Ejemplo n.º 1
0
 /**
  * Handle ajax callback for mark all notification as read
  */
 public function markread_notification()
 {
     $id = (int) $_POST['id'];
     if (isset($_POST['id']) && !ap_verify_nonce('ap_markread_notification_' . $id) && !is_user_logged_in()) {
         $this->something_wrong();
     } elseif (!ap_verify_nonce('ap_markread_notification_' . get_current_user_id()) && !is_user_logged_in()) {
         $this->something_wrong();
     }
     if (isset($_POST['id'])) {
         $notification = ap_get_notification_by_id($id);
         if ($notification && (get_current_user_id() == $notification->noti_user_id || is_super_admin())) {
             $row = ap_update_notification(array('noti_id' => $id, 'noti_user_id' => get_current_user_id()), array('noti_status' => 1));
             if (false !== $row) {
                 $this->send(array('message' => 'mark_read_notification', 'action' => 'mark_read_notification', 'container' => '.ap-notification-' . $notification->noti_id, 'view' => array('notification_count' => ap_get_total_unread_notification())));
             }
         }
     } else {
         $row = ap_notification_mark_all_read(get_current_user_id());
         if (false !== $row) {
             $this->send(array('message' => 'mark_read_notification', 'action' => 'mark_all_read', 'container' => '#ap-notification-dropdown', 'view' => array('notification_count' => '0')));
         }
     }
     $this->something_wrong();
 }
Ejemplo n.º 2
0
/**
 * Mark a notification as read
 * @param  integer $id         notification id.
 * @param  integer $user_id    notification user id.
 * @return integer|boolean	   Return FALSE on failure
 */
function ap_notification_mark_as_read($id, $user_id = false)
{
    $where = array('noti_id' => $id);
    if (false !== $user_id) {
        $where['noti_user_id'] = $user_id;
    }
    return ap_update_notification($where, array('noti_status' => 1));
}