19 include_once (
"FDL/Lib.Util.php");
29 if (count($Table) > 0) {
30 $sql_cond =
"(($column = '$Table[0]') ";
31 for ($i = 1; $i < count($Table); $i++) {
32 $sql_cond = $sql_cond .
"OR ($column = '$Table[$i]') ";
34 $sql_cond = $sql_cond .
")";
45 if (count($Table) > 0) {
47 $sql_cond =
"$column in (";
48 $sql_cond.= implode(
",", $Table);
51 foreach ($Table as & $v) $v = pg_escape_string($v);
52 $sql_cond =
"$column in ('";
53 $sql_cond.= implode(
"','", $Table);
67 if (count(
$a) == 0)
return false;
88 if ($tag ==
"font")
return '';
89 elseif (strpos($tag,
':') > 0) {
90 return strtolower($lt .
'xhtml:span' . $gt);
92 $attr = str_replace(
':=',
'=', $attr);
93 return strtolower($lt .
"xhtml:" . $tag . $attr . $gt);
107 if ($errno == E_WARNING && (substr_count($errstr,
"DOMDocument::loadXML()") > 0)) {
108 throw new DOMException($errstr);
136 include_once (
"FDL/Class.DocFile.php");
153 if (isset($gdocs[
$id]) && ((!
$latest) || ($gdocs[$id]->locked != - 1))) {
155 if ((
$doc->doctype !=
'W') || (!isset(
$doc->doc))) {
158 if (
$doc->id == $id) {
161 }
else unset($gdocs[$id]);
167 $classname =
"Doc$fromid";
169 }
else if ($fromid == - 1) $classname =
"DocFam";
172 if ($classname !=
"") {
173 include_once (
"FDL$gen/Class.$classname.php");
182 if ((
$doc->doctype !=
'C') || (count(
$doc->attributes->attr) > 0)) {
191 include_once (
"FDL/Class.DocFile.php");
212 include_once (
"FDL/Class.DocFam.php");
216 $err = $cdoc->control(
'create');
217 if (
$err !=
"")
return false;
220 $classname =
"Doc" . $fromid;
222 include_once (
"FDL$GEN/Class.$classname.php");
225 $doc->revision =
"0";
229 $doc->fromid = $fromid;
231 $doc->setProfil($cdoc->cprofid);
232 $doc->setCvid($cdoc->ccvid);
233 $doc->wid = $cdoc->wid;
235 $doc->icon = $cdoc->icon;
236 $doc->usefor = $cdoc->usefor;
237 $doc->forumid = $cdoc->forumid;
238 $doc->atags = $cdoc->atags;
239 if ($defaultvalues)
$doc->setDefaultValues($cdoc->getDefValues());
273 if (!(
$id > 0))
return false;
274 if (!is_numeric(
$id))
return false;
278 $result = pg_query(
$dbid, sprintf(
"select fromid from docfrom where id=%d",
$id));
280 if (pg_numrows($result) > 0) {
281 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
282 $fromid = $arr[
"fromid"];
298 if (!(
$id > 0))
return false;
299 if (!is_numeric(
$id))
return false;
302 $result = pg_query(
$dbid, sprintf(
"SELECT name from docfam where id=(select fromid from docfrom where id=%d)",
$id));
304 if (pg_numrows($result) > 0) {
305 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
306 $fromname = $arr[
"name"];
321 if (!(
$id > 0))
return false;
322 if (!is_numeric(
$id))
return false;
325 $result = pg_query(
$dbid,
"select fromid from docfam where id=$id;");
327 if (pg_numrows($result) > 0) {
328 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
329 $fromid = intval($arr[
"fromid"]);
348 if (!(
$id > 0))
return false;
352 if ($fromid > 0)
$table =
"doc$fromid";
353 else if ($fromid == - 1)
$table =
"docfam";
356 if (count($sqlfilters) > 0) $sqlcond =
"and (" . implode(
") and (", $sqlfilters) .
")";
357 if (count($result) == 0) {
358 $userid = $action->user->id;
359 $sql =
"select *,getuperm($userid,profid) as uperm from only $table where id=$id $sqlcond;";
361 $scol = implode($result,
",");
362 $sql =
"select $scol from only $table where id=$id $sqlcond;";
365 if ($SQLDEBUG) $sqlt1 = microtime();
370 $TSQLDELAY[] = array(
375 if (($result) && (pg_numrows($result) > 0)) {
376 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
393 if (isset(
$t[$k]) && (
$t[$k] !=
""))
return $t[$k];
394 if (strpos(
$t[
"attrids"],
"£$k") !== 0) {
396 $tvalues = explode(
"£",
$t[
"values"]);
397 $tattrids = explode(
"£",
$t[
"attrids"]);
398 foreach ($tattrids as $ka => $va) {
400 if (!isset(
$t[$va]))
$t[$va] = $tvalues[$ka];
402 if ($tvalues[$ka] !=
"")
return $tvalues[$ka];
418 $tvalues = explode(
"£",
$t[
"values"]);
419 $tattrids = explode(
"£",
$t[
"attrids"]);
420 foreach ($tattrids as $ka => $va) {
422 if (!isset(
$t[$va]))
$t[$va] = $tvalues[$ka];
434 if (isset(
$a->ordered) && isset($b->ordered)) {
435 if (
$a->ordered == $b->ordered)
return 0;
436 if (
$a->ordered > $b->ordered)
return 1;
439 if (isset(
$a->ordered))
return 1;
440 if (isset($b->ordered))
return -1;
446 if (
$a[
"cv_order"] == $b[
"cv_order"]) {
449 return (
$a[
"cv_order"] < $b[
"cv_order"]) ? -1 : 1;
461 static $_ODocCtrol =
false;
462 static $_Ocuid =
false;
466 $_Ocuid = $cd->userid;
469 if ((
$tdoc[
"profid"] <= 0) || ($_Ocuid == 1))
return true;
470 if (!isset(
$tdoc[
"uperm"])) {
472 $result = @pg_query(
$dbid, sprintf(
"select getuperm(%d,%d) as uperm", $_Ocuid,
$tdoc[
'profid']));
473 if ($result && (pg_numrows($result) > 0)) {
474 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
475 $tdoc[
"uperm"] = $arr[
"uperm"];
478 $err = $_ODocCtrol->ControlUp(
$tdoc[
"uperm"], $aclname);
490 static $_OgetDocObject;
492 if ($v[
"doctype"] ==
"C") {
493 if (!isset($_OgetDocObject[$k][
"family"])) $_OgetDocObject[$k][
"family"] =
new DocFam(
$dbaccess);
494 $_OgetDocObject[$k][
"family"]->Affect($v,
true);
495 $v[
"fromid"] =
"family";
497 if (!isset($_OgetDocObject[$k][$v[
"fromid"]])) $_OgetDocObject[$k][$v[
"fromid"]] =
createDoc(
$dbaccess, $v[
"fromid"],
false,
false);
499 $_OgetDocObject[$k][$v[
"fromid"]]->Affect($v,
true);
500 $_OgetDocObject[$k][$v[
"fromid"]]->nocache =
true;
501 return $_OgetDocObject[$k][$v[
"fromid"]];
510 $tdoc = pg_fetch_array($res, NULL, PGSQL_ASSOC);
511 if (
$tdoc ===
false)
return false;
522 if ($n ===
false)
return false;
523 $tdoc = pg_fetch_array($n, NULL, PGSQL_ASSOC);
524 if (
$tdoc ===
false) {
526 if ($n ===
false)
return false;
527 $tdoc = pg_fetch_array($n, NULL, PGSQL_ASSOC);
528 if (
$tdoc ===
false)
return false;
540 foreach ($tres as $res) $n+= pg_num_rows($res);
553 include_once (
"FDL/Class.DocFam.php");
555 if (!isset($tFamIdName)) {
556 $tFamIdName = array();
558 $ql =
$q->Query(0, 0,
"TABLE");
559 while (list($k, $v) = each($ql)) {
560 if ($v[
"name"] !=
"") $tFamIdName[$v[
"name"]] = $v[
"id"];
563 if (isset($tFamIdName[
$name]))
return $tFamIdName[
$name];
564 if (isset($tFamIdName[strtoupper($name) ]))
return $tFamIdName[strtoupper($name) ];
580 $fromonly = ($only) ?
"only" :
"";
598 static $first =
true;
603 @pg_prepare(
$dbid,
"getidfromname",
'select id from docname where name=$1');
607 $result = pg_execute(
$dbid,
"getidfromname", array(
610 $n = pg_numrows($result);
612 $arr = pg_fetch_array($result, ($n - 1) , PGSQL_ASSOC);
627 static $first =
true;
632 @pg_prepare(
$dbid,
"getNameFromId",
'select name from docname where id=$1');
635 $result = pg_execute(
$dbid,
"getNameFromId", array(
638 $n = pg_numrows($result);
640 $arr = pg_fetch_array($result, ($n - 1) , PGSQL_ASSOC);
641 $name = $arr[
"name"];
653 while (list($k, $v) = each($tFamIdName)) {
654 $action->lay->set(
"IDFAM_$k", $v);
665 if ($userid ==
"")
return false;
666 include_once (
"FDL/Lib.Dir.php");
669 if (!
$user->isAffected())
return false;
670 if (
$user->isgroup ==
"Y") {
672 "us_whatid = '$userid'"
677 "us_whatid = '$userid'"
681 if (count(
$tdoc) == 0)
return false;
689 if ($i !=
$r)
return $i;
690 return $tdoc[
'title'];
701 if (!
$tdoc)
return null;
702 return (
$tdoc[
"locked"] == - 1);
707 if ($vis ==
"I")
return $vis;
708 if ($fvis ==
"H")
return $fvis;
709 if (($fvis ==
"R") && ($vis ==
"W"))
return $fvis;
710 if (($fvis ==
"R") && ($vis ==
"O"))
return "H";
711 if (($fvis ==
"O") && ($vis ==
"W"))
return $fvis;
712 if (($fvis ==
"R") && ($vis ==
"U"))
return $fvis;
713 if (($fvis ==
"S") && (($vis ==
"W") || ($vis ==
"O")))
return $fvis;
714 if ($fvis ==
"I")
return $fvis;
716 if ($ffvis && ($vis ==
'W' || $vis==
'O')) {
717 if ($ffvis==
'S')
return 'S';
718 if ($ffvis==
'R')
return 'R';
736 if (!($initid > 0))
return false;
742 if (count(
$tf) > 0) $fromid =
$tf[0];
744 if ($fromid > 0)
$table =
"doc$fromid";
745 else if ($fromid == - 1)
$table =
"docfam";
748 if (count($sqlfilters) > 0) $sqlcond =
"and (" . implode(
") and (", $sqlfilters) .
")";
750 $userid = $action->user->id;
752 $result = @pg_query(
$dbid,
"select *,getuperm($userid,profid) as uperm from only $table where initid=$initid and doctype != 'T' and locked != -1 $sqlcond;");
753 if ($result && (pg_numrows($result) > 0)) {
754 if (pg_numrows($result) > 1) addWarningMsg(sprintf(
"document %d : multiple alive revision", $initid));
756 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
773 if (!is_array($ids))
return null;
776 foreach ($ids as $k => $v) $ids[$k] = intval($v);
777 $sids = implode($ids,
",");
778 $sql = sprintf(
"SELECT id,initid from docread where initid in (SELECT initid from docread where id in (%s)) and locked != -1;", $sids);
781 $arr = pg_fetch_all($result);
783 foreach ($arr as $v) $tlids[$v[
"initid"]] = $v[
"id"];
797 if (is_array($ids))
return null;
802 $err =
simpleQuery(
$dbaccess, sprintf(
"select id from docread where initid='%d' order by id desc limit 1", $initid) ,
$id,
true,
true);
818 if (!($initid > 0))
return false;
822 if ($fromid > 0)
$table =
"doc$fromid";
823 else if ($fromid == - 1)
$table =
"docfam";
825 $userid = $action->user->id;
826 $result = pg_query(
$dbid,
"select *,getuperm($userid,profid) as uperm from only $table where initid=$initid and revision=$rev;");
827 if (pg_numrows($result) > 0) {
828 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
847 $initid = intval($initid);
848 if (!($initid > 0))
return false;
852 if ($fromid > 0)
$table =
"doc$fromid";
853 else if ($fromid == - 1)
$table =
"docfam";
855 $result = @pg_query(
$dbid,
"SELECT revision from only $table where initid=$initid order by revision desc limit 1;");
856 if ($result && (pg_numrows($result) > 0)) {
857 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
858 return $arr[
'revision'];
872 if (
$err !=
"")
return false;
873 $dir->setValue(
"BA_TITLE", sprintf(_(
"root for %s") ,
$doc->title));
874 $dir->setValue(
"BA_DESC", _(
"default folder"));
875 $dir->setValue(
"FLD_ALLBUT",
"1");
876 $dir->setValue(
"FLD_FAM",
$doc->title .
"\n" . _(
"folder") .
"\n" . _(
"search"));
878 $dir->setValue(
"FLD_SUBFAM",
"yes\nyes\nyes");
893 $uid = $action->user->id;
894 $pname = sprintf(
"PERSONAL-PROFIL-%d",
$uid);
896 if (!$p->isAffected()) {
900 $p->setValue(
"ba_title", sprintf(_(
"Personal profile for %s %s") , $action->user->firstname, $action->user->lastname));
901 $p->setValue(
"prf_desc", sprintf(_(
"Only %s %s can view and edit") , $action->user->firstname, $action->user->lastname));
905 $err = $p->setControl();
917 if (!$node)
return false;
918 $document = $node->ownerDocument;
919 $nodeAsString = $document->saveXML($node);
920 preg_match(
'!<.*?>(.*)</.*?>!s', $nodeAsString, $match);
925 $html = preg_replace(
"/<\/?span[^>]*>/s",
"",
$html);
926 $html = preg_replace(
"/<\/?font[^>]*>/s",
"",
$html);
927 $html = preg_replace(
"/<\/?meta[^>]*>/s",
"",
$html);
928 $html = preg_replace(
"/<style[^>]*>.*?<\/style>/s",
"",
$html);
929 $html = preg_replace(
"/<([^>]*) style=\"[^\"]*\"/s",
"<\\1",
$html);
930 $html = preg_replace(
"/<([^>]*) class=\"[^\"]*\"/s",
"<\\1",
$html);