Completed
Push — master ( 9d2e77...ac0adf )
by Charles
02:45
created
protected/models/forms/ForgotForm.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -2,94 +2,94 @@
 block discarded – undo
2 2
 
3 3
 class ForgotForm extends CFormModel
4 4
 {
5
-	/**
6
-	 * @var string $email     The user's email address
7
-	 */
8
-	public $email;
9
-
10
-	/**
11
-	 * @var Users $_user     The user's model
12
-	 */
13
-	private $_user = NULL;
14
-
15
-	/**
16
-	 * Validation rules
17
-	 * @return array
18
-	 */
19
-	public function rules()
20
-	{
21
-		return array(
22
-			array('email', 'required'),
23
-			array('email', 'email'),
24
-			array('email', 'exists')
25
-		);
26
-	}
27
-
28
-	public function attributeLabels()
29
-	{
30
-		return array(
31
-			'email' => Yii::t('ciims.models.ForgotForm', 'Email Address')
32
-		);
33
-	}
34
-
35
-	/**
36
-	 * Determines if we have a user in our database with that email address
37
-	 * @param array $attributes
38
-	 * @param array $params
39
-	 * @return boolean
40
-	 */
41
-	public function exists($attributes, $params)
42
-	{
43
-		$this->_user = Users::model()->findByAttributes(array('email' => $this->email));
44
-
45
-		if ($this->_user == NULL)
46
-		{
47
-			$this->addError('email', Yii::t('ciims.models.ForgotForm', 'The email address you entered is either invalid, or does not belong to a user in our system.'));
48
-			return false;
49
-		}
50
-
51
-		return true;
52
-	}
53
-
54
-	/**
55
-	 * Initiates the password reset process on behalf of the user
56
-	 * Generates a unique hash and an expiration time that the hash is valid up until (defaults to 15 minutes)
57
-	 * This key will internally expire (but not be expunged) after that time
58
-	 */
59
-	public function initPasswordResetProcess()
60
-	{
61
-		if (!$this->validate())
62
-			return false;
63
-
64
-		$hash = Cii::generateSafeHash();
65
-		$expires = strtotime("+15 minutes");
66
-
67
-		$meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetCode'));
68
-		if ($meta === NULL)
69
-			$meta = new UserMetadata;
70
-
71
-		$meta->user_id = $this->_user->id;
72
-		$meta->key = 'passwordResetCode';
73
-		$meta->value = $hash;
74
-		$meta->save();
75
-
76
-		$meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetExpires'));
77
-		if ($meta === NULL)
78
-			$meta = new UserMetadata;
79
-
80
-		$meta->user_id = $this->_user->id;
81
-		$meta->key = 'passwordResetExpires';
82
-		$meta->value = $expires;
83
-		$meta->save();
84
-
85
-		$emailSettings = new EmailSettings;
86
-		$emailSettings->send($this->_user, Yii::t('ciims.email', 'Your Password Reset Information'), 'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.forgot', array('user' => $this->_user, 'hash' => $hash), true, true);
87
-
88
-		// Set success flash
89
-		Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'An email has been sent to {{email}} with further instructions on how to reset your password', array(
90
-			'{{email}}' => $this->email
91
-		)));
92
-
93
-		return true;
94
-	}
5
+    /**
6
+     * @var string $email     The user's email address
7
+     */
8
+    public $email;
9
+
10
+    /**
11
+     * @var Users $_user     The user's model
12
+     */
13
+    private $_user = NULL;
14
+
15
+    /**
16
+     * Validation rules
17
+     * @return array
18
+     */
19
+    public function rules()
20
+    {
21
+        return array(
22
+            array('email', 'required'),
23
+            array('email', 'email'),
24
+            array('email', 'exists')
25
+        );
26
+    }
27
+
28
+    public function attributeLabels()
29
+    {
30
+        return array(
31
+            'email' => Yii::t('ciims.models.ForgotForm', 'Email Address')
32
+        );
33
+    }
34
+
35
+    /**
36
+     * Determines if we have a user in our database with that email address
37
+     * @param array $attributes
38
+     * @param array $params
39
+     * @return boolean
40
+     */
41
+    public function exists($attributes, $params)
42
+    {
43
+        $this->_user = Users::model()->findByAttributes(array('email' => $this->email));
44
+
45
+        if ($this->_user == NULL)
46
+        {
47
+            $this->addError('email', Yii::t('ciims.models.ForgotForm', 'The email address you entered is either invalid, or does not belong to a user in our system.'));
48
+            return false;
49
+        }
50
+
51
+        return true;
52
+    }
53
+
54
+    /**
55
+     * Initiates the password reset process on behalf of the user
56
+     * Generates a unique hash and an expiration time that the hash is valid up until (defaults to 15 minutes)
57
+     * This key will internally expire (but not be expunged) after that time
58
+     */
59
+    public function initPasswordResetProcess()
60
+    {
61
+        if (!$this->validate())
62
+            return false;
63
+
64
+        $hash = Cii::generateSafeHash();
65
+        $expires = strtotime("+15 minutes");
66
+
67
+        $meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetCode'));
68
+        if ($meta === NULL)
69
+            $meta = new UserMetadata;
70
+
71
+        $meta->user_id = $this->_user->id;
72
+        $meta->key = 'passwordResetCode';
73
+        $meta->value = $hash;
74
+        $meta->save();
75
+
76
+        $meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetExpires'));
77
+        if ($meta === NULL)
78
+            $meta = new UserMetadata;
79
+
80
+        $meta->user_id = $this->_user->id;
81
+        $meta->key = 'passwordResetExpires';
82
+        $meta->value = $expires;
83
+        $meta->save();
84
+
85
+        $emailSettings = new EmailSettings;
86
+        $emailSettings->send($this->_user, Yii::t('ciims.email', 'Your Password Reset Information'), 'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.forgot', array('user' => $this->_user, 'hash' => $hash), true, true);
87
+
88
+        // Set success flash
89
+        Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'An email has been sent to {{email}} with further instructions on how to reset your password', array(
90
+            '{{email}}' => $this->email
91
+        )));
92
+
93
+        return true;
94
+    }
95 95
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * Validation rules
17 17
 	 * @return array
18 18
 	 */
19
-	public function rules()
19
+	public function rules ()
20 20
 	{
21 21
 		return array(
22 22
 			array('email', 'required'),
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 		);
26 26
 	}
27 27
 
28
-	public function attributeLabels()
28
+	public function attributeLabels ()
29 29
 	{
30 30
 		return array(
31
-			'email' => Yii::t('ciims.models.ForgotForm', 'Email Address')
31
+			'email' => Yii::t ('ciims.models.ForgotForm', 'Email Address')
32 32
 		);
33 33
 	}
34 34
 
@@ -38,13 +38,13 @@  discard block
 block discarded – undo
38 38
 	 * @param array $params
39 39
 	 * @return boolean
40 40
 	 */
41
-	public function exists($attributes, $params)
41
+	public function exists ($attributes, $params)
42 42
 	{
43
-		$this->_user = Users::model()->findByAttributes(array('email' => $this->email));
43
+		$this->_user = Users::model ()->findByAttributes (array('email' => $this->email));
44 44
 
45 45
 		if ($this->_user == NULL)
46 46
 		{
47
-			$this->addError('email', Yii::t('ciims.models.ForgotForm', 'The email address you entered is either invalid, or does not belong to a user in our system.'));
47
+			$this->addError ('email', Yii::t ('ciims.models.ForgotForm', 'The email address you entered is either invalid, or does not belong to a user in our system.'));
48 48
 			return false;
49 49
 		}
50 50
 
@@ -56,37 +56,37 @@  discard block
 block discarded – undo
56 56
 	 * Generates a unique hash and an expiration time that the hash is valid up until (defaults to 15 minutes)
57 57
 	 * This key will internally expire (but not be expunged) after that time
58 58
 	 */
59
-	public function initPasswordResetProcess()
59
+	public function initPasswordResetProcess ()
60 60
 	{
61
-		if (!$this->validate())
61
+		if (!$this->validate ())
62 62
 			return false;
63 63
 
64
-		$hash = Cii::generateSafeHash();
65
-		$expires = strtotime("+15 minutes");
64
+		$hash = Cii::generateSafeHash ();
65
+		$expires = strtotime ("+15 minutes");
66 66
 
67
-		$meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetCode'));
67
+		$meta = UserMetadata::model ()->findByAttributes (array('user_id'=>$this->_user->id, 'key'=>'passwordResetCode'));
68 68
 		if ($meta === NULL)
69 69
 			$meta = new UserMetadata;
70 70
 
71 71
 		$meta->user_id = $this->_user->id;
72 72
 		$meta->key = 'passwordResetCode';
73 73
 		$meta->value = $hash;
74
-		$meta->save();
74
+		$meta->save ();
75 75
 
76
-		$meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetExpires'));
76
+		$meta = UserMetadata::model ()->findByAttributes (array('user_id'=>$this->_user->id, 'key'=>'passwordResetExpires'));
77 77
 		if ($meta === NULL)
78 78
 			$meta = new UserMetadata;
79 79
 
80 80
 		$meta->user_id = $this->_user->id;
81 81
 		$meta->key = 'passwordResetExpires';
82 82
 		$meta->value = $expires;
83
-		$meta->save();
83
+		$meta->save ();
84 84
 
85 85
 		$emailSettings = new EmailSettings;
86
-		$emailSettings->send($this->_user, Yii::t('ciims.email', 'Your Password Reset Information'), 'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.forgot', array('user' => $this->_user, 'hash' => $hash), true, true);
86
+		$emailSettings->send ($this->_user, Yii::t ('ciims.email', 'Your Password Reset Information'), 'webroot.themes.' . Cii::getConfig ('theme', 'default') . '.views.email.forgot', array('user' => $this->_user, 'hash' => $hash), true, true);
87 87
 
88 88
 		// Set success flash
89
-		Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'An email has been sent to {{email}} with further instructions on how to reset your password', array(
89
+		Yii::app ()->user->setFlash ('success', Yii::t ('ciims.controllers.Site', 'An email has been sent to {{email}} with further instructions on how to reset your password', array(
90 90
 			'{{email}}' => $this->email
91 91
 		)));
92 92
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -58,15 +58,17 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function initPasswordResetProcess()
60 60
 	{
61
-		if (!$this->validate())
62
-			return false;
61
+		if (!$this->validate()) {
62
+					return false;
63
+		}
63 64
 
64 65
 		$hash = Cii::generateSafeHash();
65 66
 		$expires = strtotime("+15 minutes");
66 67
 
67 68
 		$meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetCode'));
68
-		if ($meta === NULL)
69
-			$meta = new UserMetadata;
69
+		if ($meta === NULL) {
70
+					$meta = new UserMetadata;
71
+		}
70 72
 
71 73
 		$meta->user_id = $this->_user->id;
72 74
 		$meta->key = 'passwordResetCode';
@@ -74,8 +76,9 @@  discard block
 block discarded – undo
74 76
 		$meta->save();
75 77
 
76 78
 		$meta = UserMetadata::model()->findByAttributes(array('user_id'=>$this->_user->id, 'key'=>'passwordResetExpires'));
77
-		if ($meta === NULL)
78
-			$meta = new UserMetadata;
79
+		if ($meta === NULL) {
80
+					$meta = new UserMetadata;
81
+		}
79 82
 
80 83
 		$meta->user_id = $this->_user->id;
81 84
 		$meta->key = 'passwordResetExpires';
Please login to merge, or discard this patch.
protected/models/forms/InvitationForm.php 3 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -2,105 +2,105 @@
 block discarded – undo
2 2
 
3 3
 class InvitationForm extends CFormModel
4 4
 {
5
-	/**
6
-	 * The email of the user to invite
7
-	 * @var string $email
8
-	 */
9
-	public $email;
5
+    /**
6
+     * The email of the user to invite
7
+     * @var string $email
8
+     */
9
+    public $email;
10 10
 
11
-	/**
12
-	 * Validation rules
13
-	 * @return array
14
-	 */
15
-	public function rules()
16
-	{
17
-		return array(
18
-			array('email', 'required'),
19
-			array('email', 'email'),
20
-			array('email', 'userExists')
21
-		);
22
-	}
11
+    /**
12
+     * Validation rules
13
+     * @return array
14
+     */
15
+    public function rules()
16
+    {
17
+        return array(
18
+            array('email', 'required'),
19
+            array('email', 'email'),
20
+            array('email', 'userExists')
21
+        );
22
+    }
23 23
 
24
-	/**
25
-	 * Validates that a user with that email address isn't already invited
26
-	 * @param array $attributes
27
-	 * @param array $params
28
-	 * @return boolean
29
-	 */
30
-	public function userExists($attributes, $params)
31
-	{
32
-		$user = Users::model()->findByAttributes(array('email' => $this->email));
24
+    /**
25
+     * Validates that a user with that email address isn't already invited
26
+     * @param array $attributes
27
+     * @param array $params
28
+     * @return boolean
29
+     */
30
+    public function userExists($attributes, $params)
31
+    {
32
+        $user = Users::model()->findByAttributes(array('email' => $this->email));
33 33
 
34
-		if ($user == NULL)
35
-			return true;
34
+        if ($user == NULL)
35
+            return true;
36 36
 
37
-		$this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.'));
38
-		return false;
39
-	}
37
+        $this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.'));
38
+        return false;
39
+    }
40 40
 
41
-	/**
42
-	 * Attribute labels
43
-	 * @return array
44
-	 */
45
-	public function attributeLabels()
46
-	{
47
-		return array(
48
-			'email' => Yii::t('ciims.models.InvitationForm', 'Email Address')
49
-		);
50
-	}
41
+    /**
42
+     * Attribute labels
43
+     * @return array
44
+     */
45
+    public function attributeLabels()
46
+    {
47
+        return array(
48
+            'email' => Yii::t('ciims.models.InvitationForm', 'Email Address')
49
+        );
50
+    }
51 51
 
52
-	/**
53
-	 * Sends an invite to a new user
54
-	 * @return boolean
55
-	 */
56
-	public function invite()
57
-	{
58
-		if (!$this->validate())
59
-			return false;
52
+    /**
53
+     * Sends an invite to a new user
54
+     * @return boolean
55
+     */
56
+    public function invite()
57
+    {
58
+        if (!$this->validate())
59
+            return false;
60 60
 
61
-		$user = new Users;
62
-		$user->attributes = array(
63
-			'email' 		=> $this->email,
64
-			'firstName'		=> null,
65
-			'lastName' 		=> null,
66
-			'displayName' 	=> null,
67
-			'password' 		=> null,
68
-			'user_role' 	=> 5,
69
-			'status' 		=> Users::PENDING_INVITATION
70
-		);
61
+        $user = new Users;
62
+        $user->attributes = array(
63
+            'email' 		=> $this->email,
64
+            'firstName'		=> null,
65
+            'lastName' 		=> null,
66
+            'displayName' 	=> null,
67
+            'password' 		=> null,
68
+            'user_role' 	=> 5,
69
+            'status' 		=> Users::PENDING_INVITATION
70
+        );
71 71
 
72
-		// Create a new user, but bypass validation
73
-		if ($user->save(false))
74
-		{
75
-			$meta = new UserMetadata;
76
-			$meta->attributes = array(
77
-				'user_id' => $user->id,
78
-				'key' => 'invitationKey',
79
-				'value' => Cii::generateSafeHash()
80
-			);
72
+        // Create a new user, but bypass validation
73
+        if ($user->save(false))
74
+        {
75
+            $meta = new UserMetadata;
76
+            $meta->attributes = array(
77
+                'user_id' => $user->id,
78
+                'key' => 'invitationKey',
79
+                'value' => Cii::generateSafeHash()
80
+            );
81 81
 
82
-			// If the key was savedm send the email out
83
-			if ($meta->save())
84
-			{
85
-				$emailSettings = new EmailSettings;
86
-        		$emailSettings->send(
87
-					$user,
88
-					Yii::t('ciims.models.InvitationForm', "You've Been Invited..."),
89
-					'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.invite',
90
-					array(
91
-						'user' => $user,
92
-						'hash' => $meta->value
93
-					),
94
-					true,
95
-					true
96
-				);
82
+            // If the key was savedm send the email out
83
+            if ($meta->save())
84
+            {
85
+                $emailSettings = new EmailSettings;
86
+                $emailSettings->send(
87
+                    $user,
88
+                    Yii::t('ciims.models.InvitationForm', "You've Been Invited..."),
89
+                    'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.invite',
90
+                    array(
91
+                        'user' => $user,
92
+                        'hash' => $meta->value
93
+                    ),
94
+                    true,
95
+                    true
96
+                );
97 97
 
98
-				return true;
99
-			}
98
+                return true;
99
+            }
100 100
 
101
-			$user->delete();
102
-		}
101
+            $user->delete();
102
+        }
103 103
 
104
-		return false;
105
-	}
104
+        return false;
105
+    }
106 106
 }
107 107
\ No newline at end of file
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
13 13
 	 * @return array
14 14
 	 */
15
-	public function rules()
15
+	public function rules ()
16 16
 	{
17 17
 		return array(
18 18
 			array('email', 'required'),
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
 	 * @param array $params
28 28
 	 * @return boolean
29 29
 	 */
30
-	public function userExists($attributes, $params)
30
+	public function userExists ($attributes, $params)
31 31
 	{
32
-		$user = Users::model()->findByAttributes(array('email' => $this->email));
32
+		$user = Users::model ()->findByAttributes (array('email' => $this->email));
33 33
 
34 34
 		if ($user == NULL)
35 35
 			return true;
36 36
 
37
-		$this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.'));
37
+		$this->addError ('email', Yii::t ('ciims.models.InvitationForm', 'A user with that email already exists.'));
38 38
 		return false;
39 39
 	}
40 40
 
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 * Attribute labels
43 43
 	 * @return array
44 44
 	 */
45
-	public function attributeLabels()
45
+	public function attributeLabels ()
46 46
 	{
47 47
 		return array(
48
-			'email' => Yii::t('ciims.models.InvitationForm', 'Email Address')
48
+			'email' => Yii::t ('ciims.models.InvitationForm', 'Email Address')
49 49
 		);
50 50
 	}
51 51
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 * Sends an invite to a new user
54 54
 	 * @return boolean
55 55
 	 */
56
-	public function invite()
56
+	public function invite ()
57 57
 	{
58
-		if (!$this->validate())
58
+		if (!$this->validate ())
59 59
 			return false;
60 60
 
61 61
 		$user = new Users;
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 		);
71 71
 
72 72
 		// Create a new user, but bypass validation
73
-		if ($user->save(false))
73
+		if ($user->save (false))
74 74
 		{
75 75
 			$meta = new UserMetadata;
76 76
 			$meta->attributes = array(
77 77
 				'user_id' => $user->id,
78 78
 				'key' => 'invitationKey',
79
-				'value' => Cii::generateSafeHash()
79
+				'value' => Cii::generateSafeHash ()
80 80
 			);
81 81
 
82 82
 			// If the key was savedm send the email out
83
-			if ($meta->save())
83
+			if ($meta->save ())
84 84
 			{
85 85
 				$emailSettings = new EmailSettings;
86
-        		$emailSettings->send(
86
+        		$emailSettings->send (
87 87
 					$user,
88
-					Yii::t('ciims.models.InvitationForm', "You've Been Invited..."),
89
-					'webroot.themes.' . Cii::getConfig('theme', 'default') .'.views.email.invite',
88
+					Yii::t ('ciims.models.InvitationForm', "You've Been Invited..."),
89
+					'webroot.themes.' . Cii::getConfig ('theme', 'default') . '.views.email.invite',
90 90
 					array(
91 91
 						'user' => $user,
92 92
 						'hash' => $meta->value
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 				return true;
99 99
 			}
100 100
 
101
-			$user->delete();
101
+			$user->delete ();
102 102
 		}
103 103
 
104 104
 		return false;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 	{
32 32
 		$user = Users::model()->findByAttributes(array('email' => $this->email));
33 33
 
34
-		if ($user == NULL)
35
-			return true;
34
+		if ($user == NULL) {
35
+					return true;
36
+		}
36 37
 
37 38
 		$this->addError('email', Yii::t('ciims.models.InvitationForm', 'A user with that email already exists.'));
38 39
 		return false;
@@ -55,8 +56,9 @@  discard block
 block discarded – undo
55 56
 	 */
56 57
 	public function invite()
57 58
 	{
58
-		if (!$this->validate())
59
-			return false;
59
+		if (!$this->validate()) {
60
+					return false;
61
+		}
60 62
 
61 63
 		$user = new Users;
62 64
 		$user->attributes = array(
Please login to merge, or discard this patch.
protected/models/forms/InviteForm.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -2,75 +2,75 @@
 block discarded – undo
2 2
 
3 3
 class InviteForm extends CFormModel
4 4
 {
5
-	/**
6
-	 * @var $id int		The User's ID that we are working with
7
-	 */
8
-	public $id = NULL;
5
+    /**
6
+     * @var $id int		The User's ID that we are working with
7
+     */
8
+    public $id = NULL;
9 9
 
10
-	/**
11
-	 * @var $displayName string	The user's requested display name
12
-	 */
13
-	public $username = NULL;
10
+    /**
11
+     * @var $displayName string	The user's requested display name
12
+     */
13
+    public $username = NULL;
14 14
 
15
-	/**
16
-	 * @var $email string
17
-	 */
18
-	public $email = NULL;
15
+    /**
16
+     * @var $email string
17
+     */
18
+    public $email = NULL;
19 19
 
20
-	/**
21
-	 * @var $password string	The user's selected password
22
-	 */
23
-	public $password = NULL;
20
+    /**
21
+     * @var $password string	The user's selected password
22
+     */
23
+    public $password = NULL;
24 24
 
25
-	/**
26
-	 * Validation Rules
27
-	 * @return array
28
-	 */
29
-	public function rules()
30
-	{
31
-		return array(
32
-			array('id, username, password', 'required'),
33
-			array('username, password', 'length', 'max' => 255)
34
-		);
35
-	}
25
+    /**
26
+     * Validation Rules
27
+     * @return array
28
+     */
29
+    public function rules()
30
+    {
31
+        return array(
32
+            array('id, username, password', 'required'),
33
+            array('username, password', 'length', 'max' => 255)
34
+        );
35
+    }
36 36
 
37
-	/**
38
-	 * Attribute labels
39
-	 * @return array
40
-	 */
41
-	public function attributeLabels()
42
-	{
43
-		return array(
44
-			'id' 		=> Yii::t('ciims.models.InviteForm', 'ID'),
45
-			'username' 	=> Yii::t('ciims.models.InviteForm', 'Username'),
46
-			'password' 	=> Yii::t('ciims.models.InviteForm', 'Password'),
47
-		);
48
-	}
37
+    /**
38
+     * Attribute labels
39
+     * @return array
40
+     */
41
+    public function attributeLabels()
42
+    {
43
+        return array(
44
+            'id' 		=> Yii::t('ciims.models.InviteForm', 'ID'),
45
+            'username' 	=> Yii::t('ciims.models.InviteForm', 'Username'),
46
+            'password' 	=> Yii::t('ciims.models.InviteForm', 'Password'),
47
+        );
48
+    }
49 49
 
50
-	/**
51
-	 * Actually creates the users
52
-	 * @return bool            If the user was created
53
-	 */
54
-	public function acceptInvite()
55
-	{
56
-		if (!$this->validate())
57
-			return false;
50
+    /**
51
+     * Actually creates the users
52
+     * @return bool            If the user was created
53
+     */
54
+    public function acceptInvite()
55
+    {
56
+        if (!$this->validate())
57
+            return false;
58 58
 
59
-		$user = Users::model()->findByPk($this->id);
59
+        $user = Users::model()->findByPk($this->id);
60 60
 
61
-		// Bcrypt the initial password instead of just using the basic hashing mechanism
62
-		$hash = Users::model()->encryptHash($this->email, $this->password, Yii::app()->params['encryptionKey']);
63
-		$cost = Cii::getBcryptCost();
61
+        // Bcrypt the initial password instead of just using the basic hashing mechanism
62
+        $hash = Users::model()->encryptHash($this->email, $this->password, Yii::app()->params['encryptionKey']);
63
+        $cost = Cii::getBcryptCost();
64 64
 
65
-		$this->password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
65
+        $this->password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
66 66
 
67
-		$user->attributes = array(
68
-			'email'			=> $this->email,
69
-			'password'		=> $this->password,
70
-			'username'	    => $this->username,
71
-			'status'		=> Users::ACTIVE
72
-		);
67
+        $user->attributes = array(
68
+            'email'			=> $this->email,
69
+            'password'		=> $this->password,
70
+            'username'	    => $this->username,
71
+            'status'		=> Users::ACTIVE
72
+        );
73 73
 
74
-		return $user->save();
75
-	}
74
+        return $user->save();
75
+    }
76 76
 }
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * Validation Rules
27 27
 	 * @return array
28 28
 	 */
29
-	public function rules()
29
+	public function rules ()
30 30
 	{
31 31
 		return array(
32 32
 			array('id, username, password', 'required'),
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	 * Attribute labels
39 39
 	 * @return array
40 40
 	 */
41
-	public function attributeLabels()
41
+	public function attributeLabels ()
42 42
 	{
43 43
 		return array(
44
-			'id' 		=> Yii::t('ciims.models.InviteForm', 'ID'),
45
-			'username' 	=> Yii::t('ciims.models.InviteForm', 'Username'),
46
-			'password' 	=> Yii::t('ciims.models.InviteForm', 'Password'),
44
+			'id' 		=> Yii::t ('ciims.models.InviteForm', 'ID'),
45
+			'username' 	=> Yii::t ('ciims.models.InviteForm', 'Username'),
46
+			'password' 	=> Yii::t ('ciims.models.InviteForm', 'Password'),
47 47
 		);
48 48
 	}
49 49
 
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 	 * Actually creates the users
52 52
 	 * @return bool            If the user was created
53 53
 	 */
54
-	public function acceptInvite()
54
+	public function acceptInvite ()
55 55
 	{
56
-		if (!$this->validate())
56
+		if (!$this->validate ())
57 57
 			return false;
58 58
 
59
-		$user = Users::model()->findByPk($this->id);
59
+		$user = Users::model ()->findByPk ($this->id);
60 60
 
61 61
 		// Bcrypt the initial password instead of just using the basic hashing mechanism
62
-		$hash = Users::model()->encryptHash($this->email, $this->password, Yii::app()->params['encryptionKey']);
63
-		$cost = Cii::getBcryptCost();
62
+		$hash = Users::model ()->encryptHash ($this->email, $this->password, Yii::app ()->params['encryptionKey']);
63
+		$cost = Cii::getBcryptCost ();
64 64
 
65
-		$this->password = password_hash($hash, PASSWORD_BCRYPT, array('cost' => $cost));
65
+		$this->password = password_hash ($hash, PASSWORD_BCRYPT, array('cost' => $cost));
66 66
 
67 67
 		$user->attributes = array(
68 68
 			'email'			=> $this->email,
@@ -71,6 +71,6 @@  discard block
 block discarded – undo
71 71
 			'status'		=> Users::ACTIVE
72 72
 		);
73 73
 
74
-		return $user->save();
74
+		return $user->save ();
75 75
 	}
76 76
 }
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +11 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 InviteForm extends CFormModel
4
-{
3
+class InviteForm extends CFormModel
4
+{
5 5
 	/**
6 6
 	 * @var $id int		The User's ID that we are working with
7 7
 	 */
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * Validation Rules
27 27
 	 * @return array
28 28
 	 */
29
-	public function rules()
30
-	{
29
+	public function rules()
30
+	{
31 31
 		return array(
32 32
 			array('id, username, password', 'required'),
33 33
 			array('username, password', 'length', 'max' => 255)
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * Attribute labels
39 39
 	 * @return array
40 40
 	 */
41
-	public function attributeLabels()
42
-	{
41
+	public function attributeLabels()
42
+	{
43 43
 		return array(
44 44
 			'id' 		=> Yii::t('ciims.models.InviteForm', 'ID'),
45 45
 			'username' 	=> Yii::t('ciims.models.InviteForm', 'Username'),
@@ -51,10 +51,11 @@  discard block
 block discarded – undo
51 51
 	 * Actually creates the users
52 52
 	 * @return bool            If the user was created
53 53
 	 */
54
-	public function acceptInvite()
55
-	{
56
-		if (!$this->validate())
57
-			return false;
54
+	public function acceptInvite()
55
+	{
56
+		if (!$this->validate()) {
57
+					return false;
58
+		}
58 59
 
59 60
 		$user = Users::model()->findByPk($this->id);
60 61
 
Please login to merge, or discard this patch.
protected/models/forms/LoginForm.php 3 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -8,169 +8,169 @@
 block discarded – undo
8 8
 Yii::import('cii.components.CiiUserIdentity');
9 9
 class LoginForm extends CFormModel
10 10
 {
11
-	/**
12
-	 * The submitted username(email)
13
-	 * @var string
14
-	 */
15
-	public $username;
11
+    /**
12
+     * The submitted username(email)
13
+     * @var string
14
+     */
15
+    public $username;
16 16
 
17
-	/**
18
-	 * The submitted password
19
-	 * @var string
20
-	 */
21
-	public $password;
17
+    /**
18
+     * The submitted password
19
+     * @var string
20
+     */
21
+    public $password;
22 22
 
23
-	/**
24
-	 * Two factor authentication code
25
-	 * @var string
26
-	 */
27
-	public $twoFactorCode = false;
23
+    /**
24
+     * Two factor authentication code
25
+     * @var string
26
+     */
27
+    public $twoFactorCode = false;
28 28
 
29
-	/**
30
-	 * Whether or not we should remember the user.
31
-	 * This isn't uses as of CiiMS 1.1
32
-	 * @var boolean ?
33
-	 */
34
-	public $rememberMe = true;
29
+    /**
30
+     * Whether or not we should remember the user.
31
+     * This isn't uses as of CiiMS 1.1
32
+     * @var boolean ?
33
+     */
34
+    public $rememberMe = true;
35 35
 
36
-	/**
37
-	 * Whether or not we should perform a forced authentication. By default we aren't going to do this
38
-	 * @var boolean
39
-	 */
40
-	private $force = false;
36
+    /**
37
+     * Whether or not we should perform a forced authentication. By default we aren't going to do this
38
+     * @var boolean
39
+     */
40
+    private $force = false;
41 41
 
42
-	/**
43
-	 * The identity of the user
44
-	 * @var CiiUserIdentity
45
-	 */
46
-	private $_identity = NULL;
42
+    /**
43
+     * The identity of the user
44
+     * @var CiiUserIdentity
45
+     */
46
+    private $_identity = NULL;
47 47
 
48
-	/**
49
-	 * The Application Name for API requests
50
-	 * @var $app_name
51
-	 */
52
-	public $app_name = NULL;
48
+    /**
49
+     * The Application Name for API requests
50
+     * @var $app_name
51
+     */
52
+    public $app_name = NULL;
53 53
 
54
-	/**
55
-	 * Determines whether or not we should do a forced authentication and bypass the user's actual password
56
-	 * @see  application.modules.HybridAuth for more details
57
-	 * @param boolean $force
58
-	 */
59
-	public function __construct($force=false)
60
-	{
61
-		$this->force = $force;
62
-	}
54
+    /**
55
+     * Determines whether or not we should do a forced authentication and bypass the user's actual password
56
+     * @see  application.modules.HybridAuth for more details
57
+     * @param boolean $force
58
+     */
59
+    public function __construct($force=false)
60
+    {
61
+        $this->force = $force;
62
+    }
63 63
 
64
-	/**
65
-	 * Declares the validation rules.
66
-	 * The rules state that username and password are required,
67
-	 * and password needs to be authenticated.
68
-	 */
69
-	public function rules()
70
-	{
71
-		return array(
72
-			array('username, password', 'required'),
73
-			array('username', 'email'),
74
-			array('password', 'authenticate'),
75
-			array('twoFactorCode', 'hasTwoFactorCode')
76
-		);
77
-	}
64
+    /**
65
+     * Declares the validation rules.
66
+     * The rules state that username and password are required,
67
+     * and password needs to be authenticated.
68
+     */
69
+    public function rules()
70
+    {
71
+        return array(
72
+            array('username, password', 'required'),
73
+            array('username', 'email'),
74
+            array('password', 'authenticate'),
75
+            array('twoFactorCode', 'hasTwoFactorCode')
76
+        );
77
+    }
78 78
 
79
-	/**
80
-	 * Yii attribute labels
81
-	 * @return array
82
-	 */
83
-	public function attributeLabels()
84
-	{
85
-		return array(
86
-			'username' 		=> Yii::t('ciims.models.LoginForm', 'Username'),
87
-			'password' 		=> Yii::t('ciims.models.LoginForm', 'Password'),
88
-			'twoFactorCode' => Yii::t('ciims.models.LoginForm', 'Two Factor Authentication Code'),
89
-		);
90
-	}
79
+    /**
80
+     * Yii attribute labels
81
+     * @return array
82
+     */
83
+    public function attributeLabels()
84
+    {
85
+        return array(
86
+            'username' 		=> Yii::t('ciims.models.LoginForm', 'Username'),
87
+            'password' 		=> Yii::t('ciims.models.LoginForm', 'Password'),
88
+            'twoFactorCode' => Yii::t('ciims.models.LoginForm', 'Two Factor Authentication Code'),
89
+        );
90
+    }
91 91
 
92
-	/**
93
-	 * Returns an instance of CiiUserIdentity
94
-	 * @return CiiUserIdentity
95
-	 */
96
-	public function getIdentity()
97
-	{
98
-		if ($this->_identity === NULL)
99
-			$this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode);
92
+    /**
93
+     * Returns an instance of CiiUserIdentity
94
+     * @return CiiUserIdentity
95
+     */
96
+    public function getIdentity()
97
+    {
98
+        if ($this->_identity === NULL)
99
+            $this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode);
100 100
 		
101
-		return $this->_identity;
102
-	}
101
+        return $this->_identity;
102
+    }
103 103
 	
104
-	/**
105
-	 * Authenticates the password.
106
-	 * This is the 'authenticate' validator as declared in rules().
107
-	 */
108
-	public function authenticate($attribute, $params)
109
-	{
110
-		if (!$this->hasErrors())
111
-		{
112
-			$this->getIdentity()->app_name = $this->app_name;
113
-			if (!$this->getIdentity()->authenticate($this->force))
114
-			{
115
-				if ($this->getIdentity()->errorCode === 5)
116
-				{
117
-					$this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.'));
118
-					$this->username = NULL;
119
-					$this->password = NULL;
120
-					$this->twoFactorCode = NULL;
121
-				}
122
-				else
123
-					$this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.'));
124
-			}
125
-		}
126
-	}
104
+    /**
105
+     * Authenticates the password.
106
+     * This is the 'authenticate' validator as declared in rules().
107
+     */
108
+    public function authenticate($attribute, $params)
109
+    {
110
+        if (!$this->hasErrors())
111
+        {
112
+            $this->getIdentity()->app_name = $this->app_name;
113
+            if (!$this->getIdentity()->authenticate($this->force))
114
+            {
115
+                if ($this->getIdentity()->errorCode === 5)
116
+                {
117
+                    $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.'));
118
+                    $this->username = NULL;
119
+                    $this->password = NULL;
120
+                    $this->twoFactorCode = NULL;
121
+                }
122
+                else
123
+                    $this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.'));
124
+            }
125
+        }
126
+    }
127 127
 
128
-	/**
129
-	 * Validator for two factor authentication codes
130
-	 */
131
-	public function hasTwoFactorCode($attribute, $params)
132
-	{
133
-		if ($this->twoFactorCode === false && $this->needsTwoFactorAuth())
134
-			$this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed'));
135
-	}
128
+    /**
129
+     * Validator for two factor authentication codes
130
+     */
131
+    public function hasTwoFactorCode($attribute, $params)
132
+    {
133
+        if ($this->twoFactorCode === false && $this->needsTwoFactorAuth())
134
+            $this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed'));
135
+    }
136 136
 
137
-	/**
138
-	 * Determines if two factor authentication code is required
139
-	 * @return boolean
140
-	 */
141
-	public function needsTwoFactorAuth()
142
-	{
143
-		$user = $this->getIdentity()->getUser();
137
+    /**
138
+     * Determines if two factor authentication code is required
139
+     * @return boolean
140
+     */
141
+    public function needsTwoFactorAuth()
142
+    {
143
+        $user = $this->getIdentity()->getUser();
144 144
 
145
-		// If the user is bad, we don't need a 2fa code
146
-		if ($user == NULL)
147
-			return false;
145
+        // If the user is bad, we don't need a 2fa code
146
+        if ($user == NULL)
147
+            return false;
148 148
 
149
-		// Only return true if the user needs a 2fa code and their password validation succeeded
150
-		if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword())
151
-			return true;
149
+        // Only return true if the user needs a 2fa code and their password validation succeeded
150
+        if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword())
151
+            return true;
152 152
 			
153
-		return false;
154
-	}
153
+        return false;
154
+    }
155 155
 	
156
-	/**
157
-	 * Logs in the user using the given username and password in the model.
158
-	 * @return boolean whether login is successful
159
-	 */
160
-	public function login()
161
-	{
162
-		if (!$this->validate())
163
-			return false;
156
+    /**
157
+     * Logs in the user using the given username and password in the model.
158
+     * @return boolean whether login is successful
159
+     */
160
+    public function login()
161
+    {
162
+        if (!$this->validate())
163
+            return false;
164 164
 			
165
-		if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE)
166
-		{
167
-			Yii::app()->user->login($this->getIdentity());
165
+        if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE)
166
+        {
167
+            Yii::app()->user->login($this->getIdentity());
168 168
 			
169
-			// Store the API key and session_identifier as a key-set in cache
170
-			Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800);
171
-			return true;
172
-		}	
173
-		else
174
-			return false;
175
-	}
169
+            // Store the API key and session_identifier as a key-set in cache
170
+            Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800);
171
+            return true;
172
+        }	
173
+        else
174
+            return false;
175
+    }
176 176
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * LoginForm is the data structure for keeping
6 6
  * user login form data. It is used by the 'login' action of 'SiteController'.
7 7
  */
8
-Yii::import('cii.components.CiiUserIdentity');
8
+Yii::import ('cii.components.CiiUserIdentity');
9 9
 class LoginForm extends CFormModel
10 10
 {
11 11
 	/**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @see  application.modules.HybridAuth for more details
57 57
 	 * @param boolean $force
58 58
 	 */
59
-	public function __construct($force=false)
59
+	public function __construct ($force = false)
60 60
 	{
61 61
 		$this->force = $force;
62 62
 	}
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * The rules state that username and password are required,
67 67
 	 * and password needs to be authenticated.
68 68
 	 */
69
-	public function rules()
69
+	public function rules ()
70 70
 	{
71 71
 		return array(
72 72
 			array('username, password', 'required'),
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	 * Yii attribute labels
81 81
 	 * @return array
82 82
 	 */
83
-	public function attributeLabels()
83
+	public function attributeLabels ()
84 84
 	{
85 85
 		return array(
86
-			'username' 		=> Yii::t('ciims.models.LoginForm', 'Username'),
87
-			'password' 		=> Yii::t('ciims.models.LoginForm', 'Password'),
88
-			'twoFactorCode' => Yii::t('ciims.models.LoginForm', 'Two Factor Authentication Code'),
86
+			'username' 		=> Yii::t ('ciims.models.LoginForm', 'Username'),
87
+			'password' 		=> Yii::t ('ciims.models.LoginForm', 'Password'),
88
+			'twoFactorCode' => Yii::t ('ciims.models.LoginForm', 'Two Factor Authentication Code'),
89 89
 		);
90 90
 	}
91 91
 
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 	 * Returns an instance of CiiUserIdentity
94 94
 	 * @return CiiUserIdentity
95 95
 	 */
96
-	public function getIdentity()
96
+	public function getIdentity ()
97 97
 	{
98 98
 		if ($this->_identity === NULL)
99
-			$this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode);
99
+			$this->_identity = new CiiUserIdentity ($this->username, $this->password, $this->twoFactorCode);
100 100
 		
101 101
 		return $this->_identity;
102 102
 	}
@@ -105,22 +105,22 @@  discard block
 block discarded – undo
105 105
 	 * Authenticates the password.
106 106
 	 * This is the 'authenticate' validator as declared in rules().
107 107
 	 */
108
-	public function authenticate($attribute, $params)
108
+	public function authenticate ($attribute, $params)
109 109
 	{
110
-		if (!$this->hasErrors())
110
+		if (!$this->hasErrors ())
111 111
 		{
112
-			$this->getIdentity()->app_name = $this->app_name;
113
-			if (!$this->getIdentity()->authenticate($this->force))
112
+			$this->getIdentity ()->app_name = $this->app_name;
113
+			if (!$this->getIdentity ()->authenticate ($this->force))
114 114
 			{
115
-				if ($this->getIdentity()->errorCode === 5)
115
+				if ($this->getIdentity ()->errorCode === 5)
116 116
 				{
117
-					$this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.'));
117
+					$this->addError ('twoFactorCode', Yii::t ('ciims.models.LoginForm', 'Two factor code was not valid. Please try again.'));
118 118
 					$this->username = NULL;
119 119
 					$this->password = NULL;
120 120
 					$this->twoFactorCode = NULL;
121 121
 				}
122 122
 				else
123
-					$this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.'));
123
+					$this->addError ('password', Yii::t ('ciims.models.LoginForm', 'Incorrect username or password.'));
124 124
 			}
125 125
 		}
126 126
 	}
@@ -128,26 +128,26 @@  discard block
 block discarded – undo
128 128
 	/**
129 129
 	 * Validator for two factor authentication codes
130 130
 	 */
131
-	public function hasTwoFactorCode($attribute, $params)
131
+	public function hasTwoFactorCode ($attribute, $params)
132 132
 	{
133
-		if ($this->twoFactorCode === false && $this->needsTwoFactorAuth())
134
-			$this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed'));
133
+		if ($this->twoFactorCode === false && $this->needsTwoFactorAuth ())
134
+			$this->addError ('twoFactorCode', Yii::t ('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed'));
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * Determines if two factor authentication code is required
139 139
 	 * @return boolean
140 140
 	 */
141
-	public function needsTwoFactorAuth()
141
+	public function needsTwoFactorAuth ()
142 142
 	{
143
-		$user = $this->getIdentity()->getUser();
143
+		$user = $this->getIdentity ()->getUser ();
144 144
 
145 145
 		// If the user is bad, we don't need a 2fa code
146 146
 		if ($user == NULL)
147 147
 			return false;
148 148
 
149 149
 		// Only return true if the user needs a 2fa code and their password validation succeeded
150
-		if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword())
150
+		if ($user->needsTwoFactorAuth () && $this->getIdentity ()->validatePassword ())
151 151
 			return true;
152 152
 			
153 153
 		return false;
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	 * Logs in the user using the given username and password in the model.
158 158
 	 * @return boolean whether login is successful
159 159
 	 */
160
-	public function login()
160
+	public function login ()
161 161
 	{
162
-		if (!$this->validate())
162
+		if (!$this->validate ())
163 163
 			return false;
164 164
 			
165
-		if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE)
165
+		if ($this->getIdentity ()->errorCode === CiiUserIdentity::ERROR_NONE)
166 166
 		{
167
-			Yii::app()->user->login($this->getIdentity());
167
+			Yii::app ()->user->login ($this->getIdentity ());
168 168
 			
169 169
 			// Store the API key and session_identifier as a key-set in cache
170
-			Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800);
170
+			Yii::app ()->cache->set ($this->getIdentity ()->getState ('apiKey'), session_id (), 1800);
171 171
 			return true;
172 172
 		}	
173 173
 		else
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -95,8 +95,9 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function getIdentity()
97 97
 	{
98
-		if ($this->_identity === NULL)
99
-			$this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode);
98
+		if ($this->_identity === NULL) {
99
+					$this->_identity = new CiiUserIdentity($this->username, $this->password, $this->twoFactorCode);
100
+		}
100 101
 		
101 102
 		return $this->_identity;
102 103
 	}
@@ -118,9 +119,9 @@  discard block
 block discarded – undo
118 119
 					$this->username = NULL;
119 120
 					$this->password = NULL;
120 121
 					$this->twoFactorCode = NULL;
122
+				} else {
123
+									$this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.'));
121 124
 				}
122
-				else
123
-					$this->addError('password', Yii::t('ciims.models.LoginForm', 'Incorrect username or password.'));
124 125
 			}
125 126
 		}
126 127
 	}
@@ -130,8 +131,9 @@  discard block
 block discarded – undo
130 131
 	 */
131 132
 	public function hasTwoFactorCode($attribute, $params)
132 133
 	{
133
-		if ($this->twoFactorCode === false && $this->needsTwoFactorAuth())
134
-			$this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed'));
134
+		if ($this->twoFactorCode === false && $this->needsTwoFactorAuth()) {
135
+					$this->addError('twoFactorCode', Yii::t('ciims.models.LoginForm', 'Please enter your two factor authentication code to proceed'));
136
+		}
135 137
 	}
136 138
 
137 139
 	/**
@@ -143,12 +145,14 @@  discard block
 block discarded – undo
143 145
 		$user = $this->getIdentity()->getUser();
144 146
 
145 147
 		// If the user is bad, we don't need a 2fa code
146
-		if ($user == NULL)
147
-			return false;
148
+		if ($user == NULL) {
149
+					return false;
150
+		}
148 151
 
149 152
 		// Only return true if the user needs a 2fa code and their password validation succeeded
150
-		if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword())
151
-			return true;
153
+		if ($user->needsTwoFactorAuth() && $this->getIdentity()->validatePassword()) {
154
+					return true;
155
+		}
152 156
 			
153 157
 		return false;
154 158
 	}
@@ -159,8 +163,9 @@  discard block
 block discarded – undo
159 163
 	 */
160 164
 	public function login()
161 165
 	{
162
-		if (!$this->validate())
163
-			return false;
166
+		if (!$this->validate()) {
167
+					return false;
168
+		}
164 169
 			
165 170
 		if ($this->getIdentity()->errorCode === CiiUserIdentity::ERROR_NONE)
166 171
 		{
@@ -169,8 +174,8 @@  discard block
 block discarded – undo
169 174
 			// Store the API key and session_identifier as a key-set in cache
170 175
 			Yii::app()->cache->set($this->getIdentity()->getState('apiKey'), session_id(), 1800);
171 176
 			return true;
172
-		}	
173
-		else
174
-			return false;
177
+		} else {
178
+					return false;
179
+		}
175 180
 	}
176 181
 }
Please login to merge, or discard this patch.
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 4 patches
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.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
 
139 139
 	/**
140 140
 	 * Generates a new change key
141
-	 * @return boolean
141
+	 * @return string
142 142
 	 */
143 143
 	public function setNewEmailChangeKey()
144 144
 	{
Please login to merge, or discard this patch.
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -2,321 +2,321 @@
 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
-		var_dump($this->overridePasswordCheck);
58
-		var_dump(Yii::app()->user->id);
59
-		var_dump($this->getId());
60
-		die();
61
-		if ($this->overridePasswordCheck)
62
-			return true;
63
-
64
-		if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id)
65
-			return true;
66
-
67
-		return false;
68
-	}
69
-
70
-	/**
71
-	 * Overload of the __getter method to retrieve the user's ID
72
-	 * @var int $id
73
-	 */
74
-	public function getId()
75
-	{
76
-		return $this->_user->id;
77
-	}
78
-
79
-	/**
80
-	 * Retrieves the new email address if it is set
81
-	 * @return mixed
82
-	 */
83
-	public function getNewEmail()
84
-	{
85
-		$metadata = UserMetadata::model()->findByAttributes(array(
86
-			'user_id' => $this->_user->id,
87
-			'key'     => 'newEmailAddress'
88
-		));
89
-
90
-		if ($metadata == NULL)
91
-			return NULL;
92
-
93
-		return $metadata->value;
94
-	}
95
-
96
-	/**
97
-	 * Sets the new email address
98
-	 * @return boolean
99
-	 */
100
-	public function setNewEmail()
101
-	{
102
-		$metadata = UserMetadata::model()->findByAttributes(array(
103
-			'user_id' => $this->_user->id,
104
-			'key'     => 'newEmailAddress'
105
-		));
106
-
107
-		if ($metadata == NULL)
108
-		{
109
-			$metadata = new UserMetadata;
110
-			$metadata->attributes = array(
111
-				'user_id' => $this->_user->id,
112
-				'key'     => 'newEmailAddress'
113
-			);
114
-		}
115
-
116
-		$metadata->value = $this->email;
117
-
118
-		// Save the record
119
-		return $metadata->save();
120
-	}
121
-
122
-	/**
123
-	 * Retrieves the new email address if it is set
124
-	 * @return mixed
125
-	 */
126
-	public function getNewEmailChangeKey()
127
-	{
128
-		$metadata = UserMetadata::model()->findByAttributes(array(
129
-			'user_id' => $this->_user->id,
130
-			'key'     => 'newEmailAddressChangeKey'
131
-		));
132
-
133
-		if ($metadata == NULL)
134
-			return NULL;
135
-
136
-		return $metadata->value;
137
-	}
138
-
139
-	/**
140
-	 * Generates a new change key
141
-	 * @return boolean
142
-	 */
143
-	public function setNewEmailChangeKey()
144
-	{
145
-		$metadata = UserMetadata::model()->findByAttributes(array(
146
-			'user_id' => $this->_user->id,
147
-			'key'     => 'newEmailAddressChangeKey'
148
-		));
149
-
150
-		if ($metadata == NULL)
151
-		{
152
-			$metadata = new UserMetadata;
153
-			$metadata->attributes = array(
154
-				'user_id' => $this->_user->id,
155
-				'key'     => 'newEmailAddressChangeKey'
156
-			);
157
-		}
158
-
159
-		// Generate a new key
160
-		$metadata->value = Cii::generateSafeHash();
161
-
162
-		// Save the record
163
-		if ($metadata->save())
164
-			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
+        var_dump($this->overridePasswordCheck);
58
+        var_dump(Yii::app()->user->id);
59
+        var_dump($this->getId());
60
+        die();
61
+        if ($this->overridePasswordCheck)
62
+            return true;
63
+
64
+        if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id)
65
+            return true;
66
+
67
+        return false;
68
+    }
69
+
70
+    /**
71
+     * Overload of the __getter method to retrieve the user's ID
72
+     * @var int $id
73
+     */
74
+    public function getId()
75
+    {
76
+        return $this->_user->id;
77
+    }
78
+
79
+    /**
80
+     * Retrieves the new email address if it is set
81
+     * @return mixed
82
+     */
83
+    public function getNewEmail()
84
+    {
85
+        $metadata = UserMetadata::model()->findByAttributes(array(
86
+            'user_id' => $this->_user->id,
87
+            'key'     => 'newEmailAddress'
88
+        ));
89
+
90
+        if ($metadata == NULL)
91
+            return NULL;
92
+
93
+        return $metadata->value;
94
+    }
95
+
96
+    /**
97
+     * Sets the new email address
98
+     * @return boolean
99
+     */
100
+    public function setNewEmail()
101
+    {
102
+        $metadata = UserMetadata::model()->findByAttributes(array(
103
+            'user_id' => $this->_user->id,
104
+            'key'     => 'newEmailAddress'
105
+        ));
106
+
107
+        if ($metadata == NULL)
108
+        {
109
+            $metadata = new UserMetadata;
110
+            $metadata->attributes = array(
111
+                'user_id' => $this->_user->id,
112
+                'key'     => 'newEmailAddress'
113
+            );
114
+        }
115
+
116
+        $metadata->value = $this->email;
117
+
118
+        // Save the record
119
+        return $metadata->save();
120
+    }
121
+
122
+    /**
123
+     * Retrieves the new email address if it is set
124
+     * @return mixed
125
+     */
126
+    public function getNewEmailChangeKey()
127
+    {
128
+        $metadata = UserMetadata::model()->findByAttributes(array(
129
+            'user_id' => $this->_user->id,
130
+            'key'     => 'newEmailAddressChangeKey'
131
+        ));
132
+
133
+        if ($metadata == NULL)
134
+            return NULL;
135
+
136
+        return $metadata->value;
137
+    }
138
+
139
+    /**
140
+     * Generates a new change key
141
+     * @return boolean
142
+     */
143
+    public function setNewEmailChangeKey()
144
+    {
145
+        $metadata = UserMetadata::model()->findByAttributes(array(
146
+            'user_id' => $this->_user->id,
147
+            'key'     => 'newEmailAddressChangeKey'
148
+        ));
149
+
150
+        if ($metadata == NULL)
151
+        {
152
+            $metadata = new UserMetadata;
153
+            $metadata->attributes = array(
154
+                'user_id' => $this->_user->id,
155
+                'key'     => 'newEmailAddressChangeKey'
156
+            );
157
+        }
158
+
159
+        // Generate a new key
160
+        $metadata->value = Cii::generateSafeHash();
161
+
162
+        // Save the record
163
+        if ($metadata->save())
164
+            return $metadata->value;
165 165
 	
166
-		throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key'));
167
-	}
168
-
169
-	/**
170
-	 * Validation rules
171
-	 * @return array
172
-	 */
173
-	public function rules()
174
-	{
175
-		return array(
176
-			array('email, username', 'required'),
177
-			array('username', 'length', 'max' => 255),
178
-			array('currentPassword', 'validateUserPassword'),
179
-			array('password', 'compare'),
180
-			array('password', 'length', 'min' => 8),
181
-			array('user_role', 'numerical'),
182
-			array('user_role', 'validateUserRole')
183
-		);
184
-	}
185
-
186
-	/**
187
-	 * Retrieves the attributes labels from the Users model and returns them to reduce code redundancy
188
-	 * @return array
189
-	 */
190
-	public function attributeLabels()
191
-	{
192
-		return CMap::mergeArray(Users::model()->attributeLabels(), array(
193
-			'currentPassword' => Yii::t('ciims.models.ProfileForm', 'Your current password'),
194
-			'password_repeat' => Yii::t('ciims.models.ProfileForm', 'Your New Password (again)')
195
-		));
196
-	}
197
-
198
-	/**
199
-	 * Validates the role
200
-	 * @param array $attributes
201
-	 * @param array $params
202
-	 * return array
203
-	 */
204
-	public function validateUserRole($attributes, $params)
205
-	{
206
-		if ($this->canOverridePasswordCheck())
207
-			return true;
208
-
209
-		$this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute'));
210
-		return false;
211
-	}
212
-
213
-	/**
214
-	 * Ensures that the password entered matches the one provided during registration
215
-	 * @param array $attributes
216
-	 * @param array $params
217
-	 * return array
218
-	 */
219
-	public function validateUserPassword($attributes, $params)
220
-	{
221
-		// Apply the override if it was set
222
-		if ($this->canOverridePasswordCheck())
223
-		{
224
-			$this->password_repeat = $this->password;
225
-			return true;
226
-		}
227
-
228
-		$result = password_verify($this->password, $this->_user->password);
166
+        throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key'));
167
+    }
168
+
169
+    /**
170
+     * Validation rules
171
+     * @return array
172
+     */
173
+    public function rules()
174
+    {
175
+        return array(
176
+            array('email, username', 'required'),
177
+            array('username', 'length', 'max' => 255),
178
+            array('currentPassword', 'validateUserPassword'),
179
+            array('password', 'compare'),
180
+            array('password', 'length', 'min' => 8),
181
+            array('user_role', 'numerical'),
182
+            array('user_role', 'validateUserRole')
183
+        );
184
+    }
185
+
186
+    /**
187
+     * Retrieves the attributes labels from the Users model and returns them to reduce code redundancy
188
+     * @return array
189
+     */
190
+    public function attributeLabels()
191
+    {
192
+        return CMap::mergeArray(Users::model()->attributeLabels(), array(
193
+            'currentPassword' => Yii::t('ciims.models.ProfileForm', 'Your current password'),
194
+            'password_repeat' => Yii::t('ciims.models.ProfileForm', 'Your New Password (again)')
195
+        ));
196
+    }
197
+
198
+    /**
199
+     * Validates the role
200
+     * @param array $attributes
201
+     * @param array $params
202
+     * return array
203
+     */
204
+    public function validateUserRole($attributes, $params)
205
+    {
206
+        if ($this->canOverridePasswordCheck())
207
+            return true;
208
+
209
+        $this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute'));
210
+        return false;
211
+    }
212
+
213
+    /**
214
+     * Ensures that the password entered matches the one provided during registration
215
+     * @param array $attributes
216
+     * @param array $params
217
+     * return array
218
+     */
219
+    public function validateUserPassword($attributes, $params)
220
+    {
221
+        // Apply the override if it was set
222
+        if ($this->canOverridePasswordCheck())
223
+        {
224
+            $this->password_repeat = $this->password;
225
+            return true;
226
+        }
227
+
228
+        $result = password_verify($this->password, $this->_user->password);
229 229
 		
230
-		if ($result == false)
231
-		{
232
-			$this->addError('currentPassword', Yii::t('ciims.models.ProfileForm', 'The password you entered is invalid.'));
233
-			return false;
234
-		}
235
-
236
-		return true;
237
-	}
238
-
239
-	/**
240
-	 * Internally loads the user's information before attempting to validate it
241
-	 * @param int  $id         The user's ID
242
-	 * @param bool $override   This form may be reused
243
-	 * @return ProfileForm
244
-	 */
245
-	public function load($id, $override = false)
246
-	{
247
-		$this->overridePasswordCheck = $override;
248
-
249
-		// Load the user
250
-		$this->_user = Users::model()->findByPk($id);
251
-
252
-		if ($this->_user == NULL)
253
-			throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded'));
254
-
255
-		// Reload the attribute labels
256
-		$this->attributes = array(
257
-			'email'         => $this->_user->email,
258
-			'username'      => $this->_user->username,
259
-			'user_role'     => $this->_user->role->id
260
-		);
261
-
262
-		return $this;
263
-	}
264
-
265
-	/**
266
-	 * Updates the user's profile information
267
-	 * @return boolean
268
-	 */
269
-	public function save()
270
-	{
271
-		if (!$this->validate(NULL, false))
272
-			return false;
273
-
274
-		// Change the email address, if necessary
275
-		$this->changeEmail();
276
-
277
-		$this->_user->attributes = array(
278
-			'password'      => $this->password,
279
-			'username'      => $this->username,
280
-			'user_role'     => $this->user_role
281
-		);
282
-
283
-		if ($this->_user->save())
284
-			return true;
285
-
286
-		return false;
287
-	}
288
-
289
-	/**
290
-	 * Changes the user's email address if necessary
291
-	 * @return boolean
292
-	 */
293
-	private function changeEmail()
294
-	{
295
-		if ($this->email != $this->_user->email)
296
-		{
297
-			$this->setNewemail();
298
-			$this->setNewEmailChangeKey();
299
-			$this->sendVerificationEmail();
300
-		}
301
-
302
-		return true;
303
-	}
304
-
305
-	/**
306
-	 * Sends the verification email to the user. This is broken to it's own method to allow for the resending email to be resent
307
-	 * @return boolean
308
-	 */
309
-	public function sendVerificationEmail()
310
-	{
311
-		$emailSettings = new EmailSettings;
230
+        if ($result == false)
231
+        {
232
+            $this->addError('currentPassword', Yii::t('ciims.models.ProfileForm', 'The password you entered is invalid.'));
233
+            return false;
234
+        }
235
+
236
+        return true;
237
+    }
238
+
239
+    /**
240
+     * Internally loads the user's information before attempting to validate it
241
+     * @param int  $id         The user's ID
242
+     * @param bool $override   This form may be reused
243
+     * @return ProfileForm
244
+     */
245
+    public function load($id, $override = false)
246
+    {
247
+        $this->overridePasswordCheck = $override;
248
+
249
+        // Load the user
250
+        $this->_user = Users::model()->findByPk($id);
251
+
252
+        if ($this->_user == NULL)
253
+            throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded'));
254
+
255
+        // Reload the attribute labels
256
+        $this->attributes = array(
257
+            'email'         => $this->_user->email,
258
+            'username'      => $this->_user->username,
259
+            'user_role'     => $this->_user->role->id
260
+        );
261
+
262
+        return $this;
263
+    }
264
+
265
+    /**
266
+     * Updates the user's profile information
267
+     * @return boolean
268
+     */
269
+    public function save()
270
+    {
271
+        if (!$this->validate(NULL, false))
272
+            return false;
273
+
274
+        // Change the email address, if necessary
275
+        $this->changeEmail();
276
+
277
+        $this->_user->attributes = array(
278
+            'password'      => $this->password,
279
+            'username'      => $this->username,
280
+            'user_role'     => $this->user_role
281
+        );
282
+
283
+        if ($this->_user->save())
284
+            return true;
285
+
286
+        return false;
287
+    }
288
+
289
+    /**
290
+     * Changes the user's email address if necessary
291
+     * @return boolean
292
+     */
293
+    private function changeEmail()
294
+    {
295
+        if ($this->email != $this->_user->email)
296
+        {
297
+            $this->setNewemail();
298
+            $this->setNewEmailChangeKey();
299
+            $this->sendVerificationEmail();
300
+        }
301
+
302
+        return true;
303
+    }
304
+
305
+    /**
306
+     * Sends the verification email to the user. This is broken to it's own method to allow for the resending email to be resent
307
+     * @return boolean
308
+     */
309
+    public function sendVerificationEmail()
310
+    {
311
+        $emailSettings = new EmailSettings;
312 312
         return $emailSettings->send(
313
-			$this->_user,
314
-			Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'),
315
-			'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.email-change',
316
-			array(
317
-				'key' => $this->setNewEmailChangeKey(),
318
-				'user' => $this->_user
319
-			)
320
-		);
321
-	}
313
+            $this->_user,
314
+            Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'),
315
+            'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.email-change',
316
+            array(
317
+                'key' => $this->setNewEmailChangeKey(),
318
+                'user' => $this->_user
319
+            )
320
+        );
321
+    }
322 322
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -52,16 +52,16 @@  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
-		var_dump($this->overridePasswordCheck);
58
-		var_dump(Yii::app()->user->id);
59
-		var_dump($this->getId());
57
+		var_dump ($this->overridePasswordCheck);
58
+		var_dump (Yii::app ()->user->id);
59
+		var_dump ($this->getId ());
60 60
 		die();
61 61
 		if ($this->overridePasswordCheck)
62 62
 			return true;
63 63
 
64
-		if (isset(Yii::app()->user) && $this->getId() == Yii::app()->user->id)
64
+		if (isset(Yii::app ()->user) && $this->getId () == Yii::app ()->user->id)
65 65
 			return true;
66 66
 
67 67
 		return false;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * Overload of the __getter method to retrieve the user's ID
72 72
 	 * @var int $id
73 73
 	 */
74
-	public function getId()
74
+	public function getId ()
75 75
 	{
76 76
 		return $this->_user->id;
77 77
 	}
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * Retrieves the new email address if it is set
81 81
 	 * @return mixed
82 82
 	 */
83
-	public function getNewEmail()
83
+	public function getNewEmail ()
84 84
 	{
85
-		$metadata = UserMetadata::model()->findByAttributes(array(
85
+		$metadata = UserMetadata::model ()->findByAttributes (array(
86 86
 			'user_id' => $this->_user->id,
87 87
 			'key'     => 'newEmailAddress'
88 88
 		));
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * Sets the new email address
98 98
 	 * @return boolean
99 99
 	 */
100
-	public function setNewEmail()
100
+	public function setNewEmail ()
101 101
 	{
102
-		$metadata = UserMetadata::model()->findByAttributes(array(
102
+		$metadata = UserMetadata::model ()->findByAttributes (array(
103 103
 			'user_id' => $this->_user->id,
104 104
 			'key'     => 'newEmailAddress'
105 105
 		));
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 		$metadata->value = $this->email;
117 117
 
118 118
 		// Save the record
119
-		return $metadata->save();
119
+		return $metadata->save ();
120 120
 	}
121 121
 
122 122
 	/**
123 123
 	 * Retrieves the new email address if it is set
124 124
 	 * @return mixed
125 125
 	 */
126
-	public function getNewEmailChangeKey()
126
+	public function getNewEmailChangeKey ()
127 127
 	{
128
-		$metadata = UserMetadata::model()->findByAttributes(array(
128
+		$metadata = UserMetadata::model ()->findByAttributes (array(
129 129
 			'user_id' => $this->_user->id,
130 130
 			'key'     => 'newEmailAddressChangeKey'
131 131
 		));
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 	 * Generates a new change key
141 141
 	 * @return boolean
142 142
 	 */
143
-	public function setNewEmailChangeKey()
143
+	public function setNewEmailChangeKey ()
144 144
 	{
145
-		$metadata = UserMetadata::model()->findByAttributes(array(
145
+		$metadata = UserMetadata::model ()->findByAttributes (array(
146 146
 			'user_id' => $this->_user->id,
147 147
 			'key'     => 'newEmailAddressChangeKey'
148 148
 		));
@@ -157,20 +157,20 @@  discard block
 block discarded – undo
157 157
 		}
158 158
 
159 159
 		// Generate a new key
160
-		$metadata->value = Cii::generateSafeHash();
160
+		$metadata->value = Cii::generateSafeHash ();
161 161
 
162 162
 		// Save the record
163
-		if ($metadata->save())
163
+		if ($metadata->save ())
164 164
 			return $metadata->value;
165 165
 	
166
-		throw new CHttpException(500, Yii::t('ciims.ProfileForm', 'Unable to save change key'));
166
+		throw new CHttpException (500, Yii::t ('ciims.ProfileForm', 'Unable to save change key'));
167 167
 	}
168 168
 
169 169
 	/**
170 170
 	 * Validation rules
171 171
 	 * @return array
172 172
 	 */
173
-	public function rules()
173
+	public function rules ()
174 174
 	{
175 175
 		return array(
176 176
 			array('email, username', 'required'),
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	 * Retrieves the attributes labels from the Users model and returns them to reduce code redundancy
188 188
 	 * @return array
189 189
 	 */
190
-	public function attributeLabels()
190
+	public function attributeLabels ()
191 191
 	{
192
-		return CMap::mergeArray(Users::model()->attributeLabels(), array(
193
-			'currentPassword' => Yii::t('ciims.models.ProfileForm', 'Your current password'),
194
-			'password_repeat' => Yii::t('ciims.models.ProfileForm', 'Your New Password (again)')
192
+		return CMap::mergeArray (Users::model ()->attributeLabels (), array(
193
+			'currentPassword' => Yii::t ('ciims.models.ProfileForm', 'Your current password'),
194
+			'password_repeat' => Yii::t ('ciims.models.ProfileForm', 'Your New Password (again)')
195 195
 		));
196 196
 	}
197 197
 
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 	 * @param array $params
202 202
 	 * return array
203 203
 	 */
204
-	public function validateUserRole($attributes, $params)
204
+	public function validateUserRole ($attributes, $params)
205 205
 	{
206
-		if ($this->canOverridePasswordCheck())
206
+		if ($this->canOverridePasswordCheck ())
207 207
 			return true;
208 208
 
209
-		$this->addError('user_role', Yii::t('ciims.models.ProfileForm', 'You do not have permission to modify this attribute'));
209
+		$this->addError ('user_role', Yii::t ('ciims.models.ProfileForm', 'You do not have permission to modify this attribute'));
210 210
 		return false;
211 211
 	}
212 212
 
@@ -216,20 +216,20 @@  discard block
 block discarded – undo
216 216
 	 * @param array $params
217 217
 	 * return array
218 218
 	 */
219
-	public function validateUserPassword($attributes, $params)
219
+	public function validateUserPassword ($attributes, $params)
220 220
 	{
221 221
 		// Apply the override if it was set
222
-		if ($this->canOverridePasswordCheck())
222
+		if ($this->canOverridePasswordCheck ())
223 223
 		{
224 224
 			$this->password_repeat = $this->password;
225 225
 			return true;
226 226
 		}
227 227
 
228
-		$result = password_verify($this->password, $this->_user->password);
228
+		$result = password_verify ($this->password, $this->_user->password);
229 229
 		
230 230
 		if ($result == false)
231 231
 		{
232
-			$this->addError('currentPassword', Yii::t('ciims.models.ProfileForm', 'The password you entered is invalid.'));
232
+			$this->addError ('currentPassword', Yii::t ('ciims.models.ProfileForm', 'The password you entered is invalid.'));
233 233
 			return false;
234 234
 		}
235 235
 
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 	 * @param bool $override   This form may be reused
243 243
 	 * @return ProfileForm
244 244
 	 */
245
-	public function load($id, $override = false)
245
+	public function load ($id, $override = false)
246 246
 	{
247 247
 		$this->overridePasswordCheck = $override;
248 248
 
249 249
 		// Load the user
250
-		$this->_user = Users::model()->findByPk($id);
250
+		$this->_user = Users::model ()->findByPk ($id);
251 251
 
252 252
 		if ($this->_user == NULL)
253
-			throw new CHttpException(400, Yii::t('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded'));
253
+			throw new CHttpException (400, Yii::t ('ciims.models.ProfileForm', 'The request user\'s profile could not be loaded'));
254 254
 
255 255
 		// Reload the attribute labels
256 256
 		$this->attributes = array(
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 	 * Updates the user's profile information
267 267
 	 * @return boolean
268 268
 	 */
269
-	public function save()
269
+	public function save ()
270 270
 	{
271
-		if (!$this->validate(NULL, false))
271
+		if (!$this->validate (NULL, false))
272 272
 			return false;
273 273
 
274 274
 		// Change the email address, if necessary
275
-		$this->changeEmail();
275
+		$this->changeEmail ();
276 276
 
277 277
 		$this->_user->attributes = array(
278 278
 			'password'      => $this->password,
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 			'user_role'     => $this->user_role
281 281
 		);
282 282
 
283
-		if ($this->_user->save())
283
+		if ($this->_user->save ())
284 284
 			return true;
285 285
 
286 286
 		return false;
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 	 * Changes the user's email address if necessary
291 291
 	 * @return boolean
292 292
 	 */
293
-	private function changeEmail()
293
+	private function changeEmail ()
294 294
 	{
295 295
 		if ($this->email != $this->_user->email)
296 296
 		{
297
-			$this->setNewemail();
298
-			$this->setNewEmailChangeKey();
299
-			$this->sendVerificationEmail();
297
+			$this->setNewemail ();
298
+			$this->setNewEmailChangeKey ();
299
+			$this->sendVerificationEmail ();
300 300
 		}
301 301
 
302 302
 		return true;
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
 	 * Sends the verification email to the user. This is broken to it's own method to allow for the resending email to be resent
307 307
 	 * @return boolean
308 308
 	 */
309
-	public function sendVerificationEmail()
309
+	public function sendVerificationEmail ()
310 310
 	{
311 311
 		$emailSettings = new EmailSettings;
312
-        return $emailSettings->send(
312
+        return $emailSettings->send (
313 313
 			$this->_user,
314
-			Yii::t('ciims.models.Users', 'CiiMS Email Change Notification'),
315
-			'base.themes.' . Cii::getConfig('theme', 'default') .'.views.email.email-change',
314
+			Yii::t ('ciims.models.Users', 'CiiMS Email Change Notification'),
315
+			'base.themes.' . Cii::getConfig ('theme', 'default') . '.views.email.email-change',
316 316
 			array(
317
-				'key' => $this->setNewEmailChangeKey(),
317
+				'key' => $this->setNewEmailChangeKey (),
318 318
 				'user' => $this->_user
319 319
 			)
320 320
 		);
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.
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.
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/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
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.
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.