Пример #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();
 }
Пример #2
0
 public function markread_notification()
 {
     $id = (int) $_POST['id'];
     if (isset($_POST['id']) && !wp_verify_nonce($_POST['__nonce'], 'ap_markread_notification_' . $id) && !is_user_logged_in()) {
         ap_send_json(ap_ajax_responce('something_wrong'));
         return;
     } elseif (!wp_verify_nonce($_POST['__nonce'], 'ap_markread_notification_' . get_current_user_id()) && !is_user_logged_in()) {
         ap_send_json(ap_ajax_responce('something_wrong'));
         return;
     }
     if (isset($_POST['id'])) {
         $notification = ap_get_notification_by_id($id);
         if ($notification && ($notification['apmeta_actionid'] == get_current_user_id() || is_super_admin())) {
             $row = ap_update_meta(array('apmeta_type' => 'notification'), array('apmeta_id' => $notification['apmeta_id']));
             if ($row !== false) {
                 ap_send_json(ap_ajax_responce(array('message' => 'mark_read_notification', 'action' => 'mark_read_notification', 'container' => '.ap-notification-' . $notification['apmeta_id'], 'view' => array('notification_count' => ap_get_total_unread_notification()))));
             }
         }
     } else {
         $row = ap_notification_mark_all_read(get_current_user_id());
         if ($row !== false) {
             ap_send_json(ap_ajax_responce(array('message' => 'mark_read_notification', 'action' => 'mark_all_read', 'container' => '#ap-notification-dropdown', 'view' => array('notification_count' => '0'))));
         }
     }
     //if process reached here then there must be something wrong
     ap_send_json(ap_ajax_responce('something_wrong'));
 }