/**
  * Returns all notifications fitting to the parameters.
  * @param boolean $only_unread : true for getting only unread notifications, false for all.
  * @param null|string $user_id : ID of special user the notification should belong to or (default:) null for current user
  * @return array of \PersonalNotifications in ascending order of mkdate
  */
 public static function getMyNotifications($only_unread = true, $user_id = null, $limit = 15)
 {
     if (!$user_id) {
         $user_id = $GLOBALS['user']->id;
     }
     $cached = self::getCache($user_id);
     if ($cached === false) {
         $query = "SELECT pn.*, COUNT(DISTINCT personal_notification_id) - 1 AS unseen\n                      FROM personal_notifications AS pn\n                      INNER JOIN personal_notifications_user AS u USING (personal_notification_id)\n                      WHERE u.user_id = :user_id\n                        AND u.seen = IFNULL(:only_unread, u.seen)\n                      GROUP BY pn.url\n                      ORDER BY mkdate ASC\n                      LIMIT :limit";
         $statement = DBManager::get()->prepare($query);
         $statement->bindValue(':user_id', $user_id);
         $statement->bindValue(':only_unread', $only_unread ? '0' : null);
         $statement->bindValue(':limit', (int) $limit, StudipPDO::PARAM_COLUMN);
         $statement->execute();
         $db_data = $statement->fetchAll(PDO::FETCH_ASSOC);
         self::setCache($user_id, $db_data);
     } else {
         $db_data = $cached;
     }
     $notifications = array();
     foreach ($db_data as $data) {
         $notification = new PersonalNotifications();
         $notification->setData($data);
         $notification->more_unseen = $data['unseen'];
         $notifications[] = $notification;
     }
     return $notifications;
 }