Platform  3.1
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  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * View document zone
9  *
10  * @author Anakeen 2000
11  * @version $Id: viewcard.php,v 1.93 2009/01/04 18:36:37 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/Class.Doc.php");
20 include_once ("FDL/Class.DocAttr.php");
21 
22 include_once ("Class.TableLayout.php");
23 include_once ("Class.QueryDb.php");
24 include_once ("Class.QueryGen.php");
25 include_once ("FDL/freedom_util.php");
26 include_once ("FDL/family_help.php");
27 include_once ("VAULT/Class.VaultFile.php");
28 // -----------------------------------
29 // -----------------------------------
30 function viewcard(&$action)
31 {
32  // -----------------------------------
33  // GetAllParameters
34  $docid = GetHttpVars("id");
35  $abstract = (GetHttpVars("abstract", 'N') == "Y"); // view doc abstract attributes
36  $props = (GetHttpVars("props", 'N') == "Y"); // view doc properties
37  $zonebodycard = GetHttpVars("zone"); // define view action
38  $vid = GetHttpVars("vid"); // special controlled view
39  $ulink = (GetHttpVars("ulink", '2')); // add url link
40  $target = GetHttpVars("target"); // may be mail
41  $reload = ($action->read("reload$docid", "N") == "Y"); // need reload
42  if (($target != "mail") && ($target != "te")) $action->lay->set("MAILVIEW", false);
43  else $action->lay->set("MAILVIEW", true);
44  $action->lay->set("fhelp", ($action->Read("navigator", "") == "EXPLORER") ? "_blank" : "fhidden");
45  $action->lay->set('verifyfiles', false);
46  $action->lay->set('POSTIT', (GetHttpVars("postit", 'Y') == "Y"));
47 
48  if ($ulink == "N") $ulink = false;
49  else if ($ulink == "Y") $ulink = 1;
50  $action->lay->set("ulink", $ulink);
51  // Set the globals elements
52  $action->parent->AddJsRef(sprintf("%sapp=FDL&action=ALLVIEWJS&wv=%s", $action->getParam("CORE_SSTANDURL") , $action->getParam('WVERSION')));
53  /*
54  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/WHAT/Layout/AnchorPosition.js");
55  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/resizeimg.js");
56  // $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/idoc.js");
57  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/common.js");
58  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDC/Layout/setparamu.js");
59  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDC/Layout/inserthtml.js");
60  */
61  //pour les idocs
62  $jsfile = $action->GetLayoutFile("viewicard.js");
63  $jslay = new Layout($jsfile, $action);
64  $action->parent->AddJsCode($jslay->gen());
65 
66  $baseurl = $action->GetParam("CORE_BASEURL");
67  $standurl = $action->GetParam("CORE_STANDURL");
68  $dbaccess = $action->GetParam("FREEDOM_DB");
69  /*
70  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/DHTMLapi.js");
71  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/iframe.js");
72  */
73 
74  if ($reload) {
75  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/reload.js");
76  $action->unregister("reload$docid");
77  } else {
78  $action->lay->set("refreshfld", GetHttpVars("refreshfld"));
79  }
80 
82  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
83 
84  $err = $doc->control("view");
85  if ($err != "") $action->exitError($err);
86 
87  if ($doc->isConfidential()) {
88  redirect($action, "FDL", "FDL_CONFIDENTIAL&id=" . $doc->id);
89  }
90  $action->lay->set("RSS", ($doc->getValue("gui_isrss") == "yes"));
91  $action->lay->set("rsslink", $doc->getRssLink());
92  if ($doc->cvid > 0) {
93  // special controlled view
94  $cvdoc = new_Doc($dbaccess, $doc->cvid);
95  $cvdoc->set($doc);
96  if ($vid != "") {
97  $err = $cvdoc->control($vid); // control special view
98  if ($err != "") $action->exitError($err);
99  } else {
100  // search preferred view
101  $vid = $doc->getDefaultView(false, "id");
102  if ($vid) setHttpVar("vid", $vid);
103  }
104  if ($vid != "") {
105  $tview = $cvdoc->getView($vid);
106  $doc->setMask($tview["CV_MSKID"]);
107  if ($zonebodycard == "") $zonebodycard = $tview["CV_ZVIEW"];
108  }
109  }
110  // set emblem
111  $action->lay->set("emblem", $doc->getEmblem());
112  $domains = $doc->getDomainIds();
113  if (empty($domains)) {
114  $action->lay->set("inDomain", false);
115  } else {
116  $action->lay->set("inDomain", true);
117  }
118 
119  if ($doc->doctype == 'Z') {
120  $err = _("This document has been deleted");
121  } else {
122  // disabled control just to refresh
123  $doc->disableEditControl();
124  $err = $doc->refresh();
125  $err.= $doc->preConsultation();
126  $doc->enableEditControl();
127  if ($doc->hasWaitingFiles()) {
128  /*
129  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FDL/Layout/verifycomputedfiles.js");
130  */
131  $action->lay->set('verifyfiles', true);
132  }
133  }
134  // set view zone
135  if ($zonebodycard == "") {
136  $zonebodycard = $doc->defaultview;
137  }
138  if ($zonebodycard == "") {
139  $zonebodycard = "FDL:VIEWBODYCARD";
140  }
141  // with doc head ?
142  $zo = $doc->getZoneOption($zonebodycard);
143  if (GetHttpVars("dochead") == "") $dochead = (!preg_match("/[T|U|V]/", $zo, $reg));
144  else $dochead = (GetHttpVars("dochead", 'Y') == "Y");
145  $action->lay->set("viewbarmenu", ($zo == "V"));
146 
147  $action->lay->set("LGTEXTERROR", strlen($err));
148  $action->lay->set("TEXTERROR", nl2br($err));
149  $action->lay->Set("ZONEBODYCARD", $doc->viewDoc($zonebodycard, $target, $ulink, $abstract));
150  /*
151  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/geometry.js");
152  $action->parent->AddJsRef($action->GetParam("CORE_JSURL")."/subwindow.js");
153  $action->parent->AddJsRef($action->GetParam("CORE_STANDURL")."app=FDL&action=VIEWDOCJS&sesscache=".$action->session->id);
154  */
155  //------------------------------
156  // display document attributes
157  $action->lay->Set("reference", $doc->initid . (($doc->name == "") ? "" : " ({$doc->name})"));
158 
159  $action->lay->Set("revision", $doc->revision);
160 
161  $action->lay->Set("lockedid", 0);
162  $action->lay->Set("comment", $doc->comment);
163 
164  if ($doc->confidential > 0) $action->lay->Set("locked", _("confidential"));
165  else if ($doc->locked == - 1) $action->lay->Set("locked", _("fixed"));
166  else if ($doc->archiveid) $action->lay->Set("locked", _("archived"));
167  else if ($doc->control("edit") != "") $action->lay->Set("locked", _("read only"));
168  else if ($doc->locked == 0) {
169  $action->lay->Set("locked", _("not locked"));
170  } else {
171  $user = new User("", abs($doc->locked));
172  $action->lay->Set("locked", $user->firstname . " " . $user->lastname);
173  $action->lay->Set("lockedid", $user->fid);
174  }
175 
176  $action->lay->Set("dhelp", "none");
177  if ($doc->fromid > 0) {
178  $cdoc = $doc->getFamDoc();
179  $action->lay->Set("classtitle", $cdoc->getTitle());
180  if (getFamilyHelpFile($action, $doc->fromid)) {
181  $action->lay->Set("dhelp", "");
182  $action->lay->Set("helpid", $doc->fromid);
183  }
184  } else {
185  $action->lay->Set("classtitle", _("no family"));
186  }
187  $action->lay->Set("postitid", ($doc->postitid > 0) ? $doc->postitid : false);
188  $action->lay->Set("waskid", 0);
189  $action->lay->Set("latestwaskid", 0);
190 
191  if ($doc->locked != - 1) {
192  $latestidwask = $doc->getLatestIdWithAsk();
193  if ($latestidwask) {
194  $rdoc = new_doc($doc->dbaccess, $latestidwask);
195 
196  if (!$rdoc->askIsCompleted()) $action->lay->Set("latestwaskid", $latestidwask);
197  }
198  } else {
199  if (!$doc->askIsCompleted()) {
200  $action->lay->Set("waskid", "1");
201  }
202  }
203 
204  if ($doc->doctype == 'F' || $doc->doctype == 'D') {
205  $action->lay->Set("forum", (abs(intval($doc->forumid)) > 0 ? true : false));
206  } else {
207  $action->lay->Set("forum", false);
208  }
209 
210  if (($target == "mail") && ($doc->icon != "")) $action->lay->Set("iconsrc", "cid:icon");
211  else $action->lay->Set("iconsrc", $doc->geticon());
212 
213  if ($doc->fromid > 0) $action->lay->Set("cid", $doc->fromid);
214  else $action->lay->Set("cid", $doc->id);
215 
216  $action->lay->Set("viewstate", "none");
217  $action->lay->Set("state", "");
218 
219  $state = $doc->getState();
220  $action->lay->Set("statecolor", $doc->getStateColor("transparent"));
221  if ($state) { // see only if it is a transitionnal doc
222  if ($doc->locked == - 1) $action->lay->Set("state", $action->text($state));
223  else {
224  if ($doc->lmodify == 'Y') $stateaction = $doc->getStateActivity(_("current_state"));
225  else $stateaction = $doc->getStateActivity();
226  $action->lay->Set("state", sprintf("%s (<i>%s</i>)", $stateaction, $action->text($state)));
227  }
228  $action->lay->Set("viewstate", "inherit");
229  $action->lay->Set("wid", ($doc->wid > 0) ? $doc->wid : $doc->state);
230  }
231  $action->lay->Set("version", $doc->version);
232 
233  $action->lay->Set("title", $doc->getHTMLTitle());
234  $action->lay->Set("id", $docid);
235 
236  if ($abstract) {
237  // only 3 properties for abstract mode
238  $listattr = $doc->GetAbstractAttributes();
239  } else {
240  $listattr = $doc->GetNormalAttributes();
241  }
242  // see or don't see head
243  $action->lay->Set("HEAD", $dochead);
244  $action->lay->Set("ACTIONS", (getHttpVars("viewbarmenu") == 1));
245 
246  $action->lay->Set("amail", (($doc->usefor != "P") && ($doc->control('send') == "")) ? "inline" : "none");
247  // update access date
248  $doc->adate = $doc->getTimeDate(0, true);
249  $doc->modify(true, array(
250  "adate"
251  ) , true);
252  if ($doc->delUTag($action->user->id, "TOVIEW") == "") {
253  $err = $doc->addUTag($action->user->id, "VIEWED");
254  }
255 }
256 ?>
← centre documentaire © anakeen - published under CC License - Dynacase