Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
popupdocdetail.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: popupdocdetail.php,v 1.45 2009/01/08 17:48:40 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/popupdoc.php");
18 include_once ("FDL/Class.SearchDoc.php");
20 {
21  $docid = GetHttpVars("id");
22  if ($docid == "") $action->exitError(_("No identificator"));
23  $popup = getpopupdocdetail($action, $docid);
24  popupdoc($action, $popup);
25 }
26 
28 {
29  // define accessibility
30  $zone = GetHttpVars("zone"); // special zone
31  $dbaccess = $action->dbaccess;
33  if ($doc->isAffected()) $docid = $doc->id;
34  // if ($doc->doctype=="C") return; // not for familly
35  $tsubmenu = array();
36  // -------------------- Menu menu ------------------
37  $surl = $action->getParam("CORE_STANDURL");
38 
39  $tlink = array(
40  "headers" => array(
41  "descr" => mb_ucfirst(_("Properties")) ,
42  "url" => "$surl&app=FDL&action=IMPCARD&zone=FDL:VIEWPROPERTIES:T&id=$docid",
43  "confirm" => "false",
44  "control" => "false",
45  "tconfirm" => "",
46  "target" => "prop$docid",
47  "visibility" => POPUP_CTRLACTIVE,
48  "submenu" => "",
49  "barmenu" => "false"
50  ) ,
51  "latest" => array(
52  "descr" => mb_ucfirst(_("View latest")) ,
53  "url" => "$surl&app=FDL&action=FDL_CARD&latest=Y&id=$docid",
54  "confirm" => "false",
55  "control" => "false",
56  "tconfirm" => "",
57  "target" => "_self",
58  "visibility" => POPUP_INVISIBLE,
59  "submenu" => "",
60  "barmenu" => "false"
61  ) ,
62  "editdoc" => array(
63  "descr" => mb_ucfirst(_("Modify")) ,
64  "url" => "$surl&app=GENERIC&action=GENERIC_EDIT&rzone=$zone&id=$docid",
65  "confirm" => "false",
66  "control" => "false",
67  "tconfirm" => "",
68  "target" => "_self",
69  "visibility" => POPUP_ACTIVE,
70  "submenu" => "",
71  "barmenu" => "false"
72  )
73  );
74 
75  addCvPopup($tlink, $doc);
76  addStatesPopup($tlink, $doc);
77  $tlink = array_merge($tlink, array(
78  "delete" => array(
79  "descr" => mb_ucfirst(_("Delete")) ,
80  "url" => "$surl&app=GENERIC&action=GENERIC_DEL&id=$docid",
81  "confirm" => "true",
82  "control" => "false",
83  "tconfirm" => sprintf(_("Sure delete %s ?") , $doc->getTitle()) ,
84  "target" => "_self",
85  "visibility" => POPUP_INACTIVE,
86  "submenu" => "",
87  "barmenu" => "false"
88  ) ,
89  "restore" => array(
90  "descr" => mb_ucfirst(_("restore")) ,
91  "url" => "$surl&app=FDL&action=RESTOREDOC&id=$docid",
92  "tconfirm" => "",
93  "confirm" => "false",
94  "target" => "_self",
95  "visibility" => POPUP_INVISIBLE,
96  "submenu" => "",
97  "barmenu" => "false"
98  ) ,
99  "editstate" => array(
100  "descr" => mb_ucfirst(_("Change step")) ,
101  "url" => "$surl&app=FREEDOM&action=FREEDOM_EDITSTATE&id=$docid",
102  "confirm" => "false",
103  "control" => "false",
104  "tconfirm" => "",
105  "target" => "_self",
106  "visibility" => POPUP_INVISIBLE,
107  "submenu" => "",
108  "barmenu" => "false"
109  ) ,
110  "lockdoc" => array(
111  "descr" => mb_ucfirst(_("Lock")) ,
112  "url" => "$surl&app=FDL&action=LOCKFILE&id=$docid",
113  "confirm" => "false",
114  "control" => "false",
115  "tconfirm" => "",
116  "target" => "_self",
117  "visibility" => POPUP_INACTIVE,
118  "submenu" => N_("Security") ,
119  "barmenu" => "false"
120  ) ,
121  "unlockdoc" => array(
122  "descr" => mb_ucfirst(_("Unlock")) ,
123  "url" => "$surl&app=FDL&action=UNLOCKFILE&id=$docid",
124  "confirm" => "false",
125  "control" => "false",
126  "tconfirm" => "",
127  "target" => "_self",
128  "visibility" => POPUP_INACTIVE,
129  "submenu" => "Security",
130  "barmenu" => "false"
131  ) ,
132  "revise" => array(
133  "descr" => mb_ucfirst(_("Revise")) ,
134  "url" => "$surl&app=FREEDOM&action=REVCOMMENT&id=$docid",
135  "confirm" => "false",
136  "control" => "false",
137  "tconfirm" => "",
138  "target" => "",
139  "visibility" => POPUP_INACTIVE,
140  "submenu" => "",
141  "barmenu" => "false"
142  ) ,
143  "editprof" => array(
144  "descr" => mb_ucfirst(_("Change profile")) ,
145  "url" => "$surl&app=FREEDOM&action=EDITPROF&id=$docid",
146  "confirm" => "false",
147  "control" => "false",
148  "tconfirm" => "",
149  "target" => "",
150  "visibility" => POPUP_INACTIVE,
151  "submenu" => "Security",
152  "barmenu" => "false"
153  ) ,
154  "privateprof" => array(
155  "descr" => mb_ucfirst(_("Set private")) ,
156  "url" => "$surl&app=FREEDOM&action=MODPROF&docid=$docid&profid=private",
157  "confirm" => "false",
158  "control" => "false",
159  "tconfirm" => "",
160  "target" => "_self",
161  "visibility" => POPUP_INVISIBLE,
162  "submenu" => "Security",
163  "barmenu" => "false"
164  ) ,
165  "specprof" => array(
166  "descr" => mb_ucfirst(_("Set autonome profil")) ,
167  "url" => "$surl&app=FREEDOM&action=MODPROF&docid=$docid&profid=$docid",
168  "confirm" => "false",
169  "control" => "false",
170  "tconfirm" => "",
171  "target" => "_self",
172  "visibility" => POPUP_INVISIBLE,
173  "submenu" => "Security",
174  "barmenu" => "false"
175  ) ,
176  "publicprof" => array(
177  "descr" => mb_ucfirst(_("Set public")) ,
178  "url" => "$surl&app=FREEDOM&action=MODPROF&docid=$docid&profid=0",
179  "confirm" => "false",
180  "control" => "false",
181  "tconfirm" => "",
182  "target" => "_self",
183  "visibility" => POPUP_INVISIBLE,
184  "submenu" => "Security",
185  "barmenu" => "false"
186  ) ,
187  "histo" => array(
188  "descr" => mb_ucfirst(_("History")) ,
189  "url" => "$surl&app=FREEDOM&action=HISTO&id=$docid",
190  "confirm" => "false",
191  "control" => "false",
192  "tconfirm" => "",
193  "target" => "histo" . $doc->initid,
194  "visibility" => POPUP_INVISIBLE,
195  "submenu" => "",
196  "barmenu" => "false"
197  ) ,
198  "reaffect" => array(
199  "descr" => mb_ucfirst(_("Reaffect")) ,
200  "url" => "",
201  "jsfunction" => "popdoc(null,'$surl&app=FDL&action=EDITAFFECT&id=$docid')",
202  "confirm" => "false",
203  "control" => "false",
204  "tconfirm" => "",
205  "target" => "",
206  "visibility" => POPUP_INVISIBLE,
207  "submenu" => "",
208  "barmenu" => "false"
209  ) ,
210  "duplicate" => array(
211  "descr" => mb_ucfirst(_("Duplicate")) ,
212  "url" => "$surl&app=GENERIC&action=GENERIC_DUPLICATE&id=$docid",
213  "confirm" => "true",
214  "control" => "false",
215  "tconfirm" => _("Sure duplicate ?") ,
216  "target" => "_self",
217  "visibility" => POPUP_CTRLACTIVE,
218  "submenu" => "",
219  "barmenu" => "false"
220  ) ,
221  "access" => array(
222  "descr" => mb_ucfirst(_("goaccess")) ,
223  "url" => "$surl&app=FREEDOM&action=FREEDOM_GACCESS&id=" . $doc->id,
224  "confirm" => "false",
225  "control" => "false",
226  "tconfirm" => "",
227  "target" => "",
228  "mwidth" => 800,
229  "mheight" => 300,
230  "visibility" => POPUP_ACTIVE,
231  "submenu" => "Security",
232  "barmenu" => "false"
233  ) ,
234  "tobasket" => array(
235  "descr" => mb_ucfirst(_("Add to basket")) ,
236  "url" => "$surl&app=FREEDOM&action=ADDDIRFILE&docid=$docid&dirid=" . $action->getParam("FREEDOM_IDBASKET") ,
237  "confirm" => "false",
238  "control" => "false",
239  "tconfirm" => "",
240  "target" => "",
241  "visibility" => POPUP_CTRLACTIVE,
242  "submenu" => "",
243  "barmenu" => "false"
244  ) ,
245  "chgicon" => array(
246  "descr" => mb_ucfirst(_("Change icon")) ,
247  "url" => "$surl&app=FDL&action=EDITICON&id=$docid",
248  "confirm" => "false",
249  "control" => "false",
250  "tconfirm" => "",
251  "target" => "_self",
252  "visibility" => POPUP_INVISIBLE,
253  "submenu" => "",
254  "barmenu" => "false"
255  ) ,
256  "addpostit" => array(
257  "descr" => mb_ucfirst(_("Add postit")) ,
258  "jsfunction" => "postit('$surl&app=GENERIC&action=GENERIC_EDIT&classid=27&pit_title=&pit_idadoc=$docid',50,50,300,200)",
259  "confirm" => "false",
260  "control" => "false",
261  "tconfirm" => "",
262  "target" => "",
263  "visibility" => POPUP_ACTIVE,
264  "submenu" => "",
265  "barmenu" => "false"
266  ) ,
267  "viewask" => array(
268  "descr" => mb_ucfirst(_("View my ask")) ,
269  "jsfunction" => "viewwask('$surl&app=FDL&action=VIEWWASK&docid=$docid',50,50,300,200)",
270  "confirm" => "false",
271  "control" => "false",
272  "tconfirm" => "",
273  "target" => "",
274  "visibility" => POPUP_INVISIBLE,
275  "submenu" => "",
276  "barmenu" => "false"
277  ) ,
278  "viewanswers" => array(
279  "descr" => mb_ucfirst(_("View answers")) ,
280  "url" => "$surl&app=FDL&action=IMPCARD&zone=FDL:VIEWANSWERS&id=$docid",
281  "confirm" => "false",
282  "control" => "false",
283  "tconfirm" => "",
284  "target" => "wask" . $doc->id,
285  "visibility" => POPUP_INVISIBLE,
286  "submenu" => "",
287  "barmenu" => "false"
288  ) ,
289 
290  "toxml" => array(
291  "descr" => mb_ucfirst(_("View XML")) ,
292  "url" => "$surl&app=FDL&action=VIEWXML&id=$docid",
293  "confirm" => "false",
294  "control" => "false",
295  "tconfirm" => "",
296  "target" => "",
297  "visibility" => POPUP_CTRLACTIVE,
298  "submenu" => "",
299  "barmenu" => "false"
300  ) ,
301  "relations" => array(
302  "descr" => mb_ucfirst(_("Document relations")) ,
303  "url" => "$surl&app=FREEDOM&action=RNAVIGATE&id=$docid",
304  "confirm" => "false",
305  "control" => "false",
306  "tconfirm" => "",
307  "target" => "",
308  "visibility" => POPUP_CTRLACTIVE,
309  "submenu" => "",
310  "barmenu" => "false"
311  ) ,
312  "path" => array(
313  "descr" => mb_ucfirst(_("Access path list")) ,
314  "url" => "$surl&app=FREEDOM&action=FREEDOM_IFLD&id=$docid",
315  "confirm" => "false",
316  "control" => "false",
317  "tconfirm" => "",
318  "target" => "",
319  "visibility" => POPUP_CTRLACTIVE,
320  "submenu" => "",
321  "barmenu" => "false"
322  ) ,
323  "reference" => array(
324  "descr" => mb_ucfirst(_("Search linked documents")) ,
325  "url" => "$surl&app=GENERIC&action=GENERIC_ISEARCH&id=$docid",
326  "confirm" => "false",
327  "control" => "false",
328  "tconfirm" => "",
329  "target" => "",
330  "visibility" => POPUP_CTRLACTIVE,
331  "submenu" => "",
332  "barmenu" => "false"
333  )
334  ));
335 
336  changeMenuVisibility($action, $tlink, $doc);
337 
338  addFamilyPopup($tlink, $doc);
339  addArchivePopup($tlink, $doc);
340  addDocOfflinePopup($tlink, $doc, "_self", _("Offline menu"));
341 
342  return $tlink;
343 }
344 /**
345  * Add control view menu
346  */
347 function addArchivePopup(&$tlink, Doc & $doc, $target = "_self")
348 {
349  if ($doc->fromname == "ARCHIVING") return; // no archive archive
350  if ($doc->archiveid > 0) return;
351  $s = new SearchDoc($doc->dbaccess, "ARCHIVING");
352  $s->setObjectReturn();
353  $s->addFilter("arc_status = 'O'");
354  $s->search();
355 
356  if ($s->count() > 0) {
357  while ($archive = $s->getNextDoc()) {
358  if ($archive->control("modify") == "") {
359  $tlink["arch" . $archive->id] = array(
360  "descr" => sprintf(_("Insert in %s") , $archive->getHTMLTitle()) ,
361  "url" => "?app=FREEDOM&action=ADDDIRFILE&docid=" . $doc->initid . "&dirid=" . $archive->initid,
362  "confirm" => "false",
363  "control" => "false",
364  "tconfirm" => "",
365  "target" => "",
366  "visibility" => POPUP_ACTIVE,
367  "submenu" => _("Archive menu") ,
368  "barmenu" => "false"
369  );
370  // app=FREEDOM&action=FREEDOM_INSERTFLD&dirid=[dirid]&id=[FREEDOM_IDBASKET]
371  if (($doc->defDoctype == "S") || ($doc->defDoctype == "D")) {
372  $tlink["farch" . $archive->id] = array(
373  "descr" => sprintf(_("Insert the content in %s") , $archive->getHTMLTitle()) ,
374  "url" => "?app=FREEDOM&action=FREEDOM_INSERTFLD&dirid=" . $doc->initid . "&id=" . $archive->initid,
375  "confirm" => "true",
376  "control" => "false",
377  "tconfirm" => sprintf("Sure insert the content of %s n archive ?", $doc->getTitle()) ,
378  "target" => "",
379  "visibility" => POPUP_ACTIVE,
380  "submenu" => _("Archive menu") ,
381  "barmenu" => "false"
382  );
383  }
384  }
385  }
386  }
387 }
388 /**
389  * Additionnal menu for if document has an associated view controller
390  * @param array $tlink
391  * @param \Doc $doc
392  * @param string $target
393  */
394 function addCvPopup(&$tlink, Doc & $doc, $target = "_self")
395 {
396 
397  $rvid = getHttpVars("vid"); // for the return
398  if ($doc->cvid > 0) {
399 
400  $surl = getParam("CORE_STANDURL");
401  $cud = ($doc->CanEdit() == "");
402  $docid = $doc->id;
403  /**
404  * @var \Dcp\Family\CVDoc $cvdoc
405  */
406  $cvdoc = new_Doc($doc->dbaccess, $doc->cvid);
407  $cvdoc = clone $cvdoc;
408  $cvdoc->Set($doc);
409 
410  $tv = array(); // consult array views
411  $count = array();
412 
413  $views = $cvdoc->getDisplayableViews();
414  if (count($views) > 0) {
415  foreach ($views as $k => $viewInfo) {
416  $v = $viewInfo["cv_kview"];
417  if ($viewInfo["cv_displayed"] != "no") {
418  if ($viewInfo["cv_idview"] == "") $cvk = "CV$k";
419  else $cvk = $viewInfo["cv_idview"];
420  if ($v == "VEDIT") {
421  if ($cud) {
422  if ($cvdoc->control($cvk) == "") {
423  $tv[$cvk] = array(
424  "typeview" => N_("specialedit") , # N_("specialedit %s")
425  "idview" => $cvk,
426  "menu" => $cvdoc->getLocaleViewMenu($cvk) ,
427  "zoneview" => $viewInfo["cv_zview"],
428  "txtview" => $cvdoc->getLocaleViewLabel($cvk)
429  );
430  }
431  }
432  } else {
433  if ($cvdoc->control($cvk) == "") {
434  $tv[$cvk] = array(
435  "typeview" => N_("specialview") , # N_("specialview %s")
436  "idview" => $cvk,
437  "menu" => $cvdoc->getLocaleViewMenu($cvk) ,
438  "zoneview" => $viewInfo["cv_zview"],
439  "txtview" => $cvdoc->getLocaleViewLabel($cvk)
440  );
441  }
442  }
443  }
444  }
445  }
446  $defaultview = $doc->getDefaultView(true);
447  if ($defaultview !== 0) {
448  $tlink["editdoc"]["descr"] = $cvdoc->getLocaleViewLabel($defaultview['cv_idview']);
449  }
450 
451  $count["specialedit"] = $count["specialview"] = 0;
452  foreach ($tv as $v) {
453  if ($defaultview && $defaultview["cv_idview"] !== $v["idview"]) {
454  $count[$v["typeview"]]++;
455  }
456  }
457 
458  foreach ($tv as $v) {
459  $engine = $cvdoc->getZoneTransform($v["zoneview"]);
460  $url = ($v["typeview"] == 'specialview') ? "$surl&app=FDL&action=FDL_CARD&vid=" . $v["idview"] . "&id=$docid" : "$surl&app=GENERIC&action=GENERIC_EDIT&rvid=$rvid&vid=" . $v["idview"] . "&id=$docid";
461  if ($engine) {
462  $js = "popdoc(null,'$url')";
463  $url = "";
464  } else {
465  $js = "";
466  }
467  if ($v["menu"] != "") {
468  if ($v["menu"] == "-") $submenu = "";
469  else $submenu = $v["menu"];
470  } else {
471  $submenu = (isset($count[$v["typeview"]]) && $count[$v["typeview"]] > 1) ? $v["typeview"] : "";
472  }
473  $mtitle = $v["txtview"];
474  $target = $cvdoc->getZoneOption($v["zoneview"]) === "B" ? "_download" : $target;
475  if ((!$defaultview) || $defaultview["cv_idview"] !== $v["idview"]) {
476  $tlink[$v["idview"]] = array(
477  "descr" => $mtitle,
478  "url" => $url,
479  "jsfunction" => $js,
480  "confirm" => "false",
481  "control" => "false",
482  "tconfirm" => "",
483  "target" => $target,
484  "visibility" => POPUP_ACTIVE,
485  "submenu" => $submenu,
486  "barmenu" => "false"
487  );
488  }
489  }
490  }
491 }
492 /**
493  * Additionnal menu when workflow is detected
494  * @param array $tlink
495  * @param \Doc $doc
496  */
497 function addStatesPopup(&$tlink, Doc & $doc)
498 {
499 
500  if ($doc->wid > 0) {
501  /*
502  * @var WDoc $wdoc
503  */
504  $wdoc = new_Doc($doc->dbaccess, $doc->wid);
505  $wdoc->Set($doc, true);
506  $fstate = $wdoc->GetFollowingStates();
507 
508  $surl = getParam("CORE_STANDURL");
509  $docid = $doc->id;
510 
511  foreach ($fstate as $v) {
512  $tr = $wdoc->getTransition($doc->state, $v);
513  $jsf = "";
514 
515  if ((empty($tr["nr"])) || ((!empty($tr["ask"])) && is_array($tr["ask"]) && (count($tr["ask"]) > 0))) {
516  $jsf = sprintf("popdoc(null,'$surl&app=FDL&action=EDITCHANGESTATE&id=$docid&nstate=$v','%s',0,40,400,250)", (str_replace("'", "&rsquo;", sprintf(_("Steps")))));
517  //$jsf = sprintf("displayWindow('auto',400,'$surl&app=FDL&action=EDITCHANGESTATE&id=$docid&nstate=$v','%s')", (str_replace("'", "&rsquo;", sprintf(_("Steps")))));
518 
519  } else {
520  $jsf = sprintf("subwindow(100,100,'_self','$surl&app=FREEDOM&action=MODSTATE&newstate=$v&id=$docid');");
521  }
522  $visibility = POPUP_ACTIVE;
523  $tooltip = $wdoc->getActivity($v, mb_ucfirst(_($v)));
524  //$icon = (!$tr) ? "Images/noaccess.png" : ((is_array($tr["ask"])) ? "Images/miniask.png" : "");
525  $icon = (!$tr) ? "Images/noaccess.png" : "";
526  if ($tr && (!empty($tr["m0"]))) {
527  // verify m0
528  $err = call_user_func(array(
529  $wdoc,
530  $tr["m0"],
531  ) , $v, $wdoc->doc->state);
532  if ($err) {
533  $visibility = POPUP_INACTIVE;
534  $tooltip = $err;
535  $icon = ""; // no image "Images/nowaccess.png";
536 
537  }
538  }
539  $tlink[$v] = array(
540  "title" => $tooltip,
541  "descr" => $tr['id'] ? _($tr['id']) : $wdoc->getActivity($v, mb_ucfirst(_($v))) ,
542  "jsfunction" => $jsf,
543  "confirm" => "false",
544  "control" => "false",
545  "color" => $wdoc->getColor($v) ,
546  "tconfirm" => "",
547  "icon" => $icon,
548  "target" => "_self",
549  "visibility" => $visibility,
550  "submenu" => "chgstates", #_("chgstates")
551  "barmenu" => "false"
552  );
553  }
554  }
555 }
556 /**
557  * additional menu for family documents
558  * @param array $tlink
559  * @param Doc $doc
560  */
561 function addFamilyPopup(&$tlink, Doc & $doc)
562 {
563  $lmenu = $doc->GetMenuAttributes(true);
564  foreach ($lmenu as $k => $v) {
565  $confirm = false;
566  $control = false;
567  if (($v->getOption("onlyglobal") == "yes") && ($doc->doctype != "C")) continue;
568  if (($v->getOption("global") != "yes") && ($doc->doctype == "C")) continue;
569  if (isset($v->link[0]) && $v->link[0] == '?') {
570  $v->link = substr($v->link, 1);
571  $confirm = true;
572  }
573  if ($v->getOption("lconfirm") == "yes") $confirm = true;
574  if (isset($v->link[0]) && $v->link[0] == 'C') {
575  $v->link = substr($v->link, 1);
576  $control = true;
577  }
578  if ($v->getOption("lcontrol") == "yes") $control = true;
579  if (preg_match('/\[(.*)\](.*)/', $v->link, $reg)) {
580  $v->link = $reg[2];
581  $tlink[$k]["target"] = $reg[1];
582  } else {
583  $tlink[$k]["target"] = $v->id . "_" . $doc->id;
584  }
585  if ($v->getOption("ltarget") != "") {
586  $tlink[$k]["target"] = $v->getOption("ltarget");
587  } else if ($v->getOption("mtarget") != "") $tlink[$k]["target"] = $v->getOption("mtarget");
588  $tlink[$k]["idlink"] = $v->id;
589  $tlink[$k]["descr"] = $v->getLabel();
590  $tlink[$k]["title"] = $v->getOption("ltitle");
591  $tlink[$k]["url"] = addslashes($doc->urlWhatEncode($v->link));
592  $tlink[$k]["confirm"] = $confirm ? "true" : "false";
593  $tlink[$k]["control"] = $control;
594  $tlink[$k]["mwidth"] = $v->getOption("mwidth");
595  $tlink[$k]["mheight"] = $v->getOption("mheight");
596  $tlink[$k]["tconfirm"] = $v->getOption("tconfirm", sprintf(_("Sure %s ?") , $v->getLabel()));
597  if ($v->visibility == "H") $tlink[$k]["visibility"] = POPUP_INVISIBLE;
598  else $tlink[$k]["visibility"] = ($control) ? POPUP_CTRLACTIVE : POPUP_ACTIVE;
599  $tlink[$k]["submenu"] = $v->getOption("submenu");
600  $tlink[$k]["barmenu"] = ($v->getOption("barmenu") == "yes") ? "true" : "false";
601  if ($v->precond != "" && $tlink[$k]["url"]) {
602  $tlink[$k]["visibility"] = $doc->ApplyMethod($v->precond, POPUP_ACTIVE);
603  if ($tlink[$k]["visibility"] === false) $tlink[$k]["visibility"] = POPUP_INVISIBLE;
604  elseif ($tlink[$k]["visibility"] === true) $tlink[$k]["visibility"] = POPUP_ACTIVE;
605  }
606  if (!$tlink[$k]["url"]) $tlink[$k]["visibility"] = POPUP_INVISIBLE;
607  }
608  // -------------------- Menu action ------------------
609  $lactions = $doc->GetActionAttributes();
610  foreach ($lactions as $k => $v) {
611 
612  $confirm = false;
613  $control = false;
614  $alink = $v->getLink($doc->id);
615  if ($v->getOption("lconfirm") == "yes") $confirm = true;
616  if ($v->getOption("lcontrol") == "yes") $control = true;
617 
618  if (preg_match('/\[(.*)\](.*)/', $alink, $reg)) {
619  $alink = $reg[2];
620  $tlink[$k]["target"] = $reg[1];
621  } else {
622  $tlink[$k]["target"] = $v->id . "_" . $doc->id;
623  }
624  if ($v->getOption("ltarget") != "") {
625  $tlink[$k]["target"] = $v->getOption("ltarget");
626  } else if ($v->getOption("mtarget") != "") $tlink[$k]["target"] = $v->getOption("mtarget");
627  $tlink[$k]["barmenu"] = ($v->getOption("barmenu") == "yes") ? "true" : "false";
628  $tlink[$k]["idlink"] = $v->id;
629  $tlink[$k]["descr"] = $v->getLabel();
630  $tlink[$k]["url"] = addslashes($doc->urlWhatEncode($alink));
631  $tlink[$k]["confirm"] = $confirm ? "true" : "false";
632  $tlink[$k]["control"] = $control;
633  $tlink[$k]["mwidth"] = $v->getOption("mwidth");
634  $tlink[$k]["mheight"] = $v->getOption("mheight");
635  $tlink[$k]["tconfirm"] = sprintf(_("Sure %s ?") , $v->getLabel());
636  if ($v->visibility == "H") $tlink[$k]["visibility"] = POPUP_INVISIBLE;
637  else $tlink[$k]["visibility"] = ($control) ? POPUP_CTRLACTIVE : POPUP_ACTIVE;
638  $tlink[$k]["submenu"] = $v->getOption("submenu");
639  if ($v->precond != "") $tlink[$k]["visibility"] = $doc->ApplyMethod($v->precond, POPUP_ACTIVE);
640  }
641 }
642 /**
643  * additionnal menus when offline is installed
644  * @param array $tlink
645  * @param Doc $doc
646  * @param string $target
647  * @param string $menu
648  */
649 function addDocOfflinePopup(&$tlink, Doc & $doc, $target = "_self", $menu = 'offline')
650 {
651  if (file_exists("OFFLINE/off_popupdocfolder.php")) {
652  include_once ("OFFLINE/off_popupdocfolder.php");
653  /** @noinspection PhpUndefinedFunctionInspection */
654  addOfflinePopup($tlink, $doc, $target, $menu);
655  }
656 }
657 /**
658  * Add control view menu
659  * @param \Action $action
660  * @param array $tlink
661  * @param \Doc $doc
662  */
663 function changeMenuVisibility(Action & $action, &$tlink, Doc & $doc)
664 {
665  $cuf = ($doc->CanUnLockFile() == "");
666  $cud = ($doc->CanEdit() == "");
667  $tlink["toxml"]["visibility"] = POPUP_INVISIBLE;
668  // $tlink["reference"]["visibility"]=POPUP_CTRLACTIVE;
669  if (getParam("FREEDOM_IDBASKET") == 0 && $action->user->id == 1) {
670  /* Dynamically create basket for admin if it does not exists yet */
671  $homefld = new Dir($action->dbaccess);
672  $homefld->GetHome();
673  }
674  if (getParam("FREEDOM_IDBASKET") == 0) {
675  $tlink["tobasket"]["visibility"] = POPUP_INVISIBLE;
676  }
677 
678  if ($doc->locked == $doc->userid) $tlink["lockdoc"]["visibility"] = POPUP_INVISIBLE;
679  else if (($doc->locked != $doc->userid) && $cud) $tlink["lockdoc"]["visibility"] = POPUP_CTRLACTIVE;
680  else $tlink["lockdoc"]["visibility"] = POPUP_INVISIBLE;
681 
682  if ($doc->isLocked()) {
683  if ($cuf) $tlink["unlockdoc"]["visibility"] = POPUP_ACTIVE;
684  else $tlink["unlockdoc"]["visibility"] = POPUP_INACTIVE;
685  } else $tlink["unlockdoc"]["visibility"] = POPUP_INVISIBLE;
686 
687  if (!$doc->isRevisable()) $tlink["revise"]["visibility"] = POPUP_INVISIBLE;
688  else if ((($doc->lmodify == 'Y') || ($doc->revision == 0)) && ($cud)) $tlink["revise"]["visibility"] = POPUP_CTRLACTIVE;
689  else $tlink["revise"]["visibility"] = POPUP_CTRLINACTIVE;
690 
691  if ($doc->IsControlled() && ($doc->profid > 0) && ($doc->Control("viewacl") == "")) {
692  $tlink["access"]["visibility"] = POPUP_CTRLACTIVE;
693  } else {
694  $tlink["access"]["visibility"] = POPUP_INVISIBLE;
695  }
696 
697  if (($doc->Control("modifyacl") == "") && (!$doc->isLocked(true))) {
698  $tlink["editprof"]["visibility"] = POPUP_CTRLACTIVE;
699 
700  if (($doc->doctype != 'P') && ($doc->doctype != 'W') && ($doc->fromname != 'WASK')) {
701  if ($doc->profid != 0) $tlink["publicprof"]["visibility"] = POPUP_CTRLACTIVE;
702  if ($doc->profid == 0) $tlink["privateprof"]["visibility"] = POPUP_CTRLACTIVE;
703  } elseif (($doc->doctype == 'P') || ($doc->doctype == 'W') || ($doc->fromname == 'WASK')) {
704  if (($doc->profid == 0) || ($doc->profid != $doc->id) || ($doc->profid != $doc->initid)) $tlink["specprof"]["visibility"] = POPUP_CTRLACTIVE;
705  if ($doc->profid != 0) $tlink["publicprof"]["visibility"] = POPUP_CTRLACTIVE;
706  if (($doc->profid == 0) || ($doc->profid == $doc->id) || ($doc->profid == $doc->initid)) $tlink["editprof"]["visibility"] = POPUP_INVISIBLE;
707  }
708  } else {
709  $tlink["editprof"]["visibility"] = POPUP_CTRLINACTIVE;
710  }
711 
712  $fdoc = $doc->getFamilyDocument();
713  if ($fdoc->Control("icreate") != "") $tlink["duplicate"]["visibility"] = POPUP_INVISIBLE;
714 
715  $canDelete = ($doc->PreDocDelete() == "");
716  $tlink["delete"]["visibility"] = ($canDelete) ? POPUP_ACTIVE : POPUP_INACTIVE;
717 
718  if ($cud) {
719  $tlink["editdoc"]["visibility"] = POPUP_ACTIVE;
720  $tlink["chgicon"]["visibility"] = POPUP_CTRLACTIVE;
721  if ($doc->allocated > 0) $tlink["reaffect"]["visibility"] = POPUP_ACTIVE;
722  } else {
723  $tlink["editdoc"]["visibility"] = POPUP_INACTIVE;
724  }
725 
726  if ($doc->locked == - 1) { // fixed document
727  if ($doc->doctype != 'Z') {
728  $tmpdoc = new_Doc($doc->dbaccess, $doc->initid, true);
729  if ($tmpdoc->Control("view") == "") {
730  if (!$tmpdoc->preUndelete()) $tlink["latest"]["visibility"] = POPUP_ACTIVE;
731  }
732  } elseif ($doc->lmodify === "D") {
733  if (!$doc->preUndelete()) {
734  $tlink["restore"]["visibility"] = (!$doc->control("delete")) ? POPUP_ACTIVE : POPUP_INACTIVE;
735  }
736  } else {
737  $tlink["latest"]["visibility"] = POPUP_ACTIVE;
738  }
739  $tlink["editdoc"]["visibility"] = POPUP_INVISIBLE;
740  $tlink["delete"]["visibility"] = POPUP_INVISIBLE;
741  $tlink["editprof"]["visibility"] = POPUP_INVISIBLE;
742  $tlink["revise"]["visibility"] = POPUP_INVISIBLE;
743  $tlink["lockdoc"]["visibility"] = POPUP_INVISIBLE;
744  $tlink["publicprof"]["visibility"] = POPUP_INVISIBLE;
745  $tlink["privateprof"]["visibility"] = POPUP_INVISIBLE;
746  }
747  /*
748  if ($doc->locked != -1) {
749  if ($doc->wid > 0) {
750  $wdoc=new_Doc($doc->dbaccess, $doc->wid);
751  if ($wdoc->isAlive()) {
752  $wdoc->Set($doc);
753  if (count($wdoc->GetFollowingStates()) > 0) $tlink["editstate"]["visibility"]=POPUP_ACTIVE;
754  else $tlink["editstate"]["visibility"]=POPUP_INACTIVE;
755  }
756  }
757  }*/
758 
759  $waskes = $doc->getWasks(false);
760  if (count($waskes) > 0) {
761  if ($doc->control("wask") == "") $tlink["viewanswers"]["visibility"] = POPUP_ACTIVE;
762  $waskes = $doc->getWasks(true);
763  if (count($waskes) > 0) $tlink["viewask"]["visibility"] = POPUP_ACTIVE;
764  } else {
765  // find the wask in fixed revision
766  if (($doc->control("wask") == "") && ($doc->wid > 0)) {
767  $latestwaskid = $doc->getLatestIdWithAsk(); // change variable
768  if ($latestwaskid) {
769  $tlink["viewanswers"]["visibility"] = POPUP_ACTIVE;
770  $tlink["viewanswers"]["url"].= "&id=$latestwaskid";
771  }
772  }
773  }
774 
775  if ($doc->doctype == "F") $tlink["chgicon"]["visibility"] = POPUP_INVISIBLE;
776 
777  if (($doc->postitid > 0) || ($doc->locked == - 1)) $tlink["addpostit"]["visibility"] = POPUP_INVISIBLE;
778  else if ($doc->fromid == 27) $tlink["addpostit"]["visibility"] = POPUP_INVISIBLE; // for post it family
779  else {
780  $fnote = new_doc($doc->dbaccess, 27);
781  if ($fnote->control("icreate") != "") $tlink["addpostit"]["visibility"] = POPUP_INVISIBLE;
782  else $tlink["addpostit"]["visibility"] = POPUP_ACTIVE;
783  }
784  if (!$action->parent->Haspermission("FREEDOM", "FREEDOM")) {
785  // actions not available
786  $tlink["editstate"]["visibility"] = POPUP_INVISIBLE;
787  $tlink["revise"]["visibility"] = POPUP_INVISIBLE;
788  $tlink["editprof"]["visibility"] = POPUP_INVISIBLE;
789  $tlink["access"]["visibility"] = POPUP_INVISIBLE;
790  $tlink["tobasket"]["visibility"] = POPUP_INVISIBLE;
791  }
792  if ($action->parent->Haspermission("FREEDOM_HISTO", "FREEDOM")) {
793  $tlink["histo"]["visibility"] = POPUP_ACTIVE;
794  }
795 }
global $action
const POPUP_CTRLINACTIVE
Definition: Class.Doc.php:43
const POPUP_INVISIBLE
Definition: Class.Doc.php:44
popupdocdetail(Action &$action)
$archive
addArchivePopup(&$tlink, Doc &$doc, $target="_self")
getFamilyDocument()
Definition: Class.Doc.php:1482
addFamilyPopup(&$tlink, Doc &$doc)
getLatestIdWithAsk()
Definition: Class.Doc.php:5091
isRevisable()
Definition: Class.Doc.php:1169
const POPUP_CTRLACTIVE
Definition: Class.Doc.php:42
if($famId) $s
popupdoc(Action &$action, $tlink, $tsubmenu=array())
Definition: popupdoc.php:19
preUndelete()
Definition: Class.Doc.php:3020
getpopupdocdetail(Action &$action, $docid)
urlWhatEncode($link, $k=-1)
Definition: Class.Doc.php:6082
changeMenuVisibility(Action &$action, &$tlink, Doc &$doc)
exitError($texterr, $exit=true, $code="")
PreDocDelete()
Definition: Class.Doc.php:1647
const POPUP_INACTIVE
Definition: Class.Doc.php:40
$docid
Definition: cleanFamily.php:13
addStatesPopup(&$tlink, Doc &$doc)
isLocked($my=false)
Definition: Class.Doc.php:1449
getParam($name, $def="")
must be in core or global type
Definition: Lib.Common.php:193
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
CanUnLockFile()
Definition: Class.Doc.php:1422
mb_ucfirst($s)
Definition: Lib.Common.php:105
getTitle($id="-1", $def="", $latest=false)
Definition: Class.Doc.php:8715
const POPUP_ACTIVE
Definition: Class.Doc.php:41
new_Doc($dbaccess, $id= '', $latest=false)
getParam($name, $def="")
addDocOfflinePopup(&$tlink, Doc &$doc, $target="_self", $menu= 'offline')
$dbaccess
Definition: checkVault.php:17
getLabel($idAttr)
Definition: Class.Doc.php:2091
getZoneTransform($zone="")
Definition: Class.Doc.php:6851
if($file) if($subject==""&&$file) if($subject=="") $err
N_($s)
Definition: Lib.Common.php:18
control($aclname, $strict=false)
Definition: Class.Doc.php:6593
if(!isset($query[$parms['q']])) if($parms['desc']!= 'desc'&&$parms['desc']!= 'asc') $menu
Definition: pginfo.php:65
← centre documentaire © anakeen