16 include_once (
"FDL/import_file.php");
23 private $analyze =
false;
24 private $policy =
"update";
25 private $reinit =
false;
26 private $csvSeparator =
SEPCHAR;
27 private $csvEnclosure =
'';
28 private $csvLinebreak =
'\n';
29 private $beginLine = 0;
30 private $familyIcon = 0;
33 private $ods2CsvFile =
'';
34 private $reset = array();
36 private $badOrderErrors = array();
40 private $verifyAttributeAccess =
true;
44 private $structAttr = null;
48 private $colOrders = array();
52 private $tcr = array();
53 private $dbaccess =
'';
54 private $needCleanStructure =
false;
55 private $needCleanParamsAndDefaults =
false;
56 private $importFileName =
'';
70 private $importedAttribute = array();
76 private $knownLogicalNames = array();
77 private $userIds = [];
85 $this->ods2CsvFile =
ods2csv($importFile);
86 $this->fdoc = fopen($this->ods2CsvFile,
"r");
88 $this->fdoc = fopen($importFile,
"r");
91 throw new Dcp\Exception(sprintf(
"no import file found : %s", $importFile));
93 $this->importFileName = $importFile;
101 $this->verifyAttributeAccess = $verifyAttributeAccess;
106 $this->analyze = $analyze;
114 $this->policy = $policy;
119 $this->dirid = $dirid;
124 $this->reinit = $reinit;
130 if ($reset && !is_array($reset)) {
135 $this->
reset = $reset;
139 $this->csvSeparator = $comma;
142 public function setCsvOptions($csvSeparator =
';', $csvEnclosure =
'"', $csvLinebreak =
'\n')
144 $this->csvSeparator = $csvSeparator;
145 $this->csvEnclosure = $csvEnclosure;
146 $this->csvLinebreak = $csvLinebreak;
150 "separator" => $this->csvSeparator,
151 "enclosure" => $this->csvEnclosure,
152 "linebreak" => $this->csvLinebreak
165 $content = file_get_contents($csvFileName);
166 if ($separator ==
'auto') {
167 $detector = new \Dcp\Utils\CSVFormatDetector\Detector();
168 $detected = $detector->detect($content);
169 if (!isset($detected[
'separator'][
'char']) || $detected[
'separator'][
'char'] === null) {
170 throw new Dcp\Exception(sprintf(
"cannot find csv separator in %s file", $csvFileName));
172 $separator = $detected[
'separator'][
'char'];
174 if ($enclosure ==
'auto') {
175 $detector = new \Dcp\Utils\CSVFormatDetector\Detector();
176 $detector->separators = array(
179 $detected = $detector->detect($content);
180 if (isset($detected[
'enclosure'][
'char']) && $detected[
'enclosure'][
'char'] !== null) {
181 $enclosure = $detected[
'enclosure'][
'char'];
187 "separator" => $separator,
188 "enclosure" => $enclosure
194 if (!$this->ods2CsvFile) {
195 if (($this->csvSeparator ==
'auto') || ($this->csvEnclosure ==
'auto')) {
201 $this->csvEnclosure =
'';
202 $this->csvSeparator =
';';
203 $this->csvLinebreak =
'\n';
206 public function import()
212 $this->structAttr = null;
213 $this->colOrders = array();
214 $this->ods2CsvFile =
"";
217 $this->beginLine = 0;
218 $csvLinebreak = $this->csvLinebreak;
219 if (!$this->csvSeparator && !$csvLinebreak) {
220 $csvLinebreak =
'\n';
222 while (!feof($this->fdoc)) {
223 if (!$this->csvEnclosure) {
224 $buffer = rtrim(fgets($this->fdoc));
225 $data = explode($this->csvSeparator, $buffer);
226 $data = array_map(
function ($v) use ($csvLinebreak)
228 return str_replace(array(
238 $data = fgetcsv($this->fdoc, 0, $this->csvSeparator, $this->csvEnclosure);
239 if (
$data ===
false) {
243 $data = array_map(
function ($v) use ($csvLinebreak)
245 return str_replace($csvLinebreak,
"\n", $v);
254 if (count(
$data) < 1)
continue;
255 $this->tcr[$this->nLine] = array(
264 "values" => array() ,
269 $this->tcr[$this->nLine][
"title"] = substr(
$data[0], 0, 10);
307 $this->doc->doctype =
$data[1];
308 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"set doctype to '%s'") ,
$data[1]);
317 $this->doc->genversion =
$data[1];
318 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"generate version '%s'") ,
$data[1]);
327 $this->doc->maxrev = intval(
$data[1]);
328 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"max revision '%d'") ,
$data[1]);
365 $this->doc->schar =
$data[1];
366 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"set special characteristics to '%s'") ,
$data[1]);
383 $this->doc->usefor =
"P";
384 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change special use to '%s'") , $this->doc->usefor);
392 $this->doc->usefor =
$data[1];
393 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change special use to '%s'") , $this->doc->usefor);
458 unset($this->tcr[$this->nLine]);
464 if ($this->ods2CsvFile) {
465 unlink($this->ods2CsvFile);
475 if (!$this->doc)
return;
476 $err = $this->doc->AddATag($data[1]);
477 if (!
$err) $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change application tag to '%s'") , $this->doc->atags);
479 $this->tcr[$this->nLine][
"err"] =
"ATAG:" .
$err;
480 $this->tcr[$this->nLine][
"action"] =
"ignored";
490 $data = array_map(
"trim", $data);
494 $this->beginLine = $this->nLine;
496 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
497 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
498 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
499 $this->tcr[$this->nLine][
"action"] =
"warning"; #_(
"warning")
502 if ($this->tcr[$this->nLine][
"err"] ==
"") {
503 if (($data[3] ==
"") || ($data[3] ==
"-")) $this->doc =
new DocFam($this->dbaccess,
getFamIdFromName($this->dbaccess, $data[5]) ,
'', 0,
false);
504 else $this->doc =
new DocFam($this->dbaccess, $data[3],
'', 0,
false);
506 $this->familyIcon =
"";
508 if (!$this->doc->isAffected()) {
510 if (!$this->analyze) {
511 $this->doc =
new DocFam($this->dbaccess);
513 if (isset($data[3]) && ($data[3] > 0)) $this->doc->id = $data[3];
514 if (is_numeric($data[1])) $this->doc->fromid = $data[1];
516 if (isset($data[5])) $this->doc->name = $data[5];
517 $err = $this->doc->Add();
519 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"create %s family %s") , $data[2], $data[5]);
520 $this->tcr[$this->nLine][
"action"] =
"added";
522 $this->tcr[$this->nLine][
"action"] =
"updated";
523 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"update %s family %s") , $data[2], $data[5]);
525 if ($data[1] && ($data[1] !=
'-')) {
526 if ($data[1] ==
'--') $this->doc->fromid = 0;
527 else if (is_numeric($data[1])) $this->doc->fromid = $data[1];
530 if ($data[2] && ($data[2] !=
'-')) $this->doc->title = $data[2];
531 if ($data[4] && ($data[4] !=
'-')) $this->doc->classname = $data[4];
532 if ($data[4] ==
"--") $this->doc->classname =
'';
533 $this->tcr[$this->nLine][
"err"].=
$check->checkClass($data, $this->doc)->getErrors();
535 if ($data[5] && ($data[5] !=
'-')) $this->doc->name = $data[5];
536 $this->tcr[$this->nLine][
"err"].=
$err;
539 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"reinit all attributes"));
540 if ($this->analyze)
return;
541 $oattr =
new DocAttr($this->dbaccess);
542 $oattr->docid = intval($this->doc->id);
543 if ($oattr->docid > 0) {
544 $err = $oattr->exec_query(sprintf(
"delete from docattr where docid=%d", $oattr->docid));
548 $this->tcr[$this->nLine][
"err"].=
$err;
551 foreach ($this->
reset as $reset) {
559 $this->tcr[$this->nLine][
"err"].=
$err;
562 catch(Exception $e) {
563 $this->tcr[$this->nLine][
"err"].= $e->getMessage();
565 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
573 if (!$this->doc)
return;
575 $msg = sprintf(_(
"modify %s family") , $this->doc->title);
576 $this->tcr[$this->nLine][
"msg"] = $msg;
579 for ($i = $this->beginLine; $i < $this->nLine; $i++) {
580 if (!empty($this->tcr[$i][
"err"])) $ferr.= $this->tcr[$i][
"err"];
582 if ($this->analyze) {
585 $this->tcr[$this->beginLine][
"action"] =
"warning";
589 if ((count($data) > 3) && ($data[3] !=
"")) $this->doc->doctype =
"S";
591 $now = gettimeofday();
592 $this->doc->revdate = $now[
'sec'];
593 $this->doc->modify();
596 if ($this->doc->doctype ==
"C") {
598 $check->checkMaxAttributes($this->doc);
601 if (
$err && $this->analyze) {
602 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
603 $this->tcr[$this->nLine][
"action"] =
"warning";
607 if (strpos($this->doc->usefor,
"W") !==
false) $this->doc->postImport();
610 $this->tcr[$this->nLine][
"err"].= $msg;
611 $this->tcr[$this->nLine][
"action"] =
"ignored";
612 $this->tcr[$this->beginLine][
"action"] =
"ignored";
615 if (isset($tFamIdName)) $tFamIdName[$this->doc->name] = $this->doc->id;
617 if (count($checkCr) > 0) {
621 $childsFams = ($this->doc->getChildFam());
622 foreach ($childsFams as $famInfo) {
627 $this->tcr[$this->nLine][
"err"].=
$err;
631 if ($this->needCleanParamsAndDefaults) {
632 $this->needCleanParamsAndDefaults =
false;
636 $this->tcr[$this->nLine][
"err"].=
$check->check($data, $this->doc)->getErrors();
637 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
638 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
639 $this->tcr[$this->nLine][
"action"] =
"warning";
643 if ((!$this->analyze) && ($this->familyIcon !=
"")) $this->doc->changeIcon($this->familyIcon);
644 $this->tcr[$this->nLine][
"msg"].= $this->doc->postImport();
645 if (!$this->tcr[$this->nLine][
"err"]) {
646 $check->checkMaxAttributes($this->doc);
647 $this->tcr[$this->nLine][
"err"] =
$check->getErrors();
648 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
649 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
650 $this->tcr[$this->nLine][
"action"] =
"warning";
655 $this->doc->addHistoryEntry(_(
"Update by importation"));
660 if ($this->tcr[$this->nLine][
"err"]) {
661 $this->tcr[$this->beginLine][
"action"] =
"ignored";
662 $this->tcr[$this->nLine][
"action"] =
"ignored";
665 $this->tcr[$this->beginLine][
"action"] =
"ignored";
666 $this->tcr[$this->nLine][
"action"] =
"ignored";
668 if ($this->needCleanStructure) {
669 $this->needCleanStructure =
false;
670 if (!$this->tcr[$this->nLine][
"err"]) {
680 if (!$this->doc)
return;
682 $orphanAttributes = CheckDb::getOrphanAttributes($this->doc->id);
683 if ($orphanAttributes) {
686 foreach ($orphanAttributes as $orphanAttrId) {
687 $sql[] = sprintf(
"alter table doc%d drop column %s cascade; ", $this->doc->id, $orphanAttrId);
689 $this->tcr[$this->nLine][
"msg"].=
"\nDestroy values for \"$orphanAttrId\".";
691 $sql[] = sprintf(
"create view family.\"%s\" as select * from doc%d", strtolower($this->doc->name) , $this->doc->id);
693 foreach (
$sql as $aSql) {
702 $defs = $this->doc->getOwnDefValues();
703 foreach ($defs as $aid => $v) {
704 if (!$this->doc->getAttribute($aid)) {
705 $this->doc->setDefValue($aid,
'',
false);
706 $this->tcr[$this->nLine][
"msg"].=
"\nClear default value \"$aid\".";
709 $defs = $this->doc->getOwnParams();
710 foreach ($defs as $aid => $v) {
711 if (!$this->doc->getAttribute($aid)) {
712 $this->doc->setParam($aid,
'',
false);
713 $this->tcr[$this->nLine][
"msg"].=
"\nClear parameter value \"$aid\".";
717 $this->doc->modify();
725 if (!$this->doc)
return;
727 $data = array_map(
"trim", $data);
729 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
730 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
731 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
732 $this->tcr[$this->nLine][
"action"] =
"warning";
735 if (!$this->tcr[$this->nLine][
"err"]) {
736 switch (strtolower($data[1])) {
738 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"reinit all attributes"));
739 if ($this->analyze) {
743 $sql = sprintf(
"delete from docattr where docid=%d", $this->doc->id);
746 $this->needCleanParamsAndDefaults =
true;
750 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"Reset defaults values"));
751 $this->doc->defval =
'';
755 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"Reset parameters values"));
756 $this->doc->param =
'';
760 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"Reset enums definition"));
761 $sql = sprintf(
"update docattr set phpfunc=null from docenum where docattr.docid=docenum.famid and docattr.id = docenum.attrid and docattr.type ~ 'enum' and docattr.docid=%d", $this->doc->id);
763 $sql = sprintf(
"delete from docenum where famid=%d", $this->doc->id);
770 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"reinit all properties"));
771 if ($this->analyze) {
774 $this->doc->resetPropertiesParameters();
778 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"Reset attribute structure"));
779 if ($this->analyze) {
782 $sql = sprintf(
"delete from docattr where docid=%d", $this->doc->id);
784 $this->needCleanStructure =
true;
785 $this->needCleanParamsAndDefaults =
true;
789 $this->tcr[$this->nLine][
"action"] =
"ignored";
791 $this->tcr[$this->nLine][
"err"].=
$err;
800 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
801 $famName =
$check->getParsedFamName();
802 if ($this->tcr[$this->nLine][
"err"]) {
803 if ($this->analyze) {
804 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
805 $this->tcr[$this->nLine][
"action"] =
"warning";
807 $this->tcr[$this->nLine][
"action"] =
"ignored";
811 if ($famName !==
false && isset($this->badOrderErrors[$famName])) {
813 if ($this->analyze) {
814 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Cannot import document because the ORDER line for family '%s' is incorrect: %s") , $famName, $this->badOrderErrors[$famName]);
815 $this->tcr[$this->nLine][
"action"] =
"warning";
817 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Cannot import document because the ORDER line for family '%s' is incorrect: %s") , $famName, $this->badOrderErrors[$famName]);
818 $this->tcr[$this->nLine][
"action"] =
"ignored";
823 if (is_numeric($data[1])) $fromid = $data[1];
826 if (isset($tkeys[$fromid])) $tk = $tkeys[$fromid];
832 if (isset($this->colOrders[$fromid])) {
833 $torder = $this->colOrders[$fromid];
838 $oImportDocument->setKey($tk);
841 $oImportDocument->setOrder($torder);
843 $oImportDocument->analyzeOnly($this->analyze);
844 $oImportDocument->setPolicy($this->policy);
845 $oImportDocument->setTargetDirectory($this->dirid);
846 $oImportDocument->setVerifyAttributeAccess($this->verifyAttributeAccess);
852 if ($data[2] !=
'' && !in_array($data[2], $this->knownLogicalNames)) {
853 $this->knownLogicalNames[] = $data[2];
855 $oImportDocument->setKnownLogicalNames($this->knownLogicalNames);
857 $this->tcr[$this->nLine] = $oImportDocument->import($data)->getImportResult();
859 if ($this->tcr[$this->nLine][
"err"] ==
"") {
862 $check->addError($this->tcr[$this->nLine][
"err"]);
863 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
864 $this->tcr[$this->nLine][
"action"] =
"warning";
874 if ($data[1] !=
'') {
875 $this->tcr[$this->nLine][
"id"] = $data[1];
882 if (!$this->analyze) {
883 if ($data[1] && is_numeric($data[1])) {
888 if ($data[1] && !is_numeric($data[1])) {
889 $search->setLogicalName($data[1]);
892 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"update %s search") , $data[3]);
893 $this->tcr[$this->nLine][
"action"] =
"updated";
897 if (!$this->analyze) {
900 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"add %s search") , $data[3]);
901 $this->tcr[$this->nLine][
"action"] =
"added";
902 $this->tcr[$this->nLine][
"err"].=
$err;
907 if (!$this->analyze) {
911 $this->tcr[$this->nLine][
"err"].=
$err;
913 if (($data[4] !=
"")) {
915 $this->tcr[$this->nLine][
"err"].=
$err;
918 if ($data[2] !=
'') {
924 if (
$dir->isAlive() && method_exists(
$dir,
"insertDocument"))
$dir->insertDocument(
$search->id);
935 $idoc = new_doc($this->dbaccess, $data[1]);
936 if (!$this->analyze)
$idoc->changeIcon($data[2]);
937 if (
$idoc->isAlive()) $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"document %s : set icon to '%s'") ,
$idoc->title, $data[2]);
939 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"no change icon : document %s not found") , $data[1]);
940 $this->tcr[$this->nLine][
"action"] =
"ignored";
950 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
951 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
952 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
953 $this->tcr[$this->nLine][
"action"] =
"warning";
956 if ($this->tcr[$this->nLine][
"err"]) {
957 $this->tcr[$this->nLine][
"action"] =
"ignored";
960 $idoc = new_doc($this->dbaccess, $data[1]);
964 while (!empty($data[$i])) {
969 $tagAction = $data[3];
974 if (!$this->analyze) {
975 if ($tagAction ===
"SET") {
978 $err =
$idoc->modify(
true, array(
"atags"),
true);
980 $this->tcr[$this->nLine][
"err"] =
$err;
984 foreach ($tags as $tag) {
985 if ($tagAction ===
"DELETE") {
991 $this->tcr[$this->nLine][
"err"] =
$err;
995 switch ($tagAction) {
997 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Add atags \"%s\"") , implode(
"\", \"", $tags));
1001 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Del atags \"%s\"") , implode(
"\", \"", $tags));
1005 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Set atags \"%s\"") , implode(
"\", \"", $tags));
1015 if (empty($data[1])) {
1016 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"No Icon specified"));
1017 } elseif ($this->doc->icon ==
"") {
1018 $this->familyIcon = $data[1];
1019 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"set icon to '%s'") , $data[1]);
1021 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"icon already set. No update allowed"));
1030 if (!$this->doc)
return;
1031 if (!isset($data[1])) $data[1] =
'';
1033 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1034 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1035 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1036 $this->tcr[$this->nLine][
"action"] =
"warning";
1039 if (!$this->tcr[$this->nLine][
"err"]) {
1041 if ($data[1] ==
"auto") {
1042 if ($this->doc->dfldid ==
"") {
1043 if (!$this->analyze) {
1045 include_once (
"FDL/freedom_util.php");
1047 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"create default folder (id [%d])\n") ,
$fldid);
1050 $fldid = $this->doc->dfldid;
1051 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"default folder already set. Auto ignored"));
1053 } elseif (is_numeric($data[1]))
$fldid = $data[1];
1055 $this->doc->dfldid =
$fldid;
1056 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"set default folder to '%s'") , $data[1]);
1058 $this->tcr[$this->nLine][
"action"] =
"ignored";
1067 if (!$this->doc)
return;
1070 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1071 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1072 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1073 $this->tcr[$this->nLine][
"action"] =
"warning";
1076 if (!$this->tcr[$this->nLine][
"err"]) {
1077 if (is_numeric($data[1])) $cfldid = $data[1];
1079 $this->doc->cfldid = $cfldid;
1080 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"set primary folder to '%s'") , $data[1]);
1082 $this->tcr[$this->nLine][
"action"] =
"ignored";
1091 if (!$this->doc)
return;
1092 if (!isset($data[1])) $data[1] =
'';
1094 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1095 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1096 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1097 $this->tcr[$this->nLine][
"action"] =
"warning";
1100 if ($this->tcr[$this->nLine][
"err"]) {
1101 $this->tcr[$this->nLine][
"action"] =
"ignored";
1104 if (is_numeric($data[1])) $wid = $data[1];
1108 $wdoc = new_doc($this->dbaccess, $wid);
1109 if (!$wdoc->isAlive()) {
1110 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"WID : workflow '%s' not found") , $data[1]);
1112 if (!is_subclass_of($wdoc,
"WDoc")) {
1113 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"WID : workflow '%s' is not a workflow") , $data[1]);
1115 $this->doc->wid = $wdoc->id;
1118 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"set default workflow to '%s'") , $data[1]);
1120 catch(Exception $e) {
1121 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"WID : %s") , $e->getMessage());
1123 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1125 $this->doc->wid =
'';
1127 $this->tcr[$this->nLine][
"msg"] = _(
"unset default workflow");
1136 if (!$this->doc)
return;
1138 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1139 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1140 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1141 $this->tcr[$this->nLine][
"action"] =
"warning";
1144 if ($this->tcr[$this->nLine][
"err"]) {
1145 $this->tcr[$this->nLine][
"action"] =
"ignored";
1149 if (is_numeric($data[1])) $cvid = $data[1];
1154 $cvdoc = new_doc($this->dbaccess, $cvid);
1155 if (!$cvdoc->isAlive()) {
1156 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"CVID : view control '%s' not found") , $data[1]);
1158 $this->doc->ccvid = $cvdoc->id;
1160 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"set default view control to '%s'") , $data[1]);
1162 catch(Exception $e) {
1163 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"CVID : %s") , $e->getMessage());
1165 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1167 $this->doc->ccvid =
'';
1169 $this->tcr[$this->nLine][
"msg"] = _(
"unset default view control");
1178 if (!$this->doc)
return;
1179 $data = array_map(
"trim", $data);
1181 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1182 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1183 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1184 $this->tcr[$this->nLine][
"action"] =
"warning";
1187 if ($this->tcr[$this->nLine][
"err"]) {
1188 $this->tcr[$this->nLine][
"action"] =
"ignored";
1191 $this->doc->classname = $data[1];
1199 if (!$this->doc)
return;
1200 $data = array_map(
"trim", $data);
1202 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1203 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1204 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1205 $this->tcr[$this->nLine][
"action"] =
"warning";
1208 if ($this->tcr[$this->nLine][
"err"]) {
1209 $this->tcr[$this->nLine][
"action"] =
"ignored";
1213 if (!isset($data[1])) $aMethod = null;
1214 else $aMethod = $data[1];
1215 $s1 = ($aMethod) ? $aMethod[0] :
'';
1216 if (($s1 ==
"+") || ($s1 ==
"*")) {
1217 if ($s1 ==
"*")
$method = $aMethod;
1218 else $method = substr($aMethod, 1);
1220 if ($this->doc->methods ==
"") {
1221 $this->doc->methods =
$method;
1223 $this->doc->methods.=
"\n$method";
1225 $tmeth = explode(
"\n", $this->doc->methods);
1226 $tmeth = array_unique($tmeth);
1227 $this->doc->methods = implode(
"\n", $tmeth);
1229 }
else $this->doc->methods = $aMethod;
1231 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change methods to '%s'") , $this->doc->methods);
1232 if ($this->doc->methods) {
1233 $tmethods = explode(
"\n", $this->doc->methods);
1234 foreach ($tmethods as
$method) {
1235 $fileMethod = ($method && $method[0] ==
'*') ? substr($method, 1) :
$method;
1236 if (!file_exists(sprintf(
"FDL/%s", $fileMethod))) {
1237 $this->tcr[$this->nLine][
"err"].= sprintf(
"Method file '%s' not found.", $fileMethod);
1241 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1249 if (!$this->doc)
return;
1251 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1252 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1253 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1254 $this->tcr[$this->nLine][
"action"] =
"warning";
1257 if ($this->tcr[$this->nLine][
"err"]) {
1258 $this->tcr[$this->nLine][
"action"] =
"ignored";
1262 if (is_numeric($data[1])) $pid = $data[1];
1264 $this->doc->cprofid = $pid;
1265 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change default creation profile id to '%s'") , $data[1]);
1273 if (!$this->doc)
return;
1276 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
1277 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1278 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1279 $this->tcr[$this->nLine][
"action"] =
"warning";
1282 if ($this->tcr[$this->nLine][
"err"]) {
1283 $this->tcr[$this->nLine][
"action"] =
"ignored";
1286 if (is_numeric($data[1])) $pid = $data[1];
1288 $this->doc->setProfil($pid);
1289 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change profile id to '%s'") , $data[1]);
1298 if (!$this->doc)
return;
1300 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1301 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1302 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1303 $this->tcr[$this->nLine][
"action"] =
"warning";
1306 if ($this->tcr[$this->nLine][
"err"]) {
1307 $this->tcr[$this->nLine][
"action"] =
"ignored";
1311 if (!isset($data[2])) $data[2] =
'';
1312 $attrid = trim(strtolower($data[1]));
1313 $newValue = $data[2];
1314 $opt = (isset($data[3])) ? trim(strtolower($data[3])) : null;
1315 $force = (str_replace(
" ",
"", $opt) ==
"force=yes");
1316 $params = $this->doc->getOwnParams();
1317 $previousValue = isset($params[$attrid]) ? $params[$attrid] : null;
1318 if ((!empty($previousValue)) && (!
$force)) {
1320 $this->tcr[$this->nLine][
"msg"] = sprintf(
"keep default value %s : %s. No use %s", $attrid, $previousValue, $data[2]);
1323 if (
$force || ($previousValue === null)) {
1324 $this->doc->setParam($attrid, $newValue,
false);
1325 $this->tcr[$this->nLine][
"msg"] =
"reset default parameter";
1327 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"add default value %s %s") , $attrid, $data[2]);
1337 if (!$this->doc)
return;
1339 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1340 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1341 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1342 $this->tcr[$this->nLine][
"action"] =
"warning";
1345 if ($this->tcr[$this->nLine][
"err"]) {
1346 $this->tcr[$this->nLine][
"action"] =
"ignored";
1350 if (!isset($data[2])) $data[2] =
'';
1351 $attrid = trim(strtolower($data[1]));
1353 $opt = (isset($data[3])) ? trim(strtolower($data[3])) : null;
1354 $force = (str_replace(
" ",
"", $opt) ==
"force=yes");
1355 $ownDef = $this->doc->getOwnDefValues();
1356 if ((!empty($ownDef[$attrid])) && (!
$force)) {
1358 $this->tcr[$this->nLine][
"msg"] = sprintf(
"keep default value %s : %s. No use %s", $attrid, $ownDef[$attrid], $data[2]);
1360 $this->doc->setDefValue($attrid, $defv,
false);
1361 if (
$force || (!$this->doc->getParameterRawValue($attrid))) {
1367 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"add default value %s %s") , $attrid, $data[2]);
1379 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $action)->getErrors();
1380 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1381 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1382 $this->tcr[$this->nLine][
"action"] =
"warning";
1385 if ($this->tcr[$this->nLine][
"err"]) {
1386 $this->tcr[$this->nLine][
"action"] =
"ignored";
1389 if (ctype_digit(trim($data[1]))) $wid = trim($data[1]);
1395 $idapp = $action->parent->GetIdFromName($data[2]);
1397 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"%s application not exists") , $data[2]);
1399 $this->tcr[$this->nLine][
"msg"] =
"user #$wid";
1404 $q->AddQuery(
"id_application=$idapp");
1405 $la =
$q->Query(0, 0,
"TABLE");
1407 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"%s application has no aclss") , $data[2]);
1410 foreach (
$la as $k => $v) {
1411 $tacl[$v[
"name"]] = $v[
"id"];
1416 $p->id_application = $idapp;
1417 foreach ($data as $v) {
1420 if ($this->analyze) {
1421 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"try add acl %s") , $v);
1422 $this->tcr[$this->nLine][
"action"] =
"added";
1425 if (substr($v, 0, 1) ==
'-') {
1428 }
else $aclneg =
false;
1429 if (isset($tacl[$v])) {
1430 $p->id_acl = $tacl[$v];
1431 if ($aclneg) $p->id_acl = - $p->id_acl;
1432 $p->deletePermission($p->id_user, $p->id_application, $p->id_acl);
1434 if (
$err) $this->tcr[$this->nLine][
"err"].=
"\n$err";
1436 if ($aclneg) $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"add negative acl %s") , $v);
1437 else $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"add acl %s") , $v);
1440 $this->tcr[$this->nLine][
"err"].=
"\n" . sprintf(_(
"unknow acl %s") , $v);
1446 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1457 if (class_exists(
"CheckTagable")) {
1461 $check =
new CheckTagable();
1463 $this->tcr[$this->nLine][
"err"] =
ErrorCode::getError(
'PROP0102',
"TAGABLE",
"dynacase-tags");
1464 $this->tcr[$this->nLine][
"action"] =
"ignored";
1465 error_log(
"ERROR:" . $this->tcr[$this->nLine][
"err"]);
1471 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
1472 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1473 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1474 $this->tcr[$this->nLine][
"action"] =
"warning";
1477 if ($this->tcr[$this->nLine][
"err"]) {
1478 $this->tcr[$this->nLine][
"action"] =
"ignored";
1481 $this->doc->tagable = $data[1] ===
"no" ?
"" : $data[1];
1482 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change tagable parameter to '%s'") , $this->doc->tagable);
1491 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
1492 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1493 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1494 $this->tcr[$this->nLine][
"action"] =
"warning";
1497 if ($this->tcr[$this->nLine][
"err"]) {
1498 $this->tcr[$this->nLine][
"action"] =
"ignored";
1502 if (ctype_digit(trim($data[1]))) $pid = trim($data[1]);
1505 if (!($pid > 0)) $this->tcr[$this->nLine][
"err"] = sprintf(_(
"profil id unkonow %s") , $data[1]);
1512 $pdoc =
new_Doc($this->dbaccess, $pid);
1513 if ($pdoc->isAlive()) {
1514 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"change profil %s") , $data[1]);
1515 $this->tcr[$this->nLine][
"action"] =
"modprofil";
1516 if ($this->analyze)
return;
1518 if (($fpid !=
"") && (!is_numeric($fpid))) $fpid =
getIdFromName($this->dbaccess, $fpid);
1521 $pdoc->setProfil($fpid);
1522 $this->tcr[$this->nLine][
"err"] = $pdoc->modify(
false, array(
1527 if ($pdoc->profid != $pid) {
1528 $pdoc->setProfil($pid);
1529 $pdoc->SetControl(
false);
1530 $pdoc->disableEditControl();
1531 $this->tcr[$this->nLine][
"err"] = $pdoc->modify();
1534 $defaultUseType = trim($data[2]);
1535 $optprof = strtoupper(trim($data[3]));
1536 $initialPerms = array();
1537 $profilingHasChanged =
false;
1538 if ($optprof ==
"RESET") {
1539 $pdoc->removeControl();
1540 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"reset profil %s") , $pid);
1541 } elseif ($optprof ==
"SET") {
1543 $pdoc->removeControl();
1544 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"set profile %s") , $pid);
1546 $tacls = array_slice($data, 2);
1547 foreach ($tacls as $acl) {
1548 if (preg_match(
"/([^=]+)=(.*)/", $acl, $reg)) {
1549 $tuid = explode(
",", $reg[2]);
1550 $aclname = trim($reg[1]);
1553 if ($optprof ==
"DELETE") {
1554 foreach ($tuid as $uid) {
1555 $perr.= $pdoc->delControl($this->
getProfilUid($defaultUseType, $uid) , $aclname);
1556 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"delete %s for %s") , $aclname, $uid);
1559 foreach ($tuid as $uid) {
1560 $perr.= $pdoc->addControl($this->
getProfilUid($defaultUseType, $uid) , $aclname);
1561 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"add %s for %s") , $aclname, $uid);
1564 $this->tcr[$this->nLine][
"err"] = $perr;
1567 if ($optprof ==
"SET") {
1569 $profilingHasChanged = (serialize($newPerms) != serialize($initialPerms));
1571 if ($optprof ==
"RESET" || ($optprof ==
"SET" && $profilingHasChanged)) {
1573 $pdoc->addHistoryEntry(_(
'Recomputing profiled documents') ,
DocHisto::INFO,
'RECOMPUTE_PROFILED_DOCUMENT');
1574 $pdoc->recomputeProfiledDocument();
1578 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"profil id unknow %s") , $data[1]);
1581 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1587 $reference = trim($reference);
1588 $this->extractAccount($defaultReferenceType, $reference,
$type,
$value);
1594 case ':useAttribute':
1595 return self::attributePrefix .
$value;
1598 case ':useDocument':
1599 return self::documentPrefix .
$value;
1607 private function extractAccount($defaultReferenceType, $reference, &
$type, &
$value)
1609 if (preg_match(
'/^attribute\((.*)\)$/', $reference, $reg)) {
1610 $type =
":useAttribute";
1612 } elseif (preg_match(
'/^account\((.*)\)$/', $reference, $reg)) {
1613 $type =
":useAccount";
1615 } elseif (preg_match(
'/^document\((.*)\)$/', $reference, $reg)) {
1616 $type =
":useDocument";
1620 $type = $defaultReferenceType;
1627 if (!isset($this->userIds[
$login])) {
1628 simpleQuery(
"", sprintf(
"select id from users where login='%s'", pg_escape_string($login)) , $uid,
true,
true);
1630 throw new \Dcp\Exception(
"PRFL0204", $login);
1632 $this->userIds[
$login] = $uid;
1634 return $this->userIds[
$login];
1643 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
1644 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1645 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1646 $this->tcr[$this->nLine][
"action"] =
"warning";
1649 if ($this->tcr[$this->nLine][
"err"]) {
1650 $this->tcr[$this->nLine][
"action"] =
"ignored";
1653 if (is_numeric($data[1])) $orfromid = $data[1];
1656 $tkeys[$orfromid] =
getOrder($data);
1657 if (($tkeys[$orfromid][0] ==
"") || (count($tkeys[$orfromid]) == 0)) {
1658 $this->tcr[$this->nLine][
"err"] = sprintf(_(
"error in import keys : %s") , implode(
" - ", $tkeys[$orfromid]));
1659 unset($tkeys[$orfromid]);
1660 $this->tcr[$this->nLine][
"action"] =
"ignored";
1662 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"new import keys : %s") , implode(
" - ", $tkeys[$orfromid]));
1672 $this->tcr[$this->nLine][
"err"] =
$check->check($data)->getErrors();
1673 $famName =
$check->getParsedFamName();
1674 if ($this->tcr[$this->nLine][
"err"]) {
1675 if ($famName !==
false) {
1676 $this->badOrderErrors[$famName] = $this->tcr[$this->nLine][
"err"];
1678 if ($this->analyze) {
1679 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1680 $this->tcr[$this->nLine][
"action"] =
"warning";
1682 $this->tcr[$this->nLine][
"action"] =
"ignored";
1686 if ($famName !==
false && isset($this->badOrderErrors[$famName])) {
1687 unset($this->badOrderErrors[$famName]);
1689 if (is_numeric($data[1])) $orfromid = $data[1];
1692 $this->colOrders[$orfromid] =
getOrder($data);
1693 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"new column order %s") , implode(
" - ", $this->colOrders[$orfromid]));
1702 if (is_numeric($data[1])) $fid = $data[1];
1704 $aid = (trim($data[2]));
1712 if (substr($data[2], 0, 2) ==
"::") $oa->ldapname = $data[2];
1713 else $oa->ldapname = strtolower(trim($data[2]));
1715 $oa->ldapclass = trim($data[4]);
1717 $oa->ldapmap = $data[3];
1718 $oa->index = $index;
1719 $oa->ldapname = $aid;
1721 if ($oa->isAffected()) {
1722 if (!$this->analyze)
$err = $oa->modify();
1723 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"LDAP Attribute modified to %s %s") , $oa->ldapname, $oa->ldapmap);
1724 $this->tcr[$this->nLine][
"action"] =
"updated";
1726 if (!$this->analyze)
$err = $oa->add();
1728 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"LDAP Attribute added to %s %s") , $oa->ldapname, $oa->ldapmap);
1729 $this->tcr[$this->nLine][
"action"] =
"added";
1731 $this->tcr[$this->nLine][
"err"].=
$err;
1732 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1742 if ($curType == $newType)
return true;
1744 "docid" =>
"account",
1745 "text" =>
"longtext",
1746 "longtext" =>
"htmltext",
1754 return isset($tc[$curType]) && ($tc[$curType] == $newType);
1763 if (!$this->doc)
return;
1765 $this->tcr[$this->nLine][
"err"] =
$check->check($data, $this->doc)->getErrors();
1766 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1767 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1768 $this->tcr[$this->nLine][
"action"] =
"warning";
1771 if ($this->tcr[$this->nLine][
"err"]) {
1772 $this->tcr[$this->nLine][
"action"] =
"ignored";
1776 if (!$this->structAttr) {
1779 $this->structAttr->set($data);
1781 if (trim($data[1]) ==
'') {
1782 $this->tcr[$this->nLine][
"err"].= sprintf(_(
"attr key is empty"));
1784 $modattr = ($data[0] ==
"MODATTR");
1785 if ($data[0] ==
"MODATTR") $this->structAttr->id =
':' . $this->structAttr->id;
1786 $this->tcr[$this->nLine][
"msg"].= sprintf(_(
"update %s attribute") , $this->structAttr->id);
1787 if ($this->analyze)
return;
1788 $oattr =
new DocAttr($this->dbaccess, array(
1790 strtolower($this->structAttr->id)
1793 if ($oattr->isAffected()) {
1795 $curType = trim(strtok($oattr->type,
'('));
1796 $newType = trim(strtok($this->structAttr->type,
'('));
1797 if ($curType != $newType && (!$this->
isTypeCompatible($curType, $newType))) {
1798 $this->tcr[$this->nLine][
"err"].= sprintf(
"cannot change attribute %s type definition from %s to %s", $this->structAttr->id, $curType, $newType);
1801 if (($data[0] ==
"PARAM") && ($oattr->usefor !=
'Q')) {
1802 $this->tcr[$this->nLine][
"err"].= sprintf(
"cannot change attribute declaration to PARAM for %s", $this->structAttr->id);
1803 } elseif (($data[0] ==
"ATTR") && ($oattr->usefor ==
'Q')) {
1804 $this->tcr[$this->nLine][
"err"].= sprintf(
"cannot change attribute declaration to ATTR for %s", $this->structAttr->id);
1808 if (!$this->tcr[$this->nLine][
"err"]) {
1809 if ($data[0] ==
"PARAM") $oattr->usefor =
'Q';
1810 elseif ($data[0] ==
"OPTION") $oattr->usefor =
'O';
1811 else $oattr->usefor =
'N';
1812 $oattr->docid = $this->doc->id;
1813 $oattr->id = trim(strtolower($this->structAttr->id));
1815 $oattr->frameid = trim(strtolower($this->structAttr->setid));
1816 $oattr->labeltext = $this->structAttr->label;
1818 $oattr->title = ($this->structAttr->istitle ==
"Y") ?
"Y" :
"N";
1820 $oattr->abstract = ($this->structAttr->isabstract ==
"Y") ?
"Y" :
"N";
1821 if ($modattr) $oattr->abstract = $this->structAttr->isabstract;
1823 $oattr->type = trim($this->structAttr->type);
1825 $oattr->ordered = $this->structAttr->order;
1826 $oattr->visibility = $this->structAttr->visibility;
1827 $oattr->needed = ($this->structAttr->isneeded ==
"Y") ?
"Y" :
"N";
1829 $oattr->title = $this->structAttr->istitle;
1830 $oattr->needed = $this->structAttr->isneeded;
1832 $oattr->link = $this->structAttr->link;
1833 $oattr->phpfile = $this->structAttr->phpfile;
1834 if ($this->structAttr->elink) $oattr->elink = $this->structAttr->elink;
1835 else $oattr->elink =
'';
1836 if ($this->structAttr->constraint) $oattr->phpconstraint = $this->structAttr->constraint;
1837 else $oattr->phpconstraint =
'';
1838 if ($this->structAttr->options) $oattr->options = $this->structAttr->options;
1839 else $oattr->options =
'';
1841 if (((($this->structAttr->phpfile !=
"") && ($this->structAttr->phpfile !=
"-")) || (($this->structAttr->type !=
"enum") && ($this->structAttr->type !=
"enumlist"))) || ($oattr->phpfunc ==
"") || (strpos($oattr->options,
"system=yes") !==
false)) {
1843 $oattr->phpfunc = $this->structAttr->phpfunc;
1844 if ($oattr->type ==
"enum") {
1845 if (strlen($this->structAttr->phpfile) < 2) {
1847 $reset = (strpos($oattr->options,
"system=yes") !==
false);
1848 $this->
recordEnum($this->doc->id, $oattr->id, $this->structAttr->phpfunc, $reset);
1854 if ($oattr->ordered && !is_numeric($oattr->ordered)) {
1855 $oattr->options.= ($oattr->options) ?
"|" :
"";
1856 $oattr->options.= sprintf(
"relativeOrder=%s", $oattr->ordered);
1857 $oattr->ordered = $this->nLine;
1859 if ($oattr->isAffected())
$err = $oattr->Modify();
1860 else $err = $oattr->Add();
1863 $this->tcr[$this->nLine][
"err"].=
$err;
1866 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1884 $oe->attrid = $attrid;
1887 $sql = sprintf(
"delete from docenum where famid='%s' and attrid='%s'", pg_escape_string(
$famid) , pg_escape_string($attrid));
1891 foreach ($enums as $itemKey => $itemLabel) {
1892 $oe->label = $itemLabel;
1894 $antiItemKey = str_replace(
"\\.",
"--dot--", $itemKey);
1895 if (strpos($antiItemKey,
'.') !==
false) {
1896 $tkeys = explode(
".", $itemKey);
1897 $oe->key = array_pop($tkeys);
1898 $oe->parentkey = array_pop($tkeys);
1901 $oe->key = str_replace(
"\\.",
".", $itemKey);
1903 $oe->parentkey =
'';
1906 if (
$oe->exists()) {
1923 if (!$this->doc)
return;
1928 $fi =
new_Doc($this->dbaccess, $fiid);
1929 if ($fi->isAffected()) {
1930 $fa = $fi->getAttribute($data[1]);
1932 $oattri =
new DocAttr($this->dbaccess, array(
1934 strtolower($data[1])
1936 $oattr =
new DocAttr($this->dbaccess, array(
1938 strtolower($data[1])
1940 $oattri->docid = $this->doc->id;
1941 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"copy attribute %s from %s") , $data[1], $data[3]);
1942 if (!$this->analyze) {
1943 if ($oattr->isAffected()) {
1944 $err = $oattri->modify();
1946 $oattri->id = strtolower($data[1]);
1947 $err = $oattri->add();
1949 $this->tcr[$this->nLine][
"err"] =
$err;
1952 if ((
$err ==
"") && (strtolower(get_class($fa)) ==
"fieldsetattribute")) {
1955 foreach ($fi->attributes->attr as $k => $v) {
1956 if (strtolower(get_class($v)) ==
"normalattribute") {
1958 if (($v->fieldSet->id == $frameid) || ($v->fieldSet->fieldSet->id == $frameid)) {
1959 $this->tcr[$this->nLine][
"msg"].=
"\n" . sprintf(_(
"copy attribute %s from %s") , $v->id, $data[3]);
1960 $oattri =
new DocAttr($this->dbaccess, array(
1964 $oattr =
new DocAttr($this->dbaccess, array(
1968 $oattri->docid = $this->doc->id;
1969 if (!$this->analyze) {
1970 if ($oattr->isAffected()) {
1971 $err = $oattri->modify();
1973 $oattri->id = $v->id;
1974 $err = $oattri->add();
1976 $this->tcr[$this->nLine][
"err"].=
$err;
1984 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
1993 $this->tcr[$this->nLine][
"err"] =
$check->check(
$data, $this->doc)->getErrors();
1994 if ($this->tcr[$this->nLine][
"err"] && $this->analyze) {
1995 $this->tcr[$this->nLine][
"msg"] = sprintf(_(
"Element can't be perfectly analyze, some error might occur or be corrected when importing"));
1996 $this->tcr[$this->nLine][
"action"] =
"warning";
1999 if ($this->tcr[$this->nLine][
"err"]) {
2000 $this->tcr[$this->nLine][
"action"] =
"ignored";
2004 $propName =
$check->propName;
2005 $values =
$check->parameters;
2007 if ($this->analyze) {
2011 foreach ($values as
$value) {
2012 $pName = $value[
'name'];
2013 $pValue = $value[
'value'];
2014 if (!$this->doc->setPropertyParameter($propName, $pName, $pValue)) {
2015 $this->tcr[$this->nLine][
"err"].= sprintf(_(
"error storing configuration property (%s, %s, %s)") , $propName, $pName, $pValue);
2019 if ($this->tcr[$this->nLine][
"err"]) $this->tcr[$this->nLine][
"action"] =
"ignored";
2023 if (!isset($this->importedAttribute[
$famId])) {
2024 $this->importedAttribute[
$famId] = array();
2026 $this->importedAttribute[
$famId][$oa->id] = $oa;
2030 if (isset($this->importedAttribute[
$famId][$attrId])) {
2031 return $this->importedAttribute[
$famId][$attrId];
static verifyDbFamily($famid, NormalAttribute $aoa=null)
isTypeCompatible($curType, $newType)
setCsvOptions($csvSeparator= ';', $csvEnclosure= '"', $csvLinebreak = '\n')
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
Exception class use exceptionCode to identifiy correctly exception.
Check profil when importing definition.
getProfilUid($defaultReferenceType, $reference)
getImportedAttribute($famId, $attrId)
static detectAutoCsvOptions($csvFileName, &$separator= 'auto', &$enclosure= 'auto')
addImportedAttribute($famId, DocAttr &$oa)
static getPermsForDoc($docid)
setVerifyAttributeAccess($verifyAttributeAccess)
static getError($code, $args=null)
getOrder(array $orderdata)
Check application accesses when importing definition.
static getPermsForDoc($docid)
Check application accesses when importing definition.
static recordEnum($famid, $attrid, $phpfunc, $reset=false)
static createDocFile($dbaccess, $tdoc)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getFamIdFromName($dbaccess, $name)
new_Doc($dbaccess, $id= '', $latest=false)
cleanDefaultAndParametersValues()
setImportDirectory($dirid)
setMaxExecutionTimeTo($limit)
getIdFromName($dbaccess, $name)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
static refreshPhpPgDoc($dbaccess, $docid)
if($file) if($subject==""&&$file) if($subject=="") $err
Check family profid property when importing definition.