@@ -28,8 +28,9 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function beforeAction($action) |
30 | 30 | { |
31 | - if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false)) |
|
32 | - $this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri); |
|
31 | + if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false)) { |
|
32 | + $this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri); |
|
33 | + } |
|
33 | 34 | |
34 | 35 | return parent::beforeAction($action); |
35 | 36 | } |
@@ -43,9 +44,9 @@ discard block |
||
43 | 44 | |
44 | 45 | if($error=Yii::app()->errorHandler->error) |
45 | 46 | { |
46 | - if(Yii::app()->request->isAjaxRequest) |
|
47 | - echo $error['message']; |
|
48 | - else |
|
47 | + if(Yii::app()->request->isAjaxRequest) { |
|
48 | + echo $error['message']; |
|
49 | + } else |
|
49 | 50 | { |
50 | 51 | $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}} {{code}}', array( |
51 | 52 | '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
@@ -57,8 +58,7 @@ discard block |
||
57 | 58 | 'error' => $error |
58 | 59 | )); |
59 | 60 | } |
60 | - } |
|
61 | - else |
|
61 | + } else |
|
62 | 62 | { |
63 | 63 | $message = Yii::app()->user->getFlash('error_code'); |
64 | 64 | Yii::app()->user->setFlash('error_code', $message); |
@@ -123,8 +123,7 @@ discard block |
||
123 | 123 | $criteria->params = array( |
124 | 124 | ':author_id' => str_replace('user_id:', '', Cii::get($_GET, 'q', 0)) |
125 | 125 | ); |
126 | - } |
|
127 | - else |
|
126 | + } else |
|
128 | 127 | { |
129 | 128 | $param = Cii::get($_GET, 'q', 0); |
130 | 129 | $criteria->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))"); |
@@ -171,8 +170,9 @@ discard block |
||
171 | 170 | if (Cii::get($_POST, 'LoginForm', false)) |
172 | 171 | { |
173 | 172 | $model->attributes = Cii::get($_POST, 'LoginForm', array()); |
174 | - if ($model->login()) |
|
175 | - $this->redirect($this->_getNext() ?: Yii::app()->user->returnUrl); |
|
173 | + if ($model->login()) { |
|
174 | + $this->redirect($this->_getNext() ?: Yii::app()->user->returnUrl); |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $this->render('login', array( |
@@ -185,16 +185,18 @@ discard block |
||
185 | 185 | */ |
186 | 186 | public function actionLogout() |
187 | 187 | { |
188 | - if (Yii::app()->request->getParam('next', false)) |
|
189 | - $redirect = $this->createUrl('site/login', array('next' => $this->_getNext())); |
|
190 | - else |
|
191 | - $redirect = Yii::app()->user->returnUrl; |
|
188 | + if (Yii::app()->request->getParam('next', false)) { |
|
189 | + $redirect = $this->createUrl('site/login', array('next' => $this->_getNext())); |
|
190 | + } else { |
|
191 | + $redirect = Yii::app()->user->returnUrl; |
|
192 | + } |
|
192 | 193 | |
193 | 194 | // Purge the active sessions API Key |
194 | 195 | $apiKey = UserMetadata::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'key' => 'api_key')); |
195 | 196 | |
196 | - if ($apiKey != NULL) |
|
197 | - $apiKey->delete(); |
|
197 | + if ($apiKey != NULL) { |
|
198 | + $apiKey->delete(); |
|
199 | + } |
|
198 | 200 | |
199 | 201 | |
200 | 202 | Yii::app()->user->logout(); |
@@ -247,8 +249,9 @@ discard block |
||
247 | 249 | $model = new PasswordResetForm; |
248 | 250 | $model->reset_key = $id; |
249 | 251 | |
250 | - if (!$model->validateResetKey()) |
|
251 | - throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The password reset key provided is invalid')); |
|
252 | + if (!$model->validateResetKey()) { |
|
253 | + throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The password reset key provided is invalid')); |
|
254 | + } |
|
252 | 255 | |
253 | 256 | if (Cii::get($_POST, 'PasswordResetForm', false)) |
254 | 257 | { |
@@ -283,8 +286,9 @@ discard block |
||
283 | 286 | $model->setUser(Users::model()->findByPk(Yii::app()->user->id)); |
284 | 287 | $model->verificationKey = $key; |
285 | 288 | |
286 | - if (!$model->validateVerificationKey()) |
|
287 | - throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The verification key provided is invalid.')); |
|
289 | + if (!$model->validateVerificationKey()) { |
|
290 | + throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The verification key provided is invalid.')); |
|
291 | + } |
|
288 | 292 | |
289 | 293 | if (Cii::get($_POST, 'EmailChangeForm', false)) |
290 | 294 | { |
@@ -300,8 +304,9 @@ discard block |
||
300 | 304 | 'password' => $model->password, |
301 | 305 | ); |
302 | 306 | |
303 | - if ($loginForm->login()) |
|
304 | - return $this->redirect(Yii::app()->homeUrl); |
|
307 | + if ($loginForm->login()) { |
|
308 | + return $this->redirect(Yii::app()->homeUrl); |
|
309 | + } |
|
305 | 310 | |
306 | 311 | throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'Unable to re-authenticated user.')); |
307 | 312 | } |
@@ -328,8 +333,9 @@ discard block |
||
328 | 333 | $model = new ActivationForm; |
329 | 334 | $model->activationKey = $id; |
330 | 335 | |
331 | - if (!$model->validateKey()) |
|
332 | - throw new CHttpException(403, Yii::t('ciims.models.ActivationForm', 'The activation key you provided is invalid.')); |
|
336 | + if (!$model->validateKey()) { |
|
337 | + throw new CHttpException(403, Yii::t('ciims.models.ActivationForm', 'The activation key you provided is invalid.')); |
|
338 | + } |
|
333 | 339 | |
334 | 340 | if (Cii::get($_POST, 'ActivationForm', false)) |
335 | 341 | { |
@@ -392,13 +398,15 @@ discard block |
||
392 | 398 | '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation') |
393 | 399 | ))); |
394 | 400 | |
395 | - if ($id === NULL) |
|
396 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
401 | + if ($id === NULL) { |
|
402 | + throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
403 | + } |
|
397 | 404 | |
398 | 405 | // Make sure we have a user first |
399 | 406 | $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id)); |
400 | - if ($meta === NULL) |
|
401 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
407 | + if ($meta === NULL) { |
|
408 | + throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
409 | + } |
|
402 | 410 | |
403 | 411 | $model = new InviteForm; |
404 | 412 | $model->email = Users::model()->findByPk($meta->user_id)->email; |
@@ -2,430 +2,430 @@ |
||
2 | 2 | |
3 | 3 | class SiteController extends CiiController |
4 | 4 | { |
5 | - public function filters() |
|
6 | - { |
|
7 | - return CMap::mergeArray(parent::filters(), array('accessControl')); |
|
8 | - } |
|
9 | - |
|
10 | - /** |
|
11 | - * Setup access controls to prevent guests from changing their emaila ddress |
|
12 | - */ |
|
13 | - public function accessRules() |
|
14 | - { |
|
15 | - return array( |
|
16 | - array('deny', // The user mut be authenticated to approve an email address change |
|
17 | - 'users'=>array('*'), |
|
18 | - 'expression'=>'Yii::app()->user->isGuest==true', |
|
19 | - 'actions' => array('emailchange') |
|
20 | - ) |
|
21 | - ); |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * beforeAction method, performs operations before an action is presented |
|
26 | - * @param $action, the action being called |
|
27 | - * @see http://www.yiiframework.com/doc/api/1.1/CController#beforeAction-detail |
|
28 | - */ |
|
29 | - public function beforeAction($action) |
|
30 | - { |
|
31 | - if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false)) |
|
32 | - $this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri); |
|
33 | - |
|
34 | - return parent::beforeAction($action); |
|
35 | - } |
|
36 | - |
|
37 | - /** |
|
38 | - * This is the action to handle external exceptions. |
|
39 | - */ |
|
40 | - public function actionError($code=NULL) |
|
41 | - { |
|
42 | - $this->layout = '//layouts/main'; |
|
43 | - |
|
44 | - if($error=Yii::app()->errorHandler->error) |
|
45 | - { |
|
46 | - if(Yii::app()->request->isAjaxRequest) |
|
47 | - echo $error['message']; |
|
48 | - else |
|
49 | - { |
|
50 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}} {{code}}', array( |
|
51 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
52 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Error'), |
|
53 | - '{{code}}' => $error['code'] |
|
54 | - ))); |
|
55 | - |
|
56 | - $this->render('error', array( |
|
57 | - 'error' => $error |
|
58 | - )); |
|
59 | - } |
|
60 | - } |
|
61 | - else |
|
62 | - { |
|
63 | - $message = Yii::app()->user->getFlash('error_code'); |
|
64 | - Yii::app()->user->setFlash('error_code', $message); |
|
65 | - throw new CHttpException($code, $message); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Provides basic sitemap functionality via XML |
|
71 | - */ |
|
72 | - public function actionSitemap() |
|
73 | - { |
|
74 | - ob_end_clean(); |
|
75 | - Yii::app()->log->routes[0]->enabled = false; |
|
76 | - header('Content-type: text/xml; charset=utf-8'); |
|
77 | - $url = Yii::app()->getBaseUrl(true); |
|
78 | - $this->setLayout(null); |
|
79 | - $content = Yii::app()->db |
|
80 | - ->createCommand('SELECT slug, password, type_id, updated FROM content AS t WHERE vid=(SELECT MAX(vid) FROM content WHERE id=t.id) AND status = 1 AND published <= UTC_TIMESTAMP();') |
|
81 | - ->queryAll(); |
|
82 | - |
|
83 | - $categories = Yii::app()->db |
|
84 | - ->createCommand('SELECT slug, updated FROM categories;') |
|
85 | - ->queryAll(); |
|
86 | - |
|
87 | - $this->renderPartial('sitemap', array( |
|
88 | - 'content' => $content, |
|
89 | - 'categories' => $categories, |
|
90 | - 'url' => $url |
|
91 | - )); |
|
92 | - |
|
93 | - Yii::app()->end(); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Provides basic searching functionality |
|
98 | - * @param int $id The search pagination id |
|
99 | - */ |
|
100 | - public function actionSearch($id=1) |
|
101 | - { |
|
102 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
103 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
104 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Search') |
|
105 | - ))); |
|
106 | - |
|
107 | - $this->layout = '//layouts/default'; |
|
108 | - $data = array(); |
|
109 | - $pages = array(); |
|
110 | - $itemCount = 0; |
|
111 | - $pageSize = Cii::getConfig('searchPaginationSize', 10); |
|
112 | - |
|
113 | - if (Cii::get($_GET, 'q', false)) |
|
114 | - { |
|
115 | - $criteria = new CDbCriteria; |
|
116 | - $criteria->addCondition('status = 1') |
|
117 | - ->addCondition('published <= UTC_TIMESTAMP()'); |
|
118 | - |
|
119 | - if (strpos($_GET['q'], 'user_id') !== false) |
|
120 | - { |
|
121 | - $criteria->addCondition('author_id = :author_id') |
|
122 | - ->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id)"); |
|
123 | - $criteria->params = array( |
|
124 | - ':author_id' => str_replace('user_id:', '', Cii::get($_GET, 'q', 0)) |
|
125 | - ); |
|
126 | - } |
|
127 | - else |
|
128 | - { |
|
129 | - $param = Cii::get($_GET, 'q', 0); |
|
130 | - $criteria->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))"); |
|
131 | - $criteria->params = array( |
|
132 | - ':param' => '%' . $param . '%', |
|
133 | - ':param2' => '%' . $param . '%' |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - $criteria->addCondition('password = ""'); |
|
138 | - $criteria->limit = $pageSize; |
|
139 | - $criteria->order = 'id DESC'; |
|
140 | - $itemCount = Content::model()->count($criteria); |
|
141 | - $pages = new CPagination($itemCount); |
|
142 | - $pages->pageSize=$pageSize; |
|
143 | - |
|
144 | - $criteria->offset = $criteria->limit*($pages->getCurrentPage()); |
|
145 | - $data = Content::model()->findAll($criteria); |
|
146 | - $pages->applyLimit($criteria); |
|
147 | - } |
|
148 | - |
|
149 | - $this->render('search', array( |
|
150 | - 'url' => 'search', |
|
151 | - 'id' => $id, |
|
152 | - 'data' => $data, |
|
153 | - 'itemCount' => $itemCount, |
|
154 | - 'pages' => $pages |
|
155 | - )); |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Provides functionality to log a user into the system |
|
160 | - */ |
|
161 | - public function actionLogin() |
|
162 | - { |
|
163 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
164 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
165 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Login to your account') |
|
166 | - ))); |
|
167 | - |
|
168 | - $this->layout = '//layouts/main'; |
|
169 | - $model = new LoginForm; |
|
170 | - |
|
171 | - if (Cii::get($_POST, 'LoginForm', false)) |
|
172 | - { |
|
173 | - $model->attributes = Cii::get($_POST, 'LoginForm', array()); |
|
174 | - if ($model->login()) |
|
175 | - $this->redirect($this->_getNext() ?: Yii::app()->user->returnUrl); |
|
176 | - } |
|
177 | - |
|
178 | - $this->render('login', array( |
|
179 | - 'model' => $model |
|
180 | - )); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Provides functionality to log a user out |
|
185 | - */ |
|
186 | - public function actionLogout() |
|
187 | - { |
|
188 | - if (Yii::app()->request->getParam('next', false)) |
|
189 | - $redirect = $this->createUrl('site/login', array('next' => $this->_getNext())); |
|
190 | - else |
|
191 | - $redirect = Yii::app()->user->returnUrl; |
|
192 | - |
|
193 | - // Purge the active sessions API Key |
|
194 | - $apiKey = UserMetadata::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'key' => 'api_key')); |
|
195 | - |
|
196 | - if ($apiKey != NULL) |
|
197 | - $apiKey->delete(); |
|
198 | - |
|
199 | - |
|
200 | - Yii::app()->user->logout(); |
|
201 | - $this->redirect($redirect); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Handles resetting a users password should they forgot it |
|
206 | - */ |
|
207 | - public function actionForgot() |
|
208 | - { |
|
209 | - $this->layout = '//layouts/main'; |
|
210 | - |
|
211 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
212 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
213 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Forgot Your Password?') |
|
214 | - ))); |
|
215 | - |
|
216 | - $model = new ForgotForm; |
|
217 | - |
|
218 | - if (Cii::get($_POST, 'ForgotForm', false)) |
|
219 | - { |
|
220 | - $model->attributes = $_POST['ForgotForm']; |
|
221 | - |
|
222 | - if ($model->initPasswordResetProcess()) |
|
223 | - { |
|
224 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'A password reset link has been sent to your email address')); |
|
225 | - $this->redirect($this->createUrl('site/login')); |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - $this->render('forgot', array( |
|
230 | - 'model' => $model |
|
231 | - )); |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * Alows a user to reset their password if they initiated a forgot password request |
|
236 | - * @param string $id |
|
237 | - */ |
|
238 | - public function actionResetPassword($id=NULL) |
|
239 | - { |
|
240 | - $this->layout = '//layouts/main'; |
|
241 | - |
|
242 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
243 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
244 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Reset Your password') |
|
245 | - ))); |
|
246 | - |
|
247 | - $model = new PasswordResetForm; |
|
248 | - $model->reset_key = $id; |
|
249 | - |
|
250 | - if (!$model->validateResetKey()) |
|
251 | - throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The password reset key provided is invalid')); |
|
252 | - |
|
253 | - if (Cii::get($_POST, 'PasswordResetForm', false)) |
|
254 | - { |
|
255 | - $model->attributes = $_POST['PasswordResetForm']; |
|
256 | - |
|
257 | - if ($model->save()) |
|
258 | - { |
|
259 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your password has been reset, and you may now login with your new password')); |
|
260 | - $this->redirect($this->createUrl('site/login')); |
|
261 | - } |
|
262 | - } |
|
263 | - |
|
264 | - $this->render('resetpassword', array( |
|
265 | - 'model' => $model |
|
266 | - )); |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Allows the user to securely change their email address |
|
271 | - * @param string $key the user's secure key |
|
272 | - */ |
|
273 | - public function actionEmailChange($key=null) |
|
274 | - { |
|
275 | - $this->layout = '//layouts/main'; |
|
276 | - |
|
277 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
278 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
279 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Change Your Email Address') |
|
280 | - ))); |
|
281 | - |
|
282 | - $model = new EmailChangeForm; |
|
283 | - $model->setUser(Users::model()->findByPk(Yii::app()->user->id)); |
|
284 | - $model->verificationKey = $key; |
|
285 | - |
|
286 | - if (!$model->validateVerificationKey()) |
|
287 | - throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The verification key provided is invalid.')); |
|
288 | - |
|
289 | - if (Cii::get($_POST, 'EmailChangeForm', false)) |
|
290 | - { |
|
291 | - $model->attributes = $_POST['EmailChangeForm']; |
|
292 | - |
|
293 | - if ($model->save()) |
|
294 | - { |
|
295 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your new email address has been verified.')); |
|
296 | - |
|
297 | - $loginForm = new LoginForm; |
|
298 | - $loginForm->attributes = array( |
|
299 | - 'username' => Users::model()->findByPk(Yii::app()->user->id)->email, |
|
300 | - 'password' => $model->password, |
|
301 | - ); |
|
302 | - |
|
303 | - if ($loginForm->login()) |
|
304 | - return $this->redirect(Yii::app()->homeUrl); |
|
305 | - |
|
306 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'Unable to re-authenticated user.')); |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - $this->render('emailchange', array( |
|
311 | - 'model' => $model |
|
312 | - )); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Activates a new user's account |
|
317 | - * @param mixed $id The activation key |
|
318 | - */ |
|
319 | - public function actionActivation($id=NULL) |
|
320 | - { |
|
321 | - $this->layout = '//layouts/main'; |
|
322 | - |
|
323 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
324 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
325 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Activate Your Account') |
|
326 | - ))); |
|
327 | - |
|
328 | - $model = new ActivationForm; |
|
329 | - $model->activationKey = $id; |
|
330 | - |
|
331 | - if (!$model->validateKey()) |
|
332 | - throw new CHttpException(403, Yii::t('ciims.models.ActivationForm', 'The activation key you provided is invalid.')); |
|
333 | - |
|
334 | - if (Cii::get($_POST, 'ActivationForm', false)) |
|
335 | - { |
|
336 | - $model->attributes = $_POST['ActivationForm']; |
|
337 | - |
|
338 | - if ($model->save()) |
|
339 | - { |
|
340 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your account has successfully been activated. You may now login')); |
|
341 | - $this->redirect($this->createUrl('site/login')); |
|
342 | - } |
|
343 | - } |
|
344 | - |
|
345 | - $this->render('activation', array( |
|
346 | - 'model' => $model |
|
347 | - )); |
|
348 | - } |
|
349 | - |
|
350 | - /** |
|
351 | - * Handles the registration of new users on the site |
|
352 | - */ |
|
353 | - public function actionRegister() |
|
354 | - { |
|
355 | - $this->layout = '//layouts/main'; |
|
356 | - |
|
357 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
358 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
359 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Sign Up') |
|
360 | - ))); |
|
361 | - |
|
362 | - $model = new RegisterForm; |
|
363 | - |
|
364 | - if (Cii::get($_POST, 'RegisterForm', false)) |
|
365 | - { |
|
366 | - $model->attributes = $_POST['RegisterForm']; |
|
367 | - |
|
368 | - // Save the user's information |
|
369 | - if ($model->save()) |
|
370 | - { |
|
371 | - // Set a flash message |
|
372 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'You have successfully registered an account. Before you can login, please check your email for activation instructions')); |
|
373 | - $this->redirect($this->createUrl('site/login')); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - $this->render('register', array( |
|
378 | - 'model'=>$model |
|
379 | - )); |
|
380 | - } |
|
381 | - |
|
382 | - /** |
|
383 | - * Enables users who have recieved an invitation to setup a new account |
|
384 | - * @param string $id The activation id the of the user that we want to activate |
|
385 | - */ |
|
386 | - public function actionAcceptInvite($id=NULL) |
|
387 | - { |
|
388 | - $this->layout = '//layouts/main'; |
|
389 | - |
|
390 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
391 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
392 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation') |
|
393 | - ))); |
|
394 | - |
|
395 | - if ($id === NULL) |
|
396 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
397 | - |
|
398 | - // Make sure we have a user first |
|
399 | - $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id)); |
|
400 | - if ($meta === NULL) |
|
401 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
402 | - |
|
403 | - $model = new InviteForm; |
|
404 | - $model->email = Users::model()->findByPk($meta->user_id)->email; |
|
405 | - |
|
406 | - if (Cii::get($_POST, 'InviteForm', NULL) !== NULL) |
|
407 | - { |
|
408 | - $model->attributes = Cii::get($_POST, 'InviteForm', NULL); |
|
409 | - $model->id = $meta->user_id; |
|
410 | - |
|
411 | - if ($model->acceptInvite()) |
|
412 | - { |
|
413 | - $meta->delete(); |
|
414 | - return $this->render('invitesuccess'); |
|
415 | - } |
|
416 | - } |
|
417 | - |
|
418 | - $this->render('acceptinvite', array( |
|
419 | - 'model' => $model |
|
420 | - )); |
|
421 | - } |
|
5 | + public function filters() |
|
6 | + { |
|
7 | + return CMap::mergeArray(parent::filters(), array('accessControl')); |
|
8 | + } |
|
9 | + |
|
10 | + /** |
|
11 | + * Setup access controls to prevent guests from changing their emaila ddress |
|
12 | + */ |
|
13 | + public function accessRules() |
|
14 | + { |
|
15 | + return array( |
|
16 | + array('deny', // The user mut be authenticated to approve an email address change |
|
17 | + 'users'=>array('*'), |
|
18 | + 'expression'=>'Yii::app()->user->isGuest==true', |
|
19 | + 'actions' => array('emailchange') |
|
20 | + ) |
|
21 | + ); |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * beforeAction method, performs operations before an action is presented |
|
26 | + * @param $action, the action being called |
|
27 | + * @see http://www.yiiframework.com/doc/api/1.1/CController#beforeAction-detail |
|
28 | + */ |
|
29 | + public function beforeAction($action) |
|
30 | + { |
|
31 | + if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false)) |
|
32 | + $this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri); |
|
33 | + |
|
34 | + return parent::beforeAction($action); |
|
35 | + } |
|
36 | + |
|
37 | + /** |
|
38 | + * This is the action to handle external exceptions. |
|
39 | + */ |
|
40 | + public function actionError($code=NULL) |
|
41 | + { |
|
42 | + $this->layout = '//layouts/main'; |
|
43 | + |
|
44 | + if($error=Yii::app()->errorHandler->error) |
|
45 | + { |
|
46 | + if(Yii::app()->request->isAjaxRequest) |
|
47 | + echo $error['message']; |
|
48 | + else |
|
49 | + { |
|
50 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}} {{code}}', array( |
|
51 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
52 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Error'), |
|
53 | + '{{code}}' => $error['code'] |
|
54 | + ))); |
|
55 | + |
|
56 | + $this->render('error', array( |
|
57 | + 'error' => $error |
|
58 | + )); |
|
59 | + } |
|
60 | + } |
|
61 | + else |
|
62 | + { |
|
63 | + $message = Yii::app()->user->getFlash('error_code'); |
|
64 | + Yii::app()->user->setFlash('error_code', $message); |
|
65 | + throw new CHttpException($code, $message); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Provides basic sitemap functionality via XML |
|
71 | + */ |
|
72 | + public function actionSitemap() |
|
73 | + { |
|
74 | + ob_end_clean(); |
|
75 | + Yii::app()->log->routes[0]->enabled = false; |
|
76 | + header('Content-type: text/xml; charset=utf-8'); |
|
77 | + $url = Yii::app()->getBaseUrl(true); |
|
78 | + $this->setLayout(null); |
|
79 | + $content = Yii::app()->db |
|
80 | + ->createCommand('SELECT slug, password, type_id, updated FROM content AS t WHERE vid=(SELECT MAX(vid) FROM content WHERE id=t.id) AND status = 1 AND published <= UTC_TIMESTAMP();') |
|
81 | + ->queryAll(); |
|
82 | + |
|
83 | + $categories = Yii::app()->db |
|
84 | + ->createCommand('SELECT slug, updated FROM categories;') |
|
85 | + ->queryAll(); |
|
86 | + |
|
87 | + $this->renderPartial('sitemap', array( |
|
88 | + 'content' => $content, |
|
89 | + 'categories' => $categories, |
|
90 | + 'url' => $url |
|
91 | + )); |
|
92 | + |
|
93 | + Yii::app()->end(); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Provides basic searching functionality |
|
98 | + * @param int $id The search pagination id |
|
99 | + */ |
|
100 | + public function actionSearch($id=1) |
|
101 | + { |
|
102 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
103 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
104 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Search') |
|
105 | + ))); |
|
106 | + |
|
107 | + $this->layout = '//layouts/default'; |
|
108 | + $data = array(); |
|
109 | + $pages = array(); |
|
110 | + $itemCount = 0; |
|
111 | + $pageSize = Cii::getConfig('searchPaginationSize', 10); |
|
112 | + |
|
113 | + if (Cii::get($_GET, 'q', false)) |
|
114 | + { |
|
115 | + $criteria = new CDbCriteria; |
|
116 | + $criteria->addCondition('status = 1') |
|
117 | + ->addCondition('published <= UTC_TIMESTAMP()'); |
|
118 | + |
|
119 | + if (strpos($_GET['q'], 'user_id') !== false) |
|
120 | + { |
|
121 | + $criteria->addCondition('author_id = :author_id') |
|
122 | + ->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id)"); |
|
123 | + $criteria->params = array( |
|
124 | + ':author_id' => str_replace('user_id:', '', Cii::get($_GET, 'q', 0)) |
|
125 | + ); |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | + $param = Cii::get($_GET, 'q', 0); |
|
130 | + $criteria->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))"); |
|
131 | + $criteria->params = array( |
|
132 | + ':param' => '%' . $param . '%', |
|
133 | + ':param2' => '%' . $param . '%' |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + $criteria->addCondition('password = ""'); |
|
138 | + $criteria->limit = $pageSize; |
|
139 | + $criteria->order = 'id DESC'; |
|
140 | + $itemCount = Content::model()->count($criteria); |
|
141 | + $pages = new CPagination($itemCount); |
|
142 | + $pages->pageSize=$pageSize; |
|
143 | + |
|
144 | + $criteria->offset = $criteria->limit*($pages->getCurrentPage()); |
|
145 | + $data = Content::model()->findAll($criteria); |
|
146 | + $pages->applyLimit($criteria); |
|
147 | + } |
|
148 | + |
|
149 | + $this->render('search', array( |
|
150 | + 'url' => 'search', |
|
151 | + 'id' => $id, |
|
152 | + 'data' => $data, |
|
153 | + 'itemCount' => $itemCount, |
|
154 | + 'pages' => $pages |
|
155 | + )); |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Provides functionality to log a user into the system |
|
160 | + */ |
|
161 | + public function actionLogin() |
|
162 | + { |
|
163 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
164 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
165 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Login to your account') |
|
166 | + ))); |
|
167 | + |
|
168 | + $this->layout = '//layouts/main'; |
|
169 | + $model = new LoginForm; |
|
170 | + |
|
171 | + if (Cii::get($_POST, 'LoginForm', false)) |
|
172 | + { |
|
173 | + $model->attributes = Cii::get($_POST, 'LoginForm', array()); |
|
174 | + if ($model->login()) |
|
175 | + $this->redirect($this->_getNext() ?: Yii::app()->user->returnUrl); |
|
176 | + } |
|
177 | + |
|
178 | + $this->render('login', array( |
|
179 | + 'model' => $model |
|
180 | + )); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * Provides functionality to log a user out |
|
185 | + */ |
|
186 | + public function actionLogout() |
|
187 | + { |
|
188 | + if (Yii::app()->request->getParam('next', false)) |
|
189 | + $redirect = $this->createUrl('site/login', array('next' => $this->_getNext())); |
|
190 | + else |
|
191 | + $redirect = Yii::app()->user->returnUrl; |
|
192 | + |
|
193 | + // Purge the active sessions API Key |
|
194 | + $apiKey = UserMetadata::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'key' => 'api_key')); |
|
195 | + |
|
196 | + if ($apiKey != NULL) |
|
197 | + $apiKey->delete(); |
|
198 | + |
|
199 | + |
|
200 | + Yii::app()->user->logout(); |
|
201 | + $this->redirect($redirect); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Handles resetting a users password should they forgot it |
|
206 | + */ |
|
207 | + public function actionForgot() |
|
208 | + { |
|
209 | + $this->layout = '//layouts/main'; |
|
210 | + |
|
211 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
212 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
213 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Forgot Your Password?') |
|
214 | + ))); |
|
215 | + |
|
216 | + $model = new ForgotForm; |
|
217 | + |
|
218 | + if (Cii::get($_POST, 'ForgotForm', false)) |
|
219 | + { |
|
220 | + $model->attributes = $_POST['ForgotForm']; |
|
221 | + |
|
222 | + if ($model->initPasswordResetProcess()) |
|
223 | + { |
|
224 | + Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'A password reset link has been sent to your email address')); |
|
225 | + $this->redirect($this->createUrl('site/login')); |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + $this->render('forgot', array( |
|
230 | + 'model' => $model |
|
231 | + )); |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Alows a user to reset their password if they initiated a forgot password request |
|
236 | + * @param string $id |
|
237 | + */ |
|
238 | + public function actionResetPassword($id=NULL) |
|
239 | + { |
|
240 | + $this->layout = '//layouts/main'; |
|
241 | + |
|
242 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
243 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
244 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Reset Your password') |
|
245 | + ))); |
|
246 | + |
|
247 | + $model = new PasswordResetForm; |
|
248 | + $model->reset_key = $id; |
|
249 | + |
|
250 | + if (!$model->validateResetKey()) |
|
251 | + throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The password reset key provided is invalid')); |
|
252 | + |
|
253 | + if (Cii::get($_POST, 'PasswordResetForm', false)) |
|
254 | + { |
|
255 | + $model->attributes = $_POST['PasswordResetForm']; |
|
256 | + |
|
257 | + if ($model->save()) |
|
258 | + { |
|
259 | + Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your password has been reset, and you may now login with your new password')); |
|
260 | + $this->redirect($this->createUrl('site/login')); |
|
261 | + } |
|
262 | + } |
|
263 | + |
|
264 | + $this->render('resetpassword', array( |
|
265 | + 'model' => $model |
|
266 | + )); |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Allows the user to securely change their email address |
|
271 | + * @param string $key the user's secure key |
|
272 | + */ |
|
273 | + public function actionEmailChange($key=null) |
|
274 | + { |
|
275 | + $this->layout = '//layouts/main'; |
|
276 | + |
|
277 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
278 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
279 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Change Your Email Address') |
|
280 | + ))); |
|
281 | + |
|
282 | + $model = new EmailChangeForm; |
|
283 | + $model->setUser(Users::model()->findByPk(Yii::app()->user->id)); |
|
284 | + $model->verificationKey = $key; |
|
285 | + |
|
286 | + if (!$model->validateVerificationKey()) |
|
287 | + throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The verification key provided is invalid.')); |
|
288 | + |
|
289 | + if (Cii::get($_POST, 'EmailChangeForm', false)) |
|
290 | + { |
|
291 | + $model->attributes = $_POST['EmailChangeForm']; |
|
292 | + |
|
293 | + if ($model->save()) |
|
294 | + { |
|
295 | + Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your new email address has been verified.')); |
|
296 | + |
|
297 | + $loginForm = new LoginForm; |
|
298 | + $loginForm->attributes = array( |
|
299 | + 'username' => Users::model()->findByPk(Yii::app()->user->id)->email, |
|
300 | + 'password' => $model->password, |
|
301 | + ); |
|
302 | + |
|
303 | + if ($loginForm->login()) |
|
304 | + return $this->redirect(Yii::app()->homeUrl); |
|
305 | + |
|
306 | + throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'Unable to re-authenticated user.')); |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + $this->render('emailchange', array( |
|
311 | + 'model' => $model |
|
312 | + )); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Activates a new user's account |
|
317 | + * @param mixed $id The activation key |
|
318 | + */ |
|
319 | + public function actionActivation($id=NULL) |
|
320 | + { |
|
321 | + $this->layout = '//layouts/main'; |
|
322 | + |
|
323 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
324 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
325 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Activate Your Account') |
|
326 | + ))); |
|
327 | + |
|
328 | + $model = new ActivationForm; |
|
329 | + $model->activationKey = $id; |
|
330 | + |
|
331 | + if (!$model->validateKey()) |
|
332 | + throw new CHttpException(403, Yii::t('ciims.models.ActivationForm', 'The activation key you provided is invalid.')); |
|
333 | + |
|
334 | + if (Cii::get($_POST, 'ActivationForm', false)) |
|
335 | + { |
|
336 | + $model->attributes = $_POST['ActivationForm']; |
|
337 | + |
|
338 | + if ($model->save()) |
|
339 | + { |
|
340 | + Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your account has successfully been activated. You may now login')); |
|
341 | + $this->redirect($this->createUrl('site/login')); |
|
342 | + } |
|
343 | + } |
|
344 | + |
|
345 | + $this->render('activation', array( |
|
346 | + 'model' => $model |
|
347 | + )); |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * Handles the registration of new users on the site |
|
352 | + */ |
|
353 | + public function actionRegister() |
|
354 | + { |
|
355 | + $this->layout = '//layouts/main'; |
|
356 | + |
|
357 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
358 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
359 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Sign Up') |
|
360 | + ))); |
|
361 | + |
|
362 | + $model = new RegisterForm; |
|
363 | + |
|
364 | + if (Cii::get($_POST, 'RegisterForm', false)) |
|
365 | + { |
|
366 | + $model->attributes = $_POST['RegisterForm']; |
|
367 | + |
|
368 | + // Save the user's information |
|
369 | + if ($model->save()) |
|
370 | + { |
|
371 | + // Set a flash message |
|
372 | + Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'You have successfully registered an account. Before you can login, please check your email for activation instructions')); |
|
373 | + $this->redirect($this->createUrl('site/login')); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + $this->render('register', array( |
|
378 | + 'model'=>$model |
|
379 | + )); |
|
380 | + } |
|
381 | + |
|
382 | + /** |
|
383 | + * Enables users who have recieved an invitation to setup a new account |
|
384 | + * @param string $id The activation id the of the user that we want to activate |
|
385 | + */ |
|
386 | + public function actionAcceptInvite($id=NULL) |
|
387 | + { |
|
388 | + $this->layout = '//layouts/main'; |
|
389 | + |
|
390 | + $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
391 | + '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
392 | + '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation') |
|
393 | + ))); |
|
394 | + |
|
395 | + if ($id === NULL) |
|
396 | + throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
397 | + |
|
398 | + // Make sure we have a user first |
|
399 | + $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id)); |
|
400 | + if ($meta === NULL) |
|
401 | + throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
402 | + |
|
403 | + $model = new InviteForm; |
|
404 | + $model->email = Users::model()->findByPk($meta->user_id)->email; |
|
405 | + |
|
406 | + if (Cii::get($_POST, 'InviteForm', NULL) !== NULL) |
|
407 | + { |
|
408 | + $model->attributes = Cii::get($_POST, 'InviteForm', NULL); |
|
409 | + $model->id = $meta->user_id; |
|
410 | + |
|
411 | + if ($model->acceptInvite()) |
|
412 | + { |
|
413 | + $meta->delete(); |
|
414 | + return $this->render('invitesuccess'); |
|
415 | + } |
|
416 | + } |
|
417 | + |
|
418 | + $this->render('acceptinvite', array( |
|
419 | + 'model' => $model |
|
420 | + )); |
|
421 | + } |
|
422 | 422 | |
423 | - /** |
|
424 | - * Returns a sanitized $_GET['next'] URL if it is set. |
|
425 | - * @return mixed |
|
426 | - */ |
|
427 | - private function _getNext() |
|
428 | - { |
|
429 | - return str_replace('ftp://', '', str_replace('http://', '', str_replace('https://', '', Yii::app()->request->getParam('next', false)))); |
|
430 | - } |
|
423 | + /** |
|
424 | + * Returns a sanitized $_GET['next'] URL if it is set. |
|
425 | + * @return mixed |
|
426 | + */ |
|
427 | + private function _getNext() |
|
428 | + { |
|
429 | + return str_replace('ftp://', '', str_replace('http://', '', str_replace('https://', '', Yii::app()->request->getParam('next', false)))); |
|
430 | + } |
|
431 | 431 | } |
@@ -2,18 +2,18 @@ discard block |
||
2 | 2 | |
3 | 3 | class SiteController extends CiiController |
4 | 4 | { |
5 | - public function filters() |
|
5 | + public function filters () |
|
6 | 6 | { |
7 | - return CMap::mergeArray(parent::filters(), array('accessControl')); |
|
7 | + return CMap::mergeArray (parent::filters (), array('accessControl')); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Setup access controls to prevent guests from changing their emaila ddress |
12 | 12 | */ |
13 | - public function accessRules() |
|
13 | + public function accessRules () |
|
14 | 14 | { |
15 | 15 | return array( |
16 | - array('deny', // The user mut be authenticated to approve an email address change |
|
16 | + array('deny', // The user mut be authenticated to approve an email address change |
|
17 | 17 | 'users'=>array('*'), |
18 | 18 | 'expression'=>'Yii::app()->user->isGuest==true', |
19 | 19 | 'actions' => array('emailchange') |
@@ -26,127 +26,127 @@ discard block |
||
26 | 26 | * @param $action, the action being called |
27 | 27 | * @see http://www.yiiframework.com/doc/api/1.1/CController#beforeAction-detail |
28 | 28 | */ |
29 | - public function beforeAction($action) |
|
29 | + public function beforeAction ($action) |
|
30 | 30 | { |
31 | - if (!Yii::app()->getRequest()->isSecureConnection && Cii::getConfig('forceSecureSSL', false)) |
|
32 | - $this->redirect('https://' . Yii::app()->getRequest()->serverName . Yii::app()->getRequest()->requestUri); |
|
31 | + if (!Yii::app ()->getRequest ()->isSecureConnection && Cii::getConfig ('forceSecureSSL', false)) |
|
32 | + $this->redirect ('https://'.Yii::app ()->getRequest ()->serverName.Yii::app ()->getRequest ()->requestUri); |
|
33 | 33 | |
34 | - return parent::beforeAction($action); |
|
34 | + return parent::beforeAction ($action); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * This is the action to handle external exceptions. |
39 | 39 | */ |
40 | - public function actionError($code=NULL) |
|
40 | + public function actionError ($code = NULL) |
|
41 | 41 | { |
42 | 42 | $this->layout = '//layouts/main'; |
43 | 43 | |
44 | - if($error=Yii::app()->errorHandler->error) |
|
44 | + if ($error = Yii::app ()->errorHandler->error) |
|
45 | 45 | { |
46 | - if(Yii::app()->request->isAjaxRequest) |
|
46 | + if (Yii::app ()->request->isAjaxRequest) |
|
47 | 47 | echo $error['message']; |
48 | 48 | else |
49 | 49 | { |
50 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}} {{code}}', array( |
|
51 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
52 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Error'), |
|
50 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}} {{code}}', array( |
|
51 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
52 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Error'), |
|
53 | 53 | '{{code}}' => $error['code'] |
54 | 54 | ))); |
55 | 55 | |
56 | - $this->render('error', array( |
|
56 | + $this->render ('error', array( |
|
57 | 57 | 'error' => $error |
58 | 58 | )); |
59 | 59 | } |
60 | 60 | } |
61 | 61 | else |
62 | 62 | { |
63 | - $message = Yii::app()->user->getFlash('error_code'); |
|
64 | - Yii::app()->user->setFlash('error_code', $message); |
|
65 | - throw new CHttpException($code, $message); |
|
63 | + $message = Yii::app ()->user->getFlash ('error_code'); |
|
64 | + Yii::app ()->user->setFlash ('error_code', $message); |
|
65 | + throw new CHttpException ($code, $message); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Provides basic sitemap functionality via XML |
71 | 71 | */ |
72 | - public function actionSitemap() |
|
72 | + public function actionSitemap () |
|
73 | 73 | { |
74 | - ob_end_clean(); |
|
75 | - Yii::app()->log->routes[0]->enabled = false; |
|
76 | - header('Content-type: text/xml; charset=utf-8'); |
|
77 | - $url = Yii::app()->getBaseUrl(true); |
|
78 | - $this->setLayout(null); |
|
79 | - $content = Yii::app()->db |
|
80 | - ->createCommand('SELECT slug, password, type_id, updated FROM content AS t WHERE vid=(SELECT MAX(vid) FROM content WHERE id=t.id) AND status = 1 AND published <= UTC_TIMESTAMP();') |
|
81 | - ->queryAll(); |
|
82 | - |
|
83 | - $categories = Yii::app()->db |
|
84 | - ->createCommand('SELECT slug, updated FROM categories;') |
|
85 | - ->queryAll(); |
|
86 | - |
|
87 | - $this->renderPartial('sitemap', array( |
|
74 | + ob_end_clean (); |
|
75 | + Yii::app ()->log->routes[0]->enabled = false; |
|
76 | + header ('Content-type: text/xml; charset=utf-8'); |
|
77 | + $url = Yii::app ()->getBaseUrl (true); |
|
78 | + $this->setLayout (null); |
|
79 | + $content = Yii::app ()->db |
|
80 | + ->createCommand ('SELECT slug, password, type_id, updated FROM content AS t WHERE vid=(SELECT MAX(vid) FROM content WHERE id=t.id) AND status = 1 AND published <= UTC_TIMESTAMP();') |
|
81 | + ->queryAll (); |
|
82 | + |
|
83 | + $categories = Yii::app ()->db |
|
84 | + ->createCommand ('SELECT slug, updated FROM categories;') |
|
85 | + ->queryAll (); |
|
86 | + |
|
87 | + $this->renderPartial ('sitemap', array( |
|
88 | 88 | 'content' => $content, |
89 | 89 | 'categories' => $categories, |
90 | 90 | 'url' => $url |
91 | 91 | )); |
92 | 92 | |
93 | - Yii::app()->end(); |
|
93 | + Yii::app ()->end (); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Provides basic searching functionality |
98 | 98 | * @param int $id The search pagination id |
99 | 99 | */ |
100 | - public function actionSearch($id=1) |
|
100 | + public function actionSearch ($id = 1) |
|
101 | 101 | { |
102 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
103 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
104 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Search') |
|
102 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
103 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
104 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Search') |
|
105 | 105 | ))); |
106 | 106 | |
107 | 107 | $this->layout = '//layouts/default'; |
108 | 108 | $data = array(); |
109 | 109 | $pages = array(); |
110 | 110 | $itemCount = 0; |
111 | - $pageSize = Cii::getConfig('searchPaginationSize', 10); |
|
111 | + $pageSize = Cii::getConfig ('searchPaginationSize', 10); |
|
112 | 112 | |
113 | - if (Cii::get($_GET, 'q', false)) |
|
113 | + if (Cii::get ($_GET, 'q', false)) |
|
114 | 114 | { |
115 | 115 | $criteria = new CDbCriteria; |
116 | - $criteria->addCondition('status = 1') |
|
117 | - ->addCondition('published <= UTC_TIMESTAMP()'); |
|
116 | + $criteria->addCondition ('status = 1') |
|
117 | + ->addCondition ('published <= UTC_TIMESTAMP()'); |
|
118 | 118 | |
119 | - if (strpos($_GET['q'], 'user_id') !== false) |
|
119 | + if (strpos ($_GET['q'], 'user_id') !== false) |
|
120 | 120 | { |
121 | - $criteria->addCondition('author_id = :author_id') |
|
122 | - ->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id)"); |
|
121 | + $criteria->addCondition ('author_id = :author_id') |
|
122 | + ->addCondition ("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id)"); |
|
123 | 123 | $criteria->params = array( |
124 | - ':author_id' => str_replace('user_id:', '', Cii::get($_GET, 'q', 0)) |
|
124 | + ':author_id' => str_replace ('user_id:', '', Cii::get ($_GET, 'q', 0)) |
|
125 | 125 | ); |
126 | 126 | } |
127 | 127 | else |
128 | 128 | { |
129 | - $param = Cii::get($_GET, 'q', 0); |
|
130 | - $criteria->addCondition("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))"); |
|
129 | + $param = Cii::get ($_GET, 'q', 0); |
|
130 | + $criteria->addCondition ("vid=(SELECT MAX(vid) FROM content AS v WHERE v.id=t.id) AND ((t.content LIKE :param) OR (t.title LIKE :param2))"); |
|
131 | 131 | $criteria->params = array( |
132 | - ':param' => '%' . $param . '%', |
|
133 | - ':param2' => '%' . $param . '%' |
|
132 | + ':param' => '%'.$param.'%', |
|
133 | + ':param2' => '%'.$param.'%' |
|
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
137 | - $criteria->addCondition('password = ""'); |
|
137 | + $criteria->addCondition ('password = ""'); |
|
138 | 138 | $criteria->limit = $pageSize; |
139 | 139 | $criteria->order = 'id DESC'; |
140 | - $itemCount = Content::model()->count($criteria); |
|
141 | - $pages = new CPagination($itemCount); |
|
142 | - $pages->pageSize=$pageSize; |
|
140 | + $itemCount = Content::model ()->count ($criteria); |
|
141 | + $pages = new CPagination ($itemCount); |
|
142 | + $pages->pageSize = $pageSize; |
|
143 | 143 | |
144 | - $criteria->offset = $criteria->limit*($pages->getCurrentPage()); |
|
145 | - $data = Content::model()->findAll($criteria); |
|
146 | - $pages->applyLimit($criteria); |
|
144 | + $criteria->offset = $criteria->limit * ($pages->getCurrentPage ()); |
|
145 | + $data = Content::model ()->findAll ($criteria); |
|
146 | + $pages->applyLimit ($criteria); |
|
147 | 147 | } |
148 | 148 | |
149 | - $this->render('search', array( |
|
149 | + $this->render ('search', array( |
|
150 | 150 | 'url' => 'search', |
151 | 151 | 'id' => $id, |
152 | 152 | 'data' => $data, |
@@ -158,24 +158,24 @@ discard block |
||
158 | 158 | /** |
159 | 159 | * Provides functionality to log a user into the system |
160 | 160 | */ |
161 | - public function actionLogin() |
|
161 | + public function actionLogin () |
|
162 | 162 | { |
163 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
164 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
165 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Login to your account') |
|
163 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
164 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
165 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Login to your account') |
|
166 | 166 | ))); |
167 | 167 | |
168 | 168 | $this->layout = '//layouts/main'; |
169 | 169 | $model = new LoginForm; |
170 | 170 | |
171 | - if (Cii::get($_POST, 'LoginForm', false)) |
|
171 | + if (Cii::get ($_POST, 'LoginForm', false)) |
|
172 | 172 | { |
173 | - $model->attributes = Cii::get($_POST, 'LoginForm', array()); |
|
174 | - if ($model->login()) |
|
175 | - $this->redirect($this->_getNext() ?: Yii::app()->user->returnUrl); |
|
173 | + $model->attributes = Cii::get ($_POST, 'LoginForm', array()); |
|
174 | + if ($model->login ()) |
|
175 | + $this->redirect ($this->_getNext () ? : Yii::app ()->user->returnUrl); |
|
176 | 176 | } |
177 | 177 | |
178 | - $this->render('login', array( |
|
178 | + $this->render ('login', array( |
|
179 | 179 | 'model' => $model |
180 | 180 | )); |
181 | 181 | } |
@@ -183,50 +183,50 @@ discard block |
||
183 | 183 | /** |
184 | 184 | * Provides functionality to log a user out |
185 | 185 | */ |
186 | - public function actionLogout() |
|
186 | + public function actionLogout () |
|
187 | 187 | { |
188 | - if (Yii::app()->request->getParam('next', false)) |
|
189 | - $redirect = $this->createUrl('site/login', array('next' => $this->_getNext())); |
|
188 | + if (Yii::app ()->request->getParam ('next', false)) |
|
189 | + $redirect = $this->createUrl ('site/login', array('next' => $this->_getNext ())); |
|
190 | 190 | else |
191 | - $redirect = Yii::app()->user->returnUrl; |
|
191 | + $redirect = Yii::app ()->user->returnUrl; |
|
192 | 192 | |
193 | 193 | // Purge the active sessions API Key |
194 | - $apiKey = UserMetadata::model()->findByAttributes(array('user_id' => Yii::app()->user->id, 'key' => 'api_key')); |
|
194 | + $apiKey = UserMetadata::model ()->findByAttributes (array('user_id' => Yii::app ()->user->id, 'key' => 'api_key')); |
|
195 | 195 | |
196 | 196 | if ($apiKey != NULL) |
197 | - $apiKey->delete(); |
|
197 | + $apiKey->delete (); |
|
198 | 198 | |
199 | 199 | |
200 | - Yii::app()->user->logout(); |
|
201 | - $this->redirect($redirect); |
|
200 | + Yii::app ()->user->logout (); |
|
201 | + $this->redirect ($redirect); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | 205 | * Handles resetting a users password should they forgot it |
206 | 206 | */ |
207 | - public function actionForgot() |
|
207 | + public function actionForgot () |
|
208 | 208 | { |
209 | 209 | $this->layout = '//layouts/main'; |
210 | 210 | |
211 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
212 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
213 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Forgot Your Password?') |
|
211 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
212 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
213 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Forgot Your Password?') |
|
214 | 214 | ))); |
215 | 215 | |
216 | 216 | $model = new ForgotForm; |
217 | 217 | |
218 | - if (Cii::get($_POST, 'ForgotForm', false)) |
|
218 | + if (Cii::get ($_POST, 'ForgotForm', false)) |
|
219 | 219 | { |
220 | 220 | $model->attributes = $_POST['ForgotForm']; |
221 | 221 | |
222 | - if ($model->initPasswordResetProcess()) |
|
222 | + if ($model->initPasswordResetProcess ()) |
|
223 | 223 | { |
224 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'A password reset link has been sent to your email address')); |
|
225 | - $this->redirect($this->createUrl('site/login')); |
|
224 | + Yii::app ()->user->setFlash ('success', Yii::t ('ciims.controllers.Site', 'A password reset link has been sent to your email address')); |
|
225 | + $this->redirect ($this->createUrl ('site/login')); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - $this->render('forgot', array( |
|
229 | + $this->render ('forgot', array( |
|
230 | 230 | 'model' => $model |
231 | 231 | )); |
232 | 232 | } |
@@ -235,33 +235,33 @@ discard block |
||
235 | 235 | * Alows a user to reset their password if they initiated a forgot password request |
236 | 236 | * @param string $id |
237 | 237 | */ |
238 | - public function actionResetPassword($id=NULL) |
|
238 | + public function actionResetPassword ($id = NULL) |
|
239 | 239 | { |
240 | 240 | $this->layout = '//layouts/main'; |
241 | 241 | |
242 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
243 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
244 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Reset Your password') |
|
242 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
243 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
244 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Reset Your password') |
|
245 | 245 | ))); |
246 | 246 | |
247 | 247 | $model = new PasswordResetForm; |
248 | 248 | $model->reset_key = $id; |
249 | 249 | |
250 | - if (!$model->validateResetKey()) |
|
251 | - throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The password reset key provided is invalid')); |
|
250 | + if (!$model->validateResetKey ()) |
|
251 | + throw new CHttpException (403, Yii::t ('ciims.controllers.Site', 'The password reset key provided is invalid')); |
|
252 | 252 | |
253 | - if (Cii::get($_POST, 'PasswordResetForm', false)) |
|
253 | + if (Cii::get ($_POST, 'PasswordResetForm', false)) |
|
254 | 254 | { |
255 | 255 | $model->attributes = $_POST['PasswordResetForm']; |
256 | 256 | |
257 | - if ($model->save()) |
|
257 | + if ($model->save ()) |
|
258 | 258 | { |
259 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your password has been reset, and you may now login with your new password')); |
|
260 | - $this->redirect($this->createUrl('site/login')); |
|
259 | + Yii::app ()->user->setFlash ('success', Yii::t ('ciims.controllers.Site', 'Your password has been reset, and you may now login with your new password')); |
|
260 | + $this->redirect ($this->createUrl ('site/login')); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - $this->render('resetpassword', array( |
|
264 | + $this->render ('resetpassword', array( |
|
265 | 265 | 'model' => $model |
266 | 266 | )); |
267 | 267 | } |
@@ -270,44 +270,44 @@ discard block |
||
270 | 270 | * Allows the user to securely change their email address |
271 | 271 | * @param string $key the user's secure key |
272 | 272 | */ |
273 | - public function actionEmailChange($key=null) |
|
273 | + public function actionEmailChange ($key = null) |
|
274 | 274 | { |
275 | 275 | $this->layout = '//layouts/main'; |
276 | 276 | |
277 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
278 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
279 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Change Your Email Address') |
|
277 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
278 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
279 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Change Your Email Address') |
|
280 | 280 | ))); |
281 | 281 | |
282 | 282 | $model = new EmailChangeForm; |
283 | - $model->setUser(Users::model()->findByPk(Yii::app()->user->id)); |
|
283 | + $model->setUser (Users::model ()->findByPk (Yii::app ()->user->id)); |
|
284 | 284 | $model->verificationKey = $key; |
285 | 285 | |
286 | - if (!$model->validateVerificationKey()) |
|
287 | - throw new CHttpException(403, Yii::t('ciims.controllers.Site', 'The verification key provided is invalid.')); |
|
286 | + if (!$model->validateVerificationKey ()) |
|
287 | + throw new CHttpException (403, Yii::t ('ciims.controllers.Site', 'The verification key provided is invalid.')); |
|
288 | 288 | |
289 | - if (Cii::get($_POST, 'EmailChangeForm', false)) |
|
289 | + if (Cii::get ($_POST, 'EmailChangeForm', false)) |
|
290 | 290 | { |
291 | 291 | $model->attributes = $_POST['EmailChangeForm']; |
292 | 292 | |
293 | - if ($model->save()) |
|
293 | + if ($model->save ()) |
|
294 | 294 | { |
295 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your new email address has been verified.')); |
|
295 | + Yii::app ()->user->setFlash ('success', Yii::t ('ciims.controllers.Site', 'Your new email address has been verified.')); |
|
296 | 296 | |
297 | 297 | $loginForm = new LoginForm; |
298 | 298 | $loginForm->attributes = array( |
299 | - 'username' => Users::model()->findByPk(Yii::app()->user->id)->email, |
|
299 | + 'username' => Users::model ()->findByPk (Yii::app ()->user->id)->email, |
|
300 | 300 | 'password' => $model->password, |
301 | 301 | ); |
302 | 302 | |
303 | - if ($loginForm->login()) |
|
304 | - return $this->redirect(Yii::app()->homeUrl); |
|
303 | + if ($loginForm->login ()) |
|
304 | + return $this->redirect (Yii::app ()->homeUrl); |
|
305 | 305 | |
306 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'Unable to re-authenticated user.')); |
|
306 | + throw new CHttpException (400, Yii::t ('ciims.controllers.Site', 'Unable to re-authenticated user.')); |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - $this->render('emailchange', array( |
|
310 | + $this->render ('emailchange', array( |
|
311 | 311 | 'model' => $model |
312 | 312 | )); |
313 | 313 | } |
@@ -316,33 +316,33 @@ discard block |
||
316 | 316 | * Activates a new user's account |
317 | 317 | * @param mixed $id The activation key |
318 | 318 | */ |
319 | - public function actionActivation($id=NULL) |
|
319 | + public function actionActivation ($id = NULL) |
|
320 | 320 | { |
321 | 321 | $this->layout = '//layouts/main'; |
322 | 322 | |
323 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
324 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
325 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Activate Your Account') |
|
323 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
324 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
325 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Activate Your Account') |
|
326 | 326 | ))); |
327 | 327 | |
328 | 328 | $model = new ActivationForm; |
329 | 329 | $model->activationKey = $id; |
330 | 330 | |
331 | - if (!$model->validateKey()) |
|
332 | - throw new CHttpException(403, Yii::t('ciims.models.ActivationForm', 'The activation key you provided is invalid.')); |
|
331 | + if (!$model->validateKey ()) |
|
332 | + throw new CHttpException (403, Yii::t ('ciims.models.ActivationForm', 'The activation key you provided is invalid.')); |
|
333 | 333 | |
334 | - if (Cii::get($_POST, 'ActivationForm', false)) |
|
334 | + if (Cii::get ($_POST, 'ActivationForm', false)) |
|
335 | 335 | { |
336 | 336 | $model->attributes = $_POST['ActivationForm']; |
337 | 337 | |
338 | - if ($model->save()) |
|
338 | + if ($model->save ()) |
|
339 | 339 | { |
340 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'Your account has successfully been activated. You may now login')); |
|
341 | - $this->redirect($this->createUrl('site/login')); |
|
340 | + Yii::app ()->user->setFlash ('success', Yii::t ('ciims.controllers.Site', 'Your account has successfully been activated. You may now login')); |
|
341 | + $this->redirect ($this->createUrl ('site/login')); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - $this->render('activation', array( |
|
345 | + $this->render ('activation', array( |
|
346 | 346 | 'model' => $model |
347 | 347 | )); |
348 | 348 | } |
@@ -350,31 +350,31 @@ discard block |
||
350 | 350 | /** |
351 | 351 | * Handles the registration of new users on the site |
352 | 352 | */ |
353 | - public function actionRegister() |
|
353 | + public function actionRegister () |
|
354 | 354 | { |
355 | 355 | $this->layout = '//layouts/main'; |
356 | 356 | |
357 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
358 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
359 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Sign Up') |
|
357 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
358 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
359 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Sign Up') |
|
360 | 360 | ))); |
361 | 361 | |
362 | 362 | $model = new RegisterForm; |
363 | 363 | |
364 | - if (Cii::get($_POST, 'RegisterForm', false)) |
|
364 | + if (Cii::get ($_POST, 'RegisterForm', false)) |
|
365 | 365 | { |
366 | 366 | $model->attributes = $_POST['RegisterForm']; |
367 | 367 | |
368 | 368 | // Save the user's information |
369 | - if ($model->save()) |
|
369 | + if ($model->save ()) |
|
370 | 370 | { |
371 | 371 | // Set a flash message |
372 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Site', 'You have successfully registered an account. Before you can login, please check your email for activation instructions')); |
|
373 | - $this->redirect($this->createUrl('site/login')); |
|
372 | + Yii::app ()->user->setFlash ('success', Yii::t ('ciims.controllers.Site', 'You have successfully registered an account. Before you can login, please check your email for activation instructions')); |
|
373 | + $this->redirect ($this->createUrl ('site/login')); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
377 | - $this->render('register', array( |
|
377 | + $this->render ('register', array( |
|
378 | 378 | 'model'=>$model |
379 | 379 | )); |
380 | 380 | } |
@@ -383,39 +383,39 @@ discard block |
||
383 | 383 | * Enables users who have recieved an invitation to setup a new account |
384 | 384 | * @param string $id The activation id the of the user that we want to activate |
385 | 385 | */ |
386 | - public function actionAcceptInvite($id=NULL) |
|
386 | + public function actionAcceptInvite ($id = NULL) |
|
387 | 387 | { |
388 | 388 | $this->layout = '//layouts/main'; |
389 | 389 | |
390 | - $this->setPageTitle(Yii::t('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
391 | - '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
|
392 | - '{{label}}' => Yii::t('ciims.controllers.Site', 'Accept Invitation') |
|
390 | + $this->setPageTitle (Yii::t ('ciims.controllers.Site', '{{app_name}} | {{label}}', array( |
|
391 | + '{{app_name}}' => Cii::getConfig ('name', Yii::app ()->name), |
|
392 | + '{{label}}' => Yii::t ('ciims.controllers.Site', 'Accept Invitation') |
|
393 | 393 | ))); |
394 | 394 | |
395 | 395 | if ($id === NULL) |
396 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
396 | + throw new CHttpException (400, Yii::t ('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
397 | 397 | |
398 | 398 | // Make sure we have a user first |
399 | - $meta = UserMetadata::model()->findByAttributes(array('key' => 'invitationKey', 'value' => $id)); |
|
399 | + $meta = UserMetadata::model ()->findByAttributes (array('key' => 'invitationKey', 'value' => $id)); |
|
400 | 400 | if ($meta === NULL) |
401 | - throw new CHttpException(400, Yii::t('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
401 | + throw new CHttpException (400, Yii::t ('ciims.controllers.Site', 'There was an error fulfilling your request.')); |
|
402 | 402 | |
403 | 403 | $model = new InviteForm; |
404 | - $model->email = Users::model()->findByPk($meta->user_id)->email; |
|
404 | + $model->email = Users::model ()->findByPk ($meta->user_id)->email; |
|
405 | 405 | |
406 | - if (Cii::get($_POST, 'InviteForm', NULL) !== NULL) |
|
406 | + if (Cii::get ($_POST, 'InviteForm', NULL) !== NULL) |
|
407 | 407 | { |
408 | - $model->attributes = Cii::get($_POST, 'InviteForm', NULL); |
|
408 | + $model->attributes = Cii::get ($_POST, 'InviteForm', NULL); |
|
409 | 409 | $model->id = $meta->user_id; |
410 | 410 | |
411 | - if ($model->acceptInvite()) |
|
411 | + if ($model->acceptInvite ()) |
|
412 | 412 | { |
413 | - $meta->delete(); |
|
414 | - return $this->render('invitesuccess'); |
|
413 | + $meta->delete (); |
|
414 | + return $this->render ('invitesuccess'); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | - $this->render('acceptinvite', array( |
|
418 | + $this->render ('acceptinvite', array( |
|
419 | 419 | 'model' => $model |
420 | 420 | )); |
421 | 421 | } |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | * Returns a sanitized $_GET['next'] URL if it is set. |
425 | 425 | * @return mixed |
426 | 426 | */ |
427 | - private function _getNext() |
|
427 | + private function _getNext () |
|
428 | 428 | { |
429 | - return str_replace('ftp://', '', str_replace('http://', '', str_replace('https://', '', Yii::app()->request->getParam('next', false)))); |
|
429 | + return str_replace ('ftp://', '', str_replace ('http://', '', str_replace ('https://', '', Yii::app ()->request->getParam ('next', false)))); |
|
430 | 430 | } |
431 | 431 | } |
@@ -16,6 +16,6 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'Unable to save change key' => '', |
21 | 21 | ); |
@@ -17,5 +17,5 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'Unable to save change key' => '', |
|
20 | + 'Unable to save change key' => '', |
|
21 | 21 | ); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'Invalid routing' => '', |
21 | 21 | '{{app_name}} | {{label}}' => '', |
22 | 22 | ); |
@@ -17,6 +17,6 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'Invalid routing' => '', |
|
21 | - '{{app_name}} | {{label}}' => '', |
|
20 | + 'Invalid routing' => '', |
|
21 | + '{{app_name}} | {{label}}' => '', |
|
22 | 22 | ); |
@@ -16,6 +16,6 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'This site is currently disabled. Please check back later.' => '', |
21 | 21 | ); |
@@ -17,5 +17,5 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'This site is currently disabled. Please check back later.' => '', |
|
20 | + 'This site is currently disabled. Please check back later.' => '', |
|
21 | 21 | ); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'All Content' => '', |
21 | 21 | 'Incorrect password' => '', |
22 | 22 | 'Password Required' => '', |
@@ -17,10 +17,10 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'All Content' => '', |
|
21 | - 'Incorrect password' => '', |
|
22 | - 'Password Required' => '', |
|
23 | - 'The article you specified does not exist. If you bookmarked this page, please delete it.' => '', |
|
24 | - 'Too many password attempts. Please try again in 5 minutes' => '', |
|
25 | - '{{app_name}} | {{label}}' => '', |
|
20 | + 'All Content' => '', |
|
21 | + 'Incorrect password' => '', |
|
22 | + 'Password Required' => '', |
|
23 | + 'The article you specified does not exist. If you bookmarked this page, please delete it.' => '', |
|
24 | + 'Too many password attempts. Please try again in 5 minutes' => '', |
|
25 | + '{{app_name}} | {{label}}' => '', |
|
26 | 26 | ); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'A new verification email has been resent to {{user}}. Please check your email address.' => '', |
21 | 21 | 'Oops! That user doesn\'t exist on our network!' => '', |
22 | 22 | 'There was an error resending the verification email. Please try again later.' => '', |
@@ -17,10 +17,10 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'A new verification email has been resent to {{user}}. Please check your email address.' => '', |
|
21 | - 'Oops! That user doesn\'t exist on our network!' => '', |
|
22 | - 'There was an error resending the verification email. Please try again later.' => '', |
|
23 | - 'There were errors saving your profile. Please correct them before trying to save again.' => '', |
|
24 | - 'User {{user}} - CiiMS | {{sitename}}' => '', |
|
25 | - 'Your profile has been updated!' => '', |
|
20 | + 'A new verification email has been resent to {{user}}. Please check your email address.' => '', |
|
21 | + 'Oops! That user doesn\'t exist on our network!' => '', |
|
22 | + 'There was an error resending the verification email. Please try again later.' => '', |
|
23 | + 'There were errors saving your profile. Please correct them before trying to save again.' => '', |
|
24 | + 'User {{user}} - CiiMS | {{sitename}}' => '', |
|
25 | + 'Your profile has been updated!' => '', |
|
26 | 26 | ); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'A password reset link has been sent to your email address' => '', |
21 | 21 | 'Accept Invitation' => '', |
22 | 22 | 'Activate Your Account' => '', |
@@ -17,27 +17,27 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'A password reset link has been sent to your email address' => '', |
|
21 | - 'Accept Invitation' => '', |
|
22 | - 'Activate Your Account' => '', |
|
23 | - 'An email has been sent to {{email}} with further instructions on how to reset your password' => '', |
|
24 | - 'Change Your Email Address' => '', |
|
25 | - 'Error' => '', |
|
26 | - 'Error {{code}}' => '', |
|
27 | - 'Forgot Your Password?' => '', |
|
28 | - 'Login to your account' => '', |
|
29 | - 'Reset Your password' => '', |
|
30 | - 'Search' => '', |
|
31 | - 'Sign Up' => '', |
|
32 | - 'The password reset key provided is invalid' => '', |
|
33 | - 'The verification key provided is invalid.' => '', |
|
34 | - 'There was an error fulfilling your request.' => '', |
|
35 | - 'Unable to re-authenticated user' => '', |
|
36 | - 'Unable to re-authenticated user.' => '', |
|
37 | - 'You have successfully registered an account. Before you can login, please check your email for activation instructions' => '', |
|
38 | - 'Your account has successfully been activated. You may now login' => '', |
|
39 | - 'Your new email address has been verified.' => '', |
|
40 | - 'Your password has been reset, and you may now login with your new password' => '', |
|
41 | - '{{app_name}} | {{label}}' => '', |
|
42 | - '{{app_name}} | {{label}} {{code}}' => '', |
|
20 | + 'A password reset link has been sent to your email address' => '', |
|
21 | + 'Accept Invitation' => '', |
|
22 | + 'Activate Your Account' => '', |
|
23 | + 'An email has been sent to {{email}} with further instructions on how to reset your password' => '', |
|
24 | + 'Change Your Email Address' => '', |
|
25 | + 'Error' => '', |
|
26 | + 'Error {{code}}' => '', |
|
27 | + 'Forgot Your Password?' => '', |
|
28 | + 'Login to your account' => '', |
|
29 | + 'Reset Your password' => '', |
|
30 | + 'Search' => '', |
|
31 | + 'Sign Up' => '', |
|
32 | + 'The password reset key provided is invalid' => '', |
|
33 | + 'The verification key provided is invalid.' => '', |
|
34 | + 'There was an error fulfilling your request.' => '', |
|
35 | + 'Unable to re-authenticated user' => '', |
|
36 | + 'Unable to re-authenticated user.' => '', |
|
37 | + 'You have successfully registered an account. Before you can login, please check your email for activation instructions' => '', |
|
38 | + 'Your account has successfully been activated. You may now login' => '', |
|
39 | + 'Your new email address has been verified.' => '', |
|
40 | + 'Your password has been reset, and you may now login with your new password' => '', |
|
41 | + '{{app_name}} | {{label}}' => '', |
|
42 | + '{{app_name}} | {{label}} {{code}}' => '', |
|
43 | 43 | ); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'The requested post cannot be found.' => '', |
21 | 21 | 'The specified post cannot be found.' => '', |
22 | 22 | 'Use of CiiController::sendEmail is deprecated, and will be dropped in a future version. Use EmailSettings::send instead' => '', |
@@ -17,7 +17,7 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'The requested post cannot be found.' => '', |
|
21 | - 'The specified post cannot be found.' => '', |
|
22 | - 'Use of CiiController::sendEmail is deprecated, and will be dropped in a future version. Use EmailSettings::send instead' => '', |
|
20 | + 'The requested post cannot be found.' => '', |
|
21 | + 'The specified post cannot be found.' => '', |
|
22 | + 'Use of CiiController::sendEmail is deprecated, and will be dropped in a future version. Use EmailSettings::send instead' => '', |
|
23 | 23 | ); |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * |
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | -return array ( |
|
19 | +return array( |
|
20 | 20 | 'Activate Your Account' => '', |
21 | 21 | 'Your Password Reset Information' => '', |
22 | 22 | ); |
@@ -17,6 +17,6 @@ |
||
17 | 17 | * NOTE, this file must be saved in UTF-8 encoding. |
18 | 18 | */ |
19 | 19 | return array ( |
20 | - 'Activate Your Account' => '', |
|
21 | - 'Your Password Reset Information' => '', |
|
20 | + 'Activate Your Account' => '', |
|
21 | + 'Your Password Reset Information' => '', |
|
22 | 22 | ); |