echo $this->Form->label('Username', 'Name'); $Attributes = array(); if (!$this->data('_CanEditUsername')) { $Attributes['disabled'] = 'disabled'; } echo $this->Form->textBox('Name', $Attributes); ?> </li> <?php if ($this->data('_CanViewPersonalInfo')) { ?> <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> <?php
/** * * * @return string */ public static function signinLabelCode() { return UserModel::noEmail() ? 'Username' : 'Email/Username'; }
> <th><?php echo $Role['Name']; ?> </th> <td class="Alt"> <?php echo $this->Form->DropDown('InvitationCount[]', $this->InvitationOptions, array('value' => $CurrentValue)); echo $this->Form->Hidden('InvitationRoleID[]', array('value' => $Role['RoleID'])); ?> </td> </tr> <?php } ?> </tbody> </table> </li> <li> <div class="Info"> <?php if (UserModel::noEmail()) { echo '<div class="Warning">', t('Email addresses are disabled.', 'Email addresses are disabled. You can only add an email address if you are an administrator.'), '</div>'; } echo $this->Form->checkBox('Garden.Registration.ConfirmEmail', '@' . t('Confirm email addresses', 'Require users to confirm their email addresses (recommended)')); ?> </div> </li> </ul> <?php echo $this->Form->close('Save');
/** * 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 = '') { if (!$this->Request->isPostBack()) { $this->checkOverride('Register', $this->target()); } $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->setData('Method', stringBeginsWith($RegistrationMethod, 'Register', false, true)); $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 $Notifications = array(); if (c('Garden.Profile.ShowActivities', true)) { $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.')); } $this->Preferences = array('Notifications' => $Notifications); // 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 = val('0', $NameParts); $SubName = val('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] = val($Pref, $MetaPrefs, false); } else { $CurrentPrefs[$Pref] = val($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]); // save some space } 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(); }