18 include_once (
"Class.QueryDb.php");
19 include_once (
"Lib.FileMime.php");
20 include_once (
"FDL/Class.DocCtrl.php");
21 include_once (
"FDL/freedom_util.php");
22 include_once (
"FDL/Class.DocVaultIndex.php");
23 include_once (
"FDL/Class.DocAttr.php");
24 include_once (
"FDL/Class.DocHisto.php");
25 include_once (
'FDL/Class.ADoc.php');
31 define(
"FAM_BASE", 1);
33 define(
"FAM_ACCESSDOC", 3);
34 define(
"FAM_ACCESSDIR", 4);
35 define(
"FAM_SEARCH", 5);
36 define(
"FAM_ACCESSSEARCH", 6);
37 define(
"FAM_ACCESSFAM", 23);
38 define(
"MENU_ACTIVE", 1);
39 define(
"MENU_INVISIBLE", 2);
40 define(
"MENU_INACTIVE", 0);
42 define(
'POPUP_INACTIVE', 0);
43 define(
'POPUP_ACTIVE', 1);
44 define(
'POPUP_CTRLACTIVE', 3);
45 define(
'POPUP_CTRLINACTIVE', 4);
46 define(
'POPUP_INVISIBLE', 2);
48 define(
"DELVALUE",
'DEL??');
53 define(
"MAXGDOCS", 20);
55 define(
"REGEXPFILE",
"([^\|]*)\|([0-9]*)\|?(.*)?");
56 define(
"PREGEXPFILE",
"/([^\|]*)\|([0-9]*)\|?(.*)?/");
106 "displayable" =>
true,
108 "filterable" =>
true,
113 "displayable" =>
true,
115 "filterable" =>
true,
116 "label" =>
"prop_owner"
117 ) , #
N_(
"prop_owner"),
120 "displayable" =>
true,
122 "filterable" =>
false,
123 "label" =>
"prop_icon"
124 ) , #
N_(
"prop_icon"),
127 "displayable" =>
true,
129 "filterable" =>
true,
130 "label" =>
"prop_title"
131 ) , #
N_(
"prop_title"),
134 "displayable" =>
true,
136 "filterable" =>
true,
137 "label" =>
"prop_revision"
138 ) , #
N_(
"prop_revision"),
141 "displayable" =>
true,
143 "filterable" =>
true,
144 "label" =>
"prop_version"
145 ) , #
N_(
"prop_version"),
148 "displayable" =>
true,
150 "filterable" =>
true,
151 "label" =>
"prop_initid"
152 ) , #
N_(
"prop_initid"),
155 "displayable" =>
true,
157 "filterable" =>
true,
158 "label" =>
"prop_fromid"
159 ) , #
N_(
"prop_fromid"),
162 "displayable" =>
false,
164 "filterable" =>
true,
165 "label" =>
"prop_doctype"
166 ) , #
N_(
"prop_doctype"),
169 "displayable" =>
true,
171 "filterable" =>
false,
172 "label" =>
"prop_locked"
173 ) , #
N_(
"prop_locked"),
174 "allocated" => array(
176 "displayable" =>
false,
178 "filterable" =>
true,
179 "label" =>
"prop_allocated"
180 ) , #
N_(
"prop_allocated"),
183 "displayable" =>
false,
185 "filterable" =>
false,
186 "label" =>
"prop_lmodify"
187 ) , #
N_(
"prop_lmodify"),
190 "displayable" =>
false,
192 "filterable" =>
false,
193 "label" =>
"prop_profid"
194 ) , #
N_(
"prop_profid"),
197 "displayable" =>
false,
199 "filterable" =>
false,
200 "label" =>
"prop_usefor"
201 ) , #
N_(
"prop_usefor")
203 "type" =>
"timestamp",
204 "displayable" =>
true,
206 "filterable" =>
true,
207 "label" =>
"prop_cdate"
208 ) , #
N_(
"prop_cdate")
210 "type" =>
"timestamp",
211 "displayable" =>
true,
213 "filterable" =>
true,
214 "label" =>
"prop_adate"
215 ) , #
N_(
"prop_adate"),
217 "type" =>
"timestamp",
218 "displayable" =>
true,
220 "filterable" =>
true,
221 "label" =>
"prop_revdate"
222 ) , #
N_(
"prop_revdate"),
225 "displayable" =>
false,
227 "filterable" =>
false,
228 "label" =>
"prop_comment"
229 ) , #
N_(
"prop_comment"),
230 "classname" => array(
232 "displayable" =>
false,
234 "filterable" =>
false,
235 "label" =>
"prop_classname"
236 ) , #
N_(
"prop_classname")
239 "displayable" =>
true,
241 "filterable" =>
true,
242 "label" =>
"prop_state"
243 ) , #
N_(
"prop_state"),
246 "displayable" =>
false,
248 "filterable" =>
false,
249 "label" =>
"prop_wid"
253 "displayable" =>
false,
255 "filterable" =>
false,
256 "label" =>
"prop_postitid"
257 ) , #
N_(
"prop_postitid")
260 "displayable" =>
false,
262 "filterable" =>
false,
263 "label" =>
"forum_id"
267 "displayable" =>
false,
269 "filterable" =>
false,
270 "label" =>
"prop_cvid"
271 ) , #
N_(
"prop_cvid")
274 "displayable" =>
true,
276 "filterable" =>
true,
277 "label" =>
"prop_name"
278 ) , #
N_(
"prop_name")
281 "displayable" =>
false,
283 "filterable" =>
false,
284 "label" =>
"prop_dprofid"
285 ) , #
N_(
"prop_dprofid")
288 "displayable" =>
false,
290 "filterable" =>
false,
291 "label" =>
"prop_atags"
292 ) , #
N_(
"prop_atags")
295 "displayable" =>
false,
297 "filterable" =>
false,
298 "label" =>
"prop_prelid"
299 ) , #
N_(
"prop_prelid")
300 "lockdomainid" => array(
302 "displayable" =>
true,
304 "filterable" =>
false,
305 "label" =>
"prop_lockdomainid"
306 ) , #
N_(
"prop_lockdomainid")
309 "displayable" =>
false,
311 "filterable" =>
false,
312 "label" =>
"prop_domainid"
313 ) , #
N_(
"prop_domainid")
314 "confidential" => array(
316 "displayable" =>
false,
318 "filterable" =>
true,
319 "label" =>
"prop_confidential"
320 ) , #
N_(
"prop_confidential")
322 "type" =>
"fulltext",
323 "displayable" =>
false,
325 "filterable" =>
true,
326 "label" =>
"prop_svalues"
327 ) , #
N_(
"prop_svalues")
330 "displayable" =>
false,
332 "filterable" =>
false,
333 "label" =>
"prop_ldapdn"
335 ); #
N_(
"prop_ldapdn");
532 "FDL:VIEWABSTRACTCARD",
540 "doc_initid" => array(
544 "doc_title" => array(
550 "on" =>
"name,revision,doctype"
554 "using" =>
"@FDL_FULLIDX",
557 "doc_profid" => array(
573 private $mvalues = array();
577 private $withoutControlN = 0;
578 private $withoutControl =
false;
579 private $constraintbroken =
false;
587 create table doc ( id int not null,
591 revision int DEFAULT 0,
594 doctype char DEFAULT 'F',
595 locked int DEFAULT 0,
596 archiveid int DEFAULT 0,
597 allocated int DEFAULT 0,
599 lmodify char DEFAULT 'N',
600 profid int DEFAULT 0,
601 usefor char DEFAULT 'N',
607 classname varchar(64),
610 values text DEFAULT '',
611 attrids text DEFAULT '',
619 dprofid int DEFAULT 0,
620 prelid int DEFAULT 0,
622 confidential int DEFAULT 0,
624 svalues text DEFAULT ''
626 create table docfrom ( id int not null,
629 create table docname ( name text not null,
633 create sequence seq_id_doc start 1000;
634 create sequence seq_id_tdoc start 1000000000;
635 create index i_docname on doc(name);
636 create unique index i_docir on doc(initid, revision);";
674 private $hasChanged =
false;
684 private $_maskApplied =
false;
697 if (($this->
revision == 0) && ($this->doctype !=
"T")) {
700 $this->Addcomment(_(
"document creation") ,
HISTO_INFO,
"CREATE");
702 $this->wdoc->workflowSendMailTemplate($this->state, _(
"creation"));
703 $this->wdoc->workflowAttachTimer($this->state);
704 $this->wdoc->changeAllocateUser($this->state);
706 $this->
addLog(
"create", array(
708 "title" => $this->title,
709 "fromid" => $this->fromid,
710 "fromname" => $this->fromname
717 $date = gettimeofday();
718 $this->revdate = $date[
'sec'];
719 $this->
modify(
true, array(
724 if ($this->doctype !=
"T") {
727 $this->sendTextToEngine();
728 if ($this->dprofid > 0) {
730 $this->
modify(
true, array(
737 $this->hasChanged =
false;
740 if (count($gdocs) <
MAXGDOCS && ($this->doctype !=
'C')) {
747 $this->hasChanged =
true;
751 return ($this->hasChanged ===
true);
766 if ($this->
id ==
"") {
767 if ($this->doctype ==
'T')
$res = pg_exec($this->
init_dbid() ,
"select nextval ('seq_id_tdoc')");
768 else $res = pg_exec($this->
init_dbid() ,
"select nextval ('seq_id_doc')");
769 $arr = pg_fetch_array(
$res, 0);
773 if ($this->initid ==
"") $this->initid =
$this->id;
775 if (chop($this->title) ==
"") {
777 $this->title = sprintf(_(
"untitle %s %d") ,
$fdoc->title, $this->initid);
782 if ($this->profid ==
"") $this->profid =
"0";
783 if ($this->usefor ==
"") $this->usefor =
"N";
785 if ($this->lmodify ==
"") $this->lmodify =
"N";
786 if ($this->locked ==
"") $this->locked =
"0";
787 if ($this->owner ==
"") $this->owner = $this->userid;
791 if ($this->wid > 0) {
792 $this->wdoc =
new_Doc($this->dbaccess, $this->wid);
793 if ($this->wdoc->isAlive()) {
794 if ($this->wdoc->doctype !=
'W')
$err = sprintf(_(
"creation : document %s is not a workflow") , $this->wid);
795 else $this->wdoc->Set($this);
797 }
else $err = sprintf(_(
"creation : workflow %s not exists") , $this->wid);
810 if ($this->
id ==
"")
return _(
"cannot update no initialized document");
811 if ($this->doctype ==
'I')
return _(
"cannot update inconsistent document");
812 if (!$this->withoutControl) {
813 $err = $this->control(
"edit");
816 if ($this->locked == - 1) $this->lmodify =
'N';
817 if ($this->
isFixed())
return _(
"cannot update fixed document");
818 if ($this->constraintbroken)
return (sprintf(_(
"constraint broken %s") , $this->constraintbroken));
820 if ($this->hasChanged) {
821 if (chop($this->title) ==
"") $this->title = _(
"untitle document");
823 $date = gettimeofday();
824 $this->revdate = $date[
'sec'];
826 $this->lmodify =
'Y';
839 if (isset($gdocs[$this->
id])) {
840 if ($this->nocache) unset($gdocs[$this->
id]);
845 if ($this->hasChanged) {
853 $this->sendTextToEngine();
854 $this->hasChanged =
false;
865 $layout =
'THIS:' . $aid;
867 $layout.=
'[' . $index .
']';
871 $err = sprintf(_(
"Dynamic template %s not found ") , $orifile);
874 if (!file_exists($orifile)) {
875 $err = sprintf(_(
"Dynamic template %s not found ") , $orifile);
880 $err = sprintf(_(
"Dynamic template %s not an odt file ") , $orifile);
884 $outfile = $this->
viewDoc($layout .
':B',
'ooo');
885 if (!file_exists($outfile)) {
886 $err = sprintf(_(
"viewDoc did not returned a valid file"));
890 $fh = fopen($outfile,
'rb');
892 $err = sprintf(_(
"Error opening %s file '%s'",
'outfile', $outfile));
902 $this->
AddComment(sprintf(_(
'regeneration of file template %s') , $aid));
913 $errorList = array();
914 foreach ($fa as $aid => $oattr) {
915 $opt = $oattr->getOption(
"template");
916 if ($opt ==
"dynamic" || $opt ==
"form") {
917 if ($oattr->inArray()) {
919 foreach (
$ta as $k => $v) {
922 array_push($errorList,
$err);
928 array_push($errorList,
$err);
933 if (count($errorList) > 0) {
934 return join(
"\n", $errorList);
944 include_once (
"FDL/Class.DocRel.php");
945 $or =
new DocRel($this->dbaccess);
947 $or->initRelations($this,
$force);
955 if ($this->doctype ==
'C')
return 0;
956 if ($this->fromid ==
"")
return 0;
958 $res = pg_exec($this->
init_dbid() ,
"select nextval ('seq_doc" . $this->fromid .
"')");
959 $arr = pg_fetch_array(
$res, 0);
960 $cur = intval($arr[0]) - 1;
961 $res = pg_exec($this->
init_dbid() ,
"select setval ('seq_doc" . $this->fromid .
"',$cur)");
969 if ($this->fromid == 0)
return 0;
970 if ($this->doctype ==
'C')
return 0;
973 $arr = pg_fetch_array(
$res, 0);
974 $cur = intval($arr[0]);
982 $this->withoutControlN++;
983 $this->withoutControl =
true;
990 $this->withoutControlN--;
991 if ($this->withoutControlN <= 0) {
992 $this->withoutControlN = 0;
993 $this->withoutControl =
false;
1003 if (($this->doctype ==
'F') && ($this->usefor !=
'P')) {
1005 if (
$fdoc->schar !=
"S")
return true;
1017 $values =
$from->getValues();
1019 foreach ($values as $k => $v) {
1020 $this->setValue($k, $v);
1034 if (!$cdoc)
return false;
1035 if ($this->fromid == $cdoc->fromid)
return false;
1036 if ($this->locked == - 1)
return false;
1037 if ($cdoc->fromid == 0)
return false;
1039 $f1from = $f1doc->title .
"[" . $f1doc->id .
"]";
1040 $f2doc = $cdoc->getFamDoc();
1041 $f2from = $f2doc->title .
"[" . $f2doc->id .
"]";
1045 $cdoc->revision = 0;
1057 $err = $this->
delete(
true,
false,
true);
1060 foreach ($prevalues as $k => $v) {
1061 $cdoc->setValue($k, $v);
1063 $err = $cdoc->Add(
true,
true);
1069 foreach ($values as $k => $v) {
1070 $cdoc->setValue($k, $v);
1073 $err = $cdoc->Modify();
1076 $this->
exec_query(sprintf(
"update fld set childid=%d where childid=%d", $cdoc->id, $this->initid));
1079 $this->
exec_query(sprintf(
"update fld set fromid=%d where childid=%d", $cdoc->fromid, $this->initid));
1081 $cdoc->AddComment(sprintf(_(
"convertion from %s to %s family") , $f1from, $f2from));
1085 if (isset($gdocs[$this->
id])) {
1111 public function save(&$info = null, $skipConstraint =
false)
1116 $info->constraint =
'';
1117 if (!$skipConstraint) {
1121 $info->refresh = $this->refresh();
1122 $info->postModify = $this->postModify();
1123 if ($this->hasChanged) {
1127 if (
$err ==
"") $this->addComment(_(
"save document") ,
HISTO_INFO,
"MODIFY");
1129 $info->error =
$err;
1138 public function store(&$info = null, $skipConstraint =
false)
1144 if (!$skipConstraint) {
1150 $err = $this->add();
1154 $info->refresh = $this->refresh();
1155 $info->postModify = $this->postModify();
1156 if ($this->hasChanged) {
1160 if (
$err ==
"" && (!$create)) $this->addComment(_(
"save document") ,
HISTO_INFO,
"MODIFY");
1163 $info->constraint = $constraint;
1164 $info->error =
$err;
1174 if ($this->locked == - 1) {
1175 $err = sprintf(_(
"cannot update file %s (rev %d) : fixed. Get the latest version") , $this->title, $this->
revision);
1178 if ($this->userid == 1)
return "";
1180 if ($verifyDomain && ($this->lockdomainid > 0))
$err = sprintf(_(
"document is booked in domain %s") , $this->
getTitle($this->lockdomainid));
1182 if ($this->withoutControl)
return "";
1183 if (($this->locked != 0) && (abs($this->locked) != $this->userid)) {
1184 $user =
new User(
"", abs($this->locked));
1185 if ($this->locked < - 1)
$err = sprintf(_(
"Document %s is in edition by %s.") , $this->
getTitle() ,
$user->firstname .
" " .
$user->lastname);
1186 else $err = sprintf(_(
"you are not allowed to update the file %s (rev %d) is locked by %s.") , $this->
getTitle() , $this->
revision,
$user->firstname .
" " .
$user->lastname);
1226 if ($this->userid == 1)
return "";
1228 if ($this->locked != 0) {
1229 if ($this->profid > 0)
$err = $this->
Control(
"unlock");
1230 else $err = _(
"cannot unlock");
1237 if ($this->profid > 0) {
1254 if (($this->
user->id == 1) || (abs($this->locked) == $this->userid))
return false;
1256 return (($this->locked > 0) || ($this->locked < - 1));
1265 return (($this->confidential > 0) && ($this->
controlId($this->profid,
'confidential') !=
""));
1274 if (!isset($this->famdoc) || ($this->famdoc->id != $this->fromid)) $this->famdoc =
new_Doc($this->dbaccess, $this->fromid);
1275 return $this->famdoc;
1286 $query->basic_elem->sup_where = array(
1308 if ($this->doctype ==
'C')
return $this->
getParamValue($idp, $def);
1309 if (!$this->fromid)
return false;
1311 if (!
$fdoc->isAlive())
return false;
1312 return $fdoc->getParamValue($idp, $def);
1323 include_once (
"FDL/Lib.Dir.php");
1326 if ($this->initid > 0)
$filter[] =
"initid !='" . $this->initid .
"'";
1328 if ($key2 !=
"")
$filter[] =
"$key2='" . addslashes($this->
getValue($key2)) .
"'";
1329 $tpers =
getChildDoc($this->dbaccess, 0, 0,
"ALL",
$filter, 1,
"LIST", $this->fromid);
1345 foreach (
$ldoc as $k => $v) {
1346 if ($v[
"state"] ==
$state) {
1347 if ((($v[
"locked"] == - 1) && $fixed) || (!$fixed)) {
1359 $result = pg_exec($this->
init_dbid() ,
"delete from doc where doctype='T'");
1369 if ($this->doctype ==
'Z')
return _(
"already deleted");
1370 if ($this->
isLocked(
true))
return _(
"locked");
1371 if ($this->lockdomainid > 0)
return sprintf(_(
"document is booked in domain %s") , $this->
getTitle($this->lockdomainid));
1382 $err = DbObj::delete($nopost);
1386 if ($this->name !=
'') {
1387 $this->
exec_query(sprintf(
"delete from docname where name='%s'", pg_escape_string($this->name)));
1389 $this->
exec_query(sprintf(
"delete from docfrom where id='%s'", pg_escape_string($this->
id)));
1401 final public function Delete($really =
false, $control =
true, $nopost =
false)
1407 if ($msg !=
'')
return $msg;
1410 if (abs(intval($this->forumid)) > 0) {
1411 $df =
new_Doc($this->dbaccess, abs(intval($this->forumid)));
1412 $df->delete($really, $control, $nopost);
1416 if ($this->
id !=
"") {
1418 $this->
addLog(
'delete', array(
1422 foreach ($rev as $k => $v) {
1423 $v->ReallyDelete($nopost);
1428 if ($this->doctype ==
'Z') $msg = _(
"already deleted");
1429 if ($msg !=
'')
return $msg;
1431 if (!$nopost) $msg = $this->
PreDelete();
1432 if ($msg !=
'')
return $msg;
1434 if ($this->doctype !=
'Z') {
1436 if ($this->name !=
"") $this->
exec_query(sprintf(
"delete from doc%d where name='%s' and doctype='Z'", $this->fromid, pg_escape_string($this->name)));
1437 $this->doctype =
'Z';
1438 $this->locked = - 1;
1439 $this->lmodify =
'D';
1440 $date = gettimeofday();
1441 $this->revdate = $date[
'sec'];
1444 $this->
AddComment(sprintf(_(
"delete by action %s/%s from %s") , $action->parent->name, $action->name, $_SERVER[
"REMOTE_ADDR"]) ,
HISTO_NOTICE);
1445 $this->addComment(_(
"document deleted") ,
HISTO_MESSAGE,
"DELETE");
1446 $this->
addLog(
'delete', array(
1450 $this->
modify(
true, array(
1460 foreach ($rev as $k => $v) {
1461 if ($v->doctype !=
'Z') {
1463 if ($v->locked == - 1) $v->modify(
true, array(
1479 if (($this->control(
'delete') ==
"") || ($this->userid == 1)) {
1481 $err =
simpleQuery($this->dbaccess, sprintf(
"SELECT id from only doc%d where initid = %d order by id desc limit 1", $this->fromid, $this->initid) , $latestId,
true,
true);
1483 if (!$latestId)
$err = sprintf(_(
"document %s [%d] is strange") , $this->title, $this->
id);
1487 $this->
id = $latestId;
1488 $this->lmodify =
'Y';
1489 $this->
modify(
true, array(
1497 $rev = $this->getRevisions();
1498 foreach ($rev as $k => $v) {
1499 if ($v->doctype ==
'Z') {
1500 $v->doctype = $v->defDoctype;
1501 $err.= $v->modify(
true, array(
1510 $this->
modify(
true, array(
1517 }
else return sprintf(_(
"document %s [%d] is not in the trash") , $this->
getTitle() , $this->
id);
1518 }
else return sprintf(_(
"need privilege delete to restore %s") , $this->
getTitle());
1528 final public function Affect($array, $more =
false)
1530 if (is_array($array)) {
1531 if ($more) $this->ResetMoreValues();
1532 unset($this->uperm);
1533 foreach ($array as $k => $v) {
1534 if (!is_integer($k)) {
1539 if ($more) $this->GetMoreValues();
1541 $this->isset =
true;
1550 $this->isset =
false;
1553 $this->comment =
"";
1555 foreach ($nattr as $k => $v) {
1556 if (isset($this->$k) && ($this->$k !=
"")) $this->$k =
"";
1558 unset($this->lvalues);
1571 if (!isset($this->fathers)) {
1573 $this->fathers = array();
1574 if ($this->fromid > 0) {
1576 $this->fathers =
$fdoc->GetFathersDoc();
1577 array_push($this->fathers, $this->fromid);
1580 return $this->fathers;
1588 return $this->attributes->fromids;
1596 if (
$id == 0)
return array();
1597 if ((
$id != - 1) || (!isset($this->childs))) {
1598 include_once (
"FDL/Class.SearchDoc.php");
1600 if (!isset($this->childs)) $this->childs = array();
1603 $s->addFilter(
"fromid = " .
$id);
1604 $s->noViewControl();
1607 foreach (
$table1 as $k => $v) {
1608 if ((!$controlcreate) ||
controlTdoc($v,
"icreate")) {
1609 $this->childs[$v[
"id"]] = $v;
1615 return $this->childs;
1623 $query =
new QueryDb($this->dbaccess, strtolower(get_class($this)));
1625 $query->AddQuery(
"initid = " . $this->initid);
1626 $query->order_by =
"revision DESC LIMIT $limit";
1629 if (
$query->nb == 0)
return array();
1638 final public function latestId($fixed =
false, $forcequery =
false)
1640 if ($this->
id ==
"")
return false;
1642 if (($this->locked != - 1) && (!$fixed))
return $this->id;
1643 if ($fixed && ($this->lmodify ==
"L"))
return $this->id;
1645 if (!$fixed)
return getLatestDocId($this->dbaccess, $this->initid);
1646 $query =
new QueryDb($this->dbaccess, strtolower(get_class($this)));
1647 $query->AddQuery(
"initid = " . $this->initid);
1648 if ($fixed)
$query->AddQuery(
"lmodify = 'L'");
1649 elseif ($this->doctype !=
'Z')
$query->AddQuery(
"locked != -1");
1651 $query->order_by =
"id desc";
1653 $rev =
$query->Query(0, 2,
"TABLE");
1655 if ($this->doctype !=
'Z') {
1656 if (count($rev) > 1) addWarningMsg(sprintf(
"document %d : multiple alive revision", $this->initid));
1658 return $rev[0][
"id"];
1667 $tversion = array();
1668 if (isset($this->attributes->attr)) {
1669 foreach ($this->attributes->attr as $k => $v) {
1670 if ((get_class($v) ==
"NormalAttribute") && ($v->getOption(
"version") ==
"yes")) {
1671 $tversion[] = $this->
getValue($v->id);
1675 if (count($tversion) > 0)
$version = implode(
" ", $tversion);
1685 if (isset($this->attributes->attr[$idAttr]))
return $this->attributes->attr[$idAttr]->getLabel();
1686 return _(
"unknow attribute");
1695 $prop = trim(strtolower($prop));
1696 if (!in_array($prop, $this->fields))
return false;
1697 if (isset($this->fields[$prop]))
return false;
1698 return $this->$prop;
1709 if (!$this->_maskApplied) $this->
ApplyMask();
1710 $idAttr = strtolower($idAttr);
1712 $oa = $oas[$idAttr];
1713 if (isset($this->attributes->attr[$idAttr]))
return $oa;
1724 $fromname = ($this->doctype ==
'C') ? $this->name : $this->fromname;
1725 if ($this->attributes->fromname != $fromname) {
1727 $fromid = ($this->doctype ==
'C') ? $this->
id : $this->fromid;
1728 $adocClassName =
"ADoc" .
$fromid;
1730 $GEN =
getGen($this->dbaccess);
1731 $includePath =
"FDL$GEN/Class.$classname.php";
1732 if (file_exists($includePath)) {
1733 include_once ($includePath);
1734 $this->attributes =
new $adocClassName();
1737 if (!$this->_maskApplied) $this->
ApplyMask();
1738 reset($this->attributes->attr);
1739 return $this->attributes->attr;
1750 if ($this->cvid > 0) {
1752 $cvdoc =
new_Doc($this->dbaccess, $this->cvid);
1755 $view = $cvdoc->getPrimaryView($edition);
1760 return $view[
"cv_idview"];
1762 return $view[
"cv_mskid"];
1778 if (isset($this->attributes->attr)) {
1780 foreach ($this->attributes->attr as $k => $v) {
1781 $this->attributes->attr[$k]->mvisibility = $v->visibility;
1794 $this->_maskApplied =
true;
1796 if (is_array($oas)) {
1797 foreach ($oas as $k => $v) {
1798 if ($oas[$k]) $oas[$k]->mvisibility =
ComputeVisibility($v->visibility, $v->fieldSet->mvisibility, ($v->fieldSet->fieldSet) ? $v->fieldSet->fieldSet->mvisibility :
'');
1801 if ((!
$force) && (($this->doctype ==
'C') || (($this->doctype ==
'T') && (
$mid == 0))))
return;
1806 if (($this->wid > 0) && ($this->wid != $this->
id)) {
1808 $wdoc =
new_Doc($this->dbaccess, $this->wid);
1809 if ($wdoc->isAlive()) {
1810 if ($this->
id == 0) {
1813 $mid = $wdoc->getValue($wdoc->attrPrefix .
"_MSKID" . $this->state);
1821 if ($mdoc->isAlive()) {
1822 $tvis = $mdoc->getCVisibilities();
1823 foreach ($tvis as $k => $v) {
1824 if (isset($oas[$k])) {
1825 if ($v !=
"-") $oas[$k]->mvisibility = $v;
1828 $tdiff = array_diff(array_keys($oas) , array_keys($tvis));
1830 foreach ($tdiff as $k) {
1832 $oas[$k]->mvisibility =
ComputeVisibility($v->visibility, $v->fieldSet->mvisibility, ($v->fieldSet->fieldSet) ? $v->fieldSet->fieldSet->mvisibility :
'');
1835 $tneed = $mdoc->getNeedeeds();
1836 foreach ($tneed as $k => $v) {
1837 if (isset($oas[$k])) {
1838 if ($v ==
"Y") $oas[$k]->needed =
true;
1839 else if ($v ==
"N") $oas[$k]->needed =
false;
1844 uasort($this->attributes->attr,
"tordered");
1853 if (!$this->_maskApplied) $this->
ApplyMask();
1854 if ((isset($this->attributes)) && (method_exists($this->attributes,
"GetNormalAttributes")))
return $this->attributes->GetNormalAttributes($onlyopt);
1855 else return array();
1864 if (!$this->_maskApplied) $this->
ApplyMask();
1867 foreach ($this->attributes->attr as $k => $v) {
1868 if (get_class($v) ==
"FieldSetAttribute") $tsa[$v->id] = $v;
1879 if (!$this->_maskApplied) $this->
ApplyMask();
1881 $at = $this->attributes->GetActionAttributes();
1882 foreach ($at as $k => $v) {
1883 if ($v->mvisibility !=
'H') $tsa[$v->id] = $v;
1894 if (!$this->_maskApplied) $this->
ApplyMask();
1897 if (isset($this->attributes->attr)) {
1898 foreach ($this->attributes->attr as $k => $v) {
1899 if ((get_class($v) ==
"NormalAttribute") && ($v->usefor !=
'Q') && ($v->isInAbstract)) $tsa[$v->id] = $v;
1911 if (!$this->_maskApplied) $this->
ApplyMask();
1913 if (isset($this->attributes->attr)) {
1914 foreach ($this->attributes->attr as $k => $v) {
1915 if ((get_class($v) ==
"NormalAttribute") && ($v->isInTitle)) $tsa[$v->id] = $v;
1927 if (!$this->_maskApplied) $this->
ApplyMask();
1931 if (isset($this->attributes->attr)) {
1932 foreach ($this->attributes->attr as $k => $v) {
1933 if ((get_class($v) ==
"NormalAttribute") && ($v->type ==
"docid")) {
1934 if ($v->getOption(
"isuser") !=
"") {
1935 if ($v->getOption(
"isuser") ==
"yes") $tsb[$v->id] = $v;
1937 }
else $tsa[$v->id] = $v;
1941 if ($wopt)
return $tsb;
1951 if (!$this->_maskApplied) $this->
ApplyMask();
1954 foreach ($this->attributes->attr as $k => $v) {
1955 if ((get_class($v) ==
"NormalAttribute") && (!$v->inArray()) && ($v->mvisibility !=
"I")) {
1956 if ((($this->usefor ==
"Q") && ($v->usefor ==
"Q")) || (($this->usefor !=
"Q") && ((($v->usefor !=
"Q") && (!$onlyopt)) || (($v->usefor ==
"O") && ($onlyopt))))) $tsa[$v->id] = $v;
1970 if (!$this->_maskApplied) $this->
ApplyMask();
1971 if ((isset($this->attributes)) && (method_exists($this->attributes,
"getParamAttributes")))
return $this->attributes->getParamAttributes();
1972 else return array();
1982 if (!$this->_maskApplied) $this->
ApplyMask();
1985 foreach ($this->attributes->attr as $k => $v) {
1986 if ((get_class($v) ==
"NormalAttribute") && ($v->usefor !=
'Q') && ((($v->type ==
"image") && (!$onlyfile)) || ($v->type ==
"file"))) $tsa[$v->id] = $v;
1998 $tvid =
$dvi->getVaultIds($this->
id);
2001 foreach ($tvid as $vid) {
2003 $err =
$vf->Retrieve($vid, $info);
2004 $t = get_object_vars($info);
2006 if (
$err ==
"") $tinfo[] =
$t;
2019 $tvid =
$dvi->getVaultIds($this->
id);
2020 if (count($tvid) == 0)
return false;
2023 return ($waiting !=
false);
2034 $val = $this->
getTValue($attrid,
false, $index);
2035 if (($index == - 1) && (count($val) == 1)) {
2043 if ($ofout->isAffected()) {
2044 $err = $ofout->delete();
2059 include_once (
"FDL/Lib.Vault.php");
2060 $engine = strtolower($engine);
2062 if (is_array($va))
return "";
2064 if (
getParam(
"TE_ACTIVATE") ==
"yes") {
2072 if (!$info->teng_vid) {
2074 $value = sprintf(_(
"conversion %s in progress") , $engine);
2084 $mime =
'text/plain';
2086 $mime =
'image/png';
2089 $value =
"$mime|$vidout";
2090 if (
$err ==
"")
$vf->rename($vidout, sprintf(_(
"conversion of %s in progress") .
".%s", $info->name, $engine));
2096 $vidout = $info->id_file;
2097 $vf->rename($vidout, sprintf(_(
"update of %s in progress") .
".%s", $info1->name, $engine));
2098 $value = $info->mime_s .
'|' . $info->id_file;
2102 $err =
vault_generate($this->dbaccess, $engine, $vidin, $vidout, $isimage, $this->initid);
2104 $this->addComment(sprintf(_(
"convert file %s as %s failed : %s") , $info->name, $engine,
$err) ,
HISTO_ERROR);
2108 if ($info->teng_state < 0) {
2109 if ($info->teng_state == - 1)
$value =
"convertfail.png";
2110 else $value =
"convertimpossible.png";
2112 if ($info->teng_state == 1)
$value = $info->mime_s .
'|' . $info->id_file .
'|' . $info->name;
2115 $value = $info->mime_s .
'|' . $info->id_file .
'|' . $info->name;
2129 if (!$this->_maskApplied) $this->
ApplyMask();
2132 reset($this->attributes->attr);
2133 foreach ($this->attributes->attr as $k => $v) {
2134 if (((get_class($v) ==
"MenuAttribute")) && (($v->mvisibility !=
'H') || $viewhidden)) $tsa[$v->id] = $v;
2148 foreach ($this->attributes->attr as $k => $v) {
2149 if ((get_class($v) ==
"NormalAttribute") && ($v->needed) && ($v->usefor ==
'Q')) $tsa[$v->id] = $v;
2152 if (!$this->_maskApplied) $this->
ApplyMask();
2153 foreach ($this->attributes->attr as $k => $v) {
2154 if ((get_class($v) ==
"NormalAttribute") && ($v->needed) && ($v->usefor !=
'Q')) $tsa[$v->id] = $v;
2164 foreach ($tsa as $k => $v) {
2165 if ($this->
getValue($v->id) ==
"")
$err.= sprintf(_(
"%s needed\n") , $v->getLabel());
2172 return ($this->
$a == $b);
2182 include_once (
"GENERIC/generic_util.php");
2187 if (!$this->_maskApplied) $this->
ApplyMask();
2189 if (isset($this->attributes->attr)) {
2191 if ((!$forcedefault) && ($pref !=
"")) {
2193 $tpref = explode(
";", $pref);
2195 foreach ($this->attributes->attr as $k => $v) {
2196 if (in_array($v->id, $tpref)) {
2201 foreach ($this->attributes->attr as $k => $v) {
2202 if (get_class($v) ==
"NormalAttribute") {
2204 if (($v->type !=
"array") && ($withfile || (($v->type !=
"image") && ($v->type !=
"file")))) $tsa[$v->id] = $v;
2218 if (!$this->_maskApplied) $this->
ApplyMask();
2220 $tattr = $this->attributes->attr;
2222 foreach ($tattr as $k => $v) {
2224 if ((get_class($v) ==
"NormalAttribute") && (($v->mvisibility ==
"W") || ($v->mvisibility ==
"O") || ($v->type ==
"docid")) && ($v->type !=
"array")) {
2226 if (preg_match(
"/\(([^\)]+)\):(.+)/", $v->phpfunc, $reg)) {
2228 $aout = explode(
",", $reg[2]);
2229 foreach ($aout as $ka => $va) {
2230 $ra = $this->GetAttribute($va);
2231 if ($ra) $tsa[strtolower($va) ] = $ra;
2238 uasort($tsa,
"tordered");
2251 foreach ($nattr as $k =>
$a) {
2252 if (
$a->getOption(
'sortable') !=
'yes') {
2253 if (
$a->repeat || (
$a->visibility ==
"H") || (
$a->visibility ==
"I") || (
$a->visibility ==
"O") || (
$a->type ==
"longtext") || (
$a->type ==
"xml") || ((
$a->type ==
"docid") && (
$a->getOption(
"doctitle") ==
"")) || (
$a->type ==
"htmltext") || (
$a->type ==
"image") || (
$a->type ==
"file") || (
$a->fieldSet->visibility ==
"H") || (
$a->getOption(
'sortable') ==
'no'))
continue;
2263 if ($this->doctype ==
'C')
return;
2267 foreach ($ltitle as $k => $v) {
2268 if ($this->GetValue($v->id) !=
"") {
2269 if ($v->type ==
"enum") $title1.= $this->GetHtmlValue($v, $this->GetValue($v->id)) .
" ";
2270 else $title1.= $this->GetValue($v->id) .
" ";
2273 if (chop($title1) !=
"") $this->title = mb_substr(chop(str_replace(
"\n",
" ", $title1)) , 0, 255);
2274 $this->title = mb_substr(chop(str_replace(
"\n",
" ", $this->
getSpecTitle())) , 0, 255);
2350 foreach ($ltitle as $at) {
2351 if (($at->type ==
'text') && (($at->visibility ==
'W') || ($at->visibility ==
'O')) && (!$at->inArray())) {
2359 $this->title = str_replace(
"\n",
" ",
$title);
2360 $this->setvalue($idt,
$title);
2370 $this->lvalues = array();
2373 foreach ($nattr as $k => $v) {
2374 $this->lvalues[$v->id] = $this->GetValue($v->id);
2377 $this->lvalues = array_merge($this->lvalues, $this->mvalues);
2378 reset($this->lvalues);
2379 return $this->lvalues;
2393 $lidAttr = strtolower($idAttr);
2394 if (isset($this->$lidAttr) && ($this->$lidAttr !=
""))
return $this->$lidAttr;
2407 final public function getTValue($idAttr, $def =
"", $index = - 1)
2409 $v = $this->
getValue(
"$idAttr", $def);
2411 if ($index == - 1)
return array();
2413 }
else if ($v ==
"\t") {
2414 if ($index == - 1)
return array(
2420 if ($index == - 1) {
2422 if ($oa && $oa->type ==
"xml") {
2423 foreach (
$t as $k => $v) {
2424 $t[$k] = str_replace(
'<BR>',
"\n", $v);
2429 if (isset(
$t[$index])) {
2431 if ($oa && $oa->type ==
"xml")
$t[$index] = str_replace(
'<BR>',
"\n",
$t[$index]);
2446 if (
$a->type ==
"array") {
2447 $ta = $this->attributes->getArrayElements(
$a->id);
2450 foreach (
$ta as $k => $v) {
2452 $ix = max($ix, count($tv[$k]));
2454 for ($i = 0; $i < $ix; $i++) {
2457 foreach (
$ta as $k => $v) {
2458 for ($i = 0; $i < $ix; $i++) {
2464 if ($index == - 1)
return $ti;
2465 else return $ti[$index];
2480 if (
$a->type ==
"array") {
2481 $ta = $this->attributes->getArrayElements(
$a->id);
2485 foreach (
$ta as $k => $v) {
2489 foreach ($tv as $vv) $tvu[] = $vv;
2490 $err.= $this->setValue($k, $tvu);
2494 return sprintf(_(
"%s is not an array attribute") , $idAttr);
2507 if (
$a->type ==
"array") {
2508 $ta = $this->attributes->getArrayElements(
$a->id);
2512 foreach (
$ta as $k => $v) {
2514 if ($max < 0) $max =
$c;
2516 if (
$c != $max) $maxdiff =
true;
2517 if ($max <
$c) $max =
$c;
2521 foreach (
$ta as $k => $v) {
2525 $t = array_pad(
$t, $max,
"");
2526 $err.= $this->setValue($k,
$t);
2533 return sprintf(_(
"%s is not an array attribute") , $idAttr);
2547 if (
$a->type ==
"array") {
2550 $ta = $this->attributes->getArrayElements(
$a->id);
2554 foreach (
$ta as $k => $v) {
2556 $val = $tv[strtolower($k) ];
2558 array_unshift($tnv, $val);
2559 } elseif ($index > 0 && $index < count($tnv)) {
2560 $t1 = array_slice($tnv, 0, $index);
2561 $t2 = array_slice($tnv, $index);
2562 $tnv = array_merge($t1, array(
2568 $err.= $this->setValue($k, $tnv);
2576 return sprintf(_(
"%s is not an array attribute") , $idAttr);
2594 if (!$this->withoutControl) {
2595 if ($this->
id > 0) {
2600 $attrid = strtolower($attrid);
2601 $oattr = $this->GetAttribute($attrid);
2608 if ($oattr->type ==
'htmltext') {
2614 if (count(
$value) == 0) {
2620 if ($oattr->repeat && (count(
$value) == 1) && substr(key(
$value) , 0, 1) ==
"s") {
2622 $rank = intval(substr(key(
$value) , 1));
2623 if (count($ov) < ($rank - 1)) {
2625 for ($i =
$start; $i < $rank; $i++) $ov[$i] =
"";
2627 foreach (
$value as $k => $v) $ov[substr($k, 1, 1) ] = $v;
2637 if ($oattr ===
false)
return sprintf(_(
"attribute %s unknow in family %s [%d]") , $attrid, $this->title, $this->
id);
2638 if ($oattr->mvisibility ==
"I")
return sprintf(_(
"no permission to modify this attribute %s") , $attrid);
2640 if ($oattr->type !=
"password")
$value =
" ";
2645 if ($this->$attrid !=
"") {
2646 $this->hasChanged =
true;
2648 $this->_oldvalue[$attrid] = $this->$attrid;
2649 $this->$attrid =
"";
2650 if ($oattr->type ==
"file") {
2652 $this->clearFullAttr($oattr->id);
2657 if (!isset($this->$attrid)) $this->$attrid =
"";
2659 if (strcmp($this->$attrid,
$value) != 0 && strcmp($this->$attrid, str_replace(
"\n ",
"\n",
$value)) != 0) {
2660 $this->hasChanged =
true;
2662 if ($oattr->repeat) {
2668 foreach ($tvalues as $kvalue => $avalue) {
2669 if (($avalue !=
"") && ($avalue !=
"\t")) {
2671 $avalue = trim($avalue);
2672 $tvalues[$kvalue] = $avalue;
2673 switch ($oattr->type) {
2675 if ((!strstr($avalue,
"<BR>")) && (!strstr($avalue,
"\n")) && (!is_numeric($avalue))) {
2676 $tvalues[$kvalue] =
getIdFromName($this->dbaccess, $avalue);
2681 if ($oattr->getOption(
"etype") ==
"open") {
2683 $tenum = $oattr->getEnum();
2684 $keys = array_keys($tenum);
2685 if (!in_array($avalue, $keys)) {
2686 $oattr->addEnum($this->dbaccess, $avalue, $avalue);
2692 if ($avalue ==
'-') $avalue = 0;
2693 $tvalues[$kvalue] = str_replace(
",",
".", $avalue);
2694 $tvalues[$kvalue] = str_replace(
" ",
"", $tvalues[$kvalue]);
2695 if (($avalue !=
"\t") && (!is_numeric($tvalues[$kvalue])))
return sprintf(_(
"value [%s] is not a number") , $tvalues[$kvalue]);
2699 if ($avalue ==
'-') $avalue = 0;
2700 $tvalues[$kvalue] = str_replace(
",",
".", $avalue);
2701 $tvalues[$kvalue] = str_replace(
" ",
"", $tvalues[$kvalue]);
2702 if (($avalue !=
"\t") && (!is_numeric($tvalues[$kvalue])))
return sprintf(_(
"value [%s] is not a number") , $tvalues[$kvalue]);
2703 $tvalues[$kvalue] = round(doubleval($tvalues[$kvalue]) , 2);
2708 if ($avalue ==
'-') $avalue = 0;
2709 if (($avalue !=
"\t") && (!is_numeric($avalue)))
return sprintf(_(
"value [%s] is not a number") , $avalue);
2710 if (intval($avalue) != floatval($avalue))
return sprintf(_(
"[%s] must be a integer") , $avalue);
2712 $tvalues[$kvalue] = intval($avalue);
2716 $tt = explode(
":", $avalue);
2717 if (count($tt) == 2) {
2718 list($hh, $mm) = $tt;
2719 $tvalues[$kvalue] = sprintf(
"%02d:%02d", intval($hh) % 24, intval($mm) % 60);
2720 }
else if (count($tt) == 3) {
2721 list($hh, $mm, $ss) = $tt;
2722 $tvalues[$kvalue] = sprintf(
"%02d:%02d:%02d", intval($hh) % 24, intval($mm) % 60, intval($ss) % 60);
2727 if (trim($avalue) ==
"") {
2728 if (!$oattr->repeat) $tvalues[$kvalue] =
"";
2732 if ($localeconfig !==
false) {
2733 $tvalues[$kvalue] =
stringDateToIso($avalue, $localeconfig[
'dateFormat']);
2734 if (
getLcdate() !=
"iso") $tvalues[$kvalue] = preg_replace(
'#^([0-9]{4})-([0-9]{2})-([0-9]{2})#',
'$3/$2/$1', $tvalues[$kvalue]);
2736 return sprintf(_(
"value [%s] is not a valid date") , $avalue);
2742 if (trim($avalue) ==
"") {
2743 if (!$oattr->repeat) $tvalues[$kvalue] =
"";
2746 if ($localeconfig !==
false) {
2747 $tvalues[$kvalue] =
stringDateToIso($avalue, $localeconfig[
'dateTimeFormat']);
2748 if (
getLcdate() !=
"iso") $tvalues[$kvalue] = preg_replace(
'#^([0-9]{4})-([0-9]{2})-([0-9]{2})#',
'$3/$2/$1', $tvalues[$kvalue]);
2750 return sprintf(_(
"value [%s] is not a valid timestamp") , $avalue);
2757 if ((!$oattr->repeat) || ($avalue != $this->getTValue($attrid,
"", $kvalue))) {
2759 $this->clearFullAttr($oattr->id, ($oattr->repeat) ? $kvalue : -1);
2761 $tvalues[$kvalue] = str_replace(
'\\',
'', $tvalues[$kvalue]);
2765 $tvalues[$kvalue] = str_replace(
'\\',
'', $tvalues[$kvalue]);
2769 $tvalues[$kvalue] = preg_replace(
"/<!--.*?-->/ms",
"", $tvalues[$kvalue]);
2773 $tvalues[$kvalue] = preg_replace(
'/&(gt|lt|amp|quot|apos);/',
'&\1;', $tvalues[$kvalue]);
2775 $tvalues[$kvalue] = preg_replace(
'/(<span\s+id="[0-9]+S"\s+style="display:\s*none"> <\/span>)/u',
'', $tvalues[$kvalue]);
2776 $tvalues[$kvalue] = preg_replace(
'/(<span)(\s+id="[0-9]+S"\s+style="display:\s*none")(.*)/u',
'\1\3', $tvalues[$kvalue]);
2778 $tvalues[$kvalue] = str_replace(array(
2788 ) , html_entity_decode($tvalues[$kvalue], ENT_NOQUOTES,
'UTF-8'));
2789 $tvalues[$kvalue] = str_replace(
"[",
"[", $tvalues[$kvalue]);
2790 $tvalues[$kvalue] = str_replace(
'--quoteric--',
'&quot;', $tvalues[$kvalue]);
2791 $tvalues[$kvalue] = preg_replace(
"/<\/?meta[^>]*>/s",
"", $tvalues[$kvalue]);
2792 if ($oattr->getOption(
"htmlclean") ==
"yes") {
2793 $tvalues[$kvalue] = preg_replace(
"/<\/?span[^>]*>/s",
"", $tvalues[$kvalue]);
2794 $tvalues[$kvalue] = preg_replace(
"/<\/?font[^>]*>/s",
"", $tvalues[$kvalue]);
2795 $tvalues[$kvalue] = preg_replace(
"/<style[^>]*>.*?<\/style>/s",
"", $tvalues[$kvalue]);
2796 $tvalues[$kvalue] = preg_replace(
"/<([^>]*) style=\"[^\"]*\"/s",
"<\\1", $tvalues[$kvalue]);
2797 $tvalues[$kvalue] = preg_replace(
"/<([^>]*) class=\"[^\"]*\"/s",
"<\\1", $tvalues[$kvalue]);
2803 include_once (
"FDL/Class.DocCount.php");
2804 $d =
new docCount($this->dbaccess);
2811 $tvalues[$kvalue] = str_replace(
"\r",
" ", $tvalues[$kvalue]);
2818 $this->_oldvalue[$attrid] = $this->$attrid;
2819 $this->$attrid = implode(
"\n", $tvalues);
2830 final private function clearFullAttr($attrid, $index = - 1)
2832 $attrid = strtolower($attrid);
2834 if ($oa && $oa->usefor !=
'Q') {
2835 if ($oa->getOption(
"search") !=
"no") {
2836 $ak = $attrid .
'_txt';
2837 if ($index == - 1) {
2846 $this->fields[$ak] = $ak;
2847 $ak = $attrid .
'_vec';
2849 $this->fields[$ak] = $ak;
2850 $this->fulltext =
'';
2851 $this->fields[
'fulltext'] =
'fulltext';
2852 $this->textsend[$attrid . $index] = array(
2853 "attrid" => $attrid,
2864 final private function sendTextToEngine()
2866 if (is_array($this->textsend)) {
2867 include_once (
"FDL/Lib.Vault.php");
2868 foreach ($this->textsend as $k => $v) {
2869 $index = $v[
"index"];
2870 if ($index > 0) $fval = $this->
getTValue($v[
"attrid"],
"", $index);
2871 else $fval = strtok($this->
getValue($v[
"attrid"]) ,
"\n");
2878 $this->textsend = array();
2893 foreach ($afiles as $k => $v) {
2896 if ($v->inArray()) {
2898 foreach ($tv as $kv => $vv) {
2899 $this->clearFullAttr($k, $kv);
2902 $this->clearFullAttr($k);
2909 $this->
modify(
true, $ttxt,
true);
2910 $err = $this->sendTextToEngine();
2925 if (
$a->type ==
"file") {
2926 $err =
"file conversion";
2928 $fvalue = $this->
getValue($attrid);
2937 $basename = $info->name;
2943 if ($ftitle !=
"") {
2944 $vf->Rename($vid, $ftitle);
2945 $basename = $ftitle;
2947 if ($basename !=
"") {
2948 $vf->Rename($vid, $basename);
2952 $mime = trim(shell_exec(sprintf(
"file -ib %s", escapeshellarg(
$filename))));
2953 $value =
"$mime|$vid|$basename";
2958 $this->clearFullAttr($attrid);
2977 if (
$a->type ==
"file") {
2979 $fvalue = $this->
getValue($attrid);
2988 $basename = $info->name;
3005 final public function saveFile($attrid, $stream, $ftitle =
"", $index = - 1)
3007 if (is_resource($stream) && get_resource_type($stream) ==
"stream") {
3010 if (
$a->type ==
"file") {
3011 $err =
"file conversion";
3013 if ($index > - 1) $fvalue = $this->
getTValue($attrid,
'', $index);
3014 else $fvalue = $this->
getValue($attrid);
3023 $basename = $info->name;
3029 if ($ext ==
"") $ext =
"nop";
3033 while (!feof($stream)) {
3034 if (
false === fwrite($tmpstream, fread($stream, 4096))) {
3035 $err =
"403 Forbidden";
3041 $newfile = ($basename ==
"");
3046 $prevfile =
getv($revdoc, strtolower($attrid));
3047 if ($prevfile == $fvalue) $newfile =
true;
3055 if ($ftitle !=
"") {
3057 } elseif ($basename !=
"") {
3062 else $mime = trim(shell_exec(sprintf(
"file -ib %s", escapeshellarg(
$filename))));
3063 if ($ftitle)
$value =
"$mime|$vaultid|$ftitle";
3064 else $value =
"$mime|$vaultid|$oftitle";
3065 $err = $this->setValue($attrid,
$value, $index);
3068 $this->clearFullAttr($attrid);
3075 $this->
AddComment(sprintf(_(
"modify file %s") , $ftitle));
3076 $this->hasChanged =
true;
3089 final function copyFile($idattr, $newname =
"", $index = - 1)
3091 if ($index >= 0) $f = $this->
getTValue($idattr,
"", $index);
3092 else $f = $this->
getValue($idattr);
3096 if (
$vf->Show($reg[2], $info) ==
"") {
3098 if (file_exists(
$cible)) {
3101 if (!$newname) $newname = $info->name;
3103 $vf->Rename($vid, $newname);
3105 return $reg[1] .
"|$vid|$newname";
3124 if ($index == - 1) $f = $this->
getValue($idattr);
3125 else $f = $this->
getTValue($idattr,
"", $index);
3130 if (
$vf->Show($reg[2], $info) ==
"") {
3132 if (file_exists(
$cible)) {
3134 $vf->Rename($vid, $newname);
3135 $this->setValue($idattr, $info->mime_s .
'|' . $vid .
'|' . $newname, $index);
3156 include_once (
"FDL/Lib.Vault.php");
3160 if ((
$a->type ==
"file") || (
$a->type ==
"image")) {
3164 $mime = $info->mime_s;
3165 if (!$ftitle) $ftitle = $info->name;
3166 $this->setValue($attrid,
"$mime|$vaultid|$ftitle", $index);
3169 $err = sprintf(_(
"attribute %s is not a file attribute") ,
$a->getLabel());
3172 $err = sprintf(_(
"unknow attribute %s") , $attrid);
3185 final public function storeFiles($attrid, $filenames, $ftitle =
"")
3187 if (!is_array($filenames))
return _(
"no files");
3190 if ((
$a->type ==
"file") || (
$a->type ==
"image")) {
3191 if (
$a->inArray()) {
3193 foreach ($filenames as $k =>
$filename) {
3195 include_once (
"FDL/Lib.Vault.php");
3200 $mime = $info->mime_s;
3201 if ($ftitle[$k] ==
"") $ftitle[$k] = $info->name;
3202 $tvid[] =
"$mime|$vaultid|" . $ftitle[$k];
3206 $this->setValue($attrid, $tvid);
3208 $err = sprintf(_(
"attribute %s is not int a array") ,
$a->getLabel());
3211 $err = sprintf(_(
"attribute %s is not a file attribute") ,
$a->getLabel());
3224 foreach ($fa as $aid => $oa) {
3225 if ($oa->inArray()) {
3226 $t = $this->getTvalue($oa->id);
3228 foreach (
$t as $k => $v) {
3229 $tcopy[$k] = $this->
copyFile($oa->id,
"", $k);
3231 $this->setValue($oa->id, $tcopy);
3233 $this->setValue($oa->id, $this->copyFile($oa->id));
3246 $tattrid = explode(
":", $RidAttr);
3247 $lattrid = array_pop($tattrid);
3249 foreach ($tattrid as $k => $v) {
3251 if (
$docid ==
"")
return $def;
3255 if (
$doc->locked == - 1) {
3256 $ldocid =
$doc->latestId();
3260 if (!
$doc->isAlive())
return $def;
3262 if (
$html)
return $doc->getHtmlAttrValue($lattrid, $def);
3263 else return $doc->getValue($lattrid, $def);
3274 $attrid = strtolower($attrid);
3275 if (isset($this->_oldvalue[$attrid]))
return $this->_oldvalue[$attrid];
3280 if (isset($this->_oldvalue))
return $this->_oldvalue;
3286 $oattr = $this->GetAttribute($attrid);
3287 if ($oattr->type ==
'docid') {
3288 $doctitle = $oattr->getOption(
'doctitle');
3289 if ($doctitle ==
'auto') {
3290 $doctitle = $attrid .
'_title';
3292 if (!empty($doctitle)) {
3296 return $this->
SetValue($attrid,
" ");
3301 private function GetMoreValues()
3303 if (isset($this->values)) {
3304 $tvalues = explode(
"£", $this->values);
3305 $tattrids = explode(
"£", $this->attrids);
3307 foreach ($tvalues as $k => $v) {
3308 $attrid = $tattrids[$k];
3309 if (($attrid !=
"") && ($this->$attrid ==
"")) {
3310 $this->$attrid = $v;
3311 $this->mvalues[$attrid] = $v;
3320 private function ResetMoreValues()
3322 if (isset($this->values) && $this->
id) {
3323 $tattrids = explode(
"£", $this->attrids);
3325 foreach ($tattrids as $k => $v) {
3326 $attrid = $tattrids[$k];
3327 if ($attrid) $this->$attrid =
"";
3330 $this->mvalues = array();
3352 final public function applyMethod(
$method, $def =
"", $index = - 1, array $bargs = array() , array $mapArgs = array() , &
$err =
'')
3356 if (preg_match(
'/([^:]*)::([^\(]+)\(([^\)]*)\)/',
$method, $reg)) {
3357 $staticClass = $reg[1];
3358 if (!$staticClass) $staticClass = $this;
3359 $methodName = $reg[2];
3360 $returnArgs = $reg[3];
3361 if (method_exists($staticClass, $methodName)) {
3362 if (($returnArgs ==
"") && (empty($bargs))) {
3364 $value = call_user_func(array(
3371 $sargs = $returnArgs;
3375 for ($i = 0; $i < strlen($sargs); $i++) {
3379 if ($bq ==
$c) $bq =
'';
3380 else if (($bq ==
'') && (strlen(trim($args[$ak])) == 0)) {
3383 }
else $args[$ak].=
$c;
3384 } elseif (
$c ==
',') {
3396 if (count($bargs) > 0) $args = array_merge($bargs, $args);
3398 foreach ($args as $k => $v) {
3399 if ($v !=
" ") $v = trim($v);
3400 $mapped = $mapArgs[$v];
3402 if (is_object($mapped)) $args[$k] = & $mapArgs[$v];
3403 else $args[$k] = $mapArgs[$v];
3405 if ($attr->inArray()) $args[$k] = $this->
getTValue($v,
"", $index);
3406 else $args[$k] = $this->GetValue($v);
3409 $args[$k] = & $this;
3410 } elseif ($v ==
'K') {
3412 } elseif (($v[0] ==
"'") || ($v[0] ==
'"')) {
3413 $lc = substr($v, -1);
3414 if (($lc ==
"'") || ($lc ==
'"')) $v = substr($v, 1, -1);
3415 else $v = substr($v, 1);
3422 $value = call_user_func_array(array(
3428 $err = sprintf(_(
"Method [%s] not exists") ,
$method);
3429 addWarningMsg(
$err);
3450 if (strlen(trim($oattr->phpconstraint)) > 1) {
3452 "err" => sprintf(_(
"method %s not found") , $oattr->phpconstraint) ,
3457 if (
$res !==
true) {
3458 if (!is_array(
$res)) {
3460 "err" => _(
"constraint error")
3462 elseif (is_string(
$res))
$res = array(
3465 } elseif (
$res[
"sug"] && (!is_array(
$res[
"sug"])))
$res[
"sug"] = array(
3468 if (is_array(
$res) &&
$res[
"err"] !=
"") $this->constraintbroken =
"[$attrid] " .
$res[
"err"];
3486 foreach ($listattr as $k => $v) {
3487 if (strlen($v->phpconstraint) > 1) {
3488 if ($v->inArray()) {
3490 for ($i = 0; $i < count($tv); $i++) {
3492 if (
$res[
"err"] !=
"") {
3493 $info[$v->id . $i] = array(
3495 "label" => $v->getLabel() ,
3496 "sug" =>
$res[
"sug"],
3497 "err" =>
$res[
"err"],
3499 "pid" => $v->fieldSet->id
3501 if ($stoptofirst)
return sprintf(
"[%s] %s", $v->getLabel() ,
$res[
"err"]);
3507 if (
$res[
"err"] !=
"") {
3508 $info[$v->id] = array(
3510 "label" => $v->getLabel() ,
3511 "pid" => $v->fieldSet->id,
3512 "sug" =>
$res[
"sug"],
3513 "err" =>
$res[
"err"]
3515 if ($stoptofirst)
return sprintf(
"[%s] %s", $v->getLabel() ,
$res[
"err"]);
3529 if (count(
$t) > 0)
return current(
$t);
3543 if ($this->
id ==
"")
return;
3545 $h =
new DocHisto($this->dbaccess);
3551 $h->date = date(
"d-m-Y H:i:s");
3555 $h->uname = sprintf(
"%s %s",
$u->firstname,
$u->lastname);
3557 $h->uname = sprintf(
"%s %s", $action->user->firstname, $action->user->lastname);
3558 $h->uid = $action->user->id;
3565 error_log(sprintf(
"document %s [%d] : %s", $this->title, $this->
id,
$comment));
3581 if (($this->
id ==
"") || ($this->doctype ==
'T'))
return;
3583 include_once (
"FDL/Class.DocLog.php");
3584 $h =
new DocLog($this->dbaccess);
3594 $h->uname = sprintf(
"%s %s",
$u->firstname,
$u->lastname);
3596 $h->uname = sprintf(
"%s %s", $action->user->firstname, $action->user->lastname);
3597 $h->uid = $action->user->id;
3601 if (
$arg) $h->arg = serialize(
$arg);
3614 include_once (
"Class.QueryDb.php");
3615 $q =
new QueryDb($this->dbaccess,
"dochisto");
3616 if (
$allrev)
$q->AddQuery(
"initid=" . $this->initid);
3617 else $q->AddQuery(
"id=" . $this->
id);
3618 if ($code)
$q->addQuery(sprintf(
"code='%s'", pg_escape_string($code)));
3619 $q->order_by =
"date desc";
3620 $l =
$q->Query(0, $limit,
"TABLE");
3622 if (is_array($l))
return $l;
3634 if ($this->atags ==
"") {
3635 $this->atags = $tag;
3641 $this->atags.=
"\n$tag";
3657 if ($this->atags ==
"")
return false;
3658 return (preg_match(
"/\b$tag\b/", $this->atags) > 0);
3669 if ($this->atags ==
"")
return "";
3670 $atags = preg_replace(
"/\b$tag\b/",
"", $this->atags);
3671 $atags = str_replace(
"\n\n",
"\n", $atags);
3672 $atags = preg_replace(
"/\n$/m",
'', $atags);
3673 if ($atags != $this->atags) {
3674 $this->atags = $atags;
3690 final public function addUTag(
$uid, $tag, $datas =
"", $allrevision =
true)
3692 if (!$this->initid)
return "";
3693 if ($tag ==
"")
return _(
"no user tag specified");
3697 $h =
new DocUTag($this->dbaccess);
3701 $h->fixed = ($allrevision) ?
'false' :
'true';
3702 $h->date = date(
"d-m-Y H:i:s");
3706 $h->uname = sprintf(
"%s %s",
$u->firstname,
$u->lastname);
3708 $h->fromuid = $action->user->id;
3711 $h->comment = $datas;
3722 final public function hasUTag($tag, $allrevision =
true)
3724 if (!$this->initid)
return false;
3725 include_once (
"FDL/Class.DocUTag.php");
3726 $docid = ($allrevision) ? $this->initid : $this->
id;
3727 $utag =
new DocUTag($this->dbaccess, array(
3732 return $utag->isAffected();
3743 if (!$this->initid)
return "";
3744 if (
$uid === null) {
3745 $uid = $this->userid;
3748 include_once (
"FDL/Class.DocUTag.php");
3749 $q =
new QueryDb($this->dbaccess,
"docUTag");
3750 $q->addQuery(
"uid=" . intval(
$uid));
3751 if ($tag)
$q->addQuery(
"tag = '" . pg_escape_string($tag) .
"'");
3752 if ($allrevision)
$q->addQuery(
"initid = " . $this->initid);
3753 else $q->addQuery(
"id = " . $this->
id);
3754 $q->order_by =
"id desc";
3755 $r =
$q->Query(0, 1);
3756 if (
$q->nb == 1)
return $r[0];
3769 if ($tag ==
"")
return _(
"no user tag specified");
3770 include_once (
"FDL/Class.DocUTag.php");
3773 $docid = ($allrevision) ? $this->initid : $this->
id;
3775 $err = $this->
exec_query(sprintf(
"delete from docutag where initid=%d and tag='%s' and uid=%d", $this->initid, pg_escape_string($tag) ,
$uid));
3777 $err = $this->
exec_query(sprintf(
"delete from docutag where id=%d and tag='%s' and uid=%d", $this->
id, pg_escape_string($tag) ,
$uid));
3789 if (!$this->initid)
return "";
3791 $err = $this->
exec_query(sprintf(
"delete from docutag where initid=%d and uid=%d", $this->initid,
$uid));
3801 if (!$this->initid)
return "";
3802 include_once (
"FDL/Class.DocUTag.php");
3803 $q =
new QueryDb($this->dbaccess,
"docUTag");
3804 $q->Query(0, 0,
"TABLE", sprintf(
"update docutag set id=%d where initid=%d and (not fixed)", $this->
id, $this->initid));
3815 final public function searchUTags($tag =
"", $allrevision =
true, $allusers =
false)
3817 if (!$this->initid)
return "";
3818 include_once (
"FDL/Class.DocUTag.php");
3819 $q =
new QueryDb($this->dbaccess,
"docUTag");
3820 if (!$allusers)
$q->addQuery(
"uid=" . intval($this->userid));
3821 if ($tag)
$q->addQuery(
"tag = '" . pg_escape_string($tag) .
"'");
3822 if ($allrevision)
$q->addQuery(
"initid = " . $this->initid);
3823 else $q->addQuery(
"id = " . $this->
id);
3824 $r =
$q->Query(0, 0,
"TABLE");
3825 if (
$q->nb == 0)
$r = array();
3836 if ($this->wid > 0 && $this->locked == - 1 && $this->doctype !=
'Z' && $this->state) {
3837 $wdoc = new_doc($this->dbaccess, $this->wid);
3838 if ($wdoc->isAlive()) {
3840 $waskids = $wdoc->getDocumentWasks($this->state, $control);
3841 foreach ($waskids as $k => $waskid) {
3842 $wask = new_doc($this->dbaccess, $waskid);
3843 if ($wask->isAlive()) {
3844 $ut = $this->
getUTag(
"ASK_" . $wask->id,
false);
3845 if ($ut) $answer = $ut->comment;
3848 "waskid" => $wask->id,
3849 "ask" => $wask->getValue(
"was_ask") ,
3851 "label" => $wask->getAskLabel($answer)
3865 $err = _(
"setWaskAnswer::invalid parameters");
3866 $waskid = intval($waskid);
3867 if ($waskid && $answer) {
3868 if (is_array($answer)) $answer = $this->
_array2val($answer);
3869 $err = $this->
addUTag($this->userid,
"ASK_" . intval($waskid) , $answer,
false);
3881 foreach ($ans as $an) {
3882 if (!$an[
"key"])
return false;
3892 if (!$this->wid)
return false;
3894 $wdoc = new_doc($this->dbaccess, $this->wid);
3895 if ($wdoc->isAlive()) {
3897 foreach (
$ldoc as $k => $v) {
3898 $aask = $wdoc->attrPrefix .
"_ASKID" . ($v[
"state"]);
3899 if ($v[
"locked"] == - 1 && $wdoc->getValue($aask)) {
3900 if ($wdoc->getValue($aask))
return $v[
"id"];
3912 return isFixedDoc($this->dbaccess, $this->
id);
3924 if ($this->locked == - 1)
return _(
"document already revised");
3926 $err = _(
"document already revised");
3930 if (!$this->withoutControl) {
3936 if (
$fdoc->schar ==
"S")
return sprintf(_(
"the document of %s family cannot be revised") ,
$fdoc->title);
3939 $postitid = $this->postitid;
3940 $forumid = $this->forumid;
3941 $this->locked = - 1;
3942 $this->lmodify =
'N';
3943 $this->allocated = 0;
3944 $this->owner = $this->userid;
3945 $this->postitid = 0;
3947 $date = gettimeofday();
3948 $this->revdate = $date[
'sec'];
3956 $this->select($this->
id);
3961 $err = sprintf(
"track error revision [%s]", pg_last_error($this->dbid));
3969 foreach ($fa as $k => $v) {
3970 $ca[] = $v->id .
"_txt";
3973 foreach ($ca as
$a) {
3974 if ($this->$a !=
"") $this->fields[
$a] =
$a;
3982 else $this->locked = 0;
3984 $this->comment =
"";
3986 $this->postitid = $postitid;
3987 $this->forumid = $forumid;
3995 $this->select($olddocid);
4002 if ($this->dprofid > 0) $this->
setProfil($this->dprofid);
4007 $this->
addLog(
"revision", array(
4009 "initid" => $this->initid,
4011 "title" => $this->title,
4012 "fromid" => $this->fromid,
4013 "fromname" => $this->fromname
4017 $maxrev = intval(
$fdoc->maxrev);
4021 $revs = $this->getRevisions(
"TABLE",
"ALL");
4022 for ($i = $maxrev; $i < count($revs); $i++) {
4024 if (
$d)
$d->ReallyDelete(
true);
4043 if ($this->wid > 0)
return sprintf(_(
"cannot set free state in workflow controlled document %s") , $this->title);
4044 if ($this->wid == - 1)
return sprintf(_(
"cannot set free state for document %s: workflow not allowed") , $this->title);
4045 if (!$this->
isRevisable())
return sprintf(_(
"cannot set free state for document %s: document cannot be revised") , $this->title);
4046 if ($newstateid == 0) {
4058 $state = new_doc($this->dbaccess, $newstateid);
4059 if (!
$state->isAlive())
return sprintf(_(
"invalid freestate document %s") , $newstateid);
4060 if (
$state->fromid != 39)
return sprintf(_(
"not a freestate document %s") ,
$state->title);
4062 $this->state =
$state->id;
4086 final public function setState($newstate,
$comment =
'',
$force =
false, $withcontrol =
true, $wm1 =
true, $wm2 =
true, $wneed =
true)
4088 if ($newstate ==
"")
return _(
"no state specified");
4089 if (!$this->wid)
return _(
"document is not controlled by a workflow");
4090 $wdoc = new_doc($this->dbaccess, $this->wid);
4091 if (!$wdoc->isAlive())
return _(
"assigned workflow is not alive");
4094 $err = $wdoc->ChangeState($newstate,
$comment,
$force, $withcontrol, $wm1, $wm2, $wneed);
4096 catch(Exception $e) {
4097 $err = sprintf(_(
"workflow associated %s [%d] is corrupted") , $wdoc->title, $wdoc->id);
4111 if (is_numeric($this->state) && ($this->state > 0)) {
4127 if ($this->wid > 0) {
4128 $wdoc =
new_Doc($this->dbaccess, $this->wid);
4129 if ($wdoc->isAffected())
return $wdoc->getColor($this->state, $def);
4131 if (is_numeric($this->state) && ($this->state > 0)) {
4147 if ($this->wid > 0) {
4148 $wdoc =
new_Doc($this->dbaccess, $this->wid);
4149 if ($wdoc->isAffected())
return $wdoc->getActivity($this->state, $def);
4151 if (is_numeric($this->state) && ($this->state > 0)) {
4152 $stateact = $this->
getDocValue($this->state,
"frst_desc", $def);
4169 final public function Copy($temporary =
false, $control =
true, $linkfld =
false, $copyfile =
false)
4172 $copy =
createDoc($this->dbaccess, $this->fromid, $control);
4173 if (!is_object($copy))
return false;
4175 $copy->transfertValuesFrom($this);
4179 $copy->revision =
"0";
4180 $copy->locked =
"0";
4181 $copy->allocated =
"0";
4183 $copy->comment =
"";
4187 $copy->doctype =
"T";
4192 $copy->setProfil($cdoc->cprofid);
4195 $err = $copy->PreCopy($this);
4198 $err = $copy->Add();
4200 $copy->addComment(sprintf(_(
"copy from document #%d -%s-") , $this->
id, $this->title));
4202 if ($copyfile) $copy->duplicateFiles();
4204 $copy->PostCopy($this);
4208 if ($linkfld && method_exists($copy,
"insertFolder")) {
4209 $copy->insertFolder($this->initid);
4230 if (
$doc->isAlive()) {
4231 foreach ($translate as $afrom => $ato) {
4232 $this->setValue($ato,
$doc->getValue($afrom));
4243 if ($this->archiveid == 0) {
4244 if ($this->doctype ==
"C")
$err = sprintf(
"families cannot be archieved");
4245 elseif (!$this->withoutControl)
$err = $this->control(
"edit");
4249 $this->dprofid = ($this->dprofid > 0) ? (-$this->dprofid) : (-abs($this->profid));
4250 $archprof =
$archive->getValue(
"arc_profil");
4251 $this->profid = $archprof;
4259 $this->addComment(sprintf(_(
"Archiving into %s") ,
$archive->getTitle()) ,
HISTO_MESSAGE,
"ARCHIVE");
4261 $err = $this->
exec_query(sprintf(
"update doc%d set archiveid=%d, dprofid=-abs(profid), profid=%d where initid=%d and locked = -1", $this->fromid,
$archive->id, $archprof, $this->initid));
4264 }
else $err = sprintf(
"document is already archived");
4276 if ($this->archiveid ==
$archive->id) {
4277 if (!$this->withoutControl)
$err = $this->control(
"edit");
4280 $this->archiveid =
"";
4281 $restoreprofil = abs($this->dprofid);
4291 $this->addComment(sprintf(_(
"Unarchiving from %s") ,
$archive->getTitle()) ,
HISTO_MESSAGE,
"UNARCHIVE");
4293 $err = $this->
exec_query(sprintf(
"update doc%d set archiveid=null, profid=abs(dprofid), dprofid=null where initid=%d and locked = -1", $this->fromid, $this->initid));
4296 }
else $err = sprintf(
"document not archived");
4311 final public function lock($auto =
false, $userid =
"")
4315 if ($userid ==
"") {
4318 $userid = $this->userid;
4324 if (($userid != 1) && ($this->locked == 0)) {
4325 $this->locked = - $userid;
4332 if (($this->locked != $userid) || ($this->lockDomain)) {
4333 $this->locked = $userid;
4358 if ($this->locked == 0)
return "";
4363 if ($this->locked < - 1) {
4364 $this->locked =
"0";
4365 $this->
modify(
false, array(
4371 if ($this->locked != - 1) {
4372 $this->locked =
"0";
4373 $this->lockdomainid =
'';
4374 $this->
modify(
false, array(
4399 if (
$err !=
"")
$err = _(
"Affectation aborded") .
"\n" .
$err;
4401 $u =
new User(
"", $userid);
4402 if (
$u->isAffected()) {
4403 if (
$err !=
"")
$err = _(
"Affectation aborded") .
"\n" .
$err;
4408 $this->addComment(sprintf(_(
"Affected to %s %s") ,
$u->firstname,
$u->lastname));
4413 $this->addComment(sprintf(_(
"Affected for %s") ,
$comment));
4416 $this->
addLog(
'allocate', array(
4417 "allocated" => array(
4419 "firstname" =>
$u->firstname,
4420 "lastname" =>
$u->lastname
4426 if ($autolock)
$err = $this->
lock(
false, $userid);
4429 $err = _(
"Affectation aborded : user not know");
4433 $this->allocated = $userid;
4434 $this->
modify(
true, array(
4452 if ($this->allocated == 0)
return "";
4456 if ((!$this->withoutControl) && ($this->userid != $this->allocated))
$err = $this->control(
"unlock");
4460 $u =
new User(
"", $this->allocated);
4461 if (
$u->isAffected()) {
4462 $err = $this->unlock();
4466 else $this->addComment(sprintf(_(
"Unallocated of %s %s: %s") ,
$u->firstname,
$u->lastname,
$comment));
4469 $err = _(
"user not know");
4473 $this->allocated = 0;
4474 $this->
modify(
true, array(
4477 $this->
addLog(
'unallocate');
4480 if (
$err !=
"")
$err = _(
"Unallocate aborded") .
"\n" .
$err;
4493 if ($idicon !=
"") {
4497 $efile =
"resizeimg.php?vid=" . $reg[2] .
"&size=" .
$size;
4499 $efile =
"FDL/geticon.php?vaultid=" . $reg[2] .
"&mimetype=" . $reg[1];
4502 $efile = $action->parent->GetImageUrl($idicon,
true,
$size);
4506 if ($this->fromid == 0) {
4508 return $action->GetImageUrl(
"doc.gif",
true,
$size);
4511 return $action->GetImageUrl(
"doc.gif",
true,
$size);
4521 if ($this->doctype ==
"C") {
4523 if ($this->icon !=
"") {
4526 $qt[] =
"ALTER TABLE doc$fromid DISABLE TRIGGER ALL";
4527 $qt[] =
"update doc$fromid set icon='$icon' where (fromid=" .
$fromid .
") AND (doctype != 'C') and ((icon='" . $this->icon .
"') or (icon is null))";
4528 $qt[] =
"ALTER TABLE doc$fromid ENABLE TRIGGER ALL";
4529 $qt[] =
"update docread set icon='$icon' where (fromid=" .
$fromid .
") AND (doctype != 'C') and ((icon='" . $this->icon .
"') or (icon is null))";
4534 $q =
"update doc$fromid set icon='$icon' where (fromid=" .
$fromid .
") AND (doctype != 'C') and (icon is null)";
4539 $this->icon =
$icon;
4550 $tin = explode(
",", strtolower($in));
4552 $this->paramRefresh[
"$in:$out"] = array(
4564 foreach ($this->attributes->attr as $k => $v) {
4565 $tv[$v->id] = $v->mvisibility;
4567 foreach ($this->paramRefresh as $k => $v) {
4570 while ($val && (list($ka, $va) = each($v[
"in"]))) {
4574 foreach ($v[
"out"] as $oa) {
4575 if (($tv[$oa] ==
"W") || ($tv[$oa] ==
"O")) $tv[$oa] =
"S";
4602 if ($this->locked == - 1)
return;
4603 if (($this->doctype ==
'C') || ($this->doctype ==
'Z'))
return;
4604 if ($this->lockdomainid > 0)
return '';
4605 $changed = $this->hasChanged;
4610 if ($this->hasChanged) {
4625 foreach ($fa as $aid => $oa) {
4626 $rn = $oa->getOption(
"rn");
4628 if ($oa->inArray()) {
4629 $t = $this->getTvalue($oa->id);
4630 foreach (
$t as $k => $v) {
4636 if ($fname != $cfname) {
4647 if ($fname != $cfname) {
4660 $dbaccess = $action->GetParam(
"FREEDOM_DB");
4662 $mi = strlen($link);
4663 for ($i = 0; $i < $mi; $i++) {
4664 switch ($link[$i]) {
4667 if ($link[$i] ==
"%") {
4671 if ($link[$i + 1] ==
"%") {
4673 switch ($link[$i]) {
4675 $urllink.= $action->GetParam(
"CORE_BASEURL");
4679 $urllink.= $action->GetParam(
"CORE_STANDURL");
4699 while (($i < $mi) && ($link[$i] !=
"%")) {
4700 $sattrid.= $link[$i];
4703 $oa = $this->GetAttribute($sattrid);
4704 if (($k >= 0) && ($oa && $oa->repeat)) {
4705 $tval = $this->GetTValue($sattrid);
4706 $ovalue = chop($tval[$k]);
4708 $ovalue = $this->GetValue($sattrid);
4710 if ($ovalue ==
"")
return false;
4713 if ($ovalue[0] ==
'[') $urllink.= urlencode($ovalue);
4714 else if (strstr($ovalue,
"\n")) $urllink.= str_replace(
"\n",
'\n', $ovalue);
4715 else $urllink.= ($ovalue);
4725 while ($link[$i] !=
'}') {
4726 $sattrid.= $link[$i];
4730 $ovalue = $action->GetParam($sattrid);
4736 $urllink.= $link[$i];
4740 return (chop($urllink));
4752 if ($v ===
"" || $v === null)
return array();
4753 return explode(
"\n", str_replace(
"\r",
"", $v));
4758 $v = str_replace(
"\n", $br, $v);
4759 if (count($v) == 0)
return "";
4760 return implode(
"\n", $v);
4769 return sprintf(
"%s?app=FREEDOM&action=FREEDOM_RSS&authtype=open&privateid=%s&id=%s", $action->getParam(
"CORE_OPENURL", $action->getParam(
"CORE_EXTERNURL")) , $action->user->getUserToken() ,
$this->id);
4779 public function getFileLink($attrid, $index = - 1, $cache =
false, $inline =
false)
4782 if ($index >= 0) $avalue = $this->
getTValue($attrid,
"", $index);
4783 else $avalue = $this->
getValue($attrid);
4788 return sprintf(
"file/%s/%d/%s/%s/%s?cache=%s&inline=%s", $this->
id, $vid, $attrid, $index, rawurlencode($reg[3]) , $cache ?
"yes" :
"no", $inline ?
"yes" :
"no");
4790 return sprintf(
"%s?app=FDL&action=EXPORTFILE&cache=%s&inline=%s&vid=%s&docid=%s&attrid=%s&index=%d",
"", $cache ?
"yes" :
"no", $inline ?
"yes" :
"no", $vid, $this->
id, $attrid, $index);
4807 $latest = ($docrev ==
"latest" || $docrev ==
"");
4811 if (trim(
$title) ==
"") {
4813 $a =
"<a>" . sprintf(_(
"document not exists yet")) .
"</a>";
4815 $a =
"<a>" . sprintf(_(
"unknown document id %s") ,
$id) .
"</a>";
4820 $ul = GetParam(
"CORE_EXTERNURL") .
"?";
4824 $jslatest = (
$latest) ?
'true' :
'false';
4825 $ec = getHttpVars(
"ext:targetRelation",
'Ext.fdl.Document.prototype.publish("opendocument",null,%V%,"view",{latest:' . $jslatest .
'})');
4830 if ($lid)
$id = $lid;
4832 $ec = str_replace(
"%V%",
$id, $ec);
4833 $ecu = str_replace(
"'",
'"', $ec);
4836 simpleQuery($this->dbaccess, sprintf(
'select icon from docread where id=%d',
$id) , $iconValue,
true,
true);
4837 $ajs.= sprintf(
'class="relation" style="background-image:url(%s)"', $this->
getIcon($iconValue, 14)) .
$title;
4839 $a =
"<a $ajs onclick='parent.$ecu'>$title</a>";
4841 if ($docrev ==
"latest" || $docrev ==
"" || !$docrev) $ul.=
"&latest=Y";
4842 elseif ($docrev !=
"fixed") {
4844 if (preg_match(
"/^state\(([a-zA-Z0-9_:-]+)\)/", $docrev, $matches)) {
4845 $ul.=
"&state=" . $matches[1];
4848 $ul.=
"&app=FDL&action=VIEWEXTDOC&id=$id";
4849 $a =
"<a href=\"$ul\">$title</a>";
4852 if ($docrev ==
"latest" || $docrev ==
"" || !$docrev) $ul.=
"&latest=Y";
4853 elseif ($docrev !=
"fixed") {
4855 if (preg_match(
"/^state\(([a-zA-Z0-9_:-]+)\)/", $docrev, $matches)) {
4856 $ul.=
"&state=" . $matches[1];
4859 $ul.=
"&app=FDL&action=FDL_CARD&id=$id";
4860 if ($js) $ajs =
"oncontextmenu=\"popdoc(event,'$ul');return false;\"";
4863 $ajs.= sprintf(
' documentId="%s" ',
$id);
4865 simpleQuery($this->dbaccess, sprintf(
'select icon from docread where id=%d',
$id) , $iconValue,
true,
true);
4866 $ajs.= sprintf(
'class="relation" style="background-image:url(%s)"', $this->
getIcon($iconValue, 14)) .
$title;
4868 $a =
"<a $ajs target=\"$target\" href=\"$ul\">$title</a>";
4877 final private function rowattrReplace(
$s, $index)
4879 if (substr(
$s, 0, 2) ==
"L_")
return "[$s]";
4880 if (substr(
$s, 0, 2) ==
"V_") {
4881 $sl = substr(strtolower(
$s) , 2);
4884 if (($vis ==
"H") || ($vis ==
"I") || ($vis ==
"O")) $v =
"";
4885 else $v = $this->GetHtmlAttrValue($sl,
"_self", 2, $index);
4887 $sl = strtolower(
$s);
4888 if (!isset($this->$sl))
return "[$s]";
4898 $aformat = $oattr->format;
4899 $atype = $oattr->type;
4901 if (($oattr->repeat) && ($index <= 0)) {
4902 $tvalues = explode(
"\n",
$value);
4904 $tvalues[$index] =
$value;
4906 $idocfamid = $oattr->format;
4908 $attrid = $oattr->id;
4909 foreach ($tvalues as $kvalue => $avalue) {
4918 $temp = base64_decode(
$value);
4919 $entete =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>";
4925 $attrid = $attrid . $index;
4926 $htmlval =
"<form style=\"display:inline\"><INPUT id=\"_" . $attrid .
"\" TYPE=\"hidden\" name=\"_" . $attrid .
"\" value=\"" .
$value .
" \">";
4927 $htmlval.=
"<a onclick=\"subwindow(400,400,'_$attrid','');viewidoc('_$attrid','$idocfamid')\" ";
4928 $htmlval.=
"oncontextmenu=\"viewidoc_in_popdoc(event,'$attrid','_$attrid','$idocfamid');return false\">$title</a>";
4929 $htmlval.=
"</form>";
4934 $htmlval =
"cid:" . $oattr->id;
4935 if ($index >= 0) $htmlval.=
"+$index";
4938 $htmlval =
"file://" . $this->
vault_filename($oattr->id,
true, $kvalue);
4944 if (($oattr->repeat) && ($index <= 0)) $idx = $kvalue;
4946 $inline = $oattr->getOption(
"inline");
4947 if ($inline ==
"yes") $opt =
"&inline=yes";
4949 $htmlval = $action->GetParam(
"CORE_BASEURL") .
"app=FDL" .
"&action=EXPORTFILE$opt&cache=no&vid=$vid&docid=" . $this->
id .
"&attrid=" . $oattr->id .
"&index=$idx";
4952 $htmlval = $action->GetImageUrl($avalue);
4964 include_once (
"FDL/Lib.Dir.php");
4966 if (
$vf->Show($reg[2], $info) ==
"") $fname = $info->name;
4967 else $htmlval = _(
"vault file error");
4968 }
else $htmlval = _(
"no filename");
4971 $htmlval =
"<a target=\"_blank\" href=\"";
4972 $htmlval.=
"cid:" . $oattr->id;
4973 if ($index >= 0) $htmlval.=
"+$index";
4974 $htmlval.=
"\">" . $fname .
"</a>";
4977 if ($info->teng_state < 0 || $info->teng_state > 1) {
4979 include_once (
"WHAT/Class.TEClient.php");
4980 switch (intval($info->teng_state)) {
4982 $textval = _(
"file conversion failed");
4986 $textval = _(
"file conversion not supported");
4990 $textval = _(
"cannot contact server");
4994 $textval = _(
"waiting conversion file");
4998 $textval = _(
"generating file");
5002 $textval = sprintf(_(
"unknown file state %s") , $info->teng_state);
5007 if ($info->teng_state > 1) $waiting =
"<img class=\"mime\" src=\"Images/loading.gif\">";
5008 else $waiting =
"<img class=\"mime\" needresize=1 src=\"Images/bullet_error.png\">";;
5009 $htmlval = sprintf(
'<a _href_="%s" vid="%d" onclick="popdoc(event,this.getAttribute(\'_href_\')+\'&inline=yes\',\'%s\')">%s %s</a>', $this->
getFileLink($oattr->id, $index) , $info->id_file, str_replace(
"'",
"’", _(
"file status")) , $waiting, $textval);
5010 if ($info->teng_state < 0) {
5011 $htmlval.= sprintf(
'<a href="?app=FDL&action=FDL_METHOD&id=%d&method=resetConvertVaultFile(\'%s,%s)"><img class="mime" title="%s" src="%s"></a>', $this->
id, $oattr->id, $index, _(
"retry file conversion") ,
"Images/arrow_refresh.png");
5014 $htmlval = $textval;
5016 } elseif ($htmllink) {
5018 $mimeicon =
getIconMimeFile($info->mime_s ==
"" ? $mime : $info->mime_s);
5019 if (($oattr->repeat) && ($index <= 0)) $idx = $kvalue;
5021 $standardview =
true;
5023 $viewfiletype = $oattr->getOption(
"viewfiletype");
5024 if ($viewfiletype ==
"image" || $viewfiletype ==
"pdf") {
5027 if (substr($info->mime_s, 0, 5) ==
"image") {
5029 $viewfiletype =
'png';
5031 } elseif (substr($info->mime_s, 0, 4) ==
"text") {
5033 $viewfiletype =
'embed';
5036 $err =
$vf->Show($vid, $infopdf,
'pdf');
5040 if ($viewfiletype ==
'image') $viewfiletype =
'png';
5041 else if ($viewfiletype ==
'pdf') $viewfiletype =
'embed';
5049 if ($imageview && (!$abstract)) {
5050 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/widgetFile.js");
5051 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/detectPdfPlugin.js");
5052 $lay =
new Layout(
"FDL/Layout/viewfileimage.xml", $action);
5053 $lay->set(
"docid", $this->
id);
5054 $lay->set(
"waiting", ($waiting ?
'true' :
'false'));
5055 $lay->set(
"attrid", $oattr->id);
5056 $lay->set(
"index", $idx);
5057 $lay->set(
"viewtype", $viewfiletype);
5058 $lay->set(
"mimeicon", $mimeicon);
5059 $lay->set(
"vid", ($infopdf ? $infopdf->id_file : $vid));
5060 $lay->set(
"filetitle", $fname);
5061 $lay->set(
"height", $oattr->getOption(
'viewfileheight',
'300px'));
5062 $lay->set(
"filelink", $this->
getFileLink($oattr->id, $idx,
false,
false));
5064 $lay->set(
"pdflink",
'');
5065 if ($pdfattr = $oattr->getOption(
'pdffile')) {
5067 if (!preg_match(
'/^(text|image)/', $info->mime_s)) {
5069 if ($waiting || preg_match(
'/(pdf)/', $infopdf->mime_s)) {
5070 $lay->set(
"pdflink", $this->
getFileLink($pdfattr, $idx,
false,
false));
5074 $lay->set(
"pages", $pages);
5075 $htmlval = $lay->gen();
5076 $standardview =
false;
5079 if ($standardview) {
5080 $size = round($info->size / 1024) . _(
"AbbrKbyte");
5081 $utarget = ($action->Read(
"navigator",
"") ==
"NETSCAPE") ?
"_self" :
"_blank";
5083 $inline = $oattr->getOption(
"inline");
5084 if ($inline ==
"yes") $opt =
"&inline=yes";
5085 $htmlval =
"<a onmousedown=\"document.noselect=true;\" title=\"$size\" target=\"$utarget\" type=\"$mime\" href=\"" . $this->
getFileLink($oattr->id, $idx,
false, ($inline ==
"yes")) .
"\">";
5086 if ($mimeicon) $htmlval.=
"<img class=\"mime\" needresize=1 src=\"Images/$mimeicon\"> ";
5087 $htmlval.= $fname .
"</a>";
5090 $htmlval = $info->name;
5099 if ($entities) $bvalue = nl2br(htmlentities(stripslashes(str_replace(
"<BR>",
"\n", $avalue)) , ENT_COMPAT,
"UTF-8"));
5100 else $bvalue = stripslashes(str_replace(
"<BR>",
"\n", $avalue));
5101 $shtmllink = $htmllink ?
"true" :
"false";
5102 $bvalue = preg_replace(
"/(\[|[)ADOC ([^\]]*)\]/e",
"\$this->getDocAnchor('\\2',\"$target\",$shtmllink)", $bvalue);
5103 $htmlval = str_replace(array(
5113 $htmlval = preg_replace(
"/./",
"*", htmlentities(stripslashes($avalue) , ENT_COMPAT,
"UTF-8"));
5118 $enumlabel = $oattr->getEnumlabel();
5119 $colors = $oattr->getOption(
"boolcolor");
5120 if ($colors !=
"") {
5121 if (isset($enumlabel[$avalue])) {
5123 $tcolor = explode(
",", $colors);
5124 if (current($enumlabel) == $enumlabel[$avalue]) {
5125 $color = $tcolor[0];
5126 $htmlval = sprintf(
'<pre style="background-color:%s;display:inline"> - </pre>', $color);
5128 $color = $tcolor[1];
5129 $htmlval = sprintf(
'<pre style="background-color:%s;display:inline"> • </pre>', $color);
5131 }
else $htmlval = $avalue;
5133 if (isset($enumlabel[$avalue])) $htmlval = $enumlabel[$avalue];
5134 else $htmlval = $avalue;
5140 $viewzone = $oattr->getOption(
"rowviewzone");
5141 $sort = $oattr->getOption(
"sorttable");
5142 if ($sort ==
"yes") {
5144 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FREEDOM/Layout/sorttable.js");
5147 $lay =
new Layout(
"FDL/Layout/viewdocarray.xml", $action);
5148 $lay->set(
"issort", ($sort ==
"yes"));
5149 if (!method_exists($this->attributes,
"getArrayElements")) {
5152 $height = $oattr->getOption(
"height",
false);
5153 $lay->set(
"tableheight", $height);
5155 if (($oattr->getOption(
"vlabel",
"up") ==
"up")) $caption = $oattr->getLabel();
5156 $lay->set(
"caption", $caption);
5157 $lay->set(
"aid", $oattr->id);
5159 if (($viewzone !=
"") && preg_match(
"/([A-Z_-]+):([^:]+):{0,1}[A-Z]{0,1}/", $viewzone, $reg)) {
5161 $dxml =
new DomDocument();
5163 if (!@$dxml->load($rowlayfile)) {
5164 AddwarningMsg(sprintf(_(
"cannot open %s layout file") ,
DEFAULT_PUBDIR .
"/$rowlayfile"));
5167 $theads = $dxml->getElementsByTagName(
'table-head');
5168 if ($theads->length > 0) {
5169 $thead = $theads->item(0);
5170 $theadcells = $thead->getElementsByTagName(
'cell');
5172 for ($i = 0; $i < $theadcells->length; $i++) {
5174 $thstyle = $theadcells->item($i)->getAttribute(
"style");
5175 if ($thstyle !=
"") $thstyle =
"style=\"$thstyle\"";
5178 "astyle" => $thstyle,
5182 $lay->setBlockData(
"TATTR", $talabel);
5185 $tbodies = $dxml->getElementsByTagName(
'table-body');
5186 if ($tbodies->length > 0) {
5187 $tbody = $tbodies->item(0);
5188 $tbodycells = $tbody->getElementsByTagName(
'cell');
5189 for ($i = 0; $i < $tbodycells->length; $i++) {
5191 $tcellstyle[] = $tbodycells->item($i)->getAttribute(
"style");
5194 $ta = $this->attributes->getArrayElements($oattr->id);
5196 foreach (
$ta as $k => $v) {
5198 $nbitem = max($nbitem, count($tval[$k]));
5199 if ($emptyarray && ($this->
getValue($k) !=
"")) $emptyarray =
false;
5200 $lay->set(
"L_" . strtoupper($v->id) ,
mb_ucfirst($v->getLabel()));
5204 for ($k = 0; $k < $nbitem; $k++) {
5206 "bevalue" =>
"bevalue_$k"
5211 foreach ($tr as $kd => $vd) {
5213 $hval = preg_replace(
"/\[([^\]]*)\]/e",
"\$this->rowattrReplace('\\1',$k)", $vd);
5214 $tdstyle = $tcellstyle[$kd];
5217 "color" =>
"inherit",
5218 "tdstyle" => $tdstyle,
5219 "bgcolor" =>
"inherit",
5220 "align" =>
"inherit"
5223 $lay->setBlockData(
"bevalue_$k", $tivalue);
5225 $lay->setBlockData(
"EATTR", $tvattr);
5226 if ($nbitem > 10) $lay->set(
"caption", $oattr->getLabel() .
" ($nbitem)");
5228 $htmlval = $lay->gen();
5230 $ta = $this->attributes->getArrayElements($oattr->id);
5236 foreach (
$ta as $k => $v) {
5237 if (($v->mvisibility ==
"H") || ($v->mvisibility ==
"I") || ($v->mvisibility ==
"O"))
continue;
5240 "astyle" => $v->getOption(
"cellheadstyle") ,
5241 "cwidth" => $v->getOption(
"cwidth",
"auto")
5244 $nbitem = max($nbitem, count($tval[$k]));
5245 if ($emptyarray && ($this->
getValue($k) !=
"")) $emptyarray =
false;
5248 if ($oattr->getOption(
"vlabel") ==
"up") {
5249 $caption = $oattr->getLabel();
5250 if ($nbitem > 10) $caption.=
" ($nbitem)";
5254 if (count($talabel) > 0) {
5255 $talabel[0][
"alabel"].=
" ($nbitem)";
5260 $lay->setBlockData(
"TATTR", $talabel);
5261 $lay->set(
"caption", $caption);
5263 for ($k = 0; $k < $nbitem; $k++) {
5265 "bevalue" =>
"bevalue_$k"
5268 foreach (
$ta as $ka => $va) {
5269 if (($va->mvisibility ==
"H") || ($va->mvisibility ==
"I") || ($va->mvisibility ==
"O"))
continue;
5271 if ($va->type ==
"image") {
5272 $iwidth = $va->getOption(
"iwidth",
"80px");
5273 if ($tval[$ka][$k] ==
"") $hval =
"";
5274 else if ($va->link ==
"") {
5275 if (strstr($hval,
'?')) $optwidth =
"&width=" . intval($iwidth);
5276 else $optwidth =
'';
5277 $hval =
"<a href=\"$hval\"><img border='0' width=\"$iwidth\" src=\"" . $hval . $optwidth .
"\"></a>";
5279 $hval = preg_replace(
"/>(.+)</",
"> <img class=\"button\" width=\"$iwidth\" src=\"\\1\"> <", $hval);
5284 "tdstyle" => $va->getOption(
"cellbodystyle") ,
5285 "color" => $va->getOption(
"color",
"inherit") ,
5286 "bgcolor" => $va->getOption(
"bgcolor",
"inherit") ,
5287 "align" => $va->getOption(
"align",
"inherit")
5290 $lay->setBlockData(
"bevalue_$k", $tivalue);
5292 $lay->setBlockData(
"EATTR", $tvattr);
5294 $htmlval = $lay->gen();
5304 if ($avalue !=
"") {
5305 if ($kvalue > - 1) $idocid = $this->
getTValue($aformat,
"", $kvalue);
5306 else $idocid = $this->
getValue($aformat);
5312 $htmlval =
$idoc->viewDoc(
"FDL:VIEWTHUMBCARD:T",
"finfo");
5320 if ($oattr->format !=
"") {
5323 $multiple = ($oattr->getOption(
"multiple") ==
"yes");
5326 $ltarget = $oattr->getOption(
"ltarget");
5327 if ($ltarget !=
"") $dtarget = $ltarget;
5330 $avalue = str_replace(
"\n",
"<BR>", $avalue);
5331 $tval = explode(
"<BR>", $avalue);
5333 foreach ($tval as $kv => $vv) {
5334 if (trim($vv) ==
"") $thval[] = $vv;
5335 elseif ($oattr->link !=
"") {
5336 $link = preg_replace(
"/%" . $oattr->id .
"%/i", $vv, $oattr->link);
5338 if ($link) $thval[] =
'<a target="' . $dtarget .
'" href="' . $link .
'">' . $this->
getHTMLTitle($vv) .
'</a>';
5340 }
else $thval[] = $this->
getDocAnchor(trim($vv) , $dtarget, $htmllink,
false,
true, $oattr->getOption(
"docrev") ,
true);
5342 if ($oattr->link) $htmllink =
false;
5343 $htmlval = implode(
"<br/>", $thval);
5345 if ($avalue ==
"") $htmlval = $avalue;
5346 elseif ($oattr->link !=
"") $htmlval = $this->
getHTMLTitle($avalue);
5347 else $htmlval = $this->
getDocAnchor(trim($avalue) , $dtarget, $htmllink,
false,
true, $oattr->getOption(
"docrev") ,
true);
5349 }
else $htmlval = $avalue;
5355 $multiple = ($oattr->getOption(
"multiple") ==
"yes");
5357 $avalue = str_replace(
"\n",
"<BR>", $avalue);
5358 $tval = explode(
"<BR>", $avalue);
5360 foreach ($tval as $kv => $vv) {
5361 if (trim($vv) ==
"") $thval[] = $vv;
5363 $thc = new_doc($this->dbaccess, trim($vv));
5364 if ($thc->isAlive()) $thval[] = $this->
getDocAnchor(trim($vv) ,
$target, $htmllink, $thc->getLangTitle());
5365 else $thval[] =
"th error $vv";
5368 $htmlval = implode(
"<br/>", $thval);
5370 if ($avalue ==
"") $htmlval = $avalue;
5372 $thc = new_doc($this->dbaccess, $avalue);
5373 if ($thc->isAlive()) $htmlval = $this->
getDocAnchor(trim($avalue) ,
$target, $htmllink, $thc->getLangTitle());
5374 else $htmlval =
"th error $avalue";
5381 $lay =
new Layout(
"FDL/Layout/viewdocoption.xml", $action);
5384 if ($kvalue > - 1) $di = $this->
getTValue($oattr->format,
"", $kvalue);
5385 else $di = $this->
getValue($oattr->format);
5387 $lay->set(
"said", $di);
5388 $lay->set(
"uuvalue", urlencode($avalue));
5390 $htmlval = $lay->gen();
5396 if ($avalue !==
'') {
5397 $htmlval = money_format(
'%!.2n', doubleval($avalue));
5398 $htmlval = str_replace(
" ",
" ", $htmlval);
5406 $shtmllink = $htmllink ?
"true" :
"false";
5407 $avalue = preg_replace(
"/(\[|[)ADOC ([^\]]*)\]/e",
"\$this->getDocAnchor('\\2',\"$target\",$shtmllink)", $avalue);
5408 $htmlval =
'<div class="htmltext">' . $avalue .
'</div>';
5412 if (($aformat !=
"") && (trim($avalue) !=
"")) {
5414 else $htmlval = $avalue;
5415 } elseif (trim($avalue) ==
"") {
5425 if (($aformat !=
"") && (trim($avalue) !=
"")) {
5426 if ($avalue) $htmlval = strftime($aformat, strtotime($avalue));
5427 else $htmlval = $avalue;
5429 $htmlval = substr($avalue, 0, 5);
5436 if (($aformat !=
"") && (trim($avalue) !=
"")) {
5438 else $htmlval = $avalue;
5439 } elseif (trim($avalue) ==
"") {
5448 $lay =
new Layout(
"FDL/Layout/viewifile.xml", $action);
5449 $lay->set(
"aid", $oattr->id);
5450 $lay->set(
"id", $this->
id);
5451 $lay->set(
"iheight", $oattr->getOption(
"height",
"200px"));
5452 $htmlval = $lay->gen();
5457 $htmlval = sprintf(
"<span style=\"background-color:%s\">%s</span>", $avalue, $avalue);
5461 if ($entities) $avalue = htmlentities(stripslashes($avalue) , ENT_COMPAT,
"UTF-8");
5462 else $avalue = stripslashes($avalue);
5463 $htmlval = str_replace(array(
5474 if (($htmlval !==
'') && ($aformat !=
"") && ($atype !=
"doc") && ($atype !=
"array") && ($atype !=
"option")) {
5476 $htmlval = sprintf($aformat, $htmlval);
5479 if ($htmllink && ($oattr->link !=
"")) {
5481 $hlink = $oattr->link;
5482 if ($hlink[0] ==
"[") {
5483 if (preg_match(
'/\[(.*)\](.*)/', $hlink, $reg)) {
5485 $ititle = str_replace(
"\"",
"'", $reg[1]);
5490 if (preg_match(
"/FDL_CARD.*id=([0-9]+)/", $ulink, $reg)) {
5494 }
else if (
true || preg_match(
"/^http:/", $ulink, $reg)) {
5498 $ec = str_replace(
"%V%", $ulink, $ec);
5499 $ec = str_replace(
"%L%", $oattr->getLabel() , $ec);
5501 $abegin =
"<a onclick='parent.$ecu'>";
5503 $ltarget = $oattr->getOption(
"ltarget");
5504 $abegin =
"<a target=\"$ltarget\" href=\"$ulink\">";
5509 }
else if (
$target ==
"mail") {
5511 if (preg_match(
"/^([[:alpha:]]*):(.*)/", $ulink, $reg)) {
5514 $abegin =
"<a target=\"$target\" href=\"";
5515 if ($scheme ==
"") $abegin.= $action->GetParam(
"CORE_URLINDEX", ($action->GetParam(
"CORE_ABSURL") .
"/")) . $ulink;
5516 else $abegin.= $ulink;
5520 $ltarget = $oattr->getOption(
"ltarget");
5521 if ($ltarget !=
"")
$target = $ltarget;
5522 $ltitle = $oattr->getOption(
"ltitle");
5523 if ($ltitle !=
"") $ititle = str_replace(
"\"",
"'", $ltitle);
5524 $abegin =
"<a target=\"$target\" title=\"$ititle\" onmousedown=\"document.noselect=true;\" href=\"";
5525 $abegin.= $ulink .
"\" ";;
5526 if ($htmllink > 1) {
5528 if (preg_match(
"/^([[:alpha:]]*):(.*)/", $ulink, $reg)) {
5531 if (($scheme ==
"") || ($scheme ==
"http")) {
5532 if ($scheme ==
"") $ulink.=
"&ulink=1";
5533 $abegin.=
" oncontextmenu=\"popdoc(event,'$ulink');return false;\" ";
5548 $thtmlval[$kvalue] = $abegin . $htmlval . $aend;
5551 return implode(
"<BR>", $thtmlval);
5559 final private static function getHtmlTdContent($attr, $data)
5561 $data = preg_replace(
'|<(/?[^> ]+)(\s[^>]*?)?>|ms',
'', $data);
5562 return '<td>' . $data .
'</td>';
5565 final public function getHtmlAttrValue($attrid,
$target =
"_self", $htmllink = 2, $index = - 1, $entities =
true, $abstract =
false)
5567 if ($index != - 1) $v = $this->
getTValue($attrid,
"", $index);
5568 else $v = $this->
getValue($attrid);
5569 if ($v ==
"")
return $v;
5570 return $this->GetHtmlValue($this->
getAttribute($attrid) , $v,
$target, $htmllink, $index, $entities, $abstract);
5586 return $objectAttr->getTextualValue($this, $index, $configuration);
5594 if ($index != - 1) $v = $this->
getTValue($attrid,
"", $index);
5595 else $v = $this->
getValue($attrid);
5596 if ($v ==
"")
return $v;
5603 $aformat = $oattr->format;
5604 $atype = $oattr->type;
5606 if (($oattr->repeat) && ($index <= 0)) {
5607 $tvalues = explode(
"\n",
$value);
5609 $tvalues[$index] =
$value;
5611 $idocfamid = $oattr->format;
5613 $attrid = $oattr->id;
5614 foreach ($tvalues as $kvalue => $avalue) {
5632 $htmlval = str_replace(
"&",
"&", $avalue);
5633 $htmlval = str_replace(array(
5640 $htmlval = str_replace(
"\n",
"<text:line-break/>", $htmlval);
5641 $htmlval = str_replace(
"<BR>",
"<text:line-break/>", $htmlval);
5642 $htmlval = str_replace(
"\r",
"", $htmlval);
5650 $enumlabel = $oattr->getEnumlabel();
5651 $colors = $oattr->getOption(
"boolcolor");
5652 if ($colors !=
"") {
5653 if (isset($enumlabel[$avalue])) {
5655 $tcolor = explode(
",", $colors);
5656 if (current($enumlabel) == $enumlabel[$avalue]) {
5657 $color = $tcolor[0];
5658 $htmlval = sprintf(
'<pre style="background-color:%s;display:inline"> - </pre>', $color);
5660 $color = $tcolor[1];
5661 $htmlval = sprintf(
'<pre style="background-color:%s;display:inline"> • </pre>', $color);
5663 }
else $htmlval = $avalue;
5665 if (isset($enumlabel[$avalue])) $htmlval = $enumlabel[$avalue];
5666 else $htmlval = $avalue;
5673 $multiple = ($oattr->getOption(
"multiple") ==
"yes");
5675 $avalue = str_replace(
"\n",
"<BR>", $avalue);
5676 $tval = explode(
"<BR>", $avalue);
5678 foreach ($tval as $kv => $vv) {
5679 if (trim($vv) ==
"") $thval[] = $vv;
5681 $thc = new_doc($this->dbaccess, trim($vv));
5682 if ($thc->isAlive()) $thval[] = $thc->getLangTitle();
5683 else $thval[] =
"th error $vv";
5686 $htmlval = implode(
"<text:tab/>", $thval);
5688 if ($avalue ==
"") $htmlval = $avalue;
5690 $thc = new_doc($this->dbaccess, $avalue);
5691 if ($thc->isAlive()) $htmlval = $thc->getLangTitle();
5692 else $htmlval =
"th error $avalue";
5705 if ($oattr->format !=
"") {
5708 $multiple = ($oattr->getOption(
"multiple") ==
"yes");
5711 $ltarget = $oattr->getOption(
"ltarget");
5712 if ($ltarget !=
"") $dtarget = $ltarget;
5715 $avalue = str_replace(
"\n",
"<BR>", $avalue);
5716 $tval = explode(
"<BR>", $avalue);
5718 foreach ($tval as $kv => $vv) {
5719 if (trim($vv) ==
"") $thval[] = $vv;
5720 else $thval[] = $this->
getDocAnchor(trim($vv) , $dtarget,
false);
5722 $htmlval = implode(
"<text:tab/>", $thval);
5724 if ($avalue ==
"") $htmlval = $avalue;
5725 elseif ($oattr->link !=
"") $htmlval = $this->
getTitle($avalue);
5726 else $htmlval = $this->
getDocAnchor(trim($avalue) , $dtarget,
false);
5728 }
else $htmlval = $avalue;
5736 $htmlval = money_format(
'%!.2n', doubleval($avalue));
5741 $html_body = trim($avalue);
5742 $html_body = str_replace(array(
5751 if ($html_body[0] !=
'<') {
5753 $html_body = str_replace(
"\n<br/>",
"\n", $html_body);
5754 $html_body = str_replace(
'<br/>',
"\n", $html_body);
5755 if (!strpos($html_body,
'<br')) $html_body = str_replace(array(
5764 $html_body =
'<p>' . nl2br($html_body) .
'</p>';
5766 $html_body = str_replace(
">\r\n",
">", $html_body);
5767 $html_body = str_replace(
"\r",
"", $html_body);
5769 $html_body = preg_replace(
"/<!--.*?-->/ms",
"", $html_body);
5770 $html_body = preg_replace(
"/<td(\s[^>]*?)?>(.*?)<\/td>/mse",
"\$this->getHtmlTdContent('\\1','\\2')", $html_body);
5772 $html_body = preg_replace(
"/(<\/?)([^\s>]+)([^>]*)(>)/e",
"toxhtmltag('\\1','\\2','\\3','\\4')", $html_body);
5773 $html_body = str_replace(array(
5776 ) ,
'"', $html_body);
5777 $html_body = str_replace(
'&',
'&', html_entity_decode($html_body, ENT_NOQUOTES,
'UTF-8'));
5779 $html_body = str_replace(array(
5788 $xmldata =
'<xhtml:body xmlns:xhtml="http://www.w3.org/1999/xhtml">' . $html_body .
"</xhtml:body>";
5790 $xslt =
new xsltProcessor;
5791 $xslt->importStyleSheet(DomDocument::load(
DEFAULT_PUBDIR .
"/CORE/Layout/html2odt.xsl"));
5794 $dom = @DomDocument::loadXML($xmldata);
5796 catch(Exception $e) {
5797 addWarningMsg(sprintf(_(
"possible incorrect conversion HTML to ODT %s") , $this->title));
5813 $xmlout = $xslt->transformToXML($dom);
5814 $dxml =
new DomDocument();
5815 $dxml->loadXML($xmlout);
5817 $ot = $dxml->getElementsByTagNameNS(
"urn:oasis:names:tc:opendocument:xmlns:office:1.0",
"text");
5818 $ot1 = $ot->item(0);
5819 $officetext = $ot1->ownerDocument->saveXML($ot1);
5820 $htmlval = str_replace(array(
5824 ) ,
"", $officetext);
5826 $htmlval = preg_replace(
"/(<text:p>[\s]*<table:table )/ ",
"<table:table ", $htmlval);
5827 $htmlval = preg_replace(
"/(<\/table:table>[\s]*<\/text:p>)/ ",
"</table:table> ", $htmlval);
5829 $pppos = mb_strrpos($htmlval,
'</text:p>');
5831 $htmlval = sprintf(
'<text:section text:style-name="Sect%s" text:name="Section%s" aid="%s">%s</text:section>', $attrid, $attrid, $attrid, $htmlval);
5834 addWarningMsg(sprintf(_(
"incorrect conversion HTML to ODT %s") , $this->title));
5840 if (($aformat !=
"") && (trim($avalue) !=
"")) {
5842 else $htmlval = $avalue;
5843 } elseif (trim($avalue) ==
"") {
5852 if ($aformat !=
"") {
5853 if ($avalue) $htmlval = strftime($aformat, strtotime($avalue));
5854 else $htmlval = $avalue;
5857 $htmlval = substr($avalue, 0, 5);
5864 if (($aformat !=
"") && (trim($avalue) !=
"")) {
5866 else $htmlval = $avalue;
5867 } elseif (trim($avalue) ==
"") {
5876 $lay =
new Layout(
"FDL/Layout/viewifile.xml", $action);
5877 $lay->set(
"aid", $oattr->id);
5878 $lay->set(
"id", $this->
id);
5879 $lay->set(
"iheight", $oattr->getOption(
"height",
"200px"));
5880 $htmlval = $lay->gen();
5885 $htmlval = sprintf(
"<span style=\"background-color:%s\">%s</span>", $avalue, $avalue);
5889 $htmlval = stripslashes($avalue);
5890 $htmlval = str_replace(array(
5903 if (($aformat !=
"") && ($atype !=
"doc") && ($atype !=
"array") && ($atype !=
"option")) {
5905 $htmlval = sprintf($aformat, $htmlval);
5908 $thtmlval[$kvalue] = $htmlval;
5911 return implode(
"<text:tab/>", $thtmlval);
5922 if (($this->IsAffected())) {
5924 if (($this->profid <= 0) || ($this->userid == 1)) {
5931 return sprintf(_(
"no privilege %s for %s") , $aclname, $this->
getTitle());
5937 if (($aclname ==
'edit' || $aclname ==
'delete' || $aclname ==
'unlock') && $this->
isRealProfile()) {
5957 if ($this->IsAffected()) {
5958 if (($this->profid <= 0) || (
$uid == 1))
return "";
5959 if (!
$uid)
return _(
"control :: user identificator is null");
5976 final public function SqlTrigger($onlydrop =
false, $code =
false)
5979 if (get_class($this) ==
"DocFam") {
5982 if ($this->doctype ==
'C')
return;
5983 if (intval($this->fromid) == 0)
return;
5990 $sql.=
"select droptrigger('doc" . $cid .
"');";
5991 if ($onlydrop)
return $sql;
5993 $lay =
new Layout(
"FDL/Layout/sqltrigger.xml");
5997 foreach ($na as $k => $v) {
5998 if (($v->type !=
"array") && ($v->type !=
"frame") && ($v->type !=
"tab") && ($v->type !=
"idoc")) {
6002 if (($v->type !=
"file") && ($v->type !=
"image") && ($v->type !=
"password")) $tsearch[] = array(
6006 if ($v->type ==
"file") {
6008 "attrid" => $k .
"_txt",
6009 "vecid" => $k .
"_vec"
6012 "attrid" => $k .
"_txt"
6017 foreach ($na as $k => $v) {
6018 if (($v->type !=
"array") && ($v->type !=
"file") && ($v->type !=
"image") && ($v->type !=
"password")) {
6019 $tabstract[] = array(
6024 $lay->setBlockData(
"ATTRFIELD", $tvalues);
6025 $lay->setBlockData(
"SEARCHFIELD", $tsearch);
6026 $lay->setBlockData(
"ABSATTR", $tabstract);
6027 $lay->setBlockData(
"FILEATTR", $files);
6028 $lay->setBlockData(
"FILEATTR2", $files);
6029 $lay->setBlockData(
"FILEATTR3", $files);
6030 $lay->set(
"hasattr", (count($tvalues) > 0));
6031 $lay->set(
"hassattr", (count($tsearch) > 0));
6032 $lay->set(
"hasabsattr", (count($tabstract) > 0));
6033 $lay->set(
"docid", $this->fromid);
6037 if (is_array($this->attributes->fromids)) {
6038 foreach ($this->attributes->fromids as $k => $v) {
6040 $sql.=
"create trigger UV{$cid}_$v BEFORE INSERT OR UPDATE ON doc$cid FOR EACH ROW EXECUTE PROCEDURE upval$v();";
6044 if ($cid !=
"fam") {
6045 $sql.=
"create trigger AUVR{$cid} BEFORE UPDATE ON doc$cid FOR EACH ROW EXECUTE PROCEDURE resetvalues();";
6046 $sql.=
"create trigger VFULL{$cid} BEFORE INSERT OR UPDATE ON doc$cid FOR EACH ROW EXECUTE PROCEDURE fullvectorize$cid();";
6048 $sql.=
"create trigger zread{$cid} AFTER INSERT OR UPDATE OR DELETE ON doc$cid FOR EACH ROW EXECUTE PROCEDURE setread();";
6049 $sql.=
"create trigger FIXDOC{$cid} AFTER INSERT ON doc$cid FOR EACH ROW EXECUTE PROCEDURE fixeddoc();";
6064 if ($v[
"unique"]) $unique =
"unique";
6066 if ($v[
"using"] !=
"") {
6068 if ($v[
"using"][0] ==
"@") {
6069 $v[
"using"] =
getParam(substr($v[
"using"], 1));
6071 $t.= sprintf(
"CREATE $unique INDEX %s$id on doc$id using %s(%s);\n", $k, $v[
"using"], $v[
"on"]);
6073 $t.= sprintf(
"CREATE $unique INDEX %s$id on doc$id(%s);\n", $k, $v[
"on"]);
6090 if (is_array($reg)) {
6091 $aid = $reg[
'layout'];
6092 if ($reg[
'index'] !=
'') {
6093 $index = $reg[
'index'];
6097 if ($oa->usefor !=
'Q') {
6098 $template = $this->
getValue($oa->id);
6104 $template = $tt[$index];
6107 if ($template ==
"") {
6126 $zoneElements = $this->
parseZone($zone);
6127 if ($zoneElements ===
false) {
6131 return $zoneElements[
'modifier'];
6143 $zoneElements = $this->
parseZone($zone);
6144 if ($zoneElements ===
false) {
6148 return $zoneElements[
'transform'];
6160 if (is_array($tdefval)) {
6161 foreach ($tdefval as $aid => $dval) {
6165 if (empty($oattr)) $ok =
false;
6166 elseif (!method_exists($oattr,
"inArray")) $ok =
false;
6167 elseif ($forcedefault) $ok =
true;
6168 elseif (!$oattr->inArray()) $ok =
true;
6169 elseif ($oattr->fieldSet->format !=
"empty" && $oattr->fieldSet->getOption(
"empty") !=
"yes") {
6176 $this->$aid = $dval;
6194 if (($this->name ==
"") && ($this->initid > 0)) {
6196 if ($dfam->name ==
"")
return sprintf(
"no family name %s", $dfam->id);
6212 $listattr = $this->GetAttributes();
6213 foreach ($listattr as $i => $attr) {
6214 if (($attr->mvisibility ==
"H") || ($attr->mvisibility ==
"I") || ($attr->mvisibility ==
"R") || ($attr->mvisibility ==
"S")) {
6215 $this->attributes->attr[$i]->mvisibility =
"W";
6229 if ($this->prelid > 0) {
6231 $d =
getTDoc($this->dbaccess, $this->prelid);
6235 if (controlTDoc(
$d,
"view")) {
6236 if (!in_array(
$d[
"initid"], array_keys($tr))) {
6237 $tr[
$d[
"initid"]] = $d[
"title"];
6238 if ($d[
"prelid"] > 0) $d =
getTDoc($this->dbaccess, $d[
"prelid"]);
6240 }
else $fini =
true;
6241 }
else $fini =
true;
6257 final public function viewDoc($layout =
"FDL:VIEWBODYCARD",
$target =
"_self", $ulink =
true, $abstract =
false, $changelayout =
false)
6262 if ($reg ===
false) {
6263 return sprintf(_(
"error in pzone format %s") , $layout);
6266 if (array_key_exists(
'args', $reg)) {
6269 $layout = $reg[
'fulllayout'];
6270 if (array_key_exists(
'argv', $reg)) {
6271 foreach ($reg[
'argv'] as $k => $v) {
6272 $ZONE_ARGS[$k] = $v;
6277 if (!$changelayout) {
6285 if (strtolower($ext) ==
"odt") {
6286 include_once (
'Class.OOoLayout.php');
6289 $this->lay =
new OOoLayout($tplfile, $action, $this);
6291 $this->lay =
new Layout($tplfile, $action,
"");
6294 $this->lay->setZone($reg);
6296 $this->lay->set(
"_readonly", ($this->
Control(
'edit') !=
""));
6297 $method = strtok(strtolower($reg[
'layout']) ,
'.');
6299 if (method_exists($this,
$method)) {
6303 catch(Exception $e) {
6304 if ((!file_exists($this->lay->file) && (!$this->lay->template))) {
6305 return sprintf(_(
"template file (layout [%s]) not found") , $layout);
6312 if ((!file_exists($this->lay->file) && (!$this->lay->template))) {
6313 return sprintf(_(
"template file (layout [%s]) not found") , $layout);
6316 $laygen = $this->lay->gen();
6318 if (!$changelayout) $this->lay = $play;
6322 return preg_replace(array(
6323 "/href=\"index\.php[^\"]*\"/i",
6324 "/onclick=\"[^\"]*\"/i",
6325 "/ondblclick=\"[^\"]*\"/i"
6334 return preg_replace(
"/\?session=[^&]*&/",
"?", $laygen);
6336 if ($binary && (
$target !=
"ooo")) {
6338 $tmpfile = uniqid(
getTmpDir() .
"/fdllay") .
".html";
6339 $nc = file_put_contents($tmpfile, $laygen);
6382 $nattr = count($listattr);
6386 $currentFrameId =
"";
6388 $changeframe =
false;
6389 $tableframe = array();
6390 $tableimage = array();
6395 $onlytab = strtolower(getHttpVars(
"onlytab"));
6397 $showonlytab = ($onlytab ? $onlytab :
false);
6399 $this->
addUTag($this->userid,
"lasttab", $onlytab);
6401 foreach ($listattr as $i => $attr) {
6402 if ($onlytab && ($attr->fieldSet->id != $onlytab && $attr->fieldSet->fieldSet->id != $onlytab))
continue;
6407 $value = chop($this->GetValue($i));
6408 if (!$attr->fieldSet) {
6409 addWarningMsg(sprintf(_(
"unknow set for attribute %s %s") , $attr->id, $attr->getLabel()));
6412 $frametpl = $attr->fieldSet->getOption(
"viewtemplate");
6413 if ($attr->fieldSet && ($frametpl && $attr->fieldSet->type !=
"array")) {
6415 if ($currentFrameId != $attr->fieldSet->id) {
6416 if (($attr->fieldSet->mvisibility !=
"H") && ($attr->fieldSet->mvisibility !=
"I")) {
6417 $changeframe =
true;
6418 $currentFrameId = $attr->fieldSet->id;
6419 $currentFrame = $attr->fieldSet;
6424 $goodvalue = (((
$value !=
"") || ($attr->type ==
"array") || $attr->getOption(
"showempty")) && ($attr->mvisibility !=
"H") && ($attr->mvisibility !=
"I") && ($attr->mvisibility !=
"O") && (!$attr->inArray()));
6425 if (($attr->type ==
"array") && (!$attr->getOption(
"showempty"))) {
6426 if (count($this->
getAValues($attr->id)) == 0) $goodvalue =
false;
6431 $toptab = $attr->getTab();
6432 if ($toptab) $tabonfly = ($toptab->getOption(
"viewonfly") ==
"yes");
6433 if ($tabonfly && (!$showonlytab)) {
6434 $ut = $this->getUtag(
"lasttab");
6435 if ($ut) $showonlytab = $ut->comment;
6436 elseif ($attr->fieldSet->id && $attr->fieldSet->fieldSet) {
6437 $showonlytab = $attr->fieldSet->fieldSet->id;
6440 $attrInNextTab = ($tabonfly && $toptab && ($toptab->id != $showonlytab));
6441 if (!$attrInNextTab) {
6442 $viewtpl = $attr->getOption(
"viewtemplate");
6444 if ($viewtpl ==
"none") {
6448 $attr->setOption(
"vlabel",
"none");
6450 $htmlvalue = sprintf(
"[ZONE FDL:VIEWTPL?id=%d&famid=%d&target=%s&zone=%s]", $this->
id, $this->fromid,
$target, $viewtpl);
6453 if (((
$value ==
"") && ($attr->type !=
"array")) || (($attr->type ==
"array") && (count($this->
getAValues($attr->id)) == 0))) $htmlvalue = $attr->getOption(
"showempty");
6454 else $htmlvalue = $this->GetHtmlValue($attr,
$value,
$target, $ulink);
6460 }
else $htmlvalue =
"";
6462 if (($htmlvalue ===
false) || ($goodvalue)) {
6463 if ($currentFrameId != $attr->fieldSet->id) {
6464 if (($currentFrameId !=
"") && ($attr->fieldSet->mvisibility !=
"H")) $changeframe =
true;
6471 $changeframe =
false;
6472 if (($v + $nbimg) > 0) {
6474 $frames[$k][
"frametext"] = ($oaf && $oaf->getOption(
"vlabel") !=
"none") ?
mb_ucfirst($this->GetLabel($currentFrameId)) :
"";
6475 $frames[$k][
"frameid"] = $currentFrameId;
6476 $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor",
false) :
false;
6478 $frames[$k][
"tag"] =
"";
6479 $frames[$k][
"TAB"] =
false;
6480 if (($currentFrame->fieldSet->id !=
"") && ($currentFrame->fieldSet->id !=
"FIELD_HIDDENS")) {
6481 $frames[$k][
"tag"] =
"TAG" . $currentFrame->fieldSet->id;
6482 $frames[$k][
"TAB"] =
true;
6483 $ttabs[$currentFrame->fieldSet->id] = array(
6484 "tabid" => $currentFrame->fieldSet->id,
6485 "tabtitle" => ($currentFrame->fieldSet->getOption(
"vlabel") ==
"none") ?
' ' :
mb_ucfirst($currentFrame->fieldSet->getLabel())
6488 $frames[$k][
"viewtpl"] = ($frametpl !=
"");
6489 $frames[$k][
"zonetpl"] = ($frametpl !=
"") ? sprintf(
"[ZONE FDL:VIEWTPL?id=%d&famid=%d&target=%s&zone=%s]", $this->
id, $this->fromid,
$target, $frametpl) :
'';
6491 $frames[$k][
"rowspan"] = $v + 1;
6492 $frames[$k][
"TABLEVALUE"] =
"TABLEVALUE_$k";
6494 $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
6495 $frames[$k][
"IMAGES"] =
"IMAGES_$k";
6496 $this->lay->SetBlockData($frames[$k][
"IMAGES"], $tableimage);
6497 $frames[$k][
"notloaded"] =
false;
6498 if ($oaf->type ==
"frame" && (count($tableframe) + count($tableimage)) == 0) {
6499 if (!$frames[$k][
"viewtpl"]) {
6500 $frames[$k][
"viewtpl"] =
true;
6501 $frames[$k][
"zonetpl"] = _(
"Loading...");
6502 $frames[$k][
"notloaded"] =
true;
6507 $tableframe = array();
6508 $tableimage = array();
6514 if ($htmlvalue ===
false) {
6516 if ($currentFrameId != $attr->fieldSet->id) {
6517 if (($attr->fieldSet->mvisibility !=
"H") && ($attr->fieldSet->mvisibility !=
"I")) {
6518 $changeframe =
true;
6519 $currentFrameId = $attr->fieldSet->id;
6520 $currentFrame = $attr->fieldSet;
6528 switch ($attr->type) {
6530 $tableimage[$nbimg][
"imgsrc"] = $htmlvalue;
6531 $tableimage[$nbimg][
"itarget"] = ($action->Read(
"navigator",
"") ==
"NETSCAPE") ?
"_self" :
"_blank";
6532 $width = $attr->getOption(
"iwidth",
"80px");
6533 $tableimage[$nbimg][
"imgwidth"] = $width;
6534 if (strstr($htmlvalue,
'EXPORTFILE')) $tableimage[$nbimg][
"imgthumbsrc"] = $htmlvalue .
"&width=" . intval($width);
6535 else $tableimage[$nbimg][
"imgthumbsrc"] = $htmlvalue;
6539 $tableframe[$v][
"nonelabel"] =
false;
6540 $tableframe[$v][
"normallabel"] =
true;
6541 $tableframe[$v][
"uplabel"] =
false;
6542 $tableframe[$v][
"value"] = $htmlvalue;
6546 if (($attr->fieldSet->mvisibility !=
"H") && ($htmlvalue !==
"" || $goodvalue)) {
6547 $currentFrameId = $attr->fieldSet->id;
6548 $currentFrame = $attr->fieldSet;
6551 if ($attr->type !=
"image") {
6552 $tableframe[$v][
"wvalue"] = (($attr->type ==
"array") && ($attr->getOption(
"vlabel") ==
"up" || $attr->getOption(
"vlabel") ==
"none")) ?
"1%" :
"30%";
6553 $tableframe[$v][
"ndisplay"] =
"inline";
6555 if ($attr->getOption(
"vlabel") ==
"none") {
6556 $tableframe[$v][
"nonelabel"] =
true;
6557 $tableframe[$v][
"normallabel"] =
false;
6558 }
else if ($attr->getOption(
"vlabel") ==
"up") {
6559 if ($attr->type ==
"array") {
6560 $tableframe[$v][
"nonelabel"] =
true;
6561 $tableframe[$v][
"normallabel"] =
false;
6563 $tableframe[$v][
"normallabel"] =
false;
6564 $tableframe[$v][
"uplabel"] =
true;
6567 $tableframe[$v][
"name"] = $this->GetLabel($attr->id);
6568 if (($attr->type ==
"htmltext") && (count($tableframe) == 1)) {
6569 $keys = array_keys($listattr);
6570 $na = $listattr[$keys[$iattr]];
6571 if ($na->fieldSet->id != $attr->fieldSet->id) {
6572 $tableframe[$v][
"ndisplay"] =
"none";
6573 $tableframe[$v][
"wvalue"] =
"1%";
6577 $tableframe[$v][
"classback"] = ($attr->usefor ==
"O") ?
"FREEDOMOpt" :
"FREEDOMBack1";
6580 $tableimage[$nbimg][
"imgalt"] = $this->GetLabel($attr->id);
6586 if (($v + $nbimg) > 0)
6589 if ($oaf) $frames[$k][
"frametext"] = ($oaf->getOption(
"vlabel") !=
"none") ?
mb_ucfirst($this->GetLabel($currentFrameId)) :
"";
6590 else $frames[$k][
"frametext"] =
'';
6591 $frames[$k][
"frameid"] = $currentFrameId;
6592 $frames[$k][
"tag"] =
"";
6593 $frames[$k][
"TAB"] =
false;
6594 $frames[$k][
"viewtpl"] = ($frametpl !=
"");
6595 $frames[$k][
"zonetpl"] = ($frametpl !=
"") ? sprintf(
"[ZONE FDL:VIEWTPL?id=%d&famid=%d&target=%s&zone=%s]", $this->
id, $this->fromid,
$target, $frametpl) :
'';
6597 $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor",
false) :
false;
6598 if (($currentFrame->fieldSet->id !=
"") && ($currentFrame->fieldSet->id !=
"FIELD_HIDDENS")) {
6599 $frames[$k][
"tag"] =
"TAG" . $currentFrame->fieldSet->id;
6600 $frames[$k][
"TAB"] =
true;
6601 $ttabs[$currentFrame->fieldSet->id] = array(
6602 "tabid" => $currentFrame->fieldSet->id,
6603 "tabtitle" => ($currentFrame->fieldSet->getOption(
"vlabel") ==
"none") ?
' ' :
mb_ucfirst($currentFrame->fieldSet->getLabel())
6606 $frames[$k][
"rowspan"] = $v + 1;
6607 $frames[$k][
"TABLEVALUE"] =
"TABLEVALUE_$k";
6609 $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
6611 $frames[$k][
"IMAGES"] =
"IMAGES_$k";
6612 $this->lay->SetBlockData($frames[$k][
"IMAGES"], $tableimage);
6613 $frames[$k][
"notloaded"] =
false;
6614 if ($oaf->type ==
"frame" && (count($tableframe) + count($tableimage)) == 0) {
6615 if (!$frames[$k][
"viewtpl"]) {
6616 $frames[$k][
"viewtpl"] =
true;
6617 $frames[$k][
"zonetpl"] = _(
"Loading...");
6618 $frames[$k][
"notloaded"] =
true;
6623 $this->lay->SetBlockData(
"TABLEBODY", $frames);
6624 $this->lay->SetBlockData(
"TABS", $ttabs);
6625 $this->lay->Set(
"ONETAB", count($ttabs) > 0);
6626 $this->lay->Set(
"NOTAB", (
$target ==
"mail") || $onlytab);
6627 $this->lay->Set(
"docid", $this->
id);
6629 if (count($ttabs) > 0) {
6630 $this->lay->Set(
"firsttab",
false);
6631 $ut = $this->getUtag(
"lasttab");
6632 if ($ut) $firstopen = $ut->comment;
6633 else $firstopen =
false;
6634 foreach ($ttabs as $k => $v) {
6636 if ($oa->getOption(
"firstopen") ==
"yes") $this->lay->set(
"firsttab", $k);
6637 if ($firstopen == $oa->id) $this->lay->Set(
"firsttab", $k);
6648 $this->lay->set(
"iconsrc", $this->
getIcon());
6651 else $this->lay->set(
"state",
"");
6659 if (
$err ==
"")
$err = $this->control(
"wask");
6661 $this->lay->template =
$err;
6667 foreach ($answers as $ka => $ans) {
6668 $utags = $this->
searchUTags(
"ASK_" . $ans[
"waskid"],
false,
true);
6669 $wask = new_doc($this->dbaccess, $ans[
"waskid"]);
6675 foreach ($utags as $k => $v) {
6676 $taguid[] = $v[
"uid"];
6678 $t[$k][
"label"] = $wask->getAskLabel($v[
"comment"]);
6679 $t[$k][
"ask"] = $wask->getvalue(
"was_ask");
6688 foreach (
$t as $k => $v) {
6689 if ($v[
"comment"] != $prevc) {
6690 $prevc = $v[
"comment"];
6693 $t[$k][
"class"] = (($odd % 2) == 0) ?
"evenanswer" :
"oddanswer";
6696 $ru = $wask->getUsersForAcl(
'answer');
6697 $una = array_diff(array_keys($ru) , $taguid);
6702 foreach ($una as $k => $v) {
6703 $tuna[$v] = $ru[$v][
"login"];
6706 asort($tuna, SORT_STRING);
6707 foreach ($tuna as $k => $v) {
6709 "login" => $ru[$k][
"login"],
6710 "fn" => $ru[$k][
"firstname"],
6711 "ln" => $ru[$k][
"lastname"]
6715 $this->lay->setBlockData(
"ANSWERS" . $wask->id,
$t);
6716 $this->lay->setBlockData(
"NOTANS" . $wask->id, $tna);
6718 $title.= $wask->getTitle();
6720 $this->lay->set(
"asktitle",
$title);
6722 "waskid" => $wask->id,
6723 "nacount" => sprintf(_(
"number of waiting answers %d") , count($una)) ,
6724 "count" => (count(
$t) > 1) ? sprintf(_(
"%d answers") , count(
$t)) : sprintf(_(
"%d answer") , count(
$t)) ,
6725 "ask" => $wask->getValue(
"was_ask")
6728 $this->lay->setBlockData(
"WASK", $tw);
6729 $this->lay->set(
"docid", $this->
id);
6736 return strcasecmp(
$a[
"comment"] .
$a[
"uname"], $b[
"comment"] . $b[
"uname"]);
6745 $this->lay->set(
"iconsrc", $this->
getIcon());
6747 $this->lay->Set(
"ficonsrc",
$fdoc->getIcon());
6749 $this->lay->Set(
"username",
$owner->firstname .
" " .
$owner->lastname);
6750 $this->lay->Set(
"userid",
$owner->fid);
6751 $this->lay->Set(
"lockedby", $this->lay->get(
"locked"));
6753 $this->lay->Set(
"lockdomain",
'');
6754 if ($this->locked == - 1) {
6755 $this->lay->Set(
"lockedid",
false);
6757 $user =
new User(
"", abs($this->locked));
6759 if ($this->lockdomainid) {
6760 $this->lay->Set(
"lockdomain", sprintf(_(
"in domain %s") , $this->
getDocAnchor($this->lockdomainid,
'_blank',
true,
'',
false,
true,
true)));
6762 $this->lay->Set(
"lockedid",
$user->fid);
6766 if (($this->locked == - 1) || ($this->lmodify !=
'Y')) $this->lay->Set(
"state", _(
$state));
6767 else $this->lay->Set(
"state", sprintf(_(
"current (<i>%s</i>)") , _(
$state)));
6768 }
else $this->lay->set(
"state", _(
"no state"));
6769 if (is_numeric($this->state) && ($this->state > 0) && (!$this->wid)) {
6770 $this->lay->set(
"freestate", $this->state);
6771 }
else $this->lay->set(
"freestate",
false);
6772 $this->lay->set(
"setname", ($this->name ==
"") && $action->parent->Haspermission(
"FREEDOM_MASTER",
"FREEDOM"));
6773 $this->lay->set(
"hasrevision", ($this->
revision > 0));
6774 $this->lay->Set(
"moddate", strftime(
"%d/%m/%Y %H:%M:%S", $this->revdate));
6775 $this->lay->set(
"moddatelabel", _(
"last modification date"));
6776 if ($this->locked == - 1) {
6777 if ($this->doctype ==
'Z') $this->lay->set(
"moddatelabel", _(
"suppression date"));
6778 else $this->lay->set(
"moddatelabel", _(
"revision date"));
6780 if (GetParam(
"CORE_LANG") ==
"fr_FR") {
6781 $this->lay->Set(
"revdate", strftime(
"%a %d %b %Y %H:%M", $this->revdate));
6783 $this->lay->Set(
"revdate", strftime(
"%x %T", $this->revdate));
6785 $this->lay->Set(
"version", $this->version);
6787 if ((abs($this->profid) > 0) && ($this->profid != $this->
id)) {
6789 $this->lay->Set(
"profile", $this->
getDocAnchor(abs($this->profid) ,
'_blank',
true,
'',
false,
'latest',
true));
6791 if ($this->profid == 0) {
6792 $this->lay->Set(
"profile", _(
"no access control"));
6794 if ($this->dprofid == 0) {
6796 $this->lay->Set(
"profile", $this->
getDocAnchor(abs($this->profid) ,
'_blank',
true, _(
"specific control") ,
false,
'latest',
true));
6798 $this->lay->Set(
"profile", $this->
getDocAnchor(abs($this->dprofid) ,
'_blank',
true, _(
"dynamic control") ,
false,
'latest',
true));
6802 if ($this->cvid == 0) {
6803 $this->lay->Set(
"cview", _(
"no view control"));
6805 $this->lay->Set(
"cview", $this->
getDocAnchor($this->cvid,
'_blank',
true,
'',
false,
'latest',
true));
6807 if ($this->prelid == 0) {
6808 $this->lay->Set(
"prel", _(
"no folder"));
6811 $this->lay->Set(
"prel", $this->
getDocAnchor($this->prelid,
'_blank',
true,
'',
false,
'latest',
true));
6814 foreach ($fldids as
$fldid) {
6815 if ($fldid != $this->prelid) {
6817 "fld" => $this->
getDocAnchor($fldid,
'_blank',
true,
'',
false,
'latest',
true)
6821 $this->lay->setBlockData(
"FOLDERS", $tfld);
6823 if ($this->allocated == 0) {
6824 $this->lay->Set(
"allocate", _(
"no allocate"));
6825 $this->lay->Set(
"allocateid",
false);
6827 $user =
new User(
"", ($this->allocated));
6828 $this->lay->Set(
"allocate",
$user->firstname .
" " .
$user->lastname);
6829 $this->lay->Set(
"allocateid",
$user->fid);
6832 if ($this->forumid ==
"") {
6833 $this->lay->Set(
"forum", _(
"forum disallowed"));
6834 $this->lay->Set(
"hforum",
false);
6835 }
else if ($this->forumid === 0) {
6836 $this->lay->Set(
"forum", _(
"forum allowed"));
6837 $this->lay->Set(
"hforum",
false);
6839 if ($this->forumid > 0) $this->lay->Set(
"forum", _(
"forum opened"));
6840 else $this->lay->Set(
"forum", _(
"forum closed"));
6841 $this->lay->Set(
"hforum",
true);
6842 $this->lay->Set(
"forumid", abs($this->forumid));
6847 $this->lay->Set(
"Timers", (count($tms) > 0));
6856 $tableframe = array();
6858 foreach ($listattr as $i => $attr) {
6861 $value = chop($this->GetValue($i));
6863 if ((
$value !=
"") && ($attr->mvisibility !=
"H") && ($attr->mvisibility !=
"I")) {
6865 switch ($attr->type) {
6868 $img =
"<IMG align=\"absbottom\" height=\"30px\" SRC=\"" . $this->GetHtmlValue($listattr[$i],
$value,
$target, $ulink) .
"&height=30\">";
6869 $tableframe[] = array(
6870 "name" => $attr->getLabel() ,
6878 $tableframe[] = array(
6879 "name" => $attr->getLabel() ,
6881 "value" => $this->GetHtmlValue($listattr[$i],
$value,
$target, $ulink = 1, -1,
true,
true)
6889 $this->lay->SetBlockData(
"TABLEVALUE", $tableframe);
6892 final public function viewattr(
$target =
"_self", $ulink =
true, $abstract =
false, $viewhidden =
false)
6896 foreach ($listattr as $k => $v) {
6897 $value = chop($this->GetValue($v->id));
6900 $this->lay->Set(
"S_" . strtoupper($v->id) , (
$value !=
""));
6902 if ((($v->mvisibility ==
"H") && (!$viewhidden)) || ($v->mvisibility ==
"I") || (($abstract) && (!$v->isInAbstract))) {
6903 $this->lay->Set(
"V_" . strtoupper($v->id) ,
"");
6904 $this->lay->Set(
"L_" . strtoupper($v->id) ,
"");
6907 if ($v->type ==
"array") {
6911 foreach ($tva as $kindex => $kvalues) {
6912 foreach ($kvalues as $kaid => $va) {
6914 if ($oa->getOption(
"multiple") ==
"yes") {
6916 $oa->setOption(
"multiple",
"no");
6917 $values = explode(
"<BR>", $va);
6919 foreach ($values as $ka => $va) {
6920 $ovalues[] = $this->GetOOoValue($oa, $va);
6923 $tmkeys[$kindex][
"V_" . strtoupper($kaid) ] = $ovalues;
6924 $oa->setOption(
"multiple",
"yes");
6927 $tmkeys[$kindex][
"V_" . strtoupper($kaid) ] = $this->GetOOoValue($oa, $va);
6932 $this->lay->setRepeatable($tmkeys);
6934 $ovalue = $this->GetOOoValue($v,
$value);
6935 if ($v->isMultiple()) $ovalue = str_replace(
"<text:tab/>",
', ', $ovalue);
6936 $this->lay->Set(
"V_" . strtoupper($v->id) , $ovalue);
6938 if ((!$v->inArray()) && ($v->getOption(
"multiple") ==
"yes")) {
6941 $v->setOption(
"multiple",
"no");
6942 foreach ($values as $ka => $va) {
6943 $ovalues[] = $this->GetOOoValue($v, $va);
6945 $v->setOption(
"multiple",
"yes");
6947 $this->lay->setColumn(
"V_" . strtoupper($v->id) , $ovalues);
6953 }
else $this->lay->Set(
"V_" . strtoupper($v->id) , $this->GetHtmlValue($v,
$value,
$target, $ulink));
6954 $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
6959 foreach ($listattr as $k => $v) {
6960 $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
6966 foreach ($this->fields as $k => $v) {
6967 if (
$target ==
'ooo') $this->lay->Set(strtoupper($v) , ($this->$v === null) ?
false : str_replace(array(
6976 else $this->lay->Set(strtoupper($v) , ($this->$v === null) ?
false : $this->$v);
6978 if (
$target ==
'ooo') $this->lay->Set(
"V_TITLE", $this->lay->get(
"TITLE"));
6979 else $this->lay->Set(
"V_TITLE", $this->
getDocAnchor($this->
id,
$target, $ulink,
false,
false));
6989 if (!preg_match(
"/^[A-Z]/i",
$name)) {
6990 return (sprintf(_(
"name must containt only alphanumeric characters: invalid [%s]") ,
$name));
6992 return (sprintf(_(
"Cannot set logical name %s because object is not affected") ,
$name));
6993 } elseif ($this->
isAffected() && ($this->name !=
"") && ($this->doctype !=
'Z')) {
6994 return (sprintf(_(
"Logical name %s already set for %s") ,
$name, $this->title));
6998 if (
$d &&
$d[
"doctype"] !=
'Z') {
6999 return sprintf(_(
"Logical name %s already use in document %s") ,
$name,
$d[
"title"]);
7001 $this->name =
$name;
7036 include_once (
"FDL/editutil.php");
7037 include_once (
"FDL/Class.SearchDoc.php");
7044 if ($this->fromid > 0) {
7046 $this->lay->Set(
"title", sprintf(_(
"new %s") , $cdoc->title));
7050 if (!$this->
isAlive())
$action->ExitError(_(
"document not referenced"));
7051 $this->lay->Set(
"title", $this->title);
7053 $this->lay->Set(
"id",
$docid);
7054 $this->lay->Set(
"classid", $this->fromid);
7057 $s->addFilter(
"help_family='%d'", $this->fromid);
7058 $help =
$s->search();
7060 $helpattr = array();
7061 if (
$s->count() > 0) {
7062 $helpid = $help[0][
"id"];
7063 $helpattr = $this->
_val2array($help[0][
"help_sec_key"]);
7071 $nattr = count($listattr);
7074 $currentFrameId =
"";
7075 $currentFrameText =
"";
7076 $currentFrame = null;
7077 $changeframe =
false;
7080 $tableframe = array();
7085 foreach ($listattr as $i => $attr) {
7090 $value = $this->GetValue($attr->id);
7094 if (!$attr->fieldSet) {
7095 addWarningMsg(sprintf(_(
"unknow set for attribute %s %s") , $attr->id, $attr->getLabel()));
7098 $frametpl = $attr->fieldSet->getOption(
"edittemplate");
7100 if ($currentFrameId != $attr->fieldSet->id) {
7102 $changeframe =
true;
7103 $currentFrameId = $attr->fieldSet->id;
7104 $currentFrame = $attr->fieldSet;
7105 if ($currentFrame->getOption(
"vlabel") ==
"none") $currentFrameText =
'';
7106 else $currentFrameText =
mb_ucfirst($currentFrame->GetLabel());
7108 } elseif ($currentFrameId !=
"") $changeframe =
true;
7111 $changeframe =
false;
7113 $frames[$k][
"frametext"] = $currentFrameText;
7114 $frames[$k][
"frameid"] = $currentFrameId;
7115 $frames[$k][
"tag"] =
"";
7116 $frames[$k][
"TAB"] =
false;
7117 $frames[$k][
"edittpl"] = ($frametpl !=
"");
7118 $frames[$k][
"zonetpl"] = ($frametpl !=
"") ? sprintf(
"[ZONE FDL:EDITTPL?id=%d&famid=%d&zone=%s]", $this->
id, $this->fromid, $frametpl) :
'';
7121 $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor",
false) :
false;
7122 if ($currentFrame && ($currentFrame->fieldSet->id !=
"") && ($currentFrame->fieldSet->id !=
"FIELD_HIDDENS")) {
7123 $frames[$k][
"tag"] =
"TAG" . $currentFrame->fieldSet->id;
7124 $frames[$k][
"TAB"] =
true;
7125 $ttabs[$currentFrame->fieldSet->id] = array(
7126 "tabid" => $currentFrame->fieldSet->id,
7127 "tabtitle" => ($currentFrame->fieldSet->getOption(
"vlabel") ==
"none") ?
' ' :
mb_ucfirst($currentFrame->fieldSet->getLabel())
7130 $frames[$k][
"TABLEVALUE"] =
"TABLEVALUE_$k";
7131 $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
7133 $tableframe = array();
7141 $currentFrameId = $listattr[$i]->fieldSet->id;
7142 $currentFrame = $listattr[$i]->fieldSet;
7143 if ($currentFrame->getOption(
"vlabel") ==
"none") $currentFrameText =
'';
7144 else $currentFrameText =
mb_ucfirst($currentFrame->GetLabel());
7145 if (($listattr[$i]->mvisibility ==
"H") || ($listattr[$i]->mvisibility ==
"R")) {
7147 $thidden[$ih][
"hname"] =
"_" . $listattr[$i]->id;
7148 $thidden[$ih][
"hid"] = $listattr[$i]->id;
7149 if ((
$value ==
"") && ($this->
id == 0)) $thidden[$ih][
"hvalue"] =
GetHttpVars($listattr[$i]->
id);
7150 else $thidden[$ih][
"hvalue"] = chop(htmlentities(
$value, ENT_COMPAT,
"UTF-8"));
7152 $thidden[$ih][
"inputtype"] =
getHtmlInput($this, $listattr[$i],
$value,
"",
"",
true);
7155 $tableframe[$v][
"value"] = chop(htmlentities(
$value, ENT_COMPAT,
"UTF-8"));
7156 $label = $listattr[$i]->getLabel();
7157 $tableframe[$v][
"attrid"] = $listattr[$i]->id;
7160 if ($listattr[$i]->needed) $tableframe[$v][
"labelclass"] =
"FREEDOMLabelNeeded";
7161 else $tableframe[$v][
"labelclass"] =
"FREEDOMLabel";
7162 $elabel = $listattr[$i]->getoption(
"elabel");
7163 $elabel = str_replace(
"'",
"’", $elabel);
7164 $tableframe[$v][
"elabel"] =
mb_ucfirst(str_replace(
'"',
"&rquot;", $elabel));
7165 $tableframe[$v][
"helpid"] = $helpid;
7166 $tableframe[$v][
"ehelp"] = ($helpid !=
false) && (in_array($listattr[$i]->
id, $helpattr));
7168 $tableframe[$v][
"multiple"] = ($attr->getOption(
"multiple") ==
"yes") ?
"true" :
"false";
7169 $tableframe[$v][
"atype"] = $attr->type;
7171 $tableframe[$v][
"classback"] = ($attr->usefor ==
"O") ?
"FREEDOMOpt" :
"FREEDOMBack1";
7173 $tableframe[$v][
"SINGLEROW"] =
true;
7175 $vlabel = $listattr[$i]->getOption(
"vlabel");
7176 if ((($listattr[$i]->
type ==
"array") && ($vlabel !=
'left')) || (($listattr[$i]->
type ==
"htmltext") && ($vlabel !=
'left')) || ($vlabel ==
'up') || ($vlabel ==
'none')) $tableframe[$v][
"SINGLEROW"] =
false;
7178 $tableframe[$v][
"viewlabel"] = (($listattr[$i]->type !=
"array") && ($vlabel !=
'none'));
7179 $edittpl = $listattr[$i]->getOption(
"edittemplate");
7181 if ($edittpl ==
"none") {
7182 unset($tableframe[$v]);
7185 $tableframe[$v][
"SINGLEROW"] =
false;
7186 $tableframe[$v][
"viewlabel"] =
false;
7188 $tableframe[$v][
"inputtype"] = sprintf(
"[ZONE FDL:EDITTPL?id=%d&famid=%d&zone=%s]", $this->
id, $this->fromid, $edittpl);
7199 $frames[$k][
"frametext"] = $currentFrameText;
7200 $frames[$k][
"frameid"] = $currentFrameId;
7201 $frames[$k][
"TABLEVALUE"] =
"TABLEVALUE_$k";
7202 $frames[$k][
"tag"] =
"";
7203 $frames[$k][
"TAB"] =
false;
7204 $frames[$k][
"edittpl"] = ($frametpl !=
"");
7205 $frames[$k][
"zonetpl"] = ($frametpl !=
"") ? sprintf(
"[ZONE FDL:EDITTPL?id=%d&famid=%d&zone=%s]", $this->
id, $this->fromid, $frametpl) :
'';
7208 $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor",
false) :
false;
7209 if (($currentFrame->fieldSet->id !=
"") && ($currentFrame->fieldSet->id !=
"FIELD_HIDDENS")) {
7210 $frames[$k][
"tag"] =
"TAG" . $currentFrame->fieldSet->id;
7211 $frames[$k][
"TAB"] =
true;
7212 $ttabs[$currentFrame->fieldSet->id] = array(
7213 "tabid" => $currentFrame->fieldSet->id,
7214 "tabtitle" => ($currentFrame->fieldSet->getOption(
"vlabel") ==
"none") ?
' ' :
mb_ucfirst($currentFrame->fieldSet->getLabel())
7217 $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
7219 $this->lay->SetBlockData(
"HIDDENS", $thidden);
7220 $this->lay->SetBlockData(
"TABLEBODY", $frames);
7221 $this->lay->SetBlockData(
"TABS", $ttabs);
7222 $this->lay->Set(
"ONETAB", count($ttabs) > 0);
7223 $this->lay->Set(
"fromid", $this->fromid);
7224 $this->lay->Set(
"docid", $this->
id);
7225 if (count($ttabs) > 0) {
7226 $this->lay->Set(
"firsttab",
false);
7227 $ut = $this->getUtag(
"lasttab");
7228 if ($ut) $firstopen = $ut->comment;
7229 else $firstopen =
false;
7231 foreach ($ttabs as $k => $v) {
7233 if ($oa->getOption(
"firstopen") ==
"yes") $this->lay->Set(
"firsttab", $k);
7234 if ($firstopen == $oa->id) $this->lay->Set(
"firsttab", $k);
7245 include_once (
"FDL/editutil.php");
7248 foreach ($listattr as $k => $v) {
7251 $value = chop($this->GetValue($v->id));
7252 if ($v->mvisibility ==
"R") $v->mvisibility =
"H";
7253 $this->lay->Set(
"V_" . strtoupper($v->id) ,
getHtmlInput($this, $v,
$value,
"",
"", (!$withtd)));
7254 if ($v->needed ==
"Y") $this->lay->Set(
"L_" . strtoupper($v->id) ,
"<B>" . $v->getLabel() .
"</B>");
7255 else $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
7256 $this->lay->Set(
"W_" . strtoupper($v->id) , ($v->mvisibility !=
"H"));
7261 foreach ($listattr as $k => $v) {
7262 $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
7276 foreach ($tFamIdName as $k => $v) {
7277 $this->lay->set(
"IDFAM_$k", $v);
7289 if ($index == - 1) $fileid = $this->
getValue($attrid);
7290 else $fileid = $this->
getTValue($attrid,
'', $index);
7305 if (
$vf->Show($reg[2], $info) ==
"") {
7306 if (
$path) $fname = $info->path;
7307 else $fname = $info->name;
7336 else $fileids[] = $this->
getValue($attr->id);
7339 foreach ($fileids as $k => $fileid) {
7343 if (
$vf->Show($reg[2], $info) ==
"") {
7344 $tinfo[$k] = get_object_vars($info);
7345 $tinfo[$k][
"vid"] = $reg[2];
7361 if (!is_string($filesvalue))
return false;
7363 include_once (
"FDL/Lib.Vault.php");
7366 if (!$info)
return false;
7368 if (isset($info->$key))
return $info->$key;
7369 else return sprintf(_(
"unknow %s file property") , $key);
7371 return get_object_vars($info);
7384 public function exportXml(&$xml, $withfile =
false, $outfile =
"", $wident =
true, $flat =
false, $exportAttributes = array())
7389 $lay->set(
"famname", strtolower($this->fromname));
7390 $lay->set(
"id", ($wident ? $this->
id :
''));
7391 $lay->set(
"name", $this->name);
7392 $lay->set(
"revision", $this->
revision);
7394 $lay->set(
"state", $this->
getState());
7395 $lay->set(
"title", str_replace(array(
7404 $lay->set(
"mdate", strftime(
"%FT%X", $this->revdate));
7405 $lay->set(
"flat", $flat);
7409 foreach (
$la as $k => $v) {
7410 if ((!$v) || ($v->getOption(
"autotitle") ==
"yes") || ($v->usefor ==
'Q')) unset(
$la[$k]);
7412 $option->withFile = $withfile;
7413 $option->outFile = $outfile;
7414 $option->withIdentificator = $wident;
7415 $option->flat = $flat;
7416 $option->exportAttributes = $exportAttributes;
7418 foreach (
$la as $k => & $v) {
7419 if (($v->id !=
"FIELD_HIDDENS") && ($v->type ==
'frame' || $v->type ==
"tab") && ((!$v->fieldSet) || $v->fieldSet->id ==
"FIELD_HIDDENS")) {
7421 "level" => $v->getXmlValue($this, $option)
7428 $lay->setBlockData(
"top", $level1);
7431 $xmlcontent = $lay->gen();
7432 $fo = fopen($outfile,
"w");
7433 $pos = strpos($xmlcontent,
"[FILE64");
7435 while ($pos !==
false) {
7436 if (fwrite($fo, substr($xmlcontent, $bpos, $pos - $bpos))) {
7437 $bpos = strpos($xmlcontent,
"]", $pos) + 1;
7439 $filepath = substr($xmlcontent, $pos + 8, ($bpos - $pos - 9));
7444 $ff = fopen($filepath,
"r");
7445 $size = 6 * 1024 * 57;
7446 while ($buf = fread($ff,
$size)) {
7447 fwrite($fo, base64_encode($buf));
7449 $pos = strpos($xmlcontent,
"[FILE64", $bpos);
7451 $err = sprintf(_(
"exportXml : cannot write file %s") , $outfile);
7455 if (
$err ==
"") fwrite($fo, substr($xmlcontent, $bpos));
7458 if (file_put_contents($outfile, $lay->gen()) ===
false) {
7459 $err = sprintf(_(
"exportXml : cannot write file %s") , $outfile);
7470 final public function toxml($withdtd =
false, $id_doc =
"")
7476 $docid = intval($this->
id);
7477 if ($id_doc ==
"") {
7483 $dbaccess = $action->GetParam(
"FREEDOM_DB");
7484 $fam_doc =
new_Doc($this->dbaccess, $this->fromid);
7485 $name = str_replace(
" ",
"_", $fam_doc->title);
7487 if ($withdtd ==
true) {
7488 $dtd =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>";
7489 $dtd.=
"<!DOCTYPE $name [";
7490 $dtd.= $this->
todtd();
7496 $this->lay =
new Layout(
"FDL/Layout/viewxml.xml", $action);
7497 $this->lay->Set(
"DTD", $dtd);
7498 $this->lay->Set(
"NOM_FAM",
$name);
7499 $this->lay->Set(
"id_doc", $id_doc);
7500 $this->lay->Set(
"TITRE",
$title);
7501 $this->lay->Set(
"ID_FAM", $fam_doc->name);
7502 $this->lay->Set(
"revision", $this->
revision);
7503 $this->lay->Set(
"revdate", $this->revdate);
7513 $nattr = count($listattr);
7516 $currentFrameId =
"";
7518 $changeframe =
false;
7519 $tableframe = array();
7523 foreach ($listattr as $i => $attr) {
7526 if ((chop($listattr[$i]->
id) !=
"") && ($listattr[$i]->
id !=
"FIELD_HIDDENS")) {
7529 if ($currentFrameId != $listattr[$i]->fieldSet->id) {
7530 if ($currentFrameId !=
"") $changeframe =
true;
7536 $changeframe =
false;
7540 $frames[$k][
"FIELD"] = $currentFrameId;
7541 $frames[$k][
"ARGUMENT"] =
"ARGUMENT_$k";
7543 $this->lay->SetBlockData($frames[$k][
"ARGUMENT"], $tableframe);
7544 $frames[$k][
"nom_fieldset"] = $this->GetLabel($currentFrameId);
7546 $tableframe = array();
7552 if (($iattr <= $nattr) && ($this->Getvalue($i) !=
"")) {
7553 $attrtype_idoc =
false;
7554 $attrtype_list =
false;
7556 if (strstr($listattr[$i]->
type,
"textlist") !=
false) {
7557 $attrtype_list =
true;
7559 if ((strstr($listattr[$i]->
type,
"idoclist")) !=
false) {
7560 $attrtype_list =
true;
7561 $attrtype_idoc =
true;
7563 if ((strstr($listattr[$i]->
type,
"idoc")) !=
false) {
7564 $attrtype_idoc =
true;
7566 if ($listattr[$i]->inArray()) {
7567 $attrtype_list =
true;
7570 if ($attrtype_list) {
7572 $value = $this->GetValue($i);
7575 while ($text = each($textlist)) {
7576 $currentFrameId = $listattr[$i]->fieldSet->id;
7577 $tableframe[$v][
"id"] = $listattr[$i]->id;
7578 if ($attrtype_idoc) {
7579 $tableframe[$v][
"value"] = base64_decode($text[1]);
7580 $tableframe[$v][
"type"] =
"idoc";
7582 $tableframe[$v][
"value"] = $text[1];
7583 $tableframe[$v][
"type"] = base64_encode($listattr[$i]->
type);
7585 $tableframe[$v][
"labelText"] = (str_replace(array(
7599 if ($attrtype_idoc) {
7600 $value = base64_decode($this->GetValue($i));
7601 $tableframe[$v][
"type"] =
"idoc";
7605 $value = htmlspecialchars($this->GetValue($i));
7606 $tableframe[$v][
"type"] = base64_encode($listattr[$i]->
type);
7609 $currentFrameId = $listattr[$i]->fieldSet->id;
7610 $tableframe[$v][
"id"] = $listattr[$i]->id;
7611 $tableframe[$v][
"value"] =
$value;
7612 $tableframe[$v][
"labelText"] = addslashes($listattr[$i]->
getLabel());
7625 $frames[$k][
"FIELD"] = $currentFrameId;
7626 $frames[$k][
"ARGUMENT"] =
"ARGUMENT_$k";
7628 $this->lay->SetBlockData($frames[$k][
"ARGUMENT"], $tableframe);
7629 $frames[$k][
"nom_fieldset"] = $this->GetLabel($currentFrameId);
7631 $tableframe = array();
7632 $tableimage = array();
7636 $this->lay->SetBlockData(
"FIELDSET", $frames);
7637 return $this->lay->gen();
7644 $this->lay =
new Layout(
"FDL/Layout/viewdtd.xml", $action);
7647 $name = str_replace(
" ",
"_", $fam_doc->title);
7648 $this->lay->Set(
"doctype", $this->doctype);
7649 $this->lay->Set(
"idfam", $this->fromid);
7650 $this->lay->Set(
"nom_fam",
$name);
7651 $this->lay->Set(
"id_fam",
$name);
7657 $nattr = count($listattr);
7660 $currentFrameId =
"";
7662 $changeframe =
false;
7664 $tableattrs = array();
7665 $tablesetting = array();
7668 foreach ($listattr as $i => $attr) {
7672 if ($currentFrameId != $listattr[$i]->fieldSet->id) {
7673 if ($currentFrameId !=
"") $changeframe =
true;
7679 $changeframe =
false;
7684 $frames[$k][
"name"] = $currentFrameId;
7685 $elements[$k][
"name"] = $currentFrameId;
7687 $elements[$k][
"name"].=
", ";
7689 $elements[$k][
"name"].=
"?, ";
7693 $frames[$k][
"ATTRIBUT_NAME"] =
"ATTRIBUT_NAME_$k";
7694 $frames[$k][
"ATTRIBUT_SETTING"] =
"ATTRIBUT_SETTING_$k";
7696 $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_NAME"], $tableattrs);
7698 $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_SETTING"], $tablesetting);
7700 unset($tablesetting);
7701 $tableattrs = array();
7702 $tablesetting = array();
7709 if ($iattr <= $nattr) {
7711 $currentFrameId = $listattr[$i]->fieldSet->id;
7712 $tablesetting[$v][
"name_attribut"] = $listattr[$i]->id;
7713 $tablesetting[$v][
"labelText"] = addslashes(str_replace(
"%",
"", $listattr[$i]->
getLabel()));
7714 $tablesetting[$v][
"type"] = base64_encode($listattr[$i]->
type);
7715 $tablesetting[$v][
"visibility"] = $listattr[$i]->visibility;
7716 if ($listattr[$i]->needed) {
7721 $insert = $listattr[$i]->id;
7722 if ($listattr[$i]->
type ==
"textlist") {
7723 if ($listattr[$i]->needed) {
7725 $tableattrs[$v][
"name_attribut"] = $insert;
7728 $tableattrs[$v][
"name_attribut"] = $insert;
7731 if ($listattr[$i]->needed) {
7732 $tableattrs[$v][
"name_attribut"] = $insert;
7734 $tableattrs[$v][
"name_attribut"] = ($insert .
"?");
7738 $insert = (
", " . $listattr[$i]->id);
7739 if ($listattr[$i]->
type ==
"textlist") {
7740 if ($listattr[$i]->needed) {
7745 $tableattrs[$v][
"name_attribut"] = $insert;
7747 if ($listattr[$i]->needed) {
7748 $tableattrs[$v][
"name_attribut"] = $insert;
7750 $tableattrs[$v][
"name_attribut"] = ($insert .
"?");
7760 $frames[$k][
"name"] = $currentFrameId;
7762 $elements[$k][
"name"] = $currentFrameId;
7764 $elements[$k][
"name"] = ($currentFrameId .
"?");
7767 $frames[$k][
"ATTRIBUT_NAME"] =
"ATTRIBUT_NAME_$k";
7768 $frames[$k][
"ATTRIBUT_SETTING"] =
"ATTRIBUT_SETTING_$k";
7769 $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_NAME"], $tableattrs);
7771 $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_SETTING"], $tablesetting);
7773 unset($tablesetting);
7774 $tableattrs = array();
7775 $tablesetting = array();
7780 $this->lay->SetBlockData(
"FIELDSET", $frames);
7781 $this->lay->SetBlockData(
"ELEMENT", $elements);
7782 return $this->lay->gen();
7798 if (
$doc->isAlive()) $this->setValue($nameTitle,
$doc->title);
7801 if (!
$doc->isAffected()) $this->deleteValue($nameId);
7811 if ($this->confidential > 0)
return $action->getImageUrl(
"confidential.gif",
true,
$size);
7812 else if ($this->locked == - 1)
return $action->getImageUrl(
"revised.png",
true,
$size);
7813 else if ($this->lockdomainid > 0) {
7814 if ($this->locked > 0) {
7815 if ((abs($this->locked) == $this->userid))
return $action->getImageUrl(
"lockorange.png",
true,
$size);
7816 else return $action->getImageUrl(
"lockred.png",
true,
$size);
7817 }
else return $action->getImageUrl(
"lockorange.png",
true,
$size);
7818 }
else if ($this->allocated == $this->userid)
return $action->getImageUrl(
"lockblue.png",
true,
$size);
7819 else if ((abs($this->locked) == $this->userid))
return $action->getImageUrl(
"lockgreen.png",
true,
$size);
7820 else if ($this->locked != 0)
return $action->getImageUrl(
"lockred.png",
true,
$size);
7821 else if ($this->archiveid != 0)
return $action->getImageUrl(
"archive.png",
true,
$size);
7822 else if ($this->control(
"edit") !=
"")
return $action->getImageUrl(
"nowrite.png",
true,
$size);
7823 else return $action->getImageUrl(
"1x1.gif");
7865 if (is_array(
$id))
return $def;
7866 if (
$id ==
"")
return $def;
7868 if ($this->locked != - 1 || (!
$latest)) {
7877 if ((strpos(
$id,
"\n") !==
false) || (strpos(
$id,
"<BR>") !==
false)) {
7878 $tid = explode(
"\n", str_replace(
"<BR>",
"\n",
$id));
7880 foreach (
$tid as $idone) {
7883 return implode(
"\n", $ttitle);
7894 if ($lastId !=
$id) {
7920 $t = str_replace(
"&",
"&",
$t);
7921 return str_replace(array(
7937 public static function getDate($daydelta = 0, $dayhour =
"", $daymin =
"", $getlocale =
false)
7939 $delta = abs(intval($daydelta));
7940 if ($daydelta > 0) {
7941 $nd = strtotime(
"+$delta day");
7942 }
else if ($daydelta < 0) {
7943 $nd = strtotime(
"-$delta day");
7948 if ($dayhour !==
"") {
7949 $delta = abs(intval($dayhour));
7951 $nd = strtotime(
"+$delta hour",
$nd);
7952 }
else if ($dayhour < 0) {
7953 $nd = strtotime(
"-$delta hour",
$nd);
7955 $delta = abs(intval($daymin));
7957 $nd = strtotime(
"+$delta min",
$nd);
7958 }
else if ($daymin < 0) {
7959 $nd = strtotime(
"-$delta min",
$nd);
7965 if ($isIsoDate)
return date(
"Y-m-d H:i",
$nd);
7966 else return date(
"d/m/Y H:i",
$nd);
7972 if ($isIsoDate)
return date(
"Y-m-d",
$nd);
7973 else return date(
"d/m/Y",
$nd);
7985 $delta = abs(intval($hourdelta));
7987 if ($second)
$format =
"Y-m-d H:i:s";
7990 if ($second)
$format =
"d/m/Y H:i:s";
7993 if ($hourdelta > 0) {
7994 if (is_float($hourdelta)) {
7995 $dm = intval((abs($hourdelta) - $delta) * 60);
7996 return date(
$format, strtotime(
"+$delta hour $dm minute"));
7997 }
else return date(
$format, strtotime(
"+$delta hour"));
7998 }
else if ($hourdelta < 0) {
7999 if (is_float($hourdelta)) {
8000 $dm = intval((abs($hourdelta) - $delta) * 60);
8001 return date(
$format, strtotime(
"-$delta hour $dm minute"));
8002 }
else return date(
$format, strtotime(
"-$delta hour"));
8015 if (intval(
$docid) > 0) {
8017 if (
$doc->isAlive()) {
8019 $ldocid =
$doc->latestId();
8035 if (intval(
$docid) > 0) {
8038 return $tdoc[strtolower($propid) ];
8050 if ($withfirst)
return $action->user->firstname .
" " . $action->user->lastname;
8051 return $action->user->lastname;
8061 return $action->user->fid;
8081 return $action->user->id;
8090 return $action->user->id;
8100 return $mydoc->getValue($idattr);
8110 $nargs = func_num_args();
8111 for ($ip = 0; $ip < $nargs; $ip++) {
8112 $var = func_get_arg($ip);
8114 if ($nargs < 1)
return "";
8115 $fmt = func_get_arg(0);
8117 for ($ip = 1; $ip < $nargs; $ip++) {
8118 if (gettype($var) !=
"array") {
8119 $sp[] = func_get_arg($ip);
8122 $r = vsprintf($fmt, $sp);
8133 foreach ($fa as $aid => $oattr) {
8134 if ($oattr->inArray()) {
8141 foreach (
$ta as $k => $v) {
8150 foreach ($tvid as $k => $vid) {
8152 $dvi->vaultid = $vid;
8165 final public function attachTimer(&$timer, &$origin = null, $execdate = null)
8168 if ($execdate == null) {
8169 $dyn = trim(strtok($timer->getValue(
"tm_dyndate") ,
" "));
8170 if ($dyn) $execdate = $this->
getValue($dyn);
8172 if (method_exists($timer,
'attachDocument')) {
8173 $err = $timer->attachDocument($this, $origin, $execdate);
8175 if ($dyn) $this->
addATag(
"DYNTIMER");
8176 $this->addComment(sprintf(_(
"attach timer %s [%d]") , $timer->title, $timer->id) ,
HISTO_NOTICE);
8177 $this->
addLog(
"attachtimer", array(
8178 "timer" => $timer->id
8182 $err = sprintf(_(
"attachTimer : the timer parameter is not a document of TIMER family"));
8194 if (method_exists($timer,
'unattachDocument')) {
8195 $err = $timer->unattachDocument($this);
8197 $this->addComment(sprintf(_(
"unattach timer %s [%d]") , $timer->title, $timer->id) ,
HISTO_NOTICE);
8198 $this->
addLog(
"unattachtimer", array(
8199 "timer" => $timer->id
8202 }
else $err = sprintf(_(
"unattachTimer : the timer parameter is not a document of TIMER family"));
8209 if (count($tms) == 0) {
8212 foreach ($tms as $k => $v) {
8213 $t = new_doc($this->dbaccess, $v[
"timerid"]);
8215 if (
$t->isAlive()) {
8216 if ($v[
"originid"]) $ori = new_doc($this->dbaccess, $v[
"originid"]);
8232 $err = $timer->unattachAllDocument($this, $origin,
$c);
8233 if (
$err ==
"" &&
$c > 0) {
8234 if ($origin) $this->addComment(sprintf(_(
"unattach %d timers associated to %s") ,
$c, $origin->title) ,
HISTO_NOTICE);
8235 else $this->addComment(sprintf(_(
"unattach all timers [%s]") ,
$c) ,
HISTO_NOTICE);
8236 $this->
addLog(
"unattachtimer", array(
8249 include_once (
"Class.QueryDb.php");
8250 include_once (
"Class.DocTimer.php");
8251 $q =
new QueryDb($this->dbaccess,
"doctimer");
8252 $q->AddQuery(
"docid=" . $this->initid);
8253 $q->AddQuery(
"donedate is null");
8254 $l =
$q->Query(0, 0,
"TABLE");
8256 if (is_array($l))
return $l;
8267 if (file_exists(
"OFFLINE/Class.DomainManager.php")) {
8268 include_once (
"FDL/Class.SearchDoc.php");
8269 $s =
new searchDoc($this->dbaccess,
"OFFLINEFOLDER");
8270 $s->join(
"id = fld(dirid)");
8271 $s->addFilter(
"fld.childid = %d", $this->initid);
8273 if (
$user)
$s->addFilter(
"off_user = '%d' or off_user is null",
$uid);
8274 $s->noViewControl();
8277 foreach (
$t as $v) {
8278 $ids[] = $v[
'off_domain'];
8279 if ($folderName && ((!
$user) || ($v[
'off_user'] ==
$uid))) {
8280 $ids[] = $v[
"name"];
8283 return array_unique($ids);
8295 if (!$userid) $userid = $this->userid;
8297 if ($domainId !=
'') {
8301 if ($this->lockdomainid != $domainId) {
8305 $this->
addUTag(1,
'LOCKTODOMAIN_LOCKED', $this->locked);
8307 $err = $this->
lock(
false, $userid);
8315 $tag = $this->
getUTag(
'LOCKTODOMAIN_LOCKED',
true, 1);
8316 if ($tag !==
false) {
8317 $this->
delUTag(1,
'LOCKTODOMAIN_LOCKED');
8318 $this->locked = $tag->comment;
8330 $this->lockdomainid = $domainId;
8343 $err =
simpleQuery($this->dbaccess, sprintf(
"select dirid from fld where qtype='S' and childid=%d", $this->initid) , $fldids,
true,
false);
8353 $this->domainid = trim($this->
_array2val($domains));
8354 if ($this->lockdomainid) {
8355 if (!in_array($this->lockdomainid, $domains)) $this->lockdomainid =
'';
8357 if ($this->locked > 0) {
8358 $err =
simpleQuery($this->dbaccess, sprintf(
"select login from users where id=%d", $this->locked) , $lockLogin,
true,
true);
8360 if ($lockLogin && (!$this->
isInDomain(
true, $lockLogin))) {
8361 $this->lockdomainid =
'';
8367 $this->
modify(
true, array(
8381 if (!$login) $login = $action->user->login;
8382 if (preg_match(
'/_' . $login .
'$/m', $this->domainid))
return true;
8385 return (!empty($this->domainid));
8412 $split = preg_split(
'/\?/', $zone, 2);
8416 $el = preg_split(
'/:/', $left);
8417 if (count($el) < 2) {
8420 $p[
'fulllayout'] = $left;
8424 $p[
'args'] = $right;
8425 $argList = preg_split(
'/&/', $p[
'args']);
8426 $p[
'argv'] = array();
8427 foreach ($argList as
$arg) {
8428 $split = preg_split(
'/=/', $arg, 2);
8429 $left = urldecode($split[0]);
8430 $right = urldecode($split[1]);
8431 $p[
'argv'][$left] = $right;
8443 while ($i < count($el)) {
8444 if (!array_key_exists($i, $parts)) {
8445 error_log(__CLASS__ .
"::" . __FUNCTION__ .
" " . sprintf(
"Unexpected part '%s' in zone '%s'.", $el[$i], $zone));
8449 if ($i == 1 && preg_match(
"/^(?P<name>.*?)\[(?P<index>-?\d)\]$/", $el[$i], $match)) {
8450 $p[$parts[$i]] = $match[
'name'];
8451 $p[
'index'] = $match[
'index'];
8456 $p[$parts[$i]] = $el[$i];