@@ -52,12 +52,12 @@ discard block |
||
| 52 | 52 | private $overridePasswordCheck = false; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - private function canOverridePasswordCheck() |
|
| 55 | + private function canOverridePasswordCheck () |
|
| 56 | 56 | { |
| 57 | 57 | if ($this->overridePasswordCheck) |
| 58 | 58 | return true; |
| 59 | 59 | |
| 60 | - if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id) |
|
| 60 | + if (isset(Yii::app ()->user) && $this->getId () == Yii::app ()->user->id) |
|
| 61 | 61 | return true; |
| 62 | 62 | |
| 63 | 63 | return false; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * Overload of the __getter method to retrieve the user's ID |
| 68 | 68 | * @var int $id |
| 69 | 69 | */ |
| 70 | - public function getId() |
|
| 70 | + public function getId () |
|
| 71 | 71 | { |
| 72 | 72 | return $this->_user->id; |
| 73 | 73 | } |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * Retrieves the new email address if it is set |
| 77 | 77 | * @return mixed |
| 78 | 78 | */ |
| 79 | - public function getNewEmail() |
|
| 79 | + public function getNewEmail () |
|
| 80 | 80 | { |
| 81 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 81 | + $metadata = UserMetadata::model ()->findByAttributes (array( |
|
| 82 | 82 | 'user_id' => $this->_user->id, |
| 83 | 83 | 'key' => 'newEmailAddress' |
| 84 | 84 | )); |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | * Sets the new email address |
| 94 | 94 | * @return boolean |
| 95 | 95 | */ |
| 96 | - public function setNewEmail() |
|
| 96 | + public function setNewEmail () |
|
| 97 | 97 | { |
| 98 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 98 | + $metadata = UserMetadata::model ()->findByAttributes (array( |
|
| 99 | 99 | 'user_id' => $this->_user->id, |
| 100 | 100 | 'key' => 'newEmailAddress' |
| 101 | 101 | )); |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | $metadata->value = $this->email; |
| 113 | 113 | |
| 114 | 114 | // Save the record |
| 115 | - return $metadata->save(); |
|
| 115 | + return $metadata->save (); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * Retrieves the new email address if it is set |
| 120 | 120 | * @return mixed |
| 121 | 121 | */ |
| 122 | - public function getNewEmailChangeKey() |
|
| 122 | + public function getNewEmailChangeKey () |
|
| 123 | 123 | { |
| 124 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 124 | + $metadata = UserMetadata::model ()->findByAttributes (array( |
|
| 125 | 125 | 'user_id' => $this->_user->id, |
| 126 | 126 | 'key' => 'newEmailAddressChangeKey' |
| 127 | 127 | )); |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | * Generates a new change key |
| 137 | 137 | * @return boolean |
| 138 | 138 | */ |
| 139 | - public function setNewEmailChangeKey() |
|
| 139 | + public function setNewEmailChangeKey () |
|
| 140 | 140 | { |
| 141 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 141 | + $metadata = UserMetadata::model ()->findByAttributes (array( |
|
| 142 | 142 | 'user_id' => $this->_user->id, |
| 143 | 143 | 'key' => 'newEmailAddressChangeKey' |
| 144 | 144 | )); |
@@ -153,20 +153,20 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Generate a new key |
| 156 | - $metadata->value = Cii::generateSafeHash(); |
|
| 156 | + $metadata->value = Cii::generateSafeHash (); |
|
| 157 | 157 | |
| 158 | 158 | // Save the record |
| 159 | - if ($metadata->save()) |
|
| 159 | + if ($metadata->save ()) |
|
| 160 | 160 | return $metadata->value; |
| 161 | 161 | |
| 162 | - throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key')); |
|
| 162 | + throw new CHttpException (500, Yii::t ('ciims.ProfileForm', 'Unable to save change key')); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * Validation rules |
| 167 | 167 | * @return array |
| 168 | 168 | */ |
| 169 | - public function rules() |
|
| 169 | + public function rules () |
|
| 170 | 170 | { |
| 171 | 171 | return array( |
| 172 | 172 | array('email, username', 'required'), |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | * Retrieves the attributes labels from the Users model and returns them to reduce code redundancy |
| 184 | 184 | * @return array |
| 185 | 185 | */ |
| 186 | - public function attributeLabels() |
|
| 186 | + public function attributeLabels () |
|
| 187 | 187 | { |
| 188 | - return CMap::mergeArray(Users::model()->attributeLabels(), array( |
|
| 189 | - 'currentPassword' => Yii::t('ciims.models.ProfileForm', 'Your current password'), |
|
| 190 | - 'password_repeat' => Yii::t('ciims.models.ProfileForm', 'Your New Password (again)') |
|
| 188 | + return CMap::mergeArray (Users::model ()->attributeLabels (), array( |
|
| 189 | + 'currentPassword' => Yii::t ('ciims.models.ProfileForm', 'Your current password'), |
|
| 190 | + 'password_repeat' => Yii::t ('ciims.models.ProfileForm', 'Your New Password (again)') |
|
| 191 | 191 | )); |
| 192 | 192 | } |
| 193 | 193 | |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | * @param array $params |
| 198 | 198 | * return array |
| 199 | 199 | */ |
| 200 | - public function validateUserRole($attributes, $params) |
|
| 200 | + public function validateUserRole ($attributes, $params) |
|
| 201 | 201 | { |
| 202 | - if ($this->canOverridePasswordCheck()) |
|
| 202 | + if ($this->canOverridePasswordCheck ()) |
|
| 203 | 203 | return true; |
| 204 | 204 | |
| 205 | - $this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute')); |
|
| 205 | + $this->addError ('user_role', Yii::t ('ciims.models.ProfileForm', 'You do not have permission to modify this attribute')); |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -212,20 +212,20 @@ discard block |
||
| 212 | 212 | * @param array $params |
| 213 | 213 | * return array |
| 214 | 214 | */ |
| 215 | - public function validateUserPassword($attributes, $params) |
|
| 215 | + public function validateUserPassword ($attributes, $params) |
|
| 216 | 216 | { |
| 217 | 217 | // Apply the override if it was set |
| 218 | - if ($this->canOverridePasswordCheck()) |
|
| 218 | + if ($this->canOverridePasswordCheck ()) |
|
| 219 | 219 | { |
| 220 | 220 | $this->password_repeat = $this->password; |
| 221 | 221 | return true; |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | - $result = password_verify($this->password, $this->_user->password); |
|
| 224 | + $result = password_verify ($this->password, $this->_user->password); |
|
| 225 | 225 | |
| 226 | 226 | if ($result == false) |
| 227 | 227 | { |
| 228 | - $this->addError('currentPassword', Yii::t('ciims.models.ProfileForm', 'The password you entered is invalid.')); |
|
| 228 | + $this->addError ('currentPassword', Yii::t ('ciims.models.ProfileForm', 'The password you entered is invalid.')); |
|
| 229 | 229 | return false; |
| 230 | 230 | } |
| 231 | 231 | |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | * @param bool $override This form may be reused |
| 239 | 239 | * @return ProfileForm |
| 240 | 240 | */ |
| 241 | - public function load($id, $override = false) |
|
| 241 | + public function load ($id, $override = false) |
|
| 242 | 242 | { |
| 243 | 243 | $this->overridePasswordCheck = $override; |
| 244 | 244 | |
| 245 | 245 | // Load the user |
| 246 | - $this->_user = Users::model()->findByPk($id); |
|
| 246 | + $this->_user = Users::model ()->findByPk ($id); |
|
| 247 | 247 | |
| 248 | 248 | if ($this->_user == NULL) |
| 249 | - throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded')); |
|
| 249 | + throw new CHttpException (400, Yii::t ('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded')); |
|
| 250 | 250 | |
| 251 | 251 | // Reload the attribute labels |
| 252 | 252 | $this->attributes = array( |
@@ -262,13 +262,13 @@ discard block |
||
| 262 | 262 | * Updates the user's profile information |
| 263 | 263 | * @return boolean |
| 264 | 264 | */ |
| 265 | - public function save() |
|
| 265 | + public function save () |
|
| 266 | 266 | { |
| 267 | - if (!$this->validate(NULL, false)) |
|
| 267 | + if (!$this->validate (NULL, false)) |
|
| 268 | 268 | return false; |
| 269 | 269 | |
| 270 | 270 | // Change the email address, if necessary |
| 271 | - $this->changeEmail(); |
|
| 271 | + $this->changeEmail (); |
|
| 272 | 272 | |
| 273 | 273 | $this->_user->attributes = array( |
| 274 | 274 | 'password' => $this->password, |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | 'user_role' => $this->user_role |
| 277 | 277 | ); |
| 278 | 278 | |
| 279 | - if ($this->_user->save()) |
|
| 279 | + if ($this->_user->save ()) |
|
| 280 | 280 | return true; |
| 281 | 281 | |
| 282 | 282 | return false; |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | * Changes the user's email address if necessary |
| 287 | 287 | * @return boolean |
| 288 | 288 | */ |
| 289 | - private function changeEmail() |
|
| 289 | + private function changeEmail () |
|
| 290 | 290 | { |
| 291 | 291 | if ($this->email != $this->_user->email) |
| 292 | 292 | { |
| 293 | - $this->setNewemail(); |
|
| 294 | - $this->setNewEmailChangeKey(); |
|
| 295 | - $this->sendVerificationEmail(); |
|
| 293 | + $this->setNewemail (); |
|
| 294 | + $this->setNewEmailChangeKey (); |
|
| 295 | + $this->sendVerificationEmail (); |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | return true; |
@@ -302,15 +302,15 @@ discard block |
||
| 302 | 302 | * Sends the verification email to the user. This is broken to it's own method to allow for the resending email to be resent |
| 303 | 303 | * @return boolean |
| 304 | 304 | */ |
| 305 | - public function sendVerificationEmail() |
|
| 305 | + public function sendVerificationEmail () |
|
| 306 | 306 | { |
| 307 | 307 | $emailSettings = new EmailSettings; |
| 308 | - return $emailSettings->send( |
|
| 308 | + return $emailSettings->send ( |
|
| 309 | 309 | $this->_user, |
| 310 | - Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'), |
|
| 311 | - 'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.email-change', |
|
| 310 | + Yii::t ('ciims.models.Users', 'CiiMS Email Change Notification'), |
|
| 311 | + 'base.themes.'.Cii::getConfig ('theme', 'default').'.views.email.email-change', |
|
| 312 | 312 | array( |
| 313 | - 'key' => $this->setNewEmailChangeKey(), |
|
| 313 | + 'key' => $this->setNewEmailChangeKey (), |
|
| 314 | 314 | 'user' => $this->_user |
| 315 | 315 | ) |
| 316 | 316 | ); |