public function EntryController_Register_Create($Sender) { if (!$Sender->Request->IsPostBack()) { $Sender->CheckOverride('Register', $Sender->Target()); } $Sender->FireEvent("Register"); $Sender->Form->SetModel($Sender->UserModel); // Define gender dropdown options $Sender->GenderOptions = array('u' => T('Unspecified'), 'm' => T('Male'), 'f' => T('Female')); // Make sure that the hour offset for new users gets defined when their account is created $Sender->AddJsFile('entry.js'); $Sender->Form->AddHidden('ClientHour', date('Y-m-d H:00')); // Use the server's current hour as a default $Sender->Form->AddHidden('Target', $Sender->Target()); $Sender->SetData('NoEmail', UserModel::NoEmail()); $RegistrationMethod = 'RegisterBasic'; $Sender->View = $RegistrationMethod; $Sender->{$RegistrationMethod}($InvitationCode); }
/** * Calls the appropriate registration method based on the configuration setting. * * Events: Register * * @access public * @since 2.0.0 * * @param string $InvitationCode Unique code given to invited user. */ public function Register($InvitationCode = '') { $this->FireEvent("Register"); $this->Form->SetModel($this->UserModel); // Define gender dropdown options $this->GenderOptions = array('u' => T('Unspecified'), 'm' => T('Male'), 'f' => T('Female')); // Make sure that the hour offset for new users gets defined when their account is created $this->AddJsFile('entry.js'); $this->Form->AddHidden('ClientHour', date('Y-m-d H:00')); // Use the server's current hour as a default $this->Form->AddHidden('Target', $this->Target()); $this->SetData('NoEmail', UserModel::NoEmail()); $RegistrationMethod = $this->_RegistrationView(); $this->View = $RegistrationMethod; $this->{$RegistrationMethod}($InvitationCode); }
/** * Edit user's preferences (mostly notification settings). * * @since 2.0.0 * @access public * @param mixed $UserReference Unique identifier, possibly username or ID. * @param string $Username. * @param int $UserID Unique identifier. */ public function Preferences($UserReference = '', $Username = '', $UserID = '') { $this->AddJsFile('profile.js'); $Session = Gdn::Session(); $this->Permission('Garden.SignIn.Allow'); // Get user data $this->GetUserInfo($UserReference, $Username, $UserID, TRUE); $UserPrefs = Gdn_Format::Unserialize($this->User->Preferences); if ($this->User->UserID != $Session->UserID) { $this->Permission(array('Garden.Users.Edit', 'Moderation.Profiles.Edit'), FALSE); } if (!is_array($UserPrefs)) { $UserPrefs = array(); } $MetaPrefs = UserModel::GetMeta($this->User->UserID, 'Preferences.%', 'Preferences.'); // Define the preferences to be managed $this->Preferences = array('Notifications' => array('Email.WallComment' => T('Notify me when people write on my wall.'), 'Email.ActivityComment' => T('Notify me when people reply to my wall comments.'), 'Popup.WallComment' => T('Notify me when people write on my wall.'), 'Popup.ActivityComment' => T('Notify me when people reply to my wall comments.'))); // Allow email notification of applicants (if they have permission & are using approval registration) if (CheckPermission('Garden.Users.Approve') && C('Garden.Registration.Method') == 'Approval') { $this->Preferences['Notifications']['Email.Applicant'] = array(T('NotifyApplicant', 'Notify me when anyone applies for membership.'), 'Meta'); } $this->FireEvent('AfterPreferencesDefined'); // Loop through the preferences looking for duplicates, and merge into a single row $this->PreferenceGroups = array(); $this->PreferenceTypes = array(); foreach ($this->Preferences as $PreferenceGroup => $Preferences) { $this->PreferenceGroups[$PreferenceGroup] = array(); $this->PreferenceTypes[$PreferenceGroup] = array(); foreach ($Preferences as $Name => $Description) { $Location = 'Prefs'; if (is_array($Description)) { list($Description, $Location) = $Description; } $NameParts = explode('.', $Name); $PrefType = GetValue('0', $NameParts); $SubName = GetValue('1', $NameParts); if ($SubName != FALSE) { // Save an array of all the different types for this group if (!in_array($PrefType, $this->PreferenceTypes[$PreferenceGroup])) { $this->PreferenceTypes[$PreferenceGroup][] = $PrefType; } // Store all the different subnames for the group if (!array_key_exists($SubName, $this->PreferenceGroups[$PreferenceGroup])) { $this->PreferenceGroups[$PreferenceGroup][$SubName] = array($Name); } else { $this->PreferenceGroups[$PreferenceGroup][$SubName][] = $Name; } } else { $this->PreferenceGroups[$PreferenceGroup][$Name] = array($Name); } } } // Loop the preferences, setting defaults from the configuration. $CurrentPrefs = array(); foreach ($this->Preferences as $PrefGroup => $Prefs) { foreach ($Prefs as $Pref => $Desc) { $Location = 'Prefs'; if (is_array($Desc)) { list($Desc, $Location) = $Desc; } if ($Location == 'Meta') { $CurrentPrefs[$Pref] = GetValue($Pref, $MetaPrefs, FALSE); } else { $CurrentPrefs[$Pref] = GetValue($Pref, $UserPrefs, C('Preferences.' . $Pref, '0')); } unset($MetaPrefs[$Pref]); } } $CurrentPrefs = array_merge($CurrentPrefs, $MetaPrefs); $CurrentPrefs = array_map('intval', $CurrentPrefs); $this->SetData('Preferences', $CurrentPrefs); if (UserModel::NoEmail()) { $this->PreferenceGroups = self::_RemoveEmailPreferences($this->PreferenceGroups); $this->PreferenceTypes = self::_RemoveEmailPreferences($this->PreferenceTypes); $this->SetData('NoEmail', TRUE); } $this->SetData('PreferenceGroups', $this->PreferenceGroups); $this->SetData('PreferenceTypes', $this->PreferenceTypes); $this->SetData('PreferenceList', $this->Preferences); if ($this->Form->AuthenticatedPostBack()) { // Get, assign, and save the preferences. $NewMetaPrefs = array(); foreach ($this->Preferences as $PrefGroup => $Prefs) { foreach ($Prefs as $Pref => $Desc) { $Location = 'Prefs'; if (is_array($Desc)) { list($Desc, $Location) = $Desc; } $Value = $this->Form->GetValue($Pref, NULL); if (is_null($Value)) { continue; } if ($Location == 'Meta') { $NewMetaPrefs[$Pref] = $Value ? $Value : NULL; if ($Value) { $UserPrefs[$Pref] = $Value; } // dup for notifications code. } else { if (!$CurrentPrefs[$Pref] && !$Value) { unset($UserPrefs[$Pref]); } else { $UserPrefs[$Pref] = $Value; } } } } $this->UserModel->SavePreference($this->User->UserID, $UserPrefs); UserModel::SetMeta($this->User->UserID, $NewMetaPrefs, 'Preferences.'); $this->SetData('Preferences', array_merge($this->Data('Preferences', array()), $UserPrefs, $NewMetaPrefs)); if (count($this->Form->Errors() == 0)) { $this->InformMessage(Sprite('Check', 'InformSprite') . T('Your preferences have been saved.'), 'Dismissable AutoDismiss HasSprite'); } } else { $this->Form->SetData($CurrentPrefs); } $this->Title(T('Notification Preferences')); $this->_SetBreadcrumbs($this->Data('Title'), $this->CanonicalUrl()); $this->Render(); }
public static function SigninLabelCode() { return UserModel::NoEmail() ? 'Username' : 'Email/Username'; }
<ul> <li class="User-Name"> <?php echo $this->Form->Label('Username', 'Name'); $Attributes = array(); if (!$this->Data('_CanEditUsername')) { $Attributes['disabled'] = 'disabled'; } echo $this->Form->TextBox('Name', $Attributes); ?> </li> <li class="User-Email"> <?php echo $this->Form->Label('Email', 'Email'); if (!$this->Data('_CanEditEmail') && UserModel::NoEmail()) { echo '<div class="Gloss">', T('Email addresses are disabled.', 'Email addresses are disabled. You can only add an email address if you are an administrator.'), '</div>'; } else { $EmailAttributes = array(); if (!$this->Data('_CanEditEmail')) { $EmailAttributes['disabled'] = 'disabled'; } // Email confirmation if (!$this->Data('_EmailConfirmed')) { $EmailAttributes['class'] = 'InputBox Unconfirmed'; } echo $this->Form->TextBox('Email', $EmailAttributes); } ?> </li>
if ($this->Data('AllowEditing')) { ?> <ul> <li> <?php echo $this->Form->Label('Username', 'Name'); echo $this->Form->TextBox('Name'); ?> </li> <?php if (Gdn::Session()->CheckPermission('Garden.PersonalInfo.View')) { ?> <li> <?php echo $this->Form->Label('Email', 'Email'); if (UserModel::NoEmail()) { echo '<div class="Gloss">', T('Email addresses are disabled.', 'Email addresses are disabled. You can only add an email address if you are an administrator.'), '</div>'; } $EmailAttributes = array(); // Email confirmation if (!$this->Data('_EmailConfirmed')) { $EmailAttributes['class'] = 'InputBox Unconfirmed'; } echo $this->Form->TextBox('Email', $EmailAttributes); ?> </li> <?php if ($this->Data('_CanConfirmEmail')) { ?> <li class="User-ConfirmEmail"> <?php