コード例 #1
0
ファイル: notifications.php プロジェクト: istrwei/Luna
/**
 * Get a specific notification.
 * 
 * Simple standalone function to avoid calling the class.
 * 
 * @since    1.1
 * 
 * @param    mixed    Either a notification ID, a notification object or a notification array
 * 
 * @return   object|null    LunaNotification if available, null else
 */
function get_notification($notification = null)
{
    $notif = null;
    if (is_null($notification) || empty($notification)) {
        return $notif;
    }
    if (is_a($notification, 'LunaNotification')) {
        $notif = $notification;
    } elseif (is_object($notification) || is_array($notification)) {
        $notif = new LunaNotification($notification);
    } else {
        if (is_int($notification)) {
            $notif = LunaNotification::get_instance($notification);
        }
    }
    return $notif;
}
コード例 #2
0
ファイル: luna_notification.php プロジェクト: istrwei/Luna
 /**
  * Delete a specific notification. Static method.
  * 
  * @since    1.1
  * 
  * @param    int    $id Notification ID.
  * 
  * @return   boolean    Deletion status
  */
 public static function delete($id)
 {
     $notification = LunaNotification::get_instance($id);
     if (!$notification) {
         return false;
     }
     return (bool) $notification->remove();
 }