本文整理汇总了PHP中UserAttributeKey::getRegistrationList方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAttributeKey::getRegistrationList方法的具体用法?PHP UserAttributeKey::getRegistrationList怎么用?PHP UserAttributeKey::getRegistrationList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAttributeKey
的用法示例。
在下文中一共展示了UserAttributeKey::getRegistrationList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: defined
defined('C5_EXECUTE') or die("Access Denied.");
$token = \Core::make('Concrete\\Core\\Validation\\CSRF\\Token');
?>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<div class="page-header">
<h1><?php
echo t('Site Registration');
?>
</h1>
</div>
</div>
</div>
<?php
$attribs = UserAttributeKey::getRegistrationList();
if ($registerSuccess) {
?>
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<?php
switch ($registerSuccess) {
case "registered":
?>
<p><strong><?php
echo $successMsg;
?>
</strong><br/><br/>
<a href="<?php
echo $view->url('/');
?>
示例2: do_register
public function do_register() {
$registerData['success']=0;
$userHelper = Loader::helper('concrete/user');
$e = Loader::helper('validation/error');
$ip = Loader::helper('validation/ip');
$txt = Loader::helper('text');
$vals = Loader::helper('validation/strings');
$valc = Loader::helper('concrete/validation');
$username = $_POST['uName'];
$password = $_POST['uPassword'];
$passwordConfirm = $_POST['uPasswordConfirm'];
// clean the username
$username = trim($username);
$username = preg_replace("/ +/", " ", $username);
if (!$ip->check()) {
$e->add($ip->getErrorMessage());
}
if (ENABLE_REGISTRATION_CAPTCHA) {
$captcha = Loader::helper('validation/captcha');
if (!$captcha->check()) {
$e->add(t("Incorrect image validation code. Please check the image and re-enter the letters or numbers as necessary."));
}
}
if (!$vals->email($_POST['uEmail'])) {
$e->add(t('Invalid email address provided.'));
} else if (!$valc->isUniqueEmail($_POST['uEmail'])) {
$e->add(t("The email address %s is already in use. Please choose another.", $_POST['uEmail']));
}
//if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == false) {
if (strlen($username) < USER_USERNAME_MINIMUM) {
$e->add(t('A username must be between at least %s characters long.', USER_USERNAME_MINIMUM));
}
if (strlen($username) > USER_USERNAME_MAXIMUM) {
$e->add(t('A username cannot be more than %s characters long.', USER_USERNAME_MAXIMUM));
}
if (strlen($username) >= USER_USERNAME_MINIMUM && !$valc->username($username)) {
if(USER_USERNAME_ALLOW_SPACES) {
$e->add(t('A username may only contain letters, numbers and spaces.'));
} else {
$e->add(t('A username may only contain letters or numbers.'));
}
}
if (!$valc->isUniqueUsername($username)) {
$e->add(t("The username %s already exists. Please choose another", $username));
}
//}
if ($username == USER_SUPER) {
$e->add(t('Invalid Username'));
}
/*
if ((strlen($password) < USER_PASSWORD_MINIMUM) || (strlen($password) > USER_PASSWORD_MAXIMUM)) {
$e->add(t('A password must be between %s and %s characters', USER_PASSWORD_MINIMUM, USER_PASSWORD_MAXIMUM));
}
if (strlen($password) >= USER_PASSWORD_MINIMUM && !$valc->password($password)) {
$e->add(t('A password may not contain ", \', >, <, or any spaces.'));
}
*/
$userHelper->validNewPassword($password,$e);
if ($password) {
if ($password != $passwordConfirm) {
$e->add(t('The two passwords provided do not match.'));
}
}
$aks = UserAttributeKey::getRegistrationList();
foreach($aks as $uak) {
if ($uak->isAttributeKeyRequiredOnRegister()) {
$e1 = $uak->validateAttributeForm();
if ($e1 == false) {
$e->add(t('The field "%s" is required', $uak->getAttributeKeyName()));
} else if ($e1 instanceof ValidationErrorHelper) {
$e->add($e1);
}
}
}
if (!$e->has()) {
// do the registration
$data = $_POST;
//.........这里部分代码省略.........
示例3: finishLogin
protected function finishLogin($loginData = array())
{
$u = new User();
if ($this->post('uMaintainLogin')) {
$u->setUserForeverCookie();
}
if (count($this->locales) > 0) {
if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN') && $this->post('USER_LOCALE') != '') {
$u->setUserDefaultLanguage($this->post('USER_LOCALE'));
}
}
// Verify that the user has filled out all
// required items that are required on register
// That means users logging in after new user attributes
// have been created and required will be prompted here to
// finish their profile
$this->set('invalidRegistrationFields', false);
Loader::model('attribute/categories/user');
$ui = UserInfo::getByID($u->getUserID());
$aks = UserAttributeKey::getRegistrationList();
$unfilledAttributes = array();
foreach ($aks as $uak) {
if ($uak->isAttributeKeyRequiredOnRegister()) {
$av = $ui->getAttributeValueObject($uak);
if (!is_object($av)) {
$unfilledAttributes[] = $uak;
}
}
}
if ($this->post('completePartialProfile')) {
foreach ($unfilledAttributes as $uak) {
$e1 = $uak->validateAttributeForm();
if ($e1 == false) {
$this->error->add(t('The field "%s" is required', $uak->getAttributeKeyName()));
} else {
if ($e1 instanceof ValidationErrorHelper) {
$this->error->add($e1);
}
}
}
if (!$this->error->has()) {
// the user has needed to complete a partial profile, and they have done so,
// and they have no errors. So we save our profile data against the account.
foreach ($unfilledAttributes as $uak) {
$uak->saveAttributeForm($ui);
$unfilledAttributes = array();
}
}
}
if (count($unfilledAttributes) > 0) {
$u->logout();
$this->set('invalidRegistrationFields', true);
$this->set('unfilledAttributes', $unfilledAttributes);
}
$txt = Loader::helper('text');
$rcID = $this->post('rcID');
$nh = Loader::helper('validation/numbers');
//set redirect url
if ($nh->integer($rcID)) {
$nh = Loader::helper('navigation');
$rc = Page::getByID($rcID);
$url = $nh->getLinkToCollection($rc, true);
$loginData['redirectURL'] = $url;
} elseif (strlen($rcID)) {
$rcID = trim($rcID, '/');
$nc2 = Page::getByPath('/' . $rcID);
if (is_object($nc2) && !$nc2->isError()) {
$loginData['redirectURL'] = BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '/' . $rcID;
}
}
/*
//full page login redirect (non-ajax login)
if( strlen($loginData['redirectURL']) && $_REQUEST['format']!='JSON' ){
header('Location: ' . $loginData['redirectURL']);
exit;
}
*/
$dash = Page::getByPath("/dashboard", "RECENT");
$dbp = new Permissions($dash);
Events::fire('on_user_login', $this);
//End JSON Login
if ($_REQUEST['format'] == 'JSON') {
return $loginData;
}
//should administrator be redirected to dashboard? defaults to yes if not set.
$adminToDash = intval(Config::get('LOGIN_ADMIN_TO_DASHBOARD'));
//Full page login, standard redirection
$u = new User();
// added for the required registration attribute change above. We recalc the user and make sure they're still logged in
if ($u->isRegistered()) {
if ($u->config('NEWSFLOW_LAST_VIEWED') == 'FIRSTRUN') {
$u->saveConfig('NEWSFLOW_LAST_VIEWED', 0);
}
if ($loginData['redirectURL']) {
//make double secretly sure there's no caching going on
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Pragma: no-cache");
header('Expires: Fri, 30 Oct 1998 14:19:41 GMT');
//in the past
$this->externalRedirect($loginData['redirectURL']);
//.........这里部分代码省略.........
示例4: view
public function view()
{
$assignment = PermissionKey::getByHandle('edit_user_properties')->getMyAssignment();
$vals = Loader::helper('validation/strings');
$valt = Loader::helper('validation/token');
$valc = Loader::helper('concrete/validation');
if ($_POST['create']) {
$username = trim($_POST['uName']);
$username = preg_replace("/\\s+/", " ", $username);
$_POST['uName'] = $username;
$password = $_POST['uPassword'];
if (!$vals->email($_POST['uEmail'])) {
$this->error->add(t('Invalid email address provided.'));
} else {
if (!$valc->isUniqueEmail($_POST['uEmail'])) {
$this->error->add(t("The email address '%s' is already in use. Please choose another.", $_POST['uEmail']));
}
}
if (strlen($username) < USER_USERNAME_MINIMUM) {
$this->error->add(t('A username must be between at least %s characters long.', USER_USERNAME_MINIMUM));
}
if (strlen($username) > USER_USERNAME_MAXIMUM) {
$this->error->add(t('A username cannot be more than %s characters long.', USER_USERNAME_MAXIMUM));
}
if (strlen($username) >= USER_USERNAME_MINIMUM && !$valc->username($username)) {
if (USER_USERNAME_ALLOW_SPACES) {
$this->error->add(t('A username may only contain letters, numbers and spaces.'));
} else {
$this->error->add(t('A username may only contain letters or numbers.'));
}
}
if (!$valc->isUniqueUsername($username)) {
$this->error->add(t("The username '%s' already exists. Please choose another", $username));
}
if ($username == USER_SUPER) {
$this->error->add(t('Invalid Username'));
}
if (strlen($password) < USER_PASSWORD_MINIMUM || strlen($password) > USER_PASSWORD_MAXIMUM) {
$this->error->add(t('A password must be between %s and %s characters', USER_PASSWORD_MINIMUM, USER_PASSWORD_MAXIMUM));
}
if (strlen($password) >= USER_PASSWORD_MINIMUM && !$valc->password($password)) {
$this->error->add(t('A password may not contain ", \', >, <, or any spaces.'));
}
if (!$valt->validate('create_account')) {
$this->error->add($valt->getErrorMessage());
}
Loader::model("attribute/categories/user");
$aks = UserAttributeKey::getRegistrationList();
foreach ($aks as $uak) {
if ($uak->isAttributeKeyRequiredOnRegister()) {
$e1 = $uak->validateAttributeForm();
if ($e1 == false) {
$this->error->add(t('The field "%s" is required', $uak->getAttributeKeyName()));
} else {
if ($e1 instanceof ValidationErrorHelper) {
$this->error->add($e1->getList());
}
}
}
}
if (!$this->error->has()) {
// do the registration
$data = array('uName' => $username, 'uPassword' => $password, 'uEmail' => $_POST['uEmail'], 'uDefaultLanguage' => $_POST['uDefaultLanguage']);
$uo = UserInfo::add($data);
if (is_object($uo)) {
$av = Loader::helper('concrete/avatar');
if ($assignment->allowEditAvatar()) {
if (is_uploaded_file($_FILES['uAvatar']['tmp_name'])) {
$uHasAvatar = $av->updateUserAvatar($_FILES['uAvatar']['tmp_name'], $uo->getUserID());
}
}
foreach ($aks as $uak) {
if (in_array($uak->getAttributeKeyID(), $assignment->getAttributesAllowedArray())) {
$uak->saveAttributeForm($uo);
}
}
$gak = PermissionKey::getByHandle('assign_user_groups');
$gIDs = array();
if (is_array($_POST['gID'])) {
foreach ($_POST['gID'] as $gID) {
if ($gak->validate($gID)) {
$gIDs[] = $gID;
}
}
}
$uo->updateGroups($gIDs);
$uID = $uo->getUserID();
$this->redirect('/dashboard/users/search?uID=' . $uID . '&user_created=1');
} else {
$this->error->add(t('An error occurred while trying to create the account.'));
$this->set('error', $this->error);
}
} else {
$this->set('error', $this->error);
}
}
}