37 function GetAllTags($Item, $Recurse=
true, $uploadtree_tablename=
"uploadtree")
45 $dbManager = $container->get(
'db.manager');
47 $stmt = __METHOD__.
".$uploadtree_tablename";
48 $sql =
"select true from tag_manage, $uploadtree_tablename u where is_disabled = true and tag_manage.upload_fk = u.upload_fk and u.uploadtree_pk = $1";
49 $tagDisabled = $dbManager->getSingleRow($sql, array($Item), $stmt);
50 if ($tagDisabled !==
false) {
54 $stmt2 = $stmt.
'.lftRgt';
55 $sql =
"select lft,rgt, upload_fk from $uploadtree_tablename where uploadtree_pk=$1";
56 $uploadtree_row = $dbManager->getSingleRow($sql,array($Item), $stmt2);
58 $params = array($Item, $uploadtree_row[
'upload_fk']);
60 $Condition =
" lft between $3 and $4 ";
62 $params[] = $uploadtree_row[
'lft'];
63 $params[] = $uploadtree_row[
'rgt'];
65 $Condition =
" uploadtree.uploadtree_pk=$1 ";
69 $sql =
"SELECT distinct(tag_fk) as tag_pk FROM tag_file, $uploadtree_tablename WHERE tag_file.pfile_fk = {$uploadtree_tablename}.pfile_fk and upload_fk=$2 AND $Condition UNION SELECT tag_fk as tag_pk FROM tag_uploadtree WHERE tag_uploadtree.uploadtree_fk = $1";
71 $stmt1 = $stmt.
'.theTags';
72 $dbManager->prepare($stmt1,
"select tag.tag AS tag_name, tag.tag_pk from tag,($sql) subquery where tag.tag_pk=subquery.tag_pk group by tag.tag_pk, tag.tag");
73 $res = $dbManager->execute($stmt1,$params);
74 $List = $dbManager->fetchAll($res);
75 $dbManager->freeResult($res);
97 $FirstEmpty=
false, $SelElt=
true, $Options=
"")
99 $str =
"\n<select name='$SLName' $Options>\n";
101 $str .=
"<option value='' > \n";
103 foreach ($KeyValArray as $key => $val) {
104 if ($SelElt ==
true) {
105 $SELECTED = ($val == $SelectedVal) ?
"SELECTED" :
"";
107 $SELECTED = ($key == $SelectedVal) ?
"SELECTED" :
"";
112 $str .=
"<option value='$key' $SELECTED>$val\n";
131 $FirstEmpty=
false, $SelElt=
true)
143 $str =
"\n<select name='$SLName'>\n";
145 $str .=
"<option value='' > \n";
147 foreach ($KeyValArray as $key => $val) {
148 if ($SelElt ==
true) {
149 $SELECTED = ($val == $SelectedVal) ?
"SELECTED" :
"";
151 $SELECTED = ($key == $SelectedVal) ?
"SELECTED" :
"";
153 $perm = GetTaggingPerms($_SESSION[
'UserId'],$key);
155 $str .=
"<option value='$key' $SELECTED>$val\n";
169 function TagFilter(&$UploadtreeRows, $tag_pk, $uploadtree_tablename)
171 foreach ($UploadtreeRows as $key=>$UploadtreeRow) {
173 $tags =
GetAllTags($UploadtreeRow[
"uploadtree_pk"],
true, $uploadtree_tablename);
174 foreach ($tags as $tagArray) {
175 if ($tagArray[
'tag_pk'] == $tag_pk) {
183 if ($found ==
false) {
184 unset($UploadtreeRows[$key]);
196 function TagStatus($upload_id)
200 $uploadDao = $container->get(
'dao.upload');
201 if (!$uploadDao->isEditable($upload_id, Auth::getGroupId())) {
206 $sql =
"select tag_manage_pk from tag_manage where upload_fk = $upload_id and is_disabled = true;";
207 $result = pg_query($PG_CONN, $sql);
209 $count = pg_num_rows($result);
210 pg_free_result($result);
211 return ($count > 0) ? 0 : 1;
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.