function sp_NoForumMessage($args = '', $deniedMessage = '', $definedMessage = '') { global $spForumView; $defs = array('tagId' => 'spNoForumMessage', 'tagClass' => 'spMessage', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_NoForumMessage_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $echo = (int) $echo; $get = (int) $get; # is Access denied if ($spForumView->forumViewStatus == 'no access') { $m = sp_filter_title_display($deniedMessage); } elseif ($spForumView->forumViewStatus == 'no data') { $m = sp_filter_title_display($definedMessage); } elseif ($spForumView->forumViewStatus == 'sneak peek') { $sflogin = sp_get_option('sflogin'); if (!empty($sflogin['sfsneakredirect'])) { sp_redirect(apply_filters('sph_sneak_redirect', $sflogin['sfsneakredirect'])); } else { $sneakpeek = sp_get_sfmeta('sneakpeek', 'message'); $m = $sneakpeek ? sp_filter_text_display($sneakpeek[0]['meta_value']) : ''; } } else { return; } if ($get) { return $m; } $out = "<div id='{$tagId}' class='{$tagClass}'>{$m}</div>\n"; $out = apply_filters('sph_NoForumMessage', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_groupview_query($groupids = '', $idOrder = false) { global $spThisUser; # can we get the results from the cache? $records = array(); if (empty($spThisUser->inspect['q_spGroupView'])) { $records = sp_get_cache('group'); } if (!$records) { $WHERE = ''; if (!empty($groupids)) { $gcount = count($groupids); $done = 0; foreach ($groupids as $id) { $WHERE .= '(' . SFGROUPS . ".group_id={$id})"; $done++; if ($done < $gcount) { $WHERE .= ' OR '; } } } $this->groupViewStatus = empty($groupids) ? 'no data' : 'no access'; # retrieve group and forum records $spdb = new spdbComplex(); $spdb->table = SFGROUPS; $spdb->fields = SFGROUPS . '.group_id, group_name, group_desc, group_rss, group_icon, group_message, forum_id, forum_name, forum_slug, forum_desc, forum_status, forum_disabled, forum_icon, forum_icon_new, forum_icon_locked, forum_rss_private, post_id, post_id_held, topic_count, post_count, post_count_held, parent, children'; $spdb->join = array(SFFORUMS . ' ON ' . SFGROUPS . '.group_id = ' . SFFORUMS . '.group_id'); $spdb->where = $WHERE; $spdb->orderby = 'group_seq, forum_seq'; $spdb = apply_filters('sph_groupview_query', $spdb, $this); if (!empty($spThisUser->inspect['q_spGroupView'])) { $spdb->inspect = 'spGroupView'; $spdb->show = true; $spThisUser->inspect['q_spGroupView'] = false; } $records = $spdb->select(); if ($records) { sp_add_cache('group', $records); } } $g = ''; if ($records) { # Set status initially to 'no access' in case current user can view no forums $this->groupViewStatus = 'no access'; $gidx = 0; $fidx = 0; $sidx = 0; $cparent = 0; $subPostId = 0; # define array to collect data $p = array(); $g = array(); foreach ($records as $r) { $groupid = $r->group_id; $forumid = $r->forum_id; if (sp_can_view($forumid, 'forum-title')) { if ($gidx == 0 || $g[$gidx]->group_id != $groupid) { # reset status to 'data' $this->groupViewStatus = 'data'; $gidx = $groupid; $fidx = 0; $g[$gidx] = new stdClass(); $g[$gidx]->group_id = $r->group_id; $g[$gidx]->group_name = sp_filter_title_display($r->group_name); $g[$gidx]->group_desc = sp_filter_title_display($r->group_desc); $g[$gidx]->group_rss = esc_url($r->group_rss); $g[$gidx]->group_icon = sanitize_file_name($r->group_icon); $g[$gidx]->group_message = sp_filter_text_display($r->group_message); $g[$gidx]->group_rss_active = 0; $g[$gidx] = apply_filters('sph_groupview_group_records', $g[$gidx], $r); } if (isset($r->forum_id)) { # Is this a subform? if ($r->parent != 0) { $sidx = $r->forum_id; $g[$gidx]->forums[$cparent]->subforums[$sidx] = new stdClass(); $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_id = $r->forum_id; $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_name = sp_filter_title_display($r->forum_name); $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_slug = $r->forum_slug; $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_icon = sanitize_file_name($r->forum_icon); $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_icon_new = sanitize_file_name($r->forum_icon_new); $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_icon_locked = sanitize_file_name($r->forum_icon_locked); $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_disabled = $r->forum_disabled; $g[$gidx]->forums[$cparent]->subforums[$sidx]->forum_permalink = sp_build_url($r->forum_slug, '', 1, 0); $g[$gidx]->forums[$cparent]->subforums[$sidx]->topic_count = $r->topic_count; $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_count = $r->post_count; $g[$gidx]->forums[$cparent]->subforums[$sidx]->parent = $r->parent; $g[$gidx]->forums[$cparent]->subforums[$sidx]->children = $r->children; $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_id = $r->post_id; $g[$gidx]->forums[$cparent]->subforums[$sidx]->unread = 0; # check if we can look at posts in moderation - if not swap for 'held' values if (!sp_get_auth('moderate_posts', $r->forum_id)) { $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_count = $r->post_count_held; $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_id = $r->post_id_held; } # See if any forums are in the current users newpost list if ($spThisUser->member && isset($spThisUser->newposts['forums'])) { $c = 0; if ($spThisUser->newposts['forums']) { foreach ($spThisUser->newposts['forums'] as $fnp) { if ($fnp == $sidx) { $c++; } } } # set the subforum unread count $g[$gidx]->forums[$cparent]->subforums[$sidx]->unread = $c; } # Update top parent counts with subforum counts $g[$gidx]->forums[$cparent]->topic_count_sub += $g[$gidx]->forums[$cparent]->subforums[$sidx]->topic_count; $g[$gidx]->forums[$cparent]->post_count_sub += $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_count; # and what about the most recent post? Is this in a subforum? if ($g[$gidx]->forums[$cparent]->subforums[$sidx]->post_id > $g[$gidx]->forums[$cparent]->post_id && $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_id > $subPostId) { # store the alternative forum id in case we need to display the topic data for this one if inc. subs $g[$gidx]->forums[$cparent]->forum_id_sub = $r->forum_id; # add the last post in subforum to the list for stats retrieval $subPostId = $g[$gidx]->forums[$cparent]->subforums[$sidx]->post_id; $p[$r->forum_id] = $subPostId; } } else { # it's a top level forum $subPostId = 0; $fidx = $forumid; $g[$gidx]->forums[$fidx] = new stdClass(); $g[$gidx]->forums[$fidx]->forum_id = $r->forum_id; $g[$gidx]->forums[$fidx]->forum_id_sub = 0; $g[$gidx]->forums[$fidx]->forum_name = sp_filter_title_display($r->forum_name); $g[$gidx]->forums[$fidx]->forum_slug = $r->forum_slug; $g[$gidx]->forums[$fidx]->forum_permalink = sp_build_url($r->forum_slug, '', 1, 0); $g[$gidx]->forums[$fidx]->forum_desc = sp_filter_title_display($r->forum_desc); $g[$gidx]->forums[$fidx]->forum_status = $r->forum_status; $g[$gidx]->forums[$fidx]->forum_disabled = $r->forum_disabled; $g[$gidx]->forums[$fidx]->forum_icon = sanitize_file_name($r->forum_icon); $g[$gidx]->forums[$fidx]->forum_icon_new = sanitize_file_name($r->forum_icon_new); $g[$gidx]->forums[$fidx]->forum_icon_locked = sanitize_file_name($r->forum_icon_locked); $g[$gidx]->forums[$fidx]->forum_rss_private = $r->forum_rss_private; $g[$gidx]->forums[$fidx]->post_id = $r->post_id; $g[$gidx]->forums[$fidx]->topic_count = $r->topic_count; $g[$gidx]->forums[$fidx]->topic_count_sub = $r->topic_count; $g[$gidx]->forums[$fidx]->post_count = $r->post_count; $g[$gidx]->forums[$fidx]->post_count_sub = $r->post_count; $g[$gidx]->forums[$fidx]->parent = $r->parent; $g[$gidx]->forums[$fidx]->children = $r->children; $g[$gidx]->forums[$fidx]->unread = 0; if (empty($g[$gidx]->forums[$fidx]->post_id)) { $g[$gidx]->forums[$fidx]->post_id = 0; } # Can the user create new topics or should we lock the forum? $g[$gidx]->forums[$fidx]->start_topics = sp_get_auth('start_topics', $r->forum_id); # check if we can look at posts in moderation - if not swap for 'held' values if (!sp_get_auth('moderate_posts', $r->forum_id)) { $g[$gidx]->forums[$fidx]->post_id = $r->post_id_held; $g[$gidx]->forums[$fidx]->post_count = $r->post_count_held; $g[$gidx]->forums[$fidx]->post_count_sub = $r->post_count_held; $thisPostid = $r->post_id_held; } else { $thisPostid = $r->post_id; } # See if any forums are in the current users newpost list if ($spThisUser->member && isset($spThisUser->newposts['forums'])) { $c = 0; if ($spThisUser->newposts['forums']) { foreach ($spThisUser->newposts['forums'] as $fnp) { if ($fnp == $fidx) { $c++; } } } $g[$gidx]->forums[$fidx]->unread = $c; } if (empty($r->children)) { $cparent = 0; } else { $cparent = $fidx; $sidx = 0; } # Build post id array for collecting stats at the end if (!empty($thisPostid)) { $p[$fidx] = $thisPostid; } $g[$gidx]->forums[$fidx] = apply_filters('sph_groupview_forum_records', $g[$gidx]->forums[$fidx], $r); } # Build special Group level flag on whether to show group RSS button or not (based on any forum in group having RSS access if (sp_get_auth('view_forum', $r->forum_id) && !$r->forum_rss_private) { $g[$gidx]->group_rss_active = 1; } } } } } if ($this->includeStats == true) { # Go grab the forum stats and data if (!empty($p)) { $stats = $this->sp_groupview_stats_query($p); if ($stats) { foreach ($g as $gr) { foreach ($gr->forums as $f) { if (!empty($stats[$f->forum_id])) { $s = $stats[$f->forum_id]; $f->topic_id = $s->topic_id; $f->topic_name = sp_filter_title_display($s->topic_name); $f->topic_slug = $s->topic_slug; $f->post_id = $s->post_id; $f->post_permalink = sp_build_url($f->forum_slug, $s->topic_slug, 0, $s->post_id, $s->post_index); $f->post_date = $s->post_date; $f->post_status = $s->post_status; $f->post_index = $s->post_index; # see if we can display the tooltip if (sp_can_view($f->forum_id, 'post-content', $spThisUser->ID, $s->user_id, $s->topic_id, $s->post_id)) { $f->post_tip = $s->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($s->post_content, $s->post_status); } else { $f->post_tip = ''; } $f->user_id = $s->user_id; $f->display_name = sp_filter_name_display($s->display_name); $f->guest_name = sp_filter_name_display($s->guest_name); } # do we need to record a possible subforum substitute topic? $fsub = $f->forum_id_sub; if ($fsub != 0 && !empty($stats[$fsub])) { $s = $stats[$fsub]; $f->topic_id_sub = $s->topic_id; $f->topic_name_sub = sp_filter_title_display($s->topic_name); $f->topic_slug_sub = $s->topic_slug; $f->post_id_sub = $s->post_id; $f->post_permalink_sub = sp_build_url($f->subforums[$fsub]->forum_slug, $s->topic_slug, 0, $s->post_id, $s->post_index); $f->post_date_sub = $s->post_date; $f->post_status_sub = $s->post_status; $f->post_index_sub = $s->post_index; # see if we can display the tooltip if (sp_can_view($fsub, 'post-content', $spThisUser->ID, $s->user_id, $s->topic_id, $s->post_id)) { $f->post_tip_sub = $s->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($s->post_content, $s->post_status); } else { $f->post_tip_sub = ''; } $f->user_id_sub = $s->user_id; $f->display_name_sub = sp_filter_name_display($s->display_name); $f->guest_name_sub = sp_filter_name_display($s->guest_name); } $f = apply_filters('sph_groupview_stats_records', $f, $s); } } unset($stats); } } } # Do we need to re-order IDs based on passed in IDs if ($groupids && $idOrder) { $n = array(); foreach ($groupids as $gid) { if (array_key_exists($gid, $g)) { $n[$gid] = $g[$gid]; } } $g = $n; unset($n); } return $g; }
function spUser_filter_item($item, $filter) { if (is_array($item)) { return $item; } switch ($filter) { case 'title': $item = sp_filter_title_display($item); break; case 'email': $item = sp_filter_email_display($item); break; case 'url': $item = sp_filter_url_display($item); break; case 'text': $item = sp_filter_text_display($item); break; case 'name': $item = sp_filter_name_display($item); break; case 'signature': $item = sp_filter_signature_display($item); break; } return $item; }
function sp_topicview_query($topicid = 0, $cPage = 1, $forumid = 0) { global $spGlobals, $spThisUser, $spVars; # do we have a valid topic id if ($topicid == 0) { $this->topicViewStatus = 'no data'; return; } else { $WHERE = SFTOPICS . '.topic_id=' . $topicid; } # default to no access $this->topicViewStatus = 'no access'; # some setup vars $startlimit = 0; $lastpage = 0; # how many posts per page? $ppaged = $spGlobals['display']['posts']['perpage']; if (!$ppaged) { $ppaged = 10; } # setup where we are in the post list (paging) if ($cPage != 1) { $startlimit = ($cPage - 1) * $ppaged; } $LIMIT = $startlimit . ', ' . $ppaged; # Set up order by $setSort = false; $reverse = false; $setSort = $spGlobals['display']['posts']['sortdesc']; if (isset($spGlobals['sort_order']['topic'])) { $reverse = array_search($topicid, (array) $spGlobals['sort_order']['topic']) !== false ? true : false; } if (isset($spThisUser->postDESC) && $spThisUser->postDESC) { $reverse = !$reverse; } if ($setSort xor $reverse) { $ORDER = 'post_pinned DESC, ' . SFPOSTS . ".post_id DESC"; } else { $ORDER = 'post_pinned DESC, ' . SFPOSTS . ".post_id ASC"; } # add newpost/sfwaiting support for admins $waitCheck = ', NULL AS new_post'; if ($spThisUser->admin || $spThisUser->moderator) { $waitCheck = ', ' . SFWAITING . '.post_count AS new_post'; } # Discover if this topic is in users new post list $maybeNewPost = false; if ($spThisUser->member && sp_is_in_users_newposts($topicid)) { $maybeNewPost = true; } # retrieve topic and post records $spdb = new spdbComplex(); $spdb->table = SFTOPICS; $spdb->found_rows = true; $spdb->fields = 'group_id, ' . SFTOPICS . '.topic_id, ' . SFTOPICS . '.forum_id, topic_name, topic_slug, topic_status, topic_pinned, topic_icon, topic_opened, ' . SFTOPICS . '.post_count, forum_name, forum_slug, forum_status, forum_disabled, forum_rss_private, ' . SFPOSTS . '.post_id, ' . spdb_zone_datetime('post_date') . ', ' . SFPOSTS . '.user_id, ' . SFTOPICS . '.user_id AS topic_starter, guest_name, guest_email, post_status, post_pinned, post_index, post_edit, poster_ip, source, post_content' . $waitCheck; $spdb->join = array(SFPOSTS . ' ON ' . SFTOPICS . '.topic_id=' . SFPOSTS . '.topic_id', SFFORUMS . ' ON ' . SFTOPICS . '.forum_id=' . SFFORUMS . '.forum_id'); if ($spThisUser->admin || $spThisUser->moderator) { $spdb->left_join = array(SFWAITING . ' ON ' . SFPOSTS . '.post_id=' . SFWAITING . '.post_id'); } $spdb->where = $WHERE; $spdb->orderby = $ORDER; $spdb->limits = $LIMIT; $spdb = apply_filters('sph_topicview_query', $spdb, $this); if (!empty($spThisUser->inspect['q_spTopicView'])) { $spdb->inspect = 'spTopicView'; $spdb->show = true; } $records = $spdb->select(); $t = array(); if ($records) { $tidx = $topicid; $pidx = 0; $r = current($records); if (sp_get_auth('view_forum', $r->forum_id)) { $this->topicViewStatus = 'data'; # construct the parent topic object $t[$tidx] = new stdClass(); $t[$tidx]->topic_id = $r->topic_id; $t[$tidx]->forum_id = $r->forum_id; $t[$tidx]->group_id = $r->group_id; $t[$tidx]->forum_name = sp_filter_title_display($r->forum_name); $t[$tidx]->topic_name = sp_filter_title_display($r->topic_name); $t[$tidx]->topic_slug = $r->topic_slug; $t[$tidx]->topic_opened = $r->topic_opened; $t[$tidx]->forum_status = $r->forum_status; $t[$tidx]->topic_pinned = $r->topic_pinned; $t[$tidx]->forum_disabled = $r->forum_disabled; $t[$tidx]->forum_slug = $r->forum_slug; $t[$tidx]->forum_rss_private = $r->forum_rss_private; $t[$tidx]->topic_permalink = sp_build_url($r->forum_slug, $r->topic_slug, 1, 0); $t[$tidx]->topic_status = $r->topic_status; $t[$tidx]->topic_icon = sanitize_file_name($r->topic_icon); $t[$tidx]->rss = ''; $t[$tidx]->editmode = 0; $t[$tidx]->tools_flag = 1; $t[$tidx]->display_page = $this->topicPage; $t[$tidx]->posts_per_page = $ppaged; $t[$tidx]->unread = 0; # user calc_rows and nor post_count as - for example - some posts may be hiodden by choice. $t[$tidx]->post_count = spdb_select('var', 'SELECT FOUND_ROWS()'); # Can the user create new topics or should we lock the forum? $t[$tidx]->start_topics = sp_get_auth('start_topics', $r->forum_id); $t[$tidx]->reply_topics = sp_get_auth('reply_topics', $r->forum_id); $t[$tidx]->reply_own_topics = sp_get_auth('reply_own_topics', $r->forum_id); # grab topic start info $t[$tidx]->topic_starter = $r->topic_starter; $totalPages = $r->post_count / $ppaged; if (!is_int($totalPages)) { $totalPages = intval($totalPages) + 1; } $t[$tidx]->total_pages = $totalPages; if ($setSort xor $reverse) { if ($cPage == 1) { $lastpage = true; } } else { if ($cPage == $totalPages) { $lastpage = true; } } $t[$tidx]->last_page = $lastpage; $t[$tidx] = apply_filters('sph_topicview_topic_record', $t[$tidx], $r); reset($records); unset($r); # now loop through the post records $newPostFlag = false; $firstPostPage = 1; $pinned = 0; # define post id and post user id arrays for plugins to use in combined filter $p = array(); $u = array(); foreach ($records as $r) { $pidx = $r->post_id; $p[] = $pidx; # prepare for user object $cUser = $spThisUser->ID == $r->user_id; $cSmall = !$cUser; $t[$tidx]->posts[$pidx] = new stdClass(); $t[$tidx]->posts[$pidx]->post_id = $r->post_id; $t[$tidx]->posts[$pidx]->post_date = $r->post_date; $t[$tidx]->posts[$pidx]->user_id = $r->user_id; $t[$tidx]->posts[$pidx]->guest_name = sp_filter_name_display($r->guest_name); $t[$tidx]->posts[$pidx]->guest_email = sp_filter_email_display($r->guest_email); $t[$tidx]->posts[$pidx]->post_status = $r->post_status; $t[$tidx]->posts[$pidx]->post_pinned = $r->post_pinned; $t[$tidx]->posts[$pidx]->post_index = $r->post_index; $t[$tidx]->posts[$pidx]->poster_ip = $r->poster_ip; $t[$tidx]->posts[$pidx]->source = $r->source; $t[$tidx]->posts[$pidx]->post_permalink = sp_build_url($r->forum_slug, $r->topic_slug, $cPage, $r->post_id); $t[$tidx]->posts[$pidx]->edits = ''; $t[$tidx]->posts[$pidx]->last_post = 0; $t[$tidx]->posts[$pidx]->last_post_on_page = 0; $t[$tidx]->posts[$pidx]->first_post_on_page = $firstPostPage; $t[$tidx]->posts[$pidx]->editmode = 0; $t[$tidx]->posts[$pidx]->post_content = sp_filter_content_display($r->post_content); $t[$tidx]->posts[$pidx]->first_pinned = 0; $t[$tidx]->posts[$pidx]->last_pinned = 0; $t[$tidx]->posts[$pidx]->postUser = new stdClass(); $t[$tidx]->posts[$pidx]->postUser = clone sp_get_user($r->user_id, $cUser, $cSmall); # populate the user guest name and email in case the poster is a guest if ($r->user_id == 0) { $t[$tidx]->posts[$pidx]->postUser->guest_name = $t[$tidx]->posts[$pidx]->guest_name; $t[$tidx]->posts[$pidx]->postUser->guest_email = $t[$tidx]->posts[$pidx]->guest_email; $t[$tidx]->posts[$pidx]->postUser->display_name = $t[$tidx]->posts[$pidx]->guest_name; $t[$tidx]->posts[$pidx]->postUser->ip = $t[$tidx]->posts[$pidx]->poster_ip; } # pinned status if ($firstPostPage == 1 && $r->post_pinned) { $t[$tidx]->posts[$pidx]->first_pinned = true; $pinned = $pidx; } if ($firstPostPage == 0 && $pinned > 0 && $r->post_pinned == false) { $t[$tidx]->posts[$pinned]->last_pinned = true; } elseif ($r->post_pinned) { $pinned = $pidx; } $firstPostPage = 0; # Is this a new post for the current user? if ($spThisUser->guest) { $newPostFlag = false; } else { if ($maybeNewPost && strtotime($r->post_date) > strtotime($spThisUser->lastvisit)) { $newPostFlag = true; } if (isset($r->new_post)) { $newPostFlag = true; } } $t[$tidx]->posts[$pidx]->new_post = $newPostFlag; # do we need to hide an admin post? if (!sp_get_auth('view_admin_posts', $r->forum_id) && sp_is_forum_admin($r->user_id)) { $adminview = sp_get_sfmeta('adminview', 'message'); if ($adminview) { $t[$tidx]->posts[$pidx]->post_content = '<div class="spMessage">'; $t[$tidx]->posts[$pidx]->post_content .= sp_filter_text_display($adminview[0]['meta_value']); $t[$tidx]->posts[$pidx]->post_content .= '</div>'; } else { $t[$tidx]->posts[$pidx]->post_content = ''; } } # do we need to hide an others posts? if (sp_get_auth('view_own_admin_posts', $r->forum_id) && !sp_is_forum_admin($r->user_id) && !sp_is_forum_mod($r->user_id) && $spThisUser->ID != $r->user_id) { $userview = sp_get_sfmeta('userview', 'message'); if ($userview) { $t[$tidx]->posts[$pidx]->post_content = '<div class="spMessage">'; $t[$tidx]->posts[$pidx]->post_content .= sp_filter_text_display($userview[0]['meta_value']); $t[$tidx]->posts[$pidx]->post_content .= '</div>'; } else { $t[$tidx]->posts[$pidx]->post_content = ''; } } # Is this post to be edited? if ($spVars['displaymode'] == 'edit' && $spVars['postedit'] == $r->post_id) { $t[$tidx]->editmode = 1; $t[$tidx]->editpost_id = $r->post_id; $t[$tidx]->editpost_content = sp_filter_content_edit($r->post_content); $t[$tidx]->posts[$pidx]->editmode = 1; } # Add edit history if (!empty($r->post_edit) && is_serialized($r->post_edit)) { $edits = unserialize($r->post_edit); $eidx = 0; foreach ($edits as $e) { $t[$tidx]->posts[$pidx]->edits[$eidx] = new stdClass(); $t[$tidx]->posts[$pidx]->edits[$eidx]->by = $e['by']; $t[$tidx]->posts[$pidx]->edits[$eidx]->at = $e['at']; $eidx++; } } if (!in_array($r->user_id, $u)) { $u[] = $r->user_id; } $t[$tidx]->posts[$pidx] = apply_filters('sph_topicview_post_records', $t[$tidx]->posts[$pidx], $r); } # index of post IDs with position in listing $t[$tidx]->post_keys = $p; $t[$tidx]->posts[$pidx]->last_post = $lastpage; $t[$tidx]->posts[$pidx]->last_post_on_page = 1; # save last post on page id $t[$tidx]->last_post_id = $r->post_id; # allow plugins to add more data to combined topic/post data structure $t[$tidx] = apply_filters('sph_topicview_combined_data', $t[$tidx], $p, $u); unset($records); } else { # check for view forum lists but not topic lists if (sp_can_view($r->forum_id, 'forum-title')) { $this->topicViewStatus = 'sneak peek'; } } } return $t; }
function spa_paint_group_forums($groupid, $parent, $parentname, $level) { $space = '<img class="subArrow" src="' . SFADMINIMAGES . 'sp_SubforumLevel.png" alt="" />'; $forums = spa_get_group_forums_by_parent($groupid, $parent); $noMembers = array(); if ($forums) { $noMembers = spa_forums_check_memberships($forums); foreach ($forums as $forum) { $subforum = $forum->parent; $haschild = ''; if ($forum->children) { $childlist = array(unserialize($forum->children)); if (count($childlist) > 0) { $haschild = $childlist; } } if (empty($forum->forum_icon)) { $icon = SPTHEMEICONSURL . 'sp_ForumIcon.png'; } else { $icon = esc_url(SFCUSTOMURL . $forum->forum_icon); if (!file_exists(SFCUSTOMDIR . $forum->forum_icon)) { $icon = SPTHEMEICONSURL . 'sp_ForumIcon.png'; } } $rowClass = in_array($forum->forum_id, $noMembers) ? ' class="spWarningBG"' : ''; ?> <tr id="forumrow-<?php echo $forum->forum_id; ?> " <?php echo $rowClass; ?> > <!-- display forum information for each forum --> <td style="text-align:center;width:2%"><?php echo $forum->forum_id; ?> </td> <td style="text-align:center;padding:8px 0px;width:5%"><?php echo '<img src="' . $icon . '" alt="" title="' . spa_text('Current forum icon') . '" />'; ?> <?php if ($haschild) { ?> <br /><img class="parentArrow" src="<?php echo SFADMINIMAGES . 'sp_HasChild.png'; ?> " alt="" title="<?php spa_etext('Parent Forum'); ?> " /> <?php } ?> </td> <td> <div class="sp-half-row-left"> <?php if ($forum->forum_status) { echo '<img class="sfalignright" src="' . SFADMINIMAGES . 'sp_LockedBig.png" alt="" />'; } if ($subforum) { ?> <?php if ($forum->forum_disabled) { echo '<img class="sfalignright" src="' . SFADMINIMAGES . 'sp_NoWrite.png" alt="" title="' . spa_text('Subforum is disabled') . '" /> '; } ?> <?php echo str_repeat($space, $level - 1); ?> <img class="subArrow" src="<?php echo SFADMINIMAGES . 'sp_Subforum.png'; ?> " alt="" title="<?php spa_etext('Subforum'); ?> " /> <div class='row-title'><strong><?php echo sp_filter_title_display($forum->forum_name); ?> </strong></div><div>(<?php echo spa_text('Subforum of') . ': ' . $parentname . ')'; ?> </div><div><?php echo sp_filter_text_display($forum->forum_desc); ?> </div> <?php } else { ?> <?php if ($forum->forum_disabled) { echo '<img class="sfalignright" src="' . SFADMINIMAGES . 'sp_NoWrite.png" alt="" title="' . spa_text('Forum is disabled') . '" /> '; } ?> <div class='row-title'><strong><?php echo sp_filter_title_display($forum->forum_name); ?> </strong></div><div><?php echo sp_filter_text_display($forum->forum_desc); ?> </div> <?php } if (in_array($forum->forum_id, $noMembers)) { echo '<p><b>' . spa_text('Warning - There are no usergroups with members that have permission to use this forum') . '</b></p>'; } sp_display_item_stats(SFTOPICS, 'forum_id', $forum->forum_id, spa_text('Topics')); echo ' | '; sp_display_item_stats(SFPOSTS, 'forum_id', $forum->forum_id, spa_text('Posts')); ?> </div> <div class="sp-half-row-right"> <?php $base = SFHOMEURL . 'index.php?sp_ahah=forums-loader&sfnonce=' . wp_create_nonce('forum-ahah'); $target = "forum-{$forum->forum_id}"; $image = SFADMINIMAGES; ?> <input id="sfreloadpb<?php echo $forum->forum_id; ?> " type="button" class="button-secondary" value="<?php echo sp_splice(spa_text('Forum Permissions'), 0); ?> " onclick="spjLoadForm('forumperm', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $forum->forum_id; ?> ');" /> <input type="button" class="button-secondary" value="<?php echo sp_splice(spa_text('Edit Forum'), 0); ?> " onclick="spjLoadForm('editforum', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $forum->forum_id; ?> ');" /> <input type="button" class="button-secondary" value="<?php echo sp_splice(spa_text('Delete Forum'), 0); ?> " onclick="spjLoadForm('deleteforum', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $forum->forum_id; ?> ');" /> <?php if ($forum->forum_disabled) { ?> <input type="button" class="button-secondary" value="<?php echo sp_splice(spa_text('Enable Forum'), 0); ?> " onclick="spjLoadForm('enableforum', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $forum->forum_id; ?> ');" /> <?php } else { ?> <input type="button" class="button-secondary" value="<?php echo sp_splice(spa_text('Disable Forum'), 0); ?> " onclick="spjLoadForm('disableforum', '<?php echo $base; ?> ', '<?php echo $target; ?> ', '<?php echo $image; ?> ', '<?php echo $forum->forum_id; ?> ');" /> <?php } ?> </div> </td> </tr> <tr class="sfinline-form"> <!-- This row will hold ahah forms for the current forum --> <td colspan="3" style="padding: 0 10px 0 0;border-bottom:1px solid #dddddd"> <div id="forum-<?php echo $forum->forum_id; ?> "></div> </td> </tr> <?php if ($haschild) { $newlevel = $level + 1; spa_paint_group_forums($groupid, $forum->forum_id, $forum->forum_name, $newlevel); } } } }
function sp_render_add_topic_form($args) { global $spVars, $spGlobals, $spThisForum, $spThisUser, $spGuestCookie; include_once SF_PLUGIN_DIR . '/forum/content/forms/sp-form-components.php'; $toolbar = $spGlobals['display']['editor']['toolbar']; $defs = array('tagClass' => 'spForm', 'hide' => 1, 'controlFieldset' => 'spEditorFieldset', 'controlInput' => 'spControl', 'controlSubmit' => 'spSubmit', 'controlOrder' => 'cancel|save', 'maxTitleLength' => 200, 'labelHeading' => sp_text('Add Topic'), 'labelGuestName' => sp_text('Guest name (required)'), 'labelGuestEmail' => sp_text('Guest email (required)'), 'labelModerateAll' => sp_text('NOTE: new posts are subject to administrator approval before being displayed'), 'labelModerateOnce' => sp_text('NOTE: first posts are subject to administrator approval before being displayed'), 'labelTopicName' => sp_text('Topic name'), 'labelSmileys' => sp_text('Smileys'), 'labelOptions' => sp_text('Options'), 'labelOptionLock' => sp_text('Lock this topic'), 'labelOptionPin' => sp_text('Pin this post'), 'labelOptionTime' => sp_text('Edit post timestamp'), 'labelMath' => sp_text('Math Required'), 'labelMathSum' => sp_text('What is the sum of'), 'labelPostButtonReady' => sp_text('Submit Topic'), 'labelPostButtonMath' => sp_text('Do Math To Save'), 'labelPostCancel' => sp_text('Cancel'), 'tipSmileysButton' => sp_text('Open/Close to Add a Smiley'), 'tipOptionsButton' => sp_text('Open/Close to select Posting Options'), 'tipSubmitButton' => sp_text('Save the New Topic'), 'tipCancelButton' => sp_text('Cancel the New Topic')); $a = wp_parse_args($args, $defs); extract($a, EXTR_SKIP); # sanitize $tagClass = esc_attr($tagClass); $hide = (int) $hide; $controlFieldset = esc_attr($controlFieldset); $controlInput = esc_attr($controlInput); $maxTitleLength = (int) $maxTitleLength; $labelHeading = sp_filter_title_display($labelHeading); $labelGuestName = sp_filter_title_display($labelGuestName); $labelGuestEmail = sp_filter_title_display($labelGuestEmail); $labelModerateAll = sp_filter_title_display($labelModerateAll); $labelModerateOnce = sp_filter_title_display($labelModerateOnce); $labelTopicName = sp_filter_title_display($labelTopicName); # Check for a failure package in case this is a redirect $f = sp_get_cache('post'); if (isset($f['guestname']) ? $guestnameval = $f['guestname'] : ($guestnameval = $spGuestCookie->guest_name)) { } if (isset($f['guestemail']) ? $guestemailval = $f['guestemail'] : ($guestemailval = $spGuestCookie->guest_email)) { } if (isset($f['newtopicname']) ? $topicnameval = $f['newtopicname'] : ($topicnameval = '')) { } if (isset($f['postitem']) ? $postitemval = $f['postitem'] : ($postitemval = '')) { } if (isset($f['message']) ? $failmessage = $f['message'] : ($failmessage = '')) { } $captchaValue = sp_get_option('captcha-value'); $out = ''; # Grab above editor message if there is one $postmsg = sp_get_option('sfpostmsg'); # Grab in-editor message if one $inEdMsg = sp_filter_text_display(sp_get_option('sfeditormsg')); if ($hide ? $hide = ' style="display:none;"' : ($hide = '')) { } $out .= '<div id="spPostForm"' . $hide . '>' . "\n"; $out .= "<form class='{$tagClass}' action='" . SFHOMEURL . "index.php?sp_ahah=post&sfnonce=" . wp_create_nonce('forum-ahah') . "' method='post' id='addtopic' name='addtopic' onsubmit='return spjValidatePostForm(this, {$spThisUser->guest}, 1, \"" . sp_paint_file_icon(SPTHEMEICONSURL, 'sp_Success.png') . "\");'>\n"; $out .= sp_create_nonce('forum-userform_addtopic'); $out .= '<div class="spEditor">' . "\n"; $out = apply_filters('sph_topic_editor_top', $out, $spThisForum); $out .= "<fieldset class='{$controlFieldset}'>\n"; $out .= "<legend>{$labelHeading}: " . $spThisForum->forum_name . "</legend>\n"; $out .= "<input type='hidden' name='action' value='topic' />\n"; $out .= "<input type='hidden' name='forumid' value='{$spThisForum->forum_id}' />\n"; $out .= "<input type='hidden' name='forumslug' value='{$spThisForum->forum_slug}' />\n"; $out .= "<input type='hidden' name='captcha' value='{$captchaValue}' />\n"; # input field that plugins can use $out .= "<input type='hidden' id='spEditorCustomValue' name='spEditorCustomValue' value='' />\n"; # plugins can add before the header $out = apply_filters('sph_topic_before_editor_header', $out, $spThisForum, $a); $tout = ''; $tout .= '<div class="spEditorSection">'; # let plugins add stuff at top of editor header $tout = apply_filters('sph_topic_editor_header_top', $tout, $spThisForum, $a); if (!empty($postmsg['sfpostmsgtopic'])) { $tout .= '<div class="spEditorMessage">' . sp_filter_text_display($postmsg['sfpostmsgtext']) . '</div>' . "\n"; } # create an empty div to allow plugins to add something $tout .= '<div id="spEditorCustomDiv"></div>'; if ($spThisUser->guest) { $tout .= '<div class="spEditorSectionLeft">' . "\n"; $tout .= "<div class='spEditorTitle'>{$labelGuestName}:\n"; $tout .= "<input type='text' tabindex='100' class='{$controlInput}' name='guestname' value='{$guestnameval}' /></div>\n"; $tout .= '</div>' . "\n"; $sfguests = sp_get_option('sfguests'); if ($sfguests['reqemail']) { $tout .= '<div class="spEditorSectionRight">' . "\n"; $tout .= "<div class='spEditorTitle'>{$labelGuestEmail}:\n"; $tout .= "<input type='text' tabindex='101' class='{$controlInput}' name='guestemail' value='{$guestemailval}' /></div>\n"; $tout .= '</div>' . "\n"; } $tout .= '<div class="spClear"></div>' . "\n"; } if (!sp_get_auth('bypass_moderation', $spThisForum->forum_id)) { $tout .= "<p class='spLabelSmall'>{$labelModerateAll}</p>\n"; } elseif (!sp_get_auth('bypass_moderation_once', $spThisForum->forum_id)) { $tout .= "<p class='spLabelSmall'>{$labelModerateOnce}</p>\n"; } $tout2 = ''; $tout2 .= "<div class='spEditorTitle'>{$labelTopicName}: \n"; $tout2 .= "<input id='spTopicTitle' type='text' tabindex='102' class='{$controlInput}' maxlength='{$maxTitleLength}' name='newtopicname' value='{$topicnameval}'/>\n"; $tout2 = apply_filters('sph_topic_editor_name', $tout2, $a); $tout2 .= '</div>' . "\n"; $tout .= apply_filters('sph_topic_editor_title', $tout2, $spThisForum, $a); # let plugins add stuff at bottom of editor header $tout = apply_filters('sph_topic_editor_header_bottom', $tout, $spThisForum, $a); $tout .= '</div>' . "\n"; # allow plugins to filter just the header $out .= apply_filters('sph_topic_editor_header', $tout, $spThisForum, $a); # do we have content? Or just add any inline message if (empty($postitemval)) { $postitemval = $inEdMsg; } # Display the selected editor $tout = ''; $tout .= '<div id="spEditorContent">' . "\n"; $tout .= sp_setup_editor(103, $postitemval); $tout .= '</div>' . "\n"; # allow plugins to filter the editor content $out .= apply_filters('sph_topic_editor_content', $tout, $spThisForum, $a); # define area above toolbar for plugins to add components $section = apply_filters('sph_topic_editor_above_toolbar', '', $spThisForum, $a); if (!empty($section)) { $tout = ''; $tout .= '<div class="spEditorSection">'; $tout .= $section; $tout .= '</div>' . "\n"; $out .= apply_filters('sph_topic_editor_above_toolbar_end', $tout, $spThisForum, $a); } # DEFINE NEW FAILURE AREA HERE # define validation failure notice area $out .= "<div class='spClear'></div>\n"; $out .= "<div id='spPostNotifications'>{$failmessage}</div>\n"; # TOOLBAR # define toolbar - submit buttons on right, plugin extensions on left $toolbarRight = apply_filters('sph_topic_editor_toolbar_submit', '', $spThisForum, $a, 'toolbar'); $toolbarLeft = apply_filters('sph_topic_editor_toolbar_buttons', '', $spThisForum, $a, 'toolbar'); if (!empty($toolbarRight) || !empty($toolbarLeft)) { # Submit section $tout = ''; $tout .= '<div class="spEditorSection spEditorToolbar">'; $tout .= $toolbarRight; # toolbar for plugins to add buttons $tout .= $toolbarLeft; $out .= apply_filters('sph_topic_editor_toolbar', $tout, $spThisForum, $a, 'toolbar'); $out .= '<div style="clear:both"></div>'; $out .= '</div>' . "\n"; } # START SMILEYS/OPTIONS # let plugins add stuff at top of editor footer $tout = ''; $tout = apply_filters('sph_topic_editor_footer_top', $tout, $spThisForum, $a); # smileys and options $tout = apply_filters('sp_topic_editor_inline_footer', $tout, $spThisForum, $a, 'inline'); # let plugins add stuff at end of editor footer $tout = apply_filters('sph_topic_editor_footer_bottom', $tout, $spThisForum, $a); # plugins can remove or adjust whole footer $out .= apply_filters('sph_topic_editor_footer', $tout, $spThisForum, $a); # allow plugins to insert stuff after editor footer $out = apply_filters('sph_topic_editor_after_footer', $out, $spThisForum, $a); # START SUBMIT SECTION # define submit section of no toolbar in use if (!$toolbar) { $out .= '<div class="spEditorSubmit">' . "\n"; $out = apply_filters('sph_topic_editor_submit_top', $out, $spThisForum, $a); # let plugins add/remove the controls area $tout = apply_filters('sp_topic_editor_inline_submit', '', $spThisForum, $a, 'inline'); # let plugins add stuff at end of editor submit bottom $out .= apply_filters('sph_topic_editor_submit_bottom', $tout, $spThisForum, $a); $out .= '</div>' . "\n"; } # close it up $out .= '</fieldset>' . "\n"; $out = apply_filters('sph_topic_editor_bottom', $out, $spThisForum, $a); $out .= '</div>' . "\n"; $out .= '</form>' . "\n"; $out .= '</div>' . "\n"; # let plugins add stuff beneath the editor $out = apply_filters('sph_topic_editor_beneath', $out, $spThisForum, $a); return $out; }
function sp_forumview_query($forumid = 0, $cPage = 1) { global $spGlobals, $spThisUser; # do we have a valid forum id if ($forumid == 0) { $this->forumViewStatus = 'no data'; return; } else { $this->forumViewStatus = 'no access'; $BASEWHERE = SFFORUMS . ".forum_id={$forumid}"; } # some setup vars $startlimit = 0; # how many topics per page? $tpaged = $spGlobals['display']['topics']['perpage']; if (!$tpaged) { $tpaged = 20; } # setup where we are in the topic list (paging) if ($cPage != 1) { $startlimit = ($cPage - 1) * $tpaged; } $LIMIT = $startlimit . ', ' . $tpaged; # Set up where clause if (sp_get_auth('moderate_posts', $forumid)) { $COLUMN = SFTOPICS . '.post_id'; $WHERE = $BASEWHERE; } else { $COLUMN = SFTOPICS . '.post_id_held'; $WHERE = $BASEWHERE . ' AND ' . SFTOPICS . '.post_count_held > 0'; } # Set up order by $reverse = false; $setSort = $spGlobals['display']['topics']['sortnewtop']; if (isset($spGlobals['sort_order']['forum'])) { $reverse = array_search($forumid, (array) $spGlobals['sort_order']['forum']) !== false ? true : false; } if (isset($spThisUser->topicASC) && $spThisUser->topicASC) { $reverse = !$reverse; } if ($setSort xor $reverse) { $ORDER = 'topic_pinned DESC, ' . $COLUMN . ' DESC'; } else { $ORDER = 'topic_pinned DESC, ' . $COLUMN . ' ASC'; } # retrieve forum and topic records $spdb = new spdbComplex(); $spdb->table = SFTOPICS; $spdb->fields = SFTOPICS . '.forum_id, forum_slug, forum_name, forum_status, group_id, topic_count, forum_icon, topic_icon, topic_icon_new, topic_icon_locked, topic_icon_pinned, forum_desc, forum_rss, forum_rss_private, parent, children, forum_message, forum_disabled, keywords, ' . SFTOPICS . '.topic_id, topic_slug, topic_name, topic_status, topic_pinned, topic_opened, ' . SFTOPICS . '.post_id, ' . SFTOPICS . '.post_count'; $spdb->join = array(SFFORUMS . ' ON ' . SFTOPICS . '.forum_id = ' . SFFORUMS . '.forum_id'); $spdb->where = $WHERE; $spdb->orderby = $ORDER; $spdb->limits = $LIMIT; $spdb = apply_filters('sph_forumview_query', $spdb, $this); if (!empty($spThisUser->inspect['q_spForumView'])) { $spdb->inspect = 'spForumView'; $spdb->show = true; } $records = $spdb->select(); $f = array(); if ($records) { $this->forumViewStatus = 'no access'; $fidx = $forumid; $tidx = 0; # define topic id array to collect forum stats and tags $t = array(); if (sp_can_view($forumid, 'topic-title')) { $this->forumViewStatus = 'data'; # construct the parent forum object $r = current($records); $f[$fidx] = new stdClass(); $f[$fidx]->forum_id = $r->forum_id; $f[$fidx]->forum_slug = $r->forum_slug; $f[$fidx]->forum_name = sp_filter_title_display($r->forum_name); $f[$fidx]->forum_permalink = sp_build_url($r->forum_slug, '', 0, 0); $f[$fidx]->forum_desc = sp_filter_title_display($r->forum_desc); $f[$fidx]->forum_status = $r->forum_status; $f[$fidx]->forum_disabled = $r->forum_disabled; $f[$fidx]->group_id = $r->group_id; $f[$fidx]->topic_count = $r->topic_count; $f[$fidx]->forum_icon = sanitize_file_name($r->forum_icon); $f[$fidx]->topic_icon = sanitize_file_name($r->topic_icon); $f[$fidx]->topic_icon_new = sanitize_file_name($r->topic_icon_new); $f[$fidx]->topic_icon_locked = sanitize_file_name($r->topic_icon_locked); $f[$fidx]->topic_icon_pinned = sanitize_file_name($r->topic_icon_pinned); $f[$fidx]->parent = $r->parent; $f[$fidx]->children = $r->children; $f[$fidx]->forum_message = sp_filter_text_display($r->forum_message); $f[$fidx]->forum_keywords = sp_filter_title_display($r->keywords); $f[$fidx]->forum_rss = esc_url($r->forum_rss); $f[$fidx]->forum_rss_private = $r->forum_rss_private; $f[$fidx]->display_page = $this->forumPage; $f[$fidx]->tools_flag = 1; $f[$fidx]->unread = 0; # Can the user create new topics or should we lock the forum? $f[$fidx]->start_topics = sp_get_auth('start_topics', $r->forum_id); $f[$fidx] = apply_filters('sph_forumview_forum_record', $f[$fidx], $r); reset($records); # now loop through the topic records $firstTopicPage = 1; $pinned = 0; foreach ($records as $r) { $tidx = $r->topic_id; $t[] = $tidx; $f[$fidx]->topics[$tidx] = new stdClass(); $f[$fidx]->topics[$tidx]->topic_id = $r->topic_id; $f[$fidx]->topics[$tidx]->topic_slug = $r->topic_slug; $f[$fidx]->topics[$tidx]->topic_name = sp_filter_title_display($r->topic_name); $f[$fidx]->topics[$tidx]->topic_permalink = sp_build_url($r->forum_slug, $r->topic_slug, 1, 0); $f[$fidx]->topics[$tidx]->topic_status = $r->topic_status; $f[$fidx]->topics[$tidx]->topic_pinned = $r->topic_pinned; $f[$fidx]->topics[$tidx]->topic_opened = $r->topic_opened; $f[$fidx]->topics[$tidx]->post_id = $r->post_id; $f[$fidx]->topics[$tidx]->post_count = $r->post_count; $f[$fidx]->topics[$tidx]->unread = 0; $f[$fidx]->topics[$tidx]->last_topic_on_page = 0; $f[$fidx]->topics[$tidx]->first_topic_on_page = $firstTopicPage; $f[$fidx]->topics[$tidx]->first_pinned = 0; $f[$fidx]->topics[$tidx]->last_pinned = 0; # Can the user create new topics or should we lock the forum? $f[$fidx]->topics[$tidx]->reply_topics = sp_get_auth('reply_topics', $fidx); # pinned status if ($firstTopicPage == 1 && $r->topic_pinned) { $f[$fidx]->topics[$tidx]->first_pinned = true; $pinned = $tidx; } if ($firstTopicPage == 0 && $pinned > 0 && $r->topic_pinned == false) { $f[$fidx]->topics[$pinned]->last_pinned = true; } elseif ($r->topic_pinned) { $pinned = $tidx; } $firstTopicPage = 0; # See if this topic is in the current users newpost list if ($spThisUser->member && !empty($spThisUser->newposts) && is_array($spThisUser->newposts['topics']) && in_array($tidx, $spThisUser->newposts['topics'])) { $f[$fidx]->topics[$tidx]->unread = 1; } $f[$fidx]->topics[$tidx] = apply_filters('sph_forumview_topic_records', $f[$fidx]->topics[$tidx], $r); } $f[$fidx]->topics[$tidx]->last_topic_on_page = 1; unset($records); # Collect any forum subforms that may exist if ($f[$fidx]->children) { $topSubs = unserialize($f[$fidx]->children); foreach ($topSubs as $topSub) { $topSubA = array(); $topSubA[] = $topSub; $subs = $this->sp_forumview_subforums_query($topSubA, true); } if ($subs) { $f = $this->sp_forumview_build_subforums($forumid, $f, $fidx, $subs); } } # allow plugins to add more data to combined forum/topic data structure $f[$fidx] = apply_filters('sph_forumview_combined_data', $f[$fidx], $t); # Collect first and last post stats for each topic $stats = $this->sp_forumview_stats_query($t, $forumid); if ($stats) { foreach ($stats as $s) { if ($s->post_index == 1) { $f[$fidx]->topics[$s->topic_id]->first_post_id = $s->post_id; $f[$fidx]->topics[$s->topic_id]->first_post_permalink = sp_build_url($f[$fidx]->forum_slug, $f[$fidx]->topics[$s->topic_id]->topic_slug, 0, $s->post_id, $s->post_index); $f[$fidx]->topics[$s->topic_id]->first_post_date = $s->post_date; $f[$fidx]->topics[$s->topic_id]->first_post_status = $s->post_status; $f[$fidx]->topics[$s->topic_id]->first_post_index = $s->post_index; $f[$fidx]->topics[$s->topic_id]->first_user_id = $s->user_id; $f[$fidx]->topics[$s->topic_id]->first_display_name = sp_filter_name_display($s->display_name); $f[$fidx]->topics[$s->topic_id]->first_guest_name = sp_filter_name_display($s->guest_name); # see if we can display the tooltip if (sp_can_view($forumid, 'post-content', $spThisUser->ID, $s->user_id, $s->topic_id, $s->post_id)) { $f[$fidx]->topics[$s->topic_id]->first_post_tip = $s->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($s->post_content, $s->post_status); } else { $f[$fidx]->topics[$s->topic_id]->first_post_tip = ''; } } if ($s->post_index > 1 || $f[$fidx]->topics[$s->topic_id]->post_count == 1) { $f[$fidx]->topics[$s->topic_id]->last_post_id = $s->post_id; $f[$fidx]->topics[$s->topic_id]->last_post_permalink = sp_build_url($f[$fidx]->forum_slug, $f[$fidx]->topics[$s->topic_id]->topic_slug, 0, $s->post_id, $s->post_index); $f[$fidx]->topics[$s->topic_id]->last_post_date = $s->post_date; $f[$fidx]->topics[$s->topic_id]->last_post_status = $s->post_status; $f[$fidx]->topics[$s->topic_id]->last_post_index = $s->post_index; $f[$fidx]->topics[$s->topic_id]->last_user_id = $s->user_id; $f[$fidx]->topics[$s->topic_id]->last_display_name = sp_filter_name_display($s->display_name); $f[$fidx]->topics[$s->topic_id]->last_guest_name = sp_filter_name_display($s->guest_name); # see if we can display the tooltip if (sp_can_view($forumid, 'post-content', $spThisUser->ID, $s->user_id, $s->topic_id, $s->post_id)) { $f[$fidx]->topics[$s->topic_id]->last_post_tip = $s->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($s->post_content, $s->post_status); } else { $f[$fidx]->topics[$s->topic_id]->last_post_tip = ''; } } $f[$fidx]->topics[$s->topic_id] = apply_filters('sph_forumview_stats_records', $f[$fidx]->topics[$s->topic_id], $s); } unset($stats); } } else { # check for view forum lists but not topic lists if (sp_can_view($forumid, 'forum-title')) { $this->forumViewStatus = 'sneak peek'; } } } else { $records = spdb_table(SFFORUMS, $BASEWHERE); $r = current($records); if ($r) { if (sp_can_view($forumid, 'topic-title')) { $this->forumViewStatus = 'data'; $f[$forumid] = new stdClass(); $f[$forumid]->forum_id = $r->forum_id; $f[$forumid]->forum_slug = $r->forum_slug; $f[$forumid]->forum_name = sp_filter_title_display($r->forum_name); $f[$forumid]->forum_permalink = sp_build_url($r->forum_slug, '', 0, 0); $f[$forumid]->forum_desc = sp_filter_title_display($r->forum_desc); $f[$forumid]->forum_status = $r->forum_status; $f[$forumid]->forum_disabled = $r->forum_disabled; $f[$forumid]->group_id = $r->group_id; $f[$forumid]->topic_count = $r->topic_count; $f[$forumid]->forum_icon = sanitize_file_name($r->forum_icon); $f[$forumid]->forum_icon_new = sanitize_file_name($r->forum_icon_new); $f[$forumid]->topic_icon = sanitize_file_name($r->topic_icon); $f[$forumid]->topic_icon_new = sanitize_file_name($r->topic_icon_new); $f[$forumid]->topic_icon_locked = sanitize_file_name($r->topic_icon_locked); $f[$forumid]->topic_icon_pinned = sanitize_file_name($r->topic_icon_pinned); $f[$forumid]->parent = $r->parent; $f[$forumid]->children = $r->children; $f[$forumid]->forum_message = sp_filter_text_display($r->forum_message); $f[$forumid]->forum_keywords = sp_filter_title_display($r->keywords); $f[$forumid]->forum_rss = esc_url($r->forum_rss); $f[$forumid]->forum_rss_private = $r->forum_rss_private; # Can the user create new topics or should we lock the forum? $f[$forumid]->start_topics = sp_get_auth('start_topics', $r->forum_id); $f[$forumid] = apply_filters('sph_forumview_forum_record', $f[$forumid], $r); } else { # check for view forum lists but not topic lists if (sp_can_view($forumid, 'forum-title')) { $this->forumViewStatus = 'sneak peek'; } } # Collect any forum subforms that may exist if (isset($f[$forumid]->children) && $f[$forumid]->children) { $topSubs = unserialize($f[$forumid]->children); foreach ($topSubs as $topSub) { $topSubA = array(); $topSubA[] = $topSub; $subs = $this->sp_forumview_subforums_query($topSubA, true); } if ($subs) { $f = $this->sp_forumview_build_subforums($forumid, $f, $forumid, $subs); } } # allow plugins to add more data to combined forum/topic data structure $f[$forumid] = apply_filters('sph_forumview_combined_data', $f[$forumid], array()); } else { # reset status to 'no data' $this->forumViewStatus = 'no data'; } } return $f; }
Simple:Press Profile Overview Form $LastChangedDate: 2014-06-14 17:34:16 -0700 (Sat, 14 Jun 2014) $ $Rev: 11559 $ */ if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('Access denied - you cannot directly call this file'); } # double check we have a user if (empty($userid)) { return; } # get the users profile data $spProfileOptions = sp_get_option('sfprofile'); $out = ''; $out .= '<p>' . sp_filter_text_display($spProfileOptions['sfprofiletext']) . '</p>'; $out .= '<hr />'; # start the form $out .= '<div class="spProfileOverview">'; $out = apply_filters('sph_ProfileFormTop', $out, $userid, $thisSlug); $out = apply_filters('sph_ProfileOverviewFormTop', $out, $userid); $tout = ''; $tout .= '<div class="spColumnSection spProfileLeftCol">'; $tout .= '<p class="spProfileLabel">' . sp_text('User') . ': </p>'; $tout .= '</div>'; $tout .= '<div class="spColumnSection spProfileSpacerCol"></div>'; $tout .= '<div class="spColumnSection spProfileRightCol">'; $tout .= '<p class="spProfileLabel">' . $spProfileUser->display_name . '</p>'; $tout .= '</div>'; $out .= apply_filters('sph_ProfileUserDisplayName', $tout, $userid, $thisSlug); $tout = '';
function spa_dashboard_news() { global $spNews; ?> <style type="text/css"> #spa_dashboard_news h4 { font-size: 17px; font-weight: bold; margin-bottom: 8px; padding-bottom: 6px; line-height: 1.2em; border-bottom: 1px solid #ddd;} #spa_dashboard_news .spa_dashboard_text p { line-height: 1.3em; margin: 6px 0 0 0; font-size: 14px; }; </style> <?php echo '<div id="spa_dashboard_news" style="background:#FFFFEA;border:2px solid #666;border-radius:9px;margin:10px;padding:15px;">'; echo '<div style="vertical-align:middle;border-bottom:1px solid #666;margin-bottom:16px;padding:7px 0;">'; echo '<img src="' . SFCOMMONIMAGES . 'sp-full-logo.png" alt="" style="vertical-align:middle;float:left;margin:0 15px 10px 0;padding-right:12px;border-right:1px solid #666;" />'; echo '<p style="vertical-align:middle;margin:13px 0 0 0;font-weight:bold;font-size:20px;line-height:1em;">' . spa_text('Recent News') . '</p>'; echo '<div style="clear:both;"></div>'; echo '</div>'; echo '<div class="spa_dashboard_text">'; echo sp_filter_text_display($spNews); echo '</div>'; echo '<div style="clear:both;"></div>'; echo '<div style="border-top:1px solid #666;margin-top:18px;padding:10px 0;">'; $site = SFHOMEURL . 'index.php?sp_ahah=remove-news&action=news&sfnonce=' . wp_create_nonce('forum-ahah'); echo '<input type="button" value="' . spa_text('Remove News Item') . '" class="button-primary" onclick="spjRemoveNews(\'' . $site . '\')"/>'; echo '</div>'; echo '</div>'; }
function sp_MobileMenuSearch($args = '', $label = '') { $defs = array('searchTagId' => 'spSearchForm', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_MobileMenuSearch_args', $a); extract($a, EXTR_SKIP); # sanitize before use $searchTagId = esc_attr($searchTagId); $echo = (int) $echo; if (!empty($label)) { $label = sp_filter_text_display($label); } $out = ''; $out .= "<li><a href='#{$searchTagId}'>"; if (!empty($label)) { $out .= $label; } $out .= "</a>\n"; $out = apply_filters('sph_MobileMenuSearch', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_AdminModeratorOnlineTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spAdminModeratorOnlineTag', 'tagClass' => 'spListTag', 'moderator' => 1, 'custom' => 1, 'customClass' => 'spAdminMessageTag', 'listTags' => 1, 'listClass' => 'spListItemTag', 'onToolTip' => __('Online', 'sp-ttags'), 'onIcon' => 'sp_UserOnlineSmall.png', 'offIcon' => 'sp_UserOfflineSmall.png', 'offToolTip' => __('Offline', 'sp-ttags'), 'useAvatar' => 0, 'avatarSize' => 25, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_AdminModeratorOnlineTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $moderator = (int) $moderator; $custom = (int) $custom; $customClass = esc_attr($customClass); $listTags = (int) $listTags; $listClass = esc_attr($listClass); $onToolTip = sp_filter_title_display($onToolTip); $offToolTip = sp_filter_title_display($offToolTip); $onIcon = sp_filter_filename_save($onIcon); $offIcon = sp_filter_filename_save($offIcon); $useAvatar = (int) $useAvatar; $avatarSize = (int) $avatarSize; $echo = (int) $echo; sp_forum_api_support(); $where = 'admin=1'; if ($moderator) { $where .= ' OR moderator = 1'; } $spdb = new spdbComplex(); $spdb->table = SFMEMBERS; $spdb->fields = 'user_id AS ID, user_email, ' . SFMEMBERS . '.display_name, admin, user_options, admin_options, ' . SFTRACK . '.id AS online'; $spdb->left_join = array(SFTRACK . ' ON ' . SFMEMBERS . '.user_id = ' . SFTRACK . '.trackuserid', SFUSERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFUSERS . '.ID'); $spdb->where = $where; $spdb->orderby = 'online DESC'; $admins = $spdb->select(); $out = ''; if ($admins) { $out .= $listTags ? "<ul id='{$tagId}' class='{$tagClass}'>" : "<div id='{$tagId}' class='{$tagClass}'>"; foreach ($admins as $admin) { $noAvatar = ''; $msg = ''; $userOpts = unserialize($admin->user_options); if (!$userOpts['hidestatus']) { $userName = sp_build_name_display($admin->ID, sp_filter_name_display($admin->display_name)); $icon = $admin->online ? $onIcon : $offIcon; $tip = $admin->online ? $onToolTip : $offToolTip; if (!$useAvatar) { $noAvatar .= "<img src='" . sp_find_icon(SPTHEMEICONSURL, "{$icon}") . "' alt='' title='{$tip}' />"; } if (!$admin->online && $custom) { $userOpts = unserialize($admin->admin_options); if (isset($userOpts['offline_message'])) { $msg = sp_filter_text_display($userOpts['offline_message']); if ($msg != '') { $msg = "<div class='{$customClass}'>{$msg}</div>"; } } } # begin loop display if ($listTags ? $out .= "<li class='{$listClass}'>" : ($out .= "<div class='{$listClass}'>")) { } # Avatar or Icon if ($useAvatar) { $admin->avatar = ''; $out .= sp_UserAvatar("tagClass=spAvatar&imgClass=spAvatar&size={$avatarSize}&context=user&echo=0", $admin); } else { $out .= $noAvatar; } # User name and current online status $out .= "<span class='spOnlineAdmin'><span class='spOnlineUser'>{$userName}</span> is <span class='admin{$tip}'>{$tip}</span>"; # display offline message is set $out .= $msg; $out .= '</span>'; # end loop display if ($listTags ? $out .= '<div style="clear:both;"></div></li>' : ($out .= '</div><div style="clear:both;"></div>')) { } } } $out .= $listTags ? '</ul>' : '</div>'; } $out = apply_filters('sph_AdminModeratorOnlineTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_MobileMenuSearch($args = '', $label = '') { $defs = array('searchTagId' => 'spSearchForm', 'icon' => 'sp_Search.png', 'iconClass' => 'spIcon', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_MobileMenuSearch_args', $a); extract($a, EXTR_SKIP); # sanitize before use $searchTagId = esc_attr($searchTagId); $icon = sanitize_file_name($icon); $iconClass = esc_attr($iconClass); $echo = (int) $echo; if (!empty($label)) { $label = sp_filter_text_display($label); } $br = '<br />'; $out = ''; $out .= sp_open_grid_cell(); $out .= "<a href='#{$searchTagId}'>"; if (!empty($icon)) { $out .= sp_paint_icon($iconClass, SPTHEMEICONSURL, $icon) . $br; } if (!empty($label)) { $out .= $label; } $out .= "</a>\n"; $out .= sp_close_grid_cell(); $out = apply_filters('sph_MobileMenuSearch', $out, $a); if ($echo) { echo $out; } else { return $out; } }