add method getNotifications()

This commit is contained in:
Uwe Steinmann 2016-02-05 16:47:38 +01:00
parent ddce7c9c69
commit d4deb0cc35

View File

@ -1287,5 +1287,33 @@ class SeedDMS_Core_User {
return true;
} /* }}} */
/**
* Get all notifications of user
*
* @param integer $type type of item (T_DOCUMENT or T_FOLDER)
* @return array array of notifications
*/
function getNotifications($type=0) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT `tblNotify`.* FROM `tblNotify` ".
"WHERE `tblNotify`.`userID` = ". $this->_id;
if($type) {
$queryStr .= " AND `tblNotify`.`targetType` = ". (int) $type;
}
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && !$resArr)
return false;
$notifications = array();
foreach ($resArr as $row) {
$not = new SeedDMS_Core_Notification($row["target"], $row["targetType"], $row["userID"], $row["groupID"]);
$not->setDMS($this);
array_push($notifications, $not);
}
return $notifications;
} /* }}} */
}
?>