本文整理汇总了PHP中user_get_id_by_name函数的典型用法代码示例。如果您正苦于以下问题:PHP user_get_id_by_name函数的具体用法?PHP user_get_id_by_name怎么用?PHP user_get_id_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_get_id_by_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bugCreateHelper
function bugCreateHelper($reproducibility, $severity, $priority, $summary, $description, $project_id, $reporter_id)
{
# Change this path to point to the Mantis installation core.php file
require_once '../core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'bug_api.php';
access_ensure_project_level(config_get('report_bug_threshold'));
$t_bug_data = new BugData();
$t_bug_data->view_state = config_get('default_bug_view_status');
$t_bug_data->reproducibility = $reproducibility;
$t_bug_data->severity = $severity;
$t_bug_data->priority = $priority;
$t_bug_data->summary = $summary;
$t_bug_data->description = $description;
$t_bug_data->project_id = $project_id;
$t_bug_data->reporter_id = user_get_id_by_name($reporter_id);
if ($t_bug_data->reporter_id == "") {
$tmp = "Reported by: " . $reporter_id . "\n---------------------------------------------------\n\n";
$tmp .= $t_bug_data->description;
$t_bug_data->description = $tmp;
}
$t_bug_data->summary = trim($t_bug_data->summary);
# Create the bug
$t_bug_id = bug_create($t_bug_data);
email_new_bug($t_bug_id);
return $t_bug_id;
}
示例2: access_denied
function access_denied()
{
if (!auth_is_user_authenticated()) {
if (basename($_SERVER['SCRIPT_NAME']) != 'login_page.php') {
$t_return_page = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$t_return_page .= '?' . $_SERVER['QUERY_STRING'];
}
$t_return_page = string_url(string_sanitize_url($t_return_page));
print_header_redirect('login_page.php?return=' . $t_return_page);
}
} else {
if (auth_get_current_user_id() == user_get_id_by_name(config_get_global('anonymous_account'))) {
if (basename($_SERVER['SCRIPT_NAME']) != 'login_page.php') {
$t_return_page = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$t_return_page .= '?' . $_SERVER['QUERY_STRING'];
}
$t_return_page = string_url(string_sanitize_url($t_return_page));
echo '<center>';
echo '<p>' . error_string(ERROR_ACCESS_DENIED) . '</p>';
print_bracket_link('login_page.php?return=' . $t_return_page, lang_get('click_to_login'));
echo '<p></p>';
print_bracket_link('main_page.php', lang_get('proceed'));
echo '</center>';
}
} else {
echo '<center>';
echo '<p>' . error_string(ERROR_ACCESS_DENIED) . '</p>';
print_bracket_link('main_page.php', lang_get('proceed'));
echo '</center>';
}
}
exit;
}
示例3: autologin
function autologin()
{
if (auth_is_user_authenticated()) {
return;
}
$t_login_method = config_get('login_method');
if ($t_login_method != BASIC_AUTH) {
trigger_error("Invalid login method. ({$t_login_method})", ERROR);
}
$t_user_id = user_get_id_by_name($_SERVER['REMOTE_USER']);
if (!$t_user_id) {
trigger_error('Invalid user.', ERROR);
}
user_increment_login_count($t_user_id);
user_reset_failed_login_count_to_zero($t_user_id);
user_reset_lost_password_in_progress_count_to_zero($t_user_id);
auth_set_cookies($t_user_id, true);
auth_set_tokens($t_user_id);
}
示例4: ERP_update_check
function ERP_update_check()
{
$t_config_version = plugin_config_get('config_version');
if ($t_config_version === 0) {
$t_username = plugin_config_get('mail_reporter', '');
if (strlen($t_username) > 0) {
$t_user_id = user_get_id_by_name($t_username);
if ($t_user_id !== FALSE) {
$t_user_email = user_get_email($t_user_id);
if ($t_user_email === 'nomail') {
plugin_require_api('core/config_api.php');
# We need to allow blank emails for a sec
ERP_set_temporary_overwrite('allow_blank_email', ON);
user_set_email($t_user_id, '');
}
}
}
$t_schema = plugin_config_get('schema');
$t_reset_schema = plugin_config_get('reset_schema');
if ($t_schema !== -1 && $t_reset_schema === 0) {
plugin_config_set('schema', -1);
plugin_config_set('reset_schema', 1);
}
plugin_config_set('config_version', 1);
}
if ($t_config_version <= 1) {
$t_mail_reporter = plugin_config_get('mail_reporter', '');
if (strlen($t_mail_reporter) > 0) {
$t_mail_reporter_id = user_get_id_by_name($t_mail_reporter);
plugin_config_set('mail_reporter_id', $t_mail_reporter_id);
}
plugin_config_delete('mail_directory');
plugin_config_delete('mail_reporter');
plugin_config_delete('mail_additional');
plugin_config_delete('random_user_number');
plugin_config_delete('mail_bug_priority_default');
plugin_config_set('config_version', 2);
}
if ($t_config_version <= 2) {
plugin_config_delete('mail_cronjob_present');
plugin_config_delete('mail_check_timer');
plugin_config_delete('mail_last_check');
plugin_config_set('config_version', 3);
}
if ($t_config_version <= 3) {
$t_mailboxes = plugin_config_get('mailboxes', array());
$t_indexes = array('mailbox_project' => 'mailbox_project_id', 'mailbox_global_category' => 'mailbox_global_category_id');
foreach ($t_mailboxes as $t_key => $t_array) {
if (isset($t_array['mailbox_hostname'])) {
# Correct the hostname if it is stored in an older format
$t_hostname = $t_array['mailbox_hostname'];
if (!is_array($t_hostname)) {
// ipv6 also uses : so we need to work around that
if (substr_count($t_hostname, ':') === 1) {
$t_hostname = explode(':', $t_hostname, 2);
} else {
$t_hostname = array($t_hostname);
}
$t_hostname = array('hostname' => $t_hostname[0], 'port' => isset($t_hostname[1]) ? $t_hostname[1] : '');
$t_array['mailbox_hostname'] = $t_hostname;
}
}
$t_mailboxes[$t_key] = $this->ERP_update_indexes($t_array, $t_indexes);
}
plugin_config_set('mailboxes', $t_mailboxes);
plugin_config_set('config_version', 4);
}
if ($t_config_version <= 4) {
$t_mail_remove_mantis_email = plugin_config_get('mail_remove_mantis_email', -1);
$t_mail_identify_reply = plugin_config_get('mail_identify_reply', $t_mail_remove_mantis_email);
if ($t_mail_remove_mantis_email !== -1 && $t_mail_identify_reply !== $t_mail_remove_mantis_email) {
plugin_config_set('mail_remove_mantis_email', $t_mail_identify_reply);
}
plugin_config_delete('mail_identify_reply');
plugin_config_set('config_version', 5);
}
if ($t_config_version <= 5) {
plugin_config_delete('mail_parse_mime');
plugin_config_set('config_version', 6);
}
if ($t_config_version <= 6) {
$t_mailboxes = plugin_config_get('mailboxes', array());
$t_indexes = array('mailbox_enabled' => 'enabled', 'mailbox_description' => 'description', 'mailbox_type' => 'type', 'mailbox_hostname' => 'hostname', 'mailbox_encryption' => 'encryption', 'mailbox_username' => 'username', 'mailbox_password' => 'password', 'mailbox_auth_method' => 'auth_method', 'mailbox_project_id' => 'project_id', 'mailbox_global_category_id' => 'global_category_id', 'mailbox_basefolder' => 'basefolder', 'mailbox_createfolderstructure' => 'createfolderstructure');
foreach ($t_mailboxes as $t_key => $t_array) {
$t_mailboxes[$t_key] = $this->ERP_update_indexes($t_array, $t_indexes);
}
plugin_config_set('mailboxes', $t_mailboxes);
plugin_config_set('config_version', 7);
}
if ($t_config_version <= 7) {
$t_mailboxes = plugin_config_get('mailboxes', array());
foreach ($t_mailboxes as $t_key => $t_array) {
if (isset($t_array['hostname'])) {
$t_hostname = $t_array['hostname'];
if (is_array($t_hostname)) {
$t_array['hostname'] = $t_hostname['hostname'];
$t_array['port'] = $t_hostname['port'];
}
$t_mailboxes[$t_key] = $t_array;
}
//.........这里部分代码省略.........
示例5: Source_set_changeset_user
/**
* 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;
}
}
}
}
}
示例6: user_get_row_by_name
/**
* return all data associated with a particular user name
* return false if the username does not exist
*
* @param integer $p_username The username to retrieve data for.
* @return array
*/
function user_get_row_by_name($p_username)
{
$t_user_id = user_get_id_by_name($p_username);
if (false === $t_user_id) {
return false;
}
$t_row = user_get_row($t_user_id);
return $t_row;
}
示例7: auth_reauthenticate
* @package MantisBT
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright (C) 2002 - 2013 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @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();
示例8: date
$frequency = (int) 1;
$base = (string) date('Y-m-d\\TH:i:sO');
# add missing : in the O part of the date. PHP 5 supports a 'c' format which will output the format
# exactly as we want it.
# // 2002-10-02T10:00:00-0500 -> // 2002-10-02T10:00:00-05:00
$base = utf8_substr($base, 0, 22) . ':' . utf8_substr($base, -2);
$rssfile->addSYdata($period, $frequency, $base);
$t_page_number = 1;
$t_issues_per_page = 25;
$t_page_count = 0;
$t_issues_count = 0;
$t_project_id = $f_project_id;
if ($f_username !== null) {
$t_user_id = user_get_id_by_name($f_username);
} else {
$t_user_id = user_get_id_by_name(config_get('anonymous_account'));
}
$t_show_sticky = null;
if ($f_filter_id == 0) {
$t_custom_filter = filter_get_default();
$t_custom_filter['sort'] = $c_sort_field;
} else {
# null will be returned if the user doesn't have access right to access the filter.
$t_custom_filter = filter_db_get_filter($f_filter_id, $t_user_id);
if (null === $t_custom_filter) {
access_denied();
}
$t_custom_filter = filter_deserialize($t_custom_filter);
}
$t_issues = filter_get_bug_rows($t_page_number, $t_issues_per_page, $t_page_count, $t_issues_count, $t_custom_filter, $t_project_id, $t_user_id, $t_show_sticky);
$t_issues_count = count($t_issues);
示例9: rss_get_news_feed_url
/**
* return rss news feed url
* @param int $p_project_id
* @param string $p_username
* @param bool $p_relative
* @return string
*/
function rss_get_news_feed_url($p_project_id = null, $p_username = null, $p_relative = true)
{
if ($p_username === null) {
$t_username = current_user_get_field('username');
} else {
$t_username = $p_username;
}
if ($p_project_id === null) {
$t_project_id = helper_get_current_project();
} else {
$t_project_id = (int) $p_project_id;
}
if ($p_relative) {
$t_rss_link = '';
} else {
$t_rss_link = config_get('path');
}
$t_user_id = user_get_id_by_name($t_username);
// If we have a logged in user then they can be given a 'proper' feed, complete with auth string.
if (user_is_anonymous($t_user_id)) {
$t_rss_link .= "news_rss.php";
if ($t_project_id != ALL_PROJECTS) {
$t_rss_link .= "?project_id={$t_project_id}";
}
} else {
$t_rss_link .= "news_rss.php?username={$t_username}&key=" . rss_calculate_key($t_user_id);
if ($t_project_id != ALL_PROJECTS) {
$t_rss_link .= "&project_id={$t_project_id}";
}
}
return $t_rss_link;
}
示例10: get_user_id
/**
* Return the user id in the destination tracker
*
* Current logic is: try to find the same user by username;
* if it fails, use $squash_userid
*
* @param $field string bugdata filed to update
* @param $username string username as imported
* @param $squash_userid integer fallback userid
*/
private function get_user_id($username, $squash_userid = 0)
{
$t_user_id = user_get_id_by_name($username);
if ($t_user_id === false) {
//not found
$t_user_id = $squash_userid;
}
return $t_user_id;
}
示例11: api_token_validate
/**
* Validate a plain token for the specified user.
* @param string $p_username The user name.
* @param string $p_token The plain token.
* @return boolean true valid username and token, false otherwise.
* @access public
*/
function api_token_validate($p_username, $p_token)
{
# If the supplied token doesn't look like a valid one, then fail the check w/o doing db lookups.
# This is likely called from code that supports both tokens and passwords.
if (is_blank($p_token) || utf8_strlen($p_token) != API_TOKEN_LENGTH) {
return false;
}
$t_user_id = user_get_id_by_name($p_username);
# If user is not found in the database, they don't have api tokens, we won't bother with worrying about
# auto-creation scenario here.
if ($t_user_id === false) {
return false;
}
$t_encrypted_token = api_token_hash($p_token);
$t_query = 'SELECT * FROM {api_token} WHERE user_id=' . db_param() . ' AND hash=' . db_param();
$t_result = db_query($t_query, array($t_user_id, $t_encrypted_token));
$t_row = db_fetch_array($t_result);
if ($t_row) {
api_token_touch($t_row['id']);
return true;
}
return false;
}
示例12: getUserIdByName
function getUserIdByName($p_username)
{
return user_get_id_by_name($p_username);
}
示例13: event_update_bug
function event_update_bug($p_bug_event, $p_bug_data, $p_bug_id)
{
global $agilemantis_pb;
global $agilemantis_commonlib;
$t_product_owner = "";
$t_handler_id = 0;
$t_product_backlog_id = 0;
$t_team_id = 0;
$f_bug_id = 0;
// Only projects with agilMantis backlog
if (!$agilemantis_commonlib->projectHasBacklogs(helper_get_current_project())) {
return;
}
$request = array_merge($_GET, $_POST);
if ($_SESSION['AGILEMANTIS_ISMANTISADMIN'] == 1 || $_SESSION['AGILEMANTIS_ISMANTISUSER'] == 1) {
if (isset($_POST['backlog']) || isset($_POST['storypoints']) || isset($_POST['businessValue']) || isset($_POST['rankingorder']) || isset($_POST['technical']) || isset($_POST['presentable']) || isset($_POST['inReleaseDocu']) || isset($_POST['sprint'])) {
$f_bug_id = (int) $_POST['bug_id'];
$agilemantis_pb->setCustomFieldValues($f_bug_id);
# change Product Backlog
if ($_POST['old_product_backlog'] != $_POST['backlog'] && $_POST['backlog'] != "") {
$p_bug_data->handler_id = $_SESSION['tracker_handler'];
$p_bug_data->status = 50;
}
# change back to Team User if no Product Backlog is selected
if ($_POST['old_product_backlog'] != $_POST['backlog'] && $_POST['backlog'] == "") {
$t_product_backlog_id = $agilemantis_pb->get_product_backlog_id($_POST['old_product_backlog']);
if ($agilemantis_pb->count_productbacklog_teams($t_product_backlog_id) > 0) {
$t_team_id = $agilemantis_pb->getTeamIdByBacklog($t_product_backlog_id);
$t_product_owner = $agilemantis_pb->getProductOwner($t_team_id);
$t_handler_id = user_get_id_by_name($t_product_owner);
}
$p_bug_data->handler_id = $t_handler_id;
}
}
}
return $p_bug_data;
}
示例14: get_user_id
function get_user_id()
{
$t_user_id = user_get_id_by_name('acra_reporter');
if ($t_user_id === false) {
user_create("acra_reporter", date("YzHis", time()), $p_email = 'acra@mantis.com');
}
$t_user_id = user_get_id_by_name('acra_reporter');
return $t_user_id;
}
示例15: auth_attempt_script_login
function auth_attempt_script_login($p_username, $p_password = null)
{
global $g_script_login_cookie, $g_cache_current_user_id;
$t_user_id = user_get_id_by_name($p_username);
$t_user = user_get_row($t_user_id);
# check for disabled account
if (OFF == $t_user['enabled']) {
return false;
}
# validate password if supplied
if (null !== $p_password) {
if (!auth_does_password_match($t_user_id, $p_password)) {
return false;
}
}
# ok, we're good to login now
# increment login count
user_increment_login_count($t_user_id);
# set the cookies
$g_script_login_cookie = $t_user['cookie_string'];
# cache user id for future reference
$g_cache_current_user_id = $t_user_id;
return true;
}