19 var
$defaultview = "FREEDOM:VIEWDSEARCH";
#N_("not include") N_("begin by") N_("not equal") N_("> or equal") N_("< or equal") N_("content file word") N_("content file expression")
39 if ($cond ===
false)
return array(
44 if (
$latest ==
"lastfixed") $distinct =
true;
45 if ($cond !=
"") $filters[] = $cond;
50 $query =
getSqlSearchDoc($this->dbaccess, $cdirid,
$famid, $filters, $distinct,
$latest ==
"yes", $this->
getRawValue(
"se_trash") ,
false, $level = 2, $join =
'', $only);
61 if ((count($this->
getMultipleRawValues(
"se_filter")) > 0) && (empty($filtersType[0]) || $filtersType[0] !=
"generated")) {
66 if (
$q) $queries[] =
$q;
70 return parent::getQuery();
76 $err = parent::postStore();
81 $err.= $e->getMessage();
95 return self::postStore();
110 $filterType = $filtersType[0];
111 if ($filterType !=
"generated") {
113 $root = simplexml_load_string(
$filter);
116 if (!is_numeric($std->family)) {
117 if (preg_match(
"/([\w:]*)\s?(strict)?/", trim($std->family) , $reg)) {
118 if (!is_numeric($reg[1])) $reg[1] =
getFamIdFromName($this->dbaccess, $reg[1]);
119 if ($reg[2] ==
"strict")
$famid =
'-' . $reg[1];
147 if ($typeFilters[0] !=
"generated")
return '';
151 $filterXml = sprintf(
"<filter><family>%s%s</family>", $this->
getRawValue(
"se_famid") , ($this->
getRawValue(
"se_famonly") ==
"yes" ?
" strict" :
""));
153 $filterXml.=
"</filter>";
154 $this->
setValue(
"se_typefilter",
"generated");
155 $this->
setValue(
"se_filter", $filterXml);
167 $root = simplexml_load_string($xml);
176 if (count(
$q) == 1) {
191 if ($xml->count() == 0) {
192 return current($xml);
194 foreach ($xml as $k => $se) {
195 if (isset($std->$k)) {
196 if (!is_array($std->$k)) $std->$k = array(
199 array_push($std->$k, $this->simpleXml2StdClass($se));
201 if ($std === null) $std = new \stdClass();
211 $err = parent::preConsultation();
216 if ($this->defaultview ==
"FREEDOM:VIEWDSEARCH") {
218 if (
$type[0] !=
"generated") {
219 $this->defaultview =
"FDL:VIEWBODYCARD";
230 if (
$type[0] !=
"generated") {
231 $this->defaultedit =
"FDL:EDITBODYCARD";
236 $oa->setVisibility(
'R');
238 $oa->setVisibility(
'W');
241 $oa->setVisibility(
'W');
259 foreach ($tlp as $lp)
if ($lp ==
"yes") $clp++;
260 foreach ($tlr as $lr)
if ($lr ==
"yes") $clr++;
261 if ($clp != $clr)
$err = sprintf(_(
"parenthesis number mismatch : %d left, %d right") , $clp, $clr);
271 private function isValidTimestamp($str)
273 $this->last_sug =
'';
275 if (preg_match(
'|^\d\d/\d\d/\d\d\d\d(\s+\d\d:\d\d(:\d\d)?)?$|', $str)) {
279 if (preg_match(
'@^\d\d\d\d-\d\d-\d\d([\s+|T]\d\d:\d\d(:\d\d)?)?$@', $str)) {
282 $this->last_sug = $this->
getDate(0,
'',
'',
true);
283 return _(
"DetailSearch:malformed timestamp").
": $str";
291 private function isValidPgRegex($str)
294 $this->last_sug =
'';
295 $point =
"dcp:isValidPgRegex";
297 $q = sprintf(
"SELECT regexp_matches('', E'%s')", pg_escape_string($str));
301 catch(\Exception $e) {
302 $err = $e->getMessage();
306 $err = _(
"invalid regular expression");
307 $this->last_sug = preg_quote($str,
'');
322 if (
$value !==
'' && $this->getMethodName(
$value) !==
'') {
329 if (substr(
$value, 0, 1) ==
'?') {
337 $this->getSqlCond($attr, $op,
$value,
'',
$err,
true);
339 $err = sprintf(_(
"Invalid condition for attribute '%s' with value '%s': %s") , $attr,
$value,
$err);
343 'sug' => isset($this->last_sug) ? $this->last_sug :
''
349 private function checkConditionsParens()
355 foreach ($lp as $p) {
360 foreach ($rp as $p) {
366 $err = _(
"DetailSearch:unbalanced parenthesis");
376 $err.= $this->checkConditionsParens();
390 function getSqlCond($col, $op, $val =
"", $val2 =
"", &
$err =
"", $validateCond =
false)
393 if ((!$this->searchfam) || ($this->searchfam->id != $this->getRawValue(
"se_famid"))) {
396 $col = trim(strtok($col,
' '));
398 if (($col ==
"revdate") && ($val !=
'') && (!is_numeric($val))) {
399 $val = stringdatetounixts($val);
402 if ($col ==
"activity" || $col ==
"fixstate") {
407 $oa = $this->searchfam->getAttribute($col);
416 if (($atype ==
"date" || $atype ==
"timestamp")) {
417 if ($col ==
'revdate') {
419 $val2 = $val + 85399;
424 if (($atype ==
"timestamp")) {
425 $pos = strpos($val,
' ');
427 $hms = substr($val, $pos + 1);
439 if (($atype ==
"timestamp") && ($op ==
"=")) {
442 if (strlen($val) == 10) {
444 $val2 = $val .
" 23:59:59";
447 } elseif (strlen($hms) == 2) {
448 $val2 = $val .
' ' . $hms .
":59:59";
449 $val.=
' ' . $hms .
":00:00";
451 } elseif (strlen($hms) == 5) {
452 $val2 = $val .
' ' . $hms .
":59";
453 $val.=
' ' . $hms .
":00";
461 if ($validateCond && in_array($op, array(
470 if ((
$err = $this->isValidTimestamp($val)) !=
'') {
485 $cond = sprintf(
" (%s is null or %s = 0) ", $col, $col);
490 $cond = sprintf(
" (%s is null) ", $col);
494 $cond = sprintf(
" (%s is null or %s = '') ", $col, $col);
500 $cond =
" " . $col .
" " . trim($op) .
" ";
505 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
509 if (trim($val) !=
"") {
510 $cond =
" " . $col .
" " . trim($op) .
" " . $this->_pg_val($val) .
" ";
516 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
520 if (trim($val) !=
"") {
521 $cond =
" " . $col .
"~* '^" . pg_escape_string(trim($val)) .
"' ";
526 if (!is_array($val)) {
529 foreach ($val as & $v) {
530 $v = self::pgRegexpQuote($v);
533 if (count($val) > 0) {
534 $cond =
" " . $col .
" ~ E'\\\\y(" . pg_escape_string(implode(
'|', $val)) .
")\\\\y' ";
539 if ((trim($val) !=
"") && (trim($val2) !=
"")) {
540 $cond = sprintf(
"%s >= %s and %s <= %s", $col, $this->_pg_val($val) , $col, $this->_pg_val($val2));
548 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
552 $err =
simpleQuery(
getDbAccessCore() , sprintf(
"select id from users where firstname ~* '%s' or lastname ~* '%s'", pg_escape_string($val) , pg_escape_string($val)) , $ids,
true);
554 if (count($ids) == 0) {
556 } elseif (count($ids) == 1) {
557 $cond =
" " . $col .
" = " . intval($ids[0]) .
" ";
559 $cond =
" " . $col .
" in (" . implode(
',', $ids) .
") ";
567 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
572 $otitle = $oa->getOption(
"doctitle");
575 if (!$fid && $oa->type ==
"account") {
579 $err = sprintf(_(
"no compatible type with operator %s") , $op);
581 if (!is_numeric($fid)) {
582 $fid = getFamidFromName($this->dbaccess, $fid);
584 $err =
simpleQuery($this->dbaccess, sprintf(
"select id from doc%d where title ~* '%s'", $fid, pg_escape_string($val)) , $ids,
true);
586 if (count($ids) == 0) {
588 } elseif (count($ids) == 1) {
589 $cond =
" " . $col .
" = '" . intval($ids[0]) .
"' ";
591 $cond =
" " . $col .
" in ('" . implode(
"','", $ids) .
"') ";
596 if ($otitle ==
"auto") {
597 $otitle = $oa->id .
"_title";
599 $oat = $this->searchfam->getAttribute($otitle);
601 $cond =
" " . $oat->id .
" ~* '" . pg_escape_string(trim($val)) .
"' ";
603 $err = sprintf(_(
"attribute %s : cannot detect title attribute") , $col);
606 } elseif ($col ==
"fromid") {
607 $err =
simpleQuery($this->dbaccess, sprintf(
"select id from docfam where title ~* '%s'", pg_escape_string($val)) , $ids,
true);
609 if (count($ids) == 0) {
611 } elseif (count($ids) == 1) {
612 $cond =
" " . $col .
" = " . intval($ids[0]) .
" ";
614 $cond =
" " . $col .
" in (" . implode(
",", $ids) .
") ";
622 $err = sprintf(_(
"attribute %s : %s type is not allowed with %s operator") , $col, $atype, $op);
624 $err = sprintf(_(
"attribute %s not found [%s]") , $col, $atype);
631 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
635 if (trim($val) !=
"") {
636 $cond =
" " . $col .
'_txt' .
" ~ '" . strtolower($val) .
"' ";
642 if (trim($val) !=
"") {
643 $tstatickeys = explode(
' ', $val);
644 if (count($tstatickeys) > 1) {
645 $keyword = str_replace(
" ",
"&", trim($val));
650 $cond =
" " . $col .
'_vec' .
" @@ to_tsquery('french','." . pg_escape_string(
unaccent(strtolower(
$keyword))) .
"') ";
651 } elseif ($op ==
"=@") {
652 $cond = sprintf(
"fulltext @@ to_tsquery('french','%s') ", pg_escape_string(
unaccent(strtolower(
$keyword))));
661 $enum = $oa->getEnum();
662 if (strrpos($val,
'.') !==
false) {
663 $val = substr($val, strrpos($val,
'.') + 1);
666 foreach ($enum as $k => $v) {
667 if (in_array($val, explode(
".", $k))) {
668 $tkids[] = substr($k, strrpos(
"." . $k,
'.'));
674 $cond =
" " . $col .
" ~ E'\\\\y(" . pg_escape_string(implode(
'|', $tkids)) .
")\\\\y' ";
676 $cond =
" $col='" . implode(
"' or $col='", $tkids) .
"'";
678 } elseif ($op ==
'!=') {
680 $cond1 =
" " . $col .
" !~ E'\\\\y(" . pg_escape_string(implode(
'|', $tkids)) .
")\\\\y' ";
682 $cond1 =
" $col !='" . implode(
"' and $col != '", $tkids) .
"'";
684 $cond =
" (($cond1) or ($col is null))";
685 } elseif ($op ==
'!~*') {
687 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
691 $cond = sprintf(
"( (%s is null) or (%s %s %s) )", $col, $col, trim($op) , $this->_pg_val($val));
697 if ($atype ==
"docid") {
698 if (!is_numeric($val)) $val =
getIdFromName($this->dbaccess, $val);
700 $cond1 =
" " . $col .
" " . trim($op) . $this->_pg_val($val) .
" ";
701 if (($op ==
'!=') || ($op ==
'!~*')) {
702 if ($validateCond && $op ==
'!~*') {
703 if ((
$err = $this->isValidPgRegex($val)) !=
'') {
707 $cond =
"(($cond1) or ($col is null))";
715 } elseif ($stateCol ==
"activity") {
716 $cond = sprintf(
"(%s and locked != -1)", $cond);
717 } elseif ($stateCol ==
"fixstate") {
718 $cond = sprintf(
"(%s and locked = -1)", $cond);
723 private static function _pg_val(
$s)
725 if (substr(
$s, 0, 2) ==
':@') {
726 return " " . trim(strtok(substr(
$s, 2) ,
" \t")) .
" ";
727 }
else return " '" . pg_escape_string(trim(
$s)) .
"' ";
745 $ol = isset($ols[1]) ? $ols[1] :
'';
751 if ($ol ==
"") $ol =
"and";
753 if (!$this->searchfam) {
756 if ((count($taid) > 1) || (count($taid) > 0 && $taid[0] !=
"")) {
758 foreach ($tkey as $k => $v) {
760 $methodName = $this->getMethodName($v);
761 if ($methodName !=
'') {
763 $workdoc = $this->getSearchFamilyDocument();
767 if (!$workdoc->isValidSearchMethod($workdoc, $methodName)) {
770 $rv = $workdoc->ApplyMethod($v);
773 if (substr($v, 0, 1) ==
"?") {
776 if ($rv ==
"-")
return (
false);
777 if ($rv ===
"" || $rv ===
" ") unset($taid[$k]);
778 else $tkey[$k] = $rv;
780 if ($taid[$k] ==
"revdate") {
781 if (substr_count($tkey[$k],
'/') === 2) {
782 list($dd, $mm, $yyyy) = explode(
"/", $tkey[$k]);
783 if ($yyyy > 0) $tkey[$k] = mktime(0, 0, 0, $mm, $dd, $yyyy);
787 foreach ($taid as $k => $v) {
788 $cond1 = $this->getSqlCond($taid[$k], trim($tf[$k]) , $tkey[$k],
"",
$err, $validateCond);
789 if ($validateCond &&
$err !=
'') {
790 throw new \Exception(
$err);
793 if (isset($tlp[$k]) && $tlp[$k] ==
"yes") $cond =
'(' . $cond1 .
" ";
794 else $cond = $cond1 .
" ";
795 if (isset($tlr[$k]) && $tlr[$k] ==
"yes") $cond.=
')';
796 } elseif ($cond1 !=
"") {
797 if (isset($tols[$k]) && $tols[$k] !=
"" && $ol ===
"perso") $ol1 = $tols[$k];
800 if ($ol1 ===
"perso") {
804 if (isset($tlp[$k]) && $tlp[$k] ==
"yes") $cond.= $ol1 .
' (' . $cond1 .
" ";
805 else $cond.= $ol1 .
" " . $cond1 .
" ";
806 if (isset($tlr[$k]) && $tlr[$k] ==
"yes") $cond.=
') ';
810 if (trim($cond) ==
"") $cond =
"true";
819 if (empty($tkey))
return false;
820 if ((count($tkey) > 1) || ($tkey[0] !=
"")) {
821 foreach ($tkey as $k => $v) {
823 if ($v && $v[0] ==
'?') {
838 if ((count($tkey) > 1) || (!empty($tkey[0]))) {
840 foreach ($tkey as $k => $v) {
842 if ($v && $v[0] ==
'?') {
843 if (
getHttpVars(substr($v, 1) ,
"-") ==
"-")
return true;
856 if ((count($tkey) > 1) || (isset($tkey[0]) && $tkey[0] !=
"")) {
858 foreach ($tkey as $k => $v) {
860 if ($v && $v[0] ==
'?') {
862 $l.=
'&' . substr($v, 1) .
"=" .
getHttpVars(substr($v, 1));
878 if ((count($tkey) > 1) || (isset($tkey[0]) && $tkey[0] !=
"")) {
880 foreach ($tkey as $k => $v) {
882 if ($v && $v[0] ==
'?') {
884 if (($vh !=
"-") && ($vh !=
"")) {
886 if (is_numeric($vh)) {
887 $fam = $this->getSearchFamilyDocument();
889 $oa = $fam->getAttribute($taid[$k]);
890 if ($oa && $oa->type ==
"docid") {
899 if (count($tl) > 0) {
900 $l =
" (" . implode(
", ", $tl) .
")";
911 function viewdsearch($target =
"_self", $ulink =
true, $abstract =
false)
920 $se_ol = $this->
getRawValue(\Dcp\AttributeIdentifiers\Dsearch::se_ol);
924 if ((count($taid) > 1) || (!empty($taid[0]))) {
927 $zpi = $fdoc->GetNormalAttributes();
928 $zpi[
"state"] = new \BasicAttribute(
"state", $this->fromid, _(
"step"));
929 $zpi[
"fixstate"] = new \BasicAttribute(
"fixstate", $this->fromid, _(
"state"));
930 $zpi[
"activity"] = new \BasicAttribute(
"activity", $this->fromid, _(
"activity"));
931 $zpi[
"title"] = new \BasicAttribute(
"title", $this->fromid, _(
"doctitle"));
932 $zpi[
"revdate"] = new \BasicAttribute(
"revdate", $this->fromid, _(
"revdate"));
933 $zpi[
"cdate"] = new \BasicAttribute(
"cdate", $this->fromid, _(
"cdate") ,
'W',
'',
'',
'date');
934 $zpi[
"revision"] = new \BasicAttribute(
"cdate", $this->fromid, _(
"revision"));
935 $zpi[
"owner"] = new \BasicAttribute(
"owner", $this->fromid, _(
"owner"));
936 $zpi[
"locked"] = new \BasicAttribute(
"owner", $this->fromid, _(
"locked"));
937 $zpi[
"allocated"] = new \BasicAttribute(
"owner", $this->fromid, _(
"allocated"));
938 $zpi[
"svalues"] = new \BasicAttribute(
"svalues", $this->fromid, _(
"any values"));
940 foreach ($taid as $k => $v) {
941 if (isset($zpi[$v])) {
942 $label = $zpi[$v]->getLabel();
943 if ($label ==
"") $label = $v;
944 if ($v ==
"activity") {
945 $fdoc->state = $tkey[$k];
946 $displayValue = $fdoc->getStatelabel();
948 $displayValue = ($tkey[$k] !=
"") ? _($tkey[$k]) : $tkey[$k];
950 $type = $zpi[$taid[$k]]->type;
951 if ($zpi[$taid[$k]]->isMultiple() || $zpi[$taid[$k]]->inArray()) {
953 else if (
$type ===
"account")
$type =
"account[]";
956 if ($se_ol ==
'perso') {
957 if (count($tcond) > 0) {
959 if (isset($se_ols[$k]) && $se_ols[$k] !=
'') {
960 $elmts[] = _($se_ols[$k]);
963 if (isset($se_leftp[$k]) && $se_leftp[$k] ==
'yes') {
967 if (isset($se_rightp[$k]) && $se_rightp[$k] ==
'yes') {
971 if (count($tcond) > 0) {
973 $elmts[] = _($se_ol);
977 $tcond[][
"condition"] = join(
' ', $elmts);
978 if (isset($tkey[$k][0]) && $tkey[$k][0] ==
'?') {
979 $tparm[substr($tkey[$k], 1) ] = $taid[$k];
985 $this->lay->SetBlockData(
"COND", $tcond);
987 $this->lay->Set(
"ddetail",
"");
1001 private function getSearchFamilyDocument()
1017 $tparm = $tcond = array();
1023 $zpi = $toperator = array();
1024 if ((count($taid) > 1) || ($taid[0] !=
"")) {
1027 $zpi = $fdoc->GetNormalAttributes();
1028 $zpi[
"state"] = new \BasicAttribute(
"state", $this->fromid, _(
"step"));
1029 $zpi[
"fixstate"] = new \BasicAttribute(
"state", $this->fromid, _(
"fixstate"));
1030 $zpi[
"activity"] = new \BasicAttribute(
"state", $this->fromid, _(
"activity"));
1031 $zpi[
"title"] = new \BasicAttribute(
"title", $this->fromid, _(
"doctitle"));
1032 $zpi[
"revdate"] = new \BasicAttribute(
"revdate", $this->fromid, _(
"revdate"));
1033 $zpi[
"cdate"] = new \BasicAttribute(
"cdate", $this->fromid, _(
"cdate") ,
'W',
'',
'',
'date');
1034 $zpi[
"revision"] = new \BasicAttribute(
"cdate", $this->fromid, _(
"revision"));
1035 $zpi[
"owner"] = new \BasicAttribute(
"owner", $this->fromid, _(
"owner"));
1036 $zpi[
"locked"] = new \BasicAttribute(
"owner", $this->fromid, _(
"locked"));
1037 $zpi[
"allocated"] = new \BasicAttribute(
"owner", $this->fromid, _(
"allocated"));
1038 $zpi[
"svalues"] = new \BasicAttribute(
"svalues", $this->fromid, _(
"any values"));
1040 foreach ($taid as $k => $v) {
1041 if ($tkey[$k][0] ==
'?') {
1042 $tparm[substr($tkey[$k], 1) ] = $taid[$k];
1043 $toperator[substr($tkey[$k], 1) ] = $tf[$k];
1046 $this->lay->SetBlockData(
"COND", $tcond);
1049 $this->lay->Set(
"ddetail",
"");
1050 if (count($tparm) > 0) {
1051 include_once (
"FDL/editutil.php");
1055 $doc = $this->getSearchFamilyDocument();
1056 $inputset = array();
1058 $tinputs = $ttransfert = array();
1059 foreach ($tparm as $k => $v) {
1060 if (isset($inputset[$v])) {
1062 $vz = $v .
"Z" . $ki;
1063 $zpi[$vz] = $zpi[$v];
1064 $zpi[$vz]->id = $vz;
1067 if ($zpi[$v]->fieldSet->type ==
'array') $zpi[$v]->fieldSet->type =
'frame';
1069 $inputset[$v] =
true;
1071 $ttransfert[] = array(
1076 $tinputs[$k][
"label"] = $zpi[$v]->getLabel();
1077 $type = $zpi[$v]->type;
1078 if ($zpi[$v]->isMultiple() || $zpi[$v]->inArray()) {
1080 else if (
$type ===
"account")
$type =
"account[]";
1083 if (($toperator[$k] ==
"=~*" || $toperator[$k] ==
"~*") && $zpi[$v]->
type ==
"docid") $zpi[$v]->type =
"text";
1084 if ($zpi[$v]->visibility ==
'R') $zpi[$v]->mvisibility =
'W';
1085 if ($zpi[$v]->visibility ==
'S') $zpi[$v]->mvisibility =
'W';
1086 if (isset($zpi[$v]->
id)) {
1087 $zpi[$v]->isAlone =
true;
1090 $aotxt = new \BasicAttribute($v,
$doc->id,
"eou");
1091 if ($v ==
"revdate") $aotxt->type =
"date";
1096 $this->lay->setBlockData(
"PARAM", $tinputs);
1097 $this->lay->setBlockData(
"TRANSFERT", $ttransfert);
1098 $this->lay->setBlockData(
"PINPUTS", $ttransfert);
1099 $this->lay->eSet(
"ddetail",
"none");
1100 $this->lay->eset(
"stext", _(
"send search"));
1101 $this->lay->eset(
"saction",
getHttpVars(
"saction",
"FREEDOM_VIEW"));
1102 $this->lay->eset(
"sapp",
getHttpVars(
"sapp",
"FREEDOM"));
1103 $this->lay->eset(
"sid",
getHttpVars(
"sid",
"dirid"));
1104 $this->lay->eset(
"starget",
getHttpVars(
"starget",
""));
1105 $this->lay->set(
"icon", $this->
getIcon());
1114 function editdsearch()
1120 $classid = GetHttpVars(
"sfamid", 0);
1122 $onlysubfam = GetHttpVars(
"onlysubfam");
1123 $dirid = GetHttpVars(
"dirid");
1125 $this->lay->set(
"ACTION", urlencode($action->name));
1126 $tclassdoc = array();
1127 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/lib/jquery/jquery.js");
1128 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FDL/Layout/edittable.js");
1129 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FREEDOM/Layout/editdsearch.js");
1136 if (method_exists(
$dir,
"isAuthorized")) {
1137 if (
$dir->isAuthorized($classid)) {
1139 if (
$dir->hasNoRestriction()) {
1140 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
1141 $tclassdoc[] = array(
1143 "title" => _(
"any families") ,
1147 $tclassdoc =
$dir->getAuthorizedFamilies();
1148 $this->lay->set(
"restrict",
true);
1151 $tclassdoc =
$dir->getAuthorizedFamilies();
1152 $first = current($tclassdoc);
1153 $famid1 = ($first[
"id"]);
1154 $this->lay->set(
"restrict",
true);
1155 $tfamids = array_keys($tclassdoc);
1159 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
1163 if (!is_numeric($onlysubfam)) $onlysubfam =
getFamIdFromName($this->dbaccess, $onlysubfam);
1164 $cdoc =
\new_Doc($this->dbaccess, $onlysubfam);
1165 $tsub = $cdoc->GetChildFam($cdoc->id,
false);
1166 $tclassdoc[$classid] = array(
1168 "title" => $cdoc->title,
1172 $tclassdoc = array_merge($tclassdoc, $tsub);
1174 if (!$this->
id) $this->
setValue(
"se_famonly", $alsosub ?
"no" :
"yes");
1175 $first = current($tclassdoc);
1176 if ($classid ==
"") $classid = $first[
"id"];
1178 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
1179 $tclassdoc[] = array(
1181 "title" => _(
"any families") ,
1186 $sLabelArray = array();
1187 foreach ($this->top as $k => $v) {
1189 if (isset($v[
"slabel"]) && is_array($v[
"slabel"])) {
1190 foreach ($v[
"slabel"] as $key =>
$value) {
1191 $sLabel[$key] = _(
$value);
1194 $sLabelArray[$k] = array(
1195 "label" => _($v[
"label"]) ,
1199 $this->lay->set(
"topInformation", json_encode($sLabelArray));
1200 $this->lay->set(
"onlysubfam", urlencode($onlysubfam));
1202 $selectclass = array();
1203 foreach ($tclassdoc as $k =>
$tdoc) {
1204 $selectclass[$k][
"idcdoc"] =
$tdoc[
"id"];
1205 $selectclass[$k][
"classname"] =
$tdoc[
"title"];
1206 $selectclass[$k][
"system_fam"] = (substr(
$tdoc[
"usefor"], 0, 1) ==
'S') ?
true :
false;
1209 $selectclass[$k][
"selected"] =
'selected="selected"';
1210 if (
$famid < 0) $this->lay->set(
"selfam",
$tdoc[
"title"] .
" " . _(
"(only)"));
1211 else $this->lay->set(
"selfam",
$tdoc[
"title"]);
1212 }
else $selectclass[$k][
"selected"] =
"";
1216 if ($this->
id &&
$famid) {
1217 $selectclass[] = array(
1220 "selected" =>
"selected"
1224 $first = current($tclassdoc);
1228 $this->lay->Set(
"dirid", urlencode(
$dirid));
1229 $this->lay->Set(
"classid", $this->fromid);
1230 $this->lay->SetBlockData(
"SELECTCLASS", $selectclass);
1231 $this->lay->set(
"has_permission_fdl_system", $action->parent->hasPermission(
'FDL',
'SYSTEM'));
1232 $this->lay->set(
"se_sysfam", ($this->
getRawValue(
'se_sysfam') ==
'yes') ?
true :
false);
1237 "title" => _(
"doctitle") ,
1238 "revdate" => _(
"revdate") ,
1239 "cdate" => _(
"cdate") ,
1240 "revision" => _(
"revision") ,
1241 "owner" => _(
"id owner") ,
1242 "locked" => _(
"id locked") ,
1243 "allocated" => _(
"id allocated") ,
1244 "svalues" => _(
"any values")
1247 $tattr[
"_prop"] = array(
1248 "attrid" =>
"_prop",
1249 "attrtype" =>
"set",
1250 "attrdisabled" =>
"disabled",
1251 "attrname" => _(
"DocProperties") ,
1252 "ismultiple" =>
'no'
1255 foreach ($internals as $k => $v) {
1256 if ($k ==
"revdate")
$type =
"date";
1257 else if ($k ==
"owner")
$type =
"uid";
1258 else if ($k ==
"locked")
$type =
"uid";
1259 else if ($k ==
"allocated")
$type =
"uid";
1260 else if ($k ==
"cdate")
$type =
"date";
1261 else if ($k ==
"revision")
$type =
"int";
1262 else if ($k ==
"state")
$type =
"docid";
1263 else $type =
"text";
1267 "ismultiple" =>
'no',
1268 "attrtype" =>
$type,
1269 "attrdisabled" =>
"",
1276 $zpi = $fdoc->GetNormalAttributes();
1278 foreach ($zpi as $k => $v) {
1279 if ($v->type ==
"array" || $v->type ==
"password") {
1282 $opt_searchcriteria = $v->getOption(
"searchcriteria",
"");
1283 if ($opt_searchcriteria ==
"hidden" || $opt_searchcriteria ==
"restricted") {
1288 if ($v->getOption(
"doctitle") && $v->isMultiple())
$type =
"docidtitle[]";
1289 $tset = $this->editGetSetAttribute($v->fieldSet);
1290 if (count($tset) > 0) $tattr = array_merge($tattr, array_reverse($tset));
1292 $tattr[$v->id] = array(
1294 "ismultiple" => ($v->isMultiple()) ?
'yes' :
'no',
1295 "attrtype" =>
$type,
1296 "attrdisabled" =>
"",
1297 "attrname" => $v->getLabel()
1300 if ($action->getParam(
"ISIE6")) {
1302 foreach ($tattr as $ka => $va) {
1303 if (!empty($va[
"attrdisabled"])) unset($tattr[$ka]);
1306 $this->lay->SetBlockData(
"ATTR", $tattr);
1308 foreach ($this->top as $k => $v) {
1310 if (isset($v[
"type"])) {
1311 $ctype = implode(
",", $v[
"type"]);
1312 if (!in_array(
'text', $v[
"type"])) $display =
'none';
1318 "functype" => $ctype,
1319 "funcdisplay" => $display,
1320 "funcname" => _($v[
"label"])
1323 $this->lay->SetBlockData(
"FUNC", $tfunc);
1324 foreach ($tfunc as $k => $v) {
1325 if (($v[
"functype"] !=
"") && (strpos($v[
"functype"],
"enum") ===
false)) unset($tfunc[$k]);
1327 $this->lay->SetBlockData(
"FUNCSTATE", $tfunc);
1328 $this->lay->Set(
"icon", $fdoc->getIcon());
1330 if ($this->
getRawValue(
"SE_LATEST") ==
"no") $this->lay->Set(
"select_all",
"selected");
1331 else $this->lay->Set(
"select_all",
"");
1336 if ($fdoc->wid > 0) {
1341 $states =
$wdoc->getStates();
1344 foreach ($states as $k => $v) {
1348 "statename" => _($v)
1350 $activity =
$wdoc->getActivity($v);
1353 "step" =>
"activity",
1355 "statename" => ($activity) ? _($activity) : _($v)
1358 $this->lay->SetBlockData(
"STATE", $tstates);
1359 $this->lay->Set(
"dstate",
"inline");
1361 $this->lay->Set(
"dstate",
"none");
1374 if ((count($taid) > 1) || ($taid && $taid[0] !=
"")) {
1375 foreach ($taid as $k => $keyId) {
1378 $oa = $fdoc->getAttribute($keyId);
1380 "OLCOND" =>
"olcond$k",
1381 "ATTRCOND" =>
"attrcond$k",
1382 "FUNCCOND" =>
"funccond$k",
1383 "ISENUM" => (($keyId ==
"state") || ($keyId ==
"fixstate") || ($keyId ==
"activity") || ($oa && $oa->type ==
"enum")) ,
1384 "SSTATE" =>
"sstate$k",
1385 "ols_and_selected" => (
$tol[$k] ==
"and") ?
"selected" :
"",
1386 "ols_or_selected" => (
$tol[$k] ==
"or") ?
"selected" :
"",
1387 "leftp_none_selected" => ($tlp[$k] !=
"yes") ?
"selected" :
"",
1388 "leftp_open_selected" => ($tlp[$k] ==
"yes") ?
"selected" :
"",
1389 "rightp_none_selected" => ($trp[$k] !=
"yes") ?
"selected" :
"",
1390 "rightp_open_selected" => ($trp[$k] ==
"yes") ?
"selected" :
"",
1394 $tattrSelect = array();
1395 if ($keyId ==
"state" || ($keyId ==
"fixstate") || ($keyId ==
"activity")) {
1397 $stateselected =
false;
1398 foreach ($states as $ks => $vs) {
1399 if ($keyId !=
"activity") {
1403 "sstate_selected" => ($vs == $v) ?
"selected" :
"",
1404 "sstatename" => _($vs)
1407 $activity =
$wdoc->getActivity($vs);
1410 "sstep" =>
"activity",
1411 "sstate_selected" => ($vs == $v) ?
"selected" :
"",
1412 "sstatename" => ($activity) ? _($activity) : _($vs)
1415 if ($vs == $v) $stateselected =
true;
1417 if (!$stateselected) $tcond[$k][
"ISENUM"] =
false;
1418 $this->lay->SetBlockData(
"sstate$k", $tstates);
1420 $tattrSelect[] = array(
1422 "ismultiple" =>
'no',
1423 "attrtype" =>
"enum",
1424 "attrdisabled" =>
'',
1425 "attrselected" =>
"selected",
1426 "attrname" => _($keyId)
1429 if ($oa && $oa->type ==
"enum") {
1433 $te = $oa->getEnum();
1435 $enumselected =
false;
1436 foreach ($te as $ks => $vs) {
1439 "sstate_selected" => ($ks == $v) ?
"selected" :
"",
1442 if ($ks == $v) $enumselected =
true;
1444 $this->lay->SetBlockData(
"sstate$k", $tstates);
1445 if (!$enumselected) $tcond[$k][
"ISENUM"] =
false;
1448 $tattrSelect = $tattr;
1449 foreach ($tattrSelect as $ki => $vi) {
1450 $tattrSelect[$ki][
"attrselected"] =
"";
1453 foreach ($internals as $ki => $vi) {
1454 if (isset($tattrSelect[$ki])) {
1455 $tattrSelect[$ki][
"attrselected"] = ($keyId == $ki) ?
"selected" :
"";
1459 $this->editGetSetAttribute(null,
true);
1460 foreach ($zpi as $ki => $vi) {
1461 if (isset($tattrSelect[$ki])) {
1462 $tattrSelect[$vi->id][
"attrselected"] = ($keyId == $vi->id) ?
"selected" :
"";
1466 $this->lay->SetBlockData(
"attrcond$k", $tattrSelect);
1469 foreach ($this->top as $ki => $vi) {
1470 $oa = $fdoc->getAttribute($keyId);
1471 if ($oa)
$type = $oa->type;
1474 if ($keyId ==
"title")
$type =
"text";
1475 elseif ($keyId ==
"cdate")
$type = "date";
1476 elseif ($keyId == "fixstate")
$type = "enum";
1477 elseif ($keyId == "activity")
$type = "enum";
1479 elseif ($keyId == "allocated")
$type = "uid";
1480 elseif ($keyId == "locked")
$type = "uid";
1481 elseif ($keyId == "revdate")
$type = "date";
1482 elseif ($keyId == "owner")
$type = "uid";
1483 elseif ($keyId == "svalues")
$type = "text";
1484 elseif ($keyId == "state")
$type = "enum";
1486 if (($oa->isMultiple() || $oa->inArray()) &&
$type ===
"docid")
$type =
"docid[]";
1487 else if (($oa->isMultiple() || $oa->inArray()) &&
$type ===
"account")
$type =
"account[]";
1488 else if ($oa->inArray() && ($oa->type !=
'file'))
$type =
"array";
1492 if (isset($vi[
"type"])) {
1493 if (!in_array(
$type, $vi[
"type"])) $display =
'none';
1494 $ctype = implode(
",", $vi[
"type"]);
1496 if ($tf[$k] == $ki && $display ==
'' && (((
$type ==
'docid' ||
$type ==
'account') && ($ki ==
'=' || $ki ==
'!=')) || ((
$type ==
'docid[]' ||
$type ==
'account[]') && $ki ==
'~y'))) {
1497 $docid_aid = $keyId;
1501 "func_selected" => ($tf[$k] == $ki) ?
"selected" :
"",
1502 "func_display" => $display,
1503 "func_type" => $ctype,
1508 $this->lay->SetBlockData(
"funccond$k", $tfunc);
1511 foreach ($this->tol as $ki => $vi) {
1514 "ol_selected" => (
$tol[$k] == $ki) ?
"selected" :
"",
1518 $this->lay->SetBlockData(
"olcond$k", $tols);
1520 if ((is_numeric($v) || empty($v)) && isset($docid_aid) && !empty($docid_aid)) {
1521 $tcond[$k][
"ISENUM"] =
false;
1522 $tcond[$k][
"ISDOCID"] =
true;
1523 $tcond[$k][
"ISDOCIDMULTIPLE"] = $oa->isMultiple();
1524 $tcond[$k][
"DOCID_AID"] = $docid_aid;
1525 $tcond[$k][
"DOCID_AIDINDEX"] = $docid_aid . $k;
1526 $tcond[$k][
"DOCID_TITLE"] = $this->
getTitle($v);
1527 $tcond[$k][
"FAMID"] = abs(
$famid);
1528 $tcond[$k][
"ISSEARCHMETHOD"] =
false;
1530 $tcond[$k][
"ISDOCID"] =
false;
1531 $tcond[$k][
"ISDOCIDMULTIPLE"] =
false;
1532 $tcond[$k][
"DOCID_AID"] = 0;
1533 $tcond[$k][
"DOCID_AIDINDEX"] = 0;
1534 $tcond[$k][
"DOCID_TITLE"] =
'';
1535 $tcond[$k][
"FAMID"] = abs(
$famid);
1536 $isSearchMethod =
false;
1538 $attrType = $oa->type;
1539 if ($oa->format !=
'') {
1541 $attrType = sprintf(
'%s("%s")', $attrType, $oa->format);
1543 $methods = $tmpDoc->getSearchMethods($oa->id, $attrType);
1545 foreach ($methods as
$method) {
1546 if ($method[
'method'] == $v) {
1547 $isSearchMethod =
true;
1552 $tcond[$k][
"ISSEARCHMETHOD"] = $isSearchMethod;
1556 if (count($tcond) > 0) $this->lay->SetBlockData(
"CONDITIONS", $tcond);
1559 foreach ($zpi as $k => $v) {
1560 if (($v->type ==
"enum") || ($v->type ==
"enumlist")) {
1562 "SELENUM" =>
"ENUM$k",
1565 $tenum = $v->getEnum();
1567 foreach ($tenum as $ke => $ve) {
1568 if ($ke ===
' ' || $ke ===
'') {
1576 $this->lay->setBlockData(
"ENUM$k", $te);
1580 $this->lay->setBlockData(
"ENUMS", $tenums);
1582 $this->lay->Set(
"id", $this->
id);
1590 private function editGetSetAttribute($fs,
$reset =
false)
1592 static $setAttribute = array();
1595 if (
$reset) $setAttribute = array();
1596 while ($fs && $fs->id != \Adoc::HIDDENFIELD) {
1597 if (!in_array($fs->id, $setAttribute)) {
1598 $tset[$fs->id] = array(
1599 "attrid" => $fs->id,
1600 "attrtype" =>
"set",
1601 "attrdisabled" =>
"disabled",
1602 "attrselected" =>
"",
1603 "attrname" => $fs->getLabel()
1605 $setAttribute[] = $fs->id;
1607 $fs = $fs->fieldSet;
1615 private function getMethodName($methodStr)
1617 $parseMethod = new \parseFamilyMethod();
1618 $parseMethod->parse($methodStr);
1619 $err = $parseMethod->getError();
1623 return $parseMethod->methodName;
1631 return preg_replace_callback(
'/[.|*+?{}\[\]()\\\\^$]/u',
function ($m)
1633 return sprintf(
'\\u00%x', ord($m[0]));
ComputeQuery($keyword="", $famid=-1, $latest="yes", $sensitive=false, $dirid=-1, $subfolder=true, $full=false)
& getAttribute($idAttr, &$oa=null, $useMask=true)
static getDate($daydelta=0, $dayhour="", $daymin="", $getlocale=false)
stringDateToIso($date, $format=false, $withT=false)
getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters=array(), $distinct=false, $latest=true, $trash="", $simplesearch=false, $folderRecursiveLevel=2, $join= '', $only="")
viewdsearch($target="_self", $ulink=true, $abstract=false)
static rawValueToArray($v)
getIcon($idicon="", $size=null, $otherId=null)
viewattr($target="_self", $ulink=true, $abstract=false, $viewhidden=false)
getLocaleConfig($core_lang= '')
static pgRegexpQuote($str)
simpleXml2StdClass(\SimpleXMLElement $xml)
getSqlGeneralFilters($keyword, $latest, $sensitive, $full=false)
getOperatorLabel($operator, $attributeType)
modify($nopost=false, $sfields="", $nopre=false)
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
getHtmlInput(&$doc, &$oattr, $value, $index="", $jsevent="", $notd=false)
setValue($attrid, $value, $index=-1, &$kvalue=null)
getMultipleRawValues($idAttr, $def="", $index=-1)
revision(Action &$action)
getHttpVars($name, $def="", $scope="all")
if($updateExistingTable) $point
getFamIdFromName($dbaccess, $name)
object2SqlFilter($of, &$famid, &$fsql)
getTitle($id="-1", $def="", $latest=false)
getRChildDirId($dbaccess, $dirid, $rchilds=array(), $level=0, $levelmax=2)
deprecatedFunction($msg= '')
new_Doc($dbaccess, $id= '', $latest=false)
editmode(Action &$action)
if(($docid!==0)&&(!is_numeric($docid))) $query
getIdFromName($dbaccess, $name)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
if($file) if($subject==""&&$file) if($subject=="") $err
getRawValue($idAttr, $def="")
paramdsearch($target="_self", $ulink=true, $abstract=false)
getSqlDetailFilter($validateCond=false)
isValidCondition($attr, $op, $value)