Esempio n. 1
0
 public static function setData()
 {
     if (isset($_POST['subject'])) {
         self::$dataSubject = apply_filters('asgarosforum_filter_subject_before_insert', trim($_POST['subject']));
     }
     if (isset($_POST['message'])) {
         self::$dataContent = apply_filters('asgarosforum_filter_content_before_insert', trim($_POST['message']));
     }
 }
Esempio n. 2
0
 function prepare()
 {
     global $post;
     if (is_a($post, 'WP_Post') && $this->checkForShortcode($post)) {
         $this->executePlugin = true;
         $this->options['location'] = $post->ID;
     }
     // Set all base links.
     if ($this->executePlugin || get_post($this->options['location'])) {
         $this->setLinks();
     }
     if (!$this->executePlugin) {
         return;
     }
     if (isset($_GET['view'])) {
         $this->current_view = esc_html($_GET['view']);
     }
     if (isset($_GET['part']) && absint($_GET['part']) > 0) {
         $this->current_page = absint($_GET['part']) - 1;
     }
     $elementID = isset($_GET['id']) ? absint($_GET['id']) : false;
     switch ($this->current_view) {
         case 'forum':
         case 'addthread':
             if ($this->element_exists($elementID, $this->tables->forums)) {
                 $this->current_forum = $elementID;
                 $this->parent_forum = $this->get_parent_id($this->current_forum, $this->tables->forums, 'parent_forum');
                 $this->current_category = $this->get_parent_id($this->current_forum, $this->tables->forums);
             } else {
                 $this->error = __('Sorry, this forum does not exist.', 'asgaros-forum');
             }
             break;
         case 'movetopic':
         case 'thread':
         case 'addpost':
             if ($this->element_exists($elementID, $this->tables->topics)) {
                 $this->current_topic = $elementID;
                 $this->current_forum = $this->get_parent_id($this->current_topic, $this->tables->topics);
                 $this->parent_forum = $this->get_parent_id($this->current_forum, $this->tables->forums, 'parent_forum');
                 $this->current_category = $this->get_parent_id($this->current_forum, $this->tables->forums);
             } else {
                 $this->error = __('Sorry, this topic does not exist.', 'asgaros-forum');
             }
             break;
         case 'editpost':
             if ($this->element_exists($elementID, $this->tables->posts)) {
                 $this->current_post = $elementID;
                 $this->current_topic = $this->get_parent_id($this->current_post, $this->tables->posts);
                 $this->current_forum = $this->get_parent_id($this->current_topic, $this->tables->topics);
                 $this->parent_forum = $this->get_parent_id($this->current_forum, $this->tables->forums, 'parent_forum');
                 $this->current_category = $this->get_parent_id($this->current_forum, $this->tables->forums);
             } else {
                 $this->error = __('Sorry, this post does not exist.', 'asgaros-forum');
             }
             break;
         case 'search':
             // Go back to overview when search is not enabled.
             if (!$this->options['enable_search']) {
                 $this->current_view = 'overview';
             }
             break;
         default:
             $this->current_view = 'overview';
             break;
     }
     // Check
     $this->check_access();
     // Override editor settings.
     $this->options_editor = apply_filters('asgarosforum_filter_editor_settings', $this->options_editor);
     // Prevent generation of some head-elements.
     remove_action('wp_head', 'rel_canonical');
     remove_action('wp_head', 'wp_shortlink_wp_head');
     remove_action('wp_head', 'wp_oembed_add_discovery_links');
     if (isset($_POST['submit_action']) && (is_user_logged_in() || $this->options['allow_guest_postings'])) {
         if (AsgarosForumInsert::getAction()) {
             AsgarosForumInsert::setData();
             if (AsgarosForumInsert::validateExecution()) {
                 AsgarosForumInsert::insertData();
             }
         }
     } else {
         if ($this->current_view === 'markallread') {
             AsgarosForumUnread::markAllRead();
         } else {
             if (isset($_GET['move_thread'])) {
                 $this->move_thread();
             } else {
                 if (isset($_GET['delete_thread'])) {
                     $this->delete_thread($this->current_topic);
                 } else {
                     if (isset($_GET['remove_post'])) {
                         $this->remove_post();
                     } else {
                         if (isset($_GET['sticky_topic']) || isset($_GET['unsticky_topic'])) {
                             $this->change_status('sticky');
                         } else {
                             if (isset($_GET['open_topic']) || isset($_GET['close_topic'])) {
                                 $this->change_status('closed');
                             } else {
                                 if (isset($_GET['subscribe_topic'])) {
                                     AsgarosForumNotifications::subscribeTopic();
                                 } else {
                                     if (isset($_GET['unsubscribe_topic'])) {
                                         AsgarosForumNotifications::unsubscribeTopic();
                                     } else {
                                         if (isset($_GET['subscribe_forum'])) {
                                             AsgarosForumNotifications::subscribeForum();
                                         } else {
                                             if (isset($_GET['unsubscribe_forum'])) {
                                                 AsgarosForumNotifications::unsubscribeForum();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // Mark visited topic as read.
     if ($this->current_view === 'thread' && $this->current_topic) {
         AsgarosForumUnread::markThreadRead();
     }
 }