Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
viewcard.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * View document zone
8  */
9 
10 include_once ("FDL/Class.Doc.php");
11 include_once ("FDL/Class.DocAttr.php");
12 
13 include_once ("Class.TableLayout.php");
14 include_once ("Class.QueryDb.php");
15 include_once ("Class.QueryGen.php");
16 include_once ("FDL/freedom_util.php");
17 include_once ("FDL/family_help.php");
18 include_once ("VAULT/Class.VaultFile.php");
19 // -----------------------------------
20 function viewcard(Action & $action)
21 {
22  // -----------------------------------
23  // GetAllParameters
24  $docid = GetHttpVars("id");
25  $abstract = (GetHttpVars("abstract", 'N') == "Y"); // view doc abstract attributes
26  $props = (GetHttpVars("props", 'N') == "Y"); // view doc properties
27  $zonebodycard = GetHttpVars("zone"); // define view action
28  $vid = GetHttpVars("vid"); // special controlled view
29  $ulink = (GetHttpVars("ulink", '2')); // add url link
30  $target = GetHttpVars("target"); // may be mail
31  $reload = ($action->read("reload$docid", "N") == "Y"); // need reload
32  if (($target != "mail") && ($target != "te")) $action->lay->set("MAILVIEW", false);
33  else $action->lay->set("MAILVIEW", true);
34  $action->lay->set("fhelp", ($action->Read("navigator", "") == "EXPLORER") ? "_blank" : "fhidden");
35  $action->lay->set('verifyfiles', false);
36  $action->lay->set('POSTIT', (GetHttpVars("postit", 'Y') == "Y"));
37 
38  if ($ulink == "N") $ulink = false;
39  else if ($ulink == "Y") $ulink = 1;
40  $action->lay->set("ulink", $ulink);
41  // Set the globals elements
42  $action->parent->AddJsRef(sprintf("?app=FDL&amp;action=ALLVIEWJS&amp;wv=%s", $action->getParam('WVERSION')));
43  $action->parent->addJsRef("lib/jquery/jquery.js");
44  $action->parent->addJsRef("lib/jquery-ui/js/jquery-ui.js");
45  $action->parent->addCssRef("css/dcp/jquery-ui.css");
46  /*
47  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/WHAT/Layout/AnchorPosition.js");
48  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/resizeimg.js");
49  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/common.js");
50  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDC/Layout/setparamu.js");
51  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDC/Layout/inserthtml.js");
52  */
53  $baseurl = $action->GetParam("CORE_BASEURL");
54  $standurl = $action->GetParam("CORE_STANDURL");
55  $dbaccess = $action->dbaccess;
56  /*
57  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/DHTMLapi.js");
58  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/iframe.js");
59  */
60  $action->parent->addJsRef("FDL/Layout/viewcard.js");
61  if ($reload) {
62  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/reload.js");
63  $action->unregister("reload$docid");
64  } else {
65  $action->lay->eset("refreshfld", GetHttpVars("refreshfld"));
66  }
67  $action->lay->eset("ITSELF", (isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : '#'));
69  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
70 
71  $err = $doc->control("view");
72  if ($err != "") {
73  redirectAsGuest($action);
74  $action->exitError($err);
75  }
76  if ($doc->isConfidential()) {
77  redirect($action, "FDL", "FDL_CONFIDENTIAL&id=" . $doc->id);
78  }
79  $useRss = ($doc->getRawValue("gui_isrss") == "yes");
80  $action->lay->set("RSS", $useRss);
81  if ($useRss) $action->lay->eset("rsslink", $doc->getRssLink());
82 
83  $param_zone_footer = json_decode($action->getParam("FOOTER_ZONE_VIEW") , true);
84  $zone_footer = array();
85  foreach ($param_zone_footer as $zone) {
86  $zone_footer[] = array(
87  "my_zone" => $zone
88  );
89  }
90  $action->lay->SetBlockData("ZONE_FOOTER", $zone_footer);
91  /*
92  * doc->cvid | vid != '' || mask to apply
93  * -----------+-----------++-----------------
94  * 0 | 0 || setMask(0)
95  * 0 | 1 || (!) Not possible as a vid is the id of a view in doc->cvid
96  * 1 | 0 || setMask(Doc::USEMASKCVVIEW)
97  * 1 | 1 || setMask(cvid->vid->mskid) OR setMask(0)
98  */
99 
100  if ($doc->wid > 0) {
101  $err = $doc->setMask(0);
102  if ($err) addWarningMsg($err);
103  }
104  if ($doc->cvid > 0) {
105  // special controlled view
106 
107  /**
108  * @var $cvdoc \Dcp\Family\CVDOC
109  */
110  $cvdoc = new_Doc($dbaccess, $doc->cvid);
111  $cvdoc = clone $cvdoc;
112  $cvdoc->Set($doc);
113  if ($vid != "") {
114  /*
115  * Apply mask from requested view
116  */
117  $err = $cvdoc->control($vid); // control special view
118  if ($err != "") $action->exitError($err);
119  $tview = $cvdoc->getView($vid);
120  $err = $doc->setMask($tview["CV_MSKID"]);
121  if ($err) addWarningMsg($err);
122  if ($zonebodycard == "") {
123  $zonebodycard = $tview["CV_ZVIEW"];
124  }
125  } else {
126  /*
127  * Apply mask from default VIEW view
128  */
129  $doc->setMask(Doc::USEMASKCVVIEW);
130  /* Propagate default view id */
131  $vid = $doc->getDefaultView(false, "id");
132  if ($vid) {
133  setHttpVar("vid", $vid);
134  if ($zonebodycard == "") {
135  $tview = $cvdoc->getView($vid);
136  $zonebodycard = $tview["CV_ZVIEW"];
137  }
138  }
139  }
140  }
141  // set emblem
142  $action->lay->set("emblem", $doc->getEmblem());
143  $domains = $doc->getDomainIds();
144  if (empty($domains)) {
145  $action->lay->set("inDomain", false);
146  } else {
147  $action->lay->set("inDomain", true);
148  }
149 
150  if ($doc->doctype === 'Z') {
151  if ($doc->lmodify === "D") {
152  $err = _("This document has been deleted");
153  } else {
154  $err = _("This revision has been deleted");
155  }
156  } else {
157  // disabled control just to refresh
158  $doc->disableEditControl();
159  $err = $doc->refresh();
160  $err.= $doc->preConsultation();
161  $doc->enableEditControl();
162  if ($doc->hasWaitingFiles()) {
163  /*
164  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/verifycomputedfiles.js");
165  */
166  $action->lay->set('verifyfiles', true);
167  }
168  }
169  // set view zone
170  if ($zonebodycard == "") {
171  $zonebodycard = $doc->defaultview;
172  }
173  if ($zonebodycard == "") {
174  $zonebodycard = "FDL:VIEWBODYCARD";
175  }
176 
177  if ($action->getParam("ISIE", null) === null) {
178  initExplorerParam($action->parent, false);
179  }
180 
181  // with doc head ?
182  $zo = $doc->getZoneOption($zonebodycard);
183  if (GetHttpVars("dochead") == "") $dochead = (!preg_match("/[T|U|V]/", $zo, $reg));
184  else $dochead = (GetHttpVars("dochead", 'Y') == "Y");
185  $action->lay->set("viewbarmenu", ($zo == "V"));
186 
187  $action->lay->set("LGTEXTERROR", strlen($err));
188  $action->lay->set("TEXTERROR", cleanhtmljs(nl2br($err)));
189  $action->lay->Set("ZONEBODYCARD", $doc->viewDoc($zonebodycard, $target, $ulink, $abstract));
190  /*
191  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/geometry.js");
192  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/subwindow.js");
193  $action->parent->AddJsRef($action->GetParam("CORE_STANDURL")."app=FDL&action=VIEWDOCJS&sesscache=".$action->session->id);
194  */
195  //------------------------------
196  // display document attributes
197  $action->lay->Set("reference", $doc->initid . (($doc->name == "") ? "" : " ({$doc->name})"));
198 
199  $action->lay->Set("revision", $doc->revision);
200  $action->lay->Set("V_TITLE", $doc->getDocAnchor($doc->id, $target));
201 
202  $action->lay->Set("lockedid", 0);
203  $action->lay->Set("comment", '');
204 
205  if ($doc->confidential > 0) $action->lay->eSet("locked", _("confidential"));
206  else if ($doc->locked == - 1) $action->lay->eSet("locked", _("fixed"));
207  else if ($doc->archiveid) $action->lay->eSet("locked", _("archived"));
208  else if ($doc->control("edit") != "") $action->lay->eSet("locked", _("read only"));
209  else if ($doc->locked == 0) {
210  $action->lay->eSet("locked", _("not locked"));
211  } else {
212  $user = new Account("", abs($doc->locked));
213  $action->lay->eSet("locked", $user->firstname . " " . $user->lastname);
214  $action->lay->Set("lockedid", $user->fid);
215  }
216 
217  $action->lay->Set("dhelp", "none");
218  if ($doc->fromid > 0) {
219  $cdoc = $doc->getFamilyDocument();
220  $action->lay->eSet("classtitle", $cdoc->getTitle());
221  if (getFamilyHelpFile($action, $doc->fromid)) {
222  $action->lay->Set("dhelp", "");
223  $action->lay->Set("helpid", $doc->fromid);
224  }
225  } else {
226  $action->lay->Set("classtitle", _("no family"));
227  }
228  $action->lay->Set("postitid", ($doc->postitid > 0) ? $doc->postitid : false);
229  $action->lay->Set("waskid", 0);
230  $action->lay->Set("latestwaskid", 0);
231 
232  if ($doc->locked != - 1) {
233  $latestidwask = $doc->getLatestIdWithAsk();
234  if ($latestidwask) {
235  $rdoc = new_doc($doc->dbaccess, $latestidwask);
236 
237  if (!$rdoc->askIsCompleted()) $action->lay->Set("latestwaskid", $latestidwask);
238  }
239  } else {
240  if (!$doc->askIsCompleted()) {
241  $action->lay->Set("waskid", "1");
242  }
243  }
244 
245  if (($target == "mail") && ($doc->icon != "")) $action->lay->Set("iconsrc", "cid:icon");
246  else $action->lay->Set("iconsrc", $doc->geticon());
247 
248  if ($doc->fromid > 0) $action->lay->Set("cid", $doc->fromid);
249  else $action->lay->Set("cid", $doc->id);
250 
251  $action->lay->Set("viewstate", "none");
252  $action->lay->Set("state", "");
253 
254  $state = $doc->getState();
255  $action->lay->Set("statecolor", $doc->getStateColor("transparent"));
256  if ($state) { // see only if it is a transitionnal doc
257  if ($doc->locked == - 1) $action->lay->eSet("state", $action->text($state));
258  else {
259 
260  $action->lay->eSet("state", $action->Text($doc->getStateActivity($doc->getState())));
261  }
262  $action->lay->Set("viewstate", "inherit");
263  $action->lay->Set("wid", ($doc->wid > 0) ? $doc->wid : $doc->state);
264  }
265  $action->lay->Set("version", $doc->version);
266 
267  $action->lay->Set("title", $doc->getHTMLTitle());
268  $action->lay->Set("id", $doc->id);
269 
270  if ($abstract) {
271  // only 3 properties for abstract mode
272  $listattr = $doc->GetAbstractAttributes();
273  } else {
274  $listattr = $doc->GetNormalAttributes();
275  }
276  // see or don't see head
277  $action->lay->Set("HEAD", $dochead);
278  $action->lay->Set("ACTIONS", (getHttpVars("viewbarmenu") == 1));
279 
280  $famMail = new_doc($dbaccess, 'MAIL');
281  $canCreateMail = $famMail->control('create') == "";
282  $action->lay->Set("amail", (($doc->usefor != "P") && $canCreateMail && ($doc->control('send') == "")) ? "inline" : "none");
283  // update access date
284  $doc->adate = $doc->getTimeDate(0, true);
285  $doc->modify(true, array(
286  "adate"
287  ) , true);
288  if ($doc->delUTag($action->user->id, "TOVIEW") == "") {
289  $err = $doc->addUTag($action->user->id, "VIEWED");
290  }
291  // Set help URL
292  $help = $doc->getHelpPage();
293  $action->lay->Set("helpurl", ($help->isAlive()) ? $help->getAttributeHelpUrl() : false);
294  $action->lay->Set("helpid", ($help->isAlive()) ? $help->id : false);
295 }
static text($code)
global $action
cleanhtmljs($html)
Definition: Lib.Util.php:624
addWarningMsg($msg)
Definition: Lib.Common.php:95
redirectAsGuest(Action &$action)
Definition: Lib.Http.php:104
Set($name, &$parent)
const USEMASKCVVIEW
Definition: Class.Doc.php:60
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
initExplorerParam(Application &$app, $defaultValue=false)
Definition: Lib.Main.php:142
getFamilyHelpFile(Action &$action, $docid)
Definition: family_help.php:34
Read($k, $d="")
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
global $_SERVER
new_Doc($dbaccess, $id= '', $latest=false)
getParam($name, $def="")
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen