Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editinsertdocument.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Interface to inser document in folder
8  *
9  * @author Anakeen
10  * @version $Id: editinsertdocument.php,v 1.3 2008/06/03 10:12:21 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Dir.php");
18 /**
19  * View a document
20  * @param Action &$action current action
21  * @global string $id Http var : folder document identifier to see
22  * @global string $famid Http var : family to use for search
23  */
25 {
26 
27  $docid = GetHttpVars("id");
28  $famid = GetHttpVars("famid");
29 
30  if ($docid == "") $action->exitError(_("no document reference"));
31  if (!is_numeric($docid)) $docid = getIdFromName($action->dbaccess, $docid);
32  if (intval($docid) == 0) $action->exitError(sprintf(_("unknow logical reference '%s'") , GetHttpVars("id")));
33  /*
34  * @var Dir $doc
35  */
36  $doc = new_Doc($action->dbaccess, $docid);
37  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
38  if ($doc->defDoctype != 'D') $action->exitError(sprintf(_("not a static folder %s") , $doc->title));
39  $err = $doc->canModify();
40  if ($err != "") $action->exitError($err);
41  $action->parent->addJsRef('lib/jquery/jquery.js');
42  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDC/Layout/inserthtml.js");
43  $action->parent->AddJsRef($action->GetParam("CORE_STANDURL") . "app=FDL&action=EDITJS");
44  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/editinsertdocument.js");
45  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/resizeimg.js");
46 
47  $l = $doc->getContent();
48  foreach ($l as $k => $v) {
49  $l[$k]["icon"] = $doc->getIcon($v["icon"]);
50  }
51 
52  $action->lay->set("restrict", false);
53 
54  if (!$famid) {
55  $classid = 0;
56  if (method_exists($doc, "isAuthorized")) {
57  if ($doc->isAuthorized($classid)) {
58  // verify if classid is possible
59  if ($doc->hasNoRestriction()) $tclassdoc = GetClassesDoc($action->dbaccess, $action->user->id, $classid, "TABLE");
60  else {
61  $tclassdoc = $doc->getAuthorizedFamilies();
62  $action->lay->set("restrict", true);
63  }
64  } else {
65  $tclassdoc = $doc->getAuthorizedFamilies();
66  $first = current($tclassdoc);
67  $famid = $first["id"];
68  $action->lay->set("restrict", true);
69  }
70  } else {
71  $tclassdoc = GetClassesDoc($action->dbaccess, $action->user->id, $classid, "TABLE");
72  }
73  $action->lay->SetBlockData("SELECTCLASS", $tclassdoc);
74 
75  $action->lay->SetBlockData("SELECTCLASS", $tclassdoc);
76  $action->lay->set("famid", false);
77  } else {
78  $fdoc = new_Doc($action->dbaccess, $famid);
79  $action->lay->set("famid", $fdoc->id);
80  $action->lay->set("famicon", $fdoc->getIcon());
81  $action->lay->set("famtitle", sprintf(_("Search %s") , $fdoc->title));
82  }
83  $action->lay->set("docid", $doc->id);
84  $fdoc = $doc->getFamilyDocument();
85  $action->lay->eset("classtitle", $fdoc->title);
86  $action->lay->set("iconsrc", $doc->getIcon());
87  $action->lay->eset("TITLE", sprintf(_("Content managing of %s") , $doc->title));
88  $action->lay->eset("version", $doc->version);
89  $action->lay->set("hasstate", ($doc->getState() != ""));
90  $action->lay->eset("state", $doc->getState());
91  $action->lay->set("statecolor", $doc->getStateColor());
92  $action->lay->set("count", count($l));
93 
94  $action->lay->eSetBlockData("CONTENT", $l);
95  $action->lay->set("nmembers", sprintf(_("%d documents") , count($l)));
96 }
global $action
editinsertdocument(Action &$action)
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
Definition: Lib.Dir.php:906
new_Doc($dbaccess, $id= '', $latest=false)
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen