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;
}
Exemplo n.º 2
0
function bb_ksd_submit($submit, $type = false)
{
    global $bb_ksd_api_host;
    global $bb_ksd_api_port;
    switch ($type) {
        case 'ham':
        case 'spam':
            $path = '/1.1/submit-' . $type;
            $bb_post = bb_get_post($submit);
            if (!$bb_post) {
                return;
            }
            $user = bb_get_user($bb_post->poster_id);
            if (bb_is_trusted_user($user->ID)) {
                return;
            }
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => $bb_post->poster_ip, 'permalink' => get_topic_link($bb_post->topic_id), 'comment_type' => 'forum', 'comment_author' => get_user_name($user->ID), 'comment_author_email' => bb_get_user_email($user->ID), 'comment_author_url' => get_user_link($user->ID), 'comment_content' => $bb_post->post_text, 'comment_date_gmt' => $bb_post->post_time);
            break;
        case 'hammer':
        case 'spammer':
            $path = '/1.1/submit-' . substr($type, 0, -3);
            $user = bb_get_user($submit);
            if (!$user) {
                return;
            }
            if (bb_is_trusted_user($user->ID)) {
                return;
            }
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'permalink' => get_user_profile_link($user->ID), 'comment_type' => 'profile', 'comment_author' => get_user_name($user->ID), 'comment_author_email' => bb_get_user_email($user->ID), 'comment_author_url' => get_user_link($user->ID), 'comment_content' => $user->occ . ' ' . $user->interests, 'comment_date_gmt' => $user->user_registered);
            break;
        default:
            if (bb_is_trusted_user(bb_get_current_user())) {
                return;
            }
            $path = '/1.1/comment-check';
            $_submit = array('blog' => bb_get_uri(null, null, BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_AKISMET), 'user_ip' => preg_replace('/[^0-9., ]/', '', $_SERVER['REMOTE_ADDR']), 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER'], 'comment_type' => isset($_POST['topic_id']) ? 'forum' : 'profile', 'comment_author' => bb_get_current_user_info('name'), 'comment_author_email' => bb_get_current_user_info('email'), 'comment_author_url' => bb_get_current_user_info('url'), 'comment_content' => $submit);
            if (isset($_POST['topic_id'])) {
                $_submit['permalink'] = get_topic_link($_POST['topic_id']);
                // First page
            }
            break;
    }
    $query_string = '';
    foreach ($_submit as $key => $data) {
        $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
    }
    return bb_ksd_http_post($query_string, $bb_ksd_api_host, $path, $bb_ksd_api_port);
}
 /**
  * Retrieve the avatar for a user provided a user ID or email address
  *
  * @since 0.9
  * @param int|string $id_or_email A user ID or email address
  * @param int $size Size of the avatar image
  * @param string $default URL to a default image to use if no avatar is available
  * @param string $alt Alternate text to use in image tag. Defaults to blank
  * @return string <img> tag for the user's avatar
 */
 function bb_get_avatar($id_or_email, $size = 80, $default = '', $alt = false)
 {
     if (!bb_get_option('avatars_show')) {
         return false;
     }
     if (false === $alt) {
         $safe_alt = '';
     } else {
         $safe_alt = esc_attr($alt);
     }
     if (!is_numeric($size)) {
         $size = 80;
     }
     if ($email = bb_get_user_email($id_or_email)) {
         $class = 'photo ';
     } else {
         $class = '';
         $email = $id_or_email;
     }
     if (!$email) {
         $email = '';
     }
     if (empty($default)) {
         $default = bb_get_option('avatars_default');
     }
     if (is_ssl()) {
         $host = 'https://secure.gravatar.com';
     } else {
         $host = 'http://www.gravatar.com';
     }
     switch ($default) {
         case 'logo':
             $default = '';
             break;
         case 'blank':
             $default = bb_get_uri('bb-admin/images/blank.gif', null, BB_URI_CONTEXT_IMG_SRC);
             break;
         case 'monsterid':
         case 'wavatar':
         case 'identicon':
             break;
         case 'default':
         default:
             $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size;
             // ad516503a11cd5ca435acc9bb6523536 == md5('*****@*****.**')
             break;
     }
     $src = $host . '/avatar/';
     $class .= 'avatar avatar-' . $size;
     if (!empty($email)) {
         $src .= md5(strtolower($email));
     } else {
         $src .= 'd41d8cd98f00b204e9800998ecf8427e';
         // d41d8cd98f00b204e9800998ecf8427e == md5('')
         $class .= ' avatar-noemail';
     }
     $src .= '?s=' . $size;
     $src .= '&amp;d=' . urlencode($default);
     $rating = bb_get_option('avatars_rating');
     if (!empty($rating)) {
         $src .= '&amp;r=' . $rating;
     }
     $avatar = '<img alt="' . $safe_alt . '" src="' . $src . '" class="' . $class . '" style="height:' . $size . 'px; width:' . $size . 'px;" />';
     return apply_filters('bb_get_avatar', $avatar, $id_or_email, $size, $default, $alt);
 }
function bb_get_current_user_info($key = '')
{
    if (!is_string($key)) {
        return;
    }
    if (!($user = bb_get_current_user())) {
        // Not globalized
        return false;
    }
    switch ($key) {
        case '':
            return $user;
            break;
        case 'id':
        case 'ID':
            return (int) $user->ID;
            break;
        case 'name':
            return get_user_display_name($user->ID);
            break;
        case 'login':
        case 'user_login':
            return get_user_name($user->ID);
            break;
        case 'email':
        case 'user_email':
            return bb_get_user_email($user->ID);
            break;
        case 'url':
        case 'uri':
        case 'user_url':
            return get_user_link($user->ID);
            break;
    }
}
/**
 * Sends an email with the user's new password
 *
 * {@internal Missing Long Description}}
 *
 * @since 0.7.2
 * @global bbdb $bbdb {@internal Not used}}
 *
 * @param int|string $user
 * @param string $pass
 * @return bool
 */
function bb_send_pass($user, $pass)
{
    if (!($user = bb_get_user($user))) {
        return false;
    }
    $message = sprintf(__("Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!"), $user->user_login, $pass, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT));
    $message = apply_filters('bb_send_pass_message', $message, $user, $pass);
    $subject = sprintf(__('%s: Password'), bb_get_option('name'));
    $subject = apply_filters('bb_send_pass_subject', $subject, $user);
    return bb_mail(bb_get_user_email($user->ID), $subject, $message);
}
function approve_user_registration_reject_user($user_id)
{
    global $bbdb;
    $user = defined('BACKPRESS_PATH') ? new BP_User($user_id) : new BB_User($user_id);
    $user->remove_cap('waitingapproval');
    $user->remove_cap('member');
    $user->add_cap('blocked');
    $user = bb_get_user($user_id);
    $message = __("Your user %1\$s has been rejected by the administrator. This may be due to an unsuitable username, or perhaps your email address looks suspicious. If you think you have been rejected in error please contact the site administrator.");
    return bb_mail(bb_get_user_email($user->ID), bb_get_option('name') . ': ' . __('User Rejected'), sprintf($message, $user->user_login));
}
/**
 * Sends an email with the user's new password
 *
 * {@internal Missing Long Description}}
 *
 * @since 0.7.2
 * @global bbdb $bbdb {@internal Not used}}
 *
 * @param int|string $user
 * @param string $pass
 * @return bool
 */
function bb_send_pass($user, $pass)
{
    if (!($user = bb_get_user($user))) {
        return false;
    }
    $message = __("Your username is: %1\$s \nYour password is: %2\$s \nYou can now log in: %3\$s \n\nEnjoy!");
    return bb_mail(bb_get_user_email($user->ID), bb_get_option('name') . ': ' . __('Password'), sprintf($message, $user->user_login, $pass, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT)));
}
Exemplo n.º 8
0
function li_foot_script()
{
    //ob_start();
    global $bb_current_user;
    $_linkedin_need_email_form = FALSE;
    $user =& $bb_current_user->data;
    if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE && bb_is_user_logged_in() && !li_check_if_email_set(bb_get_user_email($user->ID))) {
        //if ( li_get_prompt_status_by_userid(bb_get_user_id($user->ID))) {
        //echo $_SERVER['REQUEST_URI'];
        //echo $_SERVER['PHP_SELF'];
        //echo '/forum/profile/'.(get_user_name($user->ID).'/edit');
        // make sure not show on profile edit tab as we want users to edit email
        if (strpos($_SERVER['REQUEST_URI'], '/forum/profile/' . (get_user_name($user->ID) . '/edit')) !== FALSE) {
            $_linkedin_need_email_form = FALSE;
        } else {
            $_linkedin_need_email_form = TRUE;
        }
        //}
    }
    ?>
	
	<div id="li-root"></div>
	<!-- begin LinkedIn Connect footer -->
	<?php 
    if ($_linkedin_need_email_form) {
        /*<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
        		<label for="user_email">Email</label>
        		<input name="user_email" id="user_email" type="text" value="">
        		</br>
        		<label for="user_email_validate">Enter Email Again</label>
        		<input name="user_email_validate" id="user_email_validate" type="text" value="">
        		
        		<p class="submit left">
        		  <input type="submit" name="Defer" value="Skip">
        		</p>
        		<p class="submit right">
        		  <input type="submit" name="Submit" value="Update Email »">
        		</p>
        		</form>*/
        ?>
		<div id="linkedin_email_form">
			<a id="linkedin_email_form_close" style="cursor: pointer">x</a> 
			<br/> 

			<p>LinkedIn won’t give us an email address.</p>
			<p>Please click <a id="linkedin_email_form_close_button" 
				href="<?php 
        profile_tab_link(bb_get_user_id($user->ID), 'edit');
        ?>
" style="color:white;">here</a> to update it in your profile.</p>
			<br/>
			<p>That allows you to receive answers to comments on your posts by email.</p>
		</div>
		<div id="backgroundPopup"></div>  
	<?php 
    }
    //ob_flush();
    ?>
	
	<script>
	<?php 
    if ($_linkedin_need_email_form) {
        ?>
		//SETTING UP OUR POPUP
		//0 means disabled; 1 means enabled;
		var popupStatus = 0;

		function loadPopup(){
		if(popupStatus==0){
		$("#backgroundPopup").css({
		"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#linkedin_email_form").fadeIn("slow");
		popupStatus = 1;
		}
		}
		function disablePopup(){
		if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#linkedin_email_form").fadeOut("slow");
		popupStatus = 0;
		}
		}
		//centering popup
		function centerPopup(){
		//request data for centering
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#linkedin_email_form").height();
		var popupWidth = $("#linkedin_email_form").width();
		//centering
		$("#linkedin_email_form").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
		});
		//only need force for IE6
		$("#backgroundPopup").css({
		"height": windowHeight
		});
		}

		$(document).ready(function(){
			
			centerPopup();
			loadPopup();

			$("#linkedin_email_form_close").click(function(){
				disablePopup();
			});
			
			$("#linkedin_email_form_close_button").click(function(){
				disablePopup();
			});

			$("#backgroundPopup").click(function(){
				disablePopup();
			});
			
		});
		
		 
	<?php 
    }
    ?>
		var addUrlParam = function(search, key, val){
		  var newParam = key + '=' + val,
		  params = '?' + newParam;
	
		  if (search) {
		    params = search.replace(new RegExp('[\?&]' + key + '[^&]*'), '$1' + newParam);
		    if (params === search) {
		      params += '&' + newParam;
		    }
		  }
		  return params;
		};
		
		function li_login_action(){
			document.location = document.location.pathname + addUrlParam(document.location.search, 'li_bb_connect', escape(document.location));
		}; 
		
		function li_revoke_action() {
			document.location = document.location.pathname + addUrlParam(document.location.search, 'li_bb_revoke', escape(document.location));
		};
	</script>
	
	<!-- end Linkedin Connect footer -->
<?php 
}