function register_valid($confirm_hash) { global $Language; $request =& HTTPRequest::instance(); $vLoginName = new Valid_UserNameFormat('form_loginname'); $vLoginName->required(); if (!$request->valid($vLoginName)) { return 0; } $vRealName = new Valid_RealNameFormat('form_realname'); $vRealName->required(); if (!$request->valid($vRealName)) { $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_realname')); return 0; } if (!$request->existAndNonEmpty('form_pw')) { $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_nopasswd')); return 0; } $tz = $request->get('timezone'); if (!is_valid_timezone($tz)) { $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_notz')); return 0; } if (!$request->existAndNonEmpty('form_register_purpose') && ($GLOBALS['sys_user_approval'] && $request->get('page') != "admin_creation")) { $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_nopurpose')); return 0; } if (!validate_email($request->get('form_email'))) { $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_email')); return 0; } if ($request->get('page') != "admin_creation" && $request->get('form_pw') != $request->get('form_pw2')) { $GLOBALS['Response']->addFeedback('error', $Language->getText('account_register', 'err_passwd')); return 0; } if (!account_pwvalid($request->get('form_pw'), $errors)) { foreach ($errors as $e) { $GLOBALS['Response']->addFeedback('error', $e); } return 0; } $expiry_date = 0; if ($request->exist('form_expiry') && $request->get('form_expiry') != '' && !ereg("[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}", $request->get('form_expiry'))) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('account_register', 'data_not_parsed')); return 0; } $vDate = new Valid_String(); $vDate->required(); if ($request->exist('form_expiry') && $vDate->validate($request->get('form_expiry'))) { $date_list = split("-", $request->get('form_expiry'), 3); $unix_expiry_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]); $expiry_date = $unix_expiry_time; } $status = 'P'; if ($request->get('page') == "admin_creation") { if ($request->get('form_restricted')) { $status = 'R'; } else { $status = 'A'; } } //use sys_lang as default language for each user at register $res = account_create($request->get('form_loginname'), $request->get('form_pw'), '', $request->get('form_realname'), $request->get('form_register_purpose'), $request->get('form_email'), $status, $confirm_hash, $request->get('form_mail_site'), $request->get('form_mail_va'), $tz, UserManager::instance()->getCurrentUser()->getLocale(), 'A', $expiry_date); return $res; }
case User::STATUS_DELETED: $user->setStatus($request->get('form_status')); $user->setUnixStatus($user->getStatus()); $accountActivationEvent = 'project_admin_delete_user'; break; case User::STATUS_SUSPENDED: $user->setStatus($request->get('form_status')); $user->setUnixStatus($user->getStatus()); break; } } // Change login name if ($user->getUserName() != $request->get('form_loginname')) { if (SystemEventManager::instance()->canRenameUser($user)) { $vLoginName = new Valid_UserNameFormat('form_loginname'); $vLoginName->required(); if ($request->valid($vLoginName)) { switch ($user->getStatus()) { case User::STATUS_PENDING: case User::STATUS_VALIDATED: case User::STATUS_VALIDATED_RESTRICTED: $user->setUserName($request->get('form_loginname')); break; default: $em->processEvent(Event::USER_RENAME, array('user_id' => $user->getId(), 'new_name' => $request->get('form_loginname'))); $GLOBALS['Response']->addFeedback('info', $Language->getText('admin_usergroup', 'rename_user_msg', array($user->getUserName(), $request->get('form_loginname')))); $GLOBALS['Response']->addFeedback('warning', $Language->getText('admin_usergroup', 'rename_user_warn')); } } } else { $GLOBALS['Response']->addFeedback('warning', $Language->getText('admin_usergroup', 'rename_user_already_queued'), CODENDI_PURIFIER_DISABLED);