Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Fdl/popupcard.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generate contextual popup menu for doucments
8  *
9  * @author Anakeen
10  * @version $Id: popupcard.php,v 1.62 2006/09/08 16:28:17 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/popupfam.php");
19 // -----------------------------------
21 {
22  // -----------------------------------
23  // ------------------------------
24  // define accessibility
25  $docid = GetHttpVars("id");
26  $abstract = (GetHttpVars("abstract", 'N') == "Y");
27  $headers = (GetHttpVars("props", 'N') == "Y"); // view doc properties
28  $specialmenu = GetHttpVars("specialmenu"); // view doc properties
29  $zone = GetHttpVars("zone"); // special zone
30  $dbaccess = $action->dbaccess;
31  /*
32  * @var DocFam $doc
33  */
35  $kdiv = 1; // only one division
36  $fdoc = getTDoc($dbaccess, $doc->fromid);
37 
38  $action->lay->Set("id", $doc->id);
39  $action->lay->Set("ftitle", addjsslashes($fdoc["title"]));
40  $action->lay->Set("profid", $doc->profid);
41  $action->lay->Set("ddocid", "0"); // default doc id for pre-inserted values
42  include_once ("FDL/popup_util.php");
43  // ------------------------------------------------------
44  // definition of popup menu
45  popupInit('popupcard', array(
46  'headers',
47  'latest',
48  'sview',
49  'sedit',
50  'editdoc',
51  'lockdoc',
52  'unlockdoc',
53  'revise',
54  'allocate',
55  'duplicate',
56  'histo',
57  'editprof',
58  'access',
59  'delete',
60  'toxml',
61  'reference',
62  'tobasket',
63  'addpostit',
64 
65  'chicon',
66  'chgtitle',
67  'param',
68  'defval',
69  'editattr',
70  'editcprof',
71  'editstate',
72  'editdfld',
73  'editwdoc',
74  'editcfld',
75  'properties',
76  'cancel'
77  ));
78 
79  $clf = ($doc->CanLockFile() == "");
80  $cuf = ($doc->CanUnLockFile() == "");
81  $cud = ($doc->canEdit() == "");
82 
83  popupInvisible('popupcard', $kdiv, 'toxml'); // don't display for the moment
84  popupCtrlActive('popupcard', $kdiv, 'reference');
85 
86  if (getParam("FREEDOM_IDBASKET") > 0) popupCtrlActive('popupcard', $kdiv, 'tobasket');
87  else popupInvisible('popupcard', $kdiv, 'tobasket');
88 
89  popupInvisible('popupcard', $kdiv, 'cancel');
90  if (($doc->doctype == "C") && ($cud)) {
91 
92  popupActive('popupcard', $kdiv, 'chicon');
93  } else {
94  popupInvisible('popupcard', $kdiv, 'chicon');
95  }
96 
97  popupSubMenu('popupcard', 'lockdoc', 'security');
98  popupSubMenu('popupcard', 'unlockdoc', 'security');
99  popupSubMenu('popupcard', 'editprof', 'security');
100  popupSubMenu('popupcard', 'access', 'security');
101  if ($doc->locked == $action->user->id) popupInvisible('popupcard', $kdiv, 'lockdoc');
102  else if (($doc->locked != $action->user->id) && $clf) popupCtrlActive('popupcard', $kdiv, 'lockdoc');
103  else popupInvisible('popupcard', $kdiv, 'lockdoc');
104 
105  if ($doc->isLocked()) {
106  if ($cuf) popupActive('popupcard', $kdiv, 'unlockdoc');
107  else popupInactive('popupcard', $kdiv, 'unlockdoc');
108  } else popupInvisible('popupcard', $kdiv, 'unlockdoc');
109 
110  popupCtrlActive('popupcard', $kdiv, 'allocate');
111  if (!$doc->isRevisable()) {
112  popupInvisible('popupcard', $kdiv, 'revise');
113  popupInvisible('popupcard', $kdiv, 'allocate');
114  } else if ((($doc->lmodify == 'Y') || ($doc->revision == 0)) && ($cud || $clf)) popupCtrlActive('popupcard', $kdiv, 'revise');
115  else popupCtrlInactive('popupcard', $kdiv, 'revise');
116 
117  if ($doc->IsControlled() && ($doc->profid > 0) && ($doc->Control("viewacl") == "")) {
118  popupCtrlActive('popupcard', $kdiv, 'access');
119  } else {
120  popupInvisible('popupcard', $kdiv, 'access');
121  }
122 
123  if ($doc->Control("modifyacl") == "") {
124  popupCtrlActive('popupcard', $kdiv, 'editprof');
125  popupActive('popupcard', $kdiv, 'editcprof');
126  } else {
127  popupCtrlInactive('popupcard', $kdiv, 'editprof');
128  popupInactive('popupcard', $kdiv, 'editcprof');
129  }
130  $action->lay->Set("dtitle", AddJsSlashes($doc->title));
131  if ($doc->PreDocDelete() == "") {
132  popupActive('popupcard', $kdiv, 'delete');
133  } else {
134  popupInactive('popupcard', $kdiv, 'delete');
135  }
136 
137  popupInvisible('popupcard', $kdiv, 'editstate');
138 
139  popupInvisible('popupcard', $kdiv, 'latest');
140 
141  if (($clf) || ($cud)) {
142  popupActive('popupcard', $kdiv, 'editattr');
143  popupActive('popupcard', $kdiv, 'chgtitle');
144  popupActive('popupcard', $kdiv, 'defval');
145  popupActive('popupcard', $kdiv, 'param');
146  popupActive('popupcard', $kdiv, 'editdoc');
147  popupActive('popupcard', $kdiv, 'editdfld');
148  popupActive('popupcard', $kdiv, 'editwdoc');
149  popupActive('popupcard', $kdiv, 'editcfld');
150  } else {
151  popupInactive('popupcard', $kdiv, 'editattr');
152  popupInactive('popupcard', $kdiv, 'editdfld');
153  popupInactive('popupcard', $kdiv, 'editwdoc');
154  popupInactive('popupcard', $kdiv, 'editcfld');
155  popupInactive('popupcard', $kdiv, 'chgtitle');
156  popupInactive('popupcard', $kdiv, 'defval');
157  popupInactive('popupcard', $kdiv, 'param');
158  popupCtrlInactive('popupcard', $kdiv, 'editprof');
159  popupInactive('popupcard', $kdiv, 'editdoc');
160  }
161  if ($doc->locked == - 1) { // fixed document
162  if ($doc->doctype != 'Z') popupActive('popupcard', $kdiv, 'latest');
163  popupInvisible('popupcard', $kdiv, 'editdoc');
164  popupInvisible('popupcard', $kdiv, 'delete');
165  popupInvisible('popupcard', $kdiv, 'editattr');
166  popupInvisible('popupcard', $kdiv, 'chgtitle');
167  popupInvisible('popupcard', $kdiv, 'defval');
168  popupInvisible('popupcard', $kdiv, 'param');
169  popupInvisible('popupcard', $kdiv, 'editprof');
170  popupInvisible('popupcard', $kdiv, 'revise');
171  popupInvisible('popupcard', $kdiv, 'allocate');
172  popupInvisible('popupcard', $kdiv, 'lockdoc');
173  popupInvisible('popupcard', $kdiv, 'chicon');
174  popupInvisible('popupcard', $kdiv, 'editwdoc');
175  popupInvisible('popupcard', $kdiv, 'editdfld');
176  popupInvisible('popupcard', $kdiv, 'editcfld');
177  }
178 
179  popupCtrlActive('popupcard', $kdiv, 'duplicate');
180 
181  if ($doc->locked != - 1) {
182  if ($doc->wid > 0) {
183  /*
184  * @var WDoc $wdoc
185  */
186  $wdoc = new_Doc($doc->dbaccess, $doc->wid);
187  if ($wdoc->isAlive()) {
188  $wdoc->Set($doc);
189  if (count($wdoc->GetFollowingStates()) > 0) popupActive('popupcard', $kdiv, 'editstate');
190  else popupInactive('popupcard', $kdiv, 'editstate');
191  }
192  }
193  }
194 
195  if (($doc->wid > 0) || ($doc->revision > 0)) popupActive('popupcard', $kdiv, 'histo');
196  else popupCtrlActive('popupcard', $kdiv, 'histo');
197 
198  if ($abstract) popupActive('popupcard', $kdiv, 'properties');
199  else popupInvisible('popupcard', $kdiv, 'properties');
200 
201  if (($doc->doctype != "C") || (!$action->HasPermission("FAMILY"))) {
202 
203  popupInvisible('popupcard', $kdiv, 'editcprof');
204  popupInvisible('popupcard', $kdiv, 'chgtitle');
205  popupInvisible('popupcard', $kdiv, 'defval');
206  popupInvisible('popupcard', $kdiv, 'param');
207  popupInvisible('popupcard', $kdiv, 'editattr');
208  popupInvisible('popupcard', $kdiv, 'editdfld');
209  popupInvisible('popupcard', $kdiv, 'editwdoc');
210  popupInvisible('popupcard', $kdiv, 'editcfld');
211  popupInvisible('popupcard', $kdiv, 'chicon');
212  }
213 
214  if ($doc->doctype == "C") {
215  popupInvisible('popupcard', $kdiv, 'toxml');
216  popupInvisible('popupcard', $kdiv, 'editdoc');
217  popupInvisible('popupcard', $kdiv, 'editstate');
218  popupInvisible('popupcard', $kdiv, 'delete');
219  popupInvisible('popupcard', $kdiv, 'duplicate');
220  if ($doc->dfldid == 0) popupInactive('popupcard', $kdiv, 'editcfld');
221  }
222  // if ($doc->doctype == "S") popupInvisible('popupcard',$kdiv,'editdoc');
223  if ($headers) popupInvisible('popupcard', $kdiv, 'headers');
224  else PopupCtrlactive('popupcard', $kdiv, 'headers');
225 
226  if ($doc->postitid > 0) popupInvisible('popupcard', $kdiv, 'addpostit');
227  else PopupCtrlactive('popupcard', $kdiv, 'addpostit');
228 
229  if (!$action->parent->Haspermission("FREEDOM", "FREEDOM")) {
230  // FREEDOM not available
231  // actions not available
232  popupInvisible('popupcard', $kdiv, 'editstate');
233  popupInvisible('popupcard', $kdiv, 'revise');
234  popupInvisible('popupcard', $kdiv, 'allocate');
235  popupInvisible('popupcard', $kdiv, 'editprof');
236  popupInvisible('popupcard', $kdiv, 'access');
237  popupInvisible('popupcard', $kdiv, 'tobasket');
238  }
239  if (!$action->parent->Haspermission("FREEDOM_READ", "FREEDOM")) {
240  popupInvisible('popupcard', $kdiv, 'histo');
241  }
242  // ------------
243  // add special views
244  popupInvisible('popupcard', $kdiv, 'sview');
245  popupInvisible('popupcard', $kdiv, 'sedit');
246 
247  if ($doc->cvid > 0) {
248  /*
249  * @var CVDoc $cvdoc
250  */
251  $cvdoc = new_Doc($doc->dbaccess, $doc->cvid);
252  $cvdoc->set($doc);
253  $ti = $cvdoc->getMultipleRawValues("CV_IDVIEW");
254  $tl = $cvdoc->getMultipleRawValues("CV_LVIEW");
255  $tz = $cvdoc->getMultipleRawValues("CV_ZVIEW");
256  $tk = $cvdoc->getMultipleRawValues("CV_KVIEW");
257  $tm = $cvdoc->getMultipleRawValues("CV_MSKID");
258  $td = $cvdoc->getMultipleRawValues("CV_DISPLAYED");
259 
260  $tv = array(); // consult array views
261  $te = array(); // edit array views
262  if (count($tk) > 0) {
263  foreach ($tk as $k => $v) {
264  if ($td[$k] != "no") {
265  if ($tz[$k] != "") {
266  if ($ti[$k] == "") $cvk = "CV$k";
267  else $cvk = $ti[$k];
268  if ($v == "VEDIT") {
269  if (($clf) || ($cud)) {
270  if ($cvdoc->control($cvk) == "") {
271  $te[$cvk] = array(
272  "idview" => $cvk,
273  "zoneview" => $tz[$k],
274  "txtview" => $tl[$k]
275  );
276  }
277  }
278  } else {
279  if ($cvdoc->control($cvk) == "") {
280  $tv[$cvk] = array(
281  "idview" => $cvk,
282  "zoneview" => $tz[$k],
283  "txtview" => $tl[$k]
284  );
285  }
286  }
287  }
288  }
289  }
290  $action->lay->SetBlockData("SVIEW", $tv);
291  $action->lay->SetBlockData("SEDIT", $te);
292  }
293 
294  if (count($tv) > 0) {
295  popupInit('popupview', array_keys($tv));
296  foreach ($tv as $k => $v) popupActive('popupview', $kdiv, $k);
297  popupActive('popupcard', $kdiv, 'sview');
298  } else {
299  popupInit('popupview', array(
300  'z'
301  ));
302  }
303  if (count($te) > 0) {
304  popupInit('popupedit', array_keys($te));
305  foreach ($te as $k => $v) popupActive('popupedit', $kdiv, $k);
306  popupActive('popupcard', $kdiv, 'sedit');
307  } else {
308  popupInit('popupedit', array(
309  'z'
310  ));
311  }
312  }
313 
314  $tsubmenu["security"] = array(
315  "idmenu" => "security",
316  "labelmenu" => _("Security")
317  );
318  $noctrlkey = ($action->getParam("FDL_CTRLKEY", "yes") == "no");
319  if ($noctrlkey) {
320  popupNoCtrlKey();
321  $tsubmenu["ctrlkey"] = array(
322  "idmenu" => "ctrlkey",
323  "labelmenu" => _("others...")
324  );
325  }
326 
327  popupfam($action, $tsubmenu);
328  $addidmenu = array();
329  foreach ($tsubmenu as $v) {
330  $addidmenu[] = $v["idmenu"];
331  }
332  if (count($addidmenu) > 0) {
333  foreach ($addidmenu as $v) {
334  popupAddItem('popupcard', $v);
335  $ti = popupGetSubItems('popupcard', $v);
336  Popupinvisible('popupcard', $kdiv, $v);
337  //compute the access of submenu
338  // if all items are invisibles then sub menu is invisble
339  $mctrl = false;
340  foreach ($ti as $ki => $vi) {
341  $a = popupGetAccessItem('popupcard', $kdiv, $vi);
342  if (($a == POPUP_ACTIVE) || ($a == POPUP_INACTIVE)) {
343  PopupActive('popupcard', $kdiv, $v);
344  $mctrl = false;
345  break;
346  }
347  if (($a == POPUP_CTRLACTIVE) || ($a == POPUP_CTRLINACTIVE)) {
348  $mctrl = true;
349  }
350  }
351  if ($mctrl) PopupCtrlActive('popupcard', $kdiv, $v);
352  }
353  }
354  $action->lay->SetBlockData("SUBMENU", $tsubmenu);
355  $action->lay->SetBlockData("SUBDIVMENU", $tsubmenu);
356  $action->lay->eSet("zone", $zone);
357  /*
358  if (($specialmenu!="") && (in_array($specialmenu,$doc->specialmenu))) {
359  if (method_exists($doc,$specialmenu)) {
360 
361  $tu=popupGetAccess("popupcard");
362  $doc->$specialmenu($tu);
363  popupSetAccess("popupcard",$tu);
364  }
365  }
366  */
367  popupGen();
368 }
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
global $action
const POPUP_CTRLINACTIVE
Definition: Class.Doc.php:43
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
popupcard(Action &$action)
const POPUP_CTRLACTIVE
Definition: Class.Doc.php:42
Set($name, &$parent)
const POPUP_INACTIVE
Definition: Class.Doc.php:40
$docid
Definition: cleanFamily.php:13
getParam($name, $def="")
must be in core or global type
Definition: Lib.Common.php:193
const POPUP_ACTIVE
Definition: Class.Doc.php:41
new_Doc($dbaccess, $id= '', $latest=false)
getParam($name, $def="")
$dbaccess
Definition: checkVault.php:17
popupfam(Action &$action, &$tsubmenu)
Definition: popupfam.php:19
← centre documentaire © anakeen