function newProductBacklog()
 {
     global $agilemantis_au;
     // Check if team-user name fits into MantisBT regulations
     if (!(utf8_strlen($this->name) < 22 && user_is_name_valid($this->name) && user_is_name_unique($this->name))) {
         return null;
     }
     $p_username = $this->generateTeamUser($this->name);
     $p_email = $this->email;
     $p_email = trim($p_email);
     $t_seed = $p_email . $p_username;
     $t_password = auth_generate_random_password($t_seed);
     if (user_is_name_unique($p_username) === true) {
         user_create($p_username, $t_password, $p_email, 55, false, true, 'Team-User-' . $_POST['pbl_name']);
     } else {
         $t_user_id = $this->getUserIdByName($p_username);
         user_set_field($t_user_id, 'email', $p_email);
     }
     $user_id = $this->getLatestUser();
     $agilemantis_au->setAgileMantisUserRights($user_id, 1, 0, 0);
     if ($this->team == 0) {
         $this->team = $this->getLatestUser();
     }
     $t_sql = "INSERT INTO gadiv_productbacklogs (name, description, user_id) VALUES ( " . db_param(0) . ", " . db_param(1) . ", " . db_param(2) . ") ";
     $t_params = array($this->name, $this->description, $user_id);
     db_query_bound($t_sql, $t_params);
     $this->id = db_insert_id("gadiv_productbacklogs");
     $this->user_id = $user_id;
     return $this->id;
 }
Example #2
0
/**
 * Check if the username is unique and trigger an ERROR if it isn't
 * @param string $p_username The username to check.
 * @return void
 */
function user_ensure_name_unique($p_username)
{
    if (!user_is_name_unique($p_username)) {
        trigger_error(ERROR_USER_NAME_NOT_UNIQUE, ERROR);
    }
}
require_once 'core.php';
$t_core_path = config_get('core_path');
require_once $t_core_path . 'email_api.php';
access_ensure_global_level(config_get('manage_user_threshold'));
$f_protected = gpc_get_bool('protected');
$f_enabled = gpc_get_bool('enabled');
$f_email = gpc_get_string('email', '');
$f_username = gpc_get_string('username', '');
$f_realname = gpc_get_string('realname', '');
$f_access_level = gpc_get_int('access_level');
$f_user_id = gpc_get_int('user_id');
$f_email = trim($f_email);
$f_username = trim($f_username);
$t_old_username = user_get_field($f_user_id, 'username');
# check that the username is unique
if (0 != strcasecmp($t_old_username, $f_username) && false == user_is_name_unique($f_username)) {
    trigger_error(ERROR_USER_NAME_NOT_UNIQUE, ERROR);
}
user_ensure_name_valid($f_username);
user_ensure_realname_valid($f_realname);
user_ensure_realname_unique($f_username, $f_realname);
$f_email = email_append_domain($f_email);
email_ensure_valid($f_email);
$c_email = db_prepare_string($f_email);
$c_username = db_prepare_string($f_username);
$c_realname = db_prepare_string($f_realname);
$c_protected = db_prepare_bool($f_protected);
$c_enabled = db_prepare_bool($f_enabled);
$c_user_id = db_prepare_int($f_user_id);
$c_access_level = db_prepare_int($f_access_level);
$t_user_table = config_get('mantis_user_table');
Example #4
0
 private function validate_username($p_username, $p_rand = '')
 {
     $t_username = $p_username;
     if (utf8_strlen($t_username . $p_rand) > DB_FIELD_SIZE_USERNAME) {
         $t_username = utf8_substr($t_username, 0, DB_FIELD_SIZE_USERNAME - strlen($p_rand));
     }
     $t_username = $t_username . $p_rand;
     if (user_is_name_valid($t_username) && user_is_name_unique($t_username)) {
         return $t_username;
     }
     return FALSE;
 }
$t_old_username = $t_user['username'];

if( $f_send_email_notification ) {
	$t_old_realname = $t_user['realname'];
	$t_old_email = $t_user['email'];
	$t_old_access_level = $t_user['access_level'];
}

# 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'] );

# check that the username is unique
if( 0 != strcasecmp( $t_old_username, $f_username )
	&& false == user_is_name_unique( $f_username ) ) {
	trigger_error( ERROR_USER_NAME_NOT_UNIQUE, ERROR );
}

user_ensure_name_valid( $f_username );

$t_ldap = ( LDAP == config_get( 'login_method' ) );

if( $t_ldap && config_get( 'use_ldap_realname' ) ) {
	$t_realname = ldap_realname_from_username( $f_username );
} else {
	# strip extra space from real name
	$t_realname = string_normalize( $f_realname );
	user_ensure_realname_unique( $t_old_username, $t_realname );
}