16 include_once (
"Class.QueryDb.php");
 
   17 include_once (
"Lib.FileMime.php");
 
   18 include_once (
"FDL/Class.DocCtrl.php");
 
   19 include_once (
"FDL/freedom_util.php");
 
   20 include_once (
"FDL/Class.DocVaultIndex.php");
 
   21 include_once (
"FDL/Class.DocAttr.php");
 
   22 include_once (
"FDL/Class.DocHisto.php");
 
   23 include_once (
'FDL/Class.ADoc.php');
 
   29 define(
"FAM_BASE", 1);
 
   31 define(
"FAM_ACCESSDOC", 3);
 
   32 define(
"FAM_ACCESSDIR", 4);
 
   33 define(
"FAM_SEARCH", 5);
 
   34 define(
"FAM_ACCESSSEARCH", 6);
 
   35 define(
"FAM_ACCESSFAM", 23);
 
   36 define(
"MENU_ACTIVE", 1);
 
   37 define(
"MENU_INVISIBLE", 2);
 
   38 define(
"MENU_INACTIVE", 0);
 
   40 define(
'POPUP_INACTIVE', 0);
 
   41 define(
'POPUP_ACTIVE', 1);
 
   42 define(
'POPUP_CTRLACTIVE', 3);
 
   43 define(
'POPUP_CTRLINACTIVE', 4);
 
   44 define(
'POPUP_INVISIBLE', 2);
 
   46 define(
"DELVALUE", 
'DEL??');
 
   51 define(
"MAXGDOCS", 20);
 
   53 define(
"REGEXPFILE", 
"([^\|]*)\|([0-9]*)\|?(.*)?");
 
   54 define(
"PREGEXPFILE", 
"/(?P<mime>[^\|]*)\|(?P<vid>[0-9]*)\|?(?P<name>.*)?/");
 
  108             "displayable" => 
true,
 
  110             "filterable" => 
true,
 
  115             "displayable" => 
true,
 
  117             "filterable" => 
true,
 
  118             "label" => 
"prop_owner" 
  119         ) , # 
N_(
"prop_owner"),
 
  122             "displayable" => 
true,
 
  124             "filterable" => 
false,
 
  125             "label" => 
"prop_icon" 
  126         ) , # 
N_(
"prop_icon"),
 
  129             "displayable" => 
true,
 
  131             "filterable" => 
true,
 
  132             "label" => 
"prop_title" 
  133         ) , # 
N_(
"prop_title"),
 
  136             "displayable" => 
true,
 
  138             "filterable" => 
true,
 
  139             "label" => 
"prop_revision" 
  140         ) , # 
N_(
"prop_revision"),
 
  143             "displayable" => 
true,
 
  145             "filterable" => 
true,
 
  146             "label" => 
"prop_version" 
  147         ) , # 
N_(
"prop_version"),
 
  150             "displayable" => 
true,
 
  152             "filterable" => 
true,
 
  153             "label" => 
"prop_initid" 
  154         ) , # 
N_(
"prop_initid"),
 
  157             "displayable" => 
true,
 
  159             "filterable" => 
true,
 
  160             "label" => 
"prop_fromid" 
  161         ) , # 
N_(
"prop_fromid"),
 
  164             "displayable" => 
false,
 
  166             "filterable" => 
true,
 
  167             "label" => 
"prop_doctype" 
  168         ) , # 
N_(
"prop_doctype"),
 
  171             "displayable" => 
true,
 
  173             "filterable" => 
false,
 
  174             "label" => 
"prop_locked" 
  175         ) , # 
N_(
"prop_locked"),
 
  176         "allocated" => array(
 
  178             "displayable" => 
false,
 
  180             "filterable" => 
true,
 
  181             "label" => 
"prop_allocated" 
  182         ) , # 
N_(
"prop_allocated"),
 
  185             "displayable" => 
false,
 
  187             "filterable" => 
false,
 
  188             "label" => 
"prop_lmodify" 
  189         ) , # 
N_(
"prop_lmodify"),
 
  192             "displayable" => 
false,
 
  194             "filterable" => 
false,
 
  195             "label" => 
"prop_profid" 
  196         ) , # 
N_(
"prop_profid"),
 
  199             "displayable" => 
false,
 
  201             "filterable" => 
false,
 
  202             "label" => 
"prop_usefor" 
  203         ) , # 
N_(
"prop_usefor")
 
  205             "type" => 
"timestamp",
 
  206             "displayable" => 
true,
 
  208             "filterable" => 
true,
 
  209             "label" => 
"prop_cdate" 
  210         ) , # 
N_(
"prop_cdate")
 
  212             "type" => 
"timestamp",
 
  213             "displayable" => 
true,
 
  215             "filterable" => 
true,
 
  216             "label" => 
"prop_adate" 
  217         ) , # 
N_(
"prop_adate"),
 
  219             "type" => 
"timestamp",
 
  220             "displayable" => 
true,
 
  222             "filterable" => 
true,
 
  223             "label" => 
"prop_revdate" 
  224         ) , # 
N_(
"prop_revdate"),
 
  227             "displayable" => 
false,
 
  229             "filterable" => 
false,
 
  230             "label" => 
"prop_comment" 
  231         ) , # 
N_(
"prop_comment"),
 
  232         "classname" => array(
 
  234             "displayable" => 
false,
 
  236             "filterable" => 
false,
 
  237             "label" => 
"prop_classname" 
  238         ) , # 
N_(
"prop_classname")
 
  241             "displayable" => 
true,
 
  243             "filterable" => 
true,
 
  244             "label" => 
"prop_state" 
  245         ) , # 
N_(
"prop_state"),
 
  248             "displayable" => 
false,
 
  250             "filterable" => 
false,
 
  251             "label" => 
"prop_wid" 
  255             "displayable" => 
false,
 
  257             "filterable" => 
false,
 
  258             "label" => 
"prop_postitid" 
  259         ) , # 
N_(
"prop_postitid")
 
  262             "displayable" => 
false,
 
  264             "filterable" => 
false,
 
  265             "label" => 
"prop_cvid" 
  266         ) , # 
N_(
"prop_cvid")
 
  269             "displayable" => 
true,
 
  271             "filterable" => 
true,
 
  272             "label" => 
"prop_name" 
  273         ) , # 
N_(
"prop_name")
 
  276             "displayable" => 
false,
 
  278             "filterable" => 
false,
 
  279             "label" => 
"prop_dprofid" 
  280         ) , # 
N_(
"prop_dprofid")
 
  283             "displayable" => 
false,
 
  285             "filterable" => 
false,
 
  286             "label" => 
"prop_atags" 
  287         ) , # 
N_(
"prop_atags")
 
  290             "displayable" => 
false,
 
  292             "filterable" => 
false,
 
  293             "label" => 
"prop_prelid" 
  294         ) , # 
N_(
"prop_prelid")
 
  295         "lockdomainid" => array(
 
  297             "displayable" => 
true,
 
  299             "filterable" => 
false,
 
  300             "label" => 
"prop_lockdomainid" 
  301         ) , # 
N_(
"prop_lockdomainid")
 
  304             "displayable" => 
false,
 
  306             "filterable" => 
false,
 
  307             "label" => 
"prop_domainid" 
  308         ) , # 
N_(
"prop_domainid")
 
  309         "confidential" => array(
 
  311             "displayable" => 
false,
 
  313             "filterable" => 
true,
 
  314             "label" => 
"prop_confidential" 
  315         ) , # 
N_(
"prop_confidential")
 
  317             "type" => 
"fulltext",
 
  318             "displayable" => 
false,
 
  320             "filterable" => 
true,
 
  321             "label" => 
"prop_svalues" 
  322         ) , # 
N_(
"prop_svalues")
 
  325             "displayable" => 
false,
 
  327             "filterable" => 
false,
 
  328             "label" => 
"prop_ldapdn" 
  330     ); # 
N_(
"prop_ldapdn");
 
  556     private $_paramValue = array();
 
  560     private $lastRefreshError = 
'';
 
  561     private $formaterLevel = 0;
 
  562     private $otherFormatter = array();
 
  570         "FDL:VIEWABSTRACTCARD",
 
  585         "doc_initid" => array(
 
  589         "doc_title" => array(
 
  595             "on" => 
"name,revision,doctype" 
  599             "using" => 
"@FDL_FULLIDX",
 
  602         "doc_profid" => array(
 
  618     private $mvalues = array();
 
  622     private $withoutControlN = 0;
 
  623     private $withoutControl = 
false;
 
  624     private $constraintbroken = 
false; 
 
  625     private $_oldvalue = array();
 
  626     private $fathers = null;
 
  627     private $childs = null;
 
  631     private $htmlFormater = null;
 
  635     private $oooFormater = null;
 
  640     private $textsend = array();
 
  641     private $vidNoSendTextToEngine = array();
 
  646     private $_setValueCompleteArray = 
false;
 
  663 create table doc ( id int not null, 
  667                    revision int DEFAULT 0, 
  670                    doctype char DEFAULT 'F', 
  671                    locked int DEFAULT 0, 
  672                    archiveid int DEFAULT 0, 
  673                    allocated int DEFAULT 0, 
  675                    lmodify char DEFAULT 'N', 
  676                    profid int DEFAULT 0, 
  677                    usefor text DEFAULT 'N', 
  686                    values text DEFAULT '', 
  687                    attrids text DEFAULT '', 
  694                    dprofid int DEFAULT 0, 
  696                    prelid int DEFAULT 0, 
  698                    confidential int DEFAULT 0, 
  700                    svalues text DEFAULT '' 
  702 create table docfrom ( id int not null, 
  705 create table docname ( name text not null, 
  709 create sequence seq_id_doc start 1000; 
  710 create sequence seq_id_tdoc start 1000000000; 
  711 create index i_docname on doc(name); 
  712 create unique index i_docir on doc(initid, revision);";
 
  755     private $hasChanged = 
false;
 
  763     private $_maskApplied = 
false; 
 
  771     private $_setValueNeedCompleteArray = 
true;
 
  778         return sprintf(
'%s "%s" [#%d]', $this->fromname, $this->
getTitle() , $this->
id);
 
  792         if (($this->
revision == 0) && ($this->doctype != 
"T")) {
 
  796             $incumbentName = 
getCurrentUser()->getIncumbentPrivilege($famDoc, 
'create');
 
  797             $createComment = _(
"document creation");
 
  798             if ($incumbentName) $createComment = sprintf(_(
"(substitute of %s) : ") , $incumbentName) . $createComment;
 
  801                 $this->wdoc->workflowSendMailTemplate($this->state, _(
"creation"));
 
  802                 $this->wdoc->workflowAttachTimer($this->state);
 
  803                 $this->wdoc->changeAllocateUser($this->state);
 
  805             $this->
addLog(
"create", array(
 
  807                 "title" => $this->title,
 
  808                 "fromid" => $this->fromid,
 
  809                 "fromname" => $this->fromname
 
  812         unset($this->fields[
"svalues"]);
 
  817         $date = gettimeofday();
 
  818         $this->revdate = $date[
'sec'];
 
  819         $this->
modify(
true, array(
 
  824         if ($this->doctype != 
'C') {
 
  828         if ($this->doctype != 
"T") {
 
  829             $err = $this->PostCreated();
 
  830             if (
$err != 
"") AddWarningMsg(
$err);
 
  831             $this->sendTextToEngine();
 
  832             if ($this->dprofid > 0) {
 
  834                 $this->
modify(
true, array(
 
  841         $this->hasChanged = 
false;
 
  846         $this->hasChanged = 
true;
 
  855         return ($this->hasChanged === 
true);
 
  867         $err = $this->PreCreated();
 
  870         if ($this->
id == 
"") {
 
  871             if ($this->doctype == 
'T') 
$res = pg_query($this->
init_dbid() , 
"select nextval ('seq_id_tdoc')");
 
  872             else $res = pg_query($this->
init_dbid() , 
"select nextval ('seq_id_doc')");
 
  873             $arr = pg_fetch_array(
$res, 0);
 
  877         if ($this->initid == 
"") $this->initid = 
$this->id;
 
  878         $this->RefreshTitle();
 
  879         if (chop($this->title) == 
"") {
 
  881             $this->title = sprintf(_(
"untitle %s %d") , $fdoc->title, $this->initid);
 
  886         if ($this->profid == 
"") {
 
  887             $this->views = 
"{0}";
 
  890         if ($this->usefor == 
"") $this->usefor = 
"N";
 
  892         if ($this->lmodify == 
"") $this->lmodify = 
"N";
 
  893         if ($this->locked == 
"") $this->locked = 
"0";
 
  904         unset($this->fields[
"svalues"]);
 
  905         if ($this->doctype !== 
"T") {
 
  906             $this->svalues = $this->getExtraSearchableDisplayValues();
 
  907             $this->fields[
"svalues"] = 
"svalues";
 
  909         if ($this->wid > 0) {
 
  915             if ($this->wdoc->isAlive()) {
 
  916                 if ($this->wdoc->doctype != 
'W') 
$err = sprintf(_(
"creation : document %s is not a workflow") , $this->wid);
 
  917                 else $this->wdoc->Set($this); 
 
  919             } 
else $err = sprintf(_(
"creation : workflow %s not exists") , $this->wid);
 
  934         if ($this->
id == 
"") 
return _(
"cannot update no initialized document");
 
  935         if ($this->doctype == 
'I') 
return _(
"cannot update inconsistent document"); 
 
  936         if (!$this->withoutControl) {
 
  940         if ($this->locked == - 1) $this->lmodify = 
'N';
 
  941         $err = $this->docIsCleanToModify();
 
  943         if ($this->constraintbroken) 
return (sprintf(_(
"constraint broken %s") , $this->constraintbroken));
 
  945         unset($this->fields[
"svalues"]);
 
  946         $this->RefreshTitle();
 
  947         if ($this->hasChanged) {
 
  948             if (chop($this->title) == 
"") $this->title = _(
"untitle document");
 
  950             if ($this->doctype !== 
"T") {
 
  951                 $this->svalues = $this->getExtraSearchableDisplayValues();
 
  952                 $this->fields[
"svalues"] = 
"svalues";
 
  954             $date = gettimeofday();
 
  955             $this->revdate = $date[
'sec'];
 
  957             $this->lmodify = 
'Y';
 
  963     private function docIsCleanToModify()
 
  965         if ($this->initid > 0 && $this->fromid > 0) {
 
  966             simpleQuery($this->dbaccess, sprintf(
"select initid, id, revision, locked from only doc%d where initid=%d", $this->fromid, $this->initid) , 
$r);
 
  970             foreach (
$r as $docInfo) {
 
  971                 if (($docInfo[
"id"] == $this->
id) && ($docInfo[
"locked"] == - 1)) {
 
  973                 } elseif ($docInfo[
"locked"] != - 1) {
 
  974                     if ($docInfo[
"id"] == $this->
id) $imAlive = 
true;
 
  978             if ($this->locked != - 1 && $cAlive == 1 && $imAlive) {
 
  981             } elseif ($cAlive > 1) {
 
  999         if ($this->hasChanged) {
 
 1001             if ($this->doctype != 
'C') {
 
 1006                 if ($this->
getATag(
"DYNTIMER")) $this->resetDynamicTimers();
 
 1010         $this->sendTextToEngine();
 
 1011         $this->hasChanged = 
false;
 
 1023         $layout = 
'THIS:' . $aid;
 
 1025             $layout.= 
'[' . $index . 
']';
 
 1029             $err = sprintf(_(
"Dynamic template %s not found ") , $orifile);
 
 1032         if (!file_exists($orifile)) {
 
 1033             $err = sprintf(_(
"Dynamic template %s not found ") , $orifile);
 
 1038             $err = sprintf(_(
"Dynamic template %s not an odt file ") , $orifile);
 
 1044             $err = sprintf(_(
"viewDoc did not returned a valid file"));
 
 1049         if ($fh === 
false) {
 
 1050             $err = sprintf(_(
"Error opening %s file '%s'") , 
'outfile', 
$outfile);
 
 1054         $err = $this->saveFile($aid, $fh, 
'', $index);
 
 1060         $this->
addHistoryEntry(sprintf(_(
'regeneration of file template %s') , $aid));
 
 1070         $fa = $this->GetFileAttributes();
 
 1071         $errorList = array();
 
 1072         foreach ($fa as $aid => $oattr) {
 
 1073             $opt = $oattr->getOption(
"template");
 
 1074             if ($opt == 
"dynamic" || $opt == 
"form") {
 
 1075                 if ($oattr->inArray()) {
 
 1077                     foreach ($ta as $k => $v) {
 
 1080                             array_push($errorList, 
$err);
 
 1086                         array_push($errorList, 
$err);
 
 1091         if (count($errorList) > 0) {
 
 1092             return join(
"\n", $errorList);
 
 1103         include_once (
"FDL/Class.DocRel.php");
 
 1104         $or = 
new DocRel($this->dbaccess);
 
 1106         $or->initRelations($this, 
$force);
 
 1114         if ($this->doctype == 
'C') 
return 0;
 
 1115         if ($this->fromid == 
"") 
return 0;
 
 1117         $res = pg_query($this->
init_dbid() , 
"select nextval ('seq_doc" . $this->fromid . 
"')");
 
 1118         $arr = pg_fetch_array(
$res, 0);
 
 1119         $cur = intval($arr[0]) - 1;
 
 1120         pg_query($this->
init_dbid() , 
"select setval ('seq_doc" . $this->fromid . 
"',$cur)");
 
 1132         if ($this->fromid == 0) 
return 0;
 
 1133         if ($this->doctype == 
'C') 
return 0;
 
 1136         $arr = pg_fetch_array(
$res, 0);
 
 1137         $cur = intval($arr[0]);
 
 1148         $this->withoutControlN++;
 
 1149         $this->withoutControl = 
true;
 
 1159         $this->withoutControlN--;
 
 1160         if ($this->withoutControlN <= 0) {
 
 1161             $this->withoutControlN = 0;
 
 1162             $this->withoutControl = 
false;
 
 1171         if (($this->doctype == 
'F') && ($this->usefor != 
'P')) {
 
 1173             if ($fdoc->schar != 
"S") 
return true;
 
 1188         foreach (
$values as $k => $v) {
 
 1204         if (!$cdoc) 
return false;
 
 1205         if ($this->fromid == $cdoc->fromid) 
return false; 
 
 1206         if ($this->locked == - 1) 
return false; 
 
 1207         if ($cdoc->fromid == 0) 
return false;
 
 1209         $f1from = $f1doc->title . 
"[" . $f1doc->id . 
"]";
 
 1210         $f2doc = $cdoc->getFamilyDocument();
 
 1211         $f2from = $f2doc->title . 
"[" . $f2doc->id . 
"]";
 
 1215         $cdoc->revision = 0;
 
 1227         $err = $this->
delete(
true, 
false, 
true); 
 
 1230         foreach ($prevalues as $k => $v) {
 
 1231             $cdoc->setValue($k, $v);
 
 1233         $err = $cdoc->Add(
true, 
true);
 
 1239         foreach (
$values as $k => $v) {
 
 1240             $cdoc->setValue($k, $v);
 
 1243         $err = $cdoc->Modify();
 
 1246                 $this->
exec_query(sprintf(
"update fld set childid=%d where childid=%d", $cdoc->id, $this->initid));
 
 1249         $this->
exec_query(sprintf(
"update fld set fromid=%d where childid=%d", $cdoc->fromid, $this->initid));
 
 1251         $cdoc->addHistoryEntry(sprintf(_(
"convertion from %s to %s family") , $f1from, $f2from));
 
 1254         if (\Dcp\Core\SharedDocuments::exists($this->
id)) {
 
 1280     public function save(&
$info = null, $skipConstraint = 
false)
 
 1284         $info = 
new stdClass();
 
 1285         $info->constraint = 
'';
 
 1286         if (!$skipConstraint) {
 
 1292             if ($this->hasChanged) {
 
 1320         if (!$skipConstraint) {
 
 1326                 $err = $this->add();
 
 1330                 $this->lastRefreshError = 
'';
 
 1332                 $err = $this->lastRefreshError;
 
 1341                     if ($this->hasChanged) {
 
 1354         $info->constraint = $constraint;
 
 1366         if ($this->locked == - 1) {
 
 1367             $err = sprintf(_(
"cannot update file %s (rev %d) : fixed. Get the latest version") , $this->title, $this->
revision);
 
 1370         if ($this->userid == 1) {
 
 1373         if ($verifyDomain && ($this->lockdomainid > 0)) {
 
 1374             $err = sprintf(_(
"document is booked in domain %s") , $this->
getTitle($this->lockdomainid));
 
 1376             if ($this->withoutControl) {
 
 1379             if (($this->locked != 0) && (abs($this->locked) != $this->userid)) {
 
 1381                 if ($this->locked < - 1) 
$err = sprintf(_(
"Document %s is in edition by %s.") , $this->
getTitle() , 
$user->firstname . 
" " . 
$user->lastname);
 
 1382                 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);
 
 1384                 $err = $this->Control(
"edit");
 
 1424         if ($this->userid == 1) 
return ""; 
 
 1426         if ($this->locked != 0) { 
 
 1427             if ($this->profid > 0) 
$err = $this->Control(
"unlock"); 
 
 1428             else $err = _(
"cannot unlock"); 
 
 1433             $err = $this->Control(
"edit");
 
 1435                 if ($this->profid > 0) {
 
 1436                     $err = $this->Control(
"unlock");
 
 1452             if ($this->userid == 1) {
 
 1453                 if ($this->locked == 1) 
return false;
 
 1454             } elseif (abs($this->locked) == $this->userid) 
return false;
 
 1456         return (($this->locked > 0) || ($this->locked < - 1));
 
 1464         return (($this->confidential > 0) && ($this->
controlId($this->profid, 
'confidential') != 
""));
 
 1487         static $famdoc = null;
 
 1488         if (($famdoc === null) || ($famdoc->id != $this->fromid)) $famdoc = 
new_Doc($this->dbaccess, $this->fromid);
 
 1500         $query->basic_elem->sup_where = array(
 
 1540         if (isset($this->_paramValue[$idp])) 
return $this->_paramValue[$idp];
 
 1544         if (!$paramAttr) 
return $def;
 
 1545         if ($paramAttr->phpfunc != 
"" && $paramAttr->phpfile == 
"" && $paramAttr->type !== 
"enum") {
 
 1546             $this->_paramValue[$idp] = 
$r;
 
 1547             if ($paramAttr->inArray()) {
 
 1548                 $attributes_array = $this->attributes->getArrayElements($paramAttr->fieldSet->id);
 
 1550                 foreach ($attributes_array as $attr) {
 
 1552                     if ($count > $max) $max = $count;
 
 1555                 for ($i = 0; $i < $max; $i++) {
 
 1556                     $val = $this->
applyMethod($paramAttr->phpfunc, 
"", $i);
 
 1557                     if ($val != $paramAttr->phpfunc) {
 
 1558                         if ($tmpVal) $tmpVal.= 
"\n";
 
 1565                 if ($val != $paramAttr->phpfunc) {
 
 1570             $this->_paramValue[$idp] = 
$r;
 
 1573         $this->_paramValue[$idp] = 
$r;
 
 1579         if (!$this->fromid) 
return false;
 
 1581         if (!$fdoc->isAlive()) 
$r = 
false;
 
 1582         else $r = $fdoc->getParameterRawValue($idp, $def);
 
 1594         $s = 
new SearchDoc($this->dbaccess, $this->fromid);
 
 1595         $s->overrideViewControl();
 
 1596         $s->addFilter(
"doctype != 'T'");
 
 1597         if ($this->initid > 0) {
 
 1598             $s->addFilter(
"initid != %d", $this->initid);
 
 1600         $s->addFilter(
"%s=E'%s'", $key1, $this->
getRawValue($key1));
 
 1602             $s->addFilter(
"%s=E'%s'", $key2, $this->
getRawValue($key2));
 
 1604         $s->setObjectReturn(
true);
 
 1606         $dl = 
$s->getDocumentList();
 
 1608         foreach ($dl as 
$doc) {
 
 1609             $t[] = clone ($doc);
 
 1622         $ldoc = $this->GetRevisions(
"TABLE");
 
 1625         foreach ($ldoc as $k => $v) {
 
 1626             if ($v[
"state"] == 
$state) {
 
 1627                 if ((($v[
"locked"] == - 1) && $fixed) || (!$fixed)) {
 
 1639         pg_query($this->
init_dbid() , 
"delete from doc where doctype='T'");
 
 1649         if ($this->doctype == 
'Z') 
return _(
"already deleted");
 
 1650         if ($this->
isLocked(
true)) 
return _(
"locked");
 
 1651         if ($this->lockdomainid > 0) 
return sprintf(_(
"document is booked in domain %s") , $this->
getTitle($this->lockdomainid));
 
 1652         $err = $this->Control(
"delete");
 
 1666         return $this->_destroy($nopost);
 
 1673     final private function _destroy($nopost)
 
 1679             if ($this->
name != 
'') {
 
 1680                 $this->
exec_query(sprintf(
"delete from docname where name='%s'", pg_escape_string($this->
name)));
 
 1682             $this->
exec_query(sprintf(
"delete from docfrom where id='%s'", pg_escape_string($this->
id)));
 
 1695     final public function delete($really = 
false, $control = 
true, $nopost = 
false)
 
 1705             if ($this->
id != 
"") {
 
 1709                 $appli = $action->parent;
 
 1710                 $this->
addHistoryEntry(sprintf(_(
"Destroyed by action %s/%s from %s") , $appli->name, $action->name, isset($_SERVER[
"REMOTE_ADDR"]) ? $_SERVER[
"REMOTE_ADDR"] : 
'bash mode') , 
DocHisto::NOTICE);
 
 1712                 $this->
addLog(
'delete', array(
 
 1715                 $rev = $this->GetRevisions();
 
 1716                 foreach ($rev as $k => $v) {
 
 1717                     $v->_destroy($nopost);
 
 1722             if ($this->doctype == 
'Z') 
$err = _(
"already deleted");
 
 1730             if ($this->doctype != 
'Z') {
 
 1732                 if ($this->
name != 
"") $this->
exec_query(sprintf(
"delete from doc%d where name='%s' and doctype='Z'", $this->fromid, pg_escape_string($this->
name))); 
 
 1733                 $this->doctype = 
'Z'; 
 
 1734                 $this->locked = - 1;
 
 1735                 $this->lmodify = 
'D'; 
 
 1736                 $date = gettimeofday();
 
 1737                 $this->revdate = $date[
'sec']; 
 
 1741                 $appli = $action->parent;
 
 1742                 $this->
addHistoryEntry(sprintf(_(
"delete by action %s/%s from %s") , $appli->name, $action->name, isset($_SERVER[
"REMOTE_ADDR"]) ? $_SERVER[
"REMOTE_ADDR"] : 
'bash mode') , 
DocHisto::NOTICE);
 
 1744                 $this->
addLog(
'delete', array(
 
 1763                     $rev = $this->GetRevisions();
 
 1764                     foreach ($rev as $k => $v) {
 
 1765                         if ($v->doctype != 
'Z') {
 
 1767                             if ($v->locked == - 1) $v->modify(
true, array(
 
 1796         if (($this->
control(
'delete') == 
"") || ($this->userid == 1)) {
 
 1800                 $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);
 
 1802                     if (!$latestId) 
$err = sprintf(_(
"document %s [%d] is strange") , $this->title, $this->
id);
 
 1807                         $this->
id = $latestId;
 
 1809                         $this->lmodify = 
'Y'; 
 
 1810                         $this->
modify(
true, array(
 
 1819                         $this->
addLog(
'undelete');
 
 1824                         foreach ($rev as $k => $v) {
 
 1825                             if ($v->doctype == 
'Z') {
 
 1826                                 $v->doctype = $v->defDoctype;
 
 1828                                 $err.= $v->modify(
true, array(
 
 1834                         if ($previousName) {
 
 1841                 $err = sprintf(_(
"document %s [%d] is not in the trash") , $this->
getTitle() , $this->
id);
 
 1844             $err = sprintf(_(
"need privilege delete to restore %s") , $this->
getTitle());
 
 1858         if (is_array($array)) {
 
 1860             if ($more) $this->resetMoreValues();
 
 1862                 foreach ($this->fields as $key) {
 
 1866             unset($this->uperm); 
 
 1867             foreach ($array as $k => $v) {
 
 1868                 if (!is_integer($k)) {
 
 1873             if ($more) $this->getMoreValues();
 
 1876                 $this->_maskApplied = 
false;
 
 1877                 $this->_oldvalue = array();
 
 1878                 $this->_paramValue = array();
 
 1879                 $this->_setValueCompleteArray = 
false;
 
 1880                 $this->childs = null;
 
 1881                 $this->constraintbroken = 
false;
 
 1882                 $this->fathers = null;
 
 1883                 $this->hasChanged = 
false;
 
 1884                 $this->htmlFormater = null;
 
 1885                 $this->lastRefreshError = 
'';
 
 1886                 $this->mvalues = array();
 
 1887                 $this->oooFormater = null;
 
 1888                 $this->formaterLevel = 0;
 
 1889                 $this->otherFormatter = array();
 
 1891                 $this->svalues = null;
 
 1892                 $this->vidNoSendTextToEngine = array();
 
 1893                 $this->textsend = array();
 
 1895             $this->isset = 
true;
 
 1936         $this->isset = 
false;
 
 1939         $nattr = $this->GetNormalAttributes();
 
 1940         foreach ($nattr as $k => $v) {
 
 1941             if (isset($this->$k) && ($this->$k != 
"")) $this->$k = 
"";
 
 1959         if ($this->fathers === null) {
 
 1961             $this->fathers = array();
 
 1962             if ($this->fromid > 0) {
 
 1964                 $this->fathers = $fdoc->GetFathersDoc();
 
 1965                 array_push($this->fathers, $this->fromid);
 
 1968         return $this->fathers;
 
 1976         return $this->attributes->fromids;
 
 1986         if (
$id == 0) 
return array();
 
 1987         if ((
$id != - 1) || (!isset($this->childs))) {
 
 1988             include_once (
"FDL/Class.SearchDoc.php");
 
 1990             if (!isset($this->childs)) $this->childs = array();
 
 1993             $s->addFilter(
"fromid = " . 
$id);
 
 1994             $s->overrideViewControl();
 
 1997                 foreach (
$table1 as $k => $v) {
 
 1998                     if ((!$controlcreate) || 
controlTdoc($v, 
"icreate")) {
 
 1999                         $this->childs[$v[
"id"]] = $v;
 
 2001                     $this->GetChildFam($v[
"id"], $controlcreate);
 
 2005         return $this->childs;
 
 2016         $query = 
new QueryDb($this->dbaccess, strtolower(get_class($this)));
 
 2018         $query->AddQuery(
"initid = " . $this->initid);
 
 2019         $query->order_by = 
"revision DESC LIMIT $limit";
 
 2022         if (
$query->nb == 0) 
return array();
 
 2033     final public function latestId($fixed = 
false, $forcequery = 
false)
 
 2045     final public function getLatestId($fixed = 
false, $forcequery = 
false)
 
 2047         if ($this->
id == 
"") 
return false;
 
 2049             if (($this->locked != - 1) && (!$fixed)) 
return $this->id;
 
 2050             if ($fixed && ($this->lmodify == 
"L")) 
return $this->id;
 
 2052         if (!$fixed) 
return getLatestDocId($this->dbaccess, $this->initid);
 
 2053         $query = 
new QueryDb($this->dbaccess, strtolower(get_class($this)));
 
 2054         $query->AddQuery(
"initid = " . $this->initid);
 
 2055         if ($fixed) 
$query->AddQuery(
"lmodify = 'L'");
 
 2056         elseif ($this->doctype != 
'Z') 
$query->AddQuery(
"locked != -1");
 
 2058             $query->order_by = 
"id desc";
 
 2060         $rev = 
$query->Query(0, 2, 
"TABLE");
 
 2062         if ($this->doctype != 
'Z') {
 
 2063             if (count($rev) > 1) 
addWarningMsg(sprintf(
"document %d : multiple alive revision", $this->initid));
 
 2065         return $rev[0][
"id"];
 
 2074         $tversion = array();
 
 2075         if (isset($this->attributes->attr)) {
 
 2076             foreach ($this->attributes->attr as $k => $v) {
 
 2077                 if ((get_class($v) == 
"NormalAttribute") && ($v->getOption(
"version") == 
"yes")) {
 
 2082         if (count($tversion) > 0) 
$version = implode(
" ", $tversion);
 
 2093         if (isset($this->attributes->attr[$idAttr])) 
return $this->attributes->attr[$idAttr]->getLabel();
 
 2094         return _(
"unknow attribute");
 
 2116         $prop = trim(strtolower($prop));
 
 2117         if (!in_array($prop, $this->fields)) 
return false;
 
 2118         if (isset($this->fields[$prop])) 
return false; 
 
 2119         return $this->$prop;
 
 2134         if (empty($tag) || $tag->docid != $this->initid) {
 
 2135             if (class_exists(
"TagManager")) {
 
 2138                 throw new Dcp\Exception(
"Need install dynacase-tags module.\n");
 
 2154         if ($idAttr !== Adoc::HIDDENFIELD) {
 
 2155             $idAttr = strtolower($idAttr);
 
 2160         if (isset($this->attributes->attr[$idAttr])) {
 
 2161             $oa = $this->attributes->attr[$idAttr];
 
 2176         $fromname = ($this->doctype == 
'C') ? $this->
name : $this->fromname;
 
 2177         $aFromName = isset($this->attributes->fromname) ? $this->attributes->fromname : 
'';
 
 2180             $fromid = ($this->doctype == 
'C') ? $this->
id : $this->fromid;
 
 2181             $adocClassName = 
"ADoc" . 
$fromid;
 
 2183             $GEN = 
getGen($this->dbaccess);
 
 2184             $includePath = 
"FDL$GEN/Class.$classname.php";
 
 2185             if (file_exists($includePath)) {
 
 2186                 include_once ($includePath);
 
 2187                 $this->attributes = 
new $adocClassName();
 
 2190         if ($useMask && !$this->_maskApplied) {
 
 2192             reset($this->attributes->attr);
 
 2194         return $this->attributes->attr;
 
 2202     final public function getDefaultView($edition = 
false, $extract = 
"all")
 
 2204         if ($this->cvid > 0) {
 
 2210             $cvdoc = 
new_Doc($this->dbaccess, $this->cvid);
 
 2211             $cvdoc = clone $cvdoc;
 
 2214             $view = $cvdoc->getPrimaryView($edition);
 
 2219                         return $view[
"cv_idview"];
 
 2221                         return $view[
"cv_mskid"];
 
 2238         if (isset($this->attributes->attr)) {
 
 2240             foreach ($this->attributes->attr as $k => $v) {
 
 2241                 if ($this->attributes->attr[$k] !== null) {
 
 2242                     $this->attributes->attr[$k]->mvisibility = $v->visibility;
 
 2246         return $this->ApplyMask(
$mid);
 
 2255     final public function applyMask(
$mid = 0, 
$force = 
false)
 
 2259         $this->_maskApplied = 
true;
 
 2261         if (is_array($oas)) {
 
 2262             foreach ($oas as $k => $v) {
 
 2263                 if ($oas[$k]) $oas[$k]->mvisibility = 
ComputeVisibility($v->visibility, (empty($v->fieldSet)) ? 
'' : $v->fieldSet->mvisibility, (!empty($v->fieldSet->fieldSet)) ? $v->fieldSet->fieldSet->mvisibility : 
'');
 
 2267         if ((!
$force) && (($this->doctype == 
'C') || (($this->doctype == 
'T') && (
$mid == 0)))) 
return '';
 
 2269         if ((!is_numeric(
$mid)) && (
$mid != 
"")) {
 
 2285                 $cvdoc = 
new_Doc($this->dbaccess, $this->cvid);
 
 2286                 if ($cvdoc->isAlive()) {
 
 2287                     $cvdoc = clone $cvdoc;
 
 2291                         $tview = $cvdoc->getView($vid);
 
 2292                         $mid = ($tview !== 
false) ? $tview[
"CV_MSKID"] : 0;
 
 2301             if (($this->wid > 0) && ($this->wid != 
$this->id)) {
 
 2308                 if (
$wdoc->isAlive()) {
 
 2309                     if ($this->
id == 0) {
 
 2312                     $mid = 
$wdoc->getStateMask($this->state);
 
 2319             if (!$argMid) $argMid = 
$mid;
 
 2324             if ($mdoc->isAlive()) {
 
 2325                 if (is_a($mdoc, 
'\Dcp\Family\Mask')) {
 
 2327                     $maskFam = $mdoc->getRawValue(
"msk_famid");
 
 2328                     if (!in_array($maskFam, $this->
getFromDoc())) {
 
 2331                         $tvis = $mdoc->getVisibilities();
 
 2332                         foreach ($tvis as $k => $v) {
 
 2333                             if (isset($oas[$k])) {
 
 2334                                 if ($v != 
"-") $oas[$k]->mvisibility = $v;
 
 2337                         $tdiff = array_diff(array_keys($oas) , array_keys($tvis));
 
 2339                         foreach ($tdiff as $k) {
 
 2341                             if ($v->type == 
"frame") {
 
 2342                                 $oas[$k]->mvisibility = 
ComputeVisibility($v->visibility, isset($v->fieldSet) ? $v->fieldSet->mvisibility : 
'', 
'');
 
 2345                         foreach ($tdiff as $k) {
 
 2347                             if ($v->type == 
"array") {
 
 2348                                 $oas[$k]->mvisibility = 
ComputeVisibility($v->visibility, isset($v->fieldSet) ? $v->fieldSet->mvisibility : 
'', isset($v->fieldSet->fieldSet) ? $v->fieldSet->fieldSet->mvisibility : 
'');
 
 2352                         foreach ($tdiff as $k) {
 
 2354                             if ($v->type != 
"frame") {
 
 2355                                 $oas[$k]->mvisibility = 
ComputeVisibility($v->visibility, isset($v->fieldSet) ? $v->fieldSet->mvisibility : 
'', isset($v->fieldSet->fieldSet) ? $v->fieldSet->fieldSet->mvisibility : 
'');
 
 2359                         $tneed = $mdoc->getNeedeeds();
 
 2360                         foreach ($tneed as $k => $v) {
 
 2361                             if (isset($oas[$k])) {
 
 2362                                 if ($v == 
"Y") $oas[$k]->needed = 
true;
 
 2363                                 else if ($v == 
"N") $oas[$k]->needed = 
false;
 
 2374         if (!empty($this->attributes->attr)) {
 
 2375             $this->attributes->orderAttributes();
 
 2389         if (!$this->_maskApplied) $this->ApplyMask();
 
 2390         if ((isset($this->attributes)) && (method_exists($this->attributes, 
"GetNormalAttributes"))) 
return $this->attributes->GetNormalAttributes($onlyopt);
 
 2391         else return array();
 
 2400         if (!$this->_maskApplied) $this->ApplyMask();
 
 2403         foreach ($this->attributes->attr as $k => $v) {
 
 2404             if (is_object($v) && (get_class($v) == 
"FieldSetAttribute")) $tsa[$v->id] = $v;
 
 2415         if (!$this->_maskApplied) $this->ApplyMask();
 
 2417         if (isset($this->attributes)) {
 
 2418             $at = $this->attributes->GetActionAttributes();
 
 2419             foreach ($at as $k => $v) {
 
 2420                 if ($v->mvisibility != 
'H') $tsa[$v->id] = $v;
 
 2432         if (!$this->_maskApplied) $this->ApplyMask();
 
 2435         if (isset($this->attributes->attr)) {
 
 2436             foreach ($this->attributes->attr as $k => $v) {
 
 2440                 if (is_object($v) && (get_class($v) == 
"NormalAttribute") && ($v->usefor != 
'Q') && ($v->isInAbstract)) $tsa[$v->id] = $v;
 
 2452         if (!$this->_maskApplied) $this->ApplyMask();
 
 2454         if (isset($this->attributes->attr)) {
 
 2455             foreach ($this->attributes->attr as $k => $v) {
 
 2459                 if ((get_class($v) == 
"NormalAttribute") && ($v->isInTitle)) $tsa[$v->id] = $v;
 
 2471         if (!$this->_maskApplied) $this->ApplyMask();
 
 2475         if (isset($this->attributes->attr)) {
 
 2476             foreach ($this->attributes->attr as $k => $v) {
 
 2477                 if ($v->type == 
"docid") {
 
 2478                     if ($v->getOption(
"isuser") != 
"") {
 
 2479                         if ($v->getOption(
"isuser") == 
"yes") $tsb[$v->id] = $v;
 
 2482                 } elseif ($v->type == 
"account") {
 
 2484                     if ($v->getOption(
"isuser") != 
"no") $tsb[$v->id] = $v;
 
 2488         if ($wopt) 
return $tsb;
 
 2499         if (!$this->_maskApplied) $this->ApplyMask();
 
 2502         foreach ($this->attributes->attr as $k => $v) {
 
 2503             if ((get_class($v) == 
"NormalAttribute") && (!$v->inArray()) && ($v->mvisibility != 
"I")) { 
 
 2504                 if ((($this->usefor == 
"Q") && ($v->usefor == 
"Q")) || (($this->usefor != 
"Q") && ((($v->usefor != 
"Q") && (!$onlyopt)) || (($v->usefor == 
"O") && ($onlyopt))))) $tsa[$v->id] = $v; 
 
 2518         if (!$this->_maskApplied) $this->ApplyMask();
 
 2519         if ((isset($this->attributes)) && (method_exists($this->attributes, 
"getParamAttributes"))) 
return $this->attributes->getParamAttributes();
 
 2520         else return array();
 
 2530         if (!$this->_maskApplied) $this->ApplyMask();
 
 2533         foreach ($this->attributes->attr as $k => $v) {
 
 2534             if ((get_class($v) == 
"NormalAttribute") && ($v->usefor != 
'Q') && ((($v->type == 
"image") && (!$onlyfile)) || ($v->type == 
"file"))) $tsa[$v->id] = $v;
 
 2546         $tvid = 
$dvi->getVaultIds($this->
id);
 
 2549         foreach ($tvid as $vid) {
 
 2552             $t = get_object_vars(
$info);
 
 2554             if (
$err == 
"") $tinfo[] = $t;
 
 2566         if (!\Dcp\Autoloader::classExists(
'Dcp\TransformationEngine\Client')) {
 
 2570         $tvid = 
$dvi->getVaultIds($this->
id);
 
 2571         if (count($tvid) == 0) 
return false;
 
 2572         $sql = sprintf(
"select id_file from vaultdiskstorage where teng_state=%d and %s limit 1", \Dcp\TransformationEngine\Client::status_waiting, getSqlCond($tvid, 
"id_file", 
true));
 
 2574         return ($waiting != 
false);
 
 2591         if (($index == - 1) && (count($val) == 1)) {
 
 2599                 if ($ofout->isAffected()) {
 
 2600                     $err = $ofout->delete();
 
 2617         include_once (
"FDL/Lib.Vault.php");
 
 2618         $engine = strtolower($engine);
 
 2620         if (is_array($va)) 
return "";
 
 2622         if (
getParam(
"TE_ACTIVATE") == 
"yes" && \Dcp\Autoloader::classExists(
'Dcp\TransformationEngine\Client')) {
 
 2628                 if (!is_object(
$info)) {
 
 2632                 if (
$info->teng_state == \Dcp\TransformationEngine\Client::error_connect) {
 
 2633                     $info->teng_state = \Dcp\TransformationEngine\Client::status_inprogress;
 
 2635                 if ((!
$info->teng_vid) || (
$info->teng_state == \Dcp\TransformationEngine\Client::status_inprogress)) {
 
 2637                     if (!
$info->teng_vid) {
 
 2639                         $value = sprintf(_(
"conversion %s in progress") , $engine);
 
 2654                             $mime = 
'text/plain';
 
 2656                             $mime = 
'image/png';
 
 2659                         $value = 
"$mime|$vidout";
 
 2660                         if (
$err == 
"") 
$vf->rename($vidout, sprintf(_(
"conversion of %s in progress") . 
".%s", 
$info->name, $engine));
 
 2664                         $this->vidNoSendTextToEngine[$vidout] = 
true;
 
 2668                             $vidout = 
$info->id_file;
 
 2669                             $vf->rename($vidout, sprintf(_(
"update of %s in progress") . 
".%s", $info1->name, $engine));
 
 2674                     $err = 
vault_generate($this->dbaccess, $engine, $vidin, $vidout, $isimage, $this->initid);
 
 2680                         if (
$info->teng_state < 0) {
 
 2681                             if (
$info->teng_state == \Dcp\TransformationEngine\Client::error_convert) 
$value = 
"convertfail.png";
 
 2682                             else $value = 
"convertimpossible.png";
 
 2684                             if (
$info->teng_state == \Dcp\TransformationEngine\Client::status_done) 
$value = 
$info->mime_s . 
'|' . 
$info->id_file . 
'|' . 
$info->name;
 
 2690                     if (
$info->teng_state != \Dcp\TransformationEngine\Client::status_done) {
 
 2691                         $this->vidNoSendTextToEngine[
$info->id_file] = 
true;
 
 2706         if (!$this->_maskApplied) $this->ApplyMask();
 
 2709         reset($this->attributes->attr);
 
 2710         foreach ($this->attributes->attr as $k => $v) {
 
 2711             if (((get_class($v) == 
"MenuAttribute")) && (($v->mvisibility != 
'H') || $viewhidden)) $tsa[$v->id] = $v;
 
 2725             foreach ($this->attributes->attr as $k => $v) {
 
 2729                 if ((get_class($v) == 
"NormalAttribute") && ($v->needed) && ($v->usefor == 
'Q')) $tsa[$v->id] = $v;
 
 2732             if (!$this->_maskApplied) $this->ApplyMask();
 
 2733             foreach ($this->attributes->attr as $k => $v) {
 
 2737                 if ((get_class($v) == 
"NormalAttribute") && ($v->needed) && ($v->usefor != 
'Q')) $tsa[$v->id] = $v;
 
 2749         $tsa = $this->GetNeededAttributes();
 
 2751         foreach ($tsa as $k => $v) {
 
 2752             if ($v->inArray()) {
 
 2755                 foreach ($columnValues as 
$value) {
 
 2757                         $err.= sprintf(_(
"%s needed\n") , $v->getLabel());
 
 2764                     $err.= sprintf(_(
"%s needed\n") , $v->getLabel());
 
 2779         return ($this->
$a == $b);
 
 2789         include_once (
"GENERIC/generic_util.php");
 
 2794         if (!$this->_maskApplied) $this->ApplyMask();
 
 2796         if (isset($this->attributes->attr)) {
 
 2798             if ((!$forcedefault) && ($pref != 
"")) {
 
 2800                 $tpref = explode(
";", $pref);
 
 2802                 foreach ($this->attributes->attr as $k => $v) {
 
 2803                     if (in_array($v->id, $tpref)) {
 
 2808                 foreach ($this->attributes->attr as $k => $v) {
 
 2809                     if (get_class($v) == 
"NormalAttribute" && $v->usefor != 
'Q') {
 
 2811                         if (($v->type != 
"array") && ($withfile || (($v->type != 
"image") && ($v->type != 
"file")))) $tsa[$v->id] = $v;
 
 2825         if (!$this->_maskApplied) $this->ApplyMask();
 
 2827         if (!empty($this->attributes->attr)) {
 
 2828             $this->attributes->orderAttributes();
 
 2830         $tattr = $this->attributes->attr;
 
 2831         foreach ($tattr as $k => $v) {
 
 2836             if ((get_class($v) == 
"NormalAttribute") && (($v->mvisibility == 
"W") || ($v->mvisibility == 
"O") || ($v->type == 
"docid")) && ($v->type != 
"array")) {
 
 2838                 if (preg_match(
"/\(([^\)]+)\):(.+)/", $v->phpfunc, $reg)) {
 
 2840                     $aout = explode(
",", $reg[2]);
 
 2841                     foreach ($aout as $ka => $va) {
 
 2842                         $ra = $this->GetAttribute($va);
 
 2843                         if ($ra) $tsa[strtolower($va) ] = $ra;
 
 2859         $nattr = $this->GetNormalAttributes();
 
 2862         foreach ($nattr as $k => 
$a) {
 
 2863             if (
$a->repeat || (
$a->visibility == 
"I") || (
$a->visibility == 
"O") || (
$a->type == 
"longtext") || (
$a->type == 
"xml") || (
$a->type == 
"htmltext") || (
$a->type == 
"image") || (
$a->type == 
"file") || (
$a->getOption(
'sortable') != 
'asc' && 
$a->getOption(
'sortable') != 
'desc')) {
 
 2876         if ($this->doctype == 
'C') 
return; 
 
 2877         $ltitle = $this->GetTitleAttributes();
 
 2880         foreach ($ltitle as $k => $v) {
 
 2882                 if ($v->inArray() && ($v->getOption(
'multiple') == 
'yes')) {
 
 2884                 } 
else $title1.= $this->
getRawValue($v->id) . 
" ";
 
 2888         if (
mb_trim($title1) != 
"") $this->title = mb_substr(
mb_trim(preg_replace(
'/\p{Cc}/u', 
' ', $title1)) , 0, 255);
 
 2889         $this->title = mb_substr(
mb_trim(preg_replace(
'/\p{Cc}/u', 
' ', $this->
getCustomTitle())) , 0, 255);
 
 3065         foreach ($ltitle as $at) {
 
 3066             if (($at->type == 
'text') && (($at->visibility == 
'W') || ($at->visibility == 
'O')) && (!$at->inArray())) {
 
 3077             $this->title = str_replace(
"\n", 
" ", 
$title);
 
 3078             $this->setvalue($idt, 
$title);
 
 3089         $nattr = $this->GetNormalAttributes();
 
 3090         foreach ($nattr as $k => $v) {
 
 3094         $lvalues = array_merge($lvalues, $this->mvalues); 
 
 3119         $lidAttr = strtolower($idAttr);
 
 3120         if (isset($this->$lidAttr) && ($this->$lidAttr != 
"")) 
return $this->$lidAttr;
 
 3137     final public function getAttributeValue($idAttr)
 
 3144             throw new Dcp\Exception(
'DOC0114', $idAttr, $this->title, $this->fromname);
 
 3147         if (empty($oa->isNormal)) {
 
 3148             throw new Dcp\Exception(
'DOC0116', $idAttr, $this->title, $this->fromname);
 
 3166         $localRecord = array();
 
 3169             throw new Dcp\Exception(
'DOC0115', $idAttr, $this->title, $this->fromname);
 
 3171         if (empty($oa->isNormal)) {
 
 3172             throw new Dcp\Exception(
'DOC0117', $idAttr, $this->title, $this->fromname);
 
 3177         if ($oa->type === 
"array") {
 
 3179             $ta = $this->attributes->getArrayElements($oa->id);
 
 3180             foreach ($ta as $k => $v) {
 
 3185         if ($oa->type === 
"array") {
 
 3186             foreach ($localRecord as $aid => $v) {
 
 3187                 if ($this->$aid !== $v) {
 
 3188                     $this->_oldvalue[$aid] = $v;
 
 3203         static $first = 
true;
 
 3221     final public function getTValue($idAttr, $def = 
"", $index = - 1)
 
 3223         static $first = 
true;
 
 3244             if ($index == - 1) 
return array();
 
 3246         } 
else if ($v == 
"\t") {
 
 3247             if ($index == - 1) 
return array(
 
 3253         if ($index == - 1) {
 
 3255             if ($oa && $oa->type == 
"xml") {
 
 3256                 foreach ($t as $k => $v) {
 
 3257                     $t[$k] = str_replace(
'<BR>', 
"\n", $v);
 
 3262         if (isset($t[$index])) {
 
 3264             if ($oa && $oa->type == 
"xml") $t[$index] = str_replace(
'<BR>', 
"\n", $t[$index]);
 
 3295         if (
$a->type == 
"array") {
 
 3296             $ta = $this->attributes->getArrayElements(
$a->id);
 
 3297             $ti = $tv = array();
 
 3300             foreach ($ta as $k => $v) {
 
 3302                 $ix = max($ix, count($tv[$k]));
 
 3304             for ($i = 0; $i < $ix; $i++) {
 
 3307             foreach ($ta as $k => $v) {
 
 3308                 for ($i = 0; $i < $ix; $i++) {
 
 3310                         $k => isset($tv[$k][$i]) ? $tv[$k][$i] : 
'' 
 3314             if ($index == - 1) 
return $ti;
 
 3315             else return $ti[$index];
 
 3331         if (
$a->type == 
"array") {
 
 3332             $ta = $this->attributes->getArrayElements(
$a->id);
 
 3335             foreach ($ta as $k => $v) {
 
 3339                 foreach ($tv as $vv) $tvu[] = $vv; 
 
 3344         return sprintf(_(
"%s is not an array attribute") , $idAttr);
 
 3358         static $calls = array();
 
 3359         if (array_key_exists(strtolower($idAttr) , $calls)) {
 
 3362             $calls[strtolower($idAttr) ] = 1;
 
 3367         if (
$a->type == 
"array") {
 
 3368             $ta = $this->attributes->getArrayElements(
$a->id);
 
 3373             foreach ($ta as $k => $v) { 
 
 3375                 if ($deleteLastEmptyRows) {
 
 3376                     $c = count($tValues[$k]);
 
 3377                     for ($i = 
$c - 1; $i >= 0; $i--) {
 
 3378                         if ($tValues[$k][$i] === 
'' || $tValues[$k][$i] === null) {
 
 3379                             unset($tValues[$k][$i]);
 
 3385             foreach ($ta as $k => $v) { 
 
 3386                 $c = count($tValues[$k]);
 
 3387                 if ($max < 0) $max = 
$c;
 
 3389                     if (
$c != $max) $needRepad = 
true;
 
 3390                     if ($max < 
$c) $max = 
$c;
 
 3394                 $oldComplete = $this->_setValueCompleteArray;
 
 3395                 $this->_setValueCompleteArray = 
true;
 
 3396                 foreach ($ta as $k => $v) { 
 
 3397                     $c = count($tValues[$k]);
 
 3399                         $nt = array_pad($tValues[$k], $max, 
"");
 
 3405                 $this->_setValueCompleteArray = $oldComplete;
 
 3408             unset($calls[strtolower($idAttr) ]);
 
 3412         unset($calls[strtolower($idAttr) ]);
 
 3413         return sprintf(_(
"%s is not an array attribute") , $idAttr);
 
 3427         if (!is_array($tv)) 
return sprintf(
'values "%s" must be an array', $tv);
 
 3428         $old_setValueCompleteArrayRow = $this->_setValueNeedCompleteArray;
 
 3429         $this->_setValueNeedCompleteArray = 
false;
 
 3431         $tv = array_change_key_case($tv, CASE_LOWER);
 
 3433         if ((!empty(
$a)) && 
$a->type == 
"array") {
 
 3436                 $ta = $this->attributes->getArrayElements(
$a->id);
 
 3437                 $attrOut = array_diff(array_keys($tv) , array_keys($ta));
 
 3439                     $this->_setValueNeedCompleteArray = $old_setValueCompleteArrayRow;
 
 3440                     return sprintf(_(
'attribute "%s" is not a part of array "%s"') , implode(
', ', $attrOut) , $idAttr);
 
 3445                 foreach ($ta as $k => $v) {
 
 3446                     $k = strtolower($k);
 
 3448                     $val = isset($tv[$k]) ? $tv[$k] : 
'';
 
 3450                         array_unshift($tnv, $val);
 
 3451                     } elseif ($index > 0 && $index < count($tnv)) {
 
 3452                         $t1 = array_slice($tnv, 0, $index);
 
 3453                         $t2 = array_slice($tnv, $index);
 
 3454                         $tnv = array_merge($t1, array(
 
 3466             $this->_setValueNeedCompleteArray = $old_setValueCompleteArrayRow;
 
 3469         $this->_setValueNeedCompleteArray = $old_setValueCompleteArrayRow;
 
 3470         return sprintf(_(
"%s is not an array attribute") , $idAttr);
 
 3482         $old_setValueCompleteArrayRow = $this->_setValueNeedCompleteArray;
 
 3483         $this->_setValueNeedCompleteArray = 
false;
 
 3486         if (
$a->type == 
"array") {
 
 3487             $ta = $this->attributes->getArrayElements(
$a->id);
 
 3490             foreach ($ta as $k => $v) {
 
 3493             $this->_setValueNeedCompleteArray = $old_setValueCompleteArrayRow;
 
 3496         $this->_setValueNeedCompleteArray = $old_setValueCompleteArrayRow;
 
 3497         return sprintf(_(
"%s is not an array attribute") , $idAttr);
 
 3531         if (!$this->withoutControl) {
 
 3532             if ($this->
id > 0) { 
 
 3533                 $err = $this->Control(
"edit");
 
 3537         $attrid = strtolower($attrid);
 
 3541         $oattr = $this->GetAttribute($attrid);
 
 3544             if (($index + 1) > count($tval)) {
 
 3545                 $tval = array_pad($tval, $index + 1, 
"");
 
 3551             if (count(
$value) == 0) {
 
 3557                 if ($oattr && $oattr->repeat && (count(
$value) == 1) && substr(key(
$value) , 0, 1) == 
"s") {
 
 3559                     $rank = intval(substr(key(
$value) , 1));
 
 3560                     if (count($ov) < ($rank - 1)) { 
 
 3562                         for ($i = 
$start; $i < $rank; $i++) {
 
 3566                     foreach (
$value as $k => $v) {
 
 3567                         $ov[substr($k, 1, 1) ] = $v;
 
 3581             if ($oattr === 
false) {
 
 3582                 if ($this->
id > 0) {
 
 3583                     return sprintf(_(
"attribute %s unknow in document \"%s\" [%s]") , $attrid, $this->
getTitle() , $this->fromname);
 
 3585                     return sprintf(_(
"attribute %s unknow in family \"%s\"") , $attrid, $this->fromname);
 
 3588             if ($oattr->mvisibility == 
"I") {
 
 3589                 if ($this->_setValueCompleteArray === 
false) {
 
 3590                     return sprintf(_(
"no permission to modify this attribute %s") , $attrid);
 
 3594                 if ($oattr->type != 
"password") 
$value = 
" ";
 
 3599                 if ((!empty($this->$attrid)) || (isset($this->$attrid) && $this->$attrid === 
"0")) {
 
 3601                     if ($this->_setValueCompleteArray === 
false) {
 
 3602                         $this->hasChanged = 
true;
 
 3603                         $this->_oldvalue[$attrid] = $this->$attrid;
 
 3606                     if ($oattr->type == 
"file") {
 
 3608                         $this->clearFullAttr($oattr->id);
 
 3613                 if (!isset($this->$attrid)) $this->$attrid = 
"";
 
 3615                 if (strcmp($this->$attrid, 
$value) != 0 && strcmp($this->$attrid, str_replace(
"\n ", 
"\n", 
$value)) != 0) {
 
 3617                     if ($oattr->repeat) {
 
 3623                     foreach ($tvalues as $kvalue => $avalue) {
 
 3624                         if (($avalue != 
"") && ($avalue != 
"\t")) {
 
 3626                                 $avalue = trim($avalue);
 
 3627                                 $tvalues[$kvalue] = $avalue;
 
 3628                                 switch ($oattr->type) {
 
 3635                                         if ($oattr->getOption(
"etype") == 
"open") {
 
 3637                                             $tenum = $oattr->getEnum();
 
 3638                                             $keys = array_keys($tenum);
 
 3639                                             if (!in_array($avalue, $keys)) {
 
 3640                                                 $oattr->addEnum($this->dbaccess, $avalue, $avalue);
 
 3646                                         if ($avalue == 
'-') {
 
 3649                                         $tvalues[$kvalue] = str_replace(
",", 
".", $avalue);
 
 3650                                         $tvalues[$kvalue] = str_replace(
" ", 
"", $tvalues[$kvalue]);
 
 3651                                         if ($avalue != 
"\t") {
 
 3652                                             if (!is_numeric($tvalues[$kvalue])) {
 
 3653                                                 return sprintf(_(
"value [%s] is not a number") , $tvalues[$kvalue]);
 
 3655                                                 $tvalues[$kvalue] = (string)((
double)$tvalues[$kvalue]); 
 
 3663                                         if ($avalue == 
'-') {
 
 3666                                         $tvalues[$kvalue] = str_replace(
",", 
".", $avalue);
 
 3667                                         $tvalues[$kvalue] = str_replace(
" ", 
"", $tvalues[$kvalue]);
 
 3668                                         if (($avalue != 
"\t") && (!is_numeric($tvalues[$kvalue]))) {
 
 3669                                             return sprintf(_(
"value [%s] is not a number") , $tvalues[$kvalue]);
 
 3671                                         $tvalues[$kvalue] = round(doubleval($tvalues[$kvalue]) , 2);
 
 3676                                         if ($avalue == 
'-') {
 
 3679                                         if (($avalue != 
"\t") && (!is_numeric($avalue))) {
 
 3680                                             return sprintf(_(
"value [%s] is not a number") , $avalue);
 
 3682                                         if (floatval($avalue) < - floatval(pow(2, 31)) || floatval($avalue) > floatval(pow(2, 31) - 1)) {
 
 3684                                             return sprintf(_(
"[%s] must be between %s and %s") , $avalue, -floatval(pow(2, 31)) , floatval(pow(2, 31) - 1));
 
 3686                                         if (intval($avalue) != floatval($avalue)) {
 
 3687                                             return sprintf(_(
"[%s] must be a integer") , $avalue);
 
 3690                                         $tvalues[$kvalue] = intval($avalue);
 
 3694                                         if (preg_match(
'/^(\d\d?):(\d\d?):?(\d\d?)?$/', $avalue, $reg)) {
 
 3695                                             $hh = intval($reg[1]);
 
 3696                                             $mm = intval($reg[2]);
 
 3697                                             $ss = isset($reg[3]) ? intval($reg[3]) : 0; 
 
 3698                                             if ($hh < 0 || $hh > 23 || $mm < 0 || $mm > 59 || $ss < 0 || $ss > 59) {
 
 3699                                                 return sprintf(_(
"value [%s] is out of limit time") , $avalue);
 
 3701                                             if (isset($reg[3])) {
 
 3702                                                 $tvalues[$kvalue] = sprintf(
"%02d:%02d:%02d", $hh, $mm, $ss);
 
 3704                                                 $tvalues[$kvalue] = sprintf(
"%02d:%02d", $hh, $mm);
 
 3707                                             return sprintf(_(
"value [%s] is not a valid time") , $avalue);
 
 3713                                         if (trim($avalue) == 
"") {
 
 3714                                             if (!$oattr->repeat) {
 
 3715                                                 $tvalues[$kvalue] = 
"";
 
 3719                                                 return sprintf(_(
"value [%s] is not a valid date") , $avalue);
 
 3723                                             if ($localeconfig !== 
false) {
 
 3724                                                 $tvalues[$kvalue] = 
stringDateToIso($avalue, $localeconfig[
'dateFormat']);
 
 3726                                                 return sprintf(_(
"local config for date not found"));
 
 3732                                         if (trim($avalue) == 
"") {
 
 3733                                             if (!$oattr->repeat) {
 
 3734                                                 $tvalues[$kvalue] = 
"";
 
 3738                                                 return sprintf(_(
"value [%s] is not a valid timestamp") , $avalue);
 
 3742                                             if ($localeconfig !== 
false) {
 
 3743                                                 $tvalues[$kvalue] = 
stringDateToIso($avalue, $localeconfig[
'dateTimeFormat']);
 
 3745                                                 return sprintf(_(
"local config for timestamp not found"));
 
 3752                                         if ((!$oattr->repeat) || ($avalue != $this->getMultipleRawValues($attrid, 
"", $kvalue))) {
 
 3754                                             $this->clearFullAttr($oattr->id, ($oattr->repeat) ? $kvalue : -1);
 
 3756                                         $tvalues[$kvalue] = str_replace(
'\\', 
'', $tvalues[$kvalue]); 
 
 3760                                         $tvalues[$kvalue] = str_replace(
'\\', 
'', $tvalues[$kvalue]);
 
 3764                                         $tvalues[$kvalue] = str_replace(
''', 
"'", $tvalues[$kvalue]);
 
 3765                                         $tvalues[$kvalue] = preg_replace(
"/<!--.*?-->/ms", 
"", $tvalues[$kvalue]); 
 
 3766                                         $tvalues[$kvalue] = \Dcp\Utils\htmlclean::xssClean($tvalues[$kvalue]);
 
 3767                                         if ($oattr->getOption(
"htmlclean") == 
"yes") {
 
 3768                                             $tvalues[$kvalue] = \Dcp\Utils\htmlclean::cleanStyle($tvalues[$kvalue]);
 
 3771                                         $html = \Dcp\Utils\htmlclean::normalizeHTMLFragment($tvalues[$kvalue], $error);
 
 3772                                         if ($html === 
false) {
 
 3777                                             return _(
"Malformed HTML:") . 
"\n" . $error;
 
 3780                                         if ($oattr->getOption(
"htmlclean") == 
"yes") {
 
 3781                                             $tvalues[$kvalue] = $html;
 
 3784                                         $tvalues[$kvalue] = str_replace(
"[", 
"[", $tvalues[$kvalue]); 
 
 3789                                         include_once (
"FDL/Class.DocCount.php");
 
 3790                                         $d = 
new docCount($this->dbaccess);
 
 3797                                         $tvalues[$kvalue] = str_replace(
"\r", 
" ", $tvalues[$kvalue]);
 
 3804                     $rawValue = implode(
"\n", $tvalues);
 
 3805                     if (!$this->_setValueCompleteArray && $this->$attrid != $rawValue) {
 
 3806                         $this->_oldvalue[$attrid] = $this->$attrid;
 
 3807                         $this->hasChanged = 
true;
 
 3809                     $this->$attrid = $rawValue;
 
 3813         if ($this->_setValueNeedCompleteArray && $oattr && $oattr->inArray()) {
 
 3825     final private function clearFullAttr($attrid, $index = - 1)
 
 3827         $attrid = strtolower($attrid);
 
 3829         if ($oa && $oa->usefor != 
'Q') {
 
 3830             if ($oa->getOption(
"search") != 
"no") {
 
 3831                 $ak = $attrid . 
'_txt';
 
 3832                 if ($index == - 1) {
 
 3841                 $this->fields[$ak] = $ak;
 
 3842                 $ak = $attrid . 
'_vec';
 
 3844                 $this->fields[$ak] = $ak;
 
 3845                 $this->fulltext = 
'';
 
 3846                 $this->fields[
'fulltext'] = 
'fulltext'; 
 
 3847                 $this->textsend[$attrid . $index] = array(
 
 3848                     "attrid" => $attrid,
 
 3859     final private function sendTextToEngine()
 
 3862         if (!empty($this->textsend)) {
 
 3863             include_once (
"FDL/Lib.Vault.php");
 
 3864             foreach ($this->textsend as $k => $v) {
 
 3865                 $index = $v[
"index"];
 
 3867                 else $fval = strtok($this->
getRawValue($v[
"attrid"]) , 
"\n");
 
 3870                     if (isset($this->vidNoSendTextToEngine[$vid])) {
 
 3877                     $this->vidNoSendTextToEngine[$vid] = 
true;
 
 3880             $this->textsend = array(); 
 
 3892         if (!$aid) $afiles = $this->GetFileAttributes(
true);
 
 3896         foreach ($afiles as $k => $v) {
 
 3899             if ($v->inArray()) {
 
 3901                 foreach ($tv as $kv => $vv) {
 
 3902                     $this->clearFullAttr($k, $kv);
 
 3905                 $this->clearFullAttr($k);
 
 3912         $this->
modify(
true, $ttxt, 
true);
 
 3913         $err = $this->sendTextToEngine();
 
 3929         if (
$a->type == 
"file") {
 
 3936                 $info = 
new vaultFileInfo();
 
 3940                     $basename = 
$info->name;
 
 3949             if ($ftitle != 
"") {
 
 3950                 $vf->Rename($vid, $ftitle);
 
 3951                 $basename = $ftitle;
 
 3953                 if ($basename != 
"") { 
 
 3954                     $vf->Rename($vid, $basename);
 
 3958                 $mime = trim(shell_exec(sprintf(
"file -ib %s", escapeshellarg(
$filename))));
 
 3959                 $value = 
"$mime|$vid|$basename";
 
 3963                     $this->clearFullAttr($attrid); 
 
 3983         if (
$a->type == 
"file") {
 
 4012     final public function saveFile($attrid, $stream, $ftitle = 
"", $index = - 1)
 
 4015         if (is_resource($stream) && get_resource_type($stream) == 
"stream") {
 
 4018             if (
$a->type == 
"file") {
 
 4031                         $basename = 
$info->name;
 
 4041                 while (!feof($stream)) {
 
 4042                     if (
false === fwrite($tmpstream, fread($stream, 4096))) {
 
 4043                         $err = 
"403 Forbidden";
 
 4050                     $newfile = ($basename == 
"");
 
 4053                         $trev = $this->GetRevisions(
"TABLE", 2);
 
 4058                         $prevfile = 
getv($revdoc, strtolower($attrid));
 
 4059                         if ($prevfile == $fvalue) $newfile = 
true;
 
 4067                     if ($ftitle != 
"") {
 
 4069                     } elseif ($basename != 
"") { 
 
 4074                         else $mime = trim(shell_exec(sprintf(
"file -ib %s", escapeshellarg(
$filename))));
 
 4075                         if ($ftitle) 
$value = 
"$mime|$vaultid|$ftitle";
 
 4076                         else $value = 
"$mime|$vaultid|$oftitle";
 
 4079                             $this->clearFullAttr($attrid); 
 
 4087                     $this->hasChanged = 
true;
 
 4101     final function copyFile($idattr, $newname = 
"", $index = - 1)
 
 4111                 if (
$vf->Show($reg[2], 
$info) == 
"") {
 
 4113                     if (file_exists(
$cible)) {
 
 4119                             if (!$newname) $newname = 
$info->name;
 
 4121                                 $vf->Rename($vid, $newname);
 
 4123                             return $reg[1] . 
"|$vid|$newname";
 
 4142             if ($index == - 1) $f = $this->
getRawValue($idattr);
 
 4151                     if (
$vf->Show($reg[2], 
$info) == 
"") {
 
 4153                         if (file_exists(
$cible)) {
 
 4155                             $vf->Rename($vid, $newname);
 
 4156                             $this->
setValue($idattr, 
$info->mime_s . 
'|' . $vid . 
'|' . $newname, $index);
 
 4175         include_once (
'FDL/Lib.Vault.php');
 
 4183         if (!is_object(
$info) || !is_a(
$info, 
'VaultFileInfo')) {
 
 4187         return sprintf(
"%s|%s|%s", 
$info->mime_s, 
$info->id_file, 
$info->name);
 
 4200         include_once (
"FDL/Lib.Vault.php");
 
 4205                 if ((
$a->type == 
"file") || (
$a->type == 
"image")) {
 
 4210                     $err = sprintf(_(
"attribute %s is not a file attribute") , 
$a->getLabel());
 
 4213                 $err = sprintf(_(
"unknow attribute %s") , $attrid);
 
 4216         catch(\Exception $e) {
 
 4218             $err = $e->getMessage();
 
 4249     final public function storeFiles($attrid, $filenames, $ftitle = 
"")
 
 4253         if (!is_array($filenames)) 
return _(
"no files");
 
 4256         if ((
$a->type == 
"file") || (
$a->type == 
"image")) {
 
 4257             if (
$a->inArray()) {
 
 4259                 foreach ($filenames as $k => 
$filename) {
 
 4261                         include_once (
"FDL/Lib.Vault.php");
 
 4266                             $mime = 
$info->mime_s;
 
 4267                             if ($ftitle[$k] == 
"") $ftitle[$k] = 
$info->name;
 
 4268                             $tvid[] = 
"$mime|$vaultid|" . $ftitle[$k];
 
 4274                 $err = sprintf(_(
"attribute %s is not int a array") , 
$a->getLabel());
 
 4277             $err = sprintf(_(
"attribute %s is not a file attribute") , 
$a->getLabel());
 
 4289         $fa = $this->GetFileAttributes();
 
 4290         foreach ($fa as $aid => $oa) {
 
 4291             if ($oa->inArray()) {
 
 4294                 foreach ($t as $k => $v) {
 
 4295                     $tcopy[$k] = $this->
copyFile($oa->id, 
"", $k);
 
 4299                 $this->
setValue($oa->id, $this->copyFile($oa->id));
 
 4335         $tattrid = explode(
":", $RidAttr);
 
 4336         $lattrid = array_pop($tattrid); 
 
 4338         foreach ($tattrid as $k => $v) {
 
 4340             if (
$docid == 
"") 
return $def;
 
 4344                 if (
$doc->locked == - 1) { 
 
 4345                     $ldocid = 
$doc->getLatestId();
 
 4349             if (!
$doc->isAlive()) 
return $def;
 
 4351         if ($html) 
return $doc->getHtmlAttrValue($lattrid, $def);
 
 4352         else return $doc->getRawValue($lattrid, $def);
 
 4377         $attrid = strtolower($attrid);
 
 4378         if (isset($this->_oldvalue[$attrid])) 
return $this->_oldvalue[$attrid];
 
 4399         if (isset($this->_oldvalue)) 
return $this->_oldvalue;
 
 4411         $oattr = $this->GetAttribute($attrid);
 
 4412         if ($oattr->type == 
'docid') {
 
 4413             $doctitle = $oattr->getOption(
'doctitle');
 
 4414             if ($doctitle == 
'auto') {
 
 4415                 $doctitle = $attrid . 
'_title';
 
 4417             if (!empty($doctitle)) {
 
 4418                 $this->SetValue($doctitle, 
" ");
 
 4421         return $this->SetValue($attrid, 
" ");
 
 4439     private function getMoreValues()
 
 4441         if (isset($this->values)) {
 
 4442             $tvalues = explode(
"£", $this->values);
 
 4443             $tattrids = explode(
"£", $this->attrids);
 
 4444             if (count($tvalues) === count($tattrids)) {
 
 4445                 foreach ($tvalues as $k => $v) {
 
 4446                     $attrid = $tattrids[$k];
 
 4447                     if (($attrid != 
"") && empty($this->$attrid)) {
 
 4448                         $this->$attrid = $v;
 
 4449                         $this->mvalues[$attrid] = $v; 
 
 4455                 $missingAttrIds = array();
 
 4456                 foreach ($tattrids as $k => $attrid) {
 
 4457                     if ($attrid && $this->$attrid === null) {
 
 4458                         $missingAttrIds[] = $attrid;
 
 4461                 if ($missingAttrIds) {
 
 4462                     $missingValues = 
getTDoc($this->dbaccess, $this->
id, array() , $missingAttrIds);
 
 4463                     foreach ($missingValues as $attrid => 
$value) {
 
 4473     private function resetMoreValues()
 
 4475         if (isset($this->values) && $this->
id) {
 
 4476             $tattrids = explode(
"£", $this->attrids);
 
 4477             foreach ($tattrids as $k => $v) {
 
 4483         $this->mvalues = array();
 
 4497         return is_string(
$method) && preg_match(
'/([^:]*)::([^\(]+)\(([^\)]*)\)/', 
$method);
 
 4511     final public function applyMethod(
$method, $def = 
"", $index = - 1, array $bargs = array() , array $mapArgs = array() , &
$err = 
'')
 
 4516         if (self::seemsMethod(
$method)) {
 
 4520             $err = $parseMethod->getError();
 
 4523             $staticClass = $parseMethod->className;
 
 4524             if (!$staticClass) $staticClass = $this;
 
 4525             $methodName = $parseMethod->methodName;
 
 4526             if (method_exists($staticClass, $methodName)) {
 
 4527                 if ((count($parseMethod->inputs) == 0) && (empty($bargs))) {
 
 4529                     $value = call_user_func(array(
 
 4538                     foreach ($bargs as $extraArg) {
 
 4541                     $inputs = array_merge($inputs, $parseMethod->inputs);
 
 4542                     foreach ($inputs as $ki => $input) {
 
 4544                         if ($input->type == 
"string") {
 
 4545                             $args[$ki] = $input->name;
 
 4547                             $mapped = (isset($mapArgs[strtolower($input->name) ])) ? $mapArgs[strtolower($input->name) ] : null;
 
 4549                                 if (is_object($mapped)) 
$args[$ki] = & $mapArgs[strtolower($input->name) ];
 
 4550                                 else $args[$ki] = $mapped;
 
 4552                                 if ($attr->usefor == 
'Q') {
 
 4553                                     if ($attr->inArray()) {
 
 4555                                         if ($index == - 1) 
$args[$ki] = $pas;
 
 4556                                         else $args[$ki] = isset($pas[$index]) ? $pas[$index] : null;
 
 4565                                 if ($input->name == 
'THIS') {
 
 4566                                     $args[$ki] = & $this;
 
 4567                                 } elseif ($input->name == 
'K') {
 
 4568                                     $args[$ki] = $index;
 
 4571                                     $args[$ki] = $input->name; 
 
 4577                     $value = call_user_func_array(array(
 
 4583                 $err = sprintf(_(
"Method [%s] not exists") , 
$method);
 
 4610         if (strlen(trim($oattr->phpconstraint)) > 1) {
 
 4612                 "err" => sprintf(_(
"method %s not found") , $oattr->phpconstraint) ,
 
 4617             if (
$res !== 
true) {
 
 4618                 if (!is_array(
$res)) {
 
 4620                         "err" => _(
"constraint error") ,
 
 4623                     elseif (is_string(
$res)) 
$res = array(
 
 4627                 } elseif (!empty(
$res[
"sug"]) && (!is_array(
$res[
"sug"]))) {
 
 4628                     $res[
"sug"] = array(
 
 4632                 if (is_array(
$res) && 
$res[
"err"] != 
"") $this->constraintbroken = 
"[$attrid] " . 
$res[
"err"];
 
 4649         $listattr = $this->GetNormalAttributes();
 
 4650         foreach ($listattr as $v) {
 
 4651             if (strlen($v->phpconstraint) > 1) {
 
 4652                 if ($v->inArray()) {
 
 4654                     for ($i = 0; $i < count($tv); $i++) {
 
 4656                         if (
$res[
"err"] != 
"") {
 
 4657                             $info[$v->id . $i] = array(
 
 4659                                 "label" => $v->getLabel() ,
 
 4660                                 "sug" => 
$res[
"sug"],
 
 4661                                 "err" => 
$res[
"err"],
 
 4663                                 "pid" => $v->fieldSet->id
 
 4665                             if ($stoptofirst) 
return sprintf(
"[%s] %s", $v->getLabel() , 
$res[
"err"]);
 
 4671                     if (
$res[
"err"] != 
"") {
 
 4672                         $info[$v->id] = array(
 
 4674                             "label" => $v->getLabel() ,
 
 4675                             "pid" => $v->fieldSet->id,
 
 4676                             "sug" => 
$res[
"sug"],
 
 4677                             "err" => 
$res[
"err"]
 
 4679                         if ($stoptofirst) 
return sprintf(
"[%s] %s", $v->getLabel() , 
$res[
"err"]);
 
 4693         $t = $this->GetFileAttributes();
 
 4694         if (count($t) > 0) 
return current($t);
 
 4710         if ($this->
id == 
"") 
return '';
 
 4712         $h = 
new DocHisto($this->dbaccess);
 
 4718         $h->date = date(
"d-m-Y H:i:s");
 
 4722             $h->uname = sprintf(
"%s %s", $u->firstname, $u->lastname);
 
 4724             $h->uname = sprintf(
"%s %s", $action->user->firstname, $action->user->lastname);
 
 4725             $h->uid = $action->user->id;
 
 4732             error_log(sprintf(
"document %s [%d] : %s", $this->title, $this->
id, 
$comment));
 
 4765         if (($this->
id == 
"") || ($this->doctype == 
'T')) 
return '';
 
 4767         include_once (
"FDL/Class.DocLog.php");
 
 4768         $h = 
new DocLog($this->dbaccess);
 
 4778             $h->uname = sprintf(
"%s %s", $u->firstname, $u->lastname);
 
 4780             $h->uname = sprintf(
"%s %s", $action->user->firstname, $action->user->lastname);
 
 4781             $h->uid = $action->user->id;
 
 4785         if (
$arg) $h->arg = serialize(
$arg);
 
 4800         include_once (
"Class.QueryDb.php");
 
 4801         $q = 
new QueryDb($this->dbaccess, 
"dochisto");
 
 4802         if (
$allrev) 
$q->AddQuery(
"initid=" . $this->initid);
 
 4803         else $q->AddQuery(
"id=" . $this->
id);
 
 4804         if ($code) 
$q->addQuery(sprintf(
"code='%s'", pg_escape_string($code)));
 
 4805         $q->order_by = 
"date desc";
 
 4806         $l = 
$q->Query(0, $limit, 
"TABLE");
 
 4808         if (is_array($l)) 
return $l;
 
 4823         if ($this->atags == 
"") {
 
 4824             $this->atags = $tag;
 
 4830                 $this->atags.= 
"\n$tag";
 
 4846         if ($this->atags == 
"") 
return false;
 
 4847         return (preg_match(sprintf(
'/^(%s)$/m', preg_quote($tag, 
'/')) , $this->atags) > 0);
 
 4858         if ($this->atags == 
"") 
return "";
 
 4859         $atags = preg_replace(sprintf(
'/^%s$/m', preg_quote($tag, 
'/')) , 
'', $this->atags);
 
 4863         if (
$atags != $this->atags) {
 
 4880     final public function addUTag($uid, $tag, $datas = 
"", $allrevision = 
true)
 
 4882         if (!$this->initid) 
return "";
 
 4883         if ($tag == 
"") 
return _(
"no user tag specified");
 
 4884         $this->
delUTag($uid, $tag, $allrevision);
 
 4887         $h = 
new DocUTag($this->dbaccess);
 
 4891         $h->fixed = ($allrevision) ? 
'false' : 
'true';
 
 4892         $h->date = date(
"d-m-Y H:i:s");
 
 4896             $h->uname = sprintf(
"%s %s", $u->firstname, $u->lastname);
 
 4898         $h->fromuid = $action->user->id;
 
 4901         $h->comment = $datas;
 
 4913     final public function hasUTag($tag, $allrevision = 
true)
 
 4915         if (!$this->initid) 
return false;
 
 4916         include_once (
"FDL/Class.DocUTag.php");
 
 4917         $docid = ($allrevision) ? $this->initid : $this->
id;
 
 4918         $utag = 
new DocUTag($this->dbaccess, array(
 
 4923         return $utag->isAffected();
 
 4934     final public function getUTag($tag, $allrevision = 
true, $uid = null)
 
 4936         if (!$this->initid) 
return "";
 
 4937         if ($uid === null) {
 
 4941         include_once (
"FDL/Class.DocUTag.php");
 
 4942         $q = 
new QueryDb($this->dbaccess, 
"docUTag");
 
 4943         $q->addQuery(
"uid=" . intval($uid));
 
 4944         if ($tag) 
$q->addQuery(
"tag = '" . pg_escape_string($tag) . 
"'");
 
 4945         if ($allrevision) 
$q->addQuery(
"initid = " . $this->initid);
 
 4946         else $q->addQuery(
"id = " . $this->
id);
 
 4947         $q->order_by = 
"id desc";
 
 4948         $r = 
$q->Query(0, 1);
 
 4949         if (
$q->nb == 1) 
return $r[0];
 
 4960     final public function delUTag($uid, $tag, $allrevision = 
true)
 
 4963             return _(
"no user tag specified");
 
 4967             $err = $this->
exec_query(sprintf(
"delete from docutag where initid=%d and tag='%s' and uid=%d", $this->initid, pg_escape_string($tag) , $uid));
 
 4969             $err = $this->
exec_query(sprintf(
"delete from docutag where id=%d and tag='%s' and uid=%d", $this->
id, pg_escape_string($tag) , $uid));
 
 4981         if (!$this->initid) 
return "";
 
 4983         $err = $this->
exec_query(sprintf(
"delete from docutag where initid=%d and uid=%d", $this->initid, $uid));
 
 4994         if (!$this->initid) 
return "";
 
 4995         include_once (
"FDL/Class.DocUTag.php");
 
 4996         $q = 
new QueryDb($this->dbaccess, 
"docUTag");
 
 4997         $q->Query(0, 0, 
"TABLE", sprintf(
"update docutag set id=%d where initid=%d and (not fixed)", $this->
id, $this->initid));
 
 5008     final public function searchUTags($tag = 
"", $allrevision = 
true, $allusers = 
false)
 
 5010         if (!$this->initid) 
return "";
 
 5011         include_once (
"FDL/Class.DocUTag.php");
 
 5012         $q = 
new QueryDb($this->dbaccess, 
"docUTag");
 
 5013         if (!$allusers) 
$q->addQuery(
"uid=" . intval($this->userid));
 
 5014         if ($tag) 
$q->addQuery(
"tag = '" . pg_escape_string($tag) . 
"'");
 
 5015         if ($allrevision) 
$q->addQuery(
"initid = " . $this->initid);
 
 5016         else $q->addQuery(
"id = " . $this->
id);
 
 5017         $r = 
$q->Query(0, 0, 
"TABLE");
 
 5018         if (
$q->nb == 0) 
$r = array();
 
 5026     public function getWasks($control = 
true)
 
 5029         if ($this->wid > 0 && $this->locked == - 1 && $this->doctype != 
'Z' && $this->state) {
 
 5033             $wdoc = new_doc($this->dbaccess, $this->wid);
 
 5034             if (
$wdoc->isAlive()) {
 
 5036                 $waskids = 
$wdoc->getDocumentWasks($this->state, $control);
 
 5037                 foreach ($waskids as $k => $waskid) {
 
 5041                     $wask = new_doc($this->dbaccess, $waskid);
 
 5042                     if ($wask->isAlive()) {
 
 5043                         $ut = $this->
getUTag(
"ASK_" . $wask->id, 
false);
 
 5044                         if ($ut) $answer = $ut->comment;
 
 5047                             "waskid" => $wask->id,
 
 5048                             "ask" => $wask->getRawValue(
"was_ask") ,
 
 5050                             "label" => $wask->getAskLabel($answer)
 
 5066         $err = _(
"setWaskAnswer::invalid parameters");
 
 5067         $waskid = intval($waskid);
 
 5068         if ($waskid && $answer) {
 
 5070             $err = $this->
addUTag($this->userid, 
"ASK_" . intval($waskid) , $answer, 
false);
 
 5081         $ans = $this->getWasks();
 
 5082         foreach ($ans as $an) {
 
 5083             if (!$an[
"key"]) 
return false;
 
 5093         if (!$this->wid) 
return false;
 
 5094         $ldoc = $this->GetRevisions(
"TABLE");
 
 5098         $wdoc = new_doc($this->dbaccess, $this->wid);
 
 5099         if (
$wdoc->isAlive()) {
 
 5101             foreach ($ldoc as $k => $v) {
 
 5102                 $aask = 
$wdoc->attrPrefix . 
"_ASKID" . ($v[
"state"]);
 
 5103                 if ($v[
"locked"] == - 1 && 
$wdoc->getRawValue($aask)) {
 
 5104                     if (
$wdoc->getRawValue($aask)) 
return $v[
"id"];
 
 5116         return isFixedDoc($this->dbaccess, $this->
id);
 
 5126     final public function revise(
$comment = 
'')
 
 5129         if ($this->locked == - 1) 
return _(
"document already revised");
 
 5131             $err = _(
"document already revised");
 
 5137         if (!$this->withoutControl) {
 
 5138             $err = $this->Control(
"edit");
 
 5143         if ($fdoc->schar == 
"S") 
return sprintf(_(
"the document of %s family cannot be revised") , $fdoc->title);
 
 5147         $this->locked = - 1; 
 
 5148         $this->lmodify = 
'N'; 
 
 5149         $this->allocated = 0; 
 
 5151         $this->postitid = 0;
 
 5152         $date = gettimeofday();
 
 5153         $this->revdate = $date[
'sec']; 
 
 5161             $this->select($this->
id); 
 
 5166             $err = sprintf(
"track error revision [%s]", pg_last_error($this->dbid));
 
 5172         $fa = $this->GetFileAttributes(
true); 
 
 5174         foreach ($fa as $k => $v) {
 
 5175             $ca[] = $v->id . 
"_txt";
 
 5178         foreach ($ca as 
$a) {
 
 5179             if ($this->$a != 
"") $this->fields[
$a] = 
$a;
 
 5187         else $this->locked = 0;
 
 5198             $this->select($olddocid); 
 
 5205         if ($this->dprofid > 0) $this->
setProfil($this->dprofid); 
 
 5210             $this->
addLog(
"revision", array(
 
 5212                 "initid" => $this->initid,
 
 5214                 "title" => $this->title,
 
 5215                 "fromid" => $this->fromid,
 
 5216                 "fromname" => $this->fromname
 
 5220             $maxrev = intval($fdoc->maxrev);
 
 5229                     for ($i = $maxrev; $i < count($revs); $i++) {
 
 5231                         if (
$d) 
$d->_destroy(
true);
 
 5266         if ($this->wid > 0) 
return sprintf(_(
"cannot set free state in workflow controlled document %s") , $this->title);
 
 5267         if ($this->wid == - 1) 
return sprintf(_(
"cannot set free state for document %s: workflow not allowed") , $this->title);
 
 5268         if (!$this->
isRevisable()) 
return sprintf(_(
"cannot set free state for document %s: document cannot be revised") , $this->title);
 
 5269         if ($newstateid == 0) {
 
 5281             $state = new_doc($this->dbaccess, $newstateid);
 
 5282             if (!
$state->isAlive()) 
return sprintf(_(
"invalid freestate document %s") , $newstateid);
 
 5283             if (
$state->fromid != 39) 
return sprintf(_(
"not a freestate document %s") , 
$state->title);
 
 5285             $this->state = 
$state->id;
 
 5314     final public function setState($newstate, 
$comment = 
'', 
$force = 
false, $withcontrol = 
true, $wm1 = 
true, $wm2 = 
true, $wneed = 
true, $wm0 = 
true, $wm3 = 
true, &$msg = 
'')
 
 5316         if ($newstate == 
"") 
return _(
"no state specified");
 
 5317         if (!$this->wid) 
return _(
"document is not controlled by a workflow");
 
 5321         $wdoc = new_doc($this->dbaccess, $this->wid);
 
 5322         if (!
$wdoc->isAlive()) 
return _(
"assigned workflow is not alive");
 
 5327         catch(Dcp\Exception $e) {
 
 5328             $err = sprintf(_(
"Unexpected transition error on workflow %s [%d] : %s") , 
$wdoc->title, 
$wdoc->id, $e->getMessage());
 
 5344         if (is_numeric($this->state) && ($this->state > 0)) {
 
 5361         if ($this->wid > 0) {
 
 5366             if (
$wdoc->isAffected()) 
return $wdoc->getColor($this->state, $def);
 
 5368             if (is_numeric($this->state) && ($this->state > 0)) {
 
 5385         if ($this->wid > 0) {
 
 5390             if (
$wdoc->isAffected()) 
return $wdoc->getActivity($this->state, $def);
 
 5392             if (is_numeric($this->state) && ($this->state > 0)) {
 
 5393                 $stateact = $this->
getDocValue($this->state, 
"frst_desc", $def);
 
 5406         if ($this->locked == - 1) $stateValue = $this->
getState();
 
 5408         return (empty($stateValue) ? 
'' : _($stateValue));
 
 5423     final public function copy($temporary = 
false, $control = 
true, $linkfld = 
false, $copyfile = 
false)
 
 5426         return $this->
duplicate($temporary, $control, $linkfld, $copyfile);
 
 5440     final public function duplicate($temporary = 
false, $control = 
true, $linkfld = 
false, $copyfile = 
false)
 
 5442         if ($this->fromid == 
'') {
 
 5445         $copy = 
createDoc($this->dbaccess, $this->fromid, $control);
 
 5446         if (!is_object($copy)) 
return false;
 
 5450         $err = $copy->transfertValuesFrom($this);
 
 5455         $copy->revision = 
"0";
 
 5456         $copy->locked = 
"0";
 
 5457         $copy->allocated = 
"0";
 
 5462             $copy->doctype = 
"T";
 
 5467             $copy->setProfil($cdoc->cprofid);
 
 5470         $err = $copy->preDuplicate($this);
 
 5473         $err = $copy->Add();
 
 5475         $copy->addHistoryEntry(sprintf(_(
"copy from document #%d -%s-") , $this->
id, $this->title));
 
 5477         if ($copyfile) $copy->duplicateFiles();
 
 5479         $msg = $copy->postDuplicate($this);
 
 5485         if ($linkfld && method_exists($copy, 
"insertFolder")) {
 
 5489             $copy->insertFolder($this->initid);
 
 5553         if (
$doc->isAlive()) {
 
 5554             foreach ($translate as $afrom => $ato) {
 
 5567         if ($this->archiveid == 0) {
 
 5568             if ($this->doctype == 
"C") 
$err = sprintf(
"families cannot be archieved");
 
 5569             elseif (!$this->withoutControl) 
$err = $this->
control(
"edit");
 
 5573                 $this->dprofid = ($this->dprofid > 0) ? (-$this->dprofid) : (-abs($this->profid));
 
 5574                 $archprof = 
$archive->getRawValue(
"arc_profil");
 
 5575                 $this->profid = $archprof;
 
 5585                     $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));
 
 5588         } 
else $err = sprintf(
"document is already archived");
 
 5602         if ($this->archiveid == 
$archive->id) {
 
 5603             if (!$this->withoutControl) 
$err = $this->
control(
"edit");
 
 5606                 $this->archiveid = 
""; 
 
 5607                 $restoreprofil = abs($this->dprofid);
 
 5619                     $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));
 
 5622         } 
else $err = sprintf(
"document not archived");
 
 5650             if ((
$userid != 1) && ($this->locked == 0)) {
 
 5658             if (($this->locked != 
$userid) || ($this->lockdomainid)) {
 
 5685         if ($this->locked == 0) 
return "";
 
 5690             if ($this->locked < - 1) {
 
 5691                 $this->locked = 
"0";
 
 5692                 $this->
modify(
false, array(
 
 5698             if ($this->locked != - 1) {
 
 5699                 $this->locked = 
"0";
 
 5700                 $this->lockdomainid = 
'';
 
 5701                 $this->
modify(
false, array(
 
 5726         if (
$err != 
"") 
$err = _(
"Affectation aborded") . 
"\n" . 
$err;
 
 5729             if ($u->isAffected()) {
 
 5730                 if (
$err != 
"") 
$err = _(
"Affectation aborded") . 
"\n" . 
$err;
 
 5735                     $this->
addHistoryEntry(sprintf(_(
"Affected to %s %s") , $u->firstname, $u->lastname));
 
 5738                             $this->revise(sprintf(_(
"Affected for %s") , 
$comment));
 
 5743                     $this->
addLog(
'allocate', array(
 
 5744                         "allocated" => array(
 
 5746                             "firstname" => $u->firstname,
 
 5747                             "lastname" => $u->lastname
 
 5751                     $this->
delUTag($this->userid, 
"AFFECTED"); 
 
 5756                 $err = _(
"Affectation aborded : user not know");
 
 5761             $this->
modify(
true, array(
 
 5780         if ($this->allocated == 0) 
return "";
 
 5783             if ((!$this->withoutControl) && ($this->userid != $this->allocated)) 
$err = $this->
control(
"unlock");
 
 5787             $u = 
new Account(
"", $this->allocated);
 
 5788             if ($u->isAffected()) {
 
 5789                 $err = $this->unlock();
 
 5791                     $this->
delUTag($this->userid, 
"AFFECTED"); 
 
 5792                     if (
$revision) $this->revise(sprintf(_(
"Unallocated of %s %s : %s") , $u->firstname, $u->lastname, 
$comment));
 
 5796                 $err = _(
"user not know");
 
 5800             $this->allocated = 0;
 
 5801             $this->
modify(
true, array(
 
 5804             $this->
addLog(
'unallocate');
 
 5807         if (
$err != 
"") 
$err = _(
"Unallocate aborded") . 
"\n" . 
$err;
 
 5824         if ($idicon != 
"") {
 
 5827                 if ($idicon[0] === 
"!") {
 
 5828                     $efile = sprintf(
"file/%s/0/icon/-1/%s?inline=yes&width=%s", ($otherId == null) ? $this->
id : $otherId, rawurlencode($reg[
"name"]) , 
$size);
 
 5830                     $efile = 
"resizeimg.php?vid=" . $reg[
"vid"] . 
"&size=" . 
$size;
 
 5832                     $efile = 
"FDL/geticon.php?vaultid=" . $reg[
"vid"] . 
"&mimetype=" . $reg[
"mime"];
 
 5835                 $efile = $action->parent->getImageLink($idicon, 
true, 
$size);
 
 5839             return $action->parent->getImageLink(
"doc.png", 
true, 
$size);
 
 5849         $point = 
"dcp:changeIcon";
 
 5856             if (!$fileData->public_access) {
 
 5861         if ($this->doctype == 
"C") { 
 
 5863             $tableName = sprintf(
"doc%s", 
$fromid);
 
 5864             if ($this->icon != 
"") {
 
 5867                 $qt[] = sprintf(
"ALTER TABLE %s DISABLE TRIGGER ALL", pg_escape_identifier($tableName));
 
 5868                 $qt[] = sprintf(
"UPDATE %s SET icon = %s WHERE (fromid = %s) AND (doctype != 'C') AND ((icon = %s) OR (icon IS NULL))", pg_escape_identifier($tableName) , pg_escape_literal(
$icon) , pg_escape_literal(
$fromid) , pg_escape_literal($this->icon));
 
 5869                 $qt[] = sprintf(
"ALTER TABLE %s ENABLE TRIGGER ALL", pg_escape_identifier($tableName));
 
 5870                 $qt[] = sprintf(
"UPDATE DOCREAD SET icon = %s WHERE (fromid = %s) AND (doctype != 'C') AND ((icon = %s) OR (icon IS NULL))", pg_escape_literal(
$icon) , pg_escape_literal(
$fromid) , pg_escape_literal($this->icon));
 
 5871                 if ((
$err = 
simpleQuery($this->dbaccess, implode(
"; ", $qt) , 
$res, 
false, 
false, 
false)) != 
'') {
 
 5876                 $q = sprintf(
"UPDATE %s SET icon = %s WHERE (fromid = %s) AND (doctype != 'C') AND (icon IS NULL)", pg_escape_identifier($tableName) , pg_escape_literal(
$icon) , pg_escape_literal(
$fromid));
 
 5884         $this->icon = 
$icon;
 
 5885         if ((
$err = $this->Modify()) != 
'') {
 
 5905         $tin = explode(
",", strtolower($in));
 
 5907         $this->paramRefresh[
"$in:$out"] = array(
 
 5919         foreach ($this->attributes->attr as $k => $v) {
 
 5920             $tv[$v->id] = $v->mvisibility;
 
 5922         foreach ($this->paramRefresh as $k => $v) {
 
 5924             foreach ($v[
"in"] as $va) {
 
 5931                 foreach ($v[
"out"] as $oa) {
 
 5932                     if (($tv[$oa] == 
"W") || ($tv[$oa] == 
"O")) $tv[$oa] = 
"S";
 
 5997         if ($oAttr->mvisibility == 
'I') {
 
 6000             if ($oAttr->inArray()) {
 
 6003                 foreach ($t as $k => $v) {
 
 6020         if ($this->locked == - 1) 
return ''; 
 
 6021         if (($this->doctype == 
'C') || ($this->doctype == 
'Z')) 
return ''; 
 
 6022         if ($this->lockdomainid > 0) 
return '';
 
 6023         $changed = $this->hasChanged;
 
 6027         $msg.= $this->SpecRefreshGen();
 
 6029         if ($this->hasChanged && $this->
id > 0) {
 
 6030             $this->lastRefreshError = $this->
modify(); 
 
 6043         $fa = $this->GetFileAttributes();
 
 6044         foreach ($fa as $aid => $oa) {
 
 6045             $rn = $oa->getOption(
"rn");
 
 6047                 if ($oa->inArray()) {
 
 6049                     foreach ($t as $k => $v) {
 
 6056                             if ($fname != $cfname) {
 
 6067                         if ($fname != $cfname) {
 
 6090         $mi = strlen($link);
 
 6091         for ($i = 0; $i < $mi; $i++) {
 
 6092             switch ($link[$i]) {
 
 6096                     if (isset($link[$i]) && $link[$i] == 
"%") {
 
 6101                         if (isset($link[$i]) && $link[$i] == 
"?") {
 
 6105                         if (isset($link[$i + 1]) && $link[$i + 1] == 
"%") {
 
 6107                             switch ($link[$i]) {
 
 6109                                     $urllink.= $action->GetParam(
"CORE_BASEURL");
 
 6113                                     $urllink.= $action->GetParam(
"CORE_STANDURL");
 
 6117                                     $urllink.= $action->GetParam(
"CORE_EXTERNURL");
 
 6125                                     $urllink.= rawurlencode($this->title);
 
 6137                             while (($i < $mi) && ($link[$i] != 
"%")) {
 
 6138                                 $sattrid.= $link[$i];
 
 6141                             if (preg_match(
'/^[a-z0-9_\\\\]*::/i', $sattrid)) {
 
 6143                                 foreach (self::$infofields as $propId => $prop) {
 
 6146                                 $urllink.= $this->
applyMethod($sattrid, $sattrid, $k, array() , $mapArgs);
 
 6149                                 if (!in_array(mb_strtolower($sattrid) , $this->fields)) {
 
 6150                                     if (preg_match(
'/[0-9A-F][0-9A-F]/', $sattrid)) {
 
 6151                                         $urllink.= 
'%' . $sattrid; 
 
 6152                                         if (isset($link[$i]) && $link[$i] == 
'%') {
 
 6165                                     $oa = $this->GetAttribute($sattrid);
 
 6166                                     if (($k >= 0) && ($oa && $oa->repeat)) {
 
 6169                                         $ovalue = isset($tval[$k]) ? chop($tval[$k]) : 
'';
 
 6174                                     if ($ovalue == 
"" && (!$optional)) {
 
 6178                                     if (strstr($ovalue, 
"\n")) {
 
 6179                                         $ovalue = str_replace(
"\n", 
'\n', $ovalue);
 
 6181                                     $urllink.= rawurlencode($ovalue); 
 
 6193                     while ($link[$i] != 
'}') {
 
 6194                         $sattrid.= $link[$i];
 
 6198                     $ovalue = $action->getParam($sattrid);
 
 6199                     $urllink.= rawurlencode($ovalue);
 
 6204                     $urllink.= $link[$i];
 
 6208         return (chop($urllink));
 
 6230         if ($v === 
"" || $v === null) 
return array();
 
 6231         return explode(
"\n", str_replace(
"\r", 
"", $v));
 
 6243         return self::rawValueToArray($v);
 
 6254         $v = str_replace(
"\n", $br, $v);
 
 6255         if (count($v) == 0) 
return "";
 
 6256         return implode(
"\n", $v);
 
 6269         return self::arrayToRawValue($v, $br);
 
 6281         return sprintf(
"%s?app=FREEDOM&action=FREEDOM_RSS&dcpopen-authorization=%s&id=%s", $action->getParam(
"CORE_OPENURL", $action->getParam(
"CORE_EXTERNURL")) , $action->user->getUserToken(
false, 
false, [
"action" => 
"FREEDOM_RSS", 
"app" => 
"FREEDOM"]) , 
$this->id);
 
 6293     public function getFileLink($attrid, $index = - 1, $cache = 
false, $inline = 
false, $otherValue = 
'', 
$info = null)
 
 6295         if ($index === 
'' || $index === null) {
 
 6303                 if (is_array($otherValue)) $avalue = $otherValue[$index];
 
 6304                 else $avalue = $otherValue;
 
 6305             } 
else $avalue = $otherValue;
 
 6308         if ($oa->usefor === 
"Q" && $this->doctype !== 
"C") {
 
 6317                 $fileKey = strtotime(
$info->mdate);
 
 6319                 $fname = str_replace(
'"', 
'-', 
$info->name);
 
 6321                 $fname = str_replace(
'"', 
'-', $reg[3]);
 
 6325             $url = sprintf(
"file/%s/%d/%s/%s/%s?cache=%s&inline=%s", 
$docid, $fileKey, $attrid, $index, rawurlencode($fname) , $cache ? 
"yes" : 
"no", $inline ? 
"yes" : 
"no");
 
 6326             if ($this->cvid > 0) {
 
 6329                     $url.= 
'&cvViewid=' . $viewId;
 
 6348     final public function getDocAnchor(
$id, $target = 
"_self", $htmllink = 
true, 
$title = 
false, $js = 
true, $docrev = 
"latest", $viewIcon = 
false)
 
 6350         $latest = ($docrev == 
"latest" || $docrev == 
"");
 
 6354             if (trim(
$title) == 
"") {
 
 6356                     $a = 
"<a>" . sprintf(_(
"document not exists yet")) . 
"</a>";
 
 6358                     $a = 
"<a>" . sprintf(_(
"unknown document id %s") , 
$id) . 
"</a>";
 
 6367                         $mUrl = 
getParam(
"CORE_MAILACTIONURL");
 
 6368                         if (strstr($mUrl, 
'%')) {
 
 6369                             if ($this->
id != 
$id) {
 
 6370                                 $mDoc = new_doc($this->dbaccess, 
$id);
 
 6374                             $ul = htmlspecialchars($mDoc->urlWhatEncode($mUrl));
 
 6377                             $ul = htmlspecialchars(GetParam(
"CORE_MAILACTIONURL"));
 
 6378                             $ul.= 
"&id=$id";
 
 6383                         $ul.= 
"&app=FDL&action=VIEWEXTDOC&id=$id";
 
 6387                         $ul.= 
"&app=FDL&action=OPENDOC&mode=view&id=$id";
 
 6390                 if ($target == 
"ext") {
 
 6392                     $jslatest = (
$latest) ? 
'true' : 
'false';
 
 6393                     $ec = 
getHttpVars(
"ext:targetRelation", 
'Ext.fdl.Document.prototype.publish("opendocument",null,%V%,"view",{latest:' . $jslatest . 
'})');
 
 6398                             if ($lid) 
$id = $lid;
 
 6400                         $ec = str_replace(
"%V%", 
$id, $ec);
 
 6401                         $ecu = str_replace(
"'", 
'"', $ec);
 
 6404                             simpleQuery($this->dbaccess, sprintf(
'select icon from docread where id=%d', 
$id) , $iconValue, 
true, 
true);
 
 6405                             $ajs.= sprintf(
'class="relation" style="background-image:url(%s)"', $this->
getIcon($iconValue, 14));
 
 6407                         $a = 
"<a $ajs onclick='parent.$ecu'>$title</a>";
 
 6409                         if ($docrev == 
"latest" || $docrev == 
"" || !$docrev) $ul.= 
"&latest=Y";
 
 6410                         elseif ($docrev != 
"fixed") {
 
 6412                             if (preg_match(
"/^state\\(([a-zA-Z0-9_:-]+)\\)/", $docrev, $matches)) {
 
 6413                                 $ul.= 
"&state=" . $matches[1];
 
 6416                         $a = 
"<a href=\"$ul\">$title</a>";
 
 6420                         if ($docrev == 
"latest" || $docrev == 
"" || !$docrev) {
 
 6421                             $ul.= 
"&latest=Y";
 
 6422                         } elseif ($docrev != 
"fixed") {
 
 6424                             if (preg_match(
"/^state\\(([a-zA-Z0-9_:-]+)\\)/", $docrev, $matches)) {
 
 6425                                 $ul.= 
"&state=" . $matches[1];
 
 6429                     if ($js) $ajs = 
"oncontextmenu=\"popdoc(event,'$ul');return false;\"";
 
 6432                     $ajs.= sprintf(
' documentId="%s" ', 
$id);
 
 6434                         simpleQuery($this->dbaccess, sprintf(
'select icon from docread where id=%d', 
$id) , $iconValue, 
true, 
true);
 
 6435                         $ajs.= sprintf(
'class="relation" style="background-image:url(%s)"', $this->
getIcon($iconValue, 14));
 
 6437                     $a = 
"<a $ajs target=\"$target\" href=\"$ul\">$title</a>";
 
 6457     final public function getHtmlValue($oattr, 
$value, $target = 
"_self", $htmllink = 
true, $index = - 1, $entities = 
true, $abstract = 
false)
 
 6459         if (!$this->htmlFormater) {
 
 6462         if ($this->formaterLevel == 0) {
 
 6463             $htmlFormater = & $this->htmlFormater;
 
 6465             if (!isset($this->otherFormatter[$this->formaterLevel])) {
 
 6466                 $this->otherFormatter[$this->formaterLevel] = 
new DocHtmlFormat($this);
 
 6468             $htmlFormater = $this->otherFormatter[$this->formaterLevel];
 
 6470         if ($htmlFormater->doc->id != $this->id) {
 
 6471             $htmlFormater->setDoc($this);
 
 6473         $this->formaterLevel++;
 
 6474         $r = $htmlFormater->getHtmlValue($oattr, 
$value, $target, $htmllink, $index, $entities, $abstract);
 
 6475         $this->formaterLevel--;
 
 6489     final public function getHtmlAttrValue($attrid, $target = 
"_self", $htmllink = 2, $index = - 1, $entities = 
true, $abstract = 
false)
 
 6493             throw new Dcp\Exception(
'DOC0130', $attrid, $this->
id, $this->fromid);
 
 6499         return $this->GetHtmlValue($oattr, $v, $target, $htmllink, $index, $entities, $abstract);
 
 6515             return $objectAttr->getTextualValue($this, $index, $configuration);
 
 6532     $htmllink = 
false, $index = - 1)
 
 6536         if ($v == 
"") 
return $v;
 
 6552     $htmllink = 
false, $index = - 1)
 
 6555         if (!$this->oooFormater) {
 
 6558         if ($this->oooFormater->doc->id != $this->id) {
 
 6559             $this->oooFormater->setDoc($this);
 
 6561         return $this->oooFormater->getOooValue($oattr, 
$value, $index);
 
 6579             return sprintf(_(
"no privilege %s for document with id %d") , $aclname, $doc->id);
 
 6584         return sprintf(_(
"no privilege %s for %s [%d]") , $aclname, $doc->
getTitle() , $doc->id);
 
 6598         if (($this->profid <= 0) || ($this->userid == 1)) {
 
 6607             if (($aclname == 
'edit' || $aclname == 
'delete' || $aclname == 
'unlock') && $this->
isRealProfile()) {
 
 6635         if ($this->IsAffected()) {
 
 6636             if (($this->profid <= 0) || ($uid == 1)) 
return ""; 
 
 6637             if (!$uid) 
return _(
"control :: user identifier is null");
 
 6657     final public function sqlTrigger($onlydrop = 
false, $code = 
false)
 
 6660         if (get_class($this) == 
"DocFam") {
 
 6664             if ($this->doctype == 
'C') 
return '';
 
 6665             if (intval($this->fromid) == 0) 
return '';
 
 6673         $sql.= 
"select droptrigger('doc" . $cid . 
"');";
 
 6674         if ($onlydrop) 
return $sql; 
 
 6678             $na = $this->GetNormalAttributes();
 
 6681             $fulltext_c = array();
 
 6682             foreach ($na as $k => $v) {
 
 6683                 $opt_searchcriteria = $v->getOption(
"searchcriteria", 
"");
 
 6684                 if (($v->type != 
"array") && ($v->type != 
"frame") && ($v->type != 
"tab")) {
 
 6686                     if ($v->docid == 
$famId) {
 
 6692                     if (($v->type != 
"file") && ($v->type != 
"image") && ($v->type != 
"password") && ($opt_searchcriteria != 
"hidden")) {
 
 6698                         $fulltext_c[] = array(
 
 6703                 if ($v->type == 
"file" && $opt_searchcriteria != 
"hidden") {
 
 6706                         "attrid" => $k . 
"_txt",
 
 6707                         "vecid" => $k . 
"_vec" 
 6711                         "attrid" => $k . 
"_txt" 
 6716             $tabstract = array();
 
 6717             $na = $this->GetAbstractAttributes();
 
 6718             foreach ($na as $k => $v) {
 
 6719                 $opt_searchcriteria = $v->getOption(
"searchcriteria", 
"");
 
 6720                 if ($opt_searchcriteria == 
"hidden") {
 
 6723                 if (($v->type != 
"array") && ($v->type != 
"file") && ($v->type != 
"image") && ($v->type != 
"password")) {
 
 6724                     $tabstract[] = array(
 
 6729             $lay->setBlockData(
"ATTRFIELD", $tvalues);
 
 6730             $lay->setBlockData(
"SEARCHFIELD", $tsearch);
 
 6731             $lay->setBlockData(
"ABSATTR", $tabstract);
 
 6732             $lay->setBlockData(
"FILEATTR", $files);
 
 6733             $lay->setBlockData(
"FILEATTR2", $files);
 
 6734             $lay->setBlockData(
"FILEATTR3", $files);
 
 6735             $lay->setBlockData(
"FULLTEXT_C", $fulltext_c);
 
 6736             $lay->set(
"hasattr", (count($tvalues) > 0));
 
 6737             $lay->set(
"hassattr", (count($tsearch) > 0));
 
 6738             $lay->set(
"hasabsattr", (count($tabstract) > 0));
 
 6739             $lay->set(
"docid", $this->fromid);
 
 6743             if ($this->attributes !== null && isset($this->attributes->fromids) && is_array($this->attributes->fromids)) {
 
 6744                 foreach ($this->attributes->fromids as $k => $v) {
 
 6746                     $sql.= 
"create trigger UV{$cid}_$v BEFORE INSERT OR UPDATE ON doc$cid FOR EACH ROW EXECUTE PROCEDURE upval$v();";
 
 6750             if ($cid != 
"fam") {
 
 6751                 $sql.= 
"create trigger AUVR{$cid} BEFORE UPDATE  ON doc$cid FOR EACH ROW EXECUTE PROCEDURE resetvalues();";
 
 6752                 $sql.= 
"create trigger VSEARCH{$cid} BEFORE INSERT OR UPDATE  ON doc$cid FOR EACH ROW EXECUTE PROCEDURE searchvalues$cid();";
 
 6754                 $sql.= 
"create trigger UVdocfam before insert or update on docfam FOR EACH ROW EXECUTE PROCEDURE upvaldocfam();";
 
 6756             $sql.= 
"create trigger zread{$cid} AFTER INSERT OR UPDATE OR DELETE ON doc$cid FOR EACH ROW EXECUTE PROCEDURE setread();";
 
 6757             $sql.= 
"create trigger FIXDOC{$cid} AFTER INSERT ON doc$cid FOR EACH ROW EXECUTE PROCEDURE fixeddoc();";
 
 6774             if (!empty($v[
"unique"])) $unique = 
"unique";
 
 6776             if (!empty($v[
"using"])) {
 
 6778                 if ($v[
"using"][0] == 
"@") {
 
 6779                     $v[
"using"] = 
getParam(substr($v[
"using"], 1));
 
 6781                 $t[] = sprintf(
"CREATE $unique INDEX %s$id on  doc$id using %s(%s);\n", $k, $v[
"using"], $v[
"on"]);
 
 6783                 $t[] = sprintf(
"CREATE $unique INDEX %s$id on  doc$id(%s);\n", $k, $v[
"on"]);
 
 6801         if (is_array($reg)) {
 
 6802             $aid = $reg[
'layout'];
 
 6803             if ($reg[
'index'] != 
'') {
 
 6804                 $index = $reg[
'index'];
 
 6808                 if ($oa->usefor != 
'Q') {
 
 6815                     $template = $tt[$index];
 
 6818                 if ($template == 
"") {
 
 6839         $zoneElements = $this->
parseZone($zone);
 
 6840         if ($zoneElements === 
false) {
 
 6844         return $zoneElements[
'modifier'];
 
 6857         $zoneElements = $this->
parseZone($zone);
 
 6858         if ($zoneElements === 
false) {
 
 6862         return $zoneElements[
'transform'];
 
 6875         if (is_array($tdefval)) {
 
 6876             foreach ($tdefval as $aid => $dval) {
 
 6883                 if (empty($oattr)) $ok = 
false;
 
 6884                 elseif ($dval === 
'' || $dval === null) $ok = 
false;
 
 6885                 elseif (!is_a($oattr, 
"BasicAttribute")) $ok = 
false;
 
 6886                 elseif ($forcedefault) $ok = 
true;
 
 6887                 elseif (!$oattr->inArray()) $ok = 
true;
 
 6888                 elseif ($oattr->fieldSet->format != 
"empty" && $oattr->fieldSet->getOption(
"empty") != 
"yes") {
 
 6889                     if (empty($tdefval[$oattr->fieldSet->id])) $ok = 
true;
 
 6893                     if ($oattr->type == 
"array") {
 
 6896                             $values = json_decode($dval, 
true);
 
 6900                                     throw new Dcp\Exception(
"DFLT0007", $aid, $dval, $this->fromname);
 
 6911                             if ($terr) 
throw new Dcp\Exception(
"DFLT0009", $aid, $dval, 
$values, $this->fromname, implode(
'; ', $terr));
 
 6917                             $this->
setValue($aid, $this->GetValueMethod($dval));
 
 6940         if (($this->
name == 
"") && ($this->initid > 0)) {
 
 6942             if ($dfam->name == 
"") 
return sprintf(
"no family name %s", $dfam->id);
 
 6944                 $this->
name = sprintf(
'TEMPORARY_%s_%s_%s', $dfam->name, $this->initid, uniqid());
 
 6964         if ($this->prelid > 0) {
 
 6966             $d = 
getTDoc($this->dbaccess, $this->prelid);
 
 6970                     if (controlTDoc(
$d, 
"view")) {
 
 6971                         if (!in_array(
$d[
"initid"], array_keys($tr))) {
 
 6972                             $tr[
$d[
"initid"]] = $d[
"title"];
 
 6973                             if ($d[
"prelid"] > 0) $d = 
getTDoc($this->dbaccess, $d[
"prelid"]);
 
 6975                         } 
else $fini = 
true;
 
 6976                     } 
else $fini = 
true;
 
 6994     final public function viewDoc($layout = 
"FDL:VIEWBODYCARD", $target = 
"_self", $ulink = 
true, $abstract = 
false, $changelayout = 
false)
 
 6999         if ($reg === 
false) {
 
 7000             return htmlspecialchars(sprintf(_(
"error in pzone format %s") , $layout) , ENT_QUOTES);
 
 7003         if (array_key_exists(
'args', $reg)) {
 
 7006             $layout = $reg[
'fulllayout'];
 
 7007             if (array_key_exists(
'argv', $reg)) {
 
 7008                 foreach ($reg[
'argv'] as $k => $v) {
 
 7009                     $ZONE_ARGS[$k] = $v;
 
 7014         if (!$changelayout) {
 
 7022         if (strtolower(
$ext) == 
"odt") {
 
 7023             include_once (
'Class.OOoLayout.php');
 
 7026             $this->lay = 
new OOoLayout($tplfile, $action, $this);
 
 7028             $this->lay = 
new Layout($tplfile, $action, 
"");
 
 7031         $this->lay->set(
"_readonly", ($this->Control(
'edit') != 
""));
 
 7032         $method = strtok(strtolower($reg[
'layout']) , 
'.');
 
 7033         if (method_exists($this, 
$method)) {
 
 7035                 $refMeth = 
new ReflectionMethod(get_class($this) , 
$method);
 
 7036                 if (preg_match(
'/@templateController\b/', $refMeth->getDocComment())) {
 
 7037                     $this->
$method($target, $ulink, $abstract);
 
 7040                     $syserr = 
ErrorCode::getError(
"DOC1101", $refMeth->getDeclaringClass()->getName() , $refMeth->getName() , $this);
 
 7041                     $action->log->error($syserr);
 
 7042                     $err = htmlspecialchars(sprintf(_(
"Layout \"%s\" : Controller not allowed") , $layout) , ENT_QUOTES);
 
 7046             catch(Exception $e) {
 
 7047                 if ((!file_exists($this->lay->file) && (!$this->lay->template))) {
 
 7048                     return htmlspecialchars(sprintf(_(
"template file (layout [%s]) not found") . 
": %s", $layout, $e->getMessage()) , ENT_QUOTES);
 
 7057         if ((!file_exists($this->lay->file) && (!$this->lay->template))) {
 
 7058             return htmlspecialchars(sprintf(_(
"template file (layout [%s]) not found") , $layout) , ENT_QUOTES);
 
 7061         $laygen = $this->lay->gen();
 
 7063         if (!$changelayout) $this->lay = $play;
 
 7067             return preg_replace(array(
 
 7068                 "/href=\"index\\.php[^\"]*\"/i",
 
 7069                 "/onclick=\"[^\"]*\"/i",
 
 7070                 "/ondblclick=\"[^\"]*\"/i" 
 7077         if ($target == 
"mail") {
 
 7079             return preg_replace(
"/\\?session=[^&]*&/", 
"?", $laygen);
 
 7081         if ($binary && ($target != 
"ooo")) {
 
 7084             file_put_contents(
$tmpfile, $laygen);
 
 7099     final public function viewdefaultcard($target = 
"_self", $ulink = 
true, $abstract = 
false, $viewhidden = 
false)
 
 7101         $this->
viewattr($target, $ulink, $abstract, $viewhidden);
 
 7102         $this->
viewprop($target, $ulink, $abstract);
 
 7114     function viewbodycard($target = 
"_self", $ulink = 
true, $abstract = 
false, $onlyopt = 
false)
 
 7124             $listattr = $this->GetAbstractAttributes();
 
 7126             $listattr = $this->GetNormalAttributes($onlyopt);
 
 7132         $currentFrameId = 
"";
 
 7136         $currentFrame = null;
 
 7137         $changeframe = 
false; 
 
 7138         $tableframe = array();
 
 7139         $tableimage = array();
 
 7146         $showonlytab = ($onlytab ? $onlytab : 
false);
 
 7148             $this->
addUTag($this->userid, 
"lasttab", $onlytab);
 
 7153         foreach ($listattr as $i => $attr) {
 
 7154             if ($onlytab && ($attr->fieldSet->id != $onlytab && $attr->fieldSet->fieldSet->id != $onlytab)) 
continue;
 
 7161             if (!$attr->fieldSet) {
 
 7162                 addWarningMsg(sprintf(_(
"unknow set for attribute %s %s") , $attr->id, $attr->getLabel()));
 
 7165             $frametpl = $attr->fieldSet->getOption(
"viewtemplate");
 
 7166             if ($attr->fieldSet && ($frametpl && $attr->fieldSet->type != 
"array")) {
 
 7168                 if ($currentFrameId != $attr->fieldSet->id) {
 
 7169                     if (($currentFrameId != 
"") && ($attr->fieldSet->mvisibility != 
"H") && ($attr->fieldSet->mvisibility != 
"I")) {
 
 7170                         $changeframe = 
true;
 
 7174                 $goodvalue = (((
$value != 
"") || ($attr->type == 
"array") || $attr->getOption(
"showempty")) && ($attr->mvisibility != 
"H") && ($attr->mvisibility != 
"I") && ($attr->mvisibility != 
"O") && (!$attr->inArray()));
 
 7175                 if (($attr->type == 
"array") && (!$attr->getOption(
"showempty"))) {
 
 7181                     $toptab = $attr->getTab();
 
 7185                     if ($toptab) $tabonfly = ($toptab->getOption(
"viewonfly") == 
"yes");
 
 7186                     if ($tabonfly && (!$showonlytab)) {
 
 7187                         $ut = $this->getUtag(
"lasttab");
 
 7188                         if ($ut) $showonlytab = $ut->comment;
 
 7189                         elseif ($attr->fieldSet->id && $attr->fieldSet->fieldSet) {
 
 7190                             $showonlytab = $attr->fieldSet->fieldSet->id;
 
 7193                     $attrInNextTab = ($tabonfly && $toptab && ($toptab->id != $showonlytab));
 
 7194                     if (!$attrInNextTab) {
 
 7195                         $viewtpl = $attr->getOption(
"viewtemplate");
 
 7197                             if ($viewtpl == 
"none") {
 
 7201                                     $attr->setOption(
"vlabel", 
"none");
 
 7203                                 $htmlvalue = sprintf(
"[ZONE FDL:VIEWTPL?id=%d&famid=%d&target=%s&zone=%s]", $this->
id, $this->fromid, $target, $viewtpl);
 
 7206                             $htmlvalue = $this->GetHtmlValue($attr, 
$value, $target, $ulink);
 
 7212                 } 
else $htmlvalue = 
"";
 
 7214                 if (($htmlvalue === 
false) || ($goodvalue)) { 
 
 7215                     if ($currentFrameId != $attr->fieldSet->id) {
 
 7216                         if (($currentFrameId != 
"") && ($attr->fieldSet->mvisibility != 
"H")) $changeframe = 
true;
 
 7223                 if ($currentFrameId == 
'') {
 
 7227                 if (!is_object($oaf)) {
 
 7228                     throw new Dcp\Exception(
'DOC0125', $currentFrameId, $attr->id);
 
 7230                 $frametpl = $oaf->getOption(
"viewtemplate");
 
 7231                 $changeframe = 
false;
 
 7232                 if ((($v + $nbimg) > 0) || $frametpl) { 
 
 7233                     $frames[$k][
"frametext"] = ($oaf && $oaf->getOption(
"vlabel") != 
"none") ? 
mb_ucfirst($this->GetLabel($oaf->id)) : 
"";
 
 7234                     $frames[$k][
"frameid"] = $oaf->id;
 
 7235                     $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor", 
false) : 
false;
 
 7237                     $frames[$k][
"tag"] = 
"";
 
 7238                     $frames[$k][
"TAB"] = 
false;
 
 7242                     $pSet = $oaf->fieldSet;
 
 7243                     if ($pSet && ($pSet->id != 
"") && ($pSet->id != Adoc::HIDDENFIELD)) {
 
 7244                         $frames[$k][
"tag"] = 
"TAG" . $pSet->id;
 
 7245                         $frames[$k][
"TAB"] = 
true;
 
 7246                         $ttabs[$pSet->id] = array(
 
 7247                             "tabid" => $pSet->id,
 
 7248                             "tabtitle" => ($pSet->getOption(
"vlabel") == 
"none") ? 
' ' : 
mb_ucfirst($pSet->getLabel())
 
 7251                     $frames[$k][
"viewtpl"] = ($frametpl != 
"");
 
 7252                     $frames[$k][
"zonetpl"] = ($frametpl != 
"") ? sprintf(
"[ZONE FDL:VIEWTPL?id=%d&famid=%d&target=%s&zone=%s]", $this->
id, $this->fromid, $target, $frametpl) : 
'';
 
 7254                     $frames[$k][
"rowspan"] = $v + 1; 
 
 7255                     $frames[$k][
"TABLEVALUE"] = 
"TABLEVALUE_$k";
 
 7257                     $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
 
 7258                     $frames[$k][
"IMAGES"] = 
"IMAGES_$k";
 
 7259                     $this->lay->SetBlockData($frames[$k][
"IMAGES"], $tableimage);
 
 7260                     $frames[$k][
"notloaded"] = 
false;
 
 7261                     if ($oaf && $oaf->type == 
"frame" && (count($tableframe) + count($tableimage)) == 0) {
 
 7262                         if (!$frames[$k][
"viewtpl"]) {
 
 7263                             $frames[$k][
"viewtpl"] = 
true;
 
 7264                             $frames[$k][
"zonetpl"] = _(
"Loading...");
 
 7265                             $frames[$k][
"notloaded"] = 
true;
 
 7270                     $tableframe = array();
 
 7271                     $tableimage = array();
 
 7276                 $currentFrameId = $attr->fieldSet->id;
 
 7278             if ($htmlvalue === 
false) {
 
 7280                 if ($currentFrameId != $attr->fieldSet->id) {
 
 7281                     if (($attr->fieldSet->mvisibility != 
"H") && ($attr->fieldSet->mvisibility != 
"I")) {
 
 7282                         $changeframe = 
true;
 
 7283                         $currentFrameId = $attr->fieldSet->id;
 
 7284                         $currentFrame = $attr->fieldSet;
 
 7292                 switch ($attr->type) {
 
 7294                         $tableimage[$nbimg][
"imgsrc"] = $htmlvalue;
 
 7295                         $tableimage[$nbimg][
"itarget"] = ($action->Read(
"navigator", 
"") == 
"NETSCAPE") ? 
"_self" : 
"_blank";
 
 7296                         $width = $attr->getOption(
"iwidth", 
"80px");
 
 7297                         $tableimage[$nbimg][
"imgwidth"] = $width;
 
 7298                         if (strstr($htmlvalue, 
'EXPORTFILE')) {
 
 7299                             $tableimage[$nbimg][
"imgthumbsrc"] = $htmlvalue . 
"&width=" . intval($width);
 
 7301                             $tableimage[$nbimg][
"imgthumbsrc"] = $htmlvalue;
 
 7306                         $tableframe[$v][
"nonelabel"] = 
false;
 
 7307                         $tableframe[$v][
"normallabel"] = 
true;
 
 7308                         $tableframe[$v][
"uplabel"] = 
false;
 
 7309                         $tableframe[$v][
"value"] = $htmlvalue;
 
 7313                 if (($attr->fieldSet->mvisibility != 
"H") && ($htmlvalue !== 
"" || $goodvalue)) {
 
 7314                     $currentFrameId = $attr->fieldSet->id;
 
 7315                     $currentFrame = $attr->fieldSet;
 
 7318                 if ($attr->type != 
"image") {
 
 7319                     $tableframe[$v][
"wvalue"] = (($attr->type == 
"array") && ($attr->getOption(
"vlabel") == 
"up" || $attr->getOption(
"vlabel") == 
"none")) ? 
"1%" : 
"30%"; 
 
 7320                     $tableframe[$v][
"ndisplay"] = 
"inline";
 
 7322                     if ($attr->getOption(
"vlabel") == 
"none") {
 
 7323                         $tableframe[$v][
"nonelabel"] = 
true;
 
 7324                         $tableframe[$v][
"normallabel"] = 
false;
 
 7325                     } 
else if ($attr->getOption(
"vlabel") == 
"up") {
 
 7326                         if ($attr->type == 
"array") { 
 
 7327                             $tableframe[$v][
"nonelabel"] = 
true;
 
 7328                             $tableframe[$v][
"normallabel"] = 
false;
 
 7330                             $tableframe[$v][
"normallabel"] = 
false;
 
 7331                             $tableframe[$v][
"uplabel"] = 
true;
 
 7334                     $tableframe[$v][
"name"] = $this->GetLabel($attr->id);
 
 7335                     if (($attr->type == 
"htmltext") && (count($tableframe) == 1)) {
 
 7336                         $keys = array_keys($listattr);
 
 7337                         if (isset($keys[$iattr])) {
 
 7338                             $na = $listattr[$keys[$iattr]]; 
 
 7339                             if ($na->fieldSet->id != $attr->fieldSet->id) { 
 
 7340                                 $tableframe[$v][
"ndisplay"] = 
"none";
 
 7341                                 $tableframe[$v][
"wvalue"] = 
"1%";
 
 7346                     $tableframe[$v][
"attrid"] = $attr->id;
 
 7347                     $tableframe[$v][
"atype"] = $attr->type;
 
 7348                     $tableframe[$v][
"classback"] = ($attr->usefor == 
"O") ? 
"FREEDOMOpt" : 
"FREEDOMBack1";
 
 7351                     $tableimage[$nbimg][
"imgalt"] = $this->GetLabel($attr->id);
 
 7355             if ($currentFrameId == 
'' && isset($attr->fieldSet->id)) {
 
 7356                 $currentFrameId = $attr->fieldSet->id;
 
 7361             $frametpl = $oaf->getOption(
"viewtemplate");
 
 7363         if ((($v + $nbimg) > 0) || $frametpl) 
 
 7365             if ($oaf) $frames[$k][
"frametext"] = ($oaf->getOption(
"vlabel") != 
"none") ? 
mb_ucfirst($this->GetLabel($currentFrameId)) : 
"";
 
 7366             else $frames[$k][
"frametext"] = 
'';
 
 7367             $frames[$k][
"frameid"] = $currentFrameId;
 
 7368             $frames[$k][
"tag"] = 
"";
 
 7369             $frames[$k][
"TAB"] = 
false;
 
 7370             $frames[$k][
"viewtpl"] = ($frametpl != 
"");
 
 7371             $frames[$k][
"zonetpl"] = ($frametpl != 
"") ? sprintf(
"[ZONE FDL:VIEWTPL?id=%d&famid=%d&target=%s&zone=%s]", $this->
id, $this->fromid, $target, $frametpl) : 
'';
 
 7373             $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor", 
false) : 
false;
 
 7374             $pSet = (isset($currentFrame->fieldSet) ? $currentFrame->fieldSet : null);
 
 7375             if ($pSet !== null && ($pSet->id != 
"") && ($pSet->id != Adoc::HIDDENFIELD)) {
 
 7376                 $frames[$k][
"tag"] = 
"TAG" . $pSet->id;
 
 7377                 $frames[$k][
"TAB"] = 
true;
 
 7378                 $ttabs[$pSet->id] = array(
 
 7379                     "tabid" => $pSet->id,
 
 7380                     "tabtitle" => ($pSet->getOption(
"vlabel") == 
"none") ? 
' ' : 
mb_ucfirst($pSet->getLabel())
 
 7383             $frames[$k][
"rowspan"] = $v + 1; 
 
 7384             $frames[$k][
"TABLEVALUE"] = 
"TABLEVALUE_$k";
 
 7386             $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
 
 7388             $frames[$k][
"IMAGES"] = 
"IMAGES_$k";
 
 7389             $this->lay->SetBlockData($frames[$k][
"IMAGES"], $tableimage);
 
 7390             $frames[$k][
"notloaded"] = 
false;
 
 7391             if ($oaf->type == 
"frame" && (count($tableframe) + count($tableimage)) == 0) {
 
 7392                 if (!$frames[$k][
"viewtpl"]) {
 
 7393                     $frames[$k][
"viewtpl"] = 
true;
 
 7394                     $frames[$k][
"zonetpl"] = _(
"Loading...");
 
 7395                     $frames[$k][
"notloaded"] = 
true;
 
 7400         $this->lay->SetBlockData(
"TABLEBODY", $frames);
 
 7401         $this->lay->SetBlockData(
"TABS", $ttabs);
 
 7402         $this->lay->Set(
"ONETAB", count($ttabs) > 0);
 
 7403         $this->lay->Set(
"NOTAB", ($target == 
"mail") || $onlytab);
 
 7404         $this->lay->Set(
"docid", $this->
id);
 
 7406         if (count($ttabs) > 0) {
 
 7407             $this->lay->Set(
"firsttab", 
false);
 
 7408             $ut = $this->getUtag(
"lasttab");
 
 7409             if ($ut) $firstopen = $ut->comment; 
 
 7410             else $firstopen = 
false;
 
 7411             foreach ($ttabs as $k => $v) {
 
 7413                 if ($oa->getOption(
"firstopen") == 
"yes") $this->lay->set(
"firsttab", $k);
 
 7414                 if ($firstopen == $oa->id) $this->lay->Set(
"firsttab", $k);
 
 7428         $this->
viewprop($target, $ulink, $abstract);
 
 7429         $this->lay->set(
"iconsrc", $this->
getIcon());
 
 7433         else $this->lay->set(
"state", 
"");
 
 7439     function viewanswers( )
 
 7442         if (!$this->
isAlive()) 
$err = (sprintf(_(
"unknow document reference '%s'") , GetHttpVars(
"docid")));
 
 7445             $this->lay->template = 
$err;
 
 7446             $this->lay->noparse = 
true;
 
 7450         $answers = $this->getWasks(
false);
 
 7452         foreach ($answers as $ka => $ans) {
 
 7453             $utags = $this->
searchUTags(
"ASK_" . $ans[
"waskid"], 
false, 
true);
 
 7457             $wask = new_doc($this->dbaccess, $ans[
"waskid"]);
 
 7463             foreach ($utags as $k => $v) {
 
 7464                 $taguid[] = $v[
"uid"];
 
 7466                 $t[$k][
"label"] = $wask->getAskLabel($v[
"comment"]);
 
 7467                 $t[$k][
"ask"] = $wask->getRawValue(
"was_ask");
 
 7476             foreach ($t as $k => $v) {
 
 7477                 if ($v[
"comment"] != $prevc) {
 
 7478                     $prevc = $v[
"comment"];
 
 7481                 $t[$k][
"class"] = (($odd % 2) == 0) ? 
"evenanswer" : 
"oddanswer";
 
 7484             $ru = $wask->getUsersForAcl(
'answer'); 
 
 7485             $una = array_diff(array_keys($ru) , $taguid);
 
 7490             foreach ($una as $k => $v) {
 
 7491                 $tuna[$v] = $ru[$v][
"login"];
 
 7494             asort($tuna, SORT_STRING);
 
 7495             foreach ($tuna as $k => $v) {
 
 7497                     "login" => $ru[$k][
"login"],
 
 7498                     "fn" => $ru[$k][
"firstname"],
 
 7499                     "ln" => $ru[$k][
"lastname"]
 
 7503             $this->lay->setBlockData(
"ANSWERS" . $wask->id, $t);
 
 7504             $this->lay->setBlockData(
"NOTANS" . $wask->id, $tna);
 
 7505             $title = $wask->getTitle();
 
 7507             $this->lay->set(
"asktitle", 
$title);
 
 7509                 "waskid" => $wask->id,
 
 7510                 "nacount" => sprintf(_(
"number of waiting answers %d") , count($una)) ,
 
 7511                 "count" => (count($t) > 1) ? sprintf(_(
"%d answers") , count($t)) : sprintf(_(
"%d answer") , count($t)) ,
 
 7512                 "ask" => $wask->getRawValue(
"was_ask")
 
 7515         $this->lay->setBlockData(
"WASK", $tw);
 
 7516         $this->lay->set(
"docid", $this->
id);
 
 7526         return strcasecmp($a[
"comment"] . $a[
"uname"], $b[
"comment"] . $b[
"uname"]);
 
 7538         $this->
viewprop($target, $ulink, $abstract);
 
 7539         $this->lay->eSet(
"iconsrc", $this->
getIcon());
 
 7541         $this->lay->eSet(
"ficonsrc", $fdoc->getIcon());
 
 7543         $this->lay->rSet(
"username", str_replace(array(
 
 7549         ) , htmlspecialchars(
$owner->firstname . 
" " . 
$owner->lastname)));
 
 7550         $this->lay->rSet(
"userid", 
$owner->fid);
 
 7551         $this->lay->rSet(
"lockedby", $this->lay->get(
"locked"));
 
 7553         $this->lay->rSet(
"lockdomain", 
'');
 
 7554         if ($this->locked == - 1) {
 
 7555             $this->lay->rSet(
"lockedid", 
false);
 
 7559             if ($this->lockdomainid) {
 
 7560                 $this->lay->eSet(
"lockdomain", sprintf(_(
"in domain %s") , $this->
getDocAnchor($this->lockdomainid, 
'_blank', 
true, 
'', 
false, 
true, 
true)));
 
 7562             $this->lay->rSet(
"lockedid", 
$user->fid);
 
 7566             if (($this->locked == - 1) || ($this->lmodify != 
'Y')) $this->lay->eSet(
"state", _(
$state));
 
 7567             else $this->lay->rSet(
"state", sprintf(_(
"current (<em>%s</em>)") , htmlspecialchars(_(
$state) , ENT_QUOTES)));
 
 7568         } 
else $this->lay->eset(
"state", _(
"no state"));
 
 7569         if (is_numeric($this->state) && ($this->state > 0) && (!$this->wid)) {
 
 7570             $this->lay->rSet(
"freestate", $this->state);
 
 7571         } 
else $this->lay->rSet(
"freestate", 
false);
 
 7572         $this->lay->rSet(
"setname", (
bool)$action->parent->Haspermission(
"FREEDOM_MASTER", 
"FREEDOM"));
 
 7573         $this->lay->rSet(
"lname", $this->
name);
 
 7574         $this->lay->rSet(
"hasrevision", ($this->
revision > 0));
 
 7575         $this->lay->eSet(
"moddate", strftime(
"%Y-%m-%d %H:%M:%S", $this->revdate));
 
 7576         $this->lay->eSet(
"moddatelabel", _(
"last modification date"));
 
 7577         if ($this->locked == - 1) {
 
 7578             if ($this->doctype == 
'Z') $this->lay->eSet(
"moddatelabel", _(
"suppression date"));
 
 7579             else $this->lay->eSet(
"moddatelabel", _(
"revision date"));
 
 7581         if (GetParam(
"CORE_LANG") == 
"fr_FR") { 
 
 7582             $this->lay->eSet(
"revdate", strftime(
"%a %d %b %Y %H:%M", $this->revdate));
 
 7584             $this->lay->eSet(
"revdate", strftime(
"%x %T", $this->revdate));
 
 7586         $this->lay->eSet(
"version", $this->version);
 
 7588         if ((abs($this->profid) > 0) && ($this->profid != $this->
id)) {
 
 7590             $this->lay->rSet(
"profile", $this->
getDocAnchor(abs($this->profid) , 
'_blank', 
true, 
'', 
false, 
'latest', 
true));
 
 7592             if ($this->profid == 0) {
 
 7593                 $this->lay->eSet(
"profile", _(
"no access control"));
 
 7595                 if ($this->dprofid == 0) {
 
 7597                     $this->lay->rSet(
"profile", $this->
getDocAnchor(abs($this->profid) , 
'_blank', 
true, _(
"specific control") , 
false, 
'latest', 
true));
 
 7599                     $this->lay->rSet(
"profile", $this->
getDocAnchor(abs($this->dprofid) , 
'_blank', 
true, _(
"dynamic control") . 
" (" . $this->
getTitle(abs($this->dprofid)) . 
")", 
false, 
'latest', 
true));
 
 7603         if ($this->cvid == 0) {
 
 7604             $this->lay->eSet(
"cview", _(
"no view control"));
 
 7606             $this->lay->rSet(
"cview", $this->
getDocAnchor($this->cvid, 
'_blank', 
true, 
'', 
false, 
'latest', 
true));
 
 7608         if ($this->prelid == 0) {
 
 7609             $this->lay->eSet(
"prel", _(
"no folder"));
 
 7612             $this->lay->rSet(
"prel", $this->
getDocAnchor($this->prelid, 
'_blank', 
true, 
'', 
false, 
'latest', 
true));
 
 7615             foreach ($fldids as 
$fldid) {
 
 7616                 if ($fldid != $this->prelid) {
 
 7618                         "fld" => $this->
getDocAnchor($fldid, 
'_blank', 
true, 
'', 
false, 
'latest', 
true)
 
 7622             $this->lay->setBlockData(
"FOLDERS", $tfld);
 
 7624         if ($this->allocated == 0) {
 
 7625             $this->lay->eSet(
"allocate", _(
"no allocate"));
 
 7626             $this->lay->rSet(
"allocateid", 
false);
 
 7629             $this->lay->eSet(
"allocate", 
$user->firstname . 
" " . 
$user->lastname);
 
 7630             $this->lay->rSet(
"allocateid", 
$user->fid);
 
 7635         $this->lay->rSet(
"Timers", (count($tms) > 0));
 
 7648         $listattr = $this->GetAbstractAttributes();
 
 7650         $tableframe = array();
 
 7652         foreach ($listattr as $i => $attr) {
 
 7657             if (($attr->mvisibility != 
"H") && ($attr->mvisibility != 
"I")) {
 
 7659                 switch ($attr->type) {
 
 7661                         $iValue = $this->GetHtmlValue($listattr[$i], 
$value, $target, $ulink, -1, 
true, 
true);
 
 7662                         if ($iValue != 
"") {
 
 7664                                 $dValue = 
"<img align=\"absbottom\" height=\"30px\" src=\"" . $iValue . 
"&height=30\">";
 
 7666                                 $dValue = 
"<img align=\"absbottom\" height=\"30px\" src=\"" . $iValue . 
"\">";
 
 7672                         $dValue = $this->
getHtmlValue($listattr[$i], 
$value, $target, $ulink = 1, -1, 
true, 
true);
 
 7676                 if ($dValue !== 
'') {
 
 7677                     $tableframe[] = array(
 
 7678                         "name" => $attr->getLabel() ,
 
 7685         $this->lay->SetBlockData(
"TABLEVALUE", $tableframe);
 
 7695     final public function viewattr($target = 
"_self", $ulink = 
true, $abstract = 
false, $viewhidden = 
false)
 
 7697         $listattr = $this->GetNormalAttributes();
 
 7699         foreach ($listattr as $k => $v) {
 
 7703             $this->lay->Set(
"S_" . strtoupper($v->id) , (
$value != 
""));
 
 7705             if ((($v->mvisibility == 
"H") && (!$viewhidden)) || ($v->mvisibility == 
"I") || (($abstract) && (!$v->isInAbstract))) {
 
 7706                 $this->lay->Set(
"V_" . strtoupper($v->id) , 
"");
 
 7707                 $this->lay->Set(
"L_" . strtoupper($v->id) , 
"");
 
 7709                 if ($target == 
"ooo") {
 
 7710                     if ($v->type == 
"array") {
 
 7714                         foreach ($tva as $kindex => $kvalues) {
 
 7715                             foreach ($kvalues as $kaid => $va) {
 
 7720                                 if ($oa->getOption(
"multiple") == 
"yes") {
 
 7722                                     $oa->setOption(
"multiple", 
"no"); 
 
 7723                                     $values = explode(
"<BR>", $va);
 
 7725                                     foreach (
$values as $ka => $vaa) {
 
 7726                                         $ovalues[] = htmlspecialchars_decode($this->GetOOoValue($oa, $vaa) , ENT_QUOTES);
 
 7729                                     $tmkeys[$kindex][
"V_" . strtoupper($kaid) ] = $ovalues;
 
 7730                                     $oa->setOption(
"multiple", 
"yes"); 
 
 7733                                     $oooValue = $this->GetOOoValue($oa, $va);
 
 7734                                     if ($oa->type !== 
"htmltext") {
 
 7735                                         $oooValue = htmlspecialchars_decode($oooValue, ENT_QUOTES);
 
 7737                                     $tmkeys[$kindex][
"V_" . strtoupper($kaid) ] = $oooValue;
 
 7742                         $this->lay->setRepeatable($tmkeys);
 
 7744                         $ovalue = $this->GetOOoValue($v, 
$value);
 
 7745                         if ($v->isMultiple()) $ovalue = str_replace(
"<text:tab/>", 
', ', $ovalue);
 
 7746                         $this->lay->Set(
"V_" . strtoupper($v->id) , $ovalue);
 
 7748                         if ((!$v->inArray()) && ($v->getOption(
"multiple") == 
"yes")) {
 
 7751                             $v->setOption(
"multiple", 
"no");
 
 7752                             foreach (
$values as $ka => $va) {
 
 7753                                 $ovalues[] = htmlspecialchars_decode($this->GetOOoValue($v, $va) , ENT_QUOTES);
 
 7755                             $v->setOption(
"multiple", 
"yes");
 
 7757                             $this->lay->setColumn(
"V_" . strtoupper($v->id) , $ovalues);
 
 7763                 } 
else $this->lay->Set(
"V_" . strtoupper($v->id) , $this->GetHtmlValue($v, 
$value, $target, $ulink));
 
 7764                 $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
 
 7767         $listattr = $this->GetFieldAttributes();
 
 7769         foreach ($listattr as $k => $v) {
 
 7770             $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
 
 7781     final public function viewprop($target = 
"_self", $ulink = 
true,
 
 7785         foreach ($this->fields as $k => $v) {
 
 7786             if ($target == 
'ooo') $this->lay->Set(strtoupper($v) , ($this->$v === null) ? 
false : str_replace(array(
 
 7795             else $this->lay->Set(strtoupper($v) , ($this->$v === null) ? 
false : $this->$v);
 
 7797         if ($target == 
'ooo') $this->lay->Set(
"V_TITLE", $this->lay->get(
"TITLE"));
 
 7798         else $this->lay->Set(
"V_TITLE", $this->
getDocAnchor($this->
id, $target, $ulink, 
false, 
false));
 
 7833             return (sprintf(_(
"name must begin with a letter and contain only alphanumeric characters or - and _: invalid  [%s]") , 
$name));
 
 7839             return (sprintf(_(
"Logical name %s already set for %s. Use reset parameter to overhide it") , 
$name, $this->title));
 
 7843             if (
$d && 
$d[
"doctype"] != 
'Z') {
 
 7844                 return sprintf(_(
"Logical name %s already use in document %s") , 
$name, 
$d[
"title"]);
 
 7848                     simpleQuery($this->dbaccess, sprintf(
"UPDATE docname SET name = '%s' WHERE name = '%s'", pg_escape_string(
$name) , pg_escape_string($this->
name)));
 
 7852                 simpleQuery(
"", sprintf(
"update %s set name='%s' where initid=%d", pg_escape_string($this->dbtable) , pg_escape_string(
$name) , $this->initid));
 
 7853                 simpleQuery(
"", sprintf(
"select name from docname where id=%d", $this->
id) , $dbdocname, 
true, 
true);
 
 7856                     $sql = sprintf(
"delete from docname where name='%s';insert into docname (id,fromid,name) select id, fromid, name from docread where name='%s' and locked != -1", pg_escape_string(
$name) , pg_escape_string(
$name));
 
 7872     final public function viewoptcard($target = 
"_self", $ulink = 
true, $abstract = 
false)
 
 7875         $this->viewbodycard($target, $ulink, $abstract, 
true);
 
 7886     final public function editoptcard($target = 
"_self", $ulink = 
true, $abstract = 
false)
 
 7902     $target = 
"_self", $ulink = 
true, $abstract = 
false, $onlyopt = 
false)
 
 7904         include_once (
"FDL/editutil.php");
 
 7905         include_once (
"FDL/Class.SearchDoc.php");
 
 7912             if ($this->fromid > 0) {
 
 7914                 $this->lay->Set(
"title", sprintf(_(
"new %s") , $cdoc->getHtmlTitle()));
 
 7923             if (!$this->
isAlive()) $action->ExitError(_(
"document not referenced"));
 
 7924             $this->lay->Set(
"title", $this->getHtmlTitle());
 
 7926         $this->lay->Set(
"id", 
$docid);
 
 7927         $this->lay->Set(
"classid", $this->fromid);
 
 7934         $listattr = $this->GetInputAttributes($onlyopt);
 
 7938         $currentFrameId = 
"";
 
 7942         $currentFrame = null;
 
 7943         $changeframe = 
false;
 
 7946         $tableframe = array();
 
 7950         foreach ($listattr as $i => $attr) {
 
 7959             if (!$attr->fieldSet) {
 
 7960                 addWarningMsg(sprintf(_(
"unknow set for attribute %s %s") , $attr->id, $attr->getLabel()));
 
 7964             if ($currentFrameId != $attr->fieldSet->id) {
 
 7965                 if ($currentFrameId != 
"") $changeframe = 
true;
 
 7968                 $changeframe = 
false;
 
 7973                 if ($v > 0 || $frametpl) { 
 
 7974                     if ($oaf->getOption(
"vlabel") == 
"none") $currentFrameText = 
'';
 
 7975                     else $currentFrameText = 
mb_ucfirst($oaf->GetLabel());
 
 7977                     $frames[$k][
"frametext"] = $currentFrameText;
 
 7978                     $frames[$k][
"frameid"] = $oaf->id;
 
 7979                     $frames[$k][
"tag"] = 
"";
 
 7980                     $frames[$k][
"TAB"] = 
false;
 
 7981                     $frames[$k][
"edittpl"] = ($frametpl != 
"");
 
 7982                     $frames[$k][
"zonetpl"] = ($frametpl != 
"") ? sprintf(
"[ZONE FDL:EDITTPL?id=%d&famid=%d&zone=%s]", $this->
id, $this->fromid, $frametpl) : 
'';
 
 7984                     $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor", 
false) : 
false;
 
 7985                     $frames[$k][
"ehelp"] = ($help->isAlive()) ? $help->getAttributeHelpUrl($oaf->id) : 
false;
 
 7986                     $frames[$k][
"ehelpid"] = ($help->isAlive()) ? $help->id : 
false;
 
 7987                     if ($oaf && $oaf->fieldSet && ($oaf->fieldSet->id != 
"") && ($oaf->fieldSet->id != Adoc::HIDDENFIELD)) {
 
 7988                         $frames[$k][
"tag"] = 
"TAG" . $oaf->fieldSet->id;
 
 7989                         $frames[$k][
"TAB"] = 
true;
 
 7990                         $ttabs[$oaf->fieldSet->id] = array(
 
 7991                             "tabid" => $oaf->fieldSet->id,
 
 7992                             "tabtitle" => ($oaf->fieldSet->getOption(
"vlabel") == 
"none") ? 
' ' : 
mb_ucfirst($oaf->fieldSet->getLabel())
 
 7995                     $frames[$k][
"TABLEVALUE"] = 
"TABLEVALUE_$k";
 
 7996                     $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
 
 7998                     $tableframe = array();
 
 8004             $currentFrameId = $listattr[$i]->fieldSet->id;
 
 8005             $currentFrame = $attr->fieldSet;
 
 8007             if ($currentFrame->mvisibility == 
'R' || $currentFrame->mvisibility == 
'H' || $currentFrame->mvisibility == 
'I') {
 
 8010                 $frametpl = $currentFrame->getOption(
"edittemplate");
 
 8015                 if (($listattr[$i]->mvisibility == 
"H") || ($listattr[$i]->mvisibility == 
"R")) {
 
 8017                     if ($listattr[$i]->
type != 
"array") {
 
 8018                         $thidden[$ih][
"hname"] = 
"_" . $listattr[$i]->id;
 
 8019                         $thidden[$ih][
"hid"] = $listattr[$i]->id;
 
 8020                         if ((
$value == 
"") && ($this->
id == 0)) $thidden[$ih][
"hvalue"] = GetHttpVars($listattr[$i]->
id);
 
 8021                         else $thidden[$ih][
"hvalue"] = chop(htmlentities(
$value, ENT_COMPAT, 
"UTF-8"));
 
 8023                         $thidden[$ih][
"inputtype"] = 
getHtmlInput($this, $listattr[$i], 
$value, 
"", 
"", 
true);
 
 8027                     $tableframe[$v][
"value"] = chop(htmlentities(
$value, ENT_COMPAT, 
"UTF-8"));
 
 8028                     $label = $listattr[$i]->getLabel();
 
 8029                     $tableframe[$v][
"attrid"] = $listattr[$i]->id;
 
 8030                     $tableframe[$v][
"name"] = 
mb_ucfirst($label);
 
 8032                     if ($listattr[$i]->needed) $tableframe[$v][
"labelclass"] = 
"FREEDOMLabelNeeded";
 
 8033                     else $tableframe[$v][
"labelclass"] = 
"FREEDOMLabel";
 
 8034                     $tableframe[$v][
"aneeded"] = $listattr[$i]->needed;
 
 8035                     $elabel = $listattr[$i]->getoption(
"elabel");
 
 8036                     $elabel = str_replace(
"'", 
"’", $elabel);
 
 8037                     $tableframe[$v][
"elabel"] = 
mb_ucfirst(str_replace(
'"', 
"&rquot;", $elabel));
 
 8038                     $tableframe[$v][
"aehelp"] = ($help->isAlive()) ? $help->getAttributeHelpUrl($listattr[$i]->id) : 
false;
 
 8039                     $tableframe[$v][
"aehelpid"] = ($help->isAlive()) ? $help->id : 
false;
 
 8041                     $tableframe[$v][
"multiple"] = ($attr->getOption(
"multiple") == 
"yes") ? 
"true" : 
"false";
 
 8042                     $tableframe[$v][
"atype"] = $attr->type;
 
 8043                     $tableframe[$v][
"name"] = 
mb_ucfirst($label);
 
 8044                     $tableframe[$v][
"classback"] = ($attr->usefor == 
"O") ? 
"FREEDOMOpt" : 
"FREEDOMBack1";
 
 8046                     $tableframe[$v][
"SINGLEROW"] = 
true;
 
 8048                     $vlabel = $listattr[$i]->getOption(
"vlabel");
 
 8049                     if ((($listattr[$i]->
type == 
"array") && ($vlabel != 
'left')) || (($listattr[$i]->
type == 
"htmltext") && ($vlabel != 
'left')) || ($vlabel == 
'up') || ($vlabel == 
'none')) $tableframe[$v][
"SINGLEROW"] = 
false;
 
 8051                     $tableframe[$v][
"viewlabel"] = (($listattr[$i]->type != 
"array") && ($vlabel != 
'none'));
 
 8052                     $edittpl = $listattr[$i]->getOption(
"edittemplate");
 
 8054                         if ($edittpl == 
"none") {
 
 8055                             unset($tableframe[$v]);
 
 8058                                 $tableframe[$v][
"SINGLEROW"] = 
false;
 
 8059                                 $tableframe[$v][
"viewlabel"] = 
false;
 
 8061                             $tableframe[$v][
"inputtype"] = sprintf(
"[ZONE FDL:EDITTPL?id=%d&famid=%d&zone=%s]", $this->
id, $this->fromid, $edittpl);
 
 8071         if ($currentFrameId != 
'') {
 
 8073             if ($oaf->mvisibility == 
'R' || $oaf->mvisibility == 
'H' || $oaf->mvisibility == 
'I') {
 
 8076                 $frametpl = $oaf->getOption(
"edittemplate");
 
 8078             if ($v > 0 || $frametpl) { 
 
 8079                 if ($oaf->getOption(
"vlabel") == 
"none") $currentFrameText = 
'';
 
 8080                 else $currentFrameText = 
mb_ucfirst($oaf->GetLabel());
 
 8081                 $frames[$k][
"frametext"] = $currentFrameText;
 
 8082                 $frames[$k][
"frameid"] = $oaf->id;
 
 8083                 $frames[$k][
"TABLEVALUE"] = 
"TABLEVALUE_$k";
 
 8084                 $frames[$k][
"tag"] = 
"";
 
 8085                 $frames[$k][
"TAB"] = 
false;
 
 8086                 $frames[$k][
"edittpl"] = ($frametpl != 
"");
 
 8087                 $frames[$k][
"zonetpl"] = ($frametpl != 
"") ? sprintf(
"[ZONE FDL:EDITTPL?id=%d&famid=%d&zone=%s]", $this->
id, $this->fromid, $frametpl) : 
'';
 
 8088                 $frames[$k][
"ehelp"] = ($help->isAlive()) ? $help->getAttributeHelpUrl($oaf->id) : 
false;
 
 8089                 $frames[$k][
"ehelpid"] = ($help->isAlive()) ? $help->id : 
false;
 
 8091                 $oaf = $this->getAttribute($oaf->id);
 
 8092                 $frames[$k][
"bgcolor"] = $oaf ? $oaf->getOption(
"bgcolor", 
false) : 
false;
 
 8093                 if (($currentFrame->fieldSet->id != 
"") && ($currentFrame->fieldSet->id != Adoc::HIDDENFIELD)) {
 
 8094                     $frames[$k][
"tag"] = 
"TAG" . $currentFrame->fieldSet->id;
 
 8095                     $frames[$k][
"TAB"] = 
true;
 
 8096                     $ttabs[$currentFrame->fieldSet->id] = array(
 
 8097                         "tabid" => $currentFrame->fieldSet->id,
 
 8098                         "tabtitle" => ($currentFrame->fieldSet->getOption(
"vlabel") == 
"none") ? 
' ' : 
mb_ucfirst($currentFrame->fieldSet->getLabel())
 
 8101                 $this->lay->SetBlockData($frames[$k][
"TABLEVALUE"], $tableframe);
 
 8104         $this->lay->SetBlockData(
"HIDDENS", $thidden);
 
 8105         $this->lay->SetBlockData(
"TABLEBODY", $frames);
 
 8106         $this->lay->SetBlockData(
"TABS", $ttabs);
 
 8107         $this->lay->Set(
"ONETAB", count($ttabs) > 0);
 
 8108         $this->lay->Set(
"fromid", $this->fromid);
 
 8109         $this->lay->Set(
"docid", $this->
id);
 
 8110         if (count($ttabs) > 0) {
 
 8111             $this->lay->Set(
"firsttab", 
false);
 
 8112             $ut = $this->getUtag(
"lasttab");
 
 8113             if ($ut) $firstopen = $ut->comment; 
 
 8114             else $firstopen = 
false;
 
 8116             foreach ($ttabs as $k => $v) {
 
 8118                 if ($oa->getOption(
"firstopen") == 
"yes") $this->lay->Set(
"firsttab", $k);
 
 8119                 if ($firstopen == $oa->id) $this->lay->Set(
"firsttab", $k);
 
 8132         include_once (
"FDL/editutil.php");
 
 8133         $listattr = $this->GetNormalAttributes();
 
 8135         foreach ($listattr as $k => $v) {
 
 8139             if ($v->mvisibility == 
"R") $v->mvisibility = 
"H"; 
 
 8140             $this->lay->Set(
"V_" . strtoupper($v->id) , 
getHtmlInput($this, $v, 
$value, 
"", 
"", (!$withtd)));
 
 8141             if ($v->needed == 
"Y") $this->lay->Set(
"L_" . strtoupper($v->id) , 
"<B>" . $v->getLabel() . 
"</B>");
 
 8142             else $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
 
 8143             $this->lay->Set(
"W_" . strtoupper($v->id) , ($v->mvisibility != 
"H"));
 
 8146         $listattr = $this->GetFieldAttributes();
 
 8148         foreach ($listattr as $k => $v) {
 
 8149             $this->lay->Set(
"L_" . strtoupper($v->id) , $v->getLabel());
 
 8165         foreach ($tFamIdName as $k => $v) {
 
 8166             $this->lay->set(
"IDFAM_$k", $v);
 
 8178         if ($index == - 1) $fileid = $this->
getRawValue($attrid);
 
 8197             if (
$vf->Show($reg[2], 
$info) == 
"") {
 
 8199                 else $fname = 
$info->name;
 
 8230         foreach ($fileids as $k => $fileid) {
 
 8237                 if (
$vf->Show($reg[2], 
$info) == 
"") {
 
 8238                     $tinfo[$k] = get_object_vars(
$info);
 
 8239                     $tinfo[$k][
"vid"] = $reg[2];
 
 8253     final public function getFileInfo($filesvalue, $key = 
"", $returnType = 
"array")
 
 8255         if (!is_string($filesvalue)) 
return false;
 
 8257             include_once (
"FDL/Lib.Vault.php");
 
 8260             if (!
$info) 
return false;
 
 8263                 else return sprintf(_(
"unknow %s file property") , $key);
 
 8265                 if ($returnType === 
"array") {
 
 8266                     return get_object_vars(
$info);
 
 8272         return $key ? 
'' : array();
 
 8284     public function exportXml(&$xml, $withfile = 
false, 
$outfile = 
"", $wident = 
true, $flat = 
false, $exportAttributes = array())
 
 8288             $exd->setDocument($this);
 
 8289             $exd->setExportFiles($withfile);
 
 8290             $exd->setExportDocumentNumericIdentiers($wident);
 
 8291             $exd->setStructureAttributes(!$flat);
 
 8292             $exd->setIncludeSchemaReference(!$flat);
 
 8293             $exd->setAttributeToExport($exportAttributes);
 
 8298                 $xml = $exd->getXml();
 
 8301         catch(Dcp\Exception $e) {
 
 8303             return $e->getMessage();
 
 8316     final public function toxml($withdtd = 
false, $id_doc = 
"")
 
 8324         $docid = intval($this->
id);
 
 8325         if ($id_doc == 
"") {
 
 8330         $fam_doc = 
new_Doc($this->dbaccess, $this->fromid);
 
 8331         $name = str_replace(
" ", 
"_", $fam_doc->title);
 
 8333         if ($withdtd == 
true) {
 
 8334             $dtd = 
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>";
 
 8335             $dtd.= 
"<!DOCTYPE $name [";
 
 8337             $dtd.= $this->
todtd();
 
 8343         $this->lay = 
new Layout(
"FDL/Layout/viewxml.xml", $action);
 
 8344         $this->lay->Set(
"DTD", $dtd);
 
 8345         $this->lay->Set(
"NOM_FAM", 
$name);
 
 8346         $this->lay->Set(
"id_doc", $id_doc);
 
 8347         $this->lay->Set(
"TITRE", 
$title);
 
 8348         $this->lay->Set(
"ID_FAM", $fam_doc->name);
 
 8349         $this->lay->Set(
"revision", $this->
revision);
 
 8350         $this->lay->Set(
"revdate", $this->revdate);
 
 8356         $listattr = $this->GetNormalAttributes();
 
 8360         $nattr = count($listattr); 
 
 8363         $currentFrameId = 
"";
 
 8365         $changeframe = 
false; 
 
 8366         $tableframe = array();
 
 8370         foreach ($listattr as $i => $attr) {
 
 8373             if ((chop($listattr[$i]->
id) != 
"") && ($listattr[$i]->
id != Adoc::HIDDENFIELD)) {
 
 8376                 if ($currentFrameId != $listattr[$i]->fieldSet->id) {
 
 8377                     if ($currentFrameId != 
"") $changeframe = 
true;
 
 8383                     $changeframe = 
false;
 
 8387                         $frames[$k][
"FIELD"] = $currentFrameId;
 
 8388                         $frames[$k][
"ARGUMENT"] = 
"ARGUMENT_$k";
 
 8390                         $this->lay->SetBlockData($frames[$k][
"ARGUMENT"], $tableframe);
 
 8391                         $frames[$k][
"nom_fieldset"] = $this->GetLabel($currentFrameId);
 
 8393                         $tableframe = array();
 
 8399                 if (($iattr <= $nattr) && ($this->
getRawValue($i) != 
"")) {
 
 8400                     $attrtype_list = 
false;
 
 8402                     if (strstr($listattr[$i]->
type, 
"textlist") != 
false) {
 
 8403                         $attrtype_list = 
true;
 
 8405                     if ($listattr[$i]->inArray()) {
 
 8406                         $attrtype_list = 
true;
 
 8409                     if ($attrtype_list) {
 
 8414                         while ($text = each($textlist)) {
 
 8415                             $currentFrameId = $listattr[$i]->fieldSet->id;
 
 8416                             $tableframe[$v][
"id"] = $listattr[$i]->id;
 
 8417                             $tableframe[$v][
"value"] = $text[1];
 
 8418                             $tableframe[$v][
"type"] = base64_encode($listattr[$i]->
type);
 
 8419                             $tableframe[$v][
"labelText"] = (str_replace(array(
 
 8433                         $tableframe[$v][
"type"] = base64_encode($listattr[$i]->
type);
 
 8435                         $currentFrameId = $listattr[$i]->fieldSet->id;
 
 8436                         $tableframe[$v][
"id"] = $listattr[$i]->id;
 
 8437                         $tableframe[$v][
"value"] = 
$value;
 
 8438                         $tableframe[$v][
"labelText"] = addslashes($listattr[$i]->
getLabel());
 
 8451             $frames[$k][
"FIELD"] = $currentFrameId;
 
 8452             $frames[$k][
"ARGUMENT"] = 
"ARGUMENT_$k";
 
 8454             $this->lay->SetBlockData($frames[$k][
"ARGUMENT"], $tableframe);
 
 8455             $frames[$k][
"nom_fieldset"] = $this->GetLabel($currentFrameId);
 
 8459         $this->lay->SetBlockData(
"FIELDSET", $frames);
 
 8460         return $this->lay->gen();
 
 8470         $this->lay = 
new Layout(
"FDL/Layout/viewdtd.xml", $action);
 
 8473         $name = str_replace(
" ", 
"_", $fam_doc->title);
 
 8474         $this->lay->Set(
"doctype", $this->doctype);
 
 8475         $this->lay->Set(
"idfam", $this->fromid);
 
 8476         $this->lay->Set(
"nom_fam", 
$name);
 
 8477         $this->lay->Set(
"id_fam", 
$name);
 
 8479         $listattr = $this->GetNormalAttributes();
 
 8481         $frames = $elements = array();
 
 8483         $nattr = count($listattr); 
 
 8486         $currentFrameId = 
"";
 
 8488         $changeframe = 
false; 
 
 8490         $tableattrs = array();
 
 8491         $tablesetting = array();
 
 8494         foreach ($listattr as $i => $attr) {
 
 8498             if ($currentFrameId != $listattr[$i]->fieldSet->id) {
 
 8499                 if ($currentFrameId != 
"") $changeframe = 
true;
 
 8505                 $changeframe = 
false;
 
 8510                     $frames[$k][
"name"] = $currentFrameId;
 
 8511                     $elements[$k][
"name"] = $currentFrameId;
 
 8513                         $elements[$k][
"name"].= 
", ";
 
 8515                         $elements[$k][
"name"].= 
"?, ";
 
 8519                     $frames[$k][
"ATTRIBUT_NAME"] = 
"ATTRIBUT_NAME_$k";
 
 8520                     $frames[$k][
"ATTRIBUT_SETTING"] = 
"ATTRIBUT_SETTING_$k";
 
 8522                     $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_NAME"], $tableattrs);
 
 8524                     $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_SETTING"], $tablesetting);
 
 8526                     unset($tablesetting);
 
 8527                     $tableattrs = array();
 
 8528                     $tablesetting = array();
 
 8535             if ($iattr <= $nattr) {
 
 8537                 $currentFrameId = $listattr[$i]->fieldSet->id;
 
 8538                 $tablesetting[$v][
"name_attribut"] = $listattr[$i]->id;
 
 8539                 $tablesetting[$v][
"labelText"] = addslashes(str_replace(
"%", 
"", $listattr[$i]->
getLabel()));
 
 8540                 $tablesetting[$v][
"type"] = base64_encode($listattr[$i]->
type);
 
 8541                 $tablesetting[$v][
"visibility"] = $listattr[$i]->visibility;
 
 8542                 if ($listattr[$i]->needed) {
 
 8547                     $insert = $listattr[$i]->id;
 
 8548                     if ($listattr[$i]->
type == 
"textlist") {
 
 8549                         if ($listattr[$i]->needed) {
 
 8551                             $tableattrs[$v][
"name_attribut"] = $insert;
 
 8554                             $tableattrs[$v][
"name_attribut"] = $insert;
 
 8557                         if ($listattr[$i]->needed) {
 
 8558                             $tableattrs[$v][
"name_attribut"] = $insert;
 
 8560                             $tableattrs[$v][
"name_attribut"] = ($insert . 
"?");
 
 8564                     $insert = (
", " . $listattr[$i]->id);
 
 8565                     if ($listattr[$i]->
type == 
"textlist") {
 
 8566                         if ($listattr[$i]->needed) {
 
 8571                         $tableattrs[$v][
"name_attribut"] = $insert;
 
 8573                         if ($listattr[$i]->needed) {
 
 8574                             $tableattrs[$v][
"name_attribut"] = $insert;
 
 8576                             $tableattrs[$v][
"name_attribut"] = ($insert . 
"?");
 
 8586             $frames[$k][
"name"] = $currentFrameId;
 
 8588                 $elements[$k][
"name"] = $currentFrameId;
 
 8590                 $elements[$k][
"name"] = ($currentFrameId . 
"?");
 
 8592             $frames[$k][
"ATTRIBUT_NAME"] = 
"ATTRIBUT_NAME_$k";
 
 8593             $frames[$k][
"ATTRIBUT_SETTING"] = 
"ATTRIBUT_SETTING_$k";
 
 8594             $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_NAME"], $tableattrs);
 
 8596             $this->lay->SetBlockData($frames[$k][
"ATTRIBUT_SETTING"], $tablesetting);
 
 8598             unset($tablesetting);
 
 8601         $this->lay->SetBlockData(
"FIELDSET", $frames);
 
 8602         $this->lay->SetBlockData(
"ELEMENT", $elements);
 
 8603         return $this->lay->gen();
 
 8632         $this->AddParamRefresh(
"$nameId", 
"$nameTitle");
 
 8651         if ($this->confidential > 0) 
return $action->parent->getImageLink(
"confidential.gif", 
true, 
$size);
 
 8652         else if ($this->locked == - 1) 
return $action->parent->getImageLink(
"revised.png", 
true, 
$size);
 
 8653         else if ($this->lockdomainid > 0) {
 
 8654             if ($this->locked > 0) {
 
 8655                 if ((abs($this->locked) == $this->userid)) 
return $action->parent->getImageLink(
"lockorange.png", 
true, 
$size);
 
 8656                 else return $action->parent->getImageLink(
"lockred.png", 
true, 
$size);
 
 8657             } 
else return $action->parent->getImageLink(
"lockorange.png", 
true, 
$size);
 
 8658         } 
else if ($this->allocated == $this->userid) 
return $action->parent->getImageLink(
"lockblue.png", 
true, 
$size);
 
 8659         else if ((abs($this->locked) == $this->userid)) 
return $action->parent->getImageLink(
"lockgreen.png", 
true, 
$size);
 
 8660         else if ($this->locked != 0) 
return $action->parent->getImageLink(
"lockred.png", 
true, 
$size);
 
 8661         else if ($this->archiveid != 0) 
return $action->parent->getImageLink(
"archive.png", 
true, 
$size);
 
 8662         else if ($this->
control(
"edit") != 
"") 
return $action->parent->getImageLink(
"nowrite.png", 
true, 
$size);
 
 8663         else return $action->parent->getImageLink(
"1x1.gif");
 
 8674     $a = 
"", $b = 
"", 
$c = 
"")
 
 8717         if (is_array(
$id)) 
return $def;
 
 8718         if (
$id == 
"") 
return $def;
 
 8720             if ($this->locked != - 1 || (!
$latest)) {
 
 8728         if ((strpos(
$id, 
"\n") !== 
false) || (strpos(
$id, 
"<BR>") !== 
false)) {
 
 8729             $tid = explode(
"\n", str_replace(
"<BR>", 
"\n", 
$id));
 
 8731             foreach (
$tid as $idone) {
 
 8734             return implode(
"\n", $ttitle);
 
 8767         $s = htmlspecialchars(
$s, ENT_QUOTES);
 
 8768         return str_replace(
"[", 
"[", 
$s);
 
 8783     public static function getDate($daydelta = 0, $dayhour = 
"", $daymin = 
"", $getlocale = 
false)
 
 8785         $delta = abs(intval($daydelta));
 
 8786         if ($daydelta > 0) {
 
 8787             $nd = strtotime(
"+$delta day");
 
 8788         } 
else if ($daydelta < 0) {
 
 8789             $nd = strtotime(
"-$delta day");
 
 8793         if ($dayhour !== 
"" || $daymin !== 
"") {
 
 8794             $delta = abs(intval($dayhour));
 
 8796                 $nd = strtotime(
"+$delta hour", 
$nd);
 
 8797             } 
else if ($dayhour < 0) {
 
 8798                 $nd = strtotime(
"-$delta hour", 
$nd);
 
 8800             $delta = abs(intval($daymin));
 
 8802                 $nd = strtotime(
"+$delta min", 
$nd);
 
 8803             } 
else if ($daymin < 0) {
 
 8804                 $nd = strtotime(
"-$delta min", 
$nd);
 
 8810                 return date(
"Y-m-d H:i", 
$nd);
 
 8816                 return date(
"Y-m-d", 
$nd);
 
 8828         $delta = abs(intval($hourdelta));
 
 8829         if ($second) $format = 
"Y-m-d H:i:s";
 
 8830         else $format = 
"Y-m-d H:i";
 
 8831         if ($hourdelta > 0) {
 
 8832             if (is_float($hourdelta)) {
 
 8833                 $dm = intval((abs($hourdelta) - $delta) * 60);
 
 8834                 return date($format, strtotime(
"+$delta hour $dm minute"));
 
 8835             } 
else return date($format, strtotime(
"+$delta hour"));
 
 8836         } 
else if ($hourdelta < 0) {
 
 8837             if (is_float($hourdelta)) {
 
 8838                 $dm = intval((abs($hourdelta) - $delta) * 60);
 
 8839                 return date($format, strtotime(
"-$delta hour $dm minute"));
 
 8840             } 
else return date($format, strtotime(
"-$delta hour"));
 
 8842         return date($format);
 
 8875         if (intval(
$docid) > 0) {
 
 8876             if (strpos(
':', $attrid) === 
false) {
 
 8877                 $attrid = strtolower($attrid);
 
 8885                     if ($rawDoc[
"locked"] == - 1) {
 
 8897                     return $rawDoc[$attrid];
 
 8901                 if (
$doc->isAlive()) {
 
 8903                         $ldocid = 
$doc->getLatestId();
 
 8922         if (intval(
$docid) > 0) {
 
 8925             return $tdoc[strtolower($propid) ];
 
 8937         if ($withfirst) 
return $action->user->firstname . 
" " . $action->user->lastname;
 
 8938         return $action->user->lastname;
 
 8948             return $action->user->fid;
 
 8973         return self::getSystemUserId();
 
 8984         return $action->user->id;
 
 8996         return $mydoc->getRawValue($idattr);
 
 9006         $nargs = func_num_args();
 
 9008         if ($nargs < 1) 
return "";
 
 9009         $fmt = func_get_arg(0);
 
 9011         for ($ip = 1; $ip < $nargs; $ip++) {
 
 9012             $vip = func_get_arg($ip);
 
 9013             if (gettype($vip) != 
"array") {
 
 9017         $r = vsprintf($fmt, $sp);
 
 9026         if (empty($this->
id)) 
return;
 
 9029         $point = uniqid(
"dcp:updateVaultIndex");
 
 9031         $this->
lockPoint($this->initid, 
"UPVI");
 
 9033         $dvi->DeleteDoc($this->
id);
 
 9038         foreach ($tvid as $vid) {
 
 9041                 $dvi->vaultid = $vid;
 
 9043                 $vids[] = intval($vid);
 
 9047         if (count($vids) > 0) {
 
 9062     final public function attachTimer(&$timer, $origin = null, $execdate = null)
 
 9065         if ($execdate == null) {
 
 9066             $dyn = trim(strtok($timer->getRawValue(
"tm_dyndate") , 
" "));
 
 9069                 if (empty($execdate)) {
 
 9074         if (method_exists($timer, 
'attachDocument')) {
 
 9075             $err = $timer->attachDocument($this, $origin, $execdate);
 
 9077                 if ($dyn) $this->
addATag(
"DYNTIMER");
 
 9079                 $this->
addLog(
"attachtimer", array(
 
 9080                     "timer" => $timer->id
 
 9084             $err = sprintf(_(
"attachTimer : the timer parameter is not a document of TIMER family"));
 
 9096         if (method_exists($timer, 
'unattachDocument')) {
 
 9097             $err = $timer->unattachDocument($this);
 
 9100                 $this->
addLog(
"unattachtimer", array(
 
 9101                     "timer" => $timer->id
 
 9104         } 
else $err = sprintf(_(
"unattachTimer : the timer parameter is not a document of TIMER family"));
 
 9110     final public function resetDynamicTimers()
 
 9113         if (count($tms) == 0) {
 
 9116             foreach ($tms as $k => $v) {
 
 9120                 $t = new_doc($this->dbaccess, $v[
"timerid"]);
 
 9121                 if ($t->isAlive()) {
 
 9122                     $dynDateAttr = trim(strtok($t->getRawValue(
"tm_dyndate") , 
" "));
 
 9127                         if ($previousExecdate !== 
false && ($execdate != $previousExecdate)) {
 
 9128                             if ($v[
"originid"]) $ori = new_doc($this->dbaccess, $v[
"originid"]);
 
 9146     final public function unattachAllTimers($origin = null)
 
 9153         $err = $timer->unattachAllDocument($this, $origin, 
$c);
 
 9154         if (
$err == 
"" && 
$c > 0) {
 
 9157             $this->
addLog(
"unattachtimer", array(
 
 9171         include_once (
"Class.QueryDb.php");
 
 9172         include_once (
"Class.DocTimer.php");
 
 9173         $q = 
new QueryDb($this->dbaccess, 
"doctimer");
 
 9174         $q->AddQuery(
"docid=" . $this->initid);
 
 9175         $q->AddQuery(
"donedate is null");
 
 9176         $l = 
$q->Query(0, 0, 
"TABLE");
 
 9178         if (is_array($l)) 
return $l;
 
 9189         if (file_exists(
"OFFLINE/Class.DomainManager.php")) {
 
 9190             include_once (
"FDL/Class.SearchDoc.php");
 
 9191             $s = 
new searchDoc($this->dbaccess, 
"OFFLINEFOLDER");
 
 9192             $s->join(
"id = fld(dirid)");
 
 9193             $s->addFilter(
"fld.childid = %d", $this->initid);
 
 9195             if (
$user) 
$s->addFilter(
"off_user = '%d' or off_user is null", $uid);
 
 9196             $s->overrideViewControl();
 
 9199             foreach ($t as $v) {
 
 9200                 $ids[] = $v[
'off_domain'];
 
 9201                 if ($folderName && ((!
$user) || ($v[
'off_user'] == $uid))) {
 
 9202                     $ids[] = $v[
"name"];
 
 9205             return array_unique($ids);
 
 9219         if ($domainId != 
'') {
 
 9223             if ($this->lockdomainid != $domainId) {
 
 9227                 $this->
addUTag(1, 
'LOCKTODOMAIN_LOCKED', $this->locked);
 
 9237             $tag = $this->
getUTag(
'LOCKTODOMAIN_LOCKED', 
true, 1);
 
 9238             if ($tag !== 
false) {
 
 9239                 $this->
delUTag(1, 
'LOCKTODOMAIN_LOCKED');
 
 9240                 $this->locked = $tag->comment;
 
 9252         $this->lockdomainid = $domainId;
 
 9265         simpleQuery($this->dbaccess, sprintf(
"select dirid from fld where qtype='S' and childid=%d", $this->initid) , $fldids, 
true, 
false);
 
 9276         if ($this->lockdomainid) {
 
 9277             if (!in_array($this->lockdomainid, $domains)) $this->lockdomainid = 
'';
 
 9279                 if ($this->locked > 0) {
 
 9280                     simpleQuery($this->dbaccess, sprintf(
"select id from users where id=%d", $this->locked) , $lockUserId, 
true, 
true);
 
 9282                     if ($lockUserId && (!$this->
isInDomain(
true, $lockUserId))) {
 
 9283                         $this->lockdomainid = 
'';
 
 9289         $this->
modify(
true, array(
 
 9304             if (!$userId) $userId = $action->user->id;
 
 9305             if (preg_match(
'/_' . $userId . 
'$/m', $this->domainid)) 
return true;
 
 9308             return (!empty($this->domainid));
 
 9335         $split = preg_split(
'/\?/', $zone, 2);
 
 9337         if (count($split) > 1) $right = $split[1];
 
 9340         $el = preg_split(
'/:/', $left);
 
 9341         if (count($el) < 2) {
 
 9344         $p[
'fulllayout'] = $left;
 
 9348             $p[
'args'] = $right;
 
 9349             $argList = preg_split(
'/&/', $p[
'args']);
 
 9350             $p[
'argv'] = array();
 
 9351             foreach ($argList as 
$arg) {
 
 9352                 $split = preg_split(
'/=/', $arg, 2);
 
 9353                 $left = urldecode($split[0]);
 
 9354                 $right = urldecode($split[1]);
 
 9355                 $p[
'argv'][$left] = $right;
 
 9365         foreach ($parts as $aPart) $p[$aPart] = null;
 
 9368         while ($i < count($el)) {
 
 9369             if (!array_key_exists($i, $parts)) {
 
 9370                 error_log(__CLASS__ . 
"::" . __FUNCTION__ . 
" " . sprintf(
"Unexpected part '%s' in zone '%s'.", $el[$i], $zone));
 
 9374             if ($i == 1 && preg_match(
"/^(?P<name>.*?)\[(?P<index>-?\d)\]$/", $el[$i], $match)) {
 
 9375                 $p[$parts[$i]] = $match[
'name'];
 
 9376                 $p[
'index'] = $match[
'index'];
 
 9381             $p[$parts[$i]] = $el[$i];
 
 9398         $s->addFilter(
"help_family='%d'", 
$fromid);
 
 9399         $help = 
$s->search();
 
 9401         if (
$s->count() > 0) {
 
 9402             $helpId = $help[0][
"id"];
 
 9405         return new_Doc($this->dbaccess, $helpId);
 
 9415     $attrId, $attrType = 
'')
 
 9417         include_once (
'FDL/Lib.Attr.php');
 
 9424         if ($pType[
'type'] != 
'docid') {
 
 9425             $attrType = $pType[
'type'];
 
 9428         $collator = 
new Collator($action->GetParam(
'CORE_LANG', 
'fr_FR'));
 
 9430         $compatibleMethods = array();
 
 9432         if ($attrType == 
'date' || $attrType == 
'timestamp') {
 
 9433             $compatibleMethods = array_merge($compatibleMethods, array(
 
 9435                     'label' => _(
"yesterday") ,
 
 9436                     'method' => 
'::getDate(-1)' 
 9439                     'label' => _(
"tomorrow") ,
 
 9440                     'method' => 
'::getDate(1)' 
 9446             $rc = 
new ReflectionClass(get_class($this));
 
 9448         catch(Exception $e) {
 
 9449             return $compatibleMethods;
 
 9452         $methods = array_filter($rc->getMethods() , 
function ($aMethod)
 
 9457             $methodName = $aMethod->getName();
 
 9458             return ($aMethod->isPublic() && $methodName != 
'__construct');
 
 9463         foreach ($methods as 
$method) {
 
 9464             $tags = self::getDocCommentTags($method->getDocComment());
 
 9466             $searchLabel = null;
 
 9467             $searchTypes = array();
 
 9469             foreach ($tags as $tag) {
 
 9470                 if ($tag[
'name'] == 
'searchLabel') {
 
 9471                     $searchLabel = $tag[
'value'];
 
 9472                 } elseif ($tag[
'name'] == 
'searchType') {
 
 9473                     $searchTypes[] = $tag[
'value'];
 
 9477             if ($searchLabel === null) {
 
 9481             if ($attrType == 
'' || in_array($attrType, $searchTypes)) {
 
 9482                 $compatibleMethods[] = array(
 
 9483                     'label' => _($searchLabel) ,
 
 9484                     'method' => sprintf(
'::%s()', $method->getName())
 
 9489         usort($compatibleMethods, 
function ($a, $b) use ($collator)
 
 9494             return $collator->compare($a[
'label'], $b[
'label']);
 
 9497         return $compatibleMethods;
 
 9513             $method = $rc->getMethod($methodName);
 
 9514             $tags = self::getDocCommentTags(
$method->getDocComment());
 
 9516             foreach ($tags as $tag) {
 
 9517                 if ($tag[
'name'] == 
'searchLabel') {
 
 9522         catch(Exception $e) {
 
 9533     final private static function getDocCommentTags($docComment = 
'')
 
 9535         if (!preg_match_all(
'/^.*?@(?P<name>[a-zA-Z0-9_-]+)\s+(?P<value>.*?)\s*$/m', $docComment, $tags, PREG_SET_ORDER)) {
 
 9538         $tags = array_map(
function ($tag)
 
 9541                 'name' => $tag[
'name'],
 
 9542                 'value' => $tag[
'value']
 
 9562         if (!is_numeric($avalue)) {
 
 9563             if ((!strstr($avalue, 
"<BR>")) && (!strstr($avalue, 
"\n"))) {
 
 9564                 if ($oattr->
getOption(
"docrev", 
"latest") == 
"latest") {
 
 9569                 if (
$res == 
'' && !in_array($avalue, $knownLogicalNames)) {
 
 9570                     $unknownLogicalNames[] = $avalue;
 
 9573                 $tnames = explode(
"\n", $avalue);
 
 9576                 foreach ($tnames as $lname) {
 
 9577                     $mids = explode(
"<BR>", $lname);
 
 9579                     foreach ($mids as $llname) {
 
 9580                         if (!is_numeric($llname)) {
 
 9581                             if ($oattr->
getOption(
"docrev", 
"latest") == 
"latest") {
 
 9586                             if ($llid == 
'' && !in_array($llname, $knownLogicalNames)) {
 
 9587                                 $unknownLogicalNames[] = $llname;
 
 9589                             $tlids[] = $llid ? $llid : $llname;
 
 9594                     $tids[] = implode(
'<BR>', $tlids);
 
 9597                 $res = implode(
"\n", $tids);
 
 9612     protected function getExtraSearchableDisplayValues($withLocale = 
true)
 
 9615         $moreSearchValues = [];
 
 9617         $fmt = new \FormatCollection($this);
 
 9620         $oneAttributeAtLeast = 
false;
 
 9622             if ($attr->type !== 
"array" && $attr->getOption(
"searchcriteria") !== 
"hidden" && $this->
getRawValue($attr->id)) {
 
 9623                 $fmt->addAttribute($attr->id);
 
 9624                 $oneAttributeAtLeast = 
true;
 
 9625                 if ($attr->type === 
"date") {
 
 9626                     if ($attr->isMultiple()) {
 
 9635         if ($oneAttributeAtLeast) {
 
 9636             $datesValues = array_unique($datesValues);
 
 9638                 $currentLocale = 
getParam(
"CORE_LANG", 
"fr_FR");
 
 9640                 $locales = array_keys(
$lang);
 
 9642                 unset($locales[$currentLocale]);
 
 9643                 $locales[] = $currentLocale;
 
 9649             foreach ($locales as $klang) {
 
 9653                 $moreSearchValues[] = $this->
getTitle();
 
 9654                 $r = $fmt->render();
 
 9656                 foreach ($datesValues as $date) {
 
 9657                     $moreSearchValues[] = strftime(
"%A %B %Y %m %d", strtotime($date));
 
 9662                 foreach (
$r[0][
"attributes"] as $renderInfo) {
 
 9663                     if (isset($renderInfo->value) && $renderInfo->displayValue !== $renderInfo->value) {
 
 9664                         $moreSearchValues[] = $renderInfo->displayValue;
 
 9665                     } elseif ($renderInfo && is_array($renderInfo)) {
 
 9666                         foreach ($renderInfo as $rowInfo) {
 
 9667                             if (isset($rowInfo->value) && $rowInfo->displayValue !== $rowInfo->value) {
 
 9668                                 $moreSearchValues[] = $rowInfo->displayValue;
 
 9669                             } elseif ($rowInfo && is_array($rowInfo)) {
 
 9670                                 foreach ($rowInfo as $subRowInfo) {
 
 9671                                     if (isset($subRowInfo->value) && $subRowInfo->displayValue !== $subRowInfo->value) {
 
 9672                                         $moreSearchValues[] = $subRowInfo->displayValue;
 
 9684             if (!is_array($custom)) {
 
 9685                 throw new \Dcp\Exception(
"DOC0126", gettype($custom));
 
 9687             $moreSearchValues = array_merge($moreSearchValues, $custom);
 
 9689         return implode(
"£", array_unique($moreSearchValues));
 
Layout is a template generator. 
 
vault_properties(NormalAttribute $attr)
 
clearArrayValues($idAttr)
 
getHtmlAttrValue($attrid, $target="_self", $htmllink=2, $index=-1, $entities=true, $abstract=false)
 
getOooAttrValue($attrid, $target="_self", $htmllink=false, $index=-1)
 
copy($temporary=false, $control=true, $linkfld=false, $copyfile=false)
 
getNormalAttributes($onlyopt=false)
 
if(substr($wsh, 0, 1)!= '/') $args
 
unallocate($comment="", $revision=true)
 
getTextualAttrValue($attrId, $index=-1, Array $configuration=array())
 
setState($newstate, $comment= '', $force=false, $withcontrol=true, $wm1=true, $wm2=true, $wneed=true, $wm0=true, $wm3=true, &$msg= '')
 
setDefaultValues($tdefval, $method=true, $forcedefault=false)
 
sep_replace($ak, $idx, $by="-", $sep="\n")
 
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
 
hasUTag($tag, $allrevision=true)
 
getLastTitle($id="-1", $def="")
 
newFreeVaultFile($dbaccess)
 
fixMultipleAliveDocument(Doc &$doc)
 
& getAttribute($idAttr, &$oa=null, $useMask=true)
 
static set($key, &$item, $force=false)
 
latestId($fixed=false, $forcequery=false)
 
addUTag($uid, $tag, $datas="", $allrevision=true)
 
static getDate($daydelta=0, $dayhour="", $daymin="", $getlocale=false)
 
verifyAllConstraints($stoptofirst=true, &$info=array())
 
addLog($code= '', $arg= '', $comment= '', $level= '', $uid= '')
 
duplicate($temporary=false, $control=true, $linkfld=false, $copyfile=false)
 
getNeededAttributes($parameters=false)
 
stringDateToIso($date, $format=false, $withT=false)
 
getFileAttributes($onlyfile=false)
 
vault_filename($attrid, $path=false, $index=-1)
 
preAffect(array &$data, &$more, &$reset)
 
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
 
exec_query($sql, $lvl=0, $prepare=false)
 
completeArrayRow($idAttr, $deleteLastEmptyRows=true)
 
print $fam getTitle() $fam name
 
static rawValueToArray($v)
 
getLatestId($fixed=false, $forcequery=false)
 
Add($nopost=false, $nopre=false)
 
Exception class use exceptionCode to identifiy correctly exception. 
 
stringDateToLocaleDate($fdate, $format= '')
 
getDocProp($docid, $propid, $latest=false)
 
setLogicalIdentificator($name, $reset=false)
 
getParamValue($idp, $def="")
 
setFile($attrid, $filename, $ftitle="", $index=-1)
 
viewoptcard($target="_self", $ulink=true, $abstract=false)
 
getAValues($idAttr, $index=-1)
 
refreshDocTitle($nameId, $nameTitle)
 
canEdit($verifyDomain=true)
 
unLock($auto=false, $force=false)
 
vaultRegisterFile($filename, $ftitle="", &$info=null)
 
getIcon($idicon="", $size=null, $otherId=null)
 
getOooValue($oattr, $value, $target="_self", $htmllink=false, $index=-1)
 
lockToDomain($domainId, $userid=0)
 
specRefreshGenAttribute($attrId, $callMethod)
 
static getUserName($withfirst=false)
 
addRevision($comment= '')
 
controlTdoc(&$tdoc, $aclname)
 
storeFile($attrid, $filename, $ftitle="", $index=-1)
 
getSearchMethods($attrId, $attrType= '')
 
nothing($a="", $b="", $c="")
 
getDocWithSameTitle($key1="title", $key2="")
 
viewattr($target="_self", $ulink=true, $abstract=false, $viewhidden=false)
 
getArrayRawValues($idAttr, $index=-1)
 
static seemsMethod($method)
 
allocate($userid, $comment="", $revision=false, $autolock=true)
 
urlWhatEncode($link, $k=-1)
 
viewdefaultcard($target="_self", $ulink=true, $abstract=false, $viewhidden=false)
 
static getError($code, $args=null)
 
getParameterFamilyRawValue($idp, $def)
 
getLocaleConfig($core_lang= '')
 
searchUTags($tag="", $allrevision=true, $allusers=false)
 
isInDomain($user=true, $userId= '')
 
getRevisionState($state, $fixed=false)
 
removeArrayRow($idAttr, $index)
 
getRValue($RidAttr, $def="", $latest=true, $html=false)
 
getDomainIds($user=true, $folderName=false)
 
setLogicalName($name, $reset=false, $verifyOnly=false)
 
getFamilyParameterValue($idp, $def="")
 
setWaskAnswer($waskid, $answer)
 
hasPermission($aclName, $strict=false)
 
getLatestTDoc($dbaccess, $initid, $sqlfilters=array(), $fromid=false)
 
viewproperties($target="finfo", $ulink=true, $abstract=true)
 
static setTypedValue(\Doc &$doc,\NormalAttribute &$oAttr, $value)
 
viewprop($target="_self", $ulink=true, $abstract=false)
 
getHisto($allrev=false, $code="", $limit=0)
 
save(&$info=null, $skipConstraint=false)
 
addParamRefresh($in, $out)
 
modify($nopost=false, $sfields="", $nopre=false)
 
sendTextTransformation($dbaccess, $docid, $attrid, $index, $vid)
 
getFreedomFromTitle($title)
 
storeFiles($attrid, $filenames, $ftitle="")
 
getDocValue($docid, $attrid, $def=" ", $latest=false)
 
updateRelations($force=false)
 
applyMethod($method, $def="", $index=-1, array $bargs=array(), array $mapArgs=array(), &$err= '')
 
convertVaultFile($va, $engine, $isimage=false)
 
static _cmpanswers($a, $b)
 
addArrayRow($idAttr, $tv, $index=-1)
 
getFileExtension($filename)
 
isValidSearchMethod($className, $methodName)
 
getValue($idAttr, $def="")
 
getLayoutFile($app, $layfile)
 
lockPoint($exclusiveLock, $exclusiveLockPrefix= '')
 
affect($array, $more=false, $reset=true)
 
recomputeTextFiles($aid= '')
 
postImport(array $extra=array())
 
changeFreeState($newstateid, $comment= '', $revision=true)
 
getHtmlInput(&$doc, &$oattr, $value, $index="", $jsevent="", $notd=false)
 
editbodycard($target="_self", $ulink=true, $abstract=false, $onlyopt=false)
 
regenerateTemplate($aid, $index=-1)
 
getDocTitle($id, $latest=true)
 
controlId($docid, $aclname, $strict=false)
 
setValue($attrid, $value, $index=-1, &$kvalue=null)
 
viewthumbcard($target="finfo", $ulink=true, $abstract=true)
 
setProfil($profid, $fromdocidvalues=null)
 
isFixedDoc($dbaccess, $id)
 
setAttributeValue($idAttr, $value)
 
static getFileInfo($idfile, $teng_name="")
 
getMultipleRawValues($idAttr, $def="", $index=-1)
 
postAffect(array $data, $more, $reset)
 
getTValue($idAttr, $def="", $index=-1)
 
UpdateVaultIndex($i, &$doc, &$dvi)
 
sqlTrigger($onlydrop=false, $code=false)
 
revision(Action &$action)
 
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
 
getHttpVars($name, $def="", $scope="all")
 
getTextValueFromFile($attrid, &$text)
 
getParam($param, $defv="")
 
if($updateExistingTable) $point
 
getHTMLTitle($id="-1", $def="", $latest=false)
 
getFileLink($attrid, $index=-1, $cache=false, $inline=false, $otherValue= '', $info=null)
 
attachTimer(&$timer, $origin=null, $execdate=null)
 
toxml($withdtd=false, $id_doc="")
 
getFamIdFromName($dbaccess, $name)
 
getTitle($id="-1", $def="", $latest=false)
 
getHtmlValue($oattr, $value, $target="_self", $htmllink=true, $index=-1, $entities=true, $abstract=false)
 
getInputAttributes($onlyopt=false)
 
getFileInfo($filesvalue, $key="", $returnType="array")
 
getUTag($tag, $allrevision=true, $uid=null)
 
getRevisions($type="LIST", $limit=200)
 
copyFile($idattr, $newname="", $index=-1)
 
vault_generate($dbaccess, $engine, $vidin, $vidout, $isimage=false, $docid= '')
 
getChildFam($id=-1, $controlcreate=false)
 
deprecatedFunction($msg= '')
 
translate($docid, $translate)
 
convert($fromid, $prevalues=array())
 
getMenuAttributes($viewhidden=false)
 
viewabstractcard($target="finfo", $ulink=true, $abstract=false)
 
setNameAuto($temporary=false)
 
new_Doc($dbaccess, $id= '', $latest=false)
 
viewDoc($layout="FDL:VIEWBODYCARD", $target="_self", $ulink=true, $abstract=false, $changelayout=false)
 
getFamilyParameter(&$action, $famid, $key, $def="")
 
vault_store($filename, &$vid, $ftitle="")
 
postDuplicate(&$copyfrom)
 
getNameFromId($dbaccess, $id)
 
resolveDocIdLogicalNames(NormalAttribute &$oattr, $avalue, &$unknownLogicalNames=array(), &$knownLogicalNames=array())
 
preImport(array $extra=array())
 
addComment($comment= '', $level=DocHisto::INFO, $code= '', $uid= '')
 
& getAttributes($useMask=true)
 
setTextValueInFile($attrid, $value, $ftitle="")
 
controlUser($uid, $aclname)
 
getExportAttributes($withfile=false, $forcedefault=false)
 
ComputeVisibility($vis, $fvis, $ffvis= '')
 
specRefreshGen($onlyspec=false)
 
static isWellformedLogicalName($name)
 
static getTimeDate($hourdelta=0, $second=false)
 
static getTypedValue(\Doc &$doc,\NormalAttribute &$oAttr)
 
resetConvertVaultFile($attrid, $index)
 
exportXml(&$xml, $withfile=false, $outfile="", $wident=true, $flat=false, $exportAttributes=array())
 
static arrayToRawValue($v, $br= '< BR >')
 
renameFile($idattr, $newname, $index=-1)
 
affectColumn($fields, $reset=true)
 
verifyConstraint($attrid, $index=-1)
 
static _array2val($v, $br= '< BR >')
 
if(($docid!==0)&&(!is_numeric($docid))) $query
 
delUTag($uid, $tag, $allrevision=true)
 
getIdFromName($dbaccess, $name)
 
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
 
getStateActivity($def="")
 
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
 
getZoneTransform($zone="")
 
store(&$info=null, $skipConstraint=false)
 
if($file) if($subject==""&&$file) if($subject=="") $err
 
addHistoryEntry($comment= '', $level=DocHisto::INFO, $code= '', $uid= '')
 
lock($auto=false, $userid=0)
 
getDocAnchor($id, $target="_self", $htmllink=true, $title=false, $js=true, $docrev="latest", $viewIcon=false)
 
getRawValue($idAttr, $def="")
 
getLatestDocId($dbaccess, $initid)
 
computeDProfil($dprofid=0, $fromdocidvalues=null)
 
editoptcard($target="_self", $ulink=true, $abstract=false)
 
vault_filename_fromvalue($fileid, $path=false)
 
controlUserId($docid, $uid, $aclname)
 
getDocObject($dbaccess, $v, $k=0)
 
control($aclname, $strict=false)
 
noPrivilegeMessage(Doc &$doc, $aclname)
 
static setFilesPersitent(array $vids)
 
transfertValuesFrom(&$from)