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