@@ -2,105 +2,105 @@ |
||
| 2 | 2 | |
| 3 | 3 | class InvitationForm extends CFormModel |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * The email of the user to invite |
|
| 7 | - * @var string $email |
|
| 8 | - */ |
|
| 9 | - public $email; |
|
| 5 | + /** |
|
| 6 | + * The email of the user to invite |
|
| 7 | + * @var string $email |
|
| 8 | + */ |
|
| 9 | + public $email; |
|
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Validation rules |
|
| 13 | - * @return array |
|
| 14 | - */ |
|
| 15 | - public function rules() |
|
| 16 | - { |
|
| 17 | - return array( |
|
| 18 | - array('email', 'required'), |
|
| 19 | - array('email', 'email'), |
|
| 20 | - array('email', 'userExists') |
|
| 21 | - ); |
|
| 22 | - } |
|
| 11 | + /** |
|
| 12 | + * Validation rules |
|
| 13 | + * @return array |
|
| 14 | + */ |
|
| 15 | + public function rules() |
|
| 16 | + { |
|
| 17 | + return array( |
|
| 18 | + array('email', 'required'), |
|
| 19 | + array('email', 'email'), |
|
| 20 | + array('email', 'userExists') |
|
| 21 | + ); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Validates that a user with that email address isn't already invited |
|
| 26 | - * @param array $attributes |
|
| 27 | - * @param array $params |
|
| 28 | - * @return boolean |
|
| 29 | - */ |
|
| 30 | - public function userExists($attributes, $params) |
|
| 31 | - { |
|
| 32 | - $user = Users::model()->findByAttributes(array('email' => $this->email)); |
|
| 24 | + /** |
|
| 25 | + * Validates that a user with that email address isn't already invited |
|
| 26 | + * @param array $attributes |
|
| 27 | + * @param array $params |
|
| 28 | + * @return boolean |
|
| 29 | + */ |
|
| 30 | + public function userExists($attributes, $params) |
|
| 31 | + { |
|
| 32 | + $user = Users::model()->findByAttributes(array('email' => $this->email)); |
|
| 33 | 33 | |
| 34 | - if ($user == NULL) |
|
| 35 | - return true; |
|
| 34 | + if ($user == NULL) |
|
| 35 | + return true; |
|
| 36 | 36 | |
| 37 | - $this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.')); |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 37 | + $this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.')); |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * Attribute labels |
|
| 43 | - * @return array |
|
| 44 | - */ |
|
| 45 | - public function attributeLabels() |
|
| 46 | - { |
|
| 47 | - return array( |
|
| 48 | - 'email' => Yii::t('ciims.models.InvitationForm', 'Email Address') |
|
| 49 | - ); |
|
| 50 | - } |
|
| 41 | + /** |
|
| 42 | + * Attribute labels |
|
| 43 | + * @return array |
|
| 44 | + */ |
|
| 45 | + public function attributeLabels() |
|
| 46 | + { |
|
| 47 | + return array( |
|
| 48 | + 'email' => Yii::t('ciims.models.InvitationForm', 'Email Address') |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Sends an invite to a new user |
|
| 54 | - * @return boolean |
|
| 55 | - */ |
|
| 56 | - public function invite() |
|
| 57 | - { |
|
| 58 | - if (!$this->validate()) |
|
| 59 | - return false; |
|
| 52 | + /** |
|
| 53 | + * Sends an invite to a new user |
|
| 54 | + * @return boolean |
|
| 55 | + */ |
|
| 56 | + public function invite() |
|
| 57 | + { |
|
| 58 | + if (!$this->validate()) |
|
| 59 | + return false; |
|
| 60 | 60 | |
| 61 | - $user = new Users; |
|
| 62 | - $user->attributes = array( |
|
| 63 | - 'email' => $this->email, |
|
| 64 | - 'firstName' => null, |
|
| 65 | - 'lastName' => null, |
|
| 66 | - 'displayName' => null, |
|
| 67 | - 'password' => null, |
|
| 68 | - 'user_role' => 5, |
|
| 69 | - 'status' => Users::PENDING_INVITATION |
|
| 70 | - ); |
|
| 61 | + $user = new Users; |
|
| 62 | + $user->attributes = array( |
|
| 63 | + 'email' => $this->email, |
|
| 64 | + 'firstName' => null, |
|
| 65 | + 'lastName' => null, |
|
| 66 | + 'displayName' => null, |
|
| 67 | + 'password' => null, |
|
| 68 | + 'user_role' => 5, |
|
| 69 | + 'status' => Users::PENDING_INVITATION |
|
| 70 | + ); |
|
| 71 | 71 | |
| 72 | - // Create a new user, but bypass validation |
|
| 73 | - if ($user->save(false)) |
|
| 74 | - { |
|
| 75 | - $meta = new UserMetadata; |
|
| 76 | - $meta->attributes = array( |
|
| 77 | - 'user_id' => $user->id, |
|
| 78 | - 'key' => 'invitationKey', |
|
| 79 | - 'value' => Cii::generateSafeHash() |
|
| 80 | - ); |
|
| 72 | + // Create a new user, but bypass validation |
|
| 73 | + if ($user->save(false)) |
|
| 74 | + { |
|
| 75 | + $meta = new UserMetadata; |
|
| 76 | + $meta->attributes = array( |
|
| 77 | + 'user_id' => $user->id, |
|
| 78 | + 'key' => 'invitationKey', |
|
| 79 | + 'value' => Cii::generateSafeHash() |
|
| 80 | + ); |
|
| 81 | 81 | |
| 82 | - // If the key was savedm send the email out |
|
| 83 | - if ($meta->save()) |
|
| 84 | - { |
|
| 85 | - $emailSettings = new EmailSettings; |
|
| 86 | - $emailSettings->send( |
|
| 87 | - $user, |
|
| 88 | - Yii::t('ciims.models.InvitationForm', "You've Been Invited..."), |
|
| 89 | - 'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.invite', |
|
| 90 | - array( |
|
| 91 | - 'user' => $user, |
|
| 92 | - 'hash' => $meta->value |
|
| 93 | - ), |
|
| 94 | - true, |
|
| 95 | - true |
|
| 96 | - ); |
|
| 82 | + // If the key was savedm send the email out |
|
| 83 | + if ($meta->save()) |
|
| 84 | + { |
|
| 85 | + $emailSettings = new EmailSettings; |
|
| 86 | + $emailSettings->send( |
|
| 87 | + $user, |
|
| 88 | + Yii::t('ciims.models.InvitationForm', "You've Been Invited..."), |
|
| 89 | + 'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.invite', |
|
| 90 | + array( |
|
| 91 | + 'user' => $user, |
|
| 92 | + 'hash' => $meta->value |
|
| 93 | + ), |
|
| 94 | + true, |
|
| 95 | + true |
|
| 96 | + ); |
|
| 97 | 97 | |
| 98 | - return true; |
|
| 99 | - } |
|
| 98 | + return true; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - $user->delete(); |
|
| 102 | - } |
|
| 101 | + $user->delete(); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - return false; |
|
| 105 | - } |
|
| 104 | + return false; |
|
| 105 | + } |
|
| 106 | 106 | } |
| 107 | 107 | \ No newline at end of file |
@@ -31,8 +31,9 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | $user = Users::model()->findByAttributes(array('email' => $this->email)); |
| 33 | 33 | |
| 34 | - if ($user == NULL) |
|
| 35 | - return true; |
|
| 34 | + if ($user == NULL) { |
|
| 35 | + return true; |
|
| 36 | + } |
|
| 36 | 37 | |
| 37 | 38 | $this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.')); |
| 38 | 39 | return false; |
@@ -55,8 +56,9 @@ discard block |
||
| 55 | 56 | */ |
| 56 | 57 | public function invite() |
| 57 | 58 | { |
| 58 | - if (!$this->validate()) |
|
| 59 | - return false; |
|
| 59 | + if (!$this->validate()) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | $user = new Users; |
| 62 | 64 | $user->attributes = array( |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * Validation rules |
| 13 | 13 | * @return array |
| 14 | 14 | */ |
| 15 | - public function rules() |
|
| 15 | + public function rules () |
|
| 16 | 16 | { |
| 17 | 17 | return array( |
| 18 | 18 | array('email', 'required'), |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | * @param array $params |
| 28 | 28 | * @return boolean |
| 29 | 29 | */ |
| 30 | - public function userExists($attributes, $params) |
|
| 30 | + public function userExists ($attributes, $params) |
|
| 31 | 31 | { |
| 32 | - $user = Users::model()->findByAttributes(array('email' => $this->email)); |
|
| 32 | + $user = Users::model ()->findByAttributes (array('email' => $this->email)); |
|
| 33 | 33 | |
| 34 | 34 | if ($user == NULL) |
| 35 | 35 | return true; |
| 36 | 36 | |
| 37 | - $this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.')); |
|
| 37 | + $this->addError ('email', Yii::t ('ciims.models.InvitationForm', 'A user with that email already exists.')); |
|
| 38 | 38 | return false; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * Attribute labels |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function attributeLabels() |
|
| 45 | + public function attributeLabels () |
|
| 46 | 46 | { |
| 47 | 47 | return array( |
| 48 | - 'email' => Yii::t('ciims.models.InvitationForm', 'Email Address') |
|
| 48 | + 'email' => Yii::t ('ciims.models.InvitationForm', 'Email Address') |
|
| 49 | 49 | ); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * Sends an invite to a new user |
| 54 | 54 | * @return boolean |
| 55 | 55 | */ |
| 56 | - public function invite() |
|
| 56 | + public function invite () |
|
| 57 | 57 | { |
| 58 | - if (!$this->validate()) |
|
| 58 | + if (!$this->validate ()) |
|
| 59 | 59 | return false; |
| 60 | 60 | |
| 61 | 61 | $user = new Users; |
@@ -70,23 +70,23 @@ discard block |
||
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | // Create a new user, but bypass validation |
| 73 | - if ($user->save(false)) |
|
| 73 | + if ($user->save (false)) |
|
| 74 | 74 | { |
| 75 | 75 | $meta = new UserMetadata; |
| 76 | 76 | $meta->attributes = array( |
| 77 | 77 | 'user_id' => $user->id, |
| 78 | 78 | 'key' => 'invitationKey', |
| 79 | - 'value' => Cii::generateSafeHash() |
|
| 79 | + 'value' => Cii::generateSafeHash () |
|
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | 82 | // If the key was savedm send the email out |
| 83 | - if ($meta->save()) |
|
| 83 | + if ($meta->save ()) |
|
| 84 | 84 | { |
| 85 | 85 | $emailSettings = new EmailSettings; |
| 86 | - $emailSettings->send( |
|
| 86 | + $emailSettings->send ( |
|
| 87 | 87 | $user, |
| 88 | - Yii::t('ciims.models.InvitationForm', "You've Been Invited..."), |
|
| 89 | - 'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.invite', |
|
| 88 | + Yii::t ('ciims.models.InvitationForm', "You've Been Invited..."), |
|
| 89 | + 'webroot.themes.'.Cii::getConfig ('theme', 'default').'.views.email.invite', |
|
| 90 | 90 | array( |
| 91 | 91 | 'user' => $user, |
| 92 | 92 | 'hash' => $meta->value |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | return true; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $user->delete(); |
|
| 101 | + $user->delete (); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | return false; |
@@ -2,75 +2,75 @@ |
||
| 2 | 2 | |
| 3 | 3 | class InviteForm extends CFormModel |
| 4 | 4 | {
|
| 5 | - /** |
|
| 6 | - * @var $id int The User's ID that we are working with |
|
| 7 | - */ |
|
| 8 | - public $id = NULL; |
|
| 5 | + /** |
|
| 6 | + * @var $id int The User's ID that we are working with |
|
| 7 | + */ |
|
| 8 | + public $id = NULL; |
|
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @var $displayName string The user's requested display name |
|
| 12 | - */ |
|
| 13 | - public $username = NULL; |
|
| 10 | + /** |
|
| 11 | + * @var $displayName string The user's requested display name |
|
| 12 | + */ |
|
| 13 | + public $username = NULL; |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @var $email string |
|
| 17 | - */ |
|
| 18 | - public $email = NULL; |
|
| 15 | + /** |
|
| 16 | + * @var $email string |
|
| 17 | + */ |
|
| 18 | + public $email = NULL; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var $password string The user's selected password |
|
| 22 | - */ |
|
| 23 | - public $password = NULL; |
|
| 20 | + /** |
|
| 21 | + * @var $password string The user's selected password |
|
| 22 | + */ |
|
| 23 | + public $password = NULL; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Validation Rules |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function rules() |
|
| 30 | - {
|
|
| 31 | - return array( |
|
| 32 | - array('id, username, password', 'required'),
|
|
| 33 | - array('username, password', 'length', 'max' => 255)
|
|
| 34 | - ); |
|
| 35 | - } |
|
| 25 | + /** |
|
| 26 | + * Validation Rules |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function rules() |
|
| 30 | + {
|
|
| 31 | + return array( |
|
| 32 | + array('id, username, password', 'required'),
|
|
| 33 | + array('username, password', 'length', 'max' => 255)
|
|
| 34 | + ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Attribute labels |
|
| 39 | - * @return array |
|
| 40 | - */ |
|
| 41 | - public function attributeLabels() |
|
| 42 | - {
|
|
| 43 | - return array( |
|
| 44 | - 'id' => Yii::t('ciims.models.InviteForm', 'ID'),
|
|
| 45 | - 'username' => Yii::t('ciims.models.InviteForm', 'Username'),
|
|
| 46 | - 'password' => Yii::t('ciims.models.InviteForm', 'Password'),
|
|
| 47 | - ); |
|
| 48 | - } |
|
| 37 | + /** |
|
| 38 | + * Attribute labels |
|
| 39 | + * @return array |
|
| 40 | + */ |
|
| 41 | + public function attributeLabels() |
|
| 42 | + {
|
|
| 43 | + return array( |
|
| 44 | + 'id' => Yii::t('ciims.models.InviteForm', 'ID'),
|
|
| 45 | + 'username' => Yii::t('ciims.models.InviteForm', 'Username'),
|
|
| 46 | + 'password' => Yii::t('ciims.models.InviteForm', 'Password'),
|
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Actually creates the users |
|
| 52 | - * @return bool If the user was created |
|
| 53 | - */ |
|
| 54 | - public function acceptInvite() |
|
| 55 | - {
|
|
| 56 | - if (!$this->validate()) |
|
| 57 | - return false; |
|
| 50 | + /** |
|
| 51 | + * Actually creates the users |
|
| 52 | + * @return bool If the user was created |
|
| 53 | + */ |
|
| 54 | + public function acceptInvite() |
|
| 55 | + {
|
|
| 56 | + if (!$this->validate()) |
|
| 57 | + return false; |
|
| 58 | 58 | |
| 59 | - $user = Users::model()->findByPk($this->id); |
|
| 59 | + $user = Users::model()->findByPk($this->id); |
|
| 60 | 60 | |
| 61 | - // Bcrypt the initial password instead of just using the basic hashing mechanism |
|
| 62 | - $hash = Users::model()->encryptHash($this->email, $this->password, Yii::app()->params['encryptionKey']); |
|
| 63 | - $cost = Cii::getBcryptCost(); |
|
| 61 | + // Bcrypt the initial password instead of just using the basic hashing mechanism |
|
| 62 | + $hash = Users::model()->encryptHash($this->email, $this->password, Yii::app()->params['encryptionKey']); |
|
| 63 | + $cost = Cii::getBcryptCost(); |
|
| 64 | 64 | |
| 65 | - $this->password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
|
|
| 65 | + $this->password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
|
|
| 66 | 66 | |
| 67 | - $user->attributes = array( |
|
| 68 | - 'email' => $this->email, |
|
| 69 | - 'password' => $this->password, |
|
| 70 | - 'username' => $this->username, |
|
| 71 | - 'status' => Users::ACTIVE |
|
| 72 | - ); |
|
| 67 | + $user->attributes = array( |
|
| 68 | + 'email' => $this->email, |
|
| 69 | + 'password' => $this->password, |
|
| 70 | + 'username' => $this->username, |
|
| 71 | + 'status' => Users::ACTIVE |
|
| 72 | + ); |
|
| 73 | 73 | |
| 74 | - return $user->save(); |
|
| 75 | - } |
|
| 74 | + return $user->save(); |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | \ No newline at end of file |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * Validation Rules |
| 27 | 27 | * @return array |
| 28 | 28 | */ |
| 29 | - public function rules() |
|
| 29 | + public function rules () |
|
| 30 | 30 | {
|
| 31 | 31 | return array( |
| 32 | 32 | array('id, username, password', 'required'),
|
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | * Attribute labels |
| 39 | 39 | * @return array |
| 40 | 40 | */ |
| 41 | - public function attributeLabels() |
|
| 41 | + public function attributeLabels () |
|
| 42 | 42 | {
|
| 43 | 43 | return array( |
| 44 | - 'id' => Yii::t('ciims.models.InviteForm', 'ID'),
|
|
| 45 | - 'username' => Yii::t('ciims.models.InviteForm', 'Username'),
|
|
| 46 | - 'password' => Yii::t('ciims.models.InviteForm', 'Password'),
|
|
| 44 | + 'id' => Yii::t ('ciims.models.InviteForm', 'ID'),
|
|
| 45 | + 'username' => Yii::t ('ciims.models.InviteForm', 'Username'),
|
|
| 46 | + 'password' => Yii::t ('ciims.models.InviteForm', 'Password'),
|
|
| 47 | 47 | ); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -51,18 +51,18 @@ discard block |
||
| 51 | 51 | * Actually creates the users |
| 52 | 52 | * @return bool If the user was created |
| 53 | 53 | */ |
| 54 | - public function acceptInvite() |
|
| 54 | + public function acceptInvite () |
|
| 55 | 55 | {
|
| 56 | - if (!$this->validate()) |
|
| 56 | + if (!$this->validate ()) |
|
| 57 | 57 | return false; |
| 58 | 58 | |
| 59 | - $user = Users::model()->findByPk($this->id); |
|
| 59 | + $user = Users::model ()->findByPk ($this->id); |
|
| 60 | 60 | |
| 61 | 61 | // Bcrypt the initial password instead of just using the basic hashing mechanism |
| 62 | - $hash = Users::model()->encryptHash($this->email, $this->password, Yii::app()->params['encryptionKey']); |
|
| 63 | - $cost = Cii::getBcryptCost(); |
|
| 62 | + $hash = Users::model ()->encryptHash ($this->email, $this->password, Yii::app ()->params['encryptionKey']); |
|
| 63 | + $cost = Cii::getBcryptCost (); |
|
| 64 | 64 | |
| 65 | - $this->password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
|
|
| 65 | + $this->password = password_hash ($hash, PASSWORD_BCRYPT, array('cost' => $cost));
|
|
| 66 | 66 | |
| 67 | 67 | $user->attributes = array( |
| 68 | 68 | 'email' => $this->email, |
@@ -71,6 +71,6 @@ discard block |
||
| 71 | 71 | 'status' => Users::ACTIVE |
| 72 | 72 | ); |
| 73 | 73 | |
| 74 | - return $user->save(); |
|
| 74 | + return $user->save (); |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class InviteForm extends CFormModel |
|
| 4 | -{
|
|
| 3 | +class InviteForm extends CFormModel |
|
| 4 | +{ |
|
| 5 | 5 | /** |
| 6 | 6 | * @var $id int The User's ID that we are working with |
| 7 | 7 | */ |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * Validation Rules |
| 27 | 27 | * @return array |
| 28 | 28 | */ |
| 29 | - public function rules() |
|
| 30 | - {
|
|
| 29 | + public function rules() |
|
| 30 | + { |
|
| 31 | 31 | return array( |
| 32 | 32 | array('id, username, password', 'required'),
|
| 33 | 33 | array('username, password', 'length', 'max' => 255)
|
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | * Attribute labels |
| 39 | 39 | * @return array |
| 40 | 40 | */ |
| 41 | - public function attributeLabels() |
|
| 42 | - {
|
|
| 41 | + public function attributeLabels() |
|
| 42 | + { |
|
| 43 | 43 | return array( |
| 44 | 44 | 'id' => Yii::t('ciims.models.InviteForm', 'ID'),
|
| 45 | 45 | 'username' => Yii::t('ciims.models.InviteForm', 'Username'),
|
@@ -51,10 +51,11 @@ discard block |
||
| 51 | 51 | * Actually creates the users |
| 52 | 52 | * @return bool If the user was created |
| 53 | 53 | */ |
| 54 | - public function acceptInvite() |
|
| 55 | - {
|
|
| 56 | - if (!$this->validate()) |
|
| 57 | - return false; |
|
| 54 | + public function acceptInvite() |
|
| 55 | + { |
|
| 56 | + if (!$this->validate()) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 58 | 59 | |
| 59 | 60 | $user = Users::model()->findByPk($this->id); |
| 60 | 61 | |
@@ -8,169 +8,169 @@ |
||
| 8 | 8 | Yii::import('cii.components.CiiUserIdentity'); |
| 9 | 9 | class LoginForm extends CFormModel |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The submitted username(email) |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - public $username; |
|
| 11 | + /** |
|
| 12 | + * The submitted username(email) |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + public $username; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * The submitted password |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $password; |
|
| 17 | + /** |
|
| 18 | + * The submitted password |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $password; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Two factor authentication code |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - public $twoFactorCode = false; |
|
| 23 | + /** |
|
| 24 | + * Two factor authentication code |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + public $twoFactorCode = false; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Whether or not we should remember the user. |
|
| 31 | - * This isn't uses as of CiiMS 1.1 |
|
| 32 | - * @var boolean ? |
|
| 33 | - */ |
|
| 34 | - public $rememberMe = true; |
|
| 29 | + /** |
|
| 30 | + * Whether or not we should remember the user. |
|
| 31 | + * This isn't uses as of CiiMS 1.1 |
|
| 32 | + * @var boolean ? |
|
| 33 | + */ |
|
| 34 | + public $rememberMe = true; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Whether or not we should perform a forced authentication. By default we aren't going to do this |
|
| 38 | - * @var boolean |
|
| 39 | - */ |
|
| 40 | - private $force = false; |
|
| 36 | + /** |
|
| 37 | + * Whether or not we should perform a forced authentication. By default we aren't going to do this |
|
| 38 | + * @var boolean |
|
| 39 | + */ |
|
| 40 | + private $force = false; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The identity of the user |
|
| 44 | - * @var CiiUserIdentity |
|
| 45 | - */ |
|
| 46 | - private $_identity = NULL; |
|
| 42 | + /** |
|
| 43 | + * The identity of the user |
|
| 44 | + * @var CiiUserIdentity |
|
| 45 | + */ |
|
| 46 | + private $_identity = NULL; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * The Application Name for API requests |
|
| 50 | - * @var $app_name |
|
| 51 | - */ |
|
| 52 | - public $app_name = NULL; |
|
| 48 | + /** |
|
| 49 | + * The Application Name for API requests |
|
| 50 | + * @var $app_name |
|
| 51 | + */ |
|
| 52 | + public $app_name = NULL; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Determines whether or not we should do a forced authentication and bypass the user's actual password |
|
| 56 | - * @see application.modules.HybridAuth for more details |
|
| 57 | - * @param boolean $force |
|
| 58 | - */ |
|
| 59 | - public function __construct($force=false) |
|
| 60 | - { |
|
| 61 | - $this->force = $force; |
|
| 62 | - } |
|
| 54 | + /** |
|
| 55 | + * Determines whether or not we should do a forced authentication and bypass the user's actual password |
|
| 56 | + * @see application.modules.HybridAuth for more details |
|
| 57 | + * @param boolean $force |
|
| 58 | + */ |
|
| 59 | + public function __construct($force=false) |
|
| 60 | + { |
|
| 61 | + $this->force = $force; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Declares the validation rules. |
|
| 66 | - * The rules state that username and password are required, |
|
| 67 | - * and password needs to be authenticated. |
|
| 68 | - */ |
|
| 69 | - public function rules() |
|
| 70 | - { |
|
| 71 | - return array( |
|
| 72 | - array('username, password', 'required'), |
|
| 73 | - array('username', 'email'), |
|
| 74 | - array('password', 'authenticate'), |
|
| 75 | - array('twoFactorCode', 'hasTwoFactorCode') |
|
| 76 | - ); |
|
| 77 | - } |
|
| 64 | + /** |
|
| 65 | + * Declares the validation rules. |
|
| 66 | + * The rules state that username and password are required, |
|
| 67 | + * and password needs to be authenticated. |
|
| 68 | + */ |
|
| 69 | + public function rules() |
|
| 70 | + { |
|
| 71 | + return array( |
|
| 72 | + array('username, password', 'required'), |
|
| 73 | + array('username', 'email'), |
|
| 74 | + array('password', 'authenticate'), |
|
| 75 | + array('twoFactorCode', 'hasTwoFactorCode') |
|
| 76 | + ); |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Yii attribute labels |
|
| 81 | - * @return array |
|
| 82 | - */ |
|
| 83 | - public function attributeLabels() |
|
| 84 | - { |
|
| 85 | - return array( |
|
| 86 | - 'username' => Yii::t('ciims.models.LoginForm', 'Username'), |
|
| 87 | - 'password' => Yii::t('ciims.models.LoginForm', 'Password'), |
|
| 88 | - 'twoFactorCode' => Yii::t('ciims.models.LoginForm', 'Two Factor Authentication Code'), |
|
| 89 | - ); |
|
| 90 | - } |
|
| 79 | + /** |
|
| 80 | + * Yii attribute labels |
|
| 81 | + * @return array |
|
| 82 | + */ |
|
| 83 | + public function attributeLabels() |
|
| 84 | + { |
|
| 85 | + return array( |
|
| 86 | + 'username' => Yii::t('ciims.models.LoginForm', 'Username'), |
|
| 87 | + 'password' => Yii::t('ciims.models.LoginForm', 'Password'), |
|
| 88 | + 'twoFactorCode' => Yii::t('ciims.models.LoginForm', 'Two Factor Authentication Code'), |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Returns an instance of CiiUserIdentity |
|
| 94 | - * @return CiiUserIdentity |
|
| 95 | - */ |
|
| 96 | - public function getIdentity() |
|
| 97 | - { |
|
| 98 | - if ($this->_identity === NULL) |
|
| 99 | - $this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode); |
|
| 92 | + /** |
|
| 93 | + * Returns an instance of CiiUserIdentity |
|
| 94 | + * @return CiiUserIdentity |
|
| 95 | + */ |
|
| 96 | + public function getIdentity() |
|
| 97 | + { |
|
| 98 | + if ($this->_identity === NULL) |
|
| 99 | + $this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode); |
|
| 100 | 100 | |
| 101 | - return $this->_identity; |
|
| 102 | - } |
|
| 101 | + return $this->_identity; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Authenticates the password. |
|
| 106 | - * This is the 'authenticate' validator as declared in rules(). |
|
| 107 | - */ |
|
| 108 | - public function authenticate($attribute, $params) |
|
| 109 | - { |
|
| 110 | - if (!$this->hasErrors()) |
|
| 111 | - { |
|
| 112 | - $this->getIdentity()->app_name = $this->app_name; |
|
| 113 | - if (!$this->getIdentity()->authenticate($this->force)) |
|
| 114 | - { |
|
| 115 | - if ($this->getIdentity()->errorCode === 5) |
|
| 116 | - { |
|
| 117 | - $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.')); |
|
| 118 | - $this->username = NULL; |
|
| 119 | - $this->password = NULL; |
|
| 120 | - $this->twoFactorCode = NULL; |
|
| 121 | - } |
|
| 122 | - else |
|
| 123 | - $this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.')); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - } |
|
| 104 | + /** |
|
| 105 | + * Authenticates the password. |
|
| 106 | + * This is the 'authenticate' validator as declared in rules(). |
|
| 107 | + */ |
|
| 108 | + public function authenticate($attribute, $params) |
|
| 109 | + { |
|
| 110 | + if (!$this->hasErrors()) |
|
| 111 | + { |
|
| 112 | + $this->getIdentity()->app_name = $this->app_name; |
|
| 113 | + if (!$this->getIdentity()->authenticate($this->force)) |
|
| 114 | + { |
|
| 115 | + if ($this->getIdentity()->errorCode === 5) |
|
| 116 | + { |
|
| 117 | + $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.')); |
|
| 118 | + $this->username = NULL; |
|
| 119 | + $this->password = NULL; |
|
| 120 | + $this->twoFactorCode = NULL; |
|
| 121 | + } |
|
| 122 | + else |
|
| 123 | + $this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.')); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - /** |
|
| 129 | - * Validator for two factor authentication codes |
|
| 130 | - */ |
|
| 131 | - public function hasTwoFactorCode($attribute, $params) |
|
| 132 | - { |
|
| 133 | - if ($this->twoFactorCode === false && $this->needsTwoFactorAuth()) |
|
| 134 | - $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed')); |
|
| 135 | - } |
|
| 128 | + /** |
|
| 129 | + * Validator for two factor authentication codes |
|
| 130 | + */ |
|
| 131 | + public function hasTwoFactorCode($attribute, $params) |
|
| 132 | + { |
|
| 133 | + if ($this->twoFactorCode === false && $this->needsTwoFactorAuth()) |
|
| 134 | + $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed')); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * Determines if two factor authentication code is required |
|
| 139 | - * @return boolean |
|
| 140 | - */ |
|
| 141 | - public function needsTwoFactorAuth() |
|
| 142 | - { |
|
| 143 | - $user = $this->getIdentity()->getUser(); |
|
| 137 | + /** |
|
| 138 | + * Determines if two factor authentication code is required |
|
| 139 | + * @return boolean |
|
| 140 | + */ |
|
| 141 | + public function needsTwoFactorAuth() |
|
| 142 | + { |
|
| 143 | + $user = $this->getIdentity()->getUser(); |
|
| 144 | 144 | |
| 145 | - // If the user is bad, we don't need a 2fa code |
|
| 146 | - if ($user == NULL) |
|
| 147 | - return false; |
|
| 145 | + // If the user is bad, we don't need a 2fa code |
|
| 146 | + if ($user == NULL) |
|
| 147 | + return false; |
|
| 148 | 148 | |
| 149 | - // Only return true if the user needs a 2fa code and their password validation succeeded |
|
| 150 | - if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword()) |
|
| 151 | - return true; |
|
| 149 | + // Only return true if the user needs a 2fa code and their password validation succeeded |
|
| 150 | + if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword()) |
|
| 151 | + return true; |
|
| 152 | 152 | |
| 153 | - return false; |
|
| 154 | - } |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - /** |
|
| 157 | - * Logs in the user using the given username and password in the model. |
|
| 158 | - * @return boolean whether login is successful |
|
| 159 | - */ |
|
| 160 | - public function login() |
|
| 161 | - { |
|
| 162 | - if (!$this->validate()) |
|
| 163 | - return false; |
|
| 156 | + /** |
|
| 157 | + * Logs in the user using the given username and password in the model. |
|
| 158 | + * @return boolean whether login is successful |
|
| 159 | + */ |
|
| 160 | + public function login() |
|
| 161 | + { |
|
| 162 | + if (!$this->validate()) |
|
| 163 | + return false; |
|
| 164 | 164 | |
| 165 | - if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE) |
|
| 166 | - { |
|
| 167 | - Yii::app()->user->login($this->getIdentity()); |
|
| 165 | + if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE) |
|
| 166 | + { |
|
| 167 | + Yii::app()->user->login($this->getIdentity()); |
|
| 168 | 168 | |
| 169 | - // Store the API key and session_identifier as a key-set in cache |
|
| 170 | - Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800); |
|
| 171 | - return true; |
|
| 172 | - } |
|
| 173 | - else |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 169 | + // Store the API key and session_identifier as a key-set in cache |
|
| 170 | + Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800); |
|
| 171 | + return true; |
|
| 172 | + } |
|
| 173 | + else |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | 176 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * LoginForm is the data structure for keeping |
| 6 | 6 | * user login form data. It is used by the 'login' action of 'SiteController'. |
| 7 | 7 | */ |
| 8 | -Yii::import('cii.components.CiiUserIdentity'); |
|
| 8 | +Yii::import ('cii.components.CiiUserIdentity'); |
|
| 9 | 9 | class LoginForm extends CFormModel |
| 10 | 10 | { |
| 11 | 11 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @see application.modules.HybridAuth for more details |
| 57 | 57 | * @param boolean $force |
| 58 | 58 | */ |
| 59 | - public function __construct($force=false) |
|
| 59 | + public function __construct ($force = false) |
|
| 60 | 60 | { |
| 61 | 61 | $this->force = $force; |
| 62 | 62 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * The rules state that username and password are required, |
| 67 | 67 | * and password needs to be authenticated. |
| 68 | 68 | */ |
| 69 | - public function rules() |
|
| 69 | + public function rules () |
|
| 70 | 70 | { |
| 71 | 71 | return array( |
| 72 | 72 | array('username, password', 'required'), |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | * Yii attribute labels |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - public function attributeLabels() |
|
| 83 | + public function attributeLabels () |
|
| 84 | 84 | { |
| 85 | 85 | return array( |
| 86 | - 'username' => Yii::t('ciims.models.LoginForm', 'Username'), |
|
| 87 | - 'password' => Yii::t('ciims.models.LoginForm', 'Password'), |
|
| 88 | - 'twoFactorCode' => Yii::t('ciims.models.LoginForm', 'Two Factor Authentication Code'), |
|
| 86 | + 'username' => Yii::t ('ciims.models.LoginForm', 'Username'), |
|
| 87 | + 'password' => Yii::t ('ciims.models.LoginForm', 'Password'), |
|
| 88 | + 'twoFactorCode' => Yii::t ('ciims.models.LoginForm', 'Two Factor Authentication Code'), |
|
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | 91 | |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | * Returns an instance of CiiUserIdentity |
| 94 | 94 | * @return CiiUserIdentity |
| 95 | 95 | */ |
| 96 | - public function getIdentity() |
|
| 96 | + public function getIdentity () |
|
| 97 | 97 | { |
| 98 | 98 | if ($this->_identity === NULL) |
| 99 | - $this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode); |
|
| 99 | + $this->_identity = new CiiUserIdentity ($this->username, $this->password, $this->twoFactorCode); |
|
| 100 | 100 | |
| 101 | 101 | return $this->_identity; |
| 102 | 102 | } |
@@ -105,22 +105,22 @@ discard block |
||
| 105 | 105 | * Authenticates the password. |
| 106 | 106 | * This is the 'authenticate' validator as declared in rules(). |
| 107 | 107 | */ |
| 108 | - public function authenticate($attribute, $params) |
|
| 108 | + public function authenticate ($attribute, $params) |
|
| 109 | 109 | { |
| 110 | - if (!$this->hasErrors()) |
|
| 110 | + if (!$this->hasErrors ()) |
|
| 111 | 111 | { |
| 112 | - $this->getIdentity()->app_name = $this->app_name; |
|
| 113 | - if (!$this->getIdentity()->authenticate($this->force)) |
|
| 112 | + $this->getIdentity ()->app_name = $this->app_name; |
|
| 113 | + if (!$this->getIdentity ()->authenticate ($this->force)) |
|
| 114 | 114 | { |
| 115 | - if ($this->getIdentity()->errorCode === 5) |
|
| 115 | + if ($this->getIdentity ()->errorCode === 5) |
|
| 116 | 116 | { |
| 117 | - $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.')); |
|
| 117 | + $this->addError ('twoFactorCode', Yii::t ('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.')); |
|
| 118 | 118 | $this->username = NULL; |
| 119 | 119 | $this->password = NULL; |
| 120 | 120 | $this->twoFactorCode = NULL; |
| 121 | 121 | } |
| 122 | 122 | else |
| 123 | - $this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.')); |
|
| 123 | + $this->addError ('password', Yii::t ('ciims.models.LoginForm', 'Incorrect username or password.')); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -128,26 +128,26 @@ discard block |
||
| 128 | 128 | /** |
| 129 | 129 | * Validator for two factor authentication codes |
| 130 | 130 | */ |
| 131 | - public function hasTwoFactorCode($attribute, $params) |
|
| 131 | + public function hasTwoFactorCode ($attribute, $params) |
|
| 132 | 132 | { |
| 133 | - if ($this->twoFactorCode === false && $this->needsTwoFactorAuth()) |
|
| 134 | - $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed')); |
|
| 133 | + if ($this->twoFactorCode === false && $this->needsTwoFactorAuth ()) |
|
| 134 | + $this->addError ('twoFactorCode', Yii::t ('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed')); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * Determines if two factor authentication code is required |
| 139 | 139 | * @return boolean |
| 140 | 140 | */ |
| 141 | - public function needsTwoFactorAuth() |
|
| 141 | + public function needsTwoFactorAuth () |
|
| 142 | 142 | { |
| 143 | - $user = $this->getIdentity()->getUser(); |
|
| 143 | + $user = $this->getIdentity ()->getUser (); |
|
| 144 | 144 | |
| 145 | 145 | // If the user is bad, we don't need a 2fa code |
| 146 | 146 | if ($user == NULL) |
| 147 | 147 | return false; |
| 148 | 148 | |
| 149 | 149 | // Only return true if the user needs a 2fa code and their password validation succeeded |
| 150 | - if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword()) |
|
| 150 | + if ($user->needsTwoFactorAuth () && $this->getIdentity ()->validatePassword ()) |
|
| 151 | 151 | return true; |
| 152 | 152 | |
| 153 | 153 | return false; |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | * Logs in the user using the given username and password in the model. |
| 158 | 158 | * @return boolean whether login is successful |
| 159 | 159 | */ |
| 160 | - public function login() |
|
| 160 | + public function login () |
|
| 161 | 161 | { |
| 162 | - if (!$this->validate()) |
|
| 162 | + if (!$this->validate ()) |
|
| 163 | 163 | return false; |
| 164 | 164 | |
| 165 | - if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE) |
|
| 165 | + if ($this->getIdentity ()->errorCode === CiiUserIdentity::ERROR_NONE) |
|
| 166 | 166 | { |
| 167 | - Yii::app()->user->login($this->getIdentity()); |
|
| 167 | + Yii::app ()->user->login ($this->getIdentity ()); |
|
| 168 | 168 | |
| 169 | 169 | // Store the API key and session_identifier as a key-set in cache |
| 170 | - Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800); |
|
| 170 | + Yii::app ()->cache->set ($this->getIdentity ()->getState ('apiKey'), session_id (), 1800); |
|
| 171 | 171 | return true; |
| 172 | 172 | } |
| 173 | 173 | else |
@@ -95,8 +95,9 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function getIdentity() |
| 97 | 97 | { |
| 98 | - if ($this->_identity === NULL) |
|
| 99 | - $this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode); |
|
| 98 | + if ($this->_identity === NULL) { |
|
| 99 | + $this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode); |
|
| 100 | + } |
|
| 100 | 101 | |
| 101 | 102 | return $this->_identity; |
| 102 | 103 | } |
@@ -118,9 +119,9 @@ discard block |
||
| 118 | 119 | $this->username = NULL; |
| 119 | 120 | $this->password = NULL; |
| 120 | 121 | $this->twoFactorCode = NULL; |
| 122 | + } else { |
|
| 123 | + $this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.')); |
|
| 121 | 124 | } |
| 122 | - else |
|
| 123 | - $this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.')); |
|
| 124 | 125 | } |
| 125 | 126 | } |
| 126 | 127 | } |
@@ -130,8 +131,9 @@ discard block |
||
| 130 | 131 | */ |
| 131 | 132 | public function hasTwoFactorCode($attribute, $params) |
| 132 | 133 | { |
| 133 | - if ($this->twoFactorCode === false && $this->needsTwoFactorAuth()) |
|
| 134 | - $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed')); |
|
| 134 | + if ($this->twoFactorCode === false && $this->needsTwoFactorAuth()) { |
|
| 135 | + $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed')); |
|
| 136 | + } |
|
| 135 | 137 | } |
| 136 | 138 | |
| 137 | 139 | /** |
@@ -143,12 +145,14 @@ discard block |
||
| 143 | 145 | $user = $this->getIdentity()->getUser(); |
| 144 | 146 | |
| 145 | 147 | // If the user is bad, we don't need a 2fa code |
| 146 | - if ($user == NULL) |
|
| 147 | - return false; |
|
| 148 | + if ($user == NULL) { |
|
| 149 | + return false; |
|
| 150 | + } |
|
| 148 | 151 | |
| 149 | 152 | // Only return true if the user needs a 2fa code and their password validation succeeded |
| 150 | - if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword()) |
|
| 151 | - return true; |
|
| 153 | + if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword()) { |
|
| 154 | + return true; |
|
| 155 | + } |
|
| 152 | 156 | |
| 153 | 157 | return false; |
| 154 | 158 | } |
@@ -159,8 +163,9 @@ discard block |
||
| 159 | 163 | */ |
| 160 | 164 | public function login() |
| 161 | 165 | { |
| 162 | - if (!$this->validate()) |
|
| 163 | - return false; |
|
| 166 | + if (!$this->validate()) { |
|
| 167 | + return false; |
|
| 168 | + } |
|
| 164 | 169 | |
| 165 | 170 | if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE) |
| 166 | 171 | { |
@@ -169,8 +174,8 @@ discard block |
||
| 169 | 174 | // Store the API key and session_identifier as a key-set in cache |
| 170 | 175 | Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800); |
| 171 | 176 | return true; |
| 172 | - } |
|
| 173 | - else |
|
| 174 | - return false; |
|
| 177 | + } else { |
|
| 178 | + return false; |
|
| 179 | + } |
|
| 175 | 180 | } |
| 176 | 181 | } |
@@ -2,125 +2,125 @@ |
||
| 2 | 2 | |
| 3 | 3 | class PasswordResetForm extends CFormModel |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * The user's new password |
|
| 7 | - * @var string $password |
|
| 8 | - */ |
|
| 9 | - public $password; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * The user's new password repeated |
|
| 13 | - * @var string $password_repeat |
|
| 14 | - */ |
|
| 15 | - public $password_repeat; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * |
|
| 19 | - * @var string $reset_key |
|
| 20 | - */ |
|
| 21 | - public $reset_key; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The user model |
|
| 25 | - * @var Users $_user |
|
| 26 | - */ |
|
| 27 | - private $_user; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * The hash model |
|
| 31 | - * @var UserMetadata $_hash |
|
| 32 | - */ |
|
| 33 | - private $_hash; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The expires model |
|
| 37 | - * @var UserMetadata $_expires |
|
| 38 | - */ |
|
| 39 | - private $_expires; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Validation rules |
|
| 43 | - * @return array |
|
| 44 | - */ |
|
| 45 | - public function rules() |
|
| 46 | - { |
|
| 47 | - return array( |
|
| 48 | - array('password, password_repeat, reset_key', 'required'), |
|
| 49 | - array('password', 'compare'), |
|
| 50 | - array('password', 'length', 'min'=>8), |
|
| 51 | - array('reset_key', 'validateResetKey') |
|
| 52 | - ); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Attribute labels |
|
| 57 | - * @return array |
|
| 58 | - */ |
|
| 59 | - public function attributeLabels() |
|
| 60 | - { |
|
| 61 | - return array( |
|
| 62 | - 'password' => Yii::t('ciims.models.PasswordResetForm', 'Your New Password'), |
|
| 63 | - 'password_repeat' => Yii::t('ciims.models.PasswordResetForm', 'Your New Password (again)'), |
|
| 64 | - 'reset_key' => Yii::t('ciims.models.PasswordResetForm', 'Your Password Reset Token'), |
|
| 65 | - ); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Validates that the reset key is valid and that it belongs to a user |
|
| 70 | - * @param array $attributes |
|
| 71 | - * @param array $params |
|
| 72 | - * @return boolean |
|
| 73 | - */ |
|
| 74 | - public function validateResetKey($attributes=array(), $params=array()) |
|
| 75 | - { |
|
| 76 | - // Validate that we have a hash for this user |
|
| 77 | - $this->_hash = UserMetadata::model()->findByAttributes(array('key'=>'passwordResetCode', 'value'=>$this->reset_key)); |
|
| 78 | - if ($this->_hash == NULL) |
|
| 79 | - { |
|
| 80 | - $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 81 | - return false; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // Validate that the expiration time has not passed |
|
| 85 | - $this->_expires = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_hash->user_id, 'key'=>'passwordResetExpires')); |
|
| 86 | - if ($this->_expires == NULL || time() > $this->_expires->value) |
|
| 87 | - { |
|
| 88 | - $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 89 | - return false; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Retrieve the user |
|
| 93 | - $this->_user = Users::model()->findByPk($this->_hash->user_id); |
|
| 94 | - if ($this->_user == NULL) |
|
| 95 | - { |
|
| 96 | - $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 97 | - return false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - return true; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Resets the user's password |
|
| 105 | - * @return boolean |
|
| 106 | - */ |
|
| 107 | - public function save() |
|
| 108 | - { |
|
| 109 | - if (!$this->validate()) |
|
| 110 | - return false; |
|
| 111 | - |
|
| 112 | - // Update the user's password |
|
| 113 | - $this->_user->password = $this->password; |
|
| 114 | - |
|
| 115 | - if ($this->_user->save()) |
|
| 116 | - { |
|
| 117 | - // Delete the hash and expires to prevent reuse attemps |
|
| 118 | - $this->_hash->delete(); |
|
| 119 | - $this->_expires->delete(); |
|
| 120 | - |
|
| 121 | - return true; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return false; |
|
| 125 | - } |
|
| 5 | + /** |
|
| 6 | + * The user's new password |
|
| 7 | + * @var string $password |
|
| 8 | + */ |
|
| 9 | + public $password; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * The user's new password repeated |
|
| 13 | + * @var string $password_repeat |
|
| 14 | + */ |
|
| 15 | + public $password_repeat; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * |
|
| 19 | + * @var string $reset_key |
|
| 20 | + */ |
|
| 21 | + public $reset_key; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The user model |
|
| 25 | + * @var Users $_user |
|
| 26 | + */ |
|
| 27 | + private $_user; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * The hash model |
|
| 31 | + * @var UserMetadata $_hash |
|
| 32 | + */ |
|
| 33 | + private $_hash; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The expires model |
|
| 37 | + * @var UserMetadata $_expires |
|
| 38 | + */ |
|
| 39 | + private $_expires; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Validation rules |
|
| 43 | + * @return array |
|
| 44 | + */ |
|
| 45 | + public function rules() |
|
| 46 | + { |
|
| 47 | + return array( |
|
| 48 | + array('password, password_repeat, reset_key', 'required'), |
|
| 49 | + array('password', 'compare'), |
|
| 50 | + array('password', 'length', 'min'=>8), |
|
| 51 | + array('reset_key', 'validateResetKey') |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Attribute labels |
|
| 57 | + * @return array |
|
| 58 | + */ |
|
| 59 | + public function attributeLabels() |
|
| 60 | + { |
|
| 61 | + return array( |
|
| 62 | + 'password' => Yii::t('ciims.models.PasswordResetForm', 'Your New Password'), |
|
| 63 | + 'password_repeat' => Yii::t('ciims.models.PasswordResetForm', 'Your New Password (again)'), |
|
| 64 | + 'reset_key' => Yii::t('ciims.models.PasswordResetForm', 'Your Password Reset Token'), |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Validates that the reset key is valid and that it belongs to a user |
|
| 70 | + * @param array $attributes |
|
| 71 | + * @param array $params |
|
| 72 | + * @return boolean |
|
| 73 | + */ |
|
| 74 | + public function validateResetKey($attributes=array(), $params=array()) |
|
| 75 | + { |
|
| 76 | + // Validate that we have a hash for this user |
|
| 77 | + $this->_hash = UserMetadata::model()->findByAttributes(array('key'=>'passwordResetCode', 'value'=>$this->reset_key)); |
|
| 78 | + if ($this->_hash == NULL) |
|
| 79 | + { |
|
| 80 | + $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 81 | + return false; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // Validate that the expiration time has not passed |
|
| 85 | + $this->_expires = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_hash->user_id, 'key'=>'passwordResetExpires')); |
|
| 86 | + if ($this->_expires == NULL || time() > $this->_expires->value) |
|
| 87 | + { |
|
| 88 | + $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Retrieve the user |
|
| 93 | + $this->_user = Users::model()->findByPk($this->_hash->user_id); |
|
| 94 | + if ($this->_user == NULL) |
|
| 95 | + { |
|
| 96 | + $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + return true; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Resets the user's password |
|
| 105 | + * @return boolean |
|
| 106 | + */ |
|
| 107 | + public function save() |
|
| 108 | + { |
|
| 109 | + if (!$this->validate()) |
|
| 110 | + return false; |
|
| 111 | + |
|
| 112 | + // Update the user's password |
|
| 113 | + $this->_user->password = $this->password; |
|
| 114 | + |
|
| 115 | + if ($this->_user->save()) |
|
| 116 | + { |
|
| 117 | + // Delete the hash and expires to prevent reuse attemps |
|
| 118 | + $this->_hash->delete(); |
|
| 119 | + $this->_expires->delete(); |
|
| 120 | + |
|
| 121 | + return true; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return false; |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Validation rules |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function rules() |
|
| 45 | + public function rules () |
|
| 46 | 46 | { |
| 47 | 47 | return array( |
| 48 | 48 | array('password, password_repeat, reset_key', 'required'), |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | * Attribute labels |
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | - public function attributeLabels() |
|
| 59 | + public function attributeLabels () |
|
| 60 | 60 | { |
| 61 | 61 | return array( |
| 62 | - 'password' => Yii::t('ciims.models.PasswordResetForm', 'Your New Password'), |
|
| 63 | - 'password_repeat' => Yii::t('ciims.models.PasswordResetForm', 'Your New Password (again)'), |
|
| 64 | - 'reset_key' => Yii::t('ciims.models.PasswordResetForm', 'Your Password Reset Token'), |
|
| 62 | + 'password' => Yii::t ('ciims.models.PasswordResetForm', 'Your New Password'), |
|
| 63 | + 'password_repeat' => Yii::t ('ciims.models.PasswordResetForm', 'Your New Password (again)'), |
|
| 64 | + 'reset_key' => Yii::t ('ciims.models.PasswordResetForm', 'Your Password Reset Token'), |
|
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -71,29 +71,29 @@ discard block |
||
| 71 | 71 | * @param array $params |
| 72 | 72 | * @return boolean |
| 73 | 73 | */ |
| 74 | - public function validateResetKey($attributes=array(), $params=array()) |
|
| 74 | + public function validateResetKey ($attributes = array(), $params = array()) |
|
| 75 | 75 | { |
| 76 | 76 | // Validate that we have a hash for this user |
| 77 | - $this->_hash = UserMetadata::model()->findByAttributes(array('key'=>'passwordResetCode', 'value'=>$this->reset_key)); |
|
| 77 | + $this->_hash = UserMetadata::model ()->findByAttributes (array('key'=>'passwordResetCode', 'value'=>$this->reset_key)); |
|
| 78 | 78 | if ($this->_hash == NULL) |
| 79 | 79 | { |
| 80 | - $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 80 | + $this->addError ('reset_key', Yii::t ('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 81 | 81 | return false; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | // Validate that the expiration time has not passed |
| 85 | - $this->_expires = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_hash->user_id, 'key'=>'passwordResetExpires')); |
|
| 86 | - if ($this->_expires == NULL || time() > $this->_expires->value) |
|
| 85 | + $this->_expires = UserMetadata::model ()->findByAttributes (array('user_id'=>$this->_hash->user_id, 'key'=>'passwordResetExpires')); |
|
| 86 | + if ($this->_expires == NULL || time () > $this->_expires->value) |
|
| 87 | 87 | { |
| 88 | - $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 88 | + $this->addError ('reset_key', Yii::t ('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 89 | 89 | return false; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Retrieve the user |
| 93 | - $this->_user = Users::model()->findByPk($this->_hash->user_id); |
|
| 93 | + $this->_user = Users::model ()->findByPk ($this->_hash->user_id); |
|
| 94 | 94 | if ($this->_user == NULL) |
| 95 | 95 | { |
| 96 | - $this->addError('reset_key', Yii::t('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 96 | + $this->addError ('reset_key', Yii::t ('ciims.models.PasswordResetForm', 'The activation key you provided is invalid')); |
|
| 97 | 97 | return false; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -104,19 +104,19 @@ discard block |
||
| 104 | 104 | * Resets the user's password |
| 105 | 105 | * @return boolean |
| 106 | 106 | */ |
| 107 | - public function save() |
|
| 107 | + public function save () |
|
| 108 | 108 | { |
| 109 | - if (!$this->validate()) |
|
| 109 | + if (!$this->validate ()) |
|
| 110 | 110 | return false; |
| 111 | 111 | |
| 112 | 112 | // Update the user's password |
| 113 | 113 | $this->_user->password = $this->password; |
| 114 | 114 | |
| 115 | - if ($this->_user->save()) |
|
| 115 | + if ($this->_user->save ()) |
|
| 116 | 116 | { |
| 117 | 117 | // Delete the hash and expires to prevent reuse attemps |
| 118 | - $this->_hash->delete(); |
|
| 119 | - $this->_expires->delete(); |
|
| 118 | + $this->_hash->delete (); |
|
| 119 | + $this->_expires->delete (); |
|
| 120 | 120 | |
| 121 | 121 | return true; |
| 122 | 122 | } |
@@ -106,8 +106,9 @@ |
||
| 106 | 106 | */ |
| 107 | 107 | public function save() |
| 108 | 108 | { |
| 109 | - if (!$this->validate()) |
|
| 110 | - return false; |
|
| 109 | + if (!$this->validate()) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 111 | 112 | |
| 112 | 113 | // Update the user's password |
| 113 | 114 | $this->_user->password = $this->password; |
@@ -2,317 +2,317 @@ |
||
| 2 | 2 | |
| 3 | 3 | class ProfileForm extends CFormModel |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * The user's email address |
|
| 7 | - * @var string $email |
|
| 8 | - */ |
|
| 9 | - public $email; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * The user's NEW password |
|
| 13 | - * @var string $password |
|
| 14 | - */ |
|
| 15 | - public $password; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * The repeated password if a NEW password is applied |
|
| 19 | - * @var string $password_repeat |
|
| 20 | - */ |
|
| 21 | - public $password_repeat; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The user's current password |
|
| 25 | - * This field is required to make any changes to the account |
|
| 26 | - * @var string $currentPassword |
|
| 27 | - */ |
|
| 28 | - public $currentPassword; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The user's display name |
|
| 32 | - * @var string $username |
|
| 33 | - */ |
|
| 34 | - public $username; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * The user role |
|
| 38 | - * @var int $role |
|
| 39 | - */ |
|
| 40 | - public $user_role; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * The user model |
|
| 44 | - * @var Users $_user |
|
| 45 | - */ |
|
| 46 | - private $_user = NULL; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * This form will likely be reused in admin portals, for re-use purposes authentication is not required to change privileged information |
|
| 50 | - * @var boolean $overridePasswordCheck |
|
| 51 | - */ |
|
| 52 | - private $overridePasswordCheck = false; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - private function canOverridePasswordCheck() |
|
| 56 | - { |
|
| 57 | - if ($this->overridePasswordCheck) |
|
| 58 | - return true; |
|
| 59 | - |
|
| 60 | - if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id) |
|
| 61 | - return true; |
|
| 62 | - |
|
| 63 | - return false; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Overload of the __getter method to retrieve the user's ID |
|
| 68 | - * @var int $id |
|
| 69 | - */ |
|
| 70 | - public function getId() |
|
| 71 | - { |
|
| 72 | - return $this->_user->id; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Retrieves the new email address if it is set |
|
| 77 | - * @return mixed |
|
| 78 | - */ |
|
| 79 | - public function getNewEmail() |
|
| 80 | - { |
|
| 81 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 82 | - 'user_id' => $this->_user->id, |
|
| 83 | - 'key' => 'newEmailAddress' |
|
| 84 | - )); |
|
| 85 | - |
|
| 86 | - if ($metadata == NULL) |
|
| 87 | - return NULL; |
|
| 88 | - |
|
| 89 | - return $metadata->value; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Sets the new email address |
|
| 94 | - * @return boolean |
|
| 95 | - */ |
|
| 96 | - public function setNewEmail() |
|
| 97 | - { |
|
| 98 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 99 | - 'user_id' => $this->_user->id, |
|
| 100 | - 'key' => 'newEmailAddress' |
|
| 101 | - )); |
|
| 102 | - |
|
| 103 | - if ($metadata == NULL) |
|
| 104 | - { |
|
| 105 | - $metadata = new UserMetadata; |
|
| 106 | - $metadata->attributes = array( |
|
| 107 | - 'user_id' => $this->_user->id, |
|
| 108 | - 'key' => 'newEmailAddress' |
|
| 109 | - ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $metadata->value = $this->email; |
|
| 113 | - |
|
| 114 | - // Save the record |
|
| 115 | - return $metadata->save(); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Retrieves the new email address if it is set |
|
| 120 | - * @return mixed |
|
| 121 | - */ |
|
| 122 | - public function getNewEmailChangeKey() |
|
| 123 | - { |
|
| 124 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 125 | - 'user_id' => $this->_user->id, |
|
| 126 | - 'key' => 'newEmailAddressChangeKey' |
|
| 127 | - )); |
|
| 128 | - |
|
| 129 | - if ($metadata == NULL) |
|
| 130 | - return NULL; |
|
| 131 | - |
|
| 132 | - return $metadata->value; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * Generates a new change key |
|
| 137 | - * @return boolean |
|
| 138 | - */ |
|
| 139 | - public function setNewEmailChangeKey() |
|
| 140 | - { |
|
| 141 | - $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 142 | - 'user_id' => $this->_user->id, |
|
| 143 | - 'key' => 'newEmailAddressChangeKey' |
|
| 144 | - )); |
|
| 145 | - |
|
| 146 | - if ($metadata == NULL) |
|
| 147 | - { |
|
| 148 | - $metadata = new UserMetadata; |
|
| 149 | - $metadata->attributes = array( |
|
| 150 | - 'user_id' => $this->_user->id, |
|
| 151 | - 'key' => 'newEmailAddressChangeKey' |
|
| 152 | - ); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - // Generate a new key |
|
| 156 | - $metadata->value = Cii::generateSafeHash(); |
|
| 157 | - |
|
| 158 | - // Save the record |
|
| 159 | - if ($metadata->save()) |
|
| 160 | - return $metadata->value; |
|
| 5 | + /** |
|
| 6 | + * The user's email address |
|
| 7 | + * @var string $email |
|
| 8 | + */ |
|
| 9 | + public $email; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * The user's NEW password |
|
| 13 | + * @var string $password |
|
| 14 | + */ |
|
| 15 | + public $password; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * The repeated password if a NEW password is applied |
|
| 19 | + * @var string $password_repeat |
|
| 20 | + */ |
|
| 21 | + public $password_repeat; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The user's current password |
|
| 25 | + * This field is required to make any changes to the account |
|
| 26 | + * @var string $currentPassword |
|
| 27 | + */ |
|
| 28 | + public $currentPassword; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The user's display name |
|
| 32 | + * @var string $username |
|
| 33 | + */ |
|
| 34 | + public $username; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * The user role |
|
| 38 | + * @var int $role |
|
| 39 | + */ |
|
| 40 | + public $user_role; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * The user model |
|
| 44 | + * @var Users $_user |
|
| 45 | + */ |
|
| 46 | + private $_user = NULL; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * This form will likely be reused in admin portals, for re-use purposes authentication is not required to change privileged information |
|
| 50 | + * @var boolean $overridePasswordCheck |
|
| 51 | + */ |
|
| 52 | + private $overridePasswordCheck = false; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + private function canOverridePasswordCheck() |
|
| 56 | + { |
|
| 57 | + if ($this->overridePasswordCheck) |
|
| 58 | + return true; |
|
| 59 | + |
|
| 60 | + if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id) |
|
| 61 | + return true; |
|
| 62 | + |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Overload of the __getter method to retrieve the user's ID |
|
| 68 | + * @var int $id |
|
| 69 | + */ |
|
| 70 | + public function getId() |
|
| 71 | + { |
|
| 72 | + return $this->_user->id; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Retrieves the new email address if it is set |
|
| 77 | + * @return mixed |
|
| 78 | + */ |
|
| 79 | + public function getNewEmail() |
|
| 80 | + { |
|
| 81 | + $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 82 | + 'user_id' => $this->_user->id, |
|
| 83 | + 'key' => 'newEmailAddress' |
|
| 84 | + )); |
|
| 85 | + |
|
| 86 | + if ($metadata == NULL) |
|
| 87 | + return NULL; |
|
| 88 | + |
|
| 89 | + return $metadata->value; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Sets the new email address |
|
| 94 | + * @return boolean |
|
| 95 | + */ |
|
| 96 | + public function setNewEmail() |
|
| 97 | + { |
|
| 98 | + $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 99 | + 'user_id' => $this->_user->id, |
|
| 100 | + 'key' => 'newEmailAddress' |
|
| 101 | + )); |
|
| 102 | + |
|
| 103 | + if ($metadata == NULL) |
|
| 104 | + { |
|
| 105 | + $metadata = new UserMetadata; |
|
| 106 | + $metadata->attributes = array( |
|
| 107 | + 'user_id' => $this->_user->id, |
|
| 108 | + 'key' => 'newEmailAddress' |
|
| 109 | + ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $metadata->value = $this->email; |
|
| 113 | + |
|
| 114 | + // Save the record |
|
| 115 | + return $metadata->save(); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Retrieves the new email address if it is set |
|
| 120 | + * @return mixed |
|
| 121 | + */ |
|
| 122 | + public function getNewEmailChangeKey() |
|
| 123 | + { |
|
| 124 | + $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 125 | + 'user_id' => $this->_user->id, |
|
| 126 | + 'key' => 'newEmailAddressChangeKey' |
|
| 127 | + )); |
|
| 128 | + |
|
| 129 | + if ($metadata == NULL) |
|
| 130 | + return NULL; |
|
| 131 | + |
|
| 132 | + return $metadata->value; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * Generates a new change key |
|
| 137 | + * @return boolean |
|
| 138 | + */ |
|
| 139 | + public function setNewEmailChangeKey() |
|
| 140 | + { |
|
| 141 | + $metadata = UserMetadata::model()->findByAttributes(array( |
|
| 142 | + 'user_id' => $this->_user->id, |
|
| 143 | + 'key' => 'newEmailAddressChangeKey' |
|
| 144 | + )); |
|
| 145 | + |
|
| 146 | + if ($metadata == NULL) |
|
| 147 | + { |
|
| 148 | + $metadata = new UserMetadata; |
|
| 149 | + $metadata->attributes = array( |
|
| 150 | + 'user_id' => $this->_user->id, |
|
| 151 | + 'key' => 'newEmailAddressChangeKey' |
|
| 152 | + ); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + // Generate a new key |
|
| 156 | + $metadata->value = Cii::generateSafeHash(); |
|
| 157 | + |
|
| 158 | + // Save the record |
|
| 159 | + if ($metadata->save()) |
|
| 160 | + return $metadata->value; |
|
| 161 | 161 | |
| 162 | - throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key')); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Validation rules |
|
| 167 | - * @return array |
|
| 168 | - */ |
|
| 169 | - public function rules() |
|
| 170 | - { |
|
| 171 | - return array( |
|
| 172 | - array('email, username', 'required'), |
|
| 173 | - array('username', 'length', 'max' => 255), |
|
| 174 | - array('currentPassword', 'validateUserPassword'), |
|
| 175 | - array('password', 'compare'), |
|
| 176 | - array('password', 'length', 'min' => 8), |
|
| 177 | - array('user_role', 'numerical'), |
|
| 178 | - array('user_role', 'validateUserRole') |
|
| 179 | - ); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Retrieves the attributes labels from the Users model and returns them to reduce code redundancy |
|
| 184 | - * @return array |
|
| 185 | - */ |
|
| 186 | - public function attributeLabels() |
|
| 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)') |
|
| 191 | - )); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Validates the role |
|
| 196 | - * @param array $attributes |
|
| 197 | - * @param array $params |
|
| 198 | - * return array |
|
| 199 | - */ |
|
| 200 | - public function validateUserRole($attributes, $params) |
|
| 201 | - { |
|
| 202 | - if ($this->canOverridePasswordCheck()) |
|
| 203 | - return true; |
|
| 204 | - |
|
| 205 | - $this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute')); |
|
| 206 | - return false; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Ensures that the password entered matches the one provided during registration |
|
| 211 | - * @param array $attributes |
|
| 212 | - * @param array $params |
|
| 213 | - * return array |
|
| 214 | - */ |
|
| 215 | - public function validateUserPassword($attributes, $params) |
|
| 216 | - { |
|
| 217 | - // Apply the override if it was set |
|
| 218 | - if ($this->canOverridePasswordCheck()) |
|
| 219 | - { |
|
| 220 | - $this->password_repeat = $this->password; |
|
| 221 | - return true; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - $result = password_verify($this->password, $this->_user->password); |
|
| 162 | + throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key')); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Validation rules |
|
| 167 | + * @return array |
|
| 168 | + */ |
|
| 169 | + public function rules() |
|
| 170 | + { |
|
| 171 | + return array( |
|
| 172 | + array('email, username', 'required'), |
|
| 173 | + array('username', 'length', 'max' => 255), |
|
| 174 | + array('currentPassword', 'validateUserPassword'), |
|
| 175 | + array('password', 'compare'), |
|
| 176 | + array('password', 'length', 'min' => 8), |
|
| 177 | + array('user_role', 'numerical'), |
|
| 178 | + array('user_role', 'validateUserRole') |
|
| 179 | + ); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Retrieves the attributes labels from the Users model and returns them to reduce code redundancy |
|
| 184 | + * @return array |
|
| 185 | + */ |
|
| 186 | + public function attributeLabels() |
|
| 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)') |
|
| 191 | + )); |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Validates the role |
|
| 196 | + * @param array $attributes |
|
| 197 | + * @param array $params |
|
| 198 | + * return array |
|
| 199 | + */ |
|
| 200 | + public function validateUserRole($attributes, $params) |
|
| 201 | + { |
|
| 202 | + if ($this->canOverridePasswordCheck()) |
|
| 203 | + return true; |
|
| 204 | + |
|
| 205 | + $this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute')); |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Ensures that the password entered matches the one provided during registration |
|
| 211 | + * @param array $attributes |
|
| 212 | + * @param array $params |
|
| 213 | + * return array |
|
| 214 | + */ |
|
| 215 | + public function validateUserPassword($attributes, $params) |
|
| 216 | + { |
|
| 217 | + // Apply the override if it was set |
|
| 218 | + if ($this->canOverridePasswordCheck()) |
|
| 219 | + { |
|
| 220 | + $this->password_repeat = $this->password; |
|
| 221 | + return true; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + $result = password_verify($this->password, $this->_user->password); |
|
| 225 | 225 | |
| 226 | - if ($result == false) |
|
| 227 | - { |
|
| 228 | - $this->addError('currentPassword', Yii::t('ciims.models.ProfileForm', 'The password you entered is invalid.')); |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - return true; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Internally loads the user's information before attempting to validate it |
|
| 237 | - * @param int $id The user's ID |
|
| 238 | - * @param bool $override This form may be reused |
|
| 239 | - * @return ProfileForm |
|
| 240 | - */ |
|
| 241 | - public function load($id, $override = false) |
|
| 242 | - { |
|
| 243 | - $this->overridePasswordCheck = $override; |
|
| 244 | - |
|
| 245 | - // Load the user |
|
| 246 | - $this->_user = Users::model()->findByPk($id); |
|
| 247 | - |
|
| 248 | - if ($this->_user == NULL) |
|
| 249 | - throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded')); |
|
| 250 | - |
|
| 251 | - // Reload the attribute labels |
|
| 252 | - $this->attributes = array( |
|
| 253 | - 'email' => $this->_user->email, |
|
| 254 | - 'username' => $this->_user->username, |
|
| 255 | - 'user_role' => $this->_user->role->id |
|
| 256 | - ); |
|
| 257 | - |
|
| 258 | - return $this; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * Updates the user's profile information |
|
| 263 | - * @return boolean |
|
| 264 | - */ |
|
| 265 | - public function save() |
|
| 266 | - { |
|
| 267 | - if (!$this->validate(NULL, false)) |
|
| 268 | - return false; |
|
| 269 | - |
|
| 270 | - // Change the email address, if necessary |
|
| 271 | - $this->changeEmail(); |
|
| 272 | - |
|
| 273 | - $this->_user->attributes = array( |
|
| 274 | - 'password' => $this->password, |
|
| 275 | - 'username' => $this->username, |
|
| 276 | - 'user_role' => $this->user_role |
|
| 277 | - ); |
|
| 278 | - |
|
| 279 | - if ($this->_user->save()) |
|
| 280 | - return true; |
|
| 281 | - |
|
| 282 | - return false; |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 286 | - * Changes the user's email address if necessary |
|
| 287 | - * @return boolean |
|
| 288 | - */ |
|
| 289 | - private function changeEmail() |
|
| 290 | - { |
|
| 291 | - if ($this->email != $this->_user->email) |
|
| 292 | - { |
|
| 293 | - $this->setNewemail(); |
|
| 294 | - $this->setNewEmailChangeKey(); |
|
| 295 | - $this->sendVerificationEmail(); |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - return true; |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - /** |
|
| 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 | - * @return boolean |
|
| 304 | - */ |
|
| 305 | - public function sendVerificationEmail() |
|
| 306 | - { |
|
| 307 | - $emailSettings = new EmailSettings; |
|
| 226 | + if ($result == false) |
|
| 227 | + { |
|
| 228 | + $this->addError('currentPassword', Yii::t('ciims.models.ProfileForm', 'The password you entered is invalid.')); |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + return true; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Internally loads the user's information before attempting to validate it |
|
| 237 | + * @param int $id The user's ID |
|
| 238 | + * @param bool $override This form may be reused |
|
| 239 | + * @return ProfileForm |
|
| 240 | + */ |
|
| 241 | + public function load($id, $override = false) |
|
| 242 | + { |
|
| 243 | + $this->overridePasswordCheck = $override; |
|
| 244 | + |
|
| 245 | + // Load the user |
|
| 246 | + $this->_user = Users::model()->findByPk($id); |
|
| 247 | + |
|
| 248 | + if ($this->_user == NULL) |
|
| 249 | + throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded')); |
|
| 250 | + |
|
| 251 | + // Reload the attribute labels |
|
| 252 | + $this->attributes = array( |
|
| 253 | + 'email' => $this->_user->email, |
|
| 254 | + 'username' => $this->_user->username, |
|
| 255 | + 'user_role' => $this->_user->role->id |
|
| 256 | + ); |
|
| 257 | + |
|
| 258 | + return $this; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * Updates the user's profile information |
|
| 263 | + * @return boolean |
|
| 264 | + */ |
|
| 265 | + public function save() |
|
| 266 | + { |
|
| 267 | + if (!$this->validate(NULL, false)) |
|
| 268 | + return false; |
|
| 269 | + |
|
| 270 | + // Change the email address, if necessary |
|
| 271 | + $this->changeEmail(); |
|
| 272 | + |
|
| 273 | + $this->_user->attributes = array( |
|
| 274 | + 'password' => $this->password, |
|
| 275 | + 'username' => $this->username, |
|
| 276 | + 'user_role' => $this->user_role |
|
| 277 | + ); |
|
| 278 | + |
|
| 279 | + if ($this->_user->save()) |
|
| 280 | + return true; |
|
| 281 | + |
|
| 282 | + return false; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Changes the user's email address if necessary |
|
| 287 | + * @return boolean |
|
| 288 | + */ |
|
| 289 | + private function changeEmail() |
|
| 290 | + { |
|
| 291 | + if ($this->email != $this->_user->email) |
|
| 292 | + { |
|
| 293 | + $this->setNewemail(); |
|
| 294 | + $this->setNewEmailChangeKey(); |
|
| 295 | + $this->sendVerificationEmail(); |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + return true; |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + /** |
|
| 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 | + * @return boolean |
|
| 304 | + */ |
|
| 305 | + public function sendVerificationEmail() |
|
| 306 | + { |
|
| 307 | + $emailSettings = new EmailSettings; |
|
| 308 | 308 | return $emailSettings->send( |
| 309 | - $this->_user, |
|
| 310 | - Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'), |
|
| 311 | - 'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.email-change', |
|
| 312 | - array( |
|
| 313 | - 'key' => $this->setNewEmailChangeKey(), |
|
| 314 | - 'user' => $this->_user |
|
| 315 | - ) |
|
| 316 | - ); |
|
| 317 | - } |
|
| 309 | + $this->_user, |
|
| 310 | + Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'), |
|
| 311 | + 'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.email-change', |
|
| 312 | + array( |
|
| 313 | + 'key' => $this->setNewEmailChangeKey(), |
|
| 314 | + 'user' => $this->_user |
|
| 315 | + ) |
|
| 316 | + ); |
|
| 317 | + } |
|
| 318 | 318 | } |
@@ -54,11 +54,13 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | private function canOverridePasswordCheck() |
| 56 | 56 | { |
| 57 | - if ($this->overridePasswordCheck) |
|
| 58 | - return true; |
|
| 57 | + if ($this->overridePasswordCheck) { |
|
| 58 | + return true; |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | - if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id) |
|
| 61 | - return true; |
|
| 61 | + if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id) { |
|
| 62 | + return true; |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | return false; |
| 64 | 66 | } |
@@ -83,8 +85,9 @@ discard block |
||
| 83 | 85 | 'key' => 'newEmailAddress' |
| 84 | 86 | )); |
| 85 | 87 | |
| 86 | - if ($metadata == NULL) |
|
| 87 | - return NULL; |
|
| 88 | + if ($metadata == NULL) { |
|
| 89 | + return NULL; |
|
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | return $metadata->value; |
| 90 | 93 | } |
@@ -126,8 +129,9 @@ discard block |
||
| 126 | 129 | 'key' => 'newEmailAddressChangeKey' |
| 127 | 130 | )); |
| 128 | 131 | |
| 129 | - if ($metadata == NULL) |
|
| 130 | - return NULL; |
|
| 132 | + if ($metadata == NULL) { |
|
| 133 | + return NULL; |
|
| 134 | + } |
|
| 131 | 135 | |
| 132 | 136 | return $metadata->value; |
| 133 | 137 | } |
@@ -156,8 +160,9 @@ discard block |
||
| 156 | 160 | $metadata->value = Cii::generateSafeHash(); |
| 157 | 161 | |
| 158 | 162 | // Save the record |
| 159 | - if ($metadata->save()) |
|
| 160 | - return $metadata->value; |
|
| 163 | + if ($metadata->save()) { |
|
| 164 | + return $metadata->value; |
|
| 165 | + } |
|
| 161 | 166 | |
| 162 | 167 | throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key')); |
| 163 | 168 | } |
@@ -199,8 +204,9 @@ discard block |
||
| 199 | 204 | */ |
| 200 | 205 | public function validateUserRole($attributes, $params) |
| 201 | 206 | { |
| 202 | - if ($this->canOverridePasswordCheck()) |
|
| 203 | - return true; |
|
| 207 | + if ($this->canOverridePasswordCheck()) { |
|
| 208 | + return true; |
|
| 209 | + } |
|
| 204 | 210 | |
| 205 | 211 | $this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute')); |
| 206 | 212 | return false; |
@@ -245,8 +251,9 @@ discard block |
||
| 245 | 251 | // Load the user |
| 246 | 252 | $this->_user = Users::model()->findByPk($id); |
| 247 | 253 | |
| 248 | - if ($this->_user == NULL) |
|
| 249 | - throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded')); |
|
| 254 | + if ($this->_user == NULL) { |
|
| 255 | + throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded')); |
|
| 256 | + } |
|
| 250 | 257 | |
| 251 | 258 | // Reload the attribute labels |
| 252 | 259 | $this->attributes = array( |
@@ -264,8 +271,9 @@ discard block |
||
| 264 | 271 | */ |
| 265 | 272 | public function save() |
| 266 | 273 | { |
| 267 | - if (!$this->validate(NULL, false)) |
|
| 268 | - return false; |
|
| 274 | + if (!$this->validate(NULL, false)) { |
|
| 275 | + return false; |
|
| 276 | + } |
|
| 269 | 277 | |
| 270 | 278 | // Change the email address, if necessary |
| 271 | 279 | $this->changeEmail(); |
@@ -276,8 +284,9 @@ discard block |
||
| 276 | 284 | 'user_role' => $this->user_role |
| 277 | 285 | ); |
| 278 | 286 | |
| 279 | - if ($this->_user->save()) |
|
| 280 | - return true; |
|
| 287 | + if ($this->_user->save()) { |
|
| 288 | + return true; |
|
| 289 | + } |
|
| 281 | 290 | |
| 282 | 291 | return false; |
| 283 | 292 | } |
@@ -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 | ); |
@@ -2,148 +2,148 @@ |
||
| 2 | 2 | |
| 3 | 3 | class RegisterForm extends CFormModel |
| 4 | 4 | { |
| 5 | - /** |
|
| 6 | - * The submitted email address |
|
| 7 | - * @var string|email |
|
| 8 | - */ |
|
| 9 | - public $email; |
|
| 10 | - |
|
| 11 | - /** |
|
| 12 | - * The submitted password |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - public $password; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * The password verification |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - public $password_repeat; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The user name as we will show it on the site |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - public $username; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * The user model |
|
| 31 | - * @param Users $_user |
|
| 32 | - */ |
|
| 33 | - protected $_user; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Declares the validation rules. |
|
| 37 | - * The rules state that username and password are required, |
|
| 38 | - * and password needs to be authenticated. |
|
| 39 | - */ |
|
| 40 | - public function rules() |
|
| 41 | - { |
|
| 42 | - return array( |
|
| 43 | - array('email, password, password_repeat, username', 'required'), |
|
| 44 | - array('password', 'compare'), |
|
| 45 | - array('password', 'length', 'min'=>8), |
|
| 46 | - array('email', 'email'), |
|
| 47 | - array('email', 'isEmailUnique'), |
|
| 48 | - array('email', 'isUsernameUnique') |
|
| 49 | - ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Determines if an email is already taken or not |
|
| 54 | - * @param array $attributes |
|
| 55 | - * @param array $params |
|
| 56 | - * @return boolean |
|
| 57 | - */ |
|
| 58 | - public function isEmailUnique($attributes, $params) |
|
| 59 | - { |
|
| 60 | - $this->_user = Users::model()->findByAttributes(array('email' => $this->email)); |
|
| 61 | - |
|
| 62 | - if ($this->_user != NULL) |
|
| 63 | - { |
|
| 64 | - $this->addError('email', Yii::t('ciims.models.RegisterForm', 'That email address is already in use')); |
|
| 65 | - return false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - return true; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Determines if an username is already taken or not |
|
| 73 | - * @param array $attributes |
|
| 74 | - * @param array $params |
|
| 75 | - * @return boolean |
|
| 76 | - */ |
|
| 77 | - public function isUsernameUnique($attributes, $params) |
|
| 78 | - { |
|
| 79 | - $this->_user = Users::model()->findByAttributes(array('username' => $this->username)); |
|
| 80 | - |
|
| 81 | - if ($this->_user != NULL) |
|
| 82 | - { |
|
| 83 | - $this->addError('username', Yii::t('ciims.models.RegisterForm', 'That username address is already in use')); |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - return true; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Model attribute labels |
|
| 92 | - * @return array |
|
| 93 | - */ |
|
| 94 | - public function attributeLabels() |
|
| 95 | - { |
|
| 96 | - return array( |
|
| 97 | - 'email' => Yii::t('ciims.models.RegisterForm', 'Your Email Address'), |
|
| 98 | - 'password' => Yii::t('ciims.models.RegisterForm', 'Your Password'), |
|
| 99 | - 'password_repeat' => Yii::t('ciims.models.RegisterForm', 'Your Password (again)'), |
|
| 100 | - 'username' => Yii::t('ciims.models.RegisterForm', 'Your Username on the Site') |
|
| 101 | - ); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * Creates a new user, and sends the appropriate messaging out |
|
| 106 | - * @return boolean |
|
| 107 | - */ |
|
| 108 | - public function save($sendEmail = true) |
|
| 109 | - { |
|
| 110 | - if (!$this->validate()) |
|
| 111 | - return false; |
|
| 112 | - |
|
| 113 | - $this->_user = new Users; |
|
| 114 | - |
|
| 115 | - // Set the model attributes |
|
| 116 | - $this->_user->attributes = array( |
|
| 117 | - 'email' => $this->email, |
|
| 118 | - 'password' => $this->password, |
|
| 119 | - 'username' => $this->username, |
|
| 120 | - 'user_role' => 1, |
|
| 121 | - 'status' => $sendEmail ? Users::PENDING_INVITATION : Users::ACTIVE |
|
| 122 | - ); |
|
| 123 | - |
|
| 124 | - // If we saved the user model, return true |
|
| 125 | - if($this->_user->save()) |
|
| 126 | - { |
|
| 127 | - // This class my be extended by other modules, in which case we don't need to send an activation form if we don't want need it to. |
|
| 128 | - if ($sendEmail) |
|
| 129 | - { |
|
| 130 | - $meta = new UserMetadata; |
|
| 131 | - $meta->attributes = array( |
|
| 132 | - 'user_id' => $this->_user->id, |
|
| 133 | - 'key' => 'activationKey', |
|
| 134 | - 'value' => Cii::generateSafeHash() |
|
| 135 | - ); |
|
| 5 | + /** |
|
| 6 | + * The submitted email address |
|
| 7 | + * @var string|email |
|
| 8 | + */ |
|
| 9 | + public $email; |
|
| 10 | + |
|
| 11 | + /** |
|
| 12 | + * The submitted password |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + public $password; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * The password verification |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + public $password_repeat; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The user name as we will show it on the site |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + public $username; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * The user model |
|
| 31 | + * @param Users $_user |
|
| 32 | + */ |
|
| 33 | + protected $_user; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Declares the validation rules. |
|
| 37 | + * The rules state that username and password are required, |
|
| 38 | + * and password needs to be authenticated. |
|
| 39 | + */ |
|
| 40 | + public function rules() |
|
| 41 | + { |
|
| 42 | + return array( |
|
| 43 | + array('email, password, password_repeat, username', 'required'), |
|
| 44 | + array('password', 'compare'), |
|
| 45 | + array('password', 'length', 'min'=>8), |
|
| 46 | + array('email', 'email'), |
|
| 47 | + array('email', 'isEmailUnique'), |
|
| 48 | + array('email', 'isUsernameUnique') |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Determines if an email is already taken or not |
|
| 54 | + * @param array $attributes |
|
| 55 | + * @param array $params |
|
| 56 | + * @return boolean |
|
| 57 | + */ |
|
| 58 | + public function isEmailUnique($attributes, $params) |
|
| 59 | + { |
|
| 60 | + $this->_user = Users::model()->findByAttributes(array('email' => $this->email)); |
|
| 61 | + |
|
| 62 | + if ($this->_user != NULL) |
|
| 63 | + { |
|
| 64 | + $this->addError('email', Yii::t('ciims.models.RegisterForm', 'That email address is already in use')); |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + return true; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Determines if an username is already taken or not |
|
| 73 | + * @param array $attributes |
|
| 74 | + * @param array $params |
|
| 75 | + * @return boolean |
|
| 76 | + */ |
|
| 77 | + public function isUsernameUnique($attributes, $params) |
|
| 78 | + { |
|
| 79 | + $this->_user = Users::model()->findByAttributes(array('username' => $this->username)); |
|
| 80 | + |
|
| 81 | + if ($this->_user != NULL) |
|
| 82 | + { |
|
| 83 | + $this->addError('username', Yii::t('ciims.models.RegisterForm', 'That username address is already in use')); |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + return true; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Model attribute labels |
|
| 92 | + * @return array |
|
| 93 | + */ |
|
| 94 | + public function attributeLabels() |
|
| 95 | + { |
|
| 96 | + return array( |
|
| 97 | + 'email' => Yii::t('ciims.models.RegisterForm', 'Your Email Address'), |
|
| 98 | + 'password' => Yii::t('ciims.models.RegisterForm', 'Your Password'), |
|
| 99 | + 'password_repeat' => Yii::t('ciims.models.RegisterForm', 'Your Password (again)'), |
|
| 100 | + 'username' => Yii::t('ciims.models.RegisterForm', 'Your Username on the Site') |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * Creates a new user, and sends the appropriate messaging out |
|
| 106 | + * @return boolean |
|
| 107 | + */ |
|
| 108 | + public function save($sendEmail = true) |
|
| 109 | + { |
|
| 110 | + if (!$this->validate()) |
|
| 111 | + return false; |
|
| 112 | + |
|
| 113 | + $this->_user = new Users; |
|
| 114 | + |
|
| 115 | + // Set the model attributes |
|
| 116 | + $this->_user->attributes = array( |
|
| 117 | + 'email' => $this->email, |
|
| 118 | + 'password' => $this->password, |
|
| 119 | + 'username' => $this->username, |
|
| 120 | + 'user_role' => 1, |
|
| 121 | + 'status' => $sendEmail ? Users::PENDING_INVITATION : Users::ACTIVE |
|
| 122 | + ); |
|
| 123 | + |
|
| 124 | + // If we saved the user model, return true |
|
| 125 | + if($this->_user->save()) |
|
| 126 | + { |
|
| 127 | + // This class my be extended by other modules, in which case we don't need to send an activation form if we don't want need it to. |
|
| 128 | + if ($sendEmail) |
|
| 129 | + { |
|
| 130 | + $meta = new UserMetadata; |
|
| 131 | + $meta->attributes = array( |
|
| 132 | + 'user_id' => $this->_user->id, |
|
| 133 | + 'key' => 'activationKey', |
|
| 134 | + 'value' => Cii::generateSafeHash() |
|
| 135 | + ); |
|
| 136 | 136 | |
| 137 | - $meta->save(); |
|
| 137 | + $meta->save(); |
|
| 138 | 138 | |
| 139 | - // Send the registration email |
|
| 140 | - $emailSettings = new EmailSettings; |
|
| 141 | - $emailSettings->send($this->_user, Yii::t('ciims.email','Activate Your Account'), 'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.register', array('user' => $this->_user, 'hash' => $meta->value), true, true); |
|
| 142 | - } |
|
| 139 | + // Send the registration email |
|
| 140 | + $emailSettings = new EmailSettings; |
|
| 141 | + $emailSettings->send($this->_user, Yii::t('ciims.email','Activate Your Account'), 'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.register', array('user' => $this->_user, 'hash' => $meta->value), true, true); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - return true; |
|
| 145 | - } |
|
| 144 | + return true; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - return false; |
|
| 148 | - } |
|
| 147 | + return false; |
|
| 148 | + } |
|
| 149 | 149 | } |
@@ -107,8 +107,9 @@ |
||
| 107 | 107 | */ |
| 108 | 108 | public function save($sendEmail = true) |
| 109 | 109 | { |
| 110 | - if (!$this->validate()) |
|
| 111 | - return false; |
|
| 110 | + if (!$this->validate()) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 112 | 113 | |
| 113 | 114 | $this->_user = new Users; |
| 114 | 115 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * The rules state that username and password are required, |
| 38 | 38 | * and password needs to be authenticated. |
| 39 | 39 | */ |
| 40 | - public function rules() |
|
| 40 | + public function rules () |
|
| 41 | 41 | { |
| 42 | 42 | return array( |
| 43 | 43 | array('email, password, password_repeat, username', 'required'), |
@@ -55,13 +55,13 @@ discard block |
||
| 55 | 55 | * @param array $params |
| 56 | 56 | * @return boolean |
| 57 | 57 | */ |
| 58 | - public function isEmailUnique($attributes, $params) |
|
| 58 | + public function isEmailUnique ($attributes, $params) |
|
| 59 | 59 | { |
| 60 | - $this->_user = Users::model()->findByAttributes(array('email' => $this->email)); |
|
| 60 | + $this->_user = Users::model ()->findByAttributes (array('email' => $this->email)); |
|
| 61 | 61 | |
| 62 | 62 | if ($this->_user != NULL) |
| 63 | 63 | { |
| 64 | - $this->addError('email', Yii::t('ciims.models.RegisterForm', 'That email address is already in use')); |
|
| 64 | + $this->addError ('email', Yii::t ('ciims.models.RegisterForm', 'That email address is already in use')); |
|
| 65 | 65 | return false; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | * @param array $params |
| 75 | 75 | * @return boolean |
| 76 | 76 | */ |
| 77 | - public function isUsernameUnique($attributes, $params) |
|
| 77 | + public function isUsernameUnique ($attributes, $params) |
|
| 78 | 78 | { |
| 79 | - $this->_user = Users::model()->findByAttributes(array('username' => $this->username)); |
|
| 79 | + $this->_user = Users::model ()->findByAttributes (array('username' => $this->username)); |
|
| 80 | 80 | |
| 81 | 81 | if ($this->_user != NULL) |
| 82 | 82 | { |
| 83 | - $this->addError('username', Yii::t('ciims.models.RegisterForm', 'That username address is already in use')); |
|
| 83 | + $this->addError ('username', Yii::t ('ciims.models.RegisterForm', 'That username address is already in use')); |
|
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | * Model attribute labels |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - public function attributeLabels() |
|
| 94 | + public function attributeLabels () |
|
| 95 | 95 | { |
| 96 | 96 | return array( |
| 97 | - 'email' => Yii::t('ciims.models.RegisterForm', 'Your Email Address'), |
|
| 98 | - 'password' => Yii::t('ciims.models.RegisterForm', 'Your Password'), |
|
| 99 | - 'password_repeat' => Yii::t('ciims.models.RegisterForm', 'Your Password (again)'), |
|
| 100 | - 'username' => Yii::t('ciims.models.RegisterForm', 'Your Username on the Site') |
|
| 97 | + 'email' => Yii::t ('ciims.models.RegisterForm', 'Your Email Address'), |
|
| 98 | + 'password' => Yii::t ('ciims.models.RegisterForm', 'Your Password'), |
|
| 99 | + 'password_repeat' => Yii::t ('ciims.models.RegisterForm', 'Your Password (again)'), |
|
| 100 | + 'username' => Yii::t ('ciims.models.RegisterForm', 'Your Username on the Site') |
|
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | * Creates a new user, and sends the appropriate messaging out |
| 106 | 106 | * @return boolean |
| 107 | 107 | */ |
| 108 | - public function save($sendEmail = true) |
|
| 108 | + public function save ($sendEmail = true) |
|
| 109 | 109 | { |
| 110 | - if (!$this->validate()) |
|
| 110 | + if (!$this->validate ()) |
|
| 111 | 111 | return false; |
| 112 | 112 | |
| 113 | 113 | $this->_user = new Users; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | ); |
| 123 | 123 | |
| 124 | 124 | // If we saved the user model, return true |
| 125 | - if($this->_user->save()) |
|
| 125 | + if ($this->_user->save ()) |
|
| 126 | 126 | { |
| 127 | 127 | // This class my be extended by other modules, in which case we don't need to send an activation form if we don't want need it to. |
| 128 | 128 | if ($sendEmail) |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $meta->attributes = array( |
| 132 | 132 | 'user_id' => $this->_user->id, |
| 133 | 133 | 'key' => 'activationKey', |
| 134 | - 'value' => Cii::generateSafeHash() |
|
| 134 | + 'value' => Cii::generateSafeHash () |
|
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $meta->save(); |
|
| 137 | + $meta->save (); |
|
| 138 | 138 | |
| 139 | 139 | // Send the registration email |
| 140 | 140 | $emailSettings = new EmailSettings; |
| 141 | - $emailSettings->send($this->_user, Yii::t('ciims.email','Activate Your Account'), 'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.register', array('user' => $this->_user, 'hash' => $meta->value), true, true); |
|
| 141 | + $emailSettings->send ($this->_user, Yii::t ('ciims.email', 'Activate Your Account'), 'base.themes.'.Cii::getConfig ('theme', 'default').'.views.email.register', array('user' => $this->_user, 'hash' => $meta->value), true, true); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return true; |
@@ -4,62 +4,62 @@ |
||
| 4 | 4 | // Note that you'll need to remove any "undefined" variables in here via stringReplace |
| 5 | 5 | class AnalyticsSettings extends CiiSettingsModel |
| 6 | 6 | {
|
| 7 | - protected $analyticsjs_Google__Analytics_enabled = false; |
|
| 8 | - protected $analyticsjs_Google__Analytics_domain = NULL; |
|
| 9 | - protected $analyticsjs_Google__Analytics_trackingId = NULL; |
|
| 10 | - protected $analyticsjs_Google__Analytics_universalClient = false; |
|
| 11 | - protected $analyticsjs_Google__Analytics_doubleClick = false; |
|
| 12 | - protected $analyticsjs_Google__Analytics_enhancedLinkAttribution = false; |
|
| 7 | + protected $analyticsjs_Google__Analytics_enabled = false; |
|
| 8 | + protected $analyticsjs_Google__Analytics_domain = NULL; |
|
| 9 | + protected $analyticsjs_Google__Analytics_trackingId = NULL; |
|
| 10 | + protected $analyticsjs_Google__Analytics_universalClient = false; |
|
| 11 | + protected $analyticsjs_Google__Analytics_doubleClick = false; |
|
| 12 | + protected $analyticsjs_Google__Analytics_enhancedLinkAttribution = false; |
|
| 13 | 13 | |
| 14 | - protected $analyticsjs_Pingdom_enabled = false; |
|
| 15 | - protected $analyticsjs_Pingdom_id = NULL; |
|
| 14 | + protected $analyticsjs_Pingdom_enabled = false; |
|
| 15 | + protected $analyticsjs_Pingdom_id = NULL; |
|
| 16 | 16 | |
| 17 | - protected $analyticsjs_Piwik_enabled = false; |
|
| 18 | - protected $analyticsjs_Piwik_url = NULL; |
|
| 19 | - protected $analyticsjs_Piwik_siteId = NULL; |
|
| 17 | + protected $analyticsjs_Piwik_enabled = false; |
|
| 18 | + protected $analyticsjs_Piwik_url = NULL; |
|
| 19 | + protected $analyticsjs_Piwik_siteId = NULL; |
|
| 20 | 20 | |
| 21 | - public $form = 'application.modules.dashboard.views.analytics.form'; |
|
| 21 | + public $form = 'application.modules.dashboard.views.analytics.form'; |
|
| 22 | 22 | |
| 23 | - public function groups() |
|
| 24 | - {
|
|
| 25 | - return array( |
|
| 26 | - 'Google Analytics' => array('analyticsjs_Google__Analytics_enabled','analyticsjs_Google__Analytics_domain', 'analyticsjs_Google__Analytics_trackingId', 'analyticsjs_Google__Analytics_universalClient', 'analyticsjs_Google__Analytics_doubleClick', 'analyticsjs_Google__Analytics_enhancedLinkAttribution'),
|
|
| 27 | - 'Pingdom' => array('analyticsjs_Pingdom_enabled', 'analyticsjs_Pingdom_id'),
|
|
| 28 | - 'Piwik' => array('analyticsjs_Piwik_enabled', 'analyticsjs_Piwik_url', 'analyticsjs_Piwik_siteId'),
|
|
| 29 | - ); |
|
| 30 | - } |
|
| 23 | + public function groups() |
|
| 24 | + {
|
|
| 25 | + return array( |
|
| 26 | + 'Google Analytics' => array('analyticsjs_Google__Analytics_enabled','analyticsjs_Google__Analytics_domain', 'analyticsjs_Google__Analytics_trackingId', 'analyticsjs_Google__Analytics_universalClient', 'analyticsjs_Google__Analytics_doubleClick', 'analyticsjs_Google__Analytics_enhancedLinkAttribution'),
|
|
| 27 | + 'Pingdom' => array('analyticsjs_Pingdom_enabled', 'analyticsjs_Pingdom_id'),
|
|
| 28 | + 'Piwik' => array('analyticsjs_Piwik_enabled', 'analyticsjs_Piwik_url', 'analyticsjs_Piwik_siteId'),
|
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function rules() |
|
| 33 | - {
|
|
| 34 | - return array( |
|
| 35 | - array('analyticsjs_Google__Analytics_enabled, analyticsjs_Google__Analytics_universalClient, analyticsjs_Google__Analytics_doubleClick, analyticsjs_Google__Analytics_enhancedLinkAttribution, analyticsjs_Pingdom_enabled, analyticsjs_Piwik_enabled', 'boolean')
|
|
| 36 | - ); |
|
| 37 | - } |
|
| 32 | + public function rules() |
|
| 33 | + {
|
|
| 34 | + return array( |
|
| 35 | + array('analyticsjs_Google__Analytics_enabled, analyticsjs_Google__Analytics_universalClient, analyticsjs_Google__Analytics_doubleClick, analyticsjs_Google__Analytics_enhancedLinkAttribution, analyticsjs_Pingdom_enabled, analyticsjs_Piwik_enabled', 'boolean')
|
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function attributeLabels() |
|
| 40 | - {
|
|
| 41 | - return array( |
|
| 42 | - 'analyticsjs_Google__Analytics_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 43 | - 'analyticsjs_Google__Analytics_domain' => Yii::t('ciims.models.analytics', 'Domain'),
|
|
| 44 | - 'analyticsjs_Google__Analytics_trackingId' => Yii::t('ciims.models.analytics', 'UA Tracking ID'),
|
|
| 45 | - 'analyticsjs_Google__Analytics_universalClient' => Yii::t('ciims.models.analytics', 'Use Universal Client?'),
|
|
| 46 | - 'analyticsjs_Google__Analytics_doubleClick' => Yii::t('ciims.models.analytics', 'DoubleClick'),
|
|
| 47 | - 'analyticsjs_Google__Analytics_enhancedLinkAttribution' => Yii::t('ciims.models.analytics', 'Enhanced Link Attribution'),
|
|
| 39 | + public function attributeLabels() |
|
| 40 | + {
|
|
| 41 | + return array( |
|
| 42 | + 'analyticsjs_Google__Analytics_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 43 | + 'analyticsjs_Google__Analytics_domain' => Yii::t('ciims.models.analytics', 'Domain'),
|
|
| 44 | + 'analyticsjs_Google__Analytics_trackingId' => Yii::t('ciims.models.analytics', 'UA Tracking ID'),
|
|
| 45 | + 'analyticsjs_Google__Analytics_universalClient' => Yii::t('ciims.models.analytics', 'Use Universal Client?'),
|
|
| 46 | + 'analyticsjs_Google__Analytics_doubleClick' => Yii::t('ciims.models.analytics', 'DoubleClick'),
|
|
| 47 | + 'analyticsjs_Google__Analytics_enhancedLinkAttribution' => Yii::t('ciims.models.analytics', 'Enhanced Link Attribution'),
|
|
| 48 | 48 | |
| 49 | - 'analyticsjs_Pingdom_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 50 | - 'analyticsjs_Pingdom_id' => Yii::t('ciims.models.analytics', 'id'),
|
|
| 49 | + 'analyticsjs_Pingdom_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 50 | + 'analyticsjs_Pingdom_id' => Yii::t('ciims.models.analytics', 'id'),
|
|
| 51 | 51 | |
| 52 | - 'analyticsjs_Piwik_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 53 | - 'analyticsjs_Piwik_url' => Yii::t('ciims.models.analytics', 'Piwik Host URL'),
|
|
| 54 | - 'analyticsjs_Piwik_siteId' => Yii::t('ciims.models.analytics', 'Site ID'),
|
|
| 55 | - ); |
|
| 56 | - } |
|
| 52 | + 'analyticsjs_Piwik_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 53 | + 'analyticsjs_Piwik_url' => Yii::t('ciims.models.analytics', 'Piwik Host URL'),
|
|
| 54 | + 'analyticsjs_Piwik_siteId' => Yii::t('ciims.models.analytics', 'Site ID'),
|
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function afterSave() |
|
| 59 | - {
|
|
| 60 | - Yii::app()->cache->set('analyticsjs_providers', false);
|
|
| 61 | - Yii::app()->analytics->getProviders(); |
|
| 58 | + public function afterSave() |
|
| 59 | + {
|
|
| 60 | + Yii::app()->cache->set('analyticsjs_providers', false);
|
|
| 61 | + Yii::app()->analytics->getProviders(); |
|
| 62 | 62 | |
| 63 | - return parent::afterSave(); |
|
| 64 | - } |
|
| 63 | + return parent::afterSave(); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -20,46 +20,46 @@ |
||
| 20 | 20 | |
| 21 | 21 | public $form = 'application.modules.dashboard.views.analytics.form'; |
| 22 | 22 | |
| 23 | - public function groups() |
|
| 23 | + public function groups () |
|
| 24 | 24 | {
|
| 25 | 25 | return array( |
| 26 | - 'Google Analytics' => array('analyticsjs_Google__Analytics_enabled','analyticsjs_Google__Analytics_domain', 'analyticsjs_Google__Analytics_trackingId', 'analyticsjs_Google__Analytics_universalClient', 'analyticsjs_Google__Analytics_doubleClick', 'analyticsjs_Google__Analytics_enhancedLinkAttribution'),
|
|
| 26 | + 'Google Analytics' => array('analyticsjs_Google__Analytics_enabled', 'analyticsjs_Google__Analytics_domain', 'analyticsjs_Google__Analytics_trackingId', 'analyticsjs_Google__Analytics_universalClient', 'analyticsjs_Google__Analytics_doubleClick', 'analyticsjs_Google__Analytics_enhancedLinkAttribution'),
|
|
| 27 | 27 | 'Pingdom' => array('analyticsjs_Pingdom_enabled', 'analyticsjs_Pingdom_id'),
|
| 28 | 28 | 'Piwik' => array('analyticsjs_Piwik_enabled', 'analyticsjs_Piwik_url', 'analyticsjs_Piwik_siteId'),
|
| 29 | 29 | ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function rules() |
|
| 32 | + public function rules () |
|
| 33 | 33 | {
|
| 34 | 34 | return array( |
| 35 | 35 | array('analyticsjs_Google__Analytics_enabled, analyticsjs_Google__Analytics_universalClient, analyticsjs_Google__Analytics_doubleClick, analyticsjs_Google__Analytics_enhancedLinkAttribution, analyticsjs_Pingdom_enabled, analyticsjs_Piwik_enabled', 'boolean')
|
| 36 | 36 | ); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function attributeLabels() |
|
| 39 | + public function attributeLabels () |
|
| 40 | 40 | {
|
| 41 | 41 | return array( |
| 42 | - 'analyticsjs_Google__Analytics_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 43 | - 'analyticsjs_Google__Analytics_domain' => Yii::t('ciims.models.analytics', 'Domain'),
|
|
| 44 | - 'analyticsjs_Google__Analytics_trackingId' => Yii::t('ciims.models.analytics', 'UA Tracking ID'),
|
|
| 45 | - 'analyticsjs_Google__Analytics_universalClient' => Yii::t('ciims.models.analytics', 'Use Universal Client?'),
|
|
| 46 | - 'analyticsjs_Google__Analytics_doubleClick' => Yii::t('ciims.models.analytics', 'DoubleClick'),
|
|
| 47 | - 'analyticsjs_Google__Analytics_enhancedLinkAttribution' => Yii::t('ciims.models.analytics', 'Enhanced Link Attribution'),
|
|
| 42 | + 'analyticsjs_Google__Analytics_enabled' => Yii::t ('ciims.models.analytics', 'Enabled'),
|
|
| 43 | + 'analyticsjs_Google__Analytics_domain' => Yii::t ('ciims.models.analytics', 'Domain'),
|
|
| 44 | + 'analyticsjs_Google__Analytics_trackingId' => Yii::t ('ciims.models.analytics', 'UA Tracking ID'),
|
|
| 45 | + 'analyticsjs_Google__Analytics_universalClient' => Yii::t ('ciims.models.analytics', 'Use Universal Client?'),
|
|
| 46 | + 'analyticsjs_Google__Analytics_doubleClick' => Yii::t ('ciims.models.analytics', 'DoubleClick'),
|
|
| 47 | + 'analyticsjs_Google__Analytics_enhancedLinkAttribution' => Yii::t ('ciims.models.analytics', 'Enhanced Link Attribution'),
|
|
| 48 | 48 | |
| 49 | - 'analyticsjs_Pingdom_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 50 | - 'analyticsjs_Pingdom_id' => Yii::t('ciims.models.analytics', 'id'),
|
|
| 49 | + 'analyticsjs_Pingdom_enabled' => Yii::t ('ciims.models.analytics', 'Enabled'),
|
|
| 50 | + 'analyticsjs_Pingdom_id' => Yii::t ('ciims.models.analytics', 'id'),
|
|
| 51 | 51 | |
| 52 | - 'analyticsjs_Piwik_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
|
| 53 | - 'analyticsjs_Piwik_url' => Yii::t('ciims.models.analytics', 'Piwik Host URL'),
|
|
| 54 | - 'analyticsjs_Piwik_siteId' => Yii::t('ciims.models.analytics', 'Site ID'),
|
|
| 52 | + 'analyticsjs_Piwik_enabled' => Yii::t ('ciims.models.analytics', 'Enabled'),
|
|
| 53 | + 'analyticsjs_Piwik_url' => Yii::t ('ciims.models.analytics', 'Piwik Host URL'),
|
|
| 54 | + 'analyticsjs_Piwik_siteId' => Yii::t ('ciims.models.analytics', 'Site ID'),
|
|
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function afterSave() |
|
| 58 | + public function afterSave () |
|
| 59 | 59 | {
|
| 60 | - Yii::app()->cache->set('analyticsjs_providers', false);
|
|
| 61 | - Yii::app()->analytics->getProviders(); |
|
| 60 | + Yii::app ()->cache->set ('analyticsjs_providers', false);
|
|
| 61 | + Yii::app ()->analytics->getProviders (); |
|
| 62 | 62 | |
| 63 | - return parent::afterSave(); |
|
| 63 | + return parent::afterSave (); |
|
| 64 | 64 | } |
| 65 | 65 | } |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | // See application.modules.dashboard.assets.AnalyticsSettingsBuilder.js for instructions on how to automatically generate this file |
| 4 | 4 | // Note that you'll need to remove any "undefined" variables in here via stringReplace |
| 5 | -class AnalyticsSettings extends CiiSettingsModel |
|
| 6 | -{
|
|
| 5 | +class AnalyticsSettings extends CiiSettingsModel |
|
| 6 | +{ |
|
| 7 | 7 | protected $analyticsjs_Google__Analytics_enabled = false; |
| 8 | 8 | protected $analyticsjs_Google__Analytics_domain = NULL; |
| 9 | 9 | protected $analyticsjs_Google__Analytics_trackingId = NULL; |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public $form = 'application.modules.dashboard.views.analytics.form'; |
| 22 | 22 | |
| 23 | - public function groups() |
|
| 24 | - {
|
|
| 23 | + public function groups() |
|
| 24 | + { |
|
| 25 | 25 | return array( |
| 26 | 26 | 'Google Analytics' => array('analyticsjs_Google__Analytics_enabled','analyticsjs_Google__Analytics_domain', 'analyticsjs_Google__Analytics_trackingId', 'analyticsjs_Google__Analytics_universalClient', 'analyticsjs_Google__Analytics_doubleClick', 'analyticsjs_Google__Analytics_enhancedLinkAttribution'),
|
| 27 | 27 | 'Pingdom' => array('analyticsjs_Pingdom_enabled', 'analyticsjs_Pingdom_id'),
|
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function rules() |
|
| 33 | - {
|
|
| 32 | + public function rules() |
|
| 33 | + { |
|
| 34 | 34 | return array( |
| 35 | 35 | array('analyticsjs_Google__Analytics_enabled, analyticsjs_Google__Analytics_universalClient, analyticsjs_Google__Analytics_doubleClick, analyticsjs_Google__Analytics_enhancedLinkAttribution, analyticsjs_Pingdom_enabled, analyticsjs_Piwik_enabled', 'boolean')
|
| 36 | 36 | ); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function attributeLabels() |
|
| 40 | - {
|
|
| 39 | + public function attributeLabels() |
|
| 40 | + { |
|
| 41 | 41 | return array( |
| 42 | 42 | 'analyticsjs_Google__Analytics_enabled' => Yii::t('ciims.models.analytics', 'Enabled'),
|
| 43 | 43 | 'analyticsjs_Google__Analytics_domain' => Yii::t('ciims.models.analytics', 'Domain'),
|
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function afterSave() |
|
| 59 | - {
|
|
| 58 | + public function afterSave() |
|
| 59 | + { |
|
| 60 | 60 | Yii::app()->cache->set('analyticsjs_providers', false);
|
| 61 | 61 | Yii::app()->analytics->getProviders(); |
| 62 | 62 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class EmailSettings extends CiiSettingsModel |
|
| 4 | -{
|
|
| 3 | +class EmailSettings extends CiiSettingsModel |
|
| 4 | +{ |
|
| 5 | 5 | protected $SMTPHost = NULL; |
| 6 | 6 | |
| 7 | 7 | protected $SMTPPort = NULL; |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | protected $useSSL = 0; |
| 20 | 20 | |
| 21 | - public function rules() |
|
| 22 | - {
|
|
| 21 | + public function rules() |
|
| 22 | + { |
|
| 23 | 23 | return array( |
| 24 | 24 | array('notifyEmail', 'email'),
|
| 25 | 25 | array('useTLS, useSSL', 'boolean'),
|
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function attributeLabels() |
|
| 33 | - {
|
|
| 32 | + public function attributeLabels() |
|
| 33 | + { |
|
| 34 | 34 | return array( |
| 35 | 35 | 'SMTPHost' => Yii::t('ciims.models.email', 'SMTP Hostname'),
|
| 36 | 36 | 'SMTPPort' => Yii::t('ciims.models.email', 'SMTP Port Number'),
|
@@ -58,19 +58,21 @@ discard block |
||
| 58 | 58 | * @param boolean $processOutput Whether the output should be processed. The default is TRUE since this output will be passed to MsgHTML |
| 59 | 59 | * @return boolean Whether or not the email sent sucessfully |
| 60 | 60 | */ |
| 61 | - public function send($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true, $debug=false) |
|
| 62 | - {
|
|
| 61 | + public function send($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true, $debug=false) |
|
| 62 | + { |
|
| 63 | 63 | $mail = new PHPMailer($debug); |
| 64 | 64 | $mail->IsSMTP(); |
| 65 | 65 | $mail->SMTPAuth = false; |
| 66 | 66 | |
| 67 | 67 | $notifyUser = $this->getNotifyUser(isset($content['origin_from']) ? $content['origin_from'] : array()); |
| 68 | 68 | |
| 69 | - if (empty($this->SMTPHost)) |
|
| 70 | - $mail->Host = $this->SMTPHost; |
|
| 69 | + if (empty($this->SMTPHost)) { |
|
| 70 | + $mail->Host = $this->SMTPHost; |
|
| 71 | + } |
|
| 71 | 72 | |
| 72 | - if (empty($this->SMTPPort)) |
|
| 73 | - $mail->Port = $this->SMTPPort; |
|
| 73 | + if (empty($this->SMTPPort)) { |
|
| 74 | + $mail->Port = $this->SMTPPort; |
|
| 75 | + } |
|
| 74 | 76 | |
| 75 | 77 | if (empty($this->SMTPUser)) |
| 76 | 78 | {
|
@@ -78,10 +80,11 @@ discard block |
||
| 78 | 80 | $mail->SMTPAuth = true; |
| 79 | 81 | } |
| 80 | 82 | |
| 81 | - if ($this->useTLS == 1) |
|
| 82 | - $mail->SMTPSecure = 'tls'; |
|
| 83 | - else if ($this->useSSL == 1) |
|
| 84 | - $mail->SMTPSecure = 'ssl'; |
|
| 83 | + if ($this->useTLS == 1) { |
|
| 84 | + $mail->SMTPSecure = 'tls'; |
|
| 85 | + } else if ($this->useSSL == 1) { |
|
| 86 | + $mail->SMTPSecure = 'ssl'; |
|
| 87 | + } |
|
| 85 | 88 | |
| 86 | 89 | if (empty($this->SMTPPass)) |
| 87 | 90 | {
|
@@ -97,13 +100,11 @@ discard block |
||
| 97 | 100 | try |
| 98 | 101 | {
|
| 99 | 102 | return $mail->Send(); |
| 100 | - } |
|
| 101 | - catch (phpmailerException $e) |
|
| 103 | + } catch (phpmailerException $e) |
|
| 102 | 104 | {
|
| 103 | 105 | Yii::log($e->getMessage(), 'info', 'ciims.models.EmailSettings'); |
| 104 | 106 | return false; |
| 105 | - } |
|
| 106 | - catch (Exception $e) |
|
| 107 | + } catch (Exception $e) |
|
| 107 | 108 | {
|
| 108 | 109 | Yii::log($e->getMessage(), 'info', 'ciims.models.EmailSettings'); |
| 109 | 110 | return false; |
@@ -114,19 +115,18 @@ discard block |
||
| 114 | 115 | * Generates a user object |
| 115 | 116 | * @param array $userData |
| 116 | 117 | */ |
| 117 | - private function getNotifyUser($userData=array()) |
|
| 118 | - {
|
|
| 118 | + private function getNotifyUser($userData=array()) |
|
| 119 | + { |
|
| 119 | 120 | $user = new stdClass; |
| 120 | 121 | if (!empty($userData)) |
| 121 | 122 | {
|
| 122 | 123 | $user->email = $userData['email']; |
| 123 | 124 | $user->username = $userData['name']; |
| 124 | - } |
|
| 125 | - else |
|
| 125 | + } else |
|
| 126 | 126 | {
|
| 127 | - if ($this->notifyName === NULL || $this->notifyEmail === NULL) |
|
| 128 | - $user = Users::model()->findByPk(1); |
|
| 129 | - else |
|
| 127 | + if ($this->notifyName === NULL || $this->notifyEmail === NULL) { |
|
| 128 | + $user = Users::model()->findByPk(1); |
|
| 129 | + } else |
|
| 130 | 130 | {
|
| 131 | 131 | $user->email = $this->notifyEmail; |
| 132 | 132 | $user->username = $this->notifyName; |
@@ -145,12 +145,13 @@ discard block |
||
| 145 | 145 | * @return string the rendering result. Null if the rendering result is not required. |
| 146 | 146 | * @throws CException if the view file does not exist |
| 147 | 147 | */ |
| 148 | - private function renderFile($viewFile,$data=null,$return=false) |
|
| 149 | - {
|
|
| 150 | - if(($renderer=Yii::app()->getViewRenderer())!==null && $renderer->fileExtension==='.'.CFileHelper::getExtension($viewFile)) |
|
| 151 | - $content=$renderer->renderFile($this,$viewFile,$data,$return); |
|
| 152 | - else |
|
| 153 | - $content=$this->renderInternal($viewFile,$data,$return); |
|
| 148 | + private function renderFile($viewFile,$data=null,$return=false) |
|
| 149 | + { |
|
| 150 | + if(($renderer=Yii::app()->getViewRenderer())!==null && $renderer->fileExtension==='.'.CFileHelper::getExtension($viewFile)) { |
|
| 151 | + $content=$renderer->renderFile($this,$viewFile,$data,$return); |
|
| 152 | + } else { |
|
| 153 | + $content=$this->renderInternal($viewFile,$data,$return); |
|
| 154 | + } |
|
| 154 | 155 | |
| 155 | 156 | return $content; |
| 156 | 157 | } |
@@ -164,21 +165,22 @@ discard block |
||
| 164 | 165 | * @param boolean $_return_ whether the rendering result should be returned as a string |
| 165 | 166 | * @return string the rendering result. Null if the rendering result is not required. |
| 166 | 167 | */ |
| 167 | - private function renderInternal($_viewFile_,$_data_=null,$_return_=false) |
|
| 168 | - {
|
|
| 168 | + private function renderInternal($_viewFile_,$_data_=null,$_return_=false) |
|
| 169 | + { |
|
| 169 | 170 | // we use special variable names here to avoid conflict when extracting data |
| 170 | - if(is_array($_data_)) |
|
| 171 | - extract($_data_,EXTR_PREFIX_SAME,'data'); |
|
| 172 | - else |
|
| 173 | - $data=$_data_; |
|
| 171 | + if(is_array($_data_)) { |
|
| 172 | + extract($_data_,EXTR_PREFIX_SAME,'data'); |
|
| 173 | + } else { |
|
| 174 | + $data=$_data_; |
|
| 175 | + } |
|
| 174 | 176 | if($_return_) |
| 175 | 177 | {
|
| 176 | 178 | ob_start(); |
| 177 | 179 | ob_implicit_flush(false); |
| 178 | 180 | require($_viewFile_); |
| 179 | 181 | return ob_get_clean(); |
| 180 | - } |
|
| 181 | - else |
|
| 182 | - require($_viewFile_); |
|
| 182 | + } else { |
|
| 183 | + require($_viewFile_); |
|
| 184 | + } |
|
| 183 | 185 | } |
| 184 | 186 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | protected $useSSL = 0; |
| 20 | 20 | |
| 21 | - public function rules() |
|
| 21 | + public function rules () |
|
| 22 | 22 | {
|
| 23 | 23 | return array( |
| 24 | 24 | array('notifyEmail', 'email'),
|
@@ -29,17 +29,17 @@ discard block |
||
| 29 | 29 | ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function attributeLabels() |
|
| 32 | + public function attributeLabels () |
|
| 33 | 33 | {
|
| 34 | 34 | return array( |
| 35 | - 'SMTPHost' => Yii::t('ciims.models.email', 'SMTP Hostname'),
|
|
| 36 | - 'SMTPPort' => Yii::t('ciims.models.email', 'SMTP Port Number'),
|
|
| 37 | - 'SMTPUser' => Yii::t('ciims.models.email', 'SMTP Username'),
|
|
| 38 | - 'SMTPPass' => Yii::t('ciims.models.email', 'SMTP Password'),
|
|
| 39 | - 'useTLS' => Yii::t('ciims.models.email', 'Use TLS Connection'),
|
|
| 40 | - 'useSSL' => Yii::t('ciims.models.email', 'Use SSL Connection'),
|
|
| 41 | - 'notifyName' => Yii::t('ciims.models.email', 'System From Name'),
|
|
| 42 | - 'notifyEmail' => Yii::t('ciims.models.email', 'System Email Address')
|
|
| 35 | + 'SMTPHost' => Yii::t ('ciims.models.email', 'SMTP Hostname'),
|
|
| 36 | + 'SMTPPort' => Yii::t ('ciims.models.email', 'SMTP Port Number'),
|
|
| 37 | + 'SMTPUser' => Yii::t ('ciims.models.email', 'SMTP Username'),
|
|
| 38 | + 'SMTPPass' => Yii::t ('ciims.models.email', 'SMTP Password'),
|
|
| 39 | + 'useTLS' => Yii::t ('ciims.models.email', 'Use TLS Connection'),
|
|
| 40 | + 'useSSL' => Yii::t ('ciims.models.email', 'Use SSL Connection'),
|
|
| 41 | + 'notifyName' => Yii::t ('ciims.models.email', 'System From Name'),
|
|
| 42 | + 'notifyEmail' => Yii::t ('ciims.models.email', 'System Email Address')
|
|
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | * @param boolean $processOutput Whether the output should be processed. The default is TRUE since this output will be passed to MsgHTML |
| 59 | 59 | * @return boolean Whether or not the email sent sucessfully |
| 60 | 60 | */ |
| 61 | - public function send($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true, $debug=false) |
|
| 61 | + public function send ($user, $subject = "", $viewFile, $content = array(), $return = true, $processOutput = true, $debug = false) |
|
| 62 | 62 | {
|
| 63 | - $mail = new PHPMailer($debug); |
|
| 64 | - $mail->IsSMTP(); |
|
| 63 | + $mail = new PHPMailer ($debug); |
|
| 64 | + $mail->IsSMTP (); |
|
| 65 | 65 | $mail->SMTPAuth = false; |
| 66 | 66 | |
| 67 | - $notifyUser = $this->getNotifyUser(isset($content['origin_from']) ? $content['origin_from'] : array()); |
|
| 67 | + $notifyUser = $this->getNotifyUser (isset($content['origin_from']) ? $content['origin_from'] : array()); |
|
| 68 | 68 | |
| 69 | 69 | if (empty($this->SMTPHost)) |
| 70 | 70 | $mail->Host = $this->SMTPHost; |
@@ -85,27 +85,27 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | if (empty($this->SMTPPass)) |
| 87 | 87 | {
|
| 88 | - $mail->Password = Cii::decrypt($this->SMTPPass); |
|
| 88 | + $mail->Password = Cii::decrypt ($this->SMTPPass); |
|
| 89 | 89 | $mail->SMTPAuth = true; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $mail->SetFrom($notifyUser->email, $notifyUser->username); |
|
| 92 | + $mail->SetFrom ($notifyUser->email, $notifyUser->username); |
|
| 93 | 93 | $mail->Subject = $subject; |
| 94 | - $mail->MsgHTML($this->renderFile(Yii::getPathOfAlias($viewFile).'.php', $content, $return, $processOutput)); |
|
| 95 | - $mail->AddAddress($user->email, $user->username); |
|
| 94 | + $mail->MsgHTML ($this->renderFile (Yii::getPathOfAlias ($viewFile).'.php', $content, $return, $processOutput)); |
|
| 95 | + $mail->AddAddress ($user->email, $user->username); |
|
| 96 | 96 | |
| 97 | 97 | try |
| 98 | 98 | {
|
| 99 | - return $mail->Send(); |
|
| 99 | + return $mail->Send (); |
|
| 100 | 100 | } |
| 101 | 101 | catch (phpmailerException $e) |
| 102 | 102 | {
|
| 103 | - Yii::log($e->getMessage(), 'info', 'ciims.models.EmailSettings'); |
|
| 103 | + Yii::log ($e->getMessage (), 'info', 'ciims.models.EmailSettings'); |
|
| 104 | 104 | return false; |
| 105 | 105 | } |
| 106 | 106 | catch (Exception $e) |
| 107 | 107 | {
|
| 108 | - Yii::log($e->getMessage(), 'info', 'ciims.models.EmailSettings'); |
|
| 108 | + Yii::log ($e->getMessage (), 'info', 'ciims.models.EmailSettings'); |
|
| 109 | 109 | return false; |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * Generates a user object |
| 115 | 115 | * @param array $userData |
| 116 | 116 | */ |
| 117 | - private function getNotifyUser($userData=array()) |
|
| 117 | + private function getNotifyUser ($userData = array()) |
|
| 118 | 118 | {
|
| 119 | 119 | $user = new stdClass; |
| 120 | 120 | if (!empty($userData)) |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | else |
| 126 | 126 | {
|
| 127 | 127 | if ($this->notifyName === NULL || $this->notifyEmail === NULL) |
| 128 | - $user = Users::model()->findByPk(1); |
|
| 128 | + $user = Users::model ()->findByPk (1); |
|
| 129 | 129 | else |
| 130 | 130 | {
|
| 131 | 131 | $user->email = $this->notifyEmail; |
@@ -145,12 +145,12 @@ discard block |
||
| 145 | 145 | * @return string the rendering result. Null if the rendering result is not required. |
| 146 | 146 | * @throws CException if the view file does not exist |
| 147 | 147 | */ |
| 148 | - private function renderFile($viewFile,$data=null,$return=false) |
|
| 148 | + private function renderFile ($viewFile, $data = null, $return = false) |
|
| 149 | 149 | {
|
| 150 | - if(($renderer=Yii::app()->getViewRenderer())!==null && $renderer->fileExtension==='.'.CFileHelper::getExtension($viewFile)) |
|
| 151 | - $content=$renderer->renderFile($this,$viewFile,$data,$return); |
|
| 150 | + if (($renderer = Yii::app ()->getViewRenderer ()) !== null && $renderer->fileExtension === '.'.CFileHelper::getExtension ($viewFile)) |
|
| 151 | + $content = $renderer->renderFile ($this, $viewFile, $data, $return); |
|
| 152 | 152 | else |
| 153 | - $content=$this->renderInternal($viewFile,$data,$return); |
|
| 153 | + $content = $this->renderInternal ($viewFile, $data, $return); |
|
| 154 | 154 | |
| 155 | 155 | return $content; |
| 156 | 156 | } |
@@ -164,19 +164,19 @@ discard block |
||
| 164 | 164 | * @param boolean $_return_ whether the rendering result should be returned as a string |
| 165 | 165 | * @return string the rendering result. Null if the rendering result is not required. |
| 166 | 166 | */ |
| 167 | - private function renderInternal($_viewFile_,$_data_=null,$_return_=false) |
|
| 167 | + private function renderInternal ($_viewFile_, $_data_ = null, $_return_ = false) |
|
| 168 | 168 | {
|
| 169 | 169 | // we use special variable names here to avoid conflict when extracting data |
| 170 | - if(is_array($_data_)) |
|
| 171 | - extract($_data_,EXTR_PREFIX_SAME,'data'); |
|
| 170 | + if (is_array ($_data_)) |
|
| 171 | + extract ($_data_, EXTR_PREFIX_SAME, 'data'); |
|
| 172 | 172 | else |
| 173 | - $data=$_data_; |
|
| 174 | - if($_return_) |
|
| 173 | + $data = $_data_; |
|
| 174 | + if ($_return_) |
|
| 175 | 175 | {
|
| 176 | - ob_start(); |
|
| 177 | - ob_implicit_flush(false); |
|
| 176 | + ob_start (); |
|
| 177 | + ob_implicit_flush (false); |
|
| 178 | 178 | require($_viewFile_); |
| 179 | - return ob_get_clean(); |
|
| 179 | + return ob_get_clean (); |
|
| 180 | 180 | } |
| 181 | 181 | else |
| 182 | 182 | require($_viewFile_); |
@@ -2,84 +2,84 @@ |
||
| 2 | 2 | |
| 3 | 3 | class GeneralSettings extends CiiSettingsModel |
| 4 | 4 | {
|
| 5 | - protected $name = NULL; |
|
| 6 | - |
|
| 7 | - protected $dateFormat = 'F jS, Y'; |
|
| 8 | - |
|
| 9 | - protected $timeFormat = 'H:i'; |
|
| 10 | - |
|
| 11 | - protected $defaultLanguage = 'en_US'; |
|
| 12 | - |
|
| 13 | - protected $forceSecureSSL = false; |
|
| 14 | - |
|
| 15 | - protected $bcrypt_cost = 13; |
|
| 16 | - |
|
| 17 | - protected $searchPaginationSize = 10; |
|
| 18 | - |
|
| 19 | - protected $categoryPaginationSize = 10; |
|
| 20 | - |
|
| 21 | - protected $contentPaginationSize = 10; |
|
| 22 | - |
|
| 23 | - protected $useDisqusComments = 0; |
|
| 24 | - |
|
| 25 | - protected $disqus_shortname = NULL; |
|
| 26 | - |
|
| 27 | - //protected $useDiscourseComments = 0; |
|
| 28 | - |
|
| 29 | - //protected $discourseUrl = ''; |
|
| 30 | - |
|
| 31 | - public function groups() |
|
| 32 | - {
|
|
| 33 | - return array( |
|
| 34 | - Yii::t('ciims.models.general', 'Site Settings') => array('name', 'forceSecureSSL', 'bcrypt_cost', 'categoryPaginationSize','contentPaginationSize','searchPaginationSize'),
|
|
| 35 | - Yii::t('ciims.models.general', 'Disqus') => array('useDisqusComments', 'disqus_shortname'),
|
|
| 36 | - //Yii::t('ciims.models.general', 'Discourse') => array('useDiscourseComments', 'discourseUrl'),
|
|
| 37 | - Yii::t('ciims.models.general', 'Display Settings') => array('dateFormat', 'timeFormat', 'defaultLanguage'),
|
|
| 38 | - ); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Validation rules |
|
| 43 | - * @return array |
|
| 44 | - */ |
|
| 45 | - public function rules() |
|
| 46 | - {
|
|
| 47 | - return array( |
|
| 48 | - array('name, dateFormat, timeFormat, defaultLanguage', 'required'),
|
|
| 49 | - array('name', 'length', 'max' => 255),
|
|
| 50 | - array('dateFormat, timeFormat, defaultLanguage', 'length', 'max' => 25),
|
|
| 51 | - array('useDisqusComments, forceSecureSSL', 'boolean'),
|
|
| 52 | - array('disqus_shortname', 'length', 'max' => 255),
|
|
| 53 | - array('bcrypt_cost', 'numerical', 'integerOnly'=>true, 'min' => 13),
|
|
| 54 | - array('searchPaginationSize, categoryPaginationSize, contentPaginationSize', 'numerical', 'integerOnly' => true, 'min' => 10),
|
|
| 55 | - //array('url', 'url')
|
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * Attribute labels |
|
| 61 | - * @return array |
|
| 62 | - */ |
|
| 63 | - public function attributeLabels() |
|
| 64 | - {
|
|
| 65 | - return array( |
|
| 66 | - 'name' => Yii::t('ciims.models.general', 'Site Name'),
|
|
| 67 | - 'dateFormat' => Yii::t('ciims.models.general', 'Date Format'),
|
|
| 68 | - 'timeFormat' => Yii::t('ciims.models.general', 'Time Format'),
|
|
| 69 | - 'defaultLanguage' => Yii::t('ciims.models.general', 'Default Language'),
|
|
| 70 | - 'forceSecureSSL' => Yii::t('ciims.models.general', 'Force SSL for Secure Areas'),
|
|
| 71 | - 'bcrypt_cost' => Yii::t('ciims.models.general', 'Password Strength Settings'),
|
|
| 72 | - 'searchPaginationSize' => Yii::t('ciims.models.general', 'Search Post Count'),
|
|
| 73 | - 'categoryPaginationSize' => Yii::t('ciims.models.general', 'Category Post Count'),
|
|
| 74 | - 'contentPaginationSize' => Yii::t('ciims.models.general', 'Content Post Cost'),
|
|
| 75 | - |
|
| 76 | - // Discourse |
|
| 77 | - 'useDisqusComments' => Yii::t('ciims.models.general', 'Use Disqus Comments'),
|
|
| 78 | - 'disqus_shortname' => Yii::t('ciims.models.general', 'Disqus Shortcode'),
|
|
| 79 | - |
|
| 80 | - // Discourse |
|
| 81 | - //'useDiscourseComments' => Yii::t('ciims.models.general', 'Use Discourse Comments'),
|
|
| 82 | - //'discourseUrl' => Yii::t('ciims.models.general', 'Discourse URL'),
|
|
| 83 | - ); |
|
| 84 | - } |
|
| 5 | + protected $name = NULL; |
|
| 6 | + |
|
| 7 | + protected $dateFormat = 'F jS, Y'; |
|
| 8 | + |
|
| 9 | + protected $timeFormat = 'H:i'; |
|
| 10 | + |
|
| 11 | + protected $defaultLanguage = 'en_US'; |
|
| 12 | + |
|
| 13 | + protected $forceSecureSSL = false; |
|
| 14 | + |
|
| 15 | + protected $bcrypt_cost = 13; |
|
| 16 | + |
|
| 17 | + protected $searchPaginationSize = 10; |
|
| 18 | + |
|
| 19 | + protected $categoryPaginationSize = 10; |
|
| 20 | + |
|
| 21 | + protected $contentPaginationSize = 10; |
|
| 22 | + |
|
| 23 | + protected $useDisqusComments = 0; |
|
| 24 | + |
|
| 25 | + protected $disqus_shortname = NULL; |
|
| 26 | + |
|
| 27 | + //protected $useDiscourseComments = 0; |
|
| 28 | + |
|
| 29 | + //protected $discourseUrl = ''; |
|
| 30 | + |
|
| 31 | + public function groups() |
|
| 32 | + {
|
|
| 33 | + return array( |
|
| 34 | + Yii::t('ciims.models.general', 'Site Settings') => array('name', 'forceSecureSSL', 'bcrypt_cost', 'categoryPaginationSize','contentPaginationSize','searchPaginationSize'),
|
|
| 35 | + Yii::t('ciims.models.general', 'Disqus') => array('useDisqusComments', 'disqus_shortname'),
|
|
| 36 | + //Yii::t('ciims.models.general', 'Discourse') => array('useDiscourseComments', 'discourseUrl'),
|
|
| 37 | + Yii::t('ciims.models.general', 'Display Settings') => array('dateFormat', 'timeFormat', 'defaultLanguage'),
|
|
| 38 | + ); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Validation rules |
|
| 43 | + * @return array |
|
| 44 | + */ |
|
| 45 | + public function rules() |
|
| 46 | + {
|
|
| 47 | + return array( |
|
| 48 | + array('name, dateFormat, timeFormat, defaultLanguage', 'required'),
|
|
| 49 | + array('name', 'length', 'max' => 255),
|
|
| 50 | + array('dateFormat, timeFormat, defaultLanguage', 'length', 'max' => 25),
|
|
| 51 | + array('useDisqusComments, forceSecureSSL', 'boolean'),
|
|
| 52 | + array('disqus_shortname', 'length', 'max' => 255),
|
|
| 53 | + array('bcrypt_cost', 'numerical', 'integerOnly'=>true, 'min' => 13),
|
|
| 54 | + array('searchPaginationSize, categoryPaginationSize, contentPaginationSize', 'numerical', 'integerOnly' => true, 'min' => 10),
|
|
| 55 | + //array('url', 'url')
|
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * Attribute labels |
|
| 61 | + * @return array |
|
| 62 | + */ |
|
| 63 | + public function attributeLabels() |
|
| 64 | + {
|
|
| 65 | + return array( |
|
| 66 | + 'name' => Yii::t('ciims.models.general', 'Site Name'),
|
|
| 67 | + 'dateFormat' => Yii::t('ciims.models.general', 'Date Format'),
|
|
| 68 | + 'timeFormat' => Yii::t('ciims.models.general', 'Time Format'),
|
|
| 69 | + 'defaultLanguage' => Yii::t('ciims.models.general', 'Default Language'),
|
|
| 70 | + 'forceSecureSSL' => Yii::t('ciims.models.general', 'Force SSL for Secure Areas'),
|
|
| 71 | + 'bcrypt_cost' => Yii::t('ciims.models.general', 'Password Strength Settings'),
|
|
| 72 | + 'searchPaginationSize' => Yii::t('ciims.models.general', 'Search Post Count'),
|
|
| 73 | + 'categoryPaginationSize' => Yii::t('ciims.models.general', 'Category Post Count'),
|
|
| 74 | + 'contentPaginationSize' => Yii::t('ciims.models.general', 'Content Post Cost'),
|
|
| 75 | + |
|
| 76 | + // Discourse |
|
| 77 | + 'useDisqusComments' => Yii::t('ciims.models.general', 'Use Disqus Comments'),
|
|
| 78 | + 'disqus_shortname' => Yii::t('ciims.models.general', 'Disqus Shortcode'),
|
|
| 79 | + |
|
| 80 | + // Discourse |
|
| 81 | + //'useDiscourseComments' => Yii::t('ciims.models.general', 'Use Discourse Comments'),
|
|
| 82 | + //'discourseUrl' => Yii::t('ciims.models.general', 'Discourse URL'),
|
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | 85 | } |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | //protected $discourseUrl = ''; |
| 30 | 30 | |
| 31 | - public function groups() |
|
| 31 | + public function groups () |
|
| 32 | 32 | {
|
| 33 | 33 | return array( |
| 34 | - Yii::t('ciims.models.general', 'Site Settings') => array('name', 'forceSecureSSL', 'bcrypt_cost', 'categoryPaginationSize','contentPaginationSize','searchPaginationSize'),
|
|
| 35 | - Yii::t('ciims.models.general', 'Disqus') => array('useDisqusComments', 'disqus_shortname'),
|
|
| 34 | + Yii::t ('ciims.models.general', 'Site Settings') => array('name', 'forceSecureSSL', 'bcrypt_cost', 'categoryPaginationSize', 'contentPaginationSize', 'searchPaginationSize'),
|
|
| 35 | + Yii::t ('ciims.models.general', 'Disqus') => array('useDisqusComments', 'disqus_shortname'),
|
|
| 36 | 36 | //Yii::t('ciims.models.general', 'Discourse') => array('useDiscourseComments', 'discourseUrl'),
|
| 37 | - Yii::t('ciims.models.general', 'Display Settings') => array('dateFormat', 'timeFormat', 'defaultLanguage'),
|
|
| 37 | + Yii::t ('ciims.models.general', 'Display Settings') => array('dateFormat', 'timeFormat', 'defaultLanguage'),
|
|
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * Validation rules |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function rules() |
|
| 45 | + public function rules () |
|
| 46 | 46 | {
|
| 47 | 47 | return array( |
| 48 | 48 | array('name, dateFormat, timeFormat, defaultLanguage', 'required'),
|
@@ -60,22 +60,22 @@ discard block |
||
| 60 | 60 | * Attribute labels |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function attributeLabels() |
|
| 63 | + public function attributeLabels () |
|
| 64 | 64 | {
|
| 65 | 65 | return array( |
| 66 | - 'name' => Yii::t('ciims.models.general', 'Site Name'),
|
|
| 67 | - 'dateFormat' => Yii::t('ciims.models.general', 'Date Format'),
|
|
| 68 | - 'timeFormat' => Yii::t('ciims.models.general', 'Time Format'),
|
|
| 69 | - 'defaultLanguage' => Yii::t('ciims.models.general', 'Default Language'),
|
|
| 70 | - 'forceSecureSSL' => Yii::t('ciims.models.general', 'Force SSL for Secure Areas'),
|
|
| 71 | - 'bcrypt_cost' => Yii::t('ciims.models.general', 'Password Strength Settings'),
|
|
| 72 | - 'searchPaginationSize' => Yii::t('ciims.models.general', 'Search Post Count'),
|
|
| 73 | - 'categoryPaginationSize' => Yii::t('ciims.models.general', 'Category Post Count'),
|
|
| 74 | - 'contentPaginationSize' => Yii::t('ciims.models.general', 'Content Post Cost'),
|
|
| 66 | + 'name' => Yii::t ('ciims.models.general', 'Site Name'),
|
|
| 67 | + 'dateFormat' => Yii::t ('ciims.models.general', 'Date Format'),
|
|
| 68 | + 'timeFormat' => Yii::t ('ciims.models.general', 'Time Format'),
|
|
| 69 | + 'defaultLanguage' => Yii::t ('ciims.models.general', 'Default Language'),
|
|
| 70 | + 'forceSecureSSL' => Yii::t ('ciims.models.general', 'Force SSL for Secure Areas'),
|
|
| 71 | + 'bcrypt_cost' => Yii::t ('ciims.models.general', 'Password Strength Settings'),
|
|
| 72 | + 'searchPaginationSize' => Yii::t ('ciims.models.general', 'Search Post Count'),
|
|
| 73 | + 'categoryPaginationSize' => Yii::t ('ciims.models.general', 'Category Post Count'),
|
|
| 74 | + 'contentPaginationSize' => Yii::t ('ciims.models.general', 'Content Post Cost'),
|
|
| 75 | 75 | |
| 76 | 76 | // Discourse |
| 77 | - 'useDisqusComments' => Yii::t('ciims.models.general', 'Use Disqus Comments'),
|
|
| 78 | - 'disqus_shortname' => Yii::t('ciims.models.general', 'Disqus Shortcode'),
|
|
| 77 | + 'useDisqusComments' => Yii::t ('ciims.models.general', 'Use Disqus Comments'),
|
|
| 78 | + 'disqus_shortname' => Yii::t ('ciims.models.general', 'Disqus Shortcode'),
|
|
| 79 | 79 | |
| 80 | 80 | // Discourse |
| 81 | 81 | //'useDiscourseComments' => Yii::t('ciims.models.general', 'Use Discourse Comments'),
|
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class GeneralSettings extends CiiSettingsModel |
|
| 4 | -{
|
|
| 3 | +class GeneralSettings extends CiiSettingsModel |
|
| 4 | +{ |
|
| 5 | 5 | protected $name = NULL; |
| 6 | 6 | |
| 7 | 7 | protected $dateFormat = 'F jS, Y'; |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | //protected $discourseUrl = ''; |
| 30 | 30 | |
| 31 | - public function groups() |
|
| 32 | - {
|
|
| 31 | + public function groups() |
|
| 32 | + { |
|
| 33 | 33 | return array( |
| 34 | 34 | Yii::t('ciims.models.general', 'Site Settings') => array('name', 'forceSecureSSL', 'bcrypt_cost', 'categoryPaginationSize','contentPaginationSize','searchPaginationSize'),
|
| 35 | 35 | Yii::t('ciims.models.general', 'Disqus') => array('useDisqusComments', 'disqus_shortname'),
|
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * Validation rules |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function rules() |
|
| 46 | - {
|
|
| 45 | + public function rules() |
|
| 46 | + { |
|
| 47 | 47 | return array( |
| 48 | 48 | array('name, dateFormat, timeFormat, defaultLanguage', 'required'),
|
| 49 | 49 | array('name', 'length', 'max' => 255),
|
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * Attribute labels |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function attributeLabels() |
|
| 64 | - {
|
|
| 63 | + public function attributeLabels() |
|
| 64 | + { |
|
| 65 | 65 | return array( |
| 66 | 66 | 'name' => Yii::t('ciims.models.general', 'Site Name'),
|
| 67 | 67 | 'dateFormat' => Yii::t('ciims.models.general', 'Date Format'),
|