function sp_do_sp_ProfileLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } global $spThisUser; sp_forum_api_support(); if ($spThisUser->ID == 0 && $spThisUser->ID == '') { return; } $defs = array('linkText' => __('Your Profile', 'sp-ttags'), 'beforeLink' => '', 'afterLink' => '', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ProfileLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $linkText = sp_filter_title_display($linkText); $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $echo = (int) $echo; if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } $out = ''; $out .= "<span>{$beforeLink}<a href='" . sp_url('profile') . "'>{$linkText}</a>{$afterLink}</span>\n"; if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_ForumHomeLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('beforeLink' => '', 'afterLink' => '', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ForumHomeLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $echo = (int) $echo; if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } $pid = sp_get_option('sfpage'); $title = spdb_table(SFWPPOSTS, "ID={$pid}", 'post_title'); $out .= '<span>' . $beforeLink . '<a href="' . get_permalink($pid) . '">' . $title . '</a>' . $afterLink . '</span>'; $out = apply_filters('sph_ForumHomeLinkTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_GroupLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('groupId' => '', 'linkText' => '%GROUPNAME%', 'beforeLink' => '', 'afterLink' => '', 'listTags' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_GroupLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $groupId = (int) $groupId; $linkText = esc_attr($linkText); $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $listTags = (int) $listTags; $echo = (int) $echo; if (empty($groupId)) { return ''; } sp_forum_api_support(); if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } # check user has access to at kleast ine forum in group $canview = false; $forums = spdb_table(SFFORUMS, "group_id={$groupId}"); if ($forums) { foreach ($forums as $forum) { if (sp_can_view($forum->forum_id, 'forum-title')) { $canview = true; } } } if ($forums && $canview) { $grouprec = spdb_table(SFGROUPS, "group_id={$groupId}", 'row'); $out = ''; $linkText = str_replace("%GROUPNAME%", sp_filter_title_display($grouprec->group_name), $linkText); if (empty($linkText)) { $linkText = sp_filter_title_display($grouprec->group_name); } if ($listTags) { $out .= '<li>'; } $out .= '<span>' . $beforeLink . '<a href="' . add_query_arg(array('group' => $groupId), sp_url()) . '">' . $linkText . '</a>' . $afterLink . '</span>'; if ($listTags) { $out .= '</li>'; } } $out = apply_filters('sph_GroupLinkTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_TopicLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('topicId' => '', 'linkText' => '%TOPICNAME%', 'beforeLink' => '', 'afterLink' => '', 'listTags' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_TopicLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $topicId = (int) $topicId; $linkText = esc_attr($linkText); $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $listTags = (int) $listTags; $echo = (int) $echo; if (empty($topicId)) { return ''; } sp_forum_api_support(); if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } $spdb = new spdbComplex(); $spdb->table = SFTOPICS; $spdb->fields = SFTOPICS . '.topic_id, ' . SFTOPICS . '.forum_id, topic_slug, topic_name, forum_name, forum_slug'; $spdb->join = array(SFFORUMS . ' ON ' . SFTOPICS . '.forum_id = ' . SFFORUMS . '.forum_id'); $spdb->where = SFTOPICS . '.topic_id=' . $topicId; $thistopic = $spdb->select(); $out = ''; if ($thistopic) { if (sp_can_view($thistopic[0]->forum_id, 'topic-title')) { $out = ''; $linkText = str_replace("%TOPICNAME%", sp_filter_title_display($thistopic[0]->topic_name), $linkText); if (empty($linkText)) { $linkText = sp_filter_title_display($thistopic[0]->topic_name); } if ($listTags) { $out .= '<li>'; } $out .= '<span>' . $beforeLink . '<a href="' . sp_build_url($thistopic[0]->forum_slug, $thistopic[0]->topic_slug, 0, 0) . '">' . $linkText . '</a>' . $afterLink . '</span>'; if ($listTags) { $out .= '</li>'; } } } else { $out = sprintf(__('Topic %s not found', 'sp-ttags'), $topicId); } $out = apply_filters('sph_TopicLinkTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_UserGroupsTag($userid, $args = '', $noMembershipLabel = '', $adminLabel = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } global $spPaths; $defs = array('tagClass' => 'spUserGroupsTag', 'stacked' => 1, 'showTitle' => 1, 'showBadge' => 1, 'echo' => 1); $a = wp_parse_args($args, $defs); extract($a, EXTR_SKIP); $tagClass = esc_attr($tagClass); $stacked = (int) $stacked; $showTitle = (int) $showTitle; $showBadge = (int) $showBadge; $echo = (int) $echo; $thisUser = sp_get_user($userid); $show = false; $tout = "<span class='{$tagClass}'>"; if (!empty($thisUser->memberships)) { $first = true; $split = $stacked ? '<br />' : ', '; foreach ($thisUser->memberships as $membership) { if (!$first) { $tout .= $split; } if ($showTitle) { $show = true; $tout .= $membership['usergroup_name']; } if ($showBadge && !empty($membership['usergroup_badge'])) { $show = true; if ($showTitle) { $tout .= '<br />'; } $tout .= "<img src='" . SF_STORE_URL . '/' . $spPaths['ranks'] . '/' . $membership['usergroup_badge'] . "' alt='' />"; } $first = false; } } else { if ($thisUser->admin) { if ($showTitle) { $show = true; $tout .= sp_filter_title_display($adminLabel); } } else { $show = true; $tout .= sp_filter_title_display($noMembershipLabel); } } $tout .= "</span>\n"; $out = $show ? $tout : ''; if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_ForumLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('forumId' => '', 'linkText' => '%FORUMNAME%', 'beforeLink' => '', 'afterLink' => '', 'listTags' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ForumLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $forumId = (int) $forumId; $linkText = esc_attr($linkText); $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $listTags = (int) $listTags; $echo = (int) $echo; if (empty($forumId)) { return ''; } sp_forum_api_support(); if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } if (sp_can_view($forumId, 'forum-title')) { $forumrec = spdb_table(SFFORUMS, "forum_id={$forumId}", 'row'); if ($forumrec) { $out = ''; $linkText = str_replace("%FORUMNAME%", sp_filter_title_display($forumrec->forum_name), $linkText); if (empty($linkText)) { $linkText = sp_filter_title_display($forumrec->forum_name); } if ($listTags) { $out .= '<li>'; } $out .= '<span>' . $beforeLink . '<a href="' . sp_build_url($forumrec->forum_slug, '', 0, 0) . '">' . $linkText . '</a>' . $afterLink . '</span>'; if ($listTags) { $out .= '</li>'; } } else { $out = sprintf(__('Forum %s not found', 'sp-ttags'), $forumId); } } $out = apply_filters('sph_ForumLinkTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_AddNewTopicLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spAddNewTopicLinkTag', 'tagClass' => 'spLinkTag', 'forumId' => '', 'linkText' => '%FORUMNAME%', 'beforeLink' => __('Add new topic in the ', 'sp-ttags'), 'afterLink' => __(' forum', 'sp-ttags'), 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_AddNewTopicLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $forumId = (int) $forumId; $linkText = esc_attr($linkText); $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $echo = (int) $echo; if (!$forumId) { return; } if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } sp_forum_api_support(); if (sp_get_auth('start_topics', $forumId)) { $forum = spdb_table(SFFORUMS, "forum_id={$forumId}", 'row'); $linkText = str_replace("%FORUMNAME%", sp_filter_title_display($forum->forum_name), $linkText); $url = sp_build_url($forum->forum_slug, '', 0, 0); $url = sp_get_sfqurl($url) . 'new=topic'; $out = "<span id='{$tagId}' class='{$tagClass}'>"; $out .= $beforeLink . '<a href="' . $url . '">' . $linkText . '</a>' . $afterLink; $out .= '</span>'; $out = apply_filters('sph_AddNewTopicLinkTag', $out); if ($echo) { echo $out; } else { return $out; } } }
function sp_do_sp_ShowSpecialRanksTag($userid, $args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } if (empty($userid)) { return; } $defs = array('tagClass' => 'spSpecialRankTag', 'titleClass' => 'spSpecialRankTag', 'badgeClass' => 'spSpecialRankTag', 'showTitle' => 1, 'showBadge' => 1, 'echo' => 1); $a = wp_parse_args($args, $defs); extract($a, EXTR_SKIP); $echo = (int) $echo; $thisUser = sp_get_user($userid); include_once SF_PLUGIN_DIR . '/forum/content/sp-common-view-functions.php'; $data = sp_UserSpecialRank($a, $thisUser->special_rank); if ($echo) { echo $data; } else { return $data; } }
function sp_do_sp_UnansweredPostsTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spUnansweredPostsTag', 'tagClass' => 'spListTag', 'listId' => 'spListItemTag%ID%', 'listClass' => 'spListItemTag', 'linkClass' => 'spLinkTag', 'textClass' => 'spTextTag', 'avatarClass' => 'spAvatarTag', 'listTags' => 1, 'forumIds' => '', 'limit' => 5, 'itemOrder' => 'FTUD', 'linkScope' => 'forum', 'beforeForum' => __('Forum: ', 'sp-ttags'), 'afterForum' => '<br />', 'beforeTopic' => __('Topic: ', 'sp-ttags'), 'afterTopic' => '<br />', 'beforeUser' => __('By: ', 'sp-ttags'), 'afterUser' => '', 'beforeDate' => ' -', 'afterDate' => '', 'avatarSize' => 25, 'niceDate' => 1, 'postTip' => 1, 'truncate' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_UnansweredPostsTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $listClass = esc_attr($listClass); $listId = esc_attr($listId); $linkClass = esc_attr($linkClass); $textClass = esc_attr($textClass); $avatarClass = esc_attr($avatarClass); $listTags = (int) $listTags; $forumIds = esc_attr($forumIds); $limit = (int) $limit; $itemOrder = esc_attr($itemOrder); $linkScope = esc_attr($linkScope); $beforeForum = sp_filter_title_display($beforeForum); $afterForum = sp_filter_title_display($afterForum); $beforeTopic = sp_filter_title_display($beforeTopic); $afterTopic = sp_filter_title_display($afterTopic); $beforeUser = sp_filter_title_display($beforeUser); $afterUser = sp_filter_title_display($afterUser); $beforeDate = sp_filter_title_display($beforeDate); $afterDate = sp_filter_title_display($afterDate); $avatarSize = (int) $avatarSize; $niceDate = (int) $niceDate; $postTip = (int) $postTip; $truncate = (int) $truncate; $echo = (int) $echo; sp_forum_api_support(); global $spPostList, $spThisPostList; $where = SFTOPICS . '.post_count=1'; # do we have forum ids specified? $where .= !empty($forumIds) ? ' AND ' . SFPOSTS . '.forum_id IN (' . $forumIds . ')' : ''; $spPostList = new spPostList($where, SFPOSTS . '.post_id DESC', $limit); if (empty($spPostList)) { return; } if (!empty($beforeForum)) { $beforeForum = trim($beforeForum) . ' '; } if (!empty($beforeTopic)) { $beforeTopic = trim($beforeTopic) . ' '; } if (!empty($beforeUser)) { $beforeUser = trim($beforeUser) . ' '; } if (!empty($beforeDate)) { $beforeDate = trim($beforeDate) . ' '; } if (!empty($afterForum)) { $afterForum = ' ' . trim($afterForum); } if (!empty($afterTopic)) { $afterTopic = ' ' . trim($afterTopic); } if (!empty($afterUser)) { $afterUser = '******' . trim($afterUser); } if (!empty($afterDate)) { $afterDate = ' ' . trim($afterDate); } $fLink = $tLink = $aLink = false; if ($linkScope == 'forum') { $fLink = $tLink = true; } if ($linkScope == 'all') { $aLink = true; } # Start building dislay $out = $listTags ? "<ul id='{$tagId}' class='{$tagClass}'>" : "<div id='{$tagId}' class='{$tagClass}'>"; # start the loop if (sp_has_postlist()) { while (sp_loop_postlist()) { sp_the_postlist(); $thisId = str_ireplace('%ID%', $spThisPostList->topic_id, $listId); $out .= $listTags ? "<li id='{$thisId}' class='{$listClass}'>" : "<div id='{$thisId}' class='{$listClass}'>"; $title = $postTip ? "title='{$spThisPostList->post_tip}'" : ''; if ($aLink) { $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>"; } for ($x = 0; $x < strlen($itemOrder); $x++) { switch (substr($itemOrder, $x, 1)) { case 'F': # Forum $out .= $beforeForum; if ($fLink) { $out .= "<a class='{$linkClass}' href='{$spThisPostList->forum_permalink}'>"; } $out .= sp_truncate($spThisPostList->forum_name, $truncate); if ($fLink) { $out .= '</a>'; } $out .= $afterForum; break; case 'T': # Topic $out .= $beforeTopic; if ($tLink) { $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>"; } $out .= sp_truncate($spThisPostList->topic_name, $truncate); if ($tLink) { $out .= '</a>'; } $out .= $afterTopic; break; case 'A': # Avatar $spx = $avatarSize + 10 . 'px'; $out .= sp_UserAvatar("tagClass={$avatarClass}&size={$avatarSize}&link=none&context=user&echo=0", $spThisPostList); break; case 'U': # user $out .= "<span class='{$textClass}'>{$spThisPostList->display_name}{$afterUser}</span>"; break; case 'D': # date if ($niceDate) { $out .= "<span class='{$textClass}'>" . $beforeDate . sp_nicedate($spThisPostList->post_date) . "{$afterDate}</span>\n"; } else { $out .= "<span class='{$textClass}'>" . $beforeDate . sp_date('d', $spThisPostList->post_date) . "{$afterDate}</span>\n"; } break; default: # Invalid code $out .= '<br />' . __('Invalid Tag Code Found', 'sp-ttags') . '<br />'; break; } } if ($aLink) { $out .= '</a>'; } $out .= $listTags ? '</li>' : '</div>'; } } $out .= $listTags ? '</ul>' : '</div>'; $out = apply_filters('sph_UnansweredPostsTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_render_forum($content) { global $spIsForum, $spContentLoaded, $spVars, $spGlobals, $spThisUser, $spStatus; # make sure we are at least in the html body before outputting any content if (!sp_get_option('sfwpheadbypass') && !did_action('wp_head')) { return ''; } if ($spIsForum && !post_password_required(get_post(sp_get_option('sfpage')))) { # Limit forum display to within the wp loop? if (sp_get_option('sfinloop') && !in_the_loop()) { return $content; } # Has forum content already been loaded and are we limiting? if (!sp_get_option('sfmultiplecontent') && $spContentLoaded) { return $content; } $spContentLoaded = true; sp_set_server_timezone(); # offer a way for forum display to be short circuited but always show for admins unless an upgrade $message = sp_abort_display_forum(); $content .= $message; if (!empty($message) && (!$spThisUser->admin || $spStatus != 'ok')) { return $content; } # process query arg actions # check for edit operation. Need tp check for '_x' in case using mobile as buttin is an image if (isset($_POST['editpost']) || isset($_POST['editpost_x'])) { sp_save_edited_post(); } if (isset($_POST['edittopic'])) { sp_save_edited_topic(); } if (isset($_POST['ordertopicpins'])) { sp_promote_pinned_topic(); } if (isset($_POST['makepostreassign'])) { sp_reassign_post(); } if (isset($_POST['approvepost'])) { sp_approve_post(false, sp_esc_int($_POST['approvepost']), $spVars['topicid']); } if (isset($_POST['unapprovepost'])) { sp_unapprove_post(sp_esc_int($_POST['unapprovepost'])); } if (isset($_POST['doqueue'])) { sp_remove_waiting_queue(); } if (isset($_POST['notifyuser'])) { sp_post_notification(sp_esc_str($_POST['sp_notify_user']), sp_esc_str($_POST['message']), sp_esc_int($_POST['postid'])); } # move a topic and redirect to that topic if (isset($_POST['maketopicmove'])) { if (empty($_POST['forumid'])) { sp_notify(1, sp_text('Destination forum not selected')); return; } sp_move_topic(); $forumslug = spdb_table(SFFORUMS, 'forum_id=' . sp_esc_int(sp_esc_int($_POST['forumid'])), 'forum_slug'); $topicslug = spdb_table(SFTOPICS, 'topic_id=' . sp_esc_int(sp_esc_int($_POST['currenttopicid'])), 'topic_slug'); $returnURL = sp_build_url($forumslug, $topicslug, 0); sp_redirect($returnURL); } # move a post and redirect to the post if (isset($_POST['makepostmove1']) || isset($_POST['makepostmove2']) || isset($_POST['makepostmove3'])) { sp_move_post(); if (isset($_POST['makepostmove1'])) { $returnURL = sp_permalink_from_postid(sp_esc_int($_POST['postid'])); sp_redirect($returnURL); } } # cancel a post move if (isset($_POST['cancelpostmove'])) { $meta = sp_get_sfmeta('post_move', 'post_move'); if ($meta) { $id = $meta[0]['meta_id']; sp_delete_sfmeta($id); unset($spGlobals['post_move']); } } # rebuild the forum and post indexes if (isset($_POST['rebuildforum']) || isset($_POST['rebuildtopic'])) { sp_build_post_index(sp_esc_int($_POST['topicid']), true); sp_build_forum_index(sp_esc_int($_POST['forumid']), false); } # Set display mode if topic view (for editing posts) if ($spVars['pageview'] == 'topic' && isset($_POST['postedit'])) { $spVars['displaymode'] = 'edit'; $spVars['postedit'] = $_POST['postedit']; } else { $spVars['displaymode'] = 'posts'; } # clean cache of timed our records sp_clean_cache(); #--Scratch Pad Area---Please Leave Here--------- #--End Scratch Pad Area------------------------- # let other plugins check for posted actions do_action('sph_setup_forum'); # do we use output buffering? $ob = sp_get_option('sfuseob'); if ($ob) { ob_start(); } # set up some stuff before wp page content $content .= sp_display_banner(); $content = apply_filters('sph_before_wp_page_content', $content); # run any other wp filters on page content but exclude ours if (!$ob) { remove_filter('the_content', 'sp_render_forum', 1); $content = apply_filters('the_content', $content); $content = wpautop($content); add_filter('the_content', 'sp_render_forum', 1); } # set up some stuff after wp page content $content = apply_filters('sph_after_wp_page_content', $content); $content .= '<div id="dialogcontainer" style="display:none;"></div>'; $content .= sp_js_check(); # echo any wp page content echo $content; # now add our content do_action('sph_before_template_processing'); sp_process_template(); do_action('sph_after_template_processing'); # Return if using output buffering if ($ob) { $forum = ob_get_contents(); ob_end_clean(); return $forum; } } # not returning any content since we output it already unless password needed if (post_password_required(get_post(sp_get_option('sfpage')))) { return $content; } }
function sp_do_sp_ForumDropdownTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spForumDropdownTag', 'tagClass' => 'spLinkTag', 'selectClass' => 'spSelectTag', 'forumList' => 0, 'label' => __("Select forum", 'sp-ttags'), 'length' => 30, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ForumDropdownTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $selectClass = esc_attr($selectClass); $forumList = esc_attr($forumList); $label = sp_filter_title_display($label); $length = (int) $length; $echo = (int) $echo; global $spThisUser; sp_forum_api_support(); $forum_ids = array(); if ($forumList == 0) { $forum_ids = sp_get_forum_memberships($spThisUser->ID); } else { $allforums = explode(',', $forumList); foreach ($allforums as $thisforum) { if (sp_can_view($thisforum, 'forum-title')) { $forum_ids[] = $thisforum; } } } if (empty($forum_ids)) { return; } # create where clause based on forums that current user can view $where = "forum_id IN (" . implode(",", $forum_ids) . ")"; $spdb = new spdbComplex(); $spdb->table = SFFORUMS; $spdb->fields = 'forum_slug, forum_name'; $spdb->join = array(SFGROUPS . ' ON ' . SFFORUMS . '.group_id = ' . SFGROUPS . '.group_id'); $spdb->where = $where; $spdb->orderby = 'group_seq, forum_seq'; $forums = $spdb->select(); $out = "<div id='{$tagId}' class='{$tagClass}'>"; $out .= '<select name="forumselect" class="' . $selectClass . '" onChange="javascript:spjChangeForumURL(this)">' . "\n"; $out .= '<option>' . $label . '</option>' . "\n"; foreach ($forums as $forum) { $out .= '<option value="' . sp_build_url($forum->forum_slug, '', 0, 0) . '"> ' . sp_create_name_extract(sp_filter_title_display($forum->forum_name), $length) . '</option>' . "\n"; } $out .= '</select>' . "\n"; $out .= '</div>'; $out .= '<script type="text/javascript">'; $out .= 'function spjChangeForumURL(menuObj) {'; $out .= 'var i = menuObj.selectedIndex;'; $out .= 'if(i > 0) {'; $out .= 'if(menuObj.options[i].value != "#") {'; $out .= 'window.location = menuObj.options[i].value;'; $out .= '}}}'; $out .= '</script>'; $out = apply_filters('sph_ForumDropdownTag', $out); 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_do_sp_AuthorPostsTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spAuthorPostsTag', 'tagClass' => 'spLinkTag', 'authorId' => '', 'showForum' => 1, 'showDate' => 1, 'limit' => 5, 'listTags' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_AuthorPostsTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $authorId = (int) $authorId; $showForum = (int) $showForum; $showDate = (int) $showDate; $limit = (int) $limit; $listTags = (int) $listTags; $echo = (int) $echo; if (empty($authorId)) { return; } sp_forum_api_support(); if ($limit == 0) { $limit = ''; } # limit to viewable forums based on permissions $where = SFPOSTS . '.user_id = ' . $authorId . ' AND ' . SFPOSTS . '.post_status=0 '; $forum_ids = sp_get_forum_memberships(); # create where clause based on forums that current user can view if ($forum_ids != '') { $where .= "AND " . SFPOSTS . ".forum_id IN (" . implode(",", $forum_ids) . ")"; } else { return ''; } $spdb = new spdbComplex(); $spdb->table = SFPOSTS; $spdb->distinct = true; $spdb->fields = SFPOSTS . '.post_id, ' . SFPOSTS . '.forum_id, ' . SFPOSTS . '.topic_id, ' . spdb_zone_datetime('post_date') . ', post_index, forum_slug, forum_name, topic_slug, topic_name'; $spdb->join = array(SFTOPICS . ' ON ' . SFPOSTS . '.topic_id = ' . SFTOPICS . '.topic_id', SFFORUMS . ' ON ' . SFPOSTS . '.forum_id = ' . SFFORUMS . '.forum_id'); $spdb->where = $where; $spdb->orderby = 'post_date DESC'; $spdb->limits = $limit; $sfposts = $spdb->select(); if (!$listTags) { $out = "<div id='{$tagId}' class='{$tagClass}'>"; $open = '<div>'; $close = '</div>'; } else { $out = "<ul id='{$tagId}' class='{$tagClass}'>"; $open = '<li>'; $close = '</li>'; } if ($sfposts) { foreach ($sfposts as $sfpost) { $out .= $open; if ($showForum) { $out .= sp_filter_title_display($sfpost->forum_name) . '<br />'; } $out .= '<a href="' . sp_build_url($sfpost->forum_slug, $sfpost->topic_slug, 0, $sfpost->post_id, $sfpost->post_index) . '">' . sp_filter_title_display($sfpost->topic_name) . '</a><br />' . "\n"; if ($showDate) { $out .= sp_date('d', $sfpost->post_date) . '<br />'; } $out .= $close; } } else { $out .= $open . __('No posts by this author', 'sp-ttags') . $close; } if (!$listTags) { $out .= '</div>'; } else { $out .= '</ul>'; } $out = apply_filters('sph_AuthorPostsTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_SideDashTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } global $spThisUser, $spGlobals; $defs = array('tagId' => 'spSideDashTag', 'tagClass' => 'spSideDashTag', 'showAvatar' => 1, 'avatarSize' => 25, 'avatarClass' => 'spAvatar', 'showAdminLink' => 1, 'showLogin' => 1, 'loginLink' => esc_url(wp_login_url()), 'showLogout' => 1, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_SideDashTag_args', $a); extract($a, EXTR_SKIP); $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $showAvatar = (int) $showAvatar; $avatarSize = (int) $avatarSize; $avatarClass = esc_attr($avatarClass); $showAdminLink = (int) $showAdminLink; $showLogin = (int) $showLogin; $loginLink = sp_filter_title_display($loginLink); $showLogout = (int) $showLogout; $echo = (int) $echo; sp_forum_api_support(); $out = ''; $sflogin = sp_get_option('sflogin'); if ($spThisUser->guest) { if (!empty($showLogin)) { # show any login links? if ($showLogin == 1) { # showing login form # display login form $out .= '<form action="' . esc_url(wp_login_url()) . '" method="post">'; $out .= '<p class="spSideDashUser"><label for="spTagLog">' . __('Username: '******'sp-ttags') . '<input type="text" name="log" id="spTagLog" value="" size="15" /></label></p>'; $out .= '<p class="spSideDashPw"><label for="spTagPwd">' . __('Password: '******'sp-ttags') . '<input type="password" name="pwd" id="spTagPwd" value="" size="15" /></label></p>'; $out .= '<p class="spSideDashRemember"><input type="checkbox" id="rememberme" name="rememberme" value="forever" /><label for="rememberme">' . __('Remember me', 'sp-ttags') . '</label></p>'; $out .= '<input type="hidden" name="redirect_to" value="' . esc_attr($sflogin['sfloginurl']) . '" />'; $out .= '<p><input type="submit" name="submit" id="submit" value="' . esc_attr(__('Log in', 'sp-ttags')) . '" /></p>'; $out .= '</form>'; } else { if ($showLogin == 2) { # showing wp login link $out .= '<a href="' . esc_url(wp_login_url($sflogin['sfloginurl'], 'login')) . '">' . __('Log In', 'sp-ttags') . '</a></p>'; } else { if ($showLogin == 3) { # showing custom login link $out .= '<a href="' . esc_attr($loginLink) . '">' . __('Log In', 'sp-ttags') . '</a></p>'; } } } # if registrations allowed, display register link $started = false; if (get_option('users_can_register') && !$spGlobals['lockdown']) { $started = true; $out .= '<p class="spSideDashLinks"><a href="' . esc_url(site_url('wp-login.php?action=register&redirect_to=' . $sflogin['sfregisterurl'], 'login')) . '">' . __('Register', 'sp-ttags') . '</a>'; } if ($started) { $out .= ' | '; } else { $out .= '<p class="spSideDashGuest">'; } # display lost password link $out .= '<a href="' . esc_url(wp_lostpassword_url()) . '">' . __('Lost password', 'sp-ttags') . '</a></p>'; } $out = apply_filters('sph_SideDashTagUser', $out); } else { if ($showAvatar) { $out .= sp_UserAvatar("tagClass={$avatarClass}&size={$avatarSize}&echo=0"); } $out .= '<p class="spSideDashLoggedIn">' . __('Logged in as', 'sp-ttags') . ' <strong>' . sp_filter_name_display($spThisUser->display_name) . '</strong></p>'; if ($showAdminLink) { $out .= '<p class="spSideDashAdminLink"><a href="' . SFHOMEURL . 'wp-admin' . '">' . __('Dashboard', 'sp-ttags') . '</a></p>'; } if ($showLogout) { $out .= '<p class="spSideDashLogout"><a href="' . esc_url(wp_logout_url($sflogin['sflogouturl'])) . '">' . __('Log out', 'sp-ttags') . '</a></p>'; } $out = apply_filters('sph_SideDashTagGuest', $out); } $out = apply_filters('sph_SideDashTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_HotTopicsTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } global $spThisUser; $defs = array('tagId' => 'spHotTopicsTag', 'tagClass' => 'spHotTopicsTag', 'listClass' => 'spListItemTag', 'textClass' => 'spHotTopicTextTag', 'listTags' => 1, 'forumIds' => 0, 'limit' => 5, 'days' => 30, 'showForum' => 1, 'textForum' => __('posted in', 'sp-ttags'), 'showCount' => 1, 'textCount' => __('recent posts', 'sp-ttags'), 'showHotness' => 1, 'textHotness' => __('hotness', 'sp-ttags'), 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_HotTopicsTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $listClass = esc_attr($listClass); $textClass = esc_attr($textClass); $listTags = (int) $listTags; $forumIds = sp_filter_title_display($forumIds); $limit = (int) $limit; $days = (int) $days; $showForum = (int) $showForum; $textForum = sp_filter_title_display($textForum); $showCount = (int) $showCount; $textCount = sp_filter_title_display($textCount); $showHotness = (int) $showHotness; $textHotness = sp_filter_title_display($textHotness); $echo = (int) $echo; sp_forum_api_support(); $forumList = ''; if (!empty($forumIds)) { # are we passing forum ID's? $flist = explode(',', $forumIds); foreach ($flist as $id) { if (sp_can_view($id, 'topic-title')) { $forumList[] = $id; } } } else { global $spThisUser; $allForums = sp_get_forum_memberships($spThisUser->ID); if ($allForums) { foreach ($allForums as $id) { if (sp_can_view($id, 'topic-title')) { $forumList[] = $id; } } } } if (!empty($forumList)) { $where = ' AND ' . SFPOSTS . '.forum_id IN (' . implode(',', $forumList) . ')'; } else { return ''; } # get any posts that meeet date criteria $spdb = new spdbComplex(); $spdb->table = SFPOSTS; $spdb->fields = SFPOSTS . '.topic_id, DATEDIFF(CURDATE(), post_date) AS delta, ' . SFPOSTS . '.forum_id, forum_name, forum_slug, forum_slug, topic_name, topic_slug'; $spdb->join = array(SFTOPICS . ' ON ' . SFTOPICS . '.topic_id = ' . SFPOSTS . '.topic_id', SFFORUMS . ' ON ' . SFFORUMS . '.forum_id = ' . SFPOSTS . '.forum_id'); $spdb->where = 'DATE_SUB(CURDATE(),INTERVAL ' . $days . ' DAY) <= post_date' . $where; $spdb = apply_filters('sph_HotTopicsTagQuery', $spdb); $posts = $spdb->select(); $out = ''; $out = $listTags ? "<ul id='{$tagId}' class='{$tagClass}'>" : "<div id='{$tagId}' class='{$tagClass}'>"; if ($posts) { # give each topic with posts a score - currently ln(cur date - post date) for each post $score = $count = $forum_name = $forum_slug = $topic_slug = $topic_name = array(); foreach ($posts as $post) { if ($post->delta != $days) { $value = apply_filters('sph_HotTopicTagScore', log($days - $post->delta), $post, $a); # let plugins modify the hotness algorithm $score[$post->topic_id] = isset($score[$post->topic_id]) ? $score[$post->topic_id] + $value : $value; $count[$post->topic_id] = isset($count[$post->topic_id]) ? $count[$post->topic_id] + 1 : 1; $forum_name[$post->topic_id] = sp_filter_title_display($post->forum_name); $forum_slug[$post->topic_id] = $post->forum_slug; $topic_slug[$post->topic_id] = $post->topic_slug; $topic_name[$post->topic_id] = sp_filter_title_display($post->topic_name); } } # reverse sort the posts and limit to number to display arsort($score); $topics = array_slice($score, 0, $limit, true); # now output the popular topics foreach ($topics as $id => $topic) { $out .= $listTags ? "<li class='{$listClass}'>" : "<div class='{$textClass}'>"; $out .= sp_get_topic_url($forum_slug[$id], $topic_slug[$id], $topic_name[$id]); if ($showForum) { $out .= " {$textForum} {$forum_name[$id]}"; } if ($showCount) { $out .= ' (' . $count[$id] . " {$textCount})"; } if ($showHotness) { $out .= ' (' . round($score[$id], 2) . " {$textHotness})"; } $out .= $listTags ? '</li>' : '</div>'; } } else { $out .= "<div class='{$textClass}'>" . __('No current hot topics to display', 'sp-ttags') . '</div>'; } $out .= $listTags ? '</ul>' : '</div>'; $out = apply_filters('sph_HotTopicsTag', $out); if ($echo) { echo $out; } else { return $out; } }