static function addHeader()
 {
     if (!CMA_Thread::canPostQuestions()) {
         self::addMessage(self::MESSAGE_ERROR, 'You cannot post questions.');
         wp_redirect(CMA::getReferer());
     }
     self::loadScripts();
 }
 public static function notifyAllUsers()
 {
     global $wpdb;
     if (!empty($_GET['nonce']) and wp_verify_nonce($_GET['nonce'], CMA_BaseController::ADMIN_BP_NOTIFY)) {
         $usersIds = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
         if (!empty($_GET['post_id']) and $thread = CMA_Thread::getInstance($_GET['post_id'])) {
             $notification = array('item_id' => $thread->getId(), 'secondary_item_id' => 0, 'component_name' => 'cma_notifier', 'component_action' => self::ACTION_NOTIFICATION_THREAD, 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => true);
             foreach ($usersIds as $userId) {
                 if ($thread->isVisible($userId)) {
                     $notification['user_id'] = $userId;
                     bp_notifications_add_notification($notification);
                 }
             }
         }
         if (!empty($_GET['comment_id']) and $answer = CMA_Answer::getById($_GET['comment_id'])) {
             $notification = array('item_id' => $answer->getId(), 'secondary_item_id' => 0, 'component_name' => 'cma_notifier', 'component_action' => self::ACTION_NOTIFICATION_ANSWER, 'date_notified' => bp_core_current_time(), 'is_new' => 1, 'allow_duplicate' => true);
             foreach ($usersIds as $userId) {
                 if ($answer->isVisible($userId)) {
                     $notification['user_id'] = $userId;
                     bp_notifications_add_notification($notification);
                 }
             }
         }
     }
     wp_safe_redirect(CMA::getReferer());
     exit;
 }
 public function getViewData()
 {
     return array('question-id' => $this->getId(), 'permalink' => $this->getPermalink(), 'favorite' => intval($this->isFavorite()), 'favorite-enabled' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_ENABLE_MARK_FAVORITE_QUESTIONS)), 'favorite-nonce' => wp_create_nonce('cma_favorite_question'), 'rating' => $this->getPostRating(), 'rating-enabled' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_ENABLE_QUESTION_RATING)), 'rating-nonce' => wp_create_nonce('cma_rate_thread_' . $this->getId()), 'rating-negative-allowed' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_NEGATIVE_RATING_ALLOWED)), 'resolve-enabled' => intval(CMA_Settings::getOption(CMA_Settings::OPTION_RESOLVE_THREAD_ENABLED)), 'can-resolve' => intval($this->canResolve()), 'can-spam' => intval($this->canMarkSpam()), 'spam' => intval($this->isMarkedAsSpam()), 'spam-nonce' => wp_create_nonce('cma_report_spam'), 'can-delete' => intval($this->canDelete()), 'can-subscribe' => intval($this->canSubscribe()), 'is-follower' => intval($this->getFollowersEngine()->isFollower()), 'backlink' => base64_encode(CMA::getReferer()));
 }
 protected static function _processResolve()
 {
     $error = false;
     $messages = array();
     $post = self::$query->post;
     $thread = CMA_Thread::getInstance($post->ID);
     try {
         if (empty($_POST['nonce']) or !wp_verify_nonce($_POST['nonce'], 'cma_resolve')) {
             throw new Exception(CMA::__('Invalid nonce.'));
         }
         $thread->resolve();
         $msg = CMA_Labels::getLocalized('thread_resolved_success');
         self::addMessage(self::MESSAGE_SUCCESS, apply_filters('cma_question_resolved_msg_success', $msg, $thread));
         wp_safe_redirect(CMA::getReferer());
         exit;
     } catch (Exception $e) {
         self::addMessage(self::MESSAGE_ERROR, $e);
         $error = true;
     }
 }