Example #1
0
 /**
  * @brief delete all notifications of the given user
  * @param $uid
  * @return number of affected rows
  */
 public static function deleteByUser($uid = null)
 {
     if (is_null($uid)) {
         if (OCP\User::isLoggedIn()) {
             $uid = OCP\User::getUser();
         } else {
             return 0;
         }
     }
     if (!isset(self::$deleteParamsByUserStmt)) {
         self::$deleteParamsByUserStmt = OCP\DB::prepare("DELETE FROM *PREFIX*notification_params WHERE nid IN (SELECT id FROM *PREFIX*notifications WHERE uid = ?)");
     }
     if (!isset(self::$deleteByUserStmt)) {
         self::$deleteByUserStmt = OCP\DB::prepare("DELETE FROM *PREFIX*notifications WHERE uid = ?");
     }
     self::$deleteParamsByUserStmt->execute(array($uid));
     self::$deleteByUserStmt->execute(array($uid));
     return self::$deleteByUserStmt->numRows();
 }