Пример #1
0
function bb_datetime_format_i18n($unixtimestamp, $type = 'datetime', $formatstring = '', $gmt = true)
{
    if (empty($formatstring)) {
        $formatstring = bb_get_datetime_formatstring_i18n($type);
    }
    return bb_gmdate_i18n($formatstring, bb_offset_time($unixtimestamp), $gmt);
}
function bb_user_row($user, $role = '', $email = false)
{
    $actions = "<a href='" . esc_attr(get_user_profile_link($user->ID)) . "'>" . __('View') . "</a>";
    $title = '';
    if (bb_current_user_can('edit_user', $user_id)) {
        $actions .= " | <a href='" . esc_attr(bb_get_user_admin_link($user->ID)) . "'>" . __('Edit') . "</a>";
        $title = " title='" . esc_attr(sprintf(__('User ID: %d'), $user->ID)) . "'";
    }
    $r = "\t<tr id='user-{$user->ID}'" . get_alt_class("user-{$role}") . ">\n";
    $r .= "\t\t<td class=\"user\">" . bb_get_avatar($user->ID, 32) . "<span class=\"row-title\"><a href='" . get_user_profile_link($user->ID) . "'" . $title . ">" . get_user_name($user->ID) . "</a></span><div><span class=\"row-actions\">{$actions}</span>&nbsp;</div></td>\n";
    $r .= "\t\t<td><a href='" . get_user_profile_link($user->ID) . "'>" . get_user_display_name($user->ID) . "</a></td>\n";
    if ($email) {
        $email = bb_get_user_email($user->ID);
        $r .= "\t\t<td><a href='mailto:{$email}'>{$email}</a></td>\n";
    }
    $registered_time = bb_gmtstrtotime($user->user_registered);
    if ($registered_time < time() - 86400) {
        $time = date('Y/m/d\\<\\b\\r \\/\\>H:i:s', bb_offset_time($registered_time));
    } else {
        $time = sprintf(__('%s ago'), bb_since($registered_time));
    }
    $r .= "\t\t<td>" . $time . "</td>\n";
    if (!isset($user->capabilities) || !is_array($user->capabilities) || empty($user->capabilities)) {
        $role = array(__('Inactive (no role)'));
    } else {
        global $nxt_roles;
        $_roles = $nxt_roles->get_names();
        $role = array();
        foreach ($user->capabilities as $cap => $cap_set) {
            if (!$cap_set) {
                continue;
            }
            $role[] = $_roles[$cap];
        }
        if (!count($role)) {
            $role[] = __('None');
        }
    }
    $r .= "\t\t<td>" . join(', ', $role) . "</td>\n\t</tr>";
    return $r;
}
        function display($show_search = true, $show_email = false)
        {
            global $wp_roles;
            $r = '';
            $now = date('Y-m-d H:i:s');
            if (isset($this->title)) {
                $title = $this->title;
            } elseif ($this->is_search()) {
                $title = sprintf(__('Users Matching "%s" by Role'), esc_html($this->search_term));
            }
            $h2_role = $this->roles[0];
            $roles = $wp_roles->get_names();
            if (in_array($h2_role, array_keys($roles))) {
                $h2_role = $roles[$h2_role];
            }
            $h2_span = apply_filters('bb_user_search_description', sprintf(__('%1$s%2$s'), $h2_search, $h2_role), $h2_search, $h2_role, $this);
            echo "<h2 class=\"first left\">" . apply_filters('bb_user_search_title', __('Users Waiting for Approval')) . $h2_span . "</h2>\n";
            do_action('bb_admin_notices');
            if ($this->get_results()) {
                if ($this->results_are_paged()) {
                    $r .= "<div class='tablenav'>\n" . $this->paging_text . "</div><div class=\"clear\"></div>\n\n";
                }
                $r .= "<table class='widefat'>\n";
                $r .= "<thead>\n";
                $r .= "\t<tr>\n";
                $r .= "\t\t<th style='width:10;'>&nbsp;</th>\n";
                $r .= "\t\t<th>" . __('Username') . "</th>\n";
                $r .= "\t\t<th>" . __('Email') . "</th>\n";
                $r .= "\t\t<th>" . __('Registered') . "</th>\n";
                $r .= "\t\t<th>" . __('Elapsed') . "</th>\n";
                $r .= "\t</tr>\n";
                $r .= "</thead>\n\n";
                $r .= "<tbody id='role-{$role}'>\n";
                foreach ((array) $this->get_results() as $user_object) {
                    //$r .= bb_user_row($user_object->ID, $role, $show_email);
                    $user = bb_get_user($user_object->ID);
                    $registered = date('Y/m/d H:i:s', bb_offset_time(bb_gmtstrtotime($user->user_registered)));
                    $date_eng = date('H:i:s - d/m/Y', bb_offset_time(bb_gmtstrtotime($user->user_registered)));
                    $difference = strtotime($now) - strtotime($registered);
                    $hours_ago = number_format($difference / 60 / 60, 0);
                    if ($hours_ago < '15') {
                        $reg_compare = '"color: red"';
                        $checked = '';
                    }
                    if ($hours_ago >= '15' && $hours_ago < '24') {
                        $reg_compare = '"color: blue"';
                        $checked = 'checked';
                    }
                    if ($hours_ago >= '24') {
                        $reg_compare = '"color: purple"';
                        $checked = 'checked';
                    }
                    $r .= "\t<tr id='user-{$user->ID}'" . get_alt_class("user-{$role}") . ">\n";
                    $r .= "\t\t<td><input type='checkbox' value='{$user->ID}' name='userids[]' {$checked}/></td>\n";
                    $r .= "\t\t<td><a href='" . get_user_profile_link($user->ID) . "' style=" . $reg_compare . ">" . get_user_name($user->ID) . "</a></td>\n";
                    $email = bb_get_user_email($user->ID);
                    $r .= "\t\t<td><a href='mailto:{$email}'>{$email}</a></td>\n";
                    $r .= "\t\t<td>" . $date_eng . "</td>\n";
                    $r .= "\t\t<td>" . $hours_ago . " hours</td>\n";
                    $r .= "\n\t</tr>";
                }
                $r .= "</tbody>\n";
                $r .= "<tfoot>\n";
                $r .= "\t<tr>\n";
                $r .= "\t\t<th>&nbsp;</th>\n";
                $r .= "\t\t<th>" . __('Username') . "</th>\n";
                $r .= "\t\t<th>" . __('Email') . "</th>\n";
                $r .= "\t\t<th>" . __('Registered') . "</th>\n";
                $r .= "\t\t<th>" . __('Elapsed') . "</th>\n";
                $r .= "\t</tr>\n";
                $r .= "</tfoot>\n\n";
                $r .= "</table>\n";
                $r .= "<p style=\"text-align: right; color: #9f9f9f; font-size: small; font-style: normal;\">Registered: Red: < 15 hours ago. Blue: > 15 hours ago. Purple: > 24 hours ago.</p>";
                if ($this->results_are_paged()) {
                    $r .= "<div class='tablenav bottom'>\n" . $this->paging_text_bottom . "</div><div class=\"clear\"></div>\n\n";
                }
            }
            ?>
			<form class="settings" method="post" name="approve_user_registration_form">
			<?php 
            echo $r;
            ?>
	       	<fieldset class="submit">
	          <input type="submit" class="submit left" name="approve_user_registration_button_approve" value="Approve" />
	          <input type="submit" class="submit left" name="approve_user_registration_button_reject" value="Reject" />
	        </fieldset>
	        </form>
			<?php 
            //			}
        }