Completed
Push — master ( e5db64...945d9a )
by Schlaefer
05:09 queued 28s
created
app/Controller/Component/SaitoEmailComponent.php 1 patch
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -1,79 +1,79 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('Component', 'Controller');
4
-	App::uses('CakeEmail', 'Network/Email');
3
+    App::uses('Component', 'Controller');
4
+    App::uses('CakeEmail', 'Network/Email');
5 5
 
6
-	class SaitoEmailComponent extends Component {
6
+    class SaitoEmailComponent extends Component {
7 7
 
8
-		protected $_emailConfigExists = null;
8
+        protected $_emailConfigExists = null;
9 9
 
10
-		protected $_User = null;
10
+        protected $_User = null;
11 11
 
12
-		protected $_config = array();
12
+        protected $_config = array();
13 13
 
14
-		protected $_viewVars = array();
14
+        protected $_viewVars = array();
15 15
 
16
-		/**
17
-		 * @var array ['User' => ['username' => , 'user_email' =>]
18
-		 */
19
-		protected $_recipient = null;
16
+        /**
17
+         * @var array ['User' => ['username' => , 'user_email' =>]
18
+         */
19
+        protected $_recipient = null;
20 20
 
21
-		/**
22
-		 * @var array ['User' => ['username' => , 'user_email' =>]
23
-		 */
24
-		protected $_sender = null;
21
+        /**
22
+         * @var array ['User' => ['username' => , 'user_email' =>]
23
+         */
24
+        protected $_sender = null;
25 25
 
26
-		/**
27
-		 * @var CakeEmail
28
-		 */
29
-		protected $_CakeEmail;
26
+        /**
27
+         * @var CakeEmail
28
+         */
29
+        protected $_CakeEmail;
30 30
 
31
-		protected $_webroot;
31
+        protected $_webroot;
32 32
 
33
-		protected $_appAddress;
33
+        protected $_appAddress;
34 34
 
35
-		protected $_addresses;
35
+        protected $_addresses;
36 36
 
37
-		protected $_forumName;
37
+        protected $_forumName;
38 38
 
39
-		protected $_headerSent;
39
+        protected $_headerSent;
40 40
 
41
-		protected $_predefined = ['contact', 'main', 'register', 'system'];
41
+        protected $_predefined = ['contact', 'main', 'register', 'system'];
42 42
 
43
-		public function startup(Controller $Controller) {
44
-			$this->_webroot = $Controller->request->webroot;
45
-			$this->_User = $Controller->User;
46
-		}
43
+        public function startup(Controller $Controller) {
44
+            $this->_webroot = $Controller->request->webroot;
45
+            $this->_User = $Controller->User;
46
+        }
47 47
 
48
-		/**
49
-		 * init only if mail is actually send during request
50
-		 *
51
-		 * @throws InvalidArgumentException
52
-		 */
53
-		protected function _init() {
54
-			if ($this->_addresses !== null) {
55
-				return;
56
-			}
48
+        /**
49
+         * init only if mail is actually send during request
50
+         *
51
+         * @throws InvalidArgumentException
52
+         */
53
+        protected function _init() {
54
+            if ($this->_addresses !== null) {
55
+                return;
56
+            }
57 57
 
58
-			$this->_addresses = [
59
-				'main' => Configure::read('Saito.Settings.forum_email'),
60
-				'contact' => Configure::read('Saito.Settings.email_contact'),
61
-				'register' => Configure::read('Saito.Settings.email_register'),
62
-				'system' => Configure::read('Saito.Settings.email_system')
63
-			];
58
+            $this->_addresses = [
59
+                'main' => Configure::read('Saito.Settings.forum_email'),
60
+                'contact' => Configure::read('Saito.Settings.email_contact'),
61
+                'register' => Configure::read('Saito.Settings.email_register'),
62
+                'system' => Configure::read('Saito.Settings.email_system')
63
+            ];
64 64
 
65
-			foreach ($this->_addresses as $title => $address) {
66
-				if (empty($address)) {
67
-					throw new InvalidArgumentException("Email address not set: $title");
68
-				}
69
-			}
65
+            foreach ($this->_addresses as $title => $address) {
66
+                if (empty($address)) {
67
+                    throw new InvalidArgumentException("Email address not set: $title");
68
+                }
69
+            }
70 70
 
71
-			$this->_emailConfigExists = file_exists(APP . 'Config' . DS . 'email' . '.php');
71
+            $this->_emailConfigExists = file_exists(APP . 'Config' . DS . 'email' . '.php');
72 72
 
73
-			$this->_forumName = Configure::read('Saito.Settings.forum_name');
73
+            $this->_forumName = Configure::read('Saito.Settings.forum_name');
74 74
 
75
-			$this->_CakeEmail = new CakeEmail();
76
-		}
75
+            $this->_CakeEmail = new CakeEmail();
76
+        }
77 77
 
78 78
 /**
79 79
  *
@@ -89,172 +89,172 @@  discard block
 block discarded – undo
89 89
  * @param array $options
90 90
  * @return array
91 91
  */
92
-		public function email($options = array()) {
93
-			$this->_init();
94
-			$this->_resetConfig();
95
-			$this->_config($options);
96
-			$result = $this->_send($this->_config, $this->_viewVars);
97
-
98
-			if (isset($options['ccsender']) && $options['ccsender'] === true) {
99
-				$result = $this->_sendCopyToOriginalSender($this->_config,
100
-					$this->_viewVars);
101
-			}
102
-
103
-			return $result;
104
-		}
105
-
106
-		protected function _resetConfig() {
107
-			$this->_config = [];
108
-			$this->_viewVars = [];
109
-			$this->_CakeEmail->reset();
110
-		}
111
-
112
-		protected function _config($params = []) {
113
-			$defaults = [
114
-				'viewVars' => [
115
-					'webroot' => Router::fullBaseUrl() . $this->_webroot,
116
-				],
117
-			];
118
-			$params = array_merge_recursive($defaults, $params);
119
-
120
-			$this->_initConfigFromFile();
121
-
122
-			$this->_sender = $this->_getSender($params['sender']);
123
-			$this->_recipient = $this->_getRecipient($params['recipient']);
124
-
125
-			$this->_config = [
126
-				'from' => $this->_pA($this->_sender,
127
-						$this->_sender['User']['username']),
128
-				'to' => $this->_recipient['User']['user_email'],
129
-				'subject' => $params['subject'],
130
-				'emailFormat' => 'text',
131
-			];
132
-
133
-			//# set 'sender' header
134
-			$headerSender = $this->_getHeaderSender();
135
-			if ($headerSender) {
136
-				$this->_config['sender'] = $headerSender;
137
-			}
138
-
139
-			if (isset($params['template'])) {
140
-				$this->_config['template'] = $params['template'];
141
-			}
142
-
143
-			if (isset($params['message'])) {
144
-				$this->_viewVars['message'] = $params['message'];
145
-			}
146
-			$this->_viewVars += $params['viewVars'];
147
-
148
-			$this->_configTransport();
149
-		}
150
-
151
-		protected function _configTransport() {
152
-			if (Configure::read('debug') > 2 || Configure::read('Saito.Debug.email')) {
153
-				$this->_config['transport'] = 'Debug';
154
-			};
155
-			if (Configure::read('debug') > 2) {
156
-				$this->_config['log'] = true;
157
-			};
158
-		}
159
-
160
-		protected function _getHeaderSender() {
161
-			if ($this->_emailConfigExists && $this->_CakeEmail->from()) {
162
-				// set the forum app address from email.php
163
-				$hs = $this->_CakeEmail->from();
164
-
165
-				// set app address name to forum's name if it's not set in email.php
166
-				if ((is_array($hs) && key($hs) === current($hs))) {
167
-					$hs = $this->_pA(key($hs));
168
-				}
169
-			} elseif ($this->_headerSent) {
170
-				$type = $this->_headerSent;
171
-				$hs = $this->_pA($this->_addresses[$type]);
172
-			} else {
173
-				$hs = false;
174
-			}
175
-			return $hs;
176
-		}
177
-
178
-		/**
179
-		 * returns participant array (Cake mail array)
180
-		 *
181
-		 * @param $address string with address or ['User']-sender/recipient
182
-		 * @param $name
183
-		 * @return array [<address> => <name>]
184
-		 */
185
-		protected function _pA($address, $name = null) {
186
-			if (is_array($address) && isset($address['User'])) {
187
-				$name = $address['User']['username'];
188
-				$address = $address['User']['user_email'];
189
-			}
190
-			if ($name === null) {
191
-				$name = $this->_forumName;
192
-			}
193
-			return [$address => $name];
194
-		}
195
-
196
-		/**
197
-		 * set base config from app/config/email.php
198
-		 */
199
-		protected function _initConfigFromFile() {
200
-			if (!$this->_emailConfigExists) {
201
-				return;
202
-			}
203
-			$this->_CakeEmail->config('saito');
204
-		}
205
-
206
-		public function getPredefinedSender($type) {
207
-			$this->_init();
208
-			return ['User' => [
209
-				'username' => $this->_forumName,
210
-				'user_email' => $this->_addresses[$type]
211
-			]];
212
-		}
213
-
214
-		protected function _getRecipient($recipient) {
215
-			return $this->_getParticipant($recipient);
216
-		}
217
-
218
-		protected function _getSender($sender) {
219
-			if (!is_string($sender) ||
220
-					!in_array($sender, $this->_predefined)
221
-			) {
222
-				// sender-address does not belong to system: is external address
223
-				// and should be send 'in behalf off'
224
-				$this->_headerSent = 'system';
225
-			}
226
-			return $this->_getParticipant($sender);
227
-		}
228
-
229
-		/**
230
-		 * @param $value
231
-		 * @return array
232
-		 * @throws Exception
233
-		 */
234
-		protected function _getParticipant($value) {
235
-			//# participant-address is valid address
236
-			if (is_array($value)) {
237
-				return $value;
238
-			}
239
-
240
-			//# participant-address belongs to system
241
-			if (is_string($value) &&
242
-				in_array($value, $this->_predefined)
243
-			) {
244
-				return $this->getPredefinedSender($value);
245
-			}
246
-
247
-			//# participant-address belongs to external user
248
-			$this->_User->id = $value;
249
-			$this->_User->contain();
250
-			$participant = $this->_User->read();
251
-
252
-			if (empty($participant)) {
253
-				throw new Exception("Can't find participant for email.");
254
-			}
255
-
256
-			return $participant;
257
-		}
92
+        public function email($options = array()) {
93
+            $this->_init();
94
+            $this->_resetConfig();
95
+            $this->_config($options);
96
+            $result = $this->_send($this->_config, $this->_viewVars);
97
+
98
+            if (isset($options['ccsender']) && $options['ccsender'] === true) {
99
+                $result = $this->_sendCopyToOriginalSender($this->_config,
100
+                    $this->_viewVars);
101
+            }
102
+
103
+            return $result;
104
+        }
105
+
106
+        protected function _resetConfig() {
107
+            $this->_config = [];
108
+            $this->_viewVars = [];
109
+            $this->_CakeEmail->reset();
110
+        }
111
+
112
+        protected function _config($params = []) {
113
+            $defaults = [
114
+                'viewVars' => [
115
+                    'webroot' => Router::fullBaseUrl() . $this->_webroot,
116
+                ],
117
+            ];
118
+            $params = array_merge_recursive($defaults, $params);
119
+
120
+            $this->_initConfigFromFile();
121
+
122
+            $this->_sender = $this->_getSender($params['sender']);
123
+            $this->_recipient = $this->_getRecipient($params['recipient']);
124
+
125
+            $this->_config = [
126
+                'from' => $this->_pA($this->_sender,
127
+                        $this->_sender['User']['username']),
128
+                'to' => $this->_recipient['User']['user_email'],
129
+                'subject' => $params['subject'],
130
+                'emailFormat' => 'text',
131
+            ];
132
+
133
+            //# set 'sender' header
134
+            $headerSender = $this->_getHeaderSender();
135
+            if ($headerSender) {
136
+                $this->_config['sender'] = $headerSender;
137
+            }
138
+
139
+            if (isset($params['template'])) {
140
+                $this->_config['template'] = $params['template'];
141
+            }
142
+
143
+            if (isset($params['message'])) {
144
+                $this->_viewVars['message'] = $params['message'];
145
+            }
146
+            $this->_viewVars += $params['viewVars'];
147
+
148
+            $this->_configTransport();
149
+        }
150
+
151
+        protected function _configTransport() {
152
+            if (Configure::read('debug') > 2 || Configure::read('Saito.Debug.email')) {
153
+                $this->_config['transport'] = 'Debug';
154
+            };
155
+            if (Configure::read('debug') > 2) {
156
+                $this->_config['log'] = true;
157
+            };
158
+        }
159
+
160
+        protected function _getHeaderSender() {
161
+            if ($this->_emailConfigExists && $this->_CakeEmail->from()) {
162
+                // set the forum app address from email.php
163
+                $hs = $this->_CakeEmail->from();
164
+
165
+                // set app address name to forum's name if it's not set in email.php
166
+                if ((is_array($hs) && key($hs) === current($hs))) {
167
+                    $hs = $this->_pA(key($hs));
168
+                }
169
+            } elseif ($this->_headerSent) {
170
+                $type = $this->_headerSent;
171
+                $hs = $this->_pA($this->_addresses[$type]);
172
+            } else {
173
+                $hs = false;
174
+            }
175
+            return $hs;
176
+        }
177
+
178
+        /**
179
+         * returns participant array (Cake mail array)
180
+         *
181
+         * @param $address string with address or ['User']-sender/recipient
182
+         * @param $name
183
+         * @return array [<address> => <name>]
184
+         */
185
+        protected function _pA($address, $name = null) {
186
+            if (is_array($address) && isset($address['User'])) {
187
+                $name = $address['User']['username'];
188
+                $address = $address['User']['user_email'];
189
+            }
190
+            if ($name === null) {
191
+                $name = $this->_forumName;
192
+            }
193
+            return [$address => $name];
194
+        }
195
+
196
+        /**
197
+         * set base config from app/config/email.php
198
+         */
199
+        protected function _initConfigFromFile() {
200
+            if (!$this->_emailConfigExists) {
201
+                return;
202
+            }
203
+            $this->_CakeEmail->config('saito');
204
+        }
205
+
206
+        public function getPredefinedSender($type) {
207
+            $this->_init();
208
+            return ['User' => [
209
+                'username' => $this->_forumName,
210
+                'user_email' => $this->_addresses[$type]
211
+            ]];
212
+        }
213
+
214
+        protected function _getRecipient($recipient) {
215
+            return $this->_getParticipant($recipient);
216
+        }
217
+
218
+        protected function _getSender($sender) {
219
+            if (!is_string($sender) ||
220
+                    !in_array($sender, $this->_predefined)
221
+            ) {
222
+                // sender-address does not belong to system: is external address
223
+                // and should be send 'in behalf off'
224
+                $this->_headerSent = 'system';
225
+            }
226
+            return $this->_getParticipant($sender);
227
+        }
228
+
229
+        /**
230
+         * @param $value
231
+         * @return array
232
+         * @throws Exception
233
+         */
234
+        protected function _getParticipant($value) {
235
+            //# participant-address is valid address
236
+            if (is_array($value)) {
237
+                return $value;
238
+            }
239
+
240
+            //# participant-address belongs to system
241
+            if (is_string($value) &&
242
+                in_array($value, $this->_predefined)
243
+            ) {
244
+                return $this->getPredefinedSender($value);
245
+            }
246
+
247
+            //# participant-address belongs to external user
248
+            $this->_User->id = $value;
249
+            $this->_User->contain();
250
+            $participant = $this->_User->read();
251
+
252
+            if (empty($participant)) {
253
+                throw new Exception("Can't find participant for email.");
254
+            }
255
+
256
+            return $participant;
257
+        }
258 258
 
259 259
 /**
260 260
  * Sends a copy of a completely configured email to the author
@@ -262,33 +262,33 @@  discard block
 block discarded – undo
262 262
  * @param $config
263 263
  * @param $viewVars
264 264
  */
265
-		protected function _sendCopyToOriginalSender($config, $viewVars) {
266
-			// use name for recipient if available
267
-			if (!empty($this->_recipient['User']['username'])) {
268
-				$emailConfig['to'] = $this->_pA($this->_recipient['User']['user_email'],
269
-					$this->_recipient['User']['username']);
270
-			}
271
-
272
-			// set new subject
273
-			$data = array('subject' => $config['subject']);
274
-			if (is_array($config['to'])) {
275
-				$data['recipient-name'] = current($config['to']);
276
-				$str = __('Copy of your message: ":subject" to ":recipient-name"');
277
-			} else {
278
-				$str = __('Copy of your message: ":subject"');
279
-			}
280
-			$config['subject'] = CakeText::insert($str, $data);
281
-
282
-			// set new addresses
283
-			$config['to'] = $config['from'];
284
-			// @todo should be system message
285
-			$config['from'] = $this->_pA($this->getPredefinedSender('system'));
286
-
287
-			// CC is always send by system
288
-			unset($config['sender']);
289
-
290
-			return $this->_send($config, $viewVars);
291
-		}
265
+        protected function _sendCopyToOriginalSender($config, $viewVars) {
266
+            // use name for recipient if available
267
+            if (!empty($this->_recipient['User']['username'])) {
268
+                $emailConfig['to'] = $this->_pA($this->_recipient['User']['user_email'],
269
+                    $this->_recipient['User']['username']);
270
+            }
271
+
272
+            // set new subject
273
+            $data = array('subject' => $config['subject']);
274
+            if (is_array($config['to'])) {
275
+                $data['recipient-name'] = current($config['to']);
276
+                $str = __('Copy of your message: ":subject" to ":recipient-name"');
277
+            } else {
278
+                $str = __('Copy of your message: ":subject"');
279
+            }
280
+            $config['subject'] = CakeText::insert($str, $data);
281
+
282
+            // set new addresses
283
+            $config['to'] = $config['from'];
284
+            // @todo should be system message
285
+            $config['from'] = $this->_pA($this->getPredefinedSender('system'));
286
+
287
+            // CC is always send by system
288
+            unset($config['sender']);
289
+
290
+            return $this->_send($config, $viewVars);
291
+        }
292 292
 
293 293
 /**
294 294
  * Sends the completely configured email
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
  * @param $config
297 297
  * @param $viewVars
298 298
  */
299
-		protected function _send($config, $viewVars) {
300
-			$email = $this->_CakeEmail;
301
-			// workaround for http://cakephp.lighthouseapp.com/projects/42648/tickets/2855-cakeemail-transports-have-ambiguous-config-behaviors
302
-			$email->config(array_merge($this->_CakeEmail->config(), $config));
303
-			$email->viewVars($viewVars);
304
-			return $email->send();
305
-		}
306
-
307
-	}
308 299
\ No newline at end of file
300
+        protected function _send($config, $viewVars) {
301
+            $email = $this->_CakeEmail;
302
+            // workaround for http://cakephp.lighthouseapp.com/projects/42648/tickets/2855-cakeemail-transports-have-ambiguous-config-behaviors
303
+            $email->config(array_merge($this->_CakeEmail->config(), $config));
304
+            $email->viewVars($viewVars);
305
+            return $email->send();
306
+        }
307
+
308
+    }
309 309
\ No newline at end of file
Please login to merge, or discard this patch.
app/Controller/Component/CurrentUserComponent.php 1 patch
Indentation   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -1,318 +1,318 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	use Saito\User\Auth\CategoryAuthorization;
4
-	use Saito\User\Bookmarks;
5
-	use Saito\User\ForumsUserInterface;
6
-	use Saito\User\LastRefresh;
7
-	use Saito\User\ReadPostings;
8
-	use Saito\User\SaitoUserTrait;
3
+    use Saito\User\Auth\CategoryAuthorization;
4
+    use Saito\User\Bookmarks;
5
+    use Saito\User\ForumsUserInterface;
6
+    use Saito\User\LastRefresh;
7
+    use Saito\User\ReadPostings;
8
+    use Saito\User\SaitoUserTrait;
9 9
 
10
-	App::uses('Component', 'Controller');
10
+    App::uses('Component', 'Controller');
11 11
 
12
-	class CurrentUserComponent extends Component implements
13
-		ArrayAccess,
14
-		ForumsUserInterface {
12
+    class CurrentUserComponent extends Component implements
13
+        ArrayAccess,
14
+        ForumsUserInterface {
15 15
 
16
-		use SaitoUserTrait;
16
+        use SaitoUserTrait;
17 17
 
18
-		/**
19
-		 * @var Saito\User\Auth\CategoryAuthorization
20
-		 */
21
-		public $Categories;
18
+        /**
19
+         * @var Saito\User\Auth\CategoryAuthorization
20
+         */
21
+        public $Categories;
22 22
 
23 23
 /**
24 24
  * Component name
25 25
  *
26 26
  * @var string
27 27
  */
28
-		public $name = 'CurrentUser';
28
+        public $name = 'CurrentUser';
29 29
 
30 30
 /**
31 31
  * Component's components
32 32
  *
33 33
  * @var array
34 34
  */
35
-		public $components = ['Cookie', 'Cron.Cron'];
35
+        public $components = ['Cookie', 'Cron.Cron'];
36 36
 
37 37
 /**
38 38
  * Manages the persistent login cookie
39 39
  *
40 40
  * @var \Saito\User\Cookie\CurrentUserCookie
41 41
  */
42
-		public $PersistentCookie = null;
42
+        public $PersistentCookie = null;
43 43
 
44 44
 /**
45 45
  * Manages the last refresh/mark entries as read for the current user
46 46
  *
47 47
  * @var \Saito\User\LastRefresh\LastRefreshAbstract
48 48
  */
49
-		public $LastRefresh = null;
49
+        public $LastRefresh = null;
50 50
 
51
-	/**
52
-	 * @var ReadPostings
53
-	 */
54
-		public $ReadEntries;
51
+    /**
52
+     * @var ReadPostings
53
+     */
54
+        public $ReadEntries;
55 55
 
56
-		/**
57
-		 * @var Bookmarks bookmarks of the current user
58
-		 */
59
-		protected $_Bookmarks;
56
+        /**
57
+         * @var Bookmarks bookmarks of the current user
58
+         */
59
+        protected $_Bookmarks;
60 60
 
61 61
 /**
62 62
  * Model User instance exclusive to the CurrentUserComponent
63 63
  *
64 64
  * @var User
65 65
  */
66
-		protected $_User = null;
66
+        protected $_User = null;
67 67
 
68 68
 /**
69 69
  * Reference to the controller
70 70
  *
71 71
  * @var Controller
72 72
  */
73
-		protected $_Controller = null;
73
+        protected $_Controller = null;
74 74
 
75
-		public function initialize(Controller $Controller) {
76
-			if ($Controller->name === 'CakeError') {
77
-				return;
78
-			}
75
+        public function initialize(Controller $Controller) {
76
+            if ($Controller->name === 'CakeError') {
77
+                return;
78
+            }
79 79
 
80
-			$this->_Controller = $Controller;
81
-			if ($this->_Controller->modelClass) {
82
-				$this->_Controller->{$this->_Controller->modelClass}->SharedObjects['CurrentUser'] = $this;
83
-			}
84
-			$this->Categories = new CategoryAuthorization($this);
80
+            $this->_Controller = $Controller;
81
+            if ($this->_Controller->modelClass) {
82
+                $this->_Controller->{$this->_Controller->modelClass}->SharedObjects['CurrentUser'] = $this;
83
+            }
84
+            $this->Categories = new CategoryAuthorization($this);
85 85
 
86
-			$this->_Controller->dic->set('CU', $this);
86
+            $this->_Controller->dic->set('CU', $this);
87 87
 
88
-			/*
88
+            /*
89 89
 			 * We create a new User Model instance. Otherwise we would overwrite $this->request->data
90 90
 			 * when reading in refresh(), causing error e.g. saving the user prefs.
91 91
 			 */
92
-			$this->_User = ClassRegistry::init(
93
-					['class' => 'User', 'alias' => 'currentUser']
94
-			);
95
-
96
-			$this->PersistentCookie = new \Saito\User\Cookie\CurrentUserCookie($this->Cookie, 'AU');
97
-
98
-			$this->_configureAuth();
99
-
100
-			// prevents session auto re-login from form's request->data: login is
101
-			// called explicitly by controller on /users/login
102
-			if ($this->_Controller->action !== 'login') {
103
-				if (!$this->_reLoginSession()) {
104
-					// don't auto-login on login related pages
105
-					if ($this->_Controller->params['action'] !== 'login' &&
106
-							$this->_Controller->params['action'] !== 'register' &&
107
-							$this->_Controller->referer() !== '/users/login'
108
-					) {
109
-						$this->_reLoginCookie();
110
-					}
111
-				}
112
-			}
113
-
114
-			if ($this->isLoggedIn()) {
115
-				$this->ReadEntries = new ReadPostings\ReadPostingsDatabase($this);
116
-			} elseif ($this->isBot()) {
117
-				$this->ReadEntries = new ReadPostings\ReadPostingsDummy($this);
118
-			} else {
119
-				$this->ReadEntries = new ReadPostings\ReadPostingsCookie($this);
120
-			}
121
-
122
-			$this->_Bookmarks = new Bookmarks($this);
123
-
124
-			$this->_markOnline();
125
-		}
126
-
127
-		public function startup(Controller $controller) {
128
-			parent::startup($controller);
129
-
130
-			if ($controller->action !== 'logout' && $this->isLoggedIn()) :
131
-				if ($this->isForbidden()) :
132
-					$this->_Controller->redirect(
133
-						['controller' => 'users', 'action' => 'logout']
134
-					);
135
-				endif;
136
-			endif;
137
-		}
92
+            $this->_User = ClassRegistry::init(
93
+                    ['class' => 'User', 'alias' => 'currentUser']
94
+            );
95
+
96
+            $this->PersistentCookie = new \Saito\User\Cookie\CurrentUserCookie($this->Cookie, 'AU');
97
+
98
+            $this->_configureAuth();
99
+
100
+            // prevents session auto re-login from form's request->data: login is
101
+            // called explicitly by controller on /users/login
102
+            if ($this->_Controller->action !== 'login') {
103
+                if (!$this->_reLoginSession()) {
104
+                    // don't auto-login on login related pages
105
+                    if ($this->_Controller->params['action'] !== 'login' &&
106
+                            $this->_Controller->params['action'] !== 'register' &&
107
+                            $this->_Controller->referer() !== '/users/login'
108
+                    ) {
109
+                        $this->_reLoginCookie();
110
+                    }
111
+                }
112
+            }
113
+
114
+            if ($this->isLoggedIn()) {
115
+                $this->ReadEntries = new ReadPostings\ReadPostingsDatabase($this);
116
+            } elseif ($this->isBot()) {
117
+                $this->ReadEntries = new ReadPostings\ReadPostingsDummy($this);
118
+            } else {
119
+                $this->ReadEntries = new ReadPostings\ReadPostingsCookie($this);
120
+            }
121
+
122
+            $this->_Bookmarks = new Bookmarks($this);
123
+
124
+            $this->_markOnline();
125
+        }
126
+
127
+        public function startup(Controller $controller) {
128
+            parent::startup($controller);
129
+
130
+            if ($controller->action !== 'logout' && $this->isLoggedIn()) :
131
+                if ($this->isForbidden()) :
132
+                    $this->_Controller->redirect(
133
+                        ['controller' => 'users', 'action' => 'logout']
134
+                    );
135
+                endif;
136
+            endif;
137
+        }
138 138
 
139 139
 /**
140 140
  * Marks users as online
141 141
  */
142
-		protected function _markOnline() {
143
-			Stopwatch::start('CurrentUser->_markOnline()');
144
-			$_isLoggedIn = $this->isLoggedIn();
145
-			if ($_isLoggedIn) {
146
-				$_id = $this->getId();
147
-			} else {
148
-				// don't count search bots as guests
149
-				if ($this->isBot()) {
150
-					return;
151
-				}
152
-				$_id = $this->_Controller->Session->id();
153
-			}
154
-			$this->_User->UserOnline->setOnline($_id, $_isLoggedIn);
155
-			Stopwatch::stop('CurrentUser->_markOnline()');
156
-		}
157
-
158
-		/**
159
-		 * Detects if the current user is a bot
160
-		 *
161
-		 * @return boolean
162
-		 */
163
-		public function isBot() {
164
-			return $this->_Controller->request->is('bot');
165
-		}
166
-
167
-		/**
168
-		 * Logs-in registered users
169
-		 *
170
-		 * @param null|array $user user-data, if null request-data is used
171
-		 * @return bool true if user is logged in false otherwise
172
-		 */
173
-		protected function _login($user = null) {
174
-			$this->_Controller->Auth->login($user);
175
-			$this->refresh();
176
-			return $this->isLoggedIn();
177
-		}
178
-
179
-		protected function _reLoginSession() {
180
-			return $this->_login();
181
-		}
182
-
183
-		protected function _reLoginCookie() {
184
-			$cookie = $this->PersistentCookie->read();
185
-			if ($cookie) {
186
-				$this->_login($cookie);
187
-				return $this->isLoggedIn();
188
-			}
189
-			return false;
190
-		}
191
-
192
-		public function login() {
193
-			// non-logged in session-id is lost after successful login
194
-			$sessionId = session_id();
195
-
196
-			if (!$this->_login()) {
197
-				return false;
198
-			}
199
-
200
-			$this->_User->incrementLogins($this->getId());
201
-			$this->_User->UserOnline->setOffline($sessionId);
202
-			//password update
203
-			if (empty($this->_Controller->request->data['User']['password']) === false) {
204
-				$this->_User->autoUpdatePassword(
205
-					$this->getId(),
206
-					$this->_Controller->request->data['User']['password']
207
-				);
208
-			}
209
-
210
-			// set cookie
211
-			if (empty($this->_Controller->request->data['User']['remember_me']) === false) {
212
-				$this->PersistentCookie->write($this);
213
-			};
214
-
215
-			return true;
216
-		}
217
-
218
-		/**
219
-		 * Sets user-data
220
-		 */
221
-		public function refresh() {
222
-			// preliminary set user-data from Cake's Auth handler
223
-			$this->setSettings($this->_Controller->Auth->user());
224
-			// set user-data from current DB data: ensures that *all sessions*
225
-			// use the same set of data (user got locked, user-type was demoted …)
226
-			if ($this->isLoggedIn()) {
227
-				$this->_User->id = $this->getId();
228
-				$this->setSettings($this->_User->getProfile($this->getId()));
229
-				$this->LastRefresh = new LastRefresh\LastRefreshDatabase($this);
230
-			} elseif ($this->isBot()) {
231
-				$this->LastRefresh = new LastRefresh\LastRefreshDummy($this);
232
-			} else {
233
-				$this->LastRefresh = new LastRefresh\LastRefreshCookie($this);
234
-			}
235
-		}
236
-
237
-		public function logout() {
238
-			if (!$this->isLoggedIn()) {
239
-				return;
240
-			}
241
-			$this->PersistentCookie->delete();
242
-			$this->_User->id = $this->getId();
243
-			$this->_User->UserOnline->setOffline($this->getId());
244
-			$this->setSettings(null);
245
-			$this->_Controller->Auth->logout();
246
-		}
247
-
248
-		public function shutdown(Controller $Controller) {
249
-			$this->_writeSession($Controller);
250
-		}
251
-
252
-		public function beforeRedirect(Controller $Controller, $url, $status = null, $exit = true) {
253
-			$this->_writeSession($Controller);
254
-		}
255
-
256
-		public function beforeRender(Controller $Controller) {
257
-			// write out the current user for access in the views
258
-			$Controller->set('CurrentUser', $this);
259
-		}
260
-
261
-		public function getModel() {
262
-			return $this->_User;
263
-		}
264
-
265
-		public function hasBookmarked($entryId) {
266
-			return $this->_Bookmarks->isBookmarked($entryId);
267
-		}
142
+        protected function _markOnline() {
143
+            Stopwatch::start('CurrentUser->_markOnline()');
144
+            $_isLoggedIn = $this->isLoggedIn();
145
+            if ($_isLoggedIn) {
146
+                $_id = $this->getId();
147
+            } else {
148
+                // don't count search bots as guests
149
+                if ($this->isBot()) {
150
+                    return;
151
+                }
152
+                $_id = $this->_Controller->Session->id();
153
+            }
154
+            $this->_User->UserOnline->setOnline($_id, $_isLoggedIn);
155
+            Stopwatch::stop('CurrentUser->_markOnline()');
156
+        }
157
+
158
+        /**
159
+         * Detects if the current user is a bot
160
+         *
161
+         * @return boolean
162
+         */
163
+        public function isBot() {
164
+            return $this->_Controller->request->is('bot');
165
+        }
166
+
167
+        /**
168
+         * Logs-in registered users
169
+         *
170
+         * @param null|array $user user-data, if null request-data is used
171
+         * @return bool true if user is logged in false otherwise
172
+         */
173
+        protected function _login($user = null) {
174
+            $this->_Controller->Auth->login($user);
175
+            $this->refresh();
176
+            return $this->isLoggedIn();
177
+        }
178
+
179
+        protected function _reLoginSession() {
180
+            return $this->_login();
181
+        }
182
+
183
+        protected function _reLoginCookie() {
184
+            $cookie = $this->PersistentCookie->read();
185
+            if ($cookie) {
186
+                $this->_login($cookie);
187
+                return $this->isLoggedIn();
188
+            }
189
+            return false;
190
+        }
191
+
192
+        public function login() {
193
+            // non-logged in session-id is lost after successful login
194
+            $sessionId = session_id();
195
+
196
+            if (!$this->_login()) {
197
+                return false;
198
+            }
199
+
200
+            $this->_User->incrementLogins($this->getId());
201
+            $this->_User->UserOnline->setOffline($sessionId);
202
+            //password update
203
+            if (empty($this->_Controller->request->data['User']['password']) === false) {
204
+                $this->_User->autoUpdatePassword(
205
+                    $this->getId(),
206
+                    $this->_Controller->request->data['User']['password']
207
+                );
208
+            }
209
+
210
+            // set cookie
211
+            if (empty($this->_Controller->request->data['User']['remember_me']) === false) {
212
+                $this->PersistentCookie->write($this);
213
+            };
214
+
215
+            return true;
216
+        }
217
+
218
+        /**
219
+         * Sets user-data
220
+         */
221
+        public function refresh() {
222
+            // preliminary set user-data from Cake's Auth handler
223
+            $this->setSettings($this->_Controller->Auth->user());
224
+            // set user-data from current DB data: ensures that *all sessions*
225
+            // use the same set of data (user got locked, user-type was demoted …)
226
+            if ($this->isLoggedIn()) {
227
+                $this->_User->id = $this->getId();
228
+                $this->setSettings($this->_User->getProfile($this->getId()));
229
+                $this->LastRefresh = new LastRefresh\LastRefreshDatabase($this);
230
+            } elseif ($this->isBot()) {
231
+                $this->LastRefresh = new LastRefresh\LastRefreshDummy($this);
232
+            } else {
233
+                $this->LastRefresh = new LastRefresh\LastRefreshCookie($this);
234
+            }
235
+        }
236
+
237
+        public function logout() {
238
+            if (!$this->isLoggedIn()) {
239
+                return;
240
+            }
241
+            $this->PersistentCookie->delete();
242
+            $this->_User->id = $this->getId();
243
+            $this->_User->UserOnline->setOffline($this->getId());
244
+            $this->setSettings(null);
245
+            $this->_Controller->Auth->logout();
246
+        }
247
+
248
+        public function shutdown(Controller $Controller) {
249
+            $this->_writeSession($Controller);
250
+        }
251
+
252
+        public function beforeRedirect(Controller $Controller, $url, $status = null, $exit = true) {
253
+            $this->_writeSession($Controller);
254
+        }
255
+
256
+        public function beforeRender(Controller $Controller) {
257
+            // write out the current user for access in the views
258
+            $Controller->set('CurrentUser', $this);
259
+        }
260
+
261
+        public function getModel() {
262
+            return $this->_User;
263
+        }
264
+
265
+        public function hasBookmarked($entryId) {
266
+            return $this->_Bookmarks->isBookmarked($entryId);
267
+        }
268 268
 
269 269
 /**
270 270
  * write the settings to the session, so that they are available on next request
271 271
  */
272
-		protected function _writeSession(&$controller) {
273
-			if ($controller->action !== 'logout' && $controller->Auth->user()):
274
-				$controller->Session->write(
275
-					'Auth.User',
276
-					$this->getSettings()
277
-				);
278
-			endif;
279
-		}
272
+        protected function _writeSession(&$controller) {
273
+            if ($controller->action !== 'logout' && $controller->Auth->user()):
274
+                $controller->Session->write(
275
+                    'Auth.User',
276
+                    $this->getSettings()
277
+                );
278
+            endif;
279
+        }
280 280
 
281 281
 /**
282 282
  * Configures the auth component
283 283
  */
284
-		protected function _configureAuth() {
285
-			// delegate authenticate method
286
-			// $this->_Controller->Auth->authenticate = $this->_User;
287
-
288
-			$this->_Controller->Auth->authenticate = [
289
-				AuthComponent::ALL => [
290
-					'useModel' => 'User',
291
-					'contain' => false,
292
-					'scope' => [
293
-						// user has activated his account (e.g. email confirmation)
294
-						'User.activate_code' => 0,
295
-						// user is not banned by admin or mod
296
-						'User.user_lock' => 0
297
-					]
298
-				],
299
-				// 'Mlf' and 'Mlf2' could be 'Form' with different passwordHasher, but
300
-				// see: https://cakephp.lighthouseapp.com/projects/42648/tickets/3907-allow-multiple-passwordhasher-with-same-authenticate-class-in-auth-config#ticket-3907-1
301
-				'Mlf', // mylittleforum 1 auth
302
-				'Mlf2', // mylittleforum 2 auth
303
-				'Form' => ['passwordHasher' => 'Blowfish'] // blowfish saito standard
304
-			];
305
-
306
-			if ($this->isLoggedIn()):
307
-				$this->_Controller->Auth->allow();
308
-			else:
309
-				$this->_Controller->Auth->deny();
310
-			endif;
311
-
312
-			$this->_Controller->Auth->autoRedirect = false; // don't redirect after Auth->login()
313
-			$this->_Controller->Auth->allow('display'); // access to static pages in views/pages is allowed
314
-			$this->_Controller->Auth->authError = __('auth_autherror'); // l10n
315
-		}
316
-
317
-	}
284
+        protected function _configureAuth() {
285
+            // delegate authenticate method
286
+            // $this->_Controller->Auth->authenticate = $this->_User;
287
+
288
+            $this->_Controller->Auth->authenticate = [
289
+                AuthComponent::ALL => [
290
+                    'useModel' => 'User',
291
+                    'contain' => false,
292
+                    'scope' => [
293
+                        // user has activated his account (e.g. email confirmation)
294
+                        'User.activate_code' => 0,
295
+                        // user is not banned by admin or mod
296
+                        'User.user_lock' => 0
297
+                    ]
298
+                ],
299
+                // 'Mlf' and 'Mlf2' could be 'Form' with different passwordHasher, but
300
+                // see: https://cakephp.lighthouseapp.com/projects/42648/tickets/3907-allow-multiple-passwordhasher-with-same-authenticate-class-in-auth-config#ticket-3907-1
301
+                'Mlf', // mylittleforum 1 auth
302
+                'Mlf2', // mylittleforum 2 auth
303
+                'Form' => ['passwordHasher' => 'Blowfish'] // blowfish saito standard
304
+            ];
305
+
306
+            if ($this->isLoggedIn()):
307
+                $this->_Controller->Auth->allow();
308
+            else:
309
+                $this->_Controller->Auth->deny();
310
+            endif;
311
+
312
+            $this->_Controller->Auth->autoRedirect = false; // don't redirect after Auth->login()
313
+            $this->_Controller->Auth->allow('display'); // access to static pages in views/pages is allowed
314
+            $this->_Controller->Auth->authError = __('auth_autherror'); // l10n
315
+        }
316
+
317
+    }
318 318
 
Please login to merge, or discard this patch.
app/Controller/Component/ShoutsComponent.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('Component', 'Controller');
3
+    App::uses('Component', 'Controller');
4 4
 
5
-	class ShoutsComponent extends Component {
5
+    class ShoutsComponent extends Component {
6 6
 
7
-		public $settings = ['maxNumberOfShouts' => 10];
7
+        public $settings = ['maxNumberOfShouts' => 10];
8 8
 
9
-		protected $_Controller;
9
+        protected $_Controller;
10 10
 
11
-		protected $_ShoutModel = null;
11
+        protected $_ShoutModel = null;
12 12
 
13
-		public function startup(Controller $controller) {
14
-			$this->_Controller = $controller;
15
-			$this->settings['maxNumberOfShouts'] = (int)Configure::read(
16
-				'Saito.Settings.shoutbox_max_shouts');
17
-		}
13
+        public function startup(Controller $controller) {
14
+            $this->_Controller = $controller;
15
+            $this->settings['maxNumberOfShouts'] = (int)Configure::read(
16
+                'Saito.Settings.shoutbox_max_shouts');
17
+        }
18 18
 
19
-		public function setShoutsForView() {
20
-			// @performance only do if cache is not valid and html need to be rendered
21
-			$this->_Controller->set('shouts', $this->get());
22
-		}
19
+        public function setShoutsForView() {
20
+            // @performance only do if cache is not valid and html need to be rendered
21
+            $this->_Controller->set('shouts', $this->get());
22
+        }
23 23
 
24
-		public function get() {
25
-			return $this->_model()->get();
26
-		}
24
+        public function get() {
25
+            return $this->_model()->get();
26
+        }
27 27
 
28
-		public function push($data) {
29
-			return $this->_model()->push($data);
30
-		}
28
+        public function push($data) {
29
+            return $this->_model()->push($data);
30
+        }
31 31
 
32
-		protected function _model() {
33
-			if ($this->_ShoutModel !== null) {
34
-				return $this->_ShoutModel;
35
-			}
36
-			$this->_Controller->loadModel('Shout');
37
-			$this->_ShoutModel = $this->_Controller->Shout;
38
-			$this->_ShoutModel->maxNumberOfShouts = $this->settings['maxNumberOfShouts'];
39
-			return $this->_ShoutModel;
40
-		}
32
+        protected function _model() {
33
+            if ($this->_ShoutModel !== null) {
34
+                return $this->_ShoutModel;
35
+            }
36
+            $this->_Controller->loadModel('Shout');
37
+            $this->_ShoutModel = $this->_Controller->Shout;
38
+            $this->_ShoutModel->maxNumberOfShouts = $this->settings['maxNumberOfShouts'];
39
+            return $this->_ShoutModel;
40
+        }
41 41
 
42
-	}
42
+    }
Please login to merge, or discard this patch.
app/Controller/Component/CacheSupportComponent.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,67 +1,67 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	use Saito\Cache\CacheSupport;
4
-	use Saito\Cache\ItemCache;
5
-	use Saito\Cache\LineCacheSupportCachelet;
6
-	use Saito\Cache\SaitoCacheEngineAppCache;
3
+    use Saito\Cache\CacheSupport;
4
+    use Saito\Cache\ItemCache;
5
+    use Saito\Cache\LineCacheSupportCachelet;
6
+    use Saito\Cache\SaitoCacheEngineAppCache;
7 7
 
8
-	App::uses('Component', 'Controller');
8
+    App::uses('Component', 'Controller');
9 9
 
10
-	class CacheSupportComponent extends Component {
10
+    class CacheSupportComponent extends Component {
11 11
 
12
-		protected $_CacheSupport;
12
+        protected $_CacheSupport;
13 13
 
14
-		/** * @var ItemCache */
15
-		public $LineCache;
14
+        /** * @var ItemCache */
15
+        public $LineCache;
16 16
 
17
-		public function initialize(Controller $Controller) {
18
-			$this->_CacheSupport = new CacheSupport();
19
-			if ($Controller->modelClass) {
20
-				$Controller->{$Controller->modelClass}->SharedObjects['CacheSupport'] = $this->_CacheSupport;
21
-			}
22
-			$this->_addConfigureCachelets();
23
-			$this->_initLineCache($Controller);
24
-		}
17
+        public function initialize(Controller $Controller) {
18
+            $this->_CacheSupport = new CacheSupport();
19
+            if ($Controller->modelClass) {
20
+                $Controller->{$Controller->modelClass}->SharedObjects['CacheSupport'] = $this->_CacheSupport;
21
+            }
22
+            $this->_addConfigureCachelets();
23
+            $this->_initLineCache($Controller);
24
+        }
25 25
 
26
-		protected function _initLineCache() {
27
-			$this->LineCache = new ItemCache(
28
-				'Saito.LineCache',
29
-				new SaitoCacheEngineAppCache,
30
-				// duration: update relative time values in HTML at least every hour
31
-				['duration' => 3600, 'maxItems' => 600]
32
-			);
33
-			$this->_CacheSupport->add(new LineCacheSupportCachelet($this->LineCache));
34
-		}
26
+        protected function _initLineCache() {
27
+            $this->LineCache = new ItemCache(
28
+                'Saito.LineCache',
29
+                new SaitoCacheEngineAppCache,
30
+                // duration: update relative time values in HTML at least every hour
31
+                ['duration' => 3600, 'maxItems' => 600]
32
+            );
33
+            $this->_CacheSupport->add(new LineCacheSupportCachelet($this->LineCache));
34
+        }
35 35
 
36
-		/**
37
-		 * Adds additional cachelets from Configure `Saito.Cachelets`
38
-		 *
39
-		 * E.g. use in `Plugin/<foo>/Config/bootstrap.php`:
40
-		 *
41
-		 * <code>
42
-		 * Configure::write('Saito.Cachelets.M', ['location' => 'M.Lib', 'name' => 'MCacheSupportCachelet']);
43
-		 * </code>
44
-		 */
45
-		protected function _addConfigureCachelets() {
46
-			$_additionalCachelets = Configure::read('Saito.Cachelets');
47
-			if (!$_additionalCachelets) {
48
-				return;
49
-			}
50
-			foreach ($_additionalCachelets as $_c) {
51
-				App::uses($_c['name'], $_c['location']);
52
-				$this->_CacheSupport->add(new $_c['name']);
53
-			}
54
-		}
36
+        /**
37
+         * Adds additional cachelets from Configure `Saito.Cachelets`
38
+         *
39
+         * E.g. use in `Plugin/<foo>/Config/bootstrap.php`:
40
+         *
41
+         * <code>
42
+         * Configure::write('Saito.Cachelets.M', ['location' => 'M.Lib', 'name' => 'MCacheSupportCachelet']);
43
+         * </code>
44
+         */
45
+        protected function _addConfigureCachelets() {
46
+            $_additionalCachelets = Configure::read('Saito.Cachelets');
47
+            if (!$_additionalCachelets) {
48
+                return;
49
+            }
50
+            foreach ($_additionalCachelets as $_c) {
51
+                App::uses($_c['name'], $_c['location']);
52
+                $this->_CacheSupport->add(new $_c['name']);
53
+            }
54
+        }
55 55
 
56
-		public function beforeRender(Controller $Controller) {
57
-			$Controller->set('LineCache', $this->LineCache);
58
-		}
56
+        public function beforeRender(Controller $Controller) {
57
+            $Controller->set('LineCache', $this->LineCache);
58
+        }
59 59
 
60
-		public function __call($method, $params) {
61
-			$proxy = [$this->_CacheSupport, $method];
62
-			if (is_callable($proxy)) {
63
-				return call_user_func_array($proxy, $params);
64
-			}
65
-		}
60
+        public function __call($method, $params) {
61
+            $proxy = [$this->_CacheSupport, $method];
62
+            if (is_callable($proxy)) {
63
+                return call_user_func_array($proxy, $params);
64
+            }
65
+        }
66 66
 
67
-	}
67
+    }
Please login to merge, or discard this patch.
app/Controller/Component/Auth/MlfAuthenticate.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('FormAuthenticate', 'Controller/Component/Auth');
3
+    App::uses('FormAuthenticate', 'Controller/Component/Auth');
4 4
 
5
-	class MlfAuthenticate extends FormAuthenticate {
5
+    class MlfAuthenticate extends FormAuthenticate {
6 6
 
7
-		public function __construct(ComponentCollection $collection, $settings) {
8
-			$this->settings['passwordHasher'] = 'Mlf';
9
-			parent::__construct($collection, $settings);
10
-		}
7
+        public function __construct(ComponentCollection $collection, $settings) {
8
+            $this->settings['passwordHasher'] = 'Mlf';
9
+            parent::__construct($collection, $settings);
10
+        }
11 11
 
12
-	}
12
+    }
Please login to merge, or discard this patch.
app/Controller/Component/Auth/MlfPasswordHasher.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('AbstractPasswordHasher', 'Controller/Component/Auth');
4
-	App::uses('Security', 'Utility');
3
+    App::uses('AbstractPasswordHasher', 'Controller/Component/Auth');
4
+    App::uses('Security', 'Utility');
5 5
 
6 6
 /**
7 7
  * mylittleforum 1.x unsalted md5 passwords
8 8
  */
9
-	class MlfPasswordHasher extends AbstractPasswordHasher {
9
+    class MlfPasswordHasher extends AbstractPasswordHasher {
10 10
 
11
-		public function hash($password) {
12
-			return Security::hash($password, 'md5', false);
13
-		}
11
+        public function hash($password) {
12
+            return Security::hash($password, 'md5', false);
13
+        }
14 14
 
15
-		public function check($password, $hash) {
16
-			return $hash === self::hash($password);
17
-		}
15
+        public function check($password, $hash) {
16
+            return $hash === self::hash($password);
17
+        }
18 18
 
19
-	}
19
+    }
Please login to merge, or discard this patch.
app/Controller/Component/Auth/Mlf2PasswordHasher.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,37 +1,37 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('AbstractPasswordHasher', 'Controller/Component/Auth');
3
+    App::uses('AbstractPasswordHasher', 'Controller/Component/Auth');
4 4
 
5 5
 /**
6 6
  * mylittleforum 2.x salted sha1 passwords
7 7
  */
8
-	class Mlf2PasswordHasher extends AbstractPasswordHasher {
8
+    class Mlf2PasswordHasher extends AbstractPasswordHasher {
9 9
 
10
-		public function hash($password) {
11
-			// compare to includes/functions.inc.php generate_pw_hash() mlf 2.3
12
-			$salt = self::_generateRandomString(10);
13
-			$saltedHash = sha1($password . $salt);
14
-			$hashWithSalt = $saltedHash . $salt;
15
-			return $hashWithSalt;
16
-		}
10
+        public function hash($password) {
11
+            // compare to includes/functions.inc.php generate_pw_hash() mlf 2.3
12
+            $salt = self::_generateRandomString(10);
13
+            $saltedHash = sha1($password . $salt);
14
+            $hashWithSalt = $saltedHash . $salt;
15
+            return $hashWithSalt;
16
+        }
17 17
 
18
-		protected static function _generateRandomString($maxLength = null) {
19
-			$string = Security::generateAuthKey();
20
-			if ($maxLength) {
21
-				$string = substr($string, 0, $maxLength);
22
-			}
23
-			return $string;
24
-		}
18
+        protected static function _generateRandomString($maxLength = null) {
19
+            $string = Security::generateAuthKey();
20
+            if ($maxLength) {
21
+                $string = substr($string, 0, $maxLength);
22
+            }
23
+            return $string;
24
+        }
25 25
 
26
-		public function check($password, $hash) {
27
-			$out = false;
28
-			// compare to includes/functions.inc.php is_pw_correct() mlf 2.3
29
-			$saltedHash = substr($hash, 0, 40);
30
-			$salt = substr($hash, 40, 10);
31
-			if (sha1($password . $salt) == $saltedHash) :
32
-				$out = true;
33
-			endif;
34
-			return $out;
35
-		}
26
+        public function check($password, $hash) {
27
+            $out = false;
28
+            // compare to includes/functions.inc.php is_pw_correct() mlf 2.3
29
+            $saltedHash = substr($hash, 0, 40);
30
+            $salt = substr($hash, 40, 10);
31
+            if (sha1($password . $salt) == $saltedHash) :
32
+                $out = true;
33
+            endif;
34
+            return $out;
35
+        }
36 36
 
37
-	}
37
+    }
Please login to merge, or discard this patch.
app/Controller/Component/Auth/Mlf2Authenticate.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	App::uses('FormAuthenticate', 'Controller/Component/Auth');
3
+    App::uses('FormAuthenticate', 'Controller/Component/Auth');
4 4
 
5
-	/**
6
-	 * mylittleforum 2.x auth with salted sha1 passwords
7
-	 */
8
-	class Mlf2Authenticate extends FormAuthenticate {
5
+    /**
6
+     * mylittleforum 2.x auth with salted sha1 passwords
7
+     */
8
+    class Mlf2Authenticate extends FormAuthenticate {
9 9
 
10
-		public function __construct(ComponentCollection $collection, $settings) {
11
-			$this->settings['passwordHasher'] = 'Mlf2';
12
-			parent::__construct($collection, $settings);
13
-		}
10
+        public function __construct(ComponentCollection $collection, $settings) {
11
+            $this->settings['passwordHasher'] = 'Mlf2';
12
+            parent::__construct($collection, $settings);
13
+        }
14 14
 
15
-	}
15
+    }
Please login to merge, or discard this patch.
app/Controller/Component/ParserComponent.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,44 +1,44 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-	use \Saito\User\Userlist;
4
-
5
-	App::uses('Component', 'Controller');
6
-
7
-	class ParserComponent extends Component {
8
-
9
-		/** @var SaitoMarkupSettings */
10
-		protected $_settings;
11
-
12
-		public function initialize(Controller $controller) {
13
-			// is needed in Markup Behavior
14
-			$this->_settings = new Saito\Markup\Settings([
15
-				'server' => Router::fullBaseUrl(),
16
-				'webroot' => $controller->webroot
17
-			]);
18
-		}
19
-
20
-		public function beforeRender(Controller $controller) {
21
-				$this->_initHelper($controller);
22
-		}
23
-
24
-		/**
25
-		 * Inits the ParserHelper for use in a View
26
-		 *
27
-		 * Call this instead of including in the controller's $helpers array.
28
-		 */
29
-		protected function _initHelper(Controller $controller) {
30
-			$userlist = new Userlist\UserlistModel();
31
-			$userlist->set($controller->User);
32
-			$smilies = new \Saito\Smiley\Cache($controller);
33
-			$controller->set('smiliesData', $smilies);
34
-
35
-			$this->_settings->add([
36
-				'quote_symbol' => Configure::read('Saito.Settings.quote_symbol'),
37
-				'smiliesData' => $smilies,
38
-				'UserList' => $userlist
39
-			]);
40
-
41
-			$controller->helpers['Parser'] = $this->_settings->get();
42
-		}
43
-
44
-	}
3
+    use \Saito\User\Userlist;
4
+
5
+    App::uses('Component', 'Controller');
6
+
7
+    class ParserComponent extends Component {
8
+
9
+        /** @var SaitoMarkupSettings */
10
+        protected $_settings;
11
+
12
+        public function initialize(Controller $controller) {
13
+            // is needed in Markup Behavior
14
+            $this->_settings = new Saito\Markup\Settings([
15
+                'server' => Router::fullBaseUrl(),
16
+                'webroot' => $controller->webroot
17
+            ]);
18
+        }
19
+
20
+        public function beforeRender(Controller $controller) {
21
+                $this->_initHelper($controller);
22
+        }
23
+
24
+        /**
25
+         * Inits the ParserHelper for use in a View
26
+         *
27
+         * Call this instead of including in the controller's $helpers array.
28
+         */
29
+        protected function _initHelper(Controller $controller) {
30
+            $userlist = new Userlist\UserlistModel();
31
+            $userlist->set($controller->User);
32
+            $smilies = new \Saito\Smiley\Cache($controller);
33
+            $controller->set('smiliesData', $smilies);
34
+
35
+            $this->_settings->add([
36
+                'quote_symbol' => Configure::read('Saito.Settings.quote_symbol'),
37
+                'smiliesData' => $smilies,
38
+                'UserList' => $userlist
39
+            ]);
40
+
41
+            $controller->helpers['Parser'] = $this->_settings->get();
42
+        }
43
+
44
+    }
Please login to merge, or discard this patch.