17 include_once (
"FDL/Class.Dir.php");
18 include_once (
"FDL/Lib.Dir.php");
27 else $fname = sprintf(_(
"file %d") , $th->initid);
29 $fname = sprintf(_(
"file %d") , $th->initid);
47 if (
$doc->isAffected())
return array(
65 if ($soc->isAffected()) {
69 $a = $soc->getAttribute($attrid);
86 $sf->setObjectReturn();
87 $sf->overrideViewControl();
88 $sf->addFilter(
"atags ~* 'MAILRECIPIENT'");
89 $dlf = $sf->search()->getDocumentList();
91 if ($dlf->count() == 0)
return sprintf(_(
"none families are described to be used as recipient"));
92 foreach ($dlf as $fam) {
97 if (!method_exists($cfam,
"getMail"))
return sprintf(_(
"family %s does not implement IMailRecipent - missing getMail method") , $fam->name);
98 if (!method_exists($cfam,
"getMailAttribute"))
return sprintf(_(
"family %s does not implement IMailRecipent - missing getMailAttribute method") , $fam->name);
99 if (!method_exists($cfam,
"getMailTitle"))
return sprintf(_(
"family %s does not implement IMailRecipient - missing getMailTitle method") , $fam->name);
101 $mailAttr = $cfam->getMailAttribute();
103 $s->setObjectReturn();
105 if ($mailAttr)
$s->addFilter(
"%s is not null", $mailAttr);
107 if ($mailAttr)
$s->addFilter(
"(title ~* '%s') or (%s ~* '%s')", $name, $mailAttr, $name);
108 else $s->addFilter(
"(title ~* '%s')", $name, $name);
110 $dl =
$s->search()->getDocumentList();
111 foreach ($dl as
$dest) {
115 $mailTitle = $dest->getMailTitle();
116 $mail = $dest->getMail();
117 if ($mailTitle ==
'') {
120 $usw = $dest->getRawValue(
"us_whatid");
138 usort($tr,
function (
$a, $b)
140 return strcasecmp(
$a[0], $b[0]);
154 return _(
"family must be defined");
162 return _(
"family must be defined");
171 return _(
"family must be defined");
180 return _(
"family must be defined");
189 return _(
"family must be defined");
195 return _(
"cycle family must be defined");
203 return _(
"cycle family must be defined");
211 return _(
"cycle family must be defined");
219 return _(
"family must be defined");
227 return _(
"cycle family must be defined");
238 return recipientDocument(
$dbaccess, $name);
241 return "error tplmail($dbaccess,$type,$famid, $name)";
249 if (is_array($users)) {
250 foreach ($users as $k => $v) {
251 $users[$k][1] = $v[1] .
' (' . $v[2] .
')';
262 include_once (
"Class.QueryDb.php");
266 $q->AddQuery(
"isglob = 'Y'");
267 if ($name)
$q->AddQuery(
"name ~* '" . pg_escape_string($name) .
"'");
268 $q->order_by =
"name";
269 $la =
$q->Query(0, 20,
"TABLE");
270 foreach (
$la as $k => $v) {
271 $p = $v[
"name"] .
' (' . $v[
"descr"] .
')';
287 $tinter =
$doc->getParamAttributes();
289 $tinter =
$doc->GetNormalAttributes();
291 $name = strtolower($name);
293 $pattern_name = preg_quote($name,
"/");
294 $pattern_type = (
$type);
295 foreach ($tinter as $k => $v) {
296 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $v->getLabel() , $reg)) || (preg_match(
"/$pattern_name/", $v->id, $reg))) {
297 preg_match(
"/$pattern_type/", $v->type, $reg);
298 if ((
$type ==
"") || ($v->type ==
$type) || ((strpos(
$type,
'|') > 0) && (preg_match(
"/$pattern_type/", $v->type, $reg)))) {
299 $r = $v->id .
' (' . $v->getLabel() .
')';
318 if (!is_numeric($subfam)) {
322 $tinter = $cdoc->GetChildFam();
323 $tinter[] = get_object_vars($cdoc);
328 $name = strtolower($name);
330 $pattern_name = preg_quote($name,
"/");
331 foreach ($tinter as $v) {
333 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $ftitle, $reg))) {
365 if (!is_numeric(
$famid)) {
369 return sprintf(_(
"family %s not found") , $famName);
388 if ($name !=
"" && is_string($name)) {
389 if (!$withDiacritic) {
392 $s->addFilter(
"title ~* '%s'", $name);
397 $s->returnsOnly(array(
401 $tinter =
$s->search();
402 if (
$s->getError()) {
403 return $s->getError();
408 foreach ($tinter as $k => $v) {
410 htmlspecialchars($v[
"title"]) ,
426 "a|à |á|â|ã|ä|å",
427 "o|ò|ó|ô|õ|ö|ø",
435 foreach ($dias as $dia) {
436 $text = preg_replace(
"/[" . str_replace(
"|",
"", $dia) .
"]/u",
"[$dia]", $text);
476 if (!is_numeric(
$famid)) {
481 $name = pg_escape_string($name);
482 $filter[] =
"title ~* '$name'";
485 $args = func_get_args();
486 foreach (
$args as $k => $v) {
487 if ($k > 2) $attr[] = strtolower($v);
495 foreach ($tinter as $k => $v) {
499 foreach ($attr as
$a) {
522 $name = pg_escape_string($name);
523 $filter[] =
"title ~* '.*$name.*'";
530 foreach ($tinter as $k => $v) {
549 $famname = explode(
'|', $families);
551 foreach ($famname as
$famid) {
552 if (count(
$tout) < $limit) {
554 if ($filterName)
$s->addFilter(
"title ~* '%s'", $filterName);
555 if ($extraFilter)
$s->addFilter($extraFilter);
556 $s->setSlice($limit);
557 $s->setObjectReturn();
559 if (
$s->getError())
return $s->getError();
561 while (
$doc =
$s->getNextDoc()) {
564 sprintf(
'<img width="10px" src="%s">%s',
$doc->getIcon(
'', 10) ,
$title) ,
571 if ((count(
$tout) == 0) && ($filterName !=
''))
return sprintf(_(
"no document match '%s'") , $filterName);
584 $searchinmail =
false;
586 $s->setSlice($limit);
587 if (preg_match(
'/usemailfilter\s*=([^|]*)/', $options, $regMatch)) {
588 $searchinmail = trim($regMatch[1]);
589 $searchinmail = ($searchinmail ==
"yes");
591 if (preg_match(
'/role\s*=([^|]*)/', $options, $regRole)) {
592 $roles = explode(
',', $regRole[1]);
594 foreach ($roles as $role) {
596 $s->addRoleFilter($role);
598 catch(Exception $e) {
599 return $e->getMessage();
603 if (preg_match(
'/group\s*=([^|]*)/', $options, $regGroup)) {
604 $groups = explode(
',', $regGroup[1]);
606 foreach ($groups as $group) {
608 $s->addGroupFilter($group);
610 catch(Exception $e) {
611 return $e->getMessage();
616 if (preg_match(
'/match\s*=([^|]*)/', $options, $regMatch)) {
617 $match = trim($regMatch[1]);
623 $s->setTypeFilter($s::groupType);
627 $s->setTypeFilter($s::roleType);
631 $s->setTypeFilter($s::userType);
634 $s->setTypeFilter($s::userType);
637 if (preg_match(
'/family\s*=([^|]*)/', $options, $regMatch)) {
638 $match = trim($regMatch[1]);
639 $s->filterFamily($match);
645 $tname = explode(
' ', $filterName);
647 if ($searchinmail) $condmail = sprintf(
"|| ' ' || coalesce(mail,'')");
648 foreach ($tname as $name) {
649 if ($condName) $condName.=
" AND ";
650 $condName.= sprintf(
"(coalesce(firstname,'') || ' ' || coalesce(lastname,'') %s ~* '%s')", $condmail, pg_escape_string(
setDiacriticRules($name)));
654 if ($condName)
$s->addFilter($condName);
655 if (!$sort) $sort =
'lastname';
657 $s->overrideViewControl(
false);
661 $mail = $account->mail ? (
' (' . mb_substr($account->mail, 0, 40) .
')') :
'';
663 htmlspecialchars($account->lastname .
" " . $account->firstname . $mail) ,
665 $account->lastname .
" " . $account->firstname
681 $tenum = explode(
"|", $enum);
685 $pattern_val = preg_quote($val,
"/");
686 foreach ($tenum as $k => $v) {
688 if (($val ==
"") || (preg_match(
"/$pattern_val/i", $v, $reg))) $tr[] = array(
709 $enumAttribute =
$doc->getAttribute($attrid);
710 if (!$enumAttribute) {
711 return sprintf(
"enum attribute %s not found [family %s]", $attrid,
$famid);
713 $tenumLabel = $enumAttribute->getEnumLabel(null,
false);
715 foreach ($tenumLabel as $key => $label) {
716 if (($val ==
"") || (preg_match(
"!" . preg_quote($val,
"!") .
"!iu", $label, $reg))) {
718 htmlspecialchars($label, ENT_NOQUOTES) ,
739 $val = str_replace(array(
746 $val = str_replace(array(
753 $enum = str_replace(array(
763 $tenum = $tenumLabel = array();
766 foreach ($tenumLabel as $key => $label) {
767 $slabel = str_replace(array(
774 if (($val ==
"") || (preg_match(
"!" . preg_quote($val,
"!") .
"!i", $slabel, $reg))) $tr[] = array(
805 if ($maskfamid > 0) {
807 $chdoc = $mdoc->GetFromDoc();
820 $chdoc = $mdoc->GetFromDoc();
831 $chdoc = $mdoc->GetFromDoc();
832 $filter[] =
"tmail_family is null or (" .
GetSqlCond($chdoc,
"tmail_family") .
')';
842 $chdoc = $mdoc->GetFromDoc();
854 "fromid=5 or fromid=16"
865 "fromid=5 or fromid=16"
871 $all = array_merge($ls, $fld);
884 if ($tview ==
"VEDIT") $tz = $cdoc->eviews;
885 else $tz = $cdoc->cviews;
887 $tz = array_merge($oz, $tz);
890 if ($tview ==
"VEDIT") $tz = $fdoc->eviews;
891 else $tz = $fdoc->cviews;
900 $tz = array_unique($tz);
902 foreach ($tz as $v) {
916 if (is_array($tidview)) {
917 foreach ($tidview as $k => $v) {
918 $currentViewId = trim($v);
919 if (
'' !== $currentViewId) {
920 $currentViewlabel = $tlview[$k];
922 htmlspecialchars(sprintf(
"%s (%s)", $currentViewlabel, $currentViewId)) ,
924 sprintf(
"%s (%s)", $currentViewlabel, $currentViewId)
945 $pattern = preg_quote($name,
"/");
948 "title" => _(
"doctitle") ,
949 "revdate" => _(
"revdate") ,
950 "revision" => _(
"revision") ,
951 "owner" => _(
"owner") ,
952 "state" => _(
"step") ,
953 "id" => _(
"document id")
955 foreach ($propList as $propName => $propLabel) {
956 if (($name ==
"") || (preg_match(
"/$pattern/i", $propLabel, $m))) {
973 if ($attr->type ==
"array")
continue;
974 if (($name ==
"") || (preg_match(
"/$pattern/i", $attr->getLabel() , $m))) {
975 $html =
'<b><i>' .
_getParentLabel($attr) .
'</i></b><br/><span> ' . $attr->getLabel() .
'</span>';
982 if (in_array($attr->type, $relTypes)) {
983 $html =
'<b><i>' .
_getParentLabel($attr) .
'</i></b><br/><span> ' . $attr->getLabel() .
'<i> (' . _(
"report:docid") .
')</i></span>';
987 sprintf(
"%s (%s)", $attr->getLabel() , _(
"report:docid")) ,
996 function reportChooseColumns(&
$action, $id)
1004 $doc = new_doc(
"", $id);
1005 if (
$doc->doctype ==
"C") {
1007 $doc->setValue(\Dcp\AttributeIdentifiers\Report::se_famid,
getHttpVars(
"_se_famid"));
1010 $doc->reportchoosecolumns();
1025 $pattern = preg_quote($name,
"/");
1028 foreach ($propList as $prop) {
1029 if (($name ==
"") || (preg_match(
"/$pattern/i", $prop[1], $m))) {
1036 if (($name ==
"") || (preg_match(
"/$pattern/i", $attr->getLabel() , $m))) {
1037 $html =
'<b><i>' .
_getParentLabel($attr) .
'</i></b><br/><span> ' . $attr->getLabel() .
'</span>';
1042 $attr->getOption(
'sortable')
1061 $pattern_name = preg_quote($name,
"/");
1065 $tinter =
$doc->GetSortAttributes();
1067 $tinter =
$doc->GetNormalAttributes();
1070 foreach ($tinter as $k => $v) {
1071 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $v->getLabel() , $reg))) {
1072 $dv =
'<b><i>' .
_getParentLabel($v) .
'</i></b><br/><span> ' . $v->getLabel() .
'</span>';
1077 $v->getOption(
'sortable')
1094 $pattern = preg_quote($name,
"/");
1096 $props = $docfam->getSortProperties();
1098 foreach ($props as $propName => $config) {
1099 if ($config[
'sort'] !=
'asc' && $config[
'sort'] !=
'desc') {
1103 switch ($propName) {
1105 if ($docfam->wid <= 0) {
1116 $label = _(
"state");
1120 $label = _(
"doctitle");
1124 $label = _(
"createdate");
1134 if ($name !=
"" && !preg_match(
"/$pattern/i", $label)) {
1153 if ($oa && $oa->fieldSet && $oa->fieldSet->id != Adoc::HIDDENFIELD) {
1154 return _getParentLabel($oa->fieldSet) . $oa->fieldSet->getLabel() .
'/';
1162 $filter[] =
"act_type='$type'";
1173 if ($n !=
"")
$q->AddQuery(
"name ~* '$n'");
1174 $la =
$q->Query(0, 0,
"TABLE");
1175 if (is_array(
$la)) {
1176 foreach (
$la as $k => $v) {
1178 $v[
"name"] .
":" . $v[
"short_name"],
1192 $q->AddQuery(
"name = '$app'");
1193 $la =
$q->Query(0, 0,
"TABLE");
1198 $q->AddQuery(
"id_application = $appid");
1199 if ($n !=
"")
$q->AddQuery(
"name ~* '$n'");
1200 $la =
$q->Query(0, 0,
"TABLE");
1203 foreach (
$la as $k => $v) {
1205 $v[
"name"] .
":" . _($v[
"short_name"]) ,
1217 $cmd = sprintf(
"cd %s/API;ls -1 *.php| cut -f1 -d'.'", escapeshellarg(
DEFAULT_PUBDIR));
1218 $apis = shell_exec(
$cmd);
1219 $tapi = explode(
"\n", $apis);
1223 $pattern_name = preg_quote($name,
"/");
1224 foreach ($tapi as $k => $v) {
1226 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $v0, $reg))) $tr[] = array(
1239 if (
$doc && method_exists(
$doc,
"getStates")) {
1243 $states =
$doc->getStates();
1245 $pattern_name = preg_quote($name,
"/");
1246 foreach ($states as $k => $v) {
1247 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $v, $reg))) $tr[] = array(
1248 $v .
' (' . _($v) .
')',
1252 }
else return sprintf(_(
"need to select workflow"));
1261 if (
$doc->isAlive() &&
$doc->wid) {
1263 if ($wdoc && method_exists($wdoc,
"getStates")) {
1267 $states = $wdoc->getStates();
1269 $pattern_name = preg_quote($name,
"/");
1270 foreach ($states as $k => $v) {
1271 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $v, $reg))) $tr[] = array(
1272 $v .
' (' . _($v) .
')',
1273 $v .
' (' . _($v) .
')'
1276 }
else return sprintf(_(
"no workflow for this document"));
1277 }
else return sprintf(_(
"no workflow for this document"));
1287 $methods = get_class_methods(
$doc);
1288 $pattern_name = preg_quote($name,
"/");
1289 foreach ($methods as $k => $v) {
1290 if (($name ==
"") || (preg_match(
"/$pattern_name/i", $v, $reg))) $tr[] = array(
1295 }
else return sprintf(_(
"need to select family"));
1310 return sprintf(_(
"connexion to %s has failed") ,
$dbaccess);
1313 $args = func_get_args();
1317 foreach (
$args as $k => $v) {
1319 if (substr($v, -2) ==
":H") {
1320 $v = substr($v, 0, -2);
1322 if (!$order) $order = strtolower($v);
1325 $cols[] = (strtolower($v));
1328 if (count($cols) == 0) {
1329 return sprintf(_(
"no columns specified"));
1331 if (count($tdn) == 0) {
1332 return sprintf(_(
"all columns are hiddens"));
1335 $select =
"select " . implode(
",", $cols);
1336 $from =
"from " . pg_escape_string($table);
1337 $orderby =
"order by " . ($order);
1338 foreach (
$_POST as $k => $v) {
1340 $filter = preg_replace(
'/' . substr($k, 1) .
'/i', pg_escape_string(trim(stripslashes($v))) ,
$filter);
1344 $where =
"where $filter";
1345 $limit =
"limit 100";
1346 $sql = $select .
' ' .
$from .
' ' . $where .
' ' . $orderby .
' ' . $limit;
1349 return sprintf(_(
"query %s has failed") ,
$sql);
1354 while ($row = pg_fetch_row($result)) {
1356 foreach ($tdn as $vi) $dn.= $row[$vi] .
' ';
1358 foreach ($row as $ki => $vi) $t[$kr][] = $vi;
1365 function recipientDocument(
$dbaccess, $name)
1369 $sf->setObjectReturn();
1370 $sf->overrideViewControl();
1371 $sf->addFilter(
"atags ~* E'\\\\yMAILRECIPIENT\\\\y'");
1372 $dlf = $sf->search()->getDocumentList();
1374 if ($dlf->count() == 0)
return sprintf(_(
"none families are described to be used as recipient"));
1375 foreach ($dlf as $fam) {
1380 if (!is_a($cfam,
"IMailRecipient")) {
1381 return sprintf(_(
"Family '%s' does not implements IMailRecipient interface.") , $fam->name);
1384 $mailAttr = $cfam->getMailAttribute();
1386 $s->setObjectReturn();
1388 if ($mailAttr)
$s->addFilter(
"%s is not null", $mailAttr);
1390 if ($mailAttr)
$s->addFilter(
"(title ~* '%s') or (%s ~* '%s')", $name, $mailAttr, $name);
1391 else $s->addFilter(
"(title ~* '%s')", $name, $name);
1393 $dl =
$s->search()->getDocumentList();
1394 foreach ($dl as $dest) {
1398 $mailTitle = $dest->getMailTitle();
1399 $mail = $dest->getMail();
1400 if ($mailTitle ==
'') {
1410 usort($tr,
function (
$a, $b)
1412 return strcasecmp(
$a[0], $b[0]);
ldocstates($dbaccess, $docid, $name="")
lfamilly($dbaccess, $famid, $name="", $dirid=0, $filter=array(), $idid="id")
if(substr($wsh, 0, 1)!= '/') $args
newFreeVaultFile($dbaccess)
lsearches($dbaccess, $name)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
lenumvalues($enum, $val="")
vault_filename($th, $fileid)
lcvdoc($dbaccess, $name, $cvfamid="")
ltimerdoc($dbaccess, $name, $cvfamid="")
laction($dbaccess, $famid, $name, $type)
lfamily($dbaccess, $famid, $name="", $dirid=0, $filter=array(), $idid="id", $withDiacritic=false)
linkenum($famid, $attrid)
db_query($dbaccess, $table, $filter)
getReportColumns($dbaccess, $famid, $name="")
lmailtemplatedoc($dbaccess, $name, $cvfamid="")
lzone_($dbaccess, $tview, $famid="")
foreach($argv as $arg) $cmd
fdlGetEnumValues($famid, $attrid, $val= '')
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
getSortProperties($dbaccess, $famid, $name="")
lfamilyvalues($dbaccess, $famid, $name="")
lmask($dbaccess, $name, $maskfamid="")
fdlGetAccounts($filterName= '', $limit=15, $options= '')
tplmail($dbaccess, $type, $famid, $wfamid, $name)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getHttpVars($name, $def="", $scope="all")
gettitle($dbaccess, $docid)
internalGetDocCollection($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
getGlobalsParameters($name)
getFamIdFromName($dbaccess, $name)
getKindDoc($dbaccess, $famname, $aid, $kid, $name="", $sqlfilter=array(), $limit=100, $qtype="TABLE", $userid=0)
fdlGetDocuments($families, $filterName= '', $limit=15, $extraFilter= '')
if(is_numeric($parms['famid'])) $attrList
getSortAttr($dbaccess, $famid, $name="", $sort=true)
getDocAttr($dbaccess, $famid, $name="")
lprofil($dbaccess, $name, $famid=0)
new_Doc($dbaccess, $id= '', $latest=false)
lfamilies($dbaccess, $name= '', $subfam="")
tpluser($dbaccess, $type, $famid, $wfamid, $name)
GetSqlCond($Table, $column, $integer=false)
lzone($dbaccess, $tview, $famid="")
lkfamily($dbaccess, $famname, $aid, $kid, $name, $filter=array())
static getLangTitle($values)
lstates($dbaccess, $wid, $name="")
lmethods($dbaccess, $famid, $name="")
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
getReportSortableColumns($dbaccess, $famid, $name="")
getFamAttribute($dbaccess, $famid, $type="text", $param=false, $name="")