public static function validateExecution() { global $asgarosforum; // Cancel if there is already an error. if (!empty($asgarosforum->error)) { return false; } // Cancel if the current user is banned. if (AsgarosForumPermissions::isBanned('current')) { $asgarosforum->error = __('You are banned!', 'asgaros-forum'); return false; } // Cancel if the current user is not allowed to edit that post. if (self::getAction() === 'edit_post' && !AsgarosForumPermissions::isModerator('current') && get_current_user_id() != $asgarosforum->get_post_author($asgarosforum->current_post)) { $asgarosforum->error = __('You are not allowed to do this.', 'asgaros-forum'); return false; } // Cancel if subject is empty. if ((self::getAction() === 'add_thread' || self::getAction() === 'edit_post' && $asgarosforum->is_first_post($asgarosforum->current_post)) && empty(self::$dataSubject)) { $asgarosforum->info = __('You must enter a subject.', 'asgaros-forum'); return false; } // Cancel if content is empty. if (empty(self::$dataContent)) { $asgarosforum->info = __('You must enter a message.', 'asgaros-forum'); return false; } // Do custom insert validation checks. $custom_check = apply_filters('asgarosforum_filter_insert_custom_validation', true); if (!$custom_check) { return false; } return true; }
echo '<div class="notice">' . __('You are not allowed to do this.', 'asgaros-forum') . '</div>'; } if (!$error) { if (!isset($_POST['message']) && isset($_GET['quote']) && $this->element_exists($_GET['quote'], $this->tables->posts)) { $quote_id = absint($_GET['quote']); $text = $this->db->get_row($this->db->prepare("SELECT text, author_id, date FROM {$this->tables->posts} WHERE id = %d;", $quote_id)); $display_name = $this->get_username($text->author_id); $threadcontent = '<blockquote><div class="quotetitle">' . __('Quote from', 'asgaros-forum') . ' ' . $display_name . ' ' . sprintf(__('on %s', 'asgaros-forum'), $this->format_date($text->date)) . '</div>' . $text->text . '</blockquote><br />'; } } } else { if ($this->current_view === 'editpost') { if (!$error) { $id = !empty($_GET['id']) && is_numeric($_GET['id']) ? absint($_GET['id']) : 0; $post = $this->db->get_row($this->db->prepare("SELECT id, text, parent_id, author_id, uploads FROM {$this->tables->posts} WHERE id = %d;", $id)); if (!is_user_logged_in() || get_current_user_id() != $post->author_id && !AsgarosForumPermissions::isModerator('current') || AsgarosForumPermissions::isBanned('current')) { $error = true; echo '<div class="notice">' . __('Sorry, you are not allowed to edit this post.', 'asgaros-forum') . '</div>'; } } if (!$error) { if (!isset($_POST['message'])) { $threadcontent = $post->text; } if (!isset($_POST['subject']) && $this->is_first_post($post->id)) { $threadname = $this->db->get_var($this->db->prepare("SELECT name FROM {$this->tables->topics} WHERE id = %d;", $post->parent_id)); } } } } }
} if ($avatars_available) { echo get_avatar($post->author_id, 80); echo '<br />'; } ?> <strong><?php echo apply_filters('asgarosforum_filter_post_username', $this->get_username($post->author_id), $post->author_id); ?> </strong><br /> <?php // Only show post-counter for existent users. if (get_userdata($post->author_id) != false) { echo '<small>' . sprintf(_n('%s Post', '%s Posts', $post->author_posts, 'asgaros-forum'), $post->author_posts) . '</small>'; } if (AsgarosForumPermissions::isBanned($post->author_id)) { echo '<br /><small class="banned">' . __('Banned', 'asgaros-forum') . '</small>'; } do_action('asgarosforum_after_post_author', $post->author_id, $post->author_posts); ?> </div> <div class="post-message"> <?php $post_content = make_clickable(wpautop($wp_embed->autoembed(stripslashes($post->text)))); if ($this->options['allow_shortcodes']) { // Prevent executing specific shortcodes in posts. $filtered_shortcodes = array(); $filtered_shortcodes[] = 'forum'; $filtered_shortcodes = apply_filters('asgarosforum_filter_post_shortcodes', $filtered_shortcodes); foreach ($filtered_shortcodes as $value) { remove_shortcode($value);
function forum_menu($location, $showallbuttons = true) { $menu = ''; if ($location === 'forum' && (is_user_logged_in() && !AsgarosForumPermissions::isBanned('current') || !is_user_logged_in() && $this->options['allow_guest_postings']) && $this->get_forum_status()) { $menu .= '<a href="' . $this->getLink('topic_add', $this->current_forum) . '"><span class="dashicons-before dashicons-plus-alt"></span><span>' . __('New Topic', 'asgaros-forum') . '</span></a>'; } else { if ($location === 'thread' && (is_user_logged_in() && (AsgarosForumPermissions::isModerator('current') || !$this->get_status('closed') && !AsgarosForumPermissions::isBanned('current')) || !is_user_logged_in() && $this->options['allow_guest_postings'] && !$this->get_status('closed'))) { $menu .= '<a href="' . $this->getLink('post_add', $this->current_topic) . '"><span class="dashicons-before dashicons-plus-alt"></span><span>' . __('Reply', 'asgaros-forum') . '</span></a>'; } } if (is_user_logged_in() && $location === 'thread' && AsgarosForumPermissions::isModerator('current') && $showallbuttons) { $menu .= '<a href="' . $this->getLink('topic_move', $this->current_topic) . '"><span class="dashicons-before dashicons-randomize"></span><span>' . __('Move', 'asgaros-forum') . '</span></a>'; $menu .= '<a href="' . $this->getLink('topic', $this->current_topic, array('delete_thread' => 1)) . '&delete_thread" onclick="return confirm(\'' . __('Are you sure you want to remove this?', 'asgaros-forum') . '\');"><span class="dashicons-before dashicons-trash"></span><span>' . __('Delete', 'asgaros-forum') . '</span></a>'; if ($this->get_status('sticky')) { $menu .= '<a href="' . $this->getLink('topic', $this->current_topic, array('unsticky_topic' => 1)) . '"><span class="dashicons-before dashicons-sticky"></span><span>' . __('Undo Sticky', 'asgaros-forum') . '</span></a>'; } else { $menu .= '<a href="' . $this->getLink('topic', $this->current_topic, array('sticky_topic' => 1)) . '"><span class="dashicons-before dashicons-admin-post"></span><span>' . __('Sticky', 'asgaros-forum') . '</span></a>'; } if ($this->get_status('closed')) { $menu .= '<a href="' . $this->getLink('topic', $this->current_topic, array('open_topic' => 1)) . '"><span class="dashicons-before dashicons-unlock"></span><span>' . __('Open', 'asgaros-forum') . '</span></a>'; } else { $menu .= '<a href="' . $this->getLink('topic', $this->current_topic, array('close_topic' => 1)) . '"><span class="dashicons-before dashicons-lock"></span><span>' . __('Close', 'asgaros-forum') . '</span></a>'; } } return $menu; }