Core  3.2
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  * @package FDL
5 */
6 /**
7  * Specific menu for family
8  *
9  * @author Anakeen
10  * @version $Id: modattribute.php,v 1.12 2008/08/14 09:59:14 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 /**
19  * Modify an attribute inline
20  * @param Action &$action current action
21  * @global docid int Http var : document identifier to modify
22  * @global attrid string Http var : the id of attribute to modify
23  * @global value string Http var : the new value for attribute
24  * @global stayedit string Http var : stay in edition
25  */
27 {
28  $docid = GetHttpVars("docid");
29  $attrid = GetHttpVars("attrid");
30  $value = GetHttpVars("value");
31  $stayedit = (GetHttpVars("stayedit") == "yes");
32  $dbaccess = $action->dbaccess;
33 
34  header('Content-type: text/xml; charset=utf-8');
35 
36  $mb = microtime();
37 
38  $action->lay->set("CODE", "OK");
39  $action->lay->set("warning", "");
40 
41  $err = '';
43  if (!$doc->isAffected()) $err = sprintf(_("cannot see unknow reference %s") , $docid);
44 
45  if (!$stayedit) {
46  $err = $doc->unlock(true); // autounlock
47  if ($err == "") $action->AddActionDone("UNLOCKDOC", $doc->id);
48  }
49  $a = $doc->getAttribute($attrid);
50  if (($value === "") && ($a->type != "file") && ($a->type != "image") && ($a->type != "password")) $value = DELVALUE;
51 
52  if ($value != ".") {
53 
54  if ($err != "") {
55  // test object permission before modify values (no access control on values yet)
56  $err = $doc->canEdit();
57  }
58 
59  if ($err == "") {
60  if (!$a) $err = sprintf(_("unknown attribute %s for document %s") , $attrid, $doc->title);
61  if ($err == "") {
62  $vis = $a->mvisibility;
63  if (strstr("WO", $vis) === false) $err = sprintf(_("visibility %s does not allow modify attribute %s for document %s") , $vis, $a->getLabel() , $doc->title);
64  if ($err == "") {
65  if ($a->type == "file") {
66  $err = $doc->SetTextValueInFile($attrid, $value);
67  } else {
68  $err = $doc->setValue($attrid, $value);
69  }
70  if ($err == "") {
71  $err = $doc->modify();
72  if ($err == "") {
73  $action->AddActionDone("MODATTR", $a->id);
74  $doc->addHistoryEntry(sprintf(_("modify [%s] attribute") , $a->getLabel()) , HISTO_INFO, "MODATTR");
75  }
76  }
77  }
78  $action->lay->set("thetext", $doc->getHtmlAttrValue($attrid));
79  }
80  }
81  } else {
82  if ($attrid) $action->lay->set("thetext", $doc->getHtmlAttrValue($attrid));
83  }
84  if ($err != "") $action->lay->set("warning", $err);
85  $action->lay->set("count", 1);
86  $action->lay->set("delay", microtime_diff(microtime() , $mb));
87  // notify actions done
88  $action->getActionDone($actcode, $actarg);
89  $tact = array();
90  foreach ($actcode as $k => $v) {
91  $tact[] = array(
92  "acode" => $v,
93  "aarg" => $actarg[$k]
94  );
95  }
96  $action->lay->setBlockData("ACTIONS", $tact);
97  $action->clearActionDone();
98 }
global $action
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
const HISTO_INFO
$docid
Definition: cleanFamily.php:13
microtime_diff($a, $b)
Definition: Lib.Common.php:302
new_Doc($dbaccess, $id= '', $latest=false)
const DELVALUE
Definition: Class.Doc.php:46
$dbaccess
Definition: checkVault.php:17
modattribute(&$action)
if($file) if($subject==""&&$file) if($subject=="") $err
$value
← centre documentaire © anakeen