function sp_load_current_user()
{
    global $current_user, $spThisUser, $spGuestCookie;
    if (empty($current_user)) {
        $current_user = wp_get_current_user();
    }
    $spThisUser = sp_get_user($current_user->ID, true);
    # check for a cookie if a guest
    $spGuestCookie = new stdClass();
    $spGuestCookie->guest_name = '';
    $spGuestCookie->guest_email = '';
    $spGuestCookie->display_name = '';
    if ($spThisUser->guest && empty($spThisUser->offmember)) {
        # so no record of them being a current member
        $sfguests = sp_get_option('sfguests');
        if ($sfguests['storecookie']) {
            if (isset($_COOKIE['guestname_' . COOKIEHASH])) {
                $spGuestCookie->guest_name = sp_filter_name_display($_COOKIE['guestname_' . COOKIEHASH]);
            }
            if (isset($_COOKIE['guestemail_' . COOKIEHASH])) {
                $spGuestCookie->guest_email = sp_filter_email_display($_COOKIE['guestemail_' . COOKIEHASH]);
            }
            $spGuestCookie->display_name = $spGuestCookie->guest_name;
        }
    }
}
function spa_display_member_roll($members, $text1, $text2)
{
    $out = '';
    $cap = '';
    $first = true;
    $out .= '<fieldset class="sfsubfieldset">';
    $out .= '<legend>' . $text1 . '</legend>';
    if ($members) {
        $out .= '<p><b>' . count($members) . ' ' . spa_text('member(s) in this user group') . '</b></p>';
        for ($x = 0; $x < count($members); $x++) {
            if (strncasecmp($members[$x]->display_name, $cap, 1) != 0) {
                if (!$first) {
                    $out .= '</ul>';
                }
                $cap = substr($members[$x]->display_name, 0, 2);
                if (function_exists('mb_strwidth')) {
                    if (mb_strwidth($cap) == 2) {
                        $cap = substr($cap, 0, 1);
                    }
                } else {
                    $cap = substr($cap, 0, 1);
                }
                $out .= '<p style="clear:both;"></p><hr /><h4>' . strtoupper($cap) . '</h4>';
                $out .= '<ul class="memberlist">';
                $first = false;
            }
            $out .= '<li>' . sp_filter_name_display($members[$x]->display_name) . '</li>';
        }
        $out .= '</ul>';
    } else {
        $out .= $text2;
    }
    $out .= '</fieldset>';
    return $out;
}
function spa_toolbox_log_form()
{
    $sflog = spa_get_log_data();
    #== log Tab ==========================================================
    spa_paint_open_tab(spa_text('Toolbox') . " - " . spa_text('Install Log'), true);
    if (!$sflog) {
        spa_etext("There are no Install Log Entries");
        return;
    }
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Install Log'), false);
    echo "<table class='wp-list-table widefat'><tr>";
    echo '<th>' . spa_text('Version') . '</th>';
    echo "<th class='logDetail'>" . "</th>";
    echo '<th>' . spa_text('Build') . '</th>';
    echo "<th class='logRelease'>" . spa_text('Release') . "</th>";
    echo '<th>' . spa_text('Installed') . '</th>';
    echo "<th class='logBy'>" . spa_text('By') . "</th>";
    echo '</tr>';
    foreach ($sflog as $log) {
        $idVer = 'version' . str_replace('.', '', $log['version']);
        $idQVer = str_replace('.', '-', $log['version']);
        echo '<tr>';
        echo "<td class='sflabel'>" . $log['version'] . "</td>";
        $site = SFHOMEURL . 'index.php?sp_ahah=install-log&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;log=' . $idQVer;
        $gif = SFCOMMONIMAGES . 'working.gif';
        echo '<td class="logDetail"><input type="button" class="logDetail button" value="' . spa_text('Details') . '" onclick="spjLoadAhah(\'' . $site . '\', \'' . $idVer . '\', \'' . $gif . '\');" /></td>';
        echo "<td class='sflabel'>" . $log['build'] . "</td>";
        echo "<td class='sflabel logRelease'>" . $log['release_type'] . "</td>";
        echo "<td class='sflabel'>" . sp_date('d', $log['install_date']) . "</td>";
        echo "<td class='sflabel logBy'>" . sp_filter_name_display($log['display_name']) . "</td>";
        echo '</tr>';
        echo "<tr><td style='display:none;' class='sflabel' id='" . $idVer . "' colspan='6'></td></tr>";
    }
    echo '</table>';
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_toolbox_install_panel');
    spa_paint_close_container();
    echo '<div class="sfform-panel-spacer"></div>';
    spa_paint_close_tab();
}
    spdb_query($sql);
}
if ($action == 'show') {
    $key = sp_esc_int($_GET['key']);
    $specialRank = sp_get_sfmeta('special_rank', false, $key);
    $users = spdb_select('col', 'SELECT display_name
						  FROM ' . SFSPECIALRANKS . '
						  JOIN ' . SFMEMBERS . ' ON ' . SFSPECIALRANKS . '.user_id = ' . SFMEMBERS . '.user_id
						  WHERE special_rank = "' . $specialRank[0]['meta_key'] . '"
						  ORDER BY display_name');
    echo '<fieldset class="sfsubfieldset">';
    echo '<legend>' . spa_text('Special Rank Members') . '</legend>';
    if ($users) {
        echo '<ul class="memberlist">';
        for ($x = 0; $x < count($users); $x++) {
            echo '<li>' . sp_filter_name_display($users[$x]) . '</li>';
        }
        echo '</ul>';
    } else {
        spa_etext('No users with this special rank');
    }
    echo '</fieldset>';
}
if ($action == 'delsmiley') {
    $file = sp_esc_str($_GET['file']);
    $path = SF_STORE_DIR . '/' . $spPaths['smileys'] . '/' . $file;
    @unlink($path);
    # load smiles from sfmeta
    $meta = sp_get_sfmeta('smileys', 'smileys');
    # now cycle through to remove this entry and resave
    if (!empty($meta[0]['meta_value'])) {
    function sp_listview_populate_newposts($topicIds)
    {
        global $spThisUser;
        $newList = array();
        # First filter topics by those in the users new post list
        $newTopicIds = array();
        foreach ($topicIds as $topic) {
            if (sp_is_in_users_newposts($topic)) {
                $newTopicIds[] = $topic;
            }
        }
        if ($newTopicIds) {
            # construct the query - need to add in sfwaiting for admins
            $where = SFPOSTS . '.topic_id IN (' . implode(',', $newTopicIds) . ') AND (post_date > "' . spdb_zone_mysql_checkdate($spThisUser->lastvisit) . '")';
            if ($spThisUser->admin || $spThisUser->moderator) {
                $wPosts = spdb_select('col', 'SELECT post_id FROM ' . SFWAITING);
                if ($wPosts) {
                    $where .= ' OR (' . SFPOSTS . '.post_id IN (' . implode(",", $wPosts) . '))';
                }
            }
            $spdb = new spdbComplex();
            $spdb->table = SFPOSTS;
            $spdb->fields = SFPOSTS . '.topic_id, ' . SFPOSTS . '.post_id, post_index, ' . spdb_zone_datetime('post_date') . ',
									guest_name, ' . SFPOSTS . '.user_id, display_name, post_count-post_index+1 AS new_post_count';
            $spdb->left_join = array(SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFPOSTS . '.user_id');
            $spdb->join = array(SFTOPICS . ' ON ' . SFPOSTS . '.topic_id = ' . SFTOPICS . '.topic_id');
            $spdb->where = $where;
            $spdb->orderby = 'topic_id, post_id';
            $spdb = apply_filters('sph_listview_newposts_query', $spdb, $this);
            $postrecords = $spdb->select();
            if ($postrecords) {
                $cTopic = 0;
                foreach ($postrecords as $p) {
                    if ($p->topic_id != $cTopic) {
                        $cTopic = $p->topic_id;
                        $newList[$cTopic] = new stdClass();
                        $newList[$cTopic]->topic_id = $cTopic;
                        $newList[$cTopic]->new_post_count = $p->new_post_count;
                        $newList[$cTopic]->new_post_post_id = $p->post_id;
                        $newList[$cTopic]->new_post_post_index = $p->post_index;
                        $newList[$cTopic]->new_post_post_date = $p->post_date;
                        $newList[$cTopic]->new_post_user_id = $p->user_id;
                        $newList[$cTopic]->new_post_display_name = sp_filter_name_display($p->display_name);
                        $newList[$cTopic]->new_post_guest_name = sp_filter_name_display($p->guest_name);
                    }
                }
            }
        }
        return $newList;
    }
Exemplo n.º 6
0
function sp_search_user()
{
    global $wpdb;
    $out = '[]';
    $query = $_GET['term'];
    $where = "display_name LIKE '%" . esc_sql($wpdb->esc_like($query)) . "%'";
    $users = spdb_table(SFMEMBERS, $where, '', 'display_name DESC', 25);
    if ($users) {
        $primary = '';
        $secondary = '';
        foreach ($users as $user) {
            $uname = sp_filter_name_display($user->display_name);
            $cUser = array('id' => $user->user_id, 'value' => $uname);
            if (strcasecmp($query, substr($uname, 0, strlen($query))) == 0) {
                $primary .= json_encode($cUser) . ',';
            } else {
                $secondary .= json_encode($cUser) . ',';
            }
        }
        if ($primary != '' || $secondary != '') {
            if ($primary != '') {
                $primary = trim($primary, ',') . ',';
            }
            if ($secondary != '') {
                $secondary = trim($secondary, ',');
            }
            $out = '[' . trim($primary . $secondary, ',') . ']';
        }
    }
    echo $out;
    die;
}
function spa_users_members_form()
{
    spa_paint_options_init();
    spa_paint_open_tab(spa_text('Users') . ' - ' . spa_text('Member Information'), true);
    spa_paint_open_panel();
    spa_paint_open_fieldset(spa_text('Member Information'), 'true', 'users-info');
    if (isset($_POST['usersearch'])) {
        $term = sp_filter_title_save(trim($_POST['usersearch']));
    } else {
        $term = '';
    }
    if (isset($_GET['userspage'])) {
        $page = sp_esc_int($_GET['userspage']);
    } else {
        $page = '';
    }
    $user_search = new SP_User_Search($term, $page);
    ?>
				<form id="posts-filter" name="searchfilter" action="<?php 
    echo SFADMINUSER . '&amp;form=member-info';
    ?>
" method="post">
					<div class="tablenav">
						<?php 
    if ($user_search->results_are_paged()) {
        ?>
							<div class="tablenav-pages">
<?php 
        $args = array();
        if (!empty($user_search->search_term)) {
            $args['usersearch'] = urlencode($user_search->search_term);
        }
        $user_search->paging_text = paginate_links(array('total' => ceil($user_search->total_users_for_query / $user_search->users_per_page), 'current' => $user_search->page, 'base' => 'admin.php?page=simple-press/admin/panel-users/spa-users.php&form=member-info&%_%', 'format' => 'userspage=%#%', 'add_args' => $args));
        echo $user_search->page_links();
        ?>
							</div>
						<?php 
    }
    ?>
						<div>
							<label class="hidden" for="post-search-input"><?php 
    spa_etext('Search Members');
    ?>
:</label>
							<input type="text" class="sfacontrol" id="post-search-input" name="usersearch" value="<?php 
    echo esc_attr($user_search->search_term);
    ?>
" />
							<input type="button" class="button-primary" onclick="javascript:document.searchfilter.submit();" id="sfusersearch" name="sfusersearch" value="<?php 
    spa_etext('Search Members');
    ?>
" />
						</div>
						<br class="clear" />
					</div>
					<br class="clear" />
				</form>
				<?php 
    if ($user_search->get_results()) {
        ?>
					<?php 
        if ($user_search->is_search()) {
            ?>
						<p><a href="<?php 
            echo SFADMINUSER;
            ?>
"><?php 
            echo sprintf(spa_text('%s Back to All Members'), '&laquo;');
            ?>
</a></p>
					<?php 
        }
        ?>

					<table id="memTable" class="widefat fixed spMobileTable1280">
						<thead>
							<tr>
								<th style="text-align:center;width:4%"><?php 
        spa_etext('ID');
        ?>
</th>
								<th style="text-align:center;"><?php 
        spa_etext('Login Name');
        ?>
</th>
								<th style="text-align:center;"><?php 
        spa_etext('Display Name');
        ?>
</th>
								<th style="text-align:center;width:15%"><?php 
        spa_etext('First Post');
        ?>
</th>
								<th style="text-align:center;width:15%"><?php 
        spa_etext('Last Post');
        ?>
</th>
								<th style="text-align:center;width:3.5%"><?php 
        spa_etext('Posts');
        ?>
</th>
								<th style="text-align:center;"><?php 
        spa_etext('Last Visit');
        ?>
</th>
								<th style="text-align:center;"><?php 
        spa_etext('Memberships');
        ?>
</th>
								<th style="text-align:center;width:auto;"><?php 
        spa_etext('Rank');
        ?>
</th>
								<th style="text-align:center;"><?php 
        spa_etext('Actions');
        ?>
</th>
							</tr>
						</thead>
						<tbody id="users" class="list:user user-list">
<?php 
        $style = '';
        $class = 'class="spMobileTableData"';
        # grab user post/page counts
        $users = $user_search->get_results();
        # output users
        foreach ($users as $userid) {
            $data = spa_get_members_info($userid);
            if ($data) {
                ?>
									<tr id="user-delete-<?php 
                echo $userid;
                ?>
" <?php 
                echo $class;
                ?>
>
										<td data-label='<?php 
                spa_etext('ID');
                ?>
'><?php 
                echo $userid;
                ?>
</td>
										<td data-label='<?php 
                spa_etext('Login Name');
                ?>
'><?php 
                echo $data['login'];
                ?>
</td>
										<?php 
                $displayname = !empty($data['display_name']) ? $data['display_name'] : '';
                ?>
										<td data-label='<?php 
                spa_etext('Display Name');
                ?>
'><strong><?php 
                echo sp_filter_name_display($displayname);
                ?>
</strong></td>
										<td data-label='<?php 
                spa_etext('First Post');
                ?>
'><?php 
                echo $data['first'];
                ?>
</td>
										<td data-label='<?php 
                spa_etext('Last Post');
                ?>
'><?php 
                echo $data['last'];
                ?>
</td>
										<td data-label='<?php 
                spa_etext('Posts');
                ?>
'>
<?php 
                if ($data['posts'] == -1) {
                    echo '<img style="vertical-align:top" src="' . SFADMINIMAGES . 'sp_UserNoPosts.png" title="' . spa_text('User has not yet visited forum') . '" alt="" />';
                } else {
                    echo $data['posts'];
                }
                ?>
										</td>
										<td data-label='<?php 
                spa_etext('Last Visit');
                ?>
'><?php 
                echo sp_date('d', $data['lastvisit']);
                ?>
</td>
										<td data-label='<?php 
                spa_etext('Memberships');
                ?>
'><?php 
                echo $data['memberships'];
                ?>
</td>
										<td data-label='<?php 
                spa_etext('Rank');
                ?>
'><?php 
                echo $data['rank'];
                ?>
</td>
										<td style="text-align:center">
<?php 
                $site = SFHOMEURL . 'index.php?sp_ahah=profile&amp;sfnonce=' . wp_create_nonce('forum-ahah') . "&amp;action=popup&amp;user={$userid}";
                $title = spa_text('Member Profile');
                $position = 'center';
                echo '<a id="memberprofile' . $userid . '" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . $title . '\', 750, 0, \'' . $position . '\');"><img src="' . SFADMINIMAGES . 'sp_UserProfile.png" title="' . spa_text('View Member Profile') . '" alt="" /></a>';
                # check to see if user can delete users before giving option to delete
                if (current_user_can('delete_user', $userid)) {
                    $nonce = wp_create_nonce('bulk-users');
                    $url = admin_url('users.php?action=delete&amp;user='******'&_wpnonce=' . $nonce . '&amp;wp_http_referer=admin.php?page=simple-press/admin/panel-users/spa-users.php');
                    echo '<a href="' . $url . '"><img src="' . SFCOMMONIMAGES . 'delete.png" title="' . spa_text('Delete User') . '" alt="" />';
                }
                ?>
										</td>
									</tr>
<?php 
            }
            $class = strpos($class, 'alternate') === false ? 'class="spMobileTableData alternate"' : 'class="spMobileTableData"';
        }
        ?>
						</tbody>
					</table>

					<div class="tablenav">
						<?php 
        if ($user_search->results_are_paged()) {
            ?>
							<div class="tablenav-pages"><?php 
            $user_search->page_links();
            ?>
</div>
						<?php 
        }
        ?>
						<br class="clear" />
					</div>
<?php 
    }
    spa_paint_close_fieldset();
    spa_paint_close_panel();
    do_action('sph_users_members_panel');
    spa_paint_close_container();
    spa_paint_close_tab();
}
    function sp_postlistview_query($where, $order, $count, $view, $type)
    {
        global $spGlobals, $spThisUser;
        # If no WHERE clause then return empty
        if (empty($where)) {
            return;
        }
        # build list of forums user can view
        $fids = sp_user_visible_forums($view);
        if (!empty($fids)) {
            $fids = implode(',', $fids);
            $where .= ' AND ' . SFPOSTS . ".forum_id IN ({$fids})";
        }
        # Check order
        if (empty($order)) {
            $order = SFPOSTS . '.post_id DESC';
        }
        $spdb = new spdbComplex();
        $spdb->table = SFPOSTS;
        $spdb->fields = SFPOSTS . '.post_id, post_content, ' . spdb_zone_datetime('post_date') . ', ' . SFPOSTS . '.topic_id, ' . SFPOSTS . '.forum_id,
								  ' . SFPOSTS . '.user_id, guest_name, post_status, post_index, forum_name, forum_slug, forum_disabled, ' . SFFORUMS . '.group_id, group_name,
								  topic_name, topic_slug, ' . SFTOPICS . '.post_count, topic_opened, display_name';
        $spdb->join = array(SFFORUMS . ' ON ' . SFFORUMS . '.forum_id = ' . SFPOSTS . '.forum_id', SFGROUPS . ' ON ' . SFGROUPS . '.group_id = ' . SFFORUMS . '.group_id', SFTOPICS . ' ON ' . SFTOPICS . '.topic_id = ' . SFPOSTS . '.topic_id');
        $spdb->left_join = array(SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFPOSTS . '.user_id');
        $spdb->where = $where;
        $spdb->orderby = $order;
        if ($count) {
            $spdb->limits = $count;
        }
        $spdb = apply_filters('sph_post_list_query', $spdb, $this, $type);
        if (!empty($spThisUser->inspect['q_spPostListView'])) {
            $spdb->inspect = 'spPostListView';
            $spdb->show = true;
        }
        $records = $spdb->select();
        # Now check authorisations and clean up the object
        $list = array();
        # Some values we need
        # How many topics to a page?
        $ppaged = $spGlobals['display']['posts']['perpage'];
        if (empty($ppaged) || $ppaged == 0) {
            $ppaged = 20;
        }
        # establish topic sort order
        $porder = 'ASC';
        # default
        if ($spGlobals['display']['posts']['sortdesc']) {
            $porder = 'DESC';
        }
        # global override
        if ($records) {
            $listPos = 1;
            foreach ($records as $r) {
                if (sp_can_view($r->forum_id, 'forum-title')) {
                    if ($r->post_status == 0 || sp_get_auth('moderate_posts', $r->forum_id)) {
                        $p = $r->post_id;
                        $list[$p] = $r;
                        # Now apply any necessary filters and data changes
                        $list[$p]->post_content = sp_filter_content_display($r->post_content);
                        $list[$p]->post_content_raw = $r->post_content;
                        $list[$p]->forum_name = sp_filter_title_display($r->forum_name);
                        $list[$p]->forum_disabled = $r->forum_disabled;
                        $list[$p]->forum_permalink = sp_build_url($r->forum_slug, '', 1, 0);
                        $list[$p]->topic_permalink = sp_build_url($r->forum_slug, $r->topic_slug, 1, 0);
                        $list[$p]->topic_name = sp_filter_title_display($r->topic_name);
                        $list[$p]->topic_opened = $r->topic_opened;
                        $list[$p]->group_name = sp_filter_title_display($r->group_name);
                        if (sp_can_view($r->forum_id, 'post-content', $spThisUser->ID, $r->user_id, $r->topic_id, $r->post_id)) {
                            $list[$p]->post_tip = $r->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($r->post_content, $r->post_status);
                        } else {
                            $list[$p]->post_tip = '';
                        }
                        # Ensure display name is populated
                        if (empty($r->display_name)) {
                            $list[$p]->display_name = $list[$p]->guest_name;
                        }
                        $list[$p]->display_name = sp_filter_name_display($list[$p]->display_name);
                        # determine the page for the post permalink
                        if ($porder == 'ASC') {
                            $page = $r->post_index / $ppaged;
                            if (!is_int($page)) {
                                $page = intval($page + 1);
                            }
                        } else {
                            $page = $r->post_count - $r->post_index;
                            $page = $page / $ppaged;
                            $page = intval($page + 1);
                        }
                        $list[$p]->post_permalink = sp_build_url($r->forum_slug, $r->topic_slug, $page, $r->post_id, $r->post_index);
                        $list[$p]->list_position = $listPos;
                        $list[$p] = apply_filters('sph_post_list_record', $list[$p], $r, $type);
                    }
                }
                $listPos++;
            }
        }
        return $list;
    }
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&amp;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;
    }
}
Exemplo n.º 10
0
    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;
    }
Exemplo n.º 11
0
function sp_post_login_check($login_name)
{
    $dname = sp_filter_name_display(sp_get_login_display_name($login_name));
    $cookiepath = preg_replace('|https?://[^/]+|i', '', user_trailingslashit(SFSITEURL));
    setcookie('sforum_' . COOKIEHASH, $dname, time() + 30000000, $cookiepath, false);
}
function sp_UserGroupList($args = '', $titleLabel = '', $userGroup = 0)
{
    if (!$userGroup) {
        return;
    }
    $defs = array('tagClass' => 'spUserGroupList', 'pTitleClass' => 'spUserGroupListTitle', 'spanClass' => 'spUserGroupListList', 'link_names' => 1, 'postCount' => 1, 'echo' => 1, 'get' => 0);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_UserGroupList_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagClass = esc_attr($tagClass);
    $pTitleClass = esc_attr($pTitleClass);
    $spanClass = esc_attr($spanClass);
    $link_names = (int) $link_names;
    $postCount = (int) $postCount;
    $echo = (int) $echo;
    $userGroup = (int) $userGroup;
    $get = (int) $get;
    if (!empty($titleLabel)) {
        $titleLabel = sp_filter_title_display($titleLabel);
    }
    # get user group member list
    $sql = "SELECT " . SFMEMBERSHIPS . ".user_id, display_name, posts\n\t\t\tFROM " . SFMEMBERSHIPS . "\n\t\t\tJOIN " . SFMEMBERS . " ON " . SFMEMBERS . ".user_id = " . SFMEMBERSHIPS . ".user_id\n\t\t\tWHERE " . SFMEMBERSHIPS . ".usergroup_id=" . $userGroup . "\n\t\t\tORDER BY display_name";
    $members = spdb_select('set', $sql);
    if ($get) {
        return $members;
    }
    # render the members list
    $out = "<div class='{$tagClass}'>";
    $out .= "<p class='{$pTitleClass}'><span class='{$pTitleClass}'>{$titleLabel}</span>";
    if ($members) {
        $first = true;
        $out .= "<span class='{$spanClass}'>";
        foreach ($members as $member) {
            $comma = !$first ? ', ' : '';
            if ($member->posts < 0) {
                $member->posts = 0;
            }
            $userPosts = $postCount ? ': ' . $member->posts : '';
            $out .= sp_build_name_display($member->user_id, $comma . sp_filter_name_display($member->display_name) . $userPosts);
            $first = false;
        }
        $out .= '</span>';
    }
    $out .= '</p>';
    # finish it up
    $out .= "</div>\n";
    $out = apply_filters('sph_UserGroupList', $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;
    }
}
if ($spStatus != 'ok') {
    include_once SPLOADINSTALL;
    die;
}
spa_panel_header();
spa_paint_options_init();
spa_paint_open_tab(spa_text('Special WP Admin Notice') . ' - ' . spa_text('Special WP Admin Notice'));
spa_paint_open_panel();
spa_paint_open_fieldset(spa_text('Special WP Admin Notice'), false);
echo '<tr><td colspan="3"><br /><p>';
spa_etext('Please note that while you are a WP admin, you are not currently an SP admin. By default, WP admins are not SP admins');
echo '<br />';
spa_etext('Contact one of the SP Admins listed below to see if they want to grant you SP admin access on the SP manage admins panel');
echo '</p>';
# list all current SPF Admins
$adminrecords = $spGlobals['forum-admins'];
if ($adminrecords) {
    echo '<p>';
    echo '<ul>';
    foreach ($adminrecords as $admin => $name) {
        echo '<li>' . sp_filter_name_display($name) . '</li>';
    }
    echo '</ul>';
    echo '</p><br />';
}
echo '</td></tr>';
spa_paint_close_fieldset();
spa_paint_close_panel();
spa_paint_close_container();
spa_paint_close_tab();
spa_panel_footer();
Exemplo n.º 15
0
function sp_NewPostListAdmin($newposts)
{
    global $spVars, $spThisUser, $spGlobals, $spDevice;
    $alt = '';
    $nourl = '';
    if ($newposts) {
        $index = array();
        foreach ($newposts as $newpost) {
            $forumid = $newpost['forum_id'];
            $index[$forumid] = count($newpost['topics']);
        }
        # Set up the autoupdate url (for quicklinks refreshing)
        $updateUrl = SFHOMEURL . 'index.php?sp_ahah=autoupdate&amp;sfnonce=' . wp_create_nonce('forum-ahah');
        # Display section heading
        echo '<div class="spAdminQueueHeader">';
        echo '<a id="newpoststop"></a>';
        $options = sp_get_option('spAdminBar');
        if ($spThisUser->admin || $spThisUser->moderator) {
            $p = $spDevice == 'mobile' && current_theme_supports('sp-theme-responsive') ? SPABIMAGESMOB : SPABIMAGES;
            echo '<form class="sfsubhead" action="' . sp_url() . '" method="post" name="removequeue">';
            echo '<input type="hidden" name="doqueue" value="1" />';
            echo '<p class="spLeft">' . __('New/Unread Posts Management', 'spab') . '</p>';
            echo '<a class="spButton spRight" href="javascript:document.removequeue.submit();">' . sp_paint_icon('', $p, "sp_markRead.png") . __('Empty the Admin Postbag', 'spab') . '</a>';
            echo '</form>';
            $removal = true;
            $canremove = '1';
        }
        echo '</div>';
        # Start actual listing display
        echo '<div class="spInlineSection spMessageSuccess" id="spAdminQueueMsg"></div>';
        # Display new posts heading
        sp_SectionStart('tagClass=spAdminQueueSection', 'AdminQueue');
        echo '<p style="text-align:center" class="spAdminBarTitle">' . __('Forums and Topics', 'spab') . '</p>';
        # Start with main forum header
        foreach ($newposts as $newpost) {
            # Display forum name
            echo '<div id="spAdminQueueForum' . $newpost['forum_id'] . '" class="spAdminQueueForum">';
            sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=9%');
            $icon = !empty($newpost['forum_icon']) ? sp_paint_custom_icon('spRopwIcon', SFCUSTOMURL . $newpost['forum_icon']) : sp_paint_icon('spTowIcon', SPTHEMEICONSURL, 'sp_ForumIcon.png');
            echo $icon;
            sp_ColumnEnd();
            sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=90%');
            echo '<p class="spAdminForum">';
            echo '<a class="spRowName" href="' . sp_build_url($newpost['forum_slug'], '', 1, 0) . '">Forum: ' . $newpost['forum_name'] . '</a>';
            echo '</p>';
            echo '<input type="hidden" id="tcount' . $newpost['forum_id'] . '" value="' . $index[$newpost['forum_id']] . '" />';
            sp_ColumnEnd();
            echo '<div class="spClear"></div>';
            echo '</div>';
            # Now for each topic with new posts
            foreach ($newpost['topics'] as $topic) {
                $postcountmod = 0;
                $postcountord = 0;
                # a quick first pass to load the post count variables and check for spam
                $is_spam = false;
                foreach ($topic['posts'] as $post) {
                    if ($post['post_status'] != 0 ? $postcountmod++ : $postcountord++) {
                    }
                    if ($post['post_status'] == 2) {
                        $is_spam = true;
                    }
                    $lastpost_id = $post['post_id'];
                }
                # Display topics in forum
                $class = $postcountmod ? 'spSubmit spModButton' : 'spSubmit spUnreadButton';
                echo '<div id="spAdminQueueTopic' . $topic['topic_id'] . '" class="spAdminQueueTopic">';
                sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=10%');
                echo "<input type='button' name='openicon" . $topic['topic_id'] . "' class='" . $class . "' value='";
                echo esc_attr(__('View', 'spab'));
                if ($is_spam) {
                    echo "\n" . esc_attr(__('Spam', 'spab'));
                }
                echo "' onclick='spjToggleLayer(\"spAdminQueueThisTopic" . $topic['topic_id'] . "\");' />";
                echo '<input type="hidden" id="pcount' . $topic['topic_id'] . '" value="' . $topic['post_count'] . '" />';
                echo '<input type="hidden" id="pcountmod' . $topic['topic_id'] . '" value="' . $postcountmod . '" />';
                echo '<input type="hidden" id="pcountord' . $topic['topic_id'] . '" value="' . $postcountord . '" />';
                sp_ColumnEnd();
                sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=90%');
                echo '<p>' . sp_get_topic_newpost_url($newpost['forum_slug'], $topic['topic_slug'], $topic['topic_name'], $lastpost_id, $post['post_index']) . '</p>';
                $nourl = '';
                if ($topic['post_count'] == 1) {
                    $note = __('There is 1 new post in this topic', 'spab');
                } else {
                    $note = sprintf(__('There are %s new posts in this topic', 'spab'), $topic['post_count']);
                }
                echo '<p class="spLabelSmall">' . $note . '</p>';
                sp_ColumnEnd();
                echo '<div class="spClear"></div>';
                echo '</div>';
                # Start display of post information
                echo '<div id="spAdminQueuePost' . $topic['topic_id'] . '" class="spAdminQueuePost">';
                echo '<div id="spAdminQueueThisTopic' . $topic['topic_id'] . '" class="spPostSection spInlineSection">';
                echo '<p style="text-align:center" class="spAdminBarTitle">' . __('Post Details', 'spab') . '</p>';
                $pindex = 0;
                $mod_required = false;
                # Start the post display loop
                foreach ($topic['posts'] as $post) {
                    $is_spam = false;
                    if ($pindex > 0) {
                        echo '<hr>';
                    }
                    echo '<div id="spAdminQueueThisPost' . $post['post_id'] . '" class="spAdminQueueThisPost">';
                    $pindex++;
                    $lastpost = $pindex == $topic['post_count'] ? true : false;
                    if ($post['post_status'] != 0) {
                        $mod_required = true;
                        echo '<div class="spAdminQueueMod spRight">' . __('Awaiting moderation', 'spab');
                        if ($post['post_status'] == 2) {
                            $is_spam = true;
                            echo '<br />' . __('Akismet marked as spam', 'spab');
                        }
                        echo '</div>';
                    }
                    echo '<b>' . sp_filter_name_display($post['display_name']) . '</b><br /><small>' . $post['user_type'] . '</small>';
                    echo '<br /><small>' . sprintf(__('Post %s in Topic', 'spab'), $post['post_index']) . '</small>';
                    echo '<hr />' . sp_filter_content_display($post['post_content']) . '</td>';
                    echo '</div>';
                    # Set up the ahah base url
                    $basesite = SFHOMEURL . "index.php?sp_ahah=moderation&amp;sfnonce=" . wp_create_nonce('forum-ahah') . "&amp;pid=" . $post['post_id'] . "&amp;tid=" . $topic['topic_id'] . "&amp;fid=" . $newpost['forum_id'];
                    echo '<div id="spAdminQueueThisPostButtons' . $post['post_id'] . '" class="spAdminQueueThisPostButtons">';
                    echo '<table><tr>';
                    if ($topic['post_count'] == 1) {
                        $label = __('This Post', 'spab');
                    } else {
                        $label = __('All Posts', 'spab');
                    }
                    if ($lastpost) {
                        $site = $basesite . '&amp;action=0&amp;canremove=' . $canremove;
                        if ($mod_required) {
                            if (sp_get_auth('moderate_posts', $newpost['forum_id'])) {
                                $posturl = sp_build_url($newpost['forum_slug'], $topic['topic_slug'], 0, $post['post_id'], $post['post_index']);
                            }
                        } else {
                            $posturl = sp_build_url($newpost['forum_slug'], $topic['topic_slug'], 0, $post['post_id'], $post['post_index']);
                        }
                        if ($mod_required) {
                            $m = $spDevice == 'mobile' ? esc_attr(__("Approve & Load", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s Approved and go to Topic", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="g0-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $posturl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'9\', \'' . $updateUrl . '\');" /></td>';
                            $m = $spDevice == 'mobile' ? esc_attr(__("Approve & Close", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s Approved and Close", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="a0-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $nourl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'0\', \'' . $updateUrl . '\');" /></td>';
                            if ($spDevice == 'mobile') {
                                echo '</tr></tr>';
                            }
                            $m = $spDevice == 'mobile' ? esc_attr(__("Approve & Reply", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s Approved and Quick Reply", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="q0-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spjToggleLayer(\'sfqform' . $topic['topic_id'] . '\');" /></td>';
                            $qaction = 0;
                        } else {
                            $site = $basesite . '&amp;action=1&amp;canremove=' . $canremove;
                            $m = $spDevice == 'mobile' ? esc_attr(__("Mark Read & Load", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s as Read and go to Topic", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="g1-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $posturl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'1\', \'' . $updateUrl . '\');" /></td>';
                            $m = $spDevice == 'mobile' ? esc_attr(__("Mark Read & Close", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s as Read and Close", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="a1-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $nourl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'1\', \'' . $updateUrl . '\');" /></td>';
                            if ($spDevice == 'mobile') {
                                echo '</tr></tr>';
                            }
                            $m = $spDevice == 'mobile' ? esc_attr(__("Mark Read & Reply", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s as Read and Quick Reply", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="a1-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spjToggleLayer(\'sfqform' . $topic['topic_id'] . '\');" /></td>';
                            $qaction = 1;
                        }
                    }
                    if ($removal) {
                        $remsite = $basesite . '&amp;action=2&amp;canremove=' . $canremove;
                        $msg = esc_js(__('Are you sure you want to delete this Post?', 'spab'));
                        $m = $spDevice == 'mobile' ? esc_attr(__("Delete Post", 'spab')) : sp_splice(esc_attr(__("Delete this Post", 'spab')), 0);
                        echo '<td><input type="button" class="spSubmit" name="a2-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="javascript: if(confirm(\'' . $msg . '\')) {spabModeratePost(\'' . $nourl . '\', \'' . $remsite . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'2\', \'' . $updateUrl . '\');}" /></td>';
                        if ($post['user_type'] == 'Member' && $is_spam) {
                            $actionUrl = SFHOMEURL . 'index.php?sp_ahah=remove-spam&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;postid=' . $post['post_id'] . '&amp;userid=' . $post['user_id'];
                            $updateUrl = SFHOMEURL . 'index.php?sp_ahah=admin-bar-update&amp;target=newposts&amp;sfnonce=' . wp_create_nonce('forum-ahah');
                            echo '</tr></tr>';
                            $m = $spDevice == 'mobile' ? esc_attr(__("Remove Member & All Their Posts", 'spab')) : sp_splice(esc_attr(__("Remove this Member and All their Posts", 'spab')), 2);
                            echo '<td colspan="2"><input type="button" class="spSubmit" name="delSpam-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabRemoveSpam(\'' . $actionUrl . '\', \'' . $updateUrl . '\');" /></td>';
                        }
                    }
                    echo '</tr></table>';
                    # Quick Reply Form
                    if ($lastpost) {
                        $qsavesite = SFHOMEURL . "index.php?sp_ahah=quickreply&amp;sfnonce=" . wp_create_nonce('forum-ahah') . "&amp;tid=" . $topic['topic_id'] . "&amp;fid=" . $newpost['forum_id'];
                        echo '<div id="sfqform' . $topic['topic_id'] . '" class="spInlineSection">';
                        echo '<form action="' . sp_url() . '" method="post" name="addpost' . $topic['topic_id'] . '" onsubmit="return spabSaveQuickReply(this, \'' . $qsavesite . '\', \'' . $site . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'' . $qaction . '\', \'' . $updateUrl . '\')">';
                        echo '<textarea  tabindex="1" class="spControl" name="postitem' . $topic['topic_id'] . '" id="postitem' . $topic['topic_id'] . '" cols="60" rows="8"></textarea>';
                        echo '<br /><input type="submit" tabindex="2" class="spSubmit" id="sfsave' . $topic['topic_id'] . '" name="newpost' . $topic['topic_id'] . '" value="' . esc_attr(__('Save New Post', 'spab')) . '" />';
                        do_action('sph_quickreply_form', $newpost, $topic, $post);
                        echo '</form><br /></div>';
                    }
                    echo '</div>';
                }
                echo '</div>';
                echo '</div>';
            }
        }
        sp_SectionEnd('', 'AdminQueue');
    } else {
        echo '<div class="spMessage">';
        echo __('There are no unread posts', 'spab') . '</div>';
        echo "<div class='spInlineSection' id='spAdminQueueMsg'></div>\n";
    }
}
Exemplo n.º 16
0
 function sp_forumview_build_subforums($forumid, $f, $fidx, $subs)
 {
     global $spThisUser;
     ksort($subs);
     foreach ($subs as $sub) {
         if (sp_can_view($sub->forum_id, 'topic-title')) {
             $f[$fidx]->subforums[$sub->forum_id] = new stdClass();
             $f[$fidx]->subforums[$sub->forum_id]->top_parent = $fidx;
             $f[$fidx]->subforums[$sub->forum_id]->top_sub_parent = $sub->topSubParent;
             $f[$fidx]->subforums[$sub->forum_id]->forum_id = $sub->forum_id;
             $f[$fidx]->subforums[$sub->forum_id]->forum_id_sub = 0;
             $f[$fidx]->subforums[$sub->forum_id]->forum_name = sp_filter_title_display($sub->forum_name);
             $f[$fidx]->subforums[$sub->forum_id]->forum_permalink = sp_build_url($sub->forum_slug, '', 1, 0);
             $f[$fidx]->subforums[$sub->forum_id]->forum_slug = $sub->forum_slug;
             $f[$fidx]->subforums[$sub->forum_id]->forum_desc = sp_filter_title_display($sub->forum_desc);
             $f[$fidx]->subforums[$sub->forum_id]->forum_status = $sub->forum_status;
             $f[$fidx]->subforums[$sub->forum_id]->forum_disabled = $sub->forum_disabled;
             $f[$fidx]->subforums[$sub->forum_id]->forum_icon = sanitize_file_name($sub->forum_icon);
             $f[$fidx]->subforums[$sub->forum_id]->forum_icon_new = sanitize_file_name($sub->forum_icon_new);
             $f[$fidx]->subforums[$sub->forum_id]->topic_icon = sanitize_file_name($sub->topic_icon);
             $f[$fidx]->subforums[$sub->forum_id]->topic_icon_new = sanitize_file_name($sub->topic_icon_new);
             $f[$fidx]->subforums[$sub->forum_id]->topic_icon_locked = sanitize_file_name($sub->topic_icon_locked);
             $f[$fidx]->subforums[$sub->forum_id]->topic_icon_pinned = sanitize_file_name($sub->topic_icon_pinned);
             $f[$fidx]->subforums[$sub->forum_id]->forum_rss_private = $sub->forum_rss_private;
             $f[$fidx]->subforums[$sub->forum_id]->post_id = $sub->post_id;
             $f[$fidx]->subforums[$sub->forum_id]->post_id_held = $sub->post_id_held;
             $f[$fidx]->subforums[$sub->forum_id]->topic_count = $sub->topic_count;
             $f[$fidx]->subforums[$sub->forum_id]->topic_count_sub = $sub->topic_count;
             $f[$fidx]->subforums[$sub->forum_id]->post_count = $sub->post_count;
             $f[$fidx]->subforums[$sub->forum_id]->post_count_sub = $sub->post_count;
             $f[$fidx]->subforums[$sub->forum_id]->post_count_held = $sub->post_count_held;
             $f[$fidx]->subforums[$sub->forum_id]->parent = $sub->parent;
             $f[$fidx]->subforums[$sub->forum_id]->children = $sub->children;
             $f[$fidx]->subforums[$sub->forum_id]->unread = 0;
             # Can the user create new topics or should we lock the forum?
             $f[$fidx]->subforums[$sub->forum_id]->start_topics = sp_get_auth('start_topics', $sub->forum_id);
             # See if any forums are in the current users newpost list
             if ($spThisUser->member) {
                 $c = 0;
                 if ($spThisUser->newposts && $spThisUser->newposts['forums']) {
                     foreach ($spThisUser->newposts['forums'] as $fnp) {
                         if ($fnp == $sub->forum_id) {
                             $c++;
                         }
                     }
                 }
                 $f[$fidx]->subforums[$sub->forum_id]->unread = $c;
             }
             # check if we can look at posts in moderation - if not swap for 'held' values
             if (!sp_get_auth('moderate_posts', $sub->forum_id)) {
                 $f[$fidx]->subforums[$sub->forum_id]->post_id = $sub->post_id_held;
                 $f[$fidx]->subforums[$sub->forum_id]->post_count = $sub->post_count_held;
                 $f[$fidx]->subforums[$sub->forum_id]->post_count_sub = $sub->post_count_held;
                 $thisPostid = $sub->post_id_held;
             } else {
                 $thisPostid = $sub->post_id;
             }
             # Build post id array for collecting stats at the end
             if (!empty($thisPostid)) {
                 $p[$sub->forum_id] = $thisPostid;
             }
             # if this subforum has a parent that is differemt to the main forum being dislayed in the view
             # then it has to be a nested subforum so do we need to merge the numbers?
             if ($sub->parent != $forumid) {
                 $f[$fidx]->subforums[$sub->parent]->topic_count_sub += $f[$fidx]->subforums[$sub->forum_id]->topic_count;
                 $f[$fidx]->subforums[$sub->parent]->post_count_sub += $f[$fidx]->subforums[$sub->forum_id]->post_count;
                 # and what about the most recent post? Is this in a nested subforum?
                 if ($f[$fidx]->subforums[$sub->forum_id]->post_id > $f[$fidx]->subforums[$sub->parent]->post_id) {
                     # store the alternative forum id in case we need to display the topic data for this one if inc. subs
                     $f[$fidx]->subforums[$sub->parent]->forum_id_sub = $sub->forum_id;
                 }
             }
         }
     }
     # Go grab the sub forum stats and data
     if (!empty($p)) {
         $stats = $this->sp_subforumview_stats_query($p);
         if ($stats) {
             $s = '';
             foreach ($subs as $sub) {
                 if (!empty($stats[$sub->forum_id])) {
                     $s = $stats[$sub->forum_id];
                     $f[$fidx]->subforums[$sub->forum_id]->topic_id = $s->topic_id;
                     $f[$fidx]->subforums[$sub->forum_id]->topic_name = sp_filter_title_display($s->topic_name);
                     $f[$fidx]->subforums[$sub->forum_id]->topic_slug = $s->topic_slug;
                     $f[$fidx]->subforums[$sub->forum_id]->post_id = $s->post_id;
                     $f[$fidx]->subforums[$sub->forum_id]->post_permalink = sp_build_url($f[$fidx]->subforums[$sub->forum_id]->forum_slug, $s->topic_slug, 0, $s->post_id, $s->post_index);
                     $f[$fidx]->subforums[$sub->forum_id]->post_date = $s->post_date;
                     $f[$fidx]->subforums[$sub->forum_id]->post_status = $s->post_status;
                     $f[$fidx]->subforums[$sub->forum_id]->post_index = $s->post_index;
                     # see if we can display the tooltip
                     if (sp_can_view($sub->forum_id, 'post-content', $spThisUser->ID, $s->user_id, $s->topic_id, $s->post_id)) {
                         $f[$fidx]->subforums[$sub->forum_id]->post_tip = $s->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($s->post_content, $s->post_status);
                     } else {
                         $f[$fidx]->subforums[$sub->forum_id]->post_tip = '';
                     }
                     $f[$fidx]->subforums[$sub->forum_id]->user_id = $s->user_id;
                     $f[$fidx]->subforums[$sub->forum_id]->display_name = sp_filter_name_display($s->display_name);
                     $f[$fidx]->subforums[$sub->forum_id]->guest_name = sp_filter_name_display($s->guest_name);
                 }
                 # do we need to record a possible subforum substitute topic?
                 $fsub = isset($f[$fidx]->subforums[$sub->forum_id]->forum_id_sub) ? $f[$fidx]->subforums[$sub->forum_id]->forum_id_sub : 0;
                 if ($fsub != 0 && !empty($stats[$fsub])) {
                     $s = $stats[$fsub];
                     $f[$fidx]->subforums[$sub->forum_id]->topic_id_sub = $s->topic_id;
                     $f[$fidx]->subforums[$sub->forum_id]->topic_name_sub = sp_filter_title_display($s->topic_name);
                     $f[$fidx]->subforums[$sub->forum_id]->topic_slug_sub = $s->topic_slug;
                     $f[$fidx]->subforums[$sub->forum_id]->post_id_sub = $s->post_id;
                     $f[$fidx]->subforums[$sub->forum_id]->post_permalink_sub = sp_build_url($f[$fidx]->subforums[$fsub]->forum_slug, $s->topic_slug, 0, $s->post_id, $s->post_index);
                     $f[$fidx]->subforums[$sub->forum_id]->post_date_sub = $s->post_date;
                     $f[$fidx]->subforums[$sub->forum_id]->post_status_sub = $s->post_status;
                     $f[$fidx]->subforums[$sub->forum_id]->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[$fidx]->subforums[$sub->forum_id]->post_tip_sub = $s->post_status ? sp_text('Post awaiting moderation') : sp_filter_tooltip_display($s->post_content, $s->post_status);
                     } else {
                         $f[$fidx]->subforums[$sub->forum_id]->post_tip_sub = '';
                     }
                     $f[$fidx]->subforums[$sub->forum_id]->user_id_sub = $s->user_id;
                     $f[$fidx]->subforums[$sub->forum_id]->display_name_sub = sp_filter_name_display($s->display_name);
                     $f[$fidx]->subforums[$sub->forum_id]->guest_name_sub = sp_filter_name_display($s->guest_name);
                 }
                 # allow plugins to add more data to combined subforum/post data structure
                 $f[$fidx]->subforums[$sub->forum_id] = apply_filters('sph_forumview_subforum_records', $f[$fidx]->subforums[$sub->forum_id], $s);
             }
         }
         unset($subs);
         unset($stats);
     }
     return $f;
 }
    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_render_msbox_list($msbox, $uid, $name, $from, $num, $records, $offset, $max, $filter)
{
    $out = '';
    $empty = true;
    $out .= '<div align="center"><strong>' . $from . '</strong><br />';
    $out .= '<select class="msAddControl" multiple="multiple" size="10" id="temp-' . $name . $uid . '" name="temp-' . $name . $uid . '[]">';
    $out .= '</div>';
    if ($records) {
        foreach ($records as $record) {
            $empty = false;
            $out .= '<option value="' . $record->user_id . '">' . sp_filter_name_display($record->display_name) . '</option>' . "\n";
        }
    }
    if ($empty) {
        $out .= '<option disabled="disabled" value="-1">' . spa_text('List is empty') . '</option>';
    }
    $out .= '</select>';
    $out .= '<div align="center">';
    $out .= '<small style="line-height:1.6em;">' . spa_text('Paging Controls') . '</small><br />';
    $out .= '<span id="filter-working"></span>';
    $last = floor($max / $num) * $num;
    if ($last >= $max) {
        $last = $last - $num;
    }
    $disabled = '';
    if ($offset == 0) {
        $disabled = ' disabled="disabled"';
    }
    $site = SFHOMEURL . 'index.php?sp_ahah=multiselect&amp;sfnonce=' . wp_create_nonce('forum-ahah') . "&amp;page_msbox=next&amp;msbox={$msbox}&amp;uid={$uid}&amp;name={$name}&amp;from=" . urlencode($from) . "&amp;num={$num}&amp;offset=0&amp;max={$max}&amp;filter={$filter}";
    $out .= '<input type="button"' . $disabled . ' id="firstpage' . $uid . '" class="button-secondary" value="<<" onclick="spjUpdateMultiSelectList(\'' . $site . '\', \'' . $name . $uid . '\');" />';
    $site = SFHOMEURL . 'index.php?sp_ahah=multiselect&amp;sfnonce=' . wp_create_nonce('forum-ahah') . "&amp;page_msbox=next&amp;msbox={$msbox}&amp;uid={$uid}&amp;name={$name}&amp;from=" . urlencode($from) . "&amp;num={$num}&amp;offset=" . ($offset - $num) . "&amp;max={$max}&amp;filter={$filter}";
    $out .= '<input type="button"' . $disabled . ' id="prevpage' . $uid . '" class="button-secondary" value="<" onclick="spjUpdateMultiSelectList(\'' . $site . '\', \'' . $name . $uid . '\');" />';
    $out .= '&nbsp;&nbsp;';
    $disabled = '';
    if ($offset + $num >= $max) {
        $disabled = ' disabled="disabled"';
    }
    $site = SFHOMEURL . 'index.php?sp_ahah=multiselect&amp;sfnonce=' . wp_create_nonce('forum-ahah') . "&amp;page_msbox=next&amp;msbox={$msbox}&amp;uid={$uid}&amp;name={$name}&amp;from=" . urlencode($from) . "&amp;num={$num}&amp;offset=" . ($offset + $num) . "&amp;max={$max}&amp;filter={$filter}";
    $out .= '<input type="button"' . $disabled . ' id="nextpage' . $uid . '" class="button-secondary" value=">" onclick="spjUpdateMultiSelectList(\'' . $site . '\', \'' . $name . $uid . '\');" />';
    $site = SFHOMEURL . 'index.php?sp_ahah=multiselect&amp;sfnonce=' . wp_create_nonce('forum-ahah') . "&amp;page_msbox=next&amp;msbox={$msbox}&amp;uid={$uid}&amp;name={$name}&amp;from=" . urlencode($from) . "&amp;num={$num}&amp;offset={$last}&amp;max={$max}&amp;filter={$filter}";
    $out .= '<input type="button"' . $disabled . ' id="lastpage' . $uid . '" class="button-secondary" value=">>" onclick="spjUpdateMultiSelectList(\'' . $site . '\', \'' . $name . $uid . '\');" />';
    $out .= '<div style="clear:both;padding: 5px 0pt;">';
    $out .= '<input type="button" id="add' . $uid . '" class="button-secondary" value="' . sp_splice(spa_text('Move to Selected List'), 1) . '" onclick="spjTransferSelectList(\'temp-' . $name . $uid . '\', \'' . $name . $uid . '\', \'' . esc_js(spa_text('List is Empty')) . '\', \'' . esc_js(spa_text('Maximum of 400 Users would be exceeded - please reduce the selections')) . '\', \'' . $name . $uid . '\')" />';
    $out .= '<br />';
    $out .= '<input type=text id="list-filter' . $name . $uid . '" name="list-filter' . $name . $uid . '" value="' . $filter . '" class="sfacontrol" size="10" />';
    $gif = SFCOMMONIMAGES . "working.gif";
    $site = SFHOMEURL . 'index.php?sp_ahah=multiselect&amp;sfnonce=' . wp_create_nonce('forum-ahah') . "&amp;page_msbox=filter&amp;msbox={$msbox}&amp;uid={$uid}&amp;name={$name}&amp;from=" . urlencode($from) . "&amp;num={$num}&amp;offset=0&amp;max={$max}";
    $out .= '<input type="button" id="filter' . $uid . '" class="button-secondary" value="' . spa_text('Filter') . '" style="margin-top:1px" onclick="spjFilterMultiSelectList(\'' . $site . '\', \'' . $name . $uid . '\', \'' . $gif . '\');" />';
    $out .= '</div>';
    $out .= '</div>';
    return $out;
}
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;
}
Exemplo n.º 20
0
$tout = '';
$tout .= '<div class="spColumnSection spProfileLeftCol">';
$tout .= '<p class="spProfileLabel">' . sp_text('First Name') . ': </p>';
$tout .= '</div>';
$tout .= '<div class="spColumnSection spProfileSpacerCol"></div>';
$tout .= '<div class="spColumnSection spProfileRightCol">';
$tout .= '<input type="text" class="spControl" name="first_name" id="first_name" value="' . sp_filter_name_display($spProfileUser->first_name) . '" />';
$tout .= '</div>';
$out .= apply_filters('sph_ProfileUserFirstName', $tout, $userid, $thisSlug);
$tout = '';
$tout .= '<div class="spColumnSection spProfileLeftCol">';
$tout .= '<p class="spProfileLabel">' . sp_text('Last Name') . ': </p>';
$tout .= '</div>';
$tout .= '<div class="spColumnSection spProfileSpacerCol"></div>';
$tout .= '<div class="spColumnSection spProfileRightCol">';
$tout .= '<input type="text" class="spControl" name="last_name" id="last_name" value="' . sp_filter_name_display($spProfileUser->last_name) . '" />';
$tout .= '</div>';
$out .= apply_filters('sph_ProfileUserLastName', $tout, $userid, $thisSlug);
$tout = '';
$tout .= '<div class="spColumnSection spProfileLeftCol">';
$tout .= '<p class="spProfileLabel">' . sp_text('Website') . ': </p>';
$tout .= '</div>';
$tout .= '<div class="spColumnSection spProfileSpacerCol"></div>';
$tout .= '<div class="spColumnSection spProfileRightCol">';
$tout .= '<input type="text" class="spControl" name="website" id="website" value="' . sp_filter_url_display($spProfileUser->user_url) . '" />';
$tout .= '</div>';
$out .= apply_filters('sph_ProfileUserWebsite', $tout, $userid, $thisSlug);
$tout = '';
$tout .= '<div class="spColumnSection spProfileLeftCol">';
$tout .= '<p class="spProfileLabel">' . sp_text('Location') . ': </p>';
$tout .= '</div>';