Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modattribute.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Specific menu for family
9  *
10  * @author Anakeen 2000
11  * @version $Id: modattribute.php,v 1.12 2008/08/14 09:59:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 /**
21  * Modify an attribute inline
22  * @param Action &$action current action
23  * @global docid Http var : document identificator to modify
24  * @global attrid Http var : the id of attribute to modify
25  * @global value Http var : the new value for attribute
26  * @global stayedit Http var : stay in edition
27  */
29 {
30  $docid = GetHttpVars("docid");
31  $attrid = GetHttpVars("attrid");
32  $value = GetHttpVars("value");
33  $stayedit = (GetHttpVars("stayedit") == "yes");
34  $dbaccess = $action->GetParam("FREEDOM_DB");
35 
36  header('Content-type: text/xml; charset=utf-8');
37 
38  $mb = microtime();
39 
40  $action->lay->set("CODE", "OK");
41  $action->lay->set("warning", "");
42 
44  if (!$doc->isAffected()) $err = sprintf(_("cannot see unknow reference %s") , $docid);
45 
46  if (!$stayedit) {
47  $err = $doc->unlock(true); // autounlock
48  if ($err == "") $action->AddActionDone("UNLOCKDOC", $doc->id);
49  }
50  $a = $doc->getAttribute($attrid);
51  if (($value === "") && ($a->type != "file") && ($a->type != "image") && ($a->type != "password")) $value = DELVALUE;
52 
53  if ($value != ".") {
54 
55  if ($err != "") {
56  // test object permission before modify values (no access control on values yet)
57  $err = $doc->canEdit();
58  }
59 
60  if ($err == "") {
61  if (!$a) $err = sprintf(_("unknown attribute %s for document %s") , $attrid, $doc->title);
62  if ($err == "") {
63  $vis = $a->mvisibility;
64  if (strstr("WO", $vis) === false) $err = sprintf(_("visibility %s does not allow modify attribute %s for document %s") , $vis, $a->getLabel() , $doc->title);
65  if ($err == "") {
66  $value = $value;
67  if ($a->type == "file") {
68  $err = $doc->SetTextValueInFile($attrid, $value);
69  } else {
70  $err = $doc->setValue($attrid, $value);
71  }
72  if ($err == "") {
73  $err = $doc->modify();
74  if ($err == "") {
75  $action->AddActionDone("MODATTR", $a->id);
76  $doc->AddComment(sprintf(_("modify [%s] attribute") , $a->getLabel()) , HISTO_INFO, "MODATTR");
77  }
78  }
79  }
80  $action->lay->set("thetext", $doc->getHtmlAttrValue($attrid));
81  }
82  }
83  } else {
84  if ($attrid) $action->lay->set("thetext", $doc->getHtmlAttrValue($attrid));
85  }
86  if ($err != "") $action->lay->set("warning", $err);
87  $action->lay->set("count", 1);
88  $action->lay->set("delay", microtime_diff(microtime() , $mb));
89  // notify actions done
90  $action->getActionDone($actcode, $actarg);
91  $tact = array();
92  foreach ($actcode as $k => $v) {
93  $tact[] = array(
94  "acode" => $v,
95  "aarg" => $actarg[$k]
96  );
97  }
98  $action->lay->setBlockData("ACTIONS", $tact);
99  $action->clearActionDone();
100 }
101 ?>
← centre documentaire © anakeen - published under CC License - Dynacase