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
/**
 * Reset the user's password
 *  Take into account the 'send_reset_password' setting
 *   - if it is ON, generate a random password and send an email
 *      (unless the second parameter is false)
 *   - if it is OFF, set the password to blank
 *  Return false if the user is protected, true if the password was
 *   successfully reset
 *
 * @param integer $p_user_id    A valid user identifier.
 * @param boolean $p_send_email Whether to send confirmation email.
 * @return boolean
 */
function user_reset_password($p_user_id, $p_send_email = true)
{
    $t_protected = user_get_field($p_user_id, 'protected');
    # Go with random password and email it to the user
    if (ON == $t_protected) {
        return false;
    }
    # @@@ do we want to force blank password instead of random if
    #      email notifications are turned off?
    #     How would we indicate that we had done this with a return value?
    #     Should we just have two functions? (user_reset_password_random()
    #     and user_reset_password() )?
    if (ON == config_get('send_reset_password') && ON == config_get('enable_email_notification')) {
        $t_email = user_get_field($p_user_id, 'email');
        if (is_blank($t_email)) {
            trigger_error(ERROR_LOST_PASSWORD_NO_EMAIL_SPECIFIED, ERROR);
        }
        # Create random password
        $t_password = auth_generate_random_password();
        $t_password2 = auth_process_plain_password($t_password);
        user_set_field($p_user_id, 'password', $t_password2);
        # Send notification email
        if ($p_send_email) {
            $t_confirm_hash = auth_generate_confirm_hash($p_user_id);
            email_send_confirm_hash_url($p_user_id, $t_confirm_hash);
        }
    } else {
        # use blank password, no emailing
        $t_password = auth_process_plain_password('');
        user_set_field($p_user_id, 'password', $t_password);
        # reset the failed login count because in this mode there is no emailing
        user_reset_failed_login_count_to_zero($p_user_id);
    }
    return true;
}
#  anyway)
# strip extra space from real name
$t_realname = string_normalize($f_realname);
user_ensure_name_valid($f_username);
user_ensure_realname_valid($t_realname);
user_ensure_realname_unique($f_username, $f_realname);
if ($f_password != $f_password_verify) {
    trigger_error(ERROR_USER_CREATE_PASSWORD_MISMATCH, ERROR);
}
$f_email = email_append_domain($f_email);
email_ensure_not_disposable($f_email);
if (ON == config_get('send_reset_password') && ON == config_get('enable_email_notification')) {
    # Check code will be sent to the user directly via email. Dummy password set to random
    # Create random password
    $t_seed = $f_email . $f_username;
    $f_password = auth_generate_random_password($t_seed);
} else {
    # Password won't to be sent by email. It entered by the admin
    # Now, if the password is empty, confirm that that is what we wanted
    if (is_blank($f_password)) {
        helper_ensure_confirmed(lang_get('empty_password_sure_msg'), lang_get('empty_password_button'));
    }
}
# Don't allow the creation of accounts with access levels higher than that of
# the user creating the account.
access_ensure_global_level($f_access_level);
# Need to send the user creation mail in the tracker language, not in the creating admin's language
# Park the current language name until the user has been created
lang_push(config_get('default_language'));
# create the user
$t_admin_name = user_get_name(auth_get_current_user_id());
Example #4
0
# Check the name for validity here so we do it before promting to use a
#  blank password (don't want to prompt the user if the process will fail
#  anyway)
# strip extra space from real name
$t_realname = string_normalize($f_realname);
user_ensure_name_valid($f_username);
user_ensure_realname_unique($f_username, $f_realname);
if ($f_password != $f_password_verify) {
    trigger_error(ERROR_USER_CREATE_PASSWORD_MISMATCH, ERROR);
}
$f_email = trim($f_email);
email_ensure_not_disposable($f_email);
if (ON == config_get('send_reset_password') && ON == config_get('enable_email_notification')) {
    # Check code will be sent to the user directly via email. Dummy password set to random
    # Create random password
    $f_password = auth_generate_random_password();
} else {
    # Password won't to be sent by email. It entered by the admin
    # Now, if the password is empty, confirm that that is what we wanted
    if (is_blank($f_password)) {
        helper_ensure_confirmed(lang_get('empty_password_sure_msg'), lang_get('empty_password_button'));
    }
}
# Don't allow the creation of accounts with access levels higher than that of
# the user creating the account.
access_ensure_global_level($f_access_level);
# Need to send the user creation mail in the tracker language, not in the creating admin's language
# Park the current language name until the user has been created
lang_push(config_get('default_language'));
# create the user
$t_admin_name = user_get_name(auth_get_current_user_id());
 /**
  * EmailReporting installation function.
  */
 function install()
 {
     // We need to load a default value since the function config() which sets
     // the defaults has not been run yet. On the other hand, configuration options
     // already present in the database will be available.
     $t_mail_reporter_id = plugin_config_get('mail_reporter_id', 'Mail');
     if ($t_mail_reporter_id === 'Mail') {
         // The plugin variable path_erp is not yet available. So path_erp cannot be used here
         plugin_require_api('core/config_api.php');
         # We need to allow blank emails for a sec
         ERP_set_temporary_overwrite('allow_blank_email', ON);
         $t_rand = mt_rand(1000, 99999);
         $t_username = $t_mail_reporter_id . $t_rand;
         $t_email = '';
         $t_seed = $t_email . $t_username;
         # Create random password
         $t_password = auth_generate_random_password($t_seed);
         # create the user
         $t_result_user_create = user_create($t_username, $t_password, $t_email, config_get_global('report_bug_threshold'), FALSE, TRUE, 'Mail Reporter', plugin_lang_get('plugin_title'));
         # Save these after the user has been created successfully
         if ($t_result_user_create) {
             $t_user_id = user_get_id_by_name($t_username);
             plugin_config_set('mail_reporter_id', $t_user_id);
         }
         // We need to set this here otherwise we mess up new installations with ERP_update_check
         plugin_config_set('reset_schema', 1);
         return $t_result_user_create;
     }
     return TRUE;
 }