예제 #1
0
function wpu_phpbb_rankblock($wpID = '')
{
    echo get_wpu_phpbb_rankblock($wpID);
}
예제 #2
0
/**
 * Gets info about the current user, or a login form if they are logged out, without displaying it
 * @author Japgalaxy, updated by John Wells
 * @example wpu_login_user_info("before=<li>&after=</li>&showLoginForm=1&showRankBlock=1&showNewPosts=1&showWriteLink=1&showAdminLinks=1&showPMs=1&autoLogin=1");
 */
function get_wpu_login_user_info($args)
{
    global $user_ID, $db, $auth, $phpbbForum, $wpUnited, $phpEx, $config;
    $defaults = array('before' => '<li>', 'after' => '</li>', 'showPMs' => 1, 'showLoginForm' => 1, 'showRankBlock' => 1, 'showNewPosts' => 1, 'showWriteLink' => 1, 'showAdminLinks' => 1, 'autoLogin' => 1);
    extract(_wpu_process_args($args, $defaults));
    $ret = '';
    get_currentuserinfo();
    $loggedIn = $phpbbForum->user_logged_in();
    $loginLang = $loggedIn ? sprintf($phpbbForum->lang['LOGOUT_USER'], $phpbbForum->get_username()) : $phpbbForum->lang['LOGIN'];
    $loginAction = $loggedIn ? '?mode=logout' : '?mode=login';
    if ($loggedIn) {
        $wpu_usr = get_wpu_phpbb_username();
        $colour = $phpbbForum->get_userdata('user_colour');
        $colour = $colour ? ' style="color: #' . $colour . '" ' : '';
        $ret .= _wpu_add_class($before, 'wpu-widget-lu-username') . '<a href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '" ' . $colour . '><strong>' . $wpu_usr . '</strong></a>' . $after;
        $ret .= _wpu_add_class($before, 'wpu-widget-lu-avatar') . '<img src="' . get_avatar_reader() . '" alt="' . $phpbbForum->lang['USER_AVATAR'] . '" />' . $after;
        if ($showRankBlock) {
            $ret .= _wpu_add_class($before, 'wpu-widget-lu-rankblock') . get_wpu_phpbb_rankblock() . $after;
        }
        if ($showNewPosts) {
            $ret .= $before . get_wpu_newposts_link() . $after;
        }
        $fStateChanged = $phpbbForum->foreground();
        $admin = $auth->acl_get('a_');
        $autoLogin = $config['allow_autologin'];
        $PMs = $phpbbForum->get_user_pm_details();
        $phpbbForum->restore_state($fStateChanged);
        // Handle new PMs
        if ($showPMs) {
            if ($PMs['text']) {
                $ret .= _wpu_add_class($before, 'wpu-has-pms') . '<a title="' . $PMs['text'] . '" href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '?i=pm&folder=inbox">' . $PMs['text'] . '</a>' . $after;
            } else {
                $ret .= _wpu_add_class($before, 'wpu-no-pms') . '<a title="' . $phpbbForum->lang['NO_NEW_PM'] . '" href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '?i=pm&folder=inbox">' . $phpbbForum->lang['NO_NEW_PM'] . '</a>' . $after;
            }
        }
        if ($showWriteLink) {
            if (current_user_can('edit_posts')) {
                $ret .= $before . '<a href="' . $wpUnited->get_wp_base_url() . 'wp-admin/post-new.php" title="' . __('Write a Post', 'wp-united') . '">' . __('Write a Post', 'wp-united') . '</a>' . $after;
            }
        }
        if ($showAdminLinks) {
            if (current_user_can('read')) {
                $ret .= $before . '<a href="' . $wpUnited->get_wp_base_url() . 'wp-admin/" title="' . __('Dashboard', 'wp-united') . '">' . __('Dashboard', 'wp-united') . '</a>' . $after;
            }
            if ($admin) {
                $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'adm/index.' . $phpEx) . '" title="' . $phpbbForum->lang['ACP'] . '">' . $phpbbForum->lang['ACP'] . '</a>' . $after;
            }
        }
        $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.' . $phpEx . $loginAction) . '" title="' . $loginLang . '">' . $loginLang . '</a>' . $after;
    } else {
        if ($showLoginForm) {
            $redir = wpu_get_redirect_link();
            $login_link = $phpbbForum->append_sid('ucp.' . $phpEx . '?mode=login') . '&amp;redirect=' . $redir;
            $ret .= '<form class="wpuloginform" method="post" action="' . $phpbbForum->get_board_url() . $login_link . '">';
            $ret .= $before . '<label for="phpbb_username">' . $phpbbForum->lang['USERNAME'] . '</label> <input tabindex="1" class="inputbox autowidth" type="text" name="username" id="phpbb_username"/>' . $after;
            $ret .= $before . '<label for="phpbb_password">' . $phpbbForum->lang['PASSWORD'] . '</label> <input tabindex="2" class="inputbox autowidth" type="password" name="password" id="phpbb_password" maxlength="32" />' . $after;
            if ($autoLogin) {
                $ret .= $before . '<input tabindex="3" type="checkbox" id="phpbb_autologin" name="autologin" /><label for="phpbb_autologin"> ' . __('Remember me', 'wp-united') . '</label>' . $after;
            }
            $ret .= $before . '<input type="submit" name="login" class="wpuloginsubmit" value="' . __('Login') . '" />' . $after;
            $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . "ucp.php?mode=register") . '">' . __('Register', 'wp-united') . '</a>' . $after;
            $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.php?mode=sendpassword') . '">' . __('Forgot Password?', 'wp-united') . '</a>' . $after;
            $ret .= '</form>';
        } else {
            $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.' . $phpEx . $loginAction) . '" title="' . $loginLang . '">' . $loginLang . '</a>';
        }
    }
    return $ret;
}