From 20f1de9a3f1de6b8e80aaf9214c93650e53034d5 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 5 Feb 2016 16:49:27 +0100 Subject: [PATCH] replace sql statements with method calls in SeedDMS_Core --- views/bootstrap/class.ManageNotify.php | 64 ++++++++++---------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/views/bootstrap/class.ManageNotify.php b/views/bootstrap/class.ManageNotify.php index f95b1be69..add47d6b2 100644 --- a/views/bootstrap/class.ManageNotify.php +++ b/views/bootstrap/class.ManageNotify.php @@ -35,40 +35,26 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style { function getNotificationList($as_group, $folders) { /* {{{ */ // First, get the list of groups of which the user is a member. + $notifications = array(); if ($as_group){ - - $groups = $this->user->getGroups(); - - if (count($groups)==0) return NULL; - - $grpList = ""; + if(!($groups = $this->user->getGroups())) + return NULL; + 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 { - $queryStr = "SELECT `tblNotify`.* FROM `tblNotify` ". - "WHERE `tblNotify`.`userID` = '". $this->user->getID()."'" ; + $notifications = $this->user->getNotifications($folders ? T_FOLDER : T_DOCUMENT); } - - $resArr = $this->db->getResultArray($queryStr); - - $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; + + return $notifications; } /* }}} */ - function printFolderNotificationList($ret,$deleteaction=true) { /* {{{ */ - if (count($ret)==0) { + function printFolderNotificationList($notifications, $deleteaction=true) { /* {{{ */ + if (count($notifications)==0) { printMLText("empty_notify_list"); } else { @@ -80,17 +66,17 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style { print "".getMLText("owner")."\n"; print "".getMLText("actions")."\n"; print "\n\n"; - foreach($ret as $ID) { - $fld = $this->dms->getFolder($ID); + foreach($notifications as $notification) { + $fld = $this->dms->getFolder($notification->getTarget()); if (is_object($fld)) { $owner = $fld->getOwner(); print ""; print ""; - print "" . htmlspecialchars($fld->getName()) . "\n"; + print "getID()."\">" . htmlspecialchars($fld->getName()) . "\n"; print "".htmlspecialchars($owner->getFullName()).""; print ""; - if ($deleteaction) print " ".getMLText("delete").""; - else print "".getMLText("edit").""; + if ($deleteaction) print " ".getMLText("delete").""; + else print "".getMLText("edit").""; print ""; } } @@ -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"); } else { @@ -113,8 +99,8 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style { print "".getMLText("status")."\n"; print "".getMLText("action")."\n"; print "\n\n"; - foreach ($ret as $ID) { - $doc = $this->dms->getDocument($ID); + foreach ($notifications as $notification) { + $doc = $this->dms->getDocument($notification->getTarget()); if (is_object($doc)) { $owner = $doc->getOwner(); $latest = $doc->getLatestContent(); @@ -129,7 +115,7 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style { } print ""; - print "" . htmlspecialchars($doc->getName()) . ""; + print "getID()."\">" . htmlspecialchars($doc->getName()) . ""; print "
".getMLText('owner').": ".htmlspecialchars($owner->getFullName()).", ".getMLText('creation_date').": ".date('Y-m-d', $doc->getDate()).", ".getMLText('version')." ".$latest->getVersion()." - ".date('Y-m-d', $latest->getDate()).""; $comment = $latest->getComment(); if($comment) { @@ -139,8 +125,8 @@ class SeedDMS_View_ManageNotify extends SeedDMS_Bootstrap_Style { print "".getOverallStatusText($status["status"]).""; print ""; - if ($deleteaction) print " ".getMLText("delete").""; - else print "".getMLText("edit").""; + if ($deleteaction) print " ".getMLText("delete").""; + else print "".getMLText("edit").""; print "\n"; } }