replace sql statements with method calls in SeedDMS_Core

This commit is contained in:
Uwe Steinmann 2016-02-05 16:49:27 +01:00
parent 879a67ab84
commit 20f1de9a3f

View File

@ -35,40 +35,26 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style {
function getNotificationList($as_group, $folders) { /* {{{ */ function getNotificationList($as_group, $folders) { /* {{{ */
// First, get the list of groups of which the user is a member. // First, get the list of groups of which the user is a member.
$notifications = array();
if ($as_group){ if ($as_group){
if(!($groups = $this->user->getGroups()))
$groups = $this->user->getGroups(); return NULL;
if (count($groups)==0) return NULL;
$grpList = "";
foreach ($groups as $group) { foreach ($groups as $group) {
$grpList .= (strlen($grpList)==0 ? "" : ", ") . $group->getID(); $tmp = $group->getNotifications($folders ? T_FOLDER : T_DOCUMENT);
if($tmp) {
$notifications = array_merge($notifications, $tmp);
}
} }
$queryStr = "SELECT `tblNotify`.* FROM `tblNotify` ".
"WHERE `tblNotify`.`groupID` IN (". $grpList .")";
} else { } else {
$queryStr = "SELECT `tblNotify`.* FROM `tblNotify` ". $notifications = $this->user->getNotifications($folders ? T_FOLDER : T_DOCUMENT);
"WHERE `tblNotify`.`userID` = '". $this->user->getID()."'" ;
} }
$resArr = $this->db->getResultArray($queryStr); return $notifications;
$ret=array();
foreach ($resArr as $res){
if (($res["targetType"] == T_DOCUMENT)&&(!$folders)) $ret[]=$res["target"];
if (($res["targetType"] == T_FOLDER)&&($folders)) $ret[]=$res["target"];
}
return $ret;
} /* }}} */ } /* }}} */
function printFolderNotificationList($ret,$deleteaction=true) { /* {{{ */ function printFolderNotificationList($notifications, $deleteaction=true) { /* {{{ */
if (count($ret)==0) { if (count($notifications)==0) {
printMLText("empty_notify_list"); printMLText("empty_notify_list");
} }
else { else {
@ -80,17 +66,17 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style {
print "<th>".getMLText("owner")."</th>\n"; print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("actions")."</th>\n"; print "<th>".getMLText("actions")."</th>\n";
print "</tr></thead>\n<tbody>\n"; print "</tr></thead>\n<tbody>\n";
foreach($ret as $ID) { foreach($notifications as $notification) {
$fld = $this->dms->getFolder($ID); $fld = $this->dms->getFolder($notification->getTarget());
if (is_object($fld)) { if (is_object($fld)) {
$owner = $fld->getOwner(); $owner = $fld->getOwner();
print "<tr class=\"folder\">"; print "<tr class=\"folder\">";
print "<td><i class=\"icon-folder-close-alt\"></i></td>"; print "<td><i class=\"icon-folder-close-alt\"></i></td>";
print "<td><a href=\"../out/out.ViewFolder.php?folderid=".$ID."\">" . htmlspecialchars($fld->getName()) . "</a></td>\n"; print "<td><a href=\"../out/out.ViewFolder.php?folderid=".$fld->getID()."\">" . htmlspecialchars($fld->getName()) . "</a></td>\n";
print "<td>".htmlspecialchars($owner->getFullName())."</td>"; print "<td>".htmlspecialchars($owner->getFullName())."</td>";
print "<td>"; print "<td>";
if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$ID."&type=folder&action=del' class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</a>"; if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$fld->getID()."&type=folder&action=del' class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</a>";
else print "<a href='../out/out.FolderNotify.php?folderid=".$ID."' class=\"btn btn-mini\">".getMLText("edit")."</a>"; else print "<a href='../out/out.FolderNotify.php?folderid=".$fld->getID()."' class=\"btn btn-mini\">".getMLText("edit")."</a>";
print "</td></tr>"; print "</td></tr>";
} }
} }
@ -98,9 +84,9 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style {
} }
} /* }}} */ } /* }}} */
function printDocumentNotificationList($ret,$deleteaction=true) { /* {{{ */ function printDocumentNotificationList($notifications,$deleteaction=true) { /* {{{ */
if (count($ret)==0) { if (count($notifications)==0) {
printMLText("empty_notify_list"); printMLText("empty_notify_list");
} }
else { else {
@ -113,8 +99,8 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style {
print "<th>".getMLText("status")."</th>\n"; print "<th>".getMLText("status")."</th>\n";
print "<th>".getMLText("action")."</th>\n"; print "<th>".getMLText("action")."</th>\n";
print "</tr></thead>\n<tbody>\n"; print "</tr></thead>\n<tbody>\n";
foreach ($ret as $ID) { foreach ($notifications as $notification) {
$doc = $this->dms->getDocument($ID); $doc = $this->dms->getDocument($notification->getTarget());
if (is_object($doc)) { if (is_object($doc)) {
$owner = $doc->getOwner(); $owner = $doc->getOwner();
$latest = $doc->getLatestContent(); $latest = $doc->getLatestContent();
@ -129,7 +115,7 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style {
} }
print "</td>"; print "</td>";
print "<td><a href=\"out.ViewDocument.php?documentid=".$ID."\">" . htmlspecialchars($doc->getName()) . "</a>"; print "<td><a href=\"out.ViewDocument.php?documentid=".$doc->getID()."\">" . htmlspecialchars($doc->getName()) . "</a>";
print "<br /><span style=\"font-size: 85%; font-style: italic; color: #666; \">".getMLText('owner').": <b>".htmlspecialchars($owner->getFullName())."</b>, ".getMLText('creation_date').": <b>".date('Y-m-d', $doc->getDate())."</b>, ".getMLText('version')." <b>".$latest->getVersion()."</b> - <b>".date('Y-m-d', $latest->getDate())."</b></span>"; print "<br /><span style=\"font-size: 85%; font-style: italic; color: #666; \">".getMLText('owner').": <b>".htmlspecialchars($owner->getFullName())."</b>, ".getMLText('creation_date').": <b>".date('Y-m-d', $doc->getDate())."</b>, ".getMLText('version')." <b>".$latest->getVersion()."</b> - <b>".date('Y-m-d', $latest->getDate())."</b></span>";
$comment = $latest->getComment(); $comment = $latest->getComment();
if($comment) { if($comment) {
@ -139,8 +125,8 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style {
print "<td>".getOverallStatusText($status["status"])."</td>"; print "<td>".getOverallStatusText($status["status"])."</td>";
print "<td>"; print "<td>";
if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$ID."&type=document&action=del' class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</a>"; if ($deleteaction) print "<a href='../op/op.ManageNotify.php?id=".$doc->getID()."&type=document&action=del' class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</a>";
else print "<a href='../out/out.DocumentNotify.php?documentid=".$ID."' class=\"btn btn-mini\">".getMLText("edit")."</a>"; else print "<a href='../out/out.DocumentNotify.php?documentid=".$doc->getID()."' class=\"btn btn-mini\">".getMLText("edit")."</a>";
print "</td></tr>\n"; print "</td></tr>\n";
} }
} }