Exemple #1
0
 /**
  * @return array
  */
 public function getNotifications()
 {
     $result = [];
     $query = $this->getAdapter()->select()->from(["n" => $this->_name])->joinLeft(["u" => $this->_dbprefix . "users"], "n.ref_userid=u.userid", ["name", "username"])->joinLeft(["pi" => $this->_dbprefix . "gallery_images"], "pi.id = u.profileImage", ['filename AS pimg', 'albumid AS palbumid'])->where("n.userid=?", $_SESSION['user']->userid)->order("n.unread DESC")->limit(5);
     $res = $this->getAdapter()->fetchAll($query);
     $resCount = count($res);
     for ($i = 0; $i < $resCount; $i++) {
         $d = Notifier::getNotificationData($res[$i]["type"]);
         $res[$i]["message"] = \sprintf($d, $res[$i]["name"]);
         $res[$i]["target"] = Url::convertUrl($res[$i]["target"]);
         if ($res[$i]["unread"] == 1) {
             $result["new"]++;
         }
     }
     $result["all"] = $res;
     return $result;
 }