コード例 #1
0
 * @link http://www.mantisbt.org
 */
/**
 * MantisBT Core API's
 */
require_once 'core.php';
auth_reauthenticate();
access_ensure_global_level(config_get('manage_user_threshold'));
$f_username = gpc_get_string('username', '');
if (is_blank($f_username)) {
    $t_user_id = gpc_get_int('user_id');
} else {
    $t_user_id = user_get_id_by_name($f_username);
    if ($t_user_id === false) {
        # If we can't find the user by name, attempt to find by email.
        $t_user_id = user_get_id_by_email($f_username);
        if ($t_user_id === false) {
            error_parameters($f_username);
            trigger_error(ERROR_USER_BY_NAME_NOT_FOUND, ERROR);
        }
    }
}
$t_user = user_get_row($t_user_id);
# Ensure that the account to be updated is of equal or lower access to the
# current user.
access_ensure_global_level($t_user['access_level']);
$t_ldap = LDAP == config_get('login_method');
html_page_top();
print_manage_menu();
?>
コード例 #2
0
/**
 * Sets the changeset's user id by looking up email address or name
 * Generic code for both Author and Committer, based on the given properties
 * @param object $p_changeset
 * @param string $p_user_type 'author' or 'committer'
 */
function Source_set_changeset_user(&$p_changeset, $p_user_type)
{
    static $s_vcs_names;
    static $s_names = array();
    static $s_emails = array();
    # Set the fields
    switch ($p_user_type) {
        case 'committer':
            list($t_id_prop, $t_name_prop, $t_email_prop) = explode(' ', 'committer_id committer committer_email');
            break;
        case 'author':
        default:
            list($t_id_prop, $t_name_prop, $t_email_prop) = explode(' ', 'user_id author author_email');
            break;
    }
    # The user's id is already set, nothing to do
    if ($p_changeset->{$t_id_prop}) {
        return;
    }
    # cache the vcs username mappings
    if (is_null($s_vcs_names)) {
        $s_vcs_names = SourceUser::load_mappings();
    }
    # Check username associations
    if (isset($s_vcs_names[$p_changeset->{$t_name_prop}])) {
        $p_changeset->{$t_id_prop} = $s_vcs_names[$p_changeset->{$t_name_prop}];
        return;
    }
    # Look up the email address if given
    if ($t_email = $p_changeset->{$t_email_prop}) {
        if (isset($s_emails[$t_email])) {
            $p_changeset->{$t_id_prop} = $s_emails[$t_email];
            return;
        } else {
            if (false !== ($t_email_id = user_get_id_by_email($t_email))) {
                $s_emails[$t_email] = $p_changeset->{$t_id_prop} = $t_email_id;
                return;
            }
        }
    }
    # Look up the name if the email failed
    if ($t_name = $p_changeset->{$t_name_prop}) {
        if (isset($s_names[$t_name])) {
            $p_changeset->{$t_id_prop} = $s_names[$t_name];
            return;
        } else {
            if (false !== ($t_user_id = user_get_id_by_realname($t_name))) {
                $s_names[$t_name] = $p_changeset->{$t_id_prop} = $t_user_id;
                return;
            } else {
                if (false !== ($t_user_id = user_get_id_by_name($p_changeset->{$t_name_prop}))) {
                    $s_names[$t_name] = $p_changeset->{$t_id_prop} = $t_user_id;
                    return;
                }
            }
        }
    }
}
コード例 #3
0
ファイル: mc_api.php プロジェクト: elmarculino/mantisbt
/**
 * Return user id
 * @param stdClass $p_user User.
 * @return integer user id
 */
function mci_get_user_id(stdClass $p_user)
{
    $p_user = SoapObjectsFactory::unwrapObject($p_user);
    $t_user_id = 0;
    if (isset($p_user['id']) && (int) $p_user['id'] != 0) {
        $t_user_id = (int) $p_user['id'];
    } elseif (isset($p_user['name'])) {
        $t_user_id = user_get_id_by_name($p_user['name']);
    } elseif (isset($p_user['email'])) {
        $t_user_id = user_get_id_by_email($p_user['email']);
    }
    return $t_user_id;
}
コード例 #4
0
ファイル: redirect.php プロジェクト: vboctor/GoogleOauth
$client->setRedirectUri(config_get(plugin_GoogleOauth_redirect_uri));
$objOAuthService = new Google_Service_Oauth2($client);
if (isset($_GET['code'])) {
    $client->authenticate($_GET['code']);
    $_SESSION['access_token'] = $client->getAccessToken();
    header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
    $client->setAccessToken($_SESSION['access_token']);
}
if ($client->getAccessToken()) {
    $userData = $objOAuthService->userinfo->get();
    $data['userData'] = $userData;
    $_SESSION['access_token'] = $client->getAccessToken();
}
$user_id = user_get_id_by_email($userData->email);
# check for disabled account
if (!user_is_enabled($user_id)) {
    echo "<p>Your email didn't to registration on this web site. Please register new account first. ";
    return false;
}
# max. failed login attempts achieved...
if (!user_is_login_request_allowed($user_id)) {
    echo "<p>Your email didn't to registration on this web site. Please register new account first. ";
    return false;
}
# check for anonymous login
if (user_is_anonymous($user_id)) {
    echo "<p>Your email didn't to registration on this web site. Please register new account first. ";
    return false;
}
コード例 #5
0
ファイル: mail_api.php プロジェクト: JeromyK/EmailReporting
 private function get_userid_from_email($p_email_address)
 {
     $t_reporter_id = FALSE;
     if ($this->_use_ldap_email) {
         $t_username = $this->ldap_get_username_from_email($p_email_address);
         if ($t_username !== NULL && user_is_name_valid($t_username)) {
             $t_reporter_id = user_get_id_by_name($t_username);
         }
     }
     if (!$t_reporter_id) {
         $t_reporter_id = user_get_id_by_email($p_email_address);
     }
     return $t_reporter_id;
 }
コード例 #6
0
ファイル: mc_api.php プロジェクト: raultm/mantisbt
function mci_get_user_id($p_user)
{
    $t_user_id = 0;
    if (isset($p_user['id']) && (int) $p_user['id'] != 0) {
        $t_user_id = (int) $p_user['id'];
    } elseif (isset($p_user['name'])) {
        $t_user_id = user_get_id_by_name($p_user['name']);
    } elseif (isset($p_user['email'])) {
        $t_user_id = user_get_id_by_email($p_user['email']);
    }
    return $t_user_id;
}
コード例 #7
0
/**
 * Determine the user ID for both the author and committer.
 * First checks the email address for a matching user, then
 * checks the name for a matching username or realname.
 * @param object Changeset object
 */
function Source_Parse_Users($p_changeset)
{
    static $s_vcs_names;
    static $s_names = array();
    static $s_emails = array();
    # cache the vcs username mappings
    if (is_null($s_vcs_names)) {
        $s_vcs_names = SourceUser::load_mappings();
    }
    # Handle the changeset author
    while (!$p_changeset->user_id) {
        # Check username associations
        if (isset($s_vcs_names[$p_changeset->author])) {
            $p_changeset->user_id = $s_vcs_names[$p_changeset->author];
            break;
        }
        # Look up the email address if given
        if ($t_email = $p_changeset->author_email) {
            if (isset($s_emails[$t_email])) {
                $p_changeset->user_id = $s_emails[$t_email];
                break;
            } else {
                if (false !== ($t_email_id = user_get_id_by_email($t_email))) {
                    $s_emails[$t_email] = $p_changeset->user_id = $t_email_id;
                    break;
                }
            }
        }
        # Look up the name if the email failed
        if ($t_name = $p_changeset->author) {
            if (isset($s_names[$t_name])) {
                $p_changeset->user_id = $s_names[$t_name];
                break;
            } else {
                if (false !== ($t_user_id = user_get_id_by_realname($t_name))) {
                    $s_names[$t_name] = $p_changeset->user_id = $t_user_id;
                    break;
                } else {
                    if (false !== ($t_user_id = user_get_id_by_name($p_changeset->author))) {
                        $s_names[$t_name] = $p_changeset->user_id = $t_user_id;
                        break;
                    }
                }
            }
        }
        # Don't actually loop
        break;
    }
    # Handle the changeset committer
    while (!$p_changeset->committer_id) {
        # Check username associations
        if (isset($s_vcs_names[$p_changeset->committer])) {
            $p_changeset->user_id = $s_vcs_names[$p_changeset->committer];
            break;
        }
        # Look up the email address if given
        if ($t_email = $t_email) {
            if (isset($s_emails[$t_email])) {
                $p_changeset->committer_id = $s_emails[$t_email];
                break;
            } else {
                if (false !== ($t_email_id = user_get_id_by_email($t_email))) {
                    $s_emails[$t_email] = $p_changeset->committer_id = $t_email_id;
                    break;
                }
            }
        }
        # Look up the name if the email failed
        if ($t_name = $p_changeset->committer) {
            if (isset($s_names[$t_name])) {
                $p_changeset->committer_id = $s_names[$t_name];
                break;
            } else {
                if (false !== ($t_user_id = user_get_id_by_realname($t_name))) {
                    $s_names[$t_name] = $p_changeset->committer_id = $t_user_id;
                    break;
                } else {
                    if (false !== ($t_user_id = user_get_id_by_name($t_name))) {
                        $s_names[$t_name] = $p_changeset->committer_id = $t_user_id;
                        break;
                    }
                }
            }
        }
        # Don't actually loop
        break;
    }
    return $p_changeset;
}