Completed
Push — master ( 2a7b74...14dab9 )
by Charles
13:24 queued 10:36
created
protected/models/forms/PasswordResetForm.php 3 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -2,125 +2,125 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
protected/models/forms/ProfileForm.php 3 patches
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -2,317 +2,317 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,11 +54,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		);
Please login to merge, or discard this patch.
protected/models/forms/RegisterForm.php 3 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -2,148 +2,148 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
protected/models/settings/AnalyticsSettings.php 3 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -4,62 +4,62 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -20,46 +20,46 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
protected/models/settings/EmailSettings.php 2 patches
Braces   +44 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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_);
Please login to merge, or discard this patch.
protected/models/settings/GeneralSettings.php 3 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -2,84 +2,84 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'),
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'),
Please login to merge, or discard this patch.
protected/models/settings/SocialSettings.php 2 patches
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -2,85 +2,85 @@
 block discarded – undo
2 2
 
3 3
 class SocialSettings extends CiiSettingsModel
4 4
 {
5
-	protected $ha_twitter_enabled = false;
6
-	protected $ha_twitter_key = NULL;
7
-	protected $ha_twitter_secret = NULL;
8
-	protected $ha_twitter_accessToken = NULL;
9
-	protected $ha_twitter_accessTokenSecret = NULL;
5
+    protected $ha_twitter_enabled = false;
6
+    protected $ha_twitter_key = NULL;
7
+    protected $ha_twitter_secret = NULL;
8
+    protected $ha_twitter_accessToken = NULL;
9
+    protected $ha_twitter_accessTokenSecret = NULL;
10 10
 
11
-	protected $ha_facebook_enabled = false;
12
-	protected $ha_facebook_id = NULL;
13
-	protected $ha_facebook_secret = NULL;
14
-	protected $ha_facebook_scope =  NULL;
11
+    protected $ha_facebook_enabled = false;
12
+    protected $ha_facebook_id = NULL;
13
+    protected $ha_facebook_secret = NULL;
14
+    protected $ha_facebook_scope =  NULL;
15 15
 
16
-	protected $ha_google_enabled = false;
17
-	protected $ha_google_id = NULL;
18
-	protected $ha_google_secret = NULL;
19
-	protected $ha_google_scope = NULL;
20
-	protected $google_plus_public_server_key = NULL;
16
+    protected $ha_google_enabled = false;
17
+    protected $ha_google_id = NULL;
18
+    protected $ha_google_secret = NULL;
19
+    protected $ha_google_scope = NULL;
20
+    protected $google_plus_public_server_key = NULL;
21 21
 
22
-	protected $ha_linkedin_enabled = false;
23
-	protected $ha_linkedin_key = NULL;
24
-	protected $ha_linkedin_secret = NULL;
22
+    protected $ha_linkedin_enabled = false;
23
+    protected $ha_linkedin_key = NULL;
24
+    protected $ha_linkedin_secret = NULL;
25 25
 
26
-	protected $addThisPublisherID = null;
26
+    protected $addThisPublisherID = null;
27 27
 
28
-	public function groups()
29
-	{
30
-		return array(
31
-			Yii::t('ciims.models.social', 'Twitter')  => array('ha_twitter_enabled', 'ha_twitter_key', 'ha_twitter_secret', 'ha_twitter_accessToken', 'ha_twitter_accessTokenSecret'),
32
-			Yii::t('ciims.models.social', 'Facebook') => array('ha_facebook_enabled', 'ha_facebook_id', 'ha_facebook_secret', 'ha_facebook_scope'),
33
-			Yii::t('ciims.models.social', 'Google+')  => array('ha_google_enabled', 'ha_google_id', 'ha_google_secret', 'ha_google_scope', 'google_plus_public_server_key'),
34
-			Yii::t('ciims.models.social', 'LinkedIn') => array('ha_linkedin_enabled', 'ha_linkedin_key', 'ha_linkedin_secret'),
35
-			Yii::t('ciims.models.social', 'AddThis') => array('addThisPublisherID')
36
-		);
37
-	}
28
+    public function groups()
29
+    {
30
+        return array(
31
+            Yii::t('ciims.models.social', 'Twitter')  => array('ha_twitter_enabled', 'ha_twitter_key', 'ha_twitter_secret', 'ha_twitter_accessToken', 'ha_twitter_accessTokenSecret'),
32
+            Yii::t('ciims.models.social', 'Facebook') => array('ha_facebook_enabled', 'ha_facebook_id', 'ha_facebook_secret', 'ha_facebook_scope'),
33
+            Yii::t('ciims.models.social', 'Google+')  => array('ha_google_enabled', 'ha_google_id', 'ha_google_secret', 'ha_google_scope', 'google_plus_public_server_key'),
34
+            Yii::t('ciims.models.social', 'LinkedIn') => array('ha_linkedin_enabled', 'ha_linkedin_key', 'ha_linkedin_secret'),
35
+            Yii::t('ciims.models.social', 'AddThis') => array('addThisPublisherID')
36
+        );
37
+    }
38 38
 
39
-	public function rules()
40
-	{
41
-		return array(
42
-			array('ha_twitter_key, ha_twitter_secret, ha_twitter_accessToken, ha_twitter_accessToken, ha_twitter_accessTokenSecret', 'length', 'max' => 255),
43
-			array('ha_facebook_id, ha_facebook_secret', 'length', 'max' => 255),
44
-			array('ha_google_id, ha_google_secret, google_plus_public_server_key', 'length', 'max' => 255),
45
-			array('ha_linkedin_key, ha_linkedin_secret', 'length', 'max' => 255),
46
-			array('ha_twitter_enabled, ha_facebook_enabled, ha_google_enabled, ha_linkedin_enabled', 'boolean'),
47
-			array('addThisPublisherID', 'length', 'max' => 255)
48
-		);
49
-	}
39
+    public function rules()
40
+    {
41
+        return array(
42
+            array('ha_twitter_key, ha_twitter_secret, ha_twitter_accessToken, ha_twitter_accessToken, ha_twitter_accessTokenSecret', 'length', 'max' => 255),
43
+            array('ha_facebook_id, ha_facebook_secret', 'length', 'max' => 255),
44
+            array('ha_google_id, ha_google_secret, google_plus_public_server_key', 'length', 'max' => 255),
45
+            array('ha_linkedin_key, ha_linkedin_secret', 'length', 'max' => 255),
46
+            array('ha_twitter_enabled, ha_facebook_enabled, ha_google_enabled, ha_linkedin_enabled', 'boolean'),
47
+            array('addThisPublisherID', 'length', 'max' => 255)
48
+        );
49
+    }
50 50
 
51
-	public function attributeLabels()
52
-	{
53
-		return array(
54
-			'ha_twitter_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
55
-			'ha_twitter_key' => Yii::t('ciims.models.social', 'Consumer Key'),
56
-			'ha_twitter_secret' => Yii::t('ciims.models.social', 'Consumer Secret'),
57
-			'ha_twitter_accessToken' => Yii::t('ciims.models.social', 'Access Token'),
58
-			'ha_twitter_accessTokenSecret' => Yii::t('ciims.models.social', 'Access Token Secret'),
51
+    public function attributeLabels()
52
+    {
53
+        return array(
54
+            'ha_twitter_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
55
+            'ha_twitter_key' => Yii::t('ciims.models.social', 'Consumer Key'),
56
+            'ha_twitter_secret' => Yii::t('ciims.models.social', 'Consumer Secret'),
57
+            'ha_twitter_accessToken' => Yii::t('ciims.models.social', 'Access Token'),
58
+            'ha_twitter_accessTokenSecret' => Yii::t('ciims.models.social', 'Access Token Secret'),
59 59
 
60
-			'ha_facebook_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
61
-			'ha_facebook_id' => Yii::t('ciims.models.social', 'App ID'),
62
-			'ha_facebook_secret' => Yii::t('ciims.models.social', 'App Secret'),
63
-			'ha_facebook_scope' => Yii::t('ciims.models.social', 'Scope'),
60
+            'ha_facebook_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
61
+            'ha_facebook_id' => Yii::t('ciims.models.social', 'App ID'),
62
+            'ha_facebook_secret' => Yii::t('ciims.models.social', 'App Secret'),
63
+            'ha_facebook_scope' => Yii::t('ciims.models.social', 'Scope'),
64 64
 
65
-			'ha_google_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
66
-			'ha_google_id' => Yii::t('ciims.models.social', 'Client ID'),
67
-			'ha_google_secret' => Yii::t('ciims.models.social', 'Client Secret'),
68
-			'ha_google_scope' => Yii::t('ciims.models.social', 'Scope'),
69
-			'google_plus_public_server_key' => Yii::t('ciims.models.social', 'Public Server API Key'),
65
+            'ha_google_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
66
+            'ha_google_id' => Yii::t('ciims.models.social', 'Client ID'),
67
+            'ha_google_secret' => Yii::t('ciims.models.social', 'Client Secret'),
68
+            'ha_google_scope' => Yii::t('ciims.models.social', 'Scope'),
69
+            'google_plus_public_server_key' => Yii::t('ciims.models.social', 'Public Server API Key'),
70 70
 
71
-			'ha_linkedin_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
72
-			'ha_linkedin_key' => Yii::t('ciims.models.social', 'Consumer Key'),
73
-			'ha_linkedin_secret' => Yii::t('ciims.models.social', 'Consumer Secret'),
71
+            'ha_linkedin_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
72
+            'ha_linkedin_key' => Yii::t('ciims.models.social', 'Consumer Key'),
73
+            'ha_linkedin_secret' => Yii::t('ciims.models.social', 'Consumer Secret'),
74 74
 
75
-			'addThisPublisherID' => Yii::t('ciims.models.social', 'AddThis Publisher ID')
76
-		);
77
-	}
75
+            'addThisPublisherID' => Yii::t('ciims.models.social', 'AddThis Publisher ID')
76
+        );
77
+    }
78 78
 
79
-	public function afterSave()
80
-	{
81
-		Yii::app()->cache->set('hybridauth_providers', false);
82
-		Cii::getHybridAuthProviders();
79
+    public function afterSave()
80
+    {
81
+        Yii::app()->cache->set('hybridauth_providers', false);
82
+        Cii::getHybridAuthProviders();
83 83
 
84
-		return parent::afterSave();
85
-	}
84
+        return parent::afterSave();
85
+    }
86 86
 }
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	protected $ha_facebook_enabled = false;
12 12
 	protected $ha_facebook_id = NULL;
13 13
 	protected $ha_facebook_secret = NULL;
14
-	protected $ha_facebook_scope =  NULL;
14
+	protected $ha_facebook_scope = NULL;
15 15
 
16 16
 	protected $ha_google_enabled = false;
17 17
 	protected $ha_google_id = NULL;
@@ -25,18 +25,18 @@  discard block
 block discarded – undo
25 25
 
26 26
 	protected $addThisPublisherID = null;
27 27
 
28
-	public function groups()
28
+	public function groups ()
29 29
 	{
30 30
 		return array(
31
-			Yii::t('ciims.models.social', 'Twitter')  => array('ha_twitter_enabled', 'ha_twitter_key', 'ha_twitter_secret', 'ha_twitter_accessToken', 'ha_twitter_accessTokenSecret'),
32
-			Yii::t('ciims.models.social', 'Facebook') => array('ha_facebook_enabled', 'ha_facebook_id', 'ha_facebook_secret', 'ha_facebook_scope'),
33
-			Yii::t('ciims.models.social', 'Google+')  => array('ha_google_enabled', 'ha_google_id', 'ha_google_secret', 'ha_google_scope', 'google_plus_public_server_key'),
34
-			Yii::t('ciims.models.social', 'LinkedIn') => array('ha_linkedin_enabled', 'ha_linkedin_key', 'ha_linkedin_secret'),
35
-			Yii::t('ciims.models.social', 'AddThis') => array('addThisPublisherID')
31
+			Yii::t ('ciims.models.social', 'Twitter')  => array('ha_twitter_enabled', 'ha_twitter_key', 'ha_twitter_secret', 'ha_twitter_accessToken', 'ha_twitter_accessTokenSecret'),
32
+			Yii::t ('ciims.models.social', 'Facebook') => array('ha_facebook_enabled', 'ha_facebook_id', 'ha_facebook_secret', 'ha_facebook_scope'),
33
+			Yii::t ('ciims.models.social', 'Google+')  => array('ha_google_enabled', 'ha_google_id', 'ha_google_secret', 'ha_google_scope', 'google_plus_public_server_key'),
34
+			Yii::t ('ciims.models.social', 'LinkedIn') => array('ha_linkedin_enabled', 'ha_linkedin_key', 'ha_linkedin_secret'),
35
+			Yii::t ('ciims.models.social', 'AddThis') => array('addThisPublisherID')
36 36
 		);
37 37
 	}
38 38
 
39
-	public function rules()
39
+	public function rules ()
40 40
 	{
41 41
 		return array(
42 42
 			array('ha_twitter_key, ha_twitter_secret, ha_twitter_accessToken, ha_twitter_accessToken, ha_twitter_accessTokenSecret', 'length', 'max' => 255),
@@ -48,39 +48,39 @@  discard block
 block discarded – undo
48 48
 		);
49 49
 	}
50 50
 
51
-	public function attributeLabels()
51
+	public function attributeLabels ()
52 52
 	{
53 53
 		return array(
54
-			'ha_twitter_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
55
-			'ha_twitter_key' => Yii::t('ciims.models.social', 'Consumer Key'),
56
-			'ha_twitter_secret' => Yii::t('ciims.models.social', 'Consumer Secret'),
57
-			'ha_twitter_accessToken' => Yii::t('ciims.models.social', 'Access Token'),
58
-			'ha_twitter_accessTokenSecret' => Yii::t('ciims.models.social', 'Access Token Secret'),
54
+			'ha_twitter_enabled' => Yii::t ('ciims.models.social', 'Social Auth'),
55
+			'ha_twitter_key' => Yii::t ('ciims.models.social', 'Consumer Key'),
56
+			'ha_twitter_secret' => Yii::t ('ciims.models.social', 'Consumer Secret'),
57
+			'ha_twitter_accessToken' => Yii::t ('ciims.models.social', 'Access Token'),
58
+			'ha_twitter_accessTokenSecret' => Yii::t ('ciims.models.social', 'Access Token Secret'),
59 59
 
60
-			'ha_facebook_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
61
-			'ha_facebook_id' => Yii::t('ciims.models.social', 'App ID'),
62
-			'ha_facebook_secret' => Yii::t('ciims.models.social', 'App Secret'),
63
-			'ha_facebook_scope' => Yii::t('ciims.models.social', 'Scope'),
60
+			'ha_facebook_enabled' => Yii::t ('ciims.models.social', 'Social Auth'),
61
+			'ha_facebook_id' => Yii::t ('ciims.models.social', 'App ID'),
62
+			'ha_facebook_secret' => Yii::t ('ciims.models.social', 'App Secret'),
63
+			'ha_facebook_scope' => Yii::t ('ciims.models.social', 'Scope'),
64 64
 
65
-			'ha_google_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
66
-			'ha_google_id' => Yii::t('ciims.models.social', 'Client ID'),
67
-			'ha_google_secret' => Yii::t('ciims.models.social', 'Client Secret'),
68
-			'ha_google_scope' => Yii::t('ciims.models.social', 'Scope'),
69
-			'google_plus_public_server_key' => Yii::t('ciims.models.social', 'Public Server API Key'),
65
+			'ha_google_enabled' => Yii::t ('ciims.models.social', 'Social Auth'),
66
+			'ha_google_id' => Yii::t ('ciims.models.social', 'Client ID'),
67
+			'ha_google_secret' => Yii::t ('ciims.models.social', 'Client Secret'),
68
+			'ha_google_scope' => Yii::t ('ciims.models.social', 'Scope'),
69
+			'google_plus_public_server_key' => Yii::t ('ciims.models.social', 'Public Server API Key'),
70 70
 
71
-			'ha_linkedin_enabled' => Yii::t('ciims.models.social', 'Social Auth'),
72
-			'ha_linkedin_key' => Yii::t('ciims.models.social', 'Consumer Key'),
73
-			'ha_linkedin_secret' => Yii::t('ciims.models.social', 'Consumer Secret'),
71
+			'ha_linkedin_enabled' => Yii::t ('ciims.models.social', 'Social Auth'),
72
+			'ha_linkedin_key' => Yii::t ('ciims.models.social', 'Consumer Key'),
73
+			'ha_linkedin_secret' => Yii::t ('ciims.models.social', 'Consumer Secret'),
74 74
 
75
-			'addThisPublisherID' => Yii::t('ciims.models.social', 'AddThis Publisher ID')
75
+			'addThisPublisherID' => Yii::t ('ciims.models.social', 'AddThis Publisher ID')
76 76
 		);
77 77
 	}
78 78
 
79
-	public function afterSave()
79
+	public function afterSave ()
80 80
 	{
81
-		Yii::app()->cache->set('hybridauth_providers', false);
82
-		Cii::getHybridAuthProviders();
81
+		Yii::app ()->cache->set ('hybridauth_providers', false);
82
+		Cii::getHybridAuthProviders ();
83 83
 
84
-		return parent::afterSave();
84
+		return parent::afterSave ();
85 85
 	}
86 86
 }
Please login to merge, or discard this patch.
protected/models/settings/ThemeSettings.php 3 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -2,92 +2,92 @@
 block discarded – undo
2 2
 
3 3
 class ThemeSettings extends CiiSettingsModel
4 4
 {
5
-	/**
6
-	 * The active theme
7
-	 * @var string
8
-	 */
9
-	public $theme = 'default';
5
+    /**
6
+     * The active theme
7
+     * @var string
8
+     */
9
+    public $theme = 'default';
10 10
 
11
-	/**
12
-	 * Validation rules for the theme
13
-	 * @return array
14
-	 */
15
-	public function rules()
16
-	{
17
-		return array(
18
-			array('theme', 'required'),
19
-			array('theme', 'length', 'max' => 255)
20
-		);
21
-	}
11
+    /**
12
+     * Validation rules for the theme
13
+     * @return array
14
+     */
15
+    public function rules()
16
+    {
17
+        return array(
18
+            array('theme', 'required'),
19
+            array('theme', 'length', 'max' => 255)
20
+        );
21
+    }
22 22
 
23
-	/**
24
-	 * Attribute labels for themes
25
-	 * @return array
26
-	 */
27
-	public function attributeLabels()
28
-	{
29
-		return array(
30
-			'theme' => Yii::t('ciims.models.theme', 'Theme'),
31
-		);
32
-	}
23
+    /**
24
+     * Attribute labels for themes
25
+     * @return array
26
+     */
27
+    public function attributeLabels()
28
+    {
29
+        return array(
30
+            'theme' => Yii::t('ciims.models.theme', 'Theme'),
31
+        );
32
+    }
33 33
 
34
-	/**
35
-	 * Returns the active theme name
36
-	 * @return string
37
-	 */
38
-	public function getTheme()
39
-	{
40
-		return $this->theme;
41
-	}
34
+    /**
35
+     * Returns the active theme name
36
+     * @return string
37
+     */
38
+    public function getTheme()
39
+    {
40
+        return $this->theme;
41
+    }
42 42
 
43
-	/**
44
-	 * Retrieves all of the themes from webroot.themes and returns them in an array group by type, each containing
45
-	 * the contents of theme.json.
46
-	 *
47
-	 * The themes are then cached for easy retrieval later. (I really hate unecessary DiskIO if something isn't changing...)
48
-	 *
49
-	 * @return array
50
-	 */
51
-	public function getThemes()
52
-	{
53
-		$themes = Yii::app()->cache->get('settings_themes');
43
+    /**
44
+     * Retrieves all of the themes from webroot.themes and returns them in an array group by type, each containing
45
+     * the contents of theme.json.
46
+     *
47
+     * The themes are then cached for easy retrieval later. (I really hate unecessary DiskIO if something isn't changing...)
48
+     *
49
+     * @return array
50
+     */
51
+    public function getThemes()
52
+    {
53
+        $themes = Yii::app()->cache->get('settings_themes');
54 54
 
55
-		if ($themes == false)
56
-		{
57
-			$themes = array();
58
-			$currentTheme = Cii::getConfig('theme');
59
-			$themePath = Yii::getPathOfAlias('base.themes') . DS;
60
-			$directories = glob($themePath . "*", GLOB_ONLYDIR);
55
+        if ($themes == false)
56
+        {
57
+            $themes = array();
58
+            $currentTheme = Cii::getConfig('theme');
59
+            $themePath = Yii::getPathOfAlias('base.themes') . DS;
60
+            $directories = glob($themePath . "*", GLOB_ONLYDIR);
61 61
 
62
-			// Pushes the current theme onto the top of the list
63
-			foreach ($directories as $k=>$dir)
64
-			{
65
-				if ($dir == Yii::getPathOfAlias('base.themes').DS.$currentTheme)
66
-				{
67
-					unset($directories[$k]);
68
-					break;
69
-				}
70
-			}
62
+            // Pushes the current theme onto the top of the list
63
+            foreach ($directories as $k=>$dir)
64
+            {
65
+                if ($dir == Yii::getPathOfAlias('base.themes').DS.$currentTheme)
66
+                {
67
+                    unset($directories[$k]);
68
+                    break;
69
+                }
70
+            }
71 71
 
72
-			array_unshift($directories, $themePath.$currentTheme);
72
+            array_unshift($directories, $themePath.$currentTheme);
73 73
 
74
-			foreach($directories as $dir)
75
-			{
76
-				$json = CJSON::decode(file_get_contents($dir . DIRECTORY_SEPARATOR . 'composer.json'));
77
-				$name = $json['name'];
78
-				$key = str_replace('ciims-themes/', '', $name);
74
+            foreach($directories as $dir)
75
+            {
76
+                $json = CJSON::decode(file_get_contents($dir . DIRECTORY_SEPARATOR . 'composer.json'));
77
+                $name = $json['name'];
78
+                $key = str_replace('ciims-themes/', '', $name);
79 79
 
80
-				$themes[$key] = array(
81
-					'path' 		=> $dir,
82
-					'name' 		=> $name,
83
-					'hidden' 	=> isset($json['hidden']) ? $json['hidden'] : false
84
-				);
85
-			}
80
+                $themes[$key] = array(
81
+                    'path' 		=> $dir,
82
+                    'name' 		=> $name,
83
+                    'hidden' 	=> isset($json['hidden']) ? $json['hidden'] : false
84
+                );
85
+            }
86 86
 
87
-			Yii::app()->cache->set('settings_themes', $themes);
88
-			return $themes;
89
-		}
87
+            Yii::app()->cache->set('settings_themes', $themes);
88
+            return $themes;
89
+        }
90 90
 
91
-		return $themes;
92
-	}
91
+        return $themes;
92
+    }
93 93
 }
94 94
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class ThemeSettings extends CiiSettingsModel
4
-{
3
+class ThemeSettings extends CiiSettingsModel
4
+{
5 5
 	/**
6 6
 	 * The active theme
7 7
 	 * @var string
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 	 * Validation rules for the theme
13 13
 	 * @return array
14 14
 	 */
15
-	public function rules()
16
-	{
15
+	public function rules()
16
+	{
17 17
 		return array(
18 18
 			array('theme', 'required'),
19 19
 			array('theme', 'length', 'max' => 255)
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 	 * Attribute labels for themes
25 25
 	 * @return array
26 26
 	 */
27
-	public function attributeLabels()
28
-	{
27
+	public function attributeLabels()
28
+	{
29 29
 		return array(
30 30
 			'theme' => Yii::t('ciims.models.theme', 'Theme'),
31 31
 		);
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * Returns the active theme name
36 36
 	 * @return string
37 37
 	 */
38
-	public function getTheme()
39
-	{
38
+	public function getTheme()
39
+	{
40 40
 		return $this->theme;
41 41
 	}
42 42
 
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return array
50 50
 	 */
51
-	public function getThemes()
52
-	{
51
+	public function getThemes()
52
+	{
53 53
 		$themes = Yii::app()->cache->get('settings_themes');
54 54
 
55 55
 		if ($themes == false)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * Validation rules for the theme
13 13
 	 * @return array
14 14
 	 */
15
-	public function rules()
15
+	public function rules ()
16 16
 	{
17 17
 		return array(
18 18
 			array('theme', 'required'),
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 * Attribute labels for themes
25 25
 	 * @return array
26 26
 	 */
27
-	public function attributeLabels()
27
+	public function attributeLabels ()
28 28
 	{
29 29
 		return array(
30
-			'theme' => Yii::t('ciims.models.theme', 'Theme'),
30
+			'theme' => Yii::t ('ciims.models.theme', 'Theme'),
31 31
 		);
32 32
 	}
33 33
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * Returns the active theme name
36 36
 	 * @return string
37 37
 	 */
38
-	public function getTheme()
38
+	public function getTheme ()
39 39
 	{
40 40
 		return $this->theme;
41 41
 	}
@@ -48,34 +48,34 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return array
50 50
 	 */
51
-	public function getThemes()
51
+	public function getThemes ()
52 52
 	{
53
-		$themes = Yii::app()->cache->get('settings_themes');
53
+		$themes = Yii::app ()->cache->get ('settings_themes');
54 54
 
55 55
 		if ($themes == false)
56 56
 		{
57 57
 			$themes = array();
58
-			$currentTheme = Cii::getConfig('theme');
59
-			$themePath = Yii::getPathOfAlias('base.themes') . DS;
60
-			$directories = glob($themePath . "*", GLOB_ONLYDIR);
58
+			$currentTheme = Cii::getConfig ('theme');
59
+			$themePath = Yii::getPathOfAlias ('base.themes').DS;
60
+			$directories = glob ($themePath."*", GLOB_ONLYDIR);
61 61
 
62 62
 			// Pushes the current theme onto the top of the list
63 63
 			foreach ($directories as $k=>$dir)
64 64
 			{
65
-				if ($dir == Yii::getPathOfAlias('base.themes').DS.$currentTheme)
65
+				if ($dir == Yii::getPathOfAlias ('base.themes').DS.$currentTheme)
66 66
 				{
67 67
 					unset($directories[$k]);
68 68
 					break;
69 69
 				}
70 70
 			}
71 71
 
72
-			array_unshift($directories, $themePath.$currentTheme);
72
+			array_unshift ($directories, $themePath.$currentTheme);
73 73
 
74
-			foreach($directories as $dir)
74
+			foreach ($directories as $dir)
75 75
 			{
76
-				$json = CJSON::decode(file_get_contents($dir . DIRECTORY_SEPARATOR . 'composer.json'));
76
+				$json = CJSON::decode (file_get_contents ($dir.DIRECTORY_SEPARATOR.'composer.json'));
77 77
 				$name = $json['name'];
78
-				$key = str_replace('ciims-themes/', '', $name);
78
+				$key = str_replace ('ciims-themes/', '', $name);
79 79
 
80 80
 				$themes[$key] = array(
81 81
 					'path' 		=> $dir,
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 				);
85 85
 			}
86 86
 
87
-			Yii::app()->cache->set('settings_themes', $themes);
87
+			Yii::app ()->cache->set ('settings_themes', $themes);
88 88
 			return $themes;
89 89
 		}
90 90
 
Please login to merge, or discard this patch.
protected/views/site/error.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,2 +1,2 @@
 block discarded – undo
1
-<h1><?php echo Yii::t('ciims.controllers.Site', 'Error {{code}}', array('{{code}}' => $error['code'])); ?></h1>
1
+<h1><?php echo Yii::t ('ciims.controllers.Site', 'Error {{code}}', array('{{code}}' => $error['code'])); ?></h1>
2 2
 <p><?php echo $error['message']; ?></p>
Please login to merge, or discard this patch.