Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
modattr.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  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: modattr.php,v 1.31 2008/06/24 07:57:02 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 include_once ("FDL/Class.DocAttr.php");
21 include_once ("FDL/Lib.Attr.php");
22 include_once ("FDL/Class.DocFam.php");
23 include_once ("FDL/freedom_util.php");
24 // -----------------------------------
25 function modattr(&$action)
26 {
27  // Get all the params
28  $docid = GetHttpVars("docid");
29  $dirid = GetHttpVars("dirid", 0); // directory to place doc if new doc
30  $orders = GetHttpVars("order");
31  $names = GetHttpVars("name");
32  $types = GetHttpVars("type");
33  $abstracts = GetHttpVars("abstractyn");
34  $needed = GetHttpVars("neededyn");
35  $titles = GetHttpVars("titleyn");
36  $attrids = GetHttpVars("attrid");
37  $frameids = GetHttpVars("frameid");
38  $visibilities = GetHttpVars("visibility");
39  $links = GetHttpVars("link");
40  $phpfiles = GetHttpVars("phpfile");
41  $phpfuncs = GetHttpVars("phpfunc");
42  $elinks = GetHttpVars("elink");
43  $phpconstraint = GetHttpVars("phpconstraint");
44  $options = GetHttpVars("options");
45  $nattrids = GetHttpVars("nattrid"); // for new attributes
46 
47  $dbaccess = $action->GetParam("FREEDOM_DB");
48 
49  $bdfreedomattr = new DocAttr($dbaccess);
50  if ($docid == 0) {
51  $doc = new DocFam($dbaccess);
52  //---------------------------
53  // add new freedom familly
54  //---------------------------
55  $doc->title = _("new familly document");
56  $doc->owner = $action->user->id;
57  $doc->locked = $action->user->id; // lock for next modification
58  $doc->doctype = 'C'; // it is a new class document
59  $doc->fromid = GetHttpVars("classid"); // inherit from
60  $doc->profid = "0"; // NO PROFILE ACCESS
61  if (GetHttpVars("classid") > 0) {
62  $cdoc = new_Doc($dbaccess, GetHttpVars("classid"));
63  $doc->classname = "";
64  $doc->profid = $cdoc->cprofid; // inherit father profile
65 
66  }
67  $err = $doc->Add();
68  if ($err != "") $action->exitError($err);
69  } else {
70  // initialise object
72 
73  $doc->lock(true);
74  // test object permission before modify values (no access control on values yet)
75  $err = $doc->canEdit();
76  if ($err != "") $action->ExitError($err);
77  // change class document
78  $doc->fromid = GetHttpVars("classid"); // inherit from
79  $doc->Modify();
80  }
81  // ------------------------------
82  // update POSGRES attributes
83  $oattr0 = new DocAttr($dbaccess);
84  $oattr0->docid = $doc->initid;
85  $tadd = array();
86  $tmod = array();
87  while (list($k, $v) = each($orders)) {
88  // print $k.":".$v."<BR>";
89  if ($names[$k] != "") {
90  if ($attrids[$k] == "") {
91  $oattr = $oattr0;
92  $oattr->isset = false;
93  $oattr->id = $nattrids[$k];
94  } else {
95  $oattr = new DocAttr($dbaccess, array(
96  $doc->initid,
97  strtolower($attrids[$k])
98  ));
99  if (!$oattr->isAffected()) $oattr = new DocAttr($dbaccess, array(
100  $doc->initid,
101  ':' . strtolower($attrids[$k])
102  ));
103  }
104 
105  if ($oattr->id == "") print "Error line $k";
106 
107  $oattr->labeltext = stripslashes($names[$k]);
108  $oattr->title = isset($titles[$k]) ? $titles[$k] : "N";
109  $oattr->abstract = isset($abstracts[$k]) ? $abstracts[$k] : "N";
110  $oattr->needed = isset($needed[$k]) ? $needed[$k] : "N";
111  $oattr->type = stripslashes($types[$k]);
112  $oattr->frameid = isset($frameids[$k]) ? $frameids[$k] : "0";
113  $oattr->ordered = isset($orders[$k]) ? $orders[$k] : "999";
114  $oattr->visibility = $visibilities[$k];
115  $oattr->link = stripslashes($links[$k]);
116  $oattr->phpfile = $phpfiles[$k];
117  $oattr->phpfunc = stripslashes($phpfuncs[$k]);
118  $oattr->elink = stripslashes($elinks[$k]);
119  $oattr->phpconstraint = stripslashes($phpconstraint[$k]);
120  $oattr->options = stripslashes($options[$k]);
121  $oattr->usefor = 'N';
122  if (!$oattr->isAffected()) {
123  // print "add $names[$k]<BR>";
124  if (isset($nattrids[$k]) && ($nattrids[$k] != "")) $oattr->id = $nattrids[$k];
125  $err = $oattr->Add();
126  if ($err == "") $tadd[] = $oattr->id;
127  // print($err);
128 
129  } else {
130  //print_r2( "mod $names[$k] ".$visibilities[$k]);
131  $err = $oattr->Modify();
132  if ($err == "") $tmod[] = $oattr->id;
133  }
134  }
135  }
136 
137  if (count($tmod) > 0) $doc->AddComment(_("Modify Attributes") , HISTO_INFO, "MODATTR");
138  if (count($tadd) > 0) $doc->AddComment(sprintf(_("Add Attributes : %s") , implode(", ", $tadd)) , HISTO_INFO, "MODATTR");
139  $wsh = getWshCmd();
140  $cmd = $wsh . "--userid={$action->user->id} --api=fdl_adoc --docid=" . $doc->initid;
141 
142  $err = exec($cmd, $out, $ret);
143 
144  $doc->unlock(true);
145  if ($ret) $action->exitError($err);
146 
147  redirect($action, "FDL", "FDL_CARD&id=" . $doc->id, $action->GetParam("CORE_STANDURL"));
148 }
149 ?>
← centre documentaire © anakeen - published under CC License - Dynacase