@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | Yii::import('cii.commands.CiiConsoleCommand'); |
4 | -class CiiCacheCommand extends CiiConsoleCommand |
|
5 | -{ |
|
6 | - public function actionFlush() |
|
7 | - { |
|
4 | +class CiiCacheCommand extends CiiConsoleCommand |
|
5 | +{ |
|
6 | + public function actionFlush() |
|
7 | + { |
|
8 | 8 | $this->log(Yii::app()->cache->flush() ? "Cache flushed" : "Unable to flush cache. Are we connected?"); |
9 | 9 | unlink(__DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php'); |
10 | 10 | return; |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | Yii::import('cii.commands.CiiConsoleCommand'); |
4 | -class CiiClassMapCommand extends CiiConsoleCommand |
|
5 | -{ |
|
6 | - public function actionIndex() |
|
7 | - { |
|
4 | +class CiiClassMapCommand extends CiiConsoleCommand |
|
5 | +{ |
|
6 | + public function actionIndex() |
|
7 | + { |
|
8 | 8 | $data = "<?php\n"; |
9 | 9 | $data .= '$basePath = dirname(__FILE__) . \'/..\';' . "\n"; |
10 | 10 | $data .= 'Yii::$classMap = ' . "array(\n"; |
@@ -21,16 +21,17 @@ discard block |
||
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
24 | - private function updateDataPath($path, &$data) |
|
25 | - { |
|
24 | + private function updateDataPath($path, &$data) |
|
25 | + { |
|
26 | 26 | $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); |
27 | 27 | foreach($objects as $name => $object) |
28 | 28 | { |
29 | 29 | if (strpos($name, '.php') !== false && strpos($name, 'gii') === false) |
30 | 30 | { |
31 | 31 | $id = str_replace('.php', '', substr( $name, strrpos( $name, '/' )+1 )); |
32 | - if ($this->startsWithUpper($id)) |
|
33 | - $data .= " '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n"; |
|
32 | + if ($this->startsWithUpper($id)) { |
|
33 | + $data .= " '" . $id . "' => " . '$basePath . \'' . str_replace('/var/www/ciims/protected', '', $name) . "',\n"; |
|
34 | + } |
|
34 | 35 | } |
35 | 36 | } |
36 | 37 | |
@@ -40,8 +41,8 @@ discard block |
||
40 | 41 | /** |
41 | 42 | * @param string $str |
42 | 43 | */ |
43 | - private function startsWithUpper($str) |
|
44 | - { |
|
44 | + private function startsWithUpper($str) |
|
45 | + { |
|
45 | 46 | $chr = mb_substr ($str, 0, 1, "UTF-8"); |
46 | 47 | return mb_strtolower($chr, "UTF-8") != $chr; |
47 | 48 | } |
@@ -72,8 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function actionThemes($name=NULL) |
74 | 74 | { |
75 | - if ($name === NULL) |
|
76 | - $this->usageError('A theme was not specified for translations'); |
|
75 | + if ($name === NULL) { |
|
76 | + $this->usageError('A theme was not specified for translations'); |
|
77 | + } |
|
77 | 78 | |
78 | 79 | $this->_config['type'] = 'theme'; |
79 | 80 | array_push($this->_config['exclude'], 'modules'); |
@@ -88,8 +89,9 @@ discard block |
||
88 | 89 | */ |
89 | 90 | public function actionModules($name=NULL) |
90 | 91 | { |
91 | - if ($name === NULL) |
|
92 | - $this->usageError('A module was not specified for translations'); |
|
92 | + if ($name === NULL) { |
|
93 | + $this->usageError('A module was not specified for translations'); |
|
94 | + } |
|
93 | 95 | |
94 | 96 | $this->_config['type'] = 'module'; |
95 | 97 | array_push($this->_config['exclude'], 'themes'); |
@@ -119,8 +121,9 @@ discard block |
||
119 | 121 | $this->validateConfig(); |
120 | 122 | |
121 | 123 | // Determine the messages |
122 | - foreach($this->getFiles() as $file) |
|
123 | - $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
124 | + foreach($this->getFiles() as $file) { |
|
125 | + $this->_messages = array_merge_recursive($this->_messages,$this->extractMessages($file,$this->_translator)); |
|
126 | + } |
|
124 | 127 | |
125 | 128 | foreach($languages as $language) |
126 | 129 | { |
@@ -139,19 +142,19 @@ discard block |
||
139 | 142 | $data = explode('.', $category); |
140 | 143 | unset($data[0]); |
141 | 144 | $dirPath = implode(DS, $data); |
142 | - } |
|
143 | - else if ($this->_config['type'] == 'module') |
|
145 | + } else if ($this->_config['type'] == 'module') |
|
144 | 146 | { |
145 | 147 | $data = explode('.', $category); |
146 | 148 | unset($data[0]); |
147 | 149 | unset($data[1]); |
148 | 150 | $dirPath = implode(DS, $data); |
151 | + } else { |
|
152 | + $dirPath = implode(DS, explode('.', $category)); |
|
149 | 153 | } |
150 | - else |
|
151 | - $dirPath = implode(DS, explode('.', $category)); |
|
152 | 154 | |
153 | - if (empty($dirPath)) |
|
154 | - continue; |
|
155 | + if (empty($dirPath)) { |
|
156 | + continue; |
|
157 | + } |
|
155 | 158 | |
156 | 159 | $this->createDirectory($dir . DS . $dirPath); |
157 | 160 | $this->createDirectory($dir . DS . $language); |
@@ -170,8 +173,9 @@ discard block |
||
170 | 173 | { |
171 | 174 | if (!is_dir($directory)) |
172 | 175 | { |
173 | - if (!mkdir($directory, 0777, true)) |
|
174 | - $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
176 | + if (!mkdir($directory, 0777, true)) { |
|
177 | + $this->usageError('The directory ' . $directory .' could not be created. Please make sure this process has write access to this directory.'); |
|
178 | + } |
|
175 | 179 | } |
176 | 180 | |
177 | 181 | return true; |
@@ -192,8 +196,9 @@ discard block |
||
192 | 196 | // Strip out all extensions |
193 | 197 | foreach ($files as $k=>$file) |
194 | 198 | { |
195 | - if (strpos($file, 'extensions') !== false) |
|
196 | - unset($files[$k]); |
|
199 | + if (strpos($file, 'extensions') !== false) { |
|
200 | + unset($files[$k]); |
|
201 | + } |
|
197 | 202 | } |
198 | 203 | |
199 | 204 | reset($files); |
@@ -208,17 +213,21 @@ discard block |
||
208 | 213 | { |
209 | 214 | extract($this->_config); |
210 | 215 | |
211 | - if(!isset($sourcePath,$messagePath,$languages)) |
|
212 | - $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
216 | + if(!isset($sourcePath,$messagePath,$languages)) { |
|
217 | + $this->usageError('The configuration file must specify "sourcePath", "messagePath" and "languages".'); |
|
218 | + } |
|
213 | 219 | |
214 | - if(!is_dir($sourcePath)) |
|
215 | - $this->usageError("The source path $sourcePath is not a valid directory."); |
|
220 | + if(!is_dir($sourcePath)) { |
|
221 | + $this->usageError("The source path $sourcePath is not a valid directory."); |
|
222 | + } |
|
216 | 223 | |
217 | - if(!is_dir($messagePath)) |
|
218 | - $this->usageError("The message path $messagePath is not a valid directory."); |
|
224 | + if(!is_dir($messagePath)) { |
|
225 | + $this->usageError("The message path $messagePath is not a valid directory."); |
|
226 | + } |
|
219 | 227 | |
220 | - if(empty($languages)) |
|
221 | - $this->usageError("Languages cannot be empty."); |
|
228 | + if(empty($languages)) { |
|
229 | + $this->usageError("Languages cannot be empty."); |
|
230 | + } |
|
222 | 231 | } |
223 | 232 | |
224 | 233 | /** |
@@ -228,8 +237,9 @@ discard block |
||
228 | 237 | { |
229 | 238 | $subject=file_get_contents($fileName); |
230 | 239 | $messages=array(); |
231 | - if(!is_array($translator)) |
|
232 | - $translator=array($translator); |
|
240 | + if(!is_array($translator)) { |
|
241 | + $translator=array($translator); |
|
242 | + } |
|
233 | 243 | |
234 | 244 | foreach ($translator as $currentTranslator) |
235 | 245 | { |
@@ -239,15 +249,16 @@ discard block |
||
239 | 249 | { |
240 | 250 | if(($pos=strpos($matches[$i][1],'.'))!==false) |
241 | 251 | { |
242 | - if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) |
|
243 | - $category='module.'.substr($matches[$i][1],1,-1); |
|
244 | - else if (strpos($matches[$i][1],'Theme')!==false) |
|
245 | - $category=$matches[$i][1]; |
|
246 | - else |
|
247 | - $category=substr($matches[$i][1],$pos+1,-1); |
|
252 | + if (strpos($matches[$i][1],'Dashboard')!==false || strpos($matches[$i][1],'Hybridauth')!==false || strpos($matches[$i][1],'Install')!==false) { |
|
253 | + $category='module.'.substr($matches[$i][1],1,-1); |
|
254 | + } else if (strpos($matches[$i][1],'Theme')!==false) { |
|
255 | + $category=$matches[$i][1]; |
|
256 | + } else { |
|
257 | + $category=substr($matches[$i][1],$pos+1,-1); |
|
258 | + } |
|
259 | + } else { |
|
260 | + $category=substr($matches[$i][1],1,-1); |
|
248 | 261 | } |
249 | - else |
|
250 | - $category=substr($matches[$i][1],1,-1); |
|
251 | 262 | |
252 | 263 | |
253 | 264 | $message=$matches[$i][2]; |
@@ -287,18 +298,20 @@ discard block |
||
287 | 298 | |
288 | 299 | foreach($messages as $message) |
289 | 300 | { |
290 | - if(array_key_exists($message,$translated) && strlen($translated[$message])>0) |
|
291 | - $merged[$message]=$translated[$message]; |
|
292 | - else |
|
293 | - $untranslated[]=$message; |
|
301 | + if(array_key_exists($message,$translated) && strlen($translated[$message])>0) { |
|
302 | + $merged[$message]=$translated[$message]; |
|
303 | + } else { |
|
304 | + $untranslated[]=$message; |
|
305 | + } |
|
294 | 306 | } |
295 | 307 | |
296 | 308 | ksort($merged); |
297 | 309 | sort($untranslated); |
298 | 310 | $todo=array(); |
299 | 311 | |
300 | - foreach($untranslated as $message) |
|
301 | - $todo[$message]=''; |
|
312 | + foreach($untranslated as $message) { |
|
313 | + $todo[$message]=''; |
|
314 | + } |
|
302 | 315 | |
303 | 316 | ksort($translated); |
304 | 317 | |
@@ -306,30 +319,33 @@ discard block |
||
306 | 319 | { |
307 | 320 | if(!isset($merged[$message]) && !isset($todo[$message]) && !$removeOld) |
308 | 321 | { |
309 | - if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') |
|
310 | - $todo[$message]=$translation; |
|
311 | - else if ($translation == '') |
|
312 | - $todo[$message] = ''; |
|
313 | - else |
|
314 | - $todo[$message]='@@'.$translation.'@@'; |
|
322 | + if(substr($translation,0,2)==='@@' && substr($translation,-2)==='@@') { |
|
323 | + $todo[$message]=$translation; |
|
324 | + } else if ($translation == '') { |
|
325 | + $todo[$message] = ''; |
|
326 | + } else { |
|
327 | + $todo[$message]='@@'.$translation.'@@'; |
|
328 | + } |
|
315 | 329 | } |
316 | 330 | } |
317 | 331 | |
318 | 332 | $merged=array_merge($todo,$merged); |
319 | 333 | |
320 | - if($sort) |
|
321 | - ksort($merged); |
|
334 | + if($sort) { |
|
335 | + ksort($merged); |
|
336 | + } |
|
322 | 337 | |
323 | - if($overwrite === false) |
|
324 | - $fileName.='.merged'; |
|
338 | + if($overwrite === false) { |
|
339 | + $fileName.='.merged'; |
|
340 | + } |
|
325 | 341 | |
326 | 342 | echo "translation merged.\n"; |
327 | - } |
|
328 | - else |
|
343 | + } else |
|
329 | 344 | { |
330 | 345 | $merged=array(); |
331 | - foreach($messages as $message) |
|
332 | - $merged[$message]=''; |
|
346 | + foreach($messages as $message) { |
|
347 | + $merged[$message]=''; |
|
348 | + } |
|
333 | 349 | |
334 | 350 | ksort($merged); |
335 | 351 | echo "saved.\n"; |
@@ -18,12 +18,14 @@ |
||
18 | 18 | * @license http://opensource.org/licenses/MIT MIT LICENSE |
19 | 19 | * @link https://github.com/charlesportwoodii/CiiMS |
20 | 20 | */ |
21 | -$import = function($default=false) { |
|
21 | +$import = function($default=false) |
|
22 | +{ |
|
22 | 23 | |
23 | 24 | $modules = (require __DIR__ . DS . 'modules.php'); |
24 | 25 | |
25 | - if ($default === true) |
|
26 | - return $modules; |
|
26 | + if ($default === true) { |
|
27 | + return $modules; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | $m = array( |
29 | 31 | 'application.models.*', |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | $cachedConfig = __DIR__.DS.'..'.DS.'runtime'.DS.'modules.config.php'; |
6 | 6 | |
7 | 7 | // Attempt to load the cached file if it exists |
8 | -if (file_exists($cachedConfig)) |
|
8 | +if (file_exists($cachedConfig)) { |
|
9 | 9 | return require($cachedConfig); |
10 | -else |
|
10 | +} else |
|
11 | 11 | { |
12 | 12 | // Otherwise generate one, and return it |
13 | 13 | $response = array(); |
@@ -20,10 +20,11 @@ discard block |
||
20 | 20 | { |
21 | 21 | $path = $filename->getPathname(); |
22 | 22 | |
23 | - if (file_exists($path.DS.'config'.DS.'main.php')) |
|
24 | - $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
25 | - else |
|
26 | - array_push($response, $filename->getFilename()); |
|
23 | + if (file_exists($path.DS.'config'.DS.'main.php')) { |
|
24 | + $response[$filename->getFilename()] = require($path.DS.'config'.DS.'main.php'); |
|
25 | + } else { |
|
26 | + array_push($response, $filename->getFilename()); |
|
27 | + } |
|
27 | 28 | } |
28 | 29 | } |
29 | 30 |
@@ -1,16 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class CategoriesController extends CiiController |
|
4 | -{ |
|
3 | +class CategoriesController extends CiiController |
|
4 | +{ |
|
5 | 5 | /** |
6 | 6 | * Base filter, allows logged in and non-logged in users to cache the page |
7 | 7 | */ |
8 | - public function filters() |
|
9 | - { |
|
8 | + public function filters() |
|
9 | + { |
|
10 | 10 | $id = Yii::app()->getRequest()->getQuery('id'); |
11 | 11 | |
12 | - if ($id == NULL || $id === false) |
|
13 | - throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing')); |
|
12 | + if ($id == NULL || $id === false) { |
|
13 | + throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing')); |
|
14 | + } |
|
14 | 15 | |
15 | 16 | return CMap::mergeArray(parent::filters(), array( |
16 | 17 | array( |
@@ -47,8 +48,8 @@ discard block |
||
47 | 48 | * Shows all blog posts for a particular category_id |
48 | 49 | * @param $id - The content ID that we want to pull from the database |
49 | 50 | **/ |
50 | - public function actionIndex($id=NULL) |
|
51 | - { |
|
51 | + public function actionIndex($id=NULL) |
|
52 | + { |
|
52 | 53 | // Run a pre check of our data |
53 | 54 | $this->beforeCiiAction($id); |
54 | 55 | |
@@ -100,8 +101,8 @@ discard block |
||
100 | 101 | * So that RSS Readers can access the website |
101 | 102 | * @param int $id |
102 | 103 | */ |
103 | - public function actionRss($id=NULL) |
|
104 | - { |
|
104 | + public function actionRss($id=NULL) |
|
105 | + { |
|
105 | 106 | Yii::app()->log->routes[0]->enabled = false; |
106 | 107 | ob_end_clean(); |
107 | 108 | header('Content-type: text/xml; charset=utf-8'); |
@@ -112,8 +113,9 @@ discard block |
||
112 | 113 | ->addCondition('type_id >= 2') |
113 | 114 | ->addCondition('password = ""'); |
114 | 115 | |
115 | - if ($id !== NULL) |
|
116 | - $criteria->addCondition("category_id = " . $id); |
|
116 | + if ($id !== NULL) { |
|
117 | + $criteria->addCondition("category_id = " . $id); |
|
118 | + } |
|
117 | 119 | |
118 | 120 | $criteria->order = 'created DESC'; |
119 | 121 | $data = Content::model()->findAll($criteria); |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -class ContentController extends CiiController |
|
4 | -{ |
|
3 | +class ContentController extends CiiController |
|
4 | +{ |
|
5 | 5 | /** |
6 | 6 | * Base filter, allows logged in and non-logged in users to cache the page |
7 | 7 | */ |
8 | - public function filters() |
|
9 | - { |
|
8 | + public function filters() |
|
9 | + { |
|
10 | 10 | $id = Yii::app()->getRequest()->getQuery('id'); |
11 | 11 | |
12 | 12 | if ($id != NULL) |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * This method is used by the 'accessControl' filter. |
48 | 48 | * @return array access control rules |
49 | 49 | */ |
50 | - public function accessRules() |
|
51 | - { |
|
50 | + public function accessRules() |
|
51 | + { |
|
52 | 52 | return array( |
53 | 53 | array('allow', // Allow all users to any section |
54 | 54 | 'actions' => array('index', 'password', 'list'), |
@@ -65,16 +65,17 @@ discard block |
||
65 | 65 | * Requests come in, are verified, and then pulled from the database dynamically |
66 | 66 | * @param $id - The content ID that we want to pull from the database |
67 | 67 | **/ |
68 | - public function actionIndex($id=NULL, $vid=NULL) |
|
69 | - { |
|
68 | + public function actionIndex($id=NULL, $vid=NULL) |
|
69 | + { |
|
70 | 70 | // Set the ReturnURL to this page so that the user can be redirected back to here after login |
71 | 71 | Yii::app()->user->setReturnUrl($this->beforeCiiAction($id)); |
72 | 72 | |
73 | 73 | // Retrieve the data |
74 | 74 | $content = Content::model()->findByPk($id); |
75 | 75 | |
76 | - if ($content->status != 1 || !$content->isPublished()) |
|
77 | - throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.')); |
|
76 | + if ($content->status != 1 || !$content->isPublished()) { |
|
77 | + throw new CHttpException(404, Yii::t('ciims.controllers.Content', 'The article you specified does not exist. If you bookmarked this page, please delete it.')); |
|
78 | + } |
|
78 | 79 | |
79 | 80 | // Check for a password |
80 | 81 | if (!empty($content->password)) |
@@ -82,8 +83,9 @@ discard block |
||
82 | 83 | // Check SESSION to see if a password is set |
83 | 84 | $tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL); |
84 | 85 | |
85 | - if ($tmpPassword != $content->password) |
|
86 | - $this->redirect(Yii::app()->createUrl('/content/password/' . $id)); |
|
86 | + if ($tmpPassword != $content->password) { |
|
87 | + $this->redirect(Yii::app()->createUrl('/content/password/' . $id)); |
|
88 | + } |
|
87 | 89 | } |
88 | 90 | |
89 | 91 | // Parse Metadata |
@@ -106,19 +108,21 @@ discard block |
||
106 | 108 | * Forces a password to be assigned before the user can proceed to the previous page |
107 | 109 | * @param $id - ID of the content we want to investigate |
108 | 110 | **/ |
109 | - public function actionPassword($id=NULL) |
|
110 | - { |
|
111 | + public function actionPassword($id=NULL) |
|
112 | + { |
|
111 | 113 | $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array( |
112 | 114 | '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
113 | 115 | '{{label}}' => Yii::t('ciims.controllers.Content', 'Password Required') |
114 | 116 | ))); |
115 | 117 | |
116 | - if ($id == NULL) |
|
117 | - $this->redirect(Yii::app()->user->returnUrl); |
|
118 | + if ($id == NULL) { |
|
119 | + $this->redirect(Yii::app()->user->returnUrl); |
|
120 | + } |
|
118 | 121 | |
119 | 122 | // Set some default data |
120 | - if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL) |
|
121 | - $_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300); |
|
123 | + if (Cii::get(Cii::get($_SESSION, 'password', array()), $id, NULL) == NULL) { |
|
124 | + $_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300); |
|
125 | + } |
|
122 | 126 | |
123 | 127 | // If the number of attempts is >= 3 |
124 | 128 | if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3) |
@@ -127,8 +131,7 @@ discard block |
||
127 | 131 | if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time()) |
128 | 132 | { |
129 | 133 | $_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300); |
130 | - } |
|
131 | - else |
|
134 | + } else |
|
132 | 135 | { |
133 | 136 | // Otherwise prevent access to it |
134 | 137 | Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes')); |
@@ -148,8 +151,7 @@ discard block |
||
148 | 151 | $_SESSION['password'][$id]['password'] = $encrypted; |
149 | 152 | $_SESSION['password'][$id]['tries'] = 0; |
150 | 153 | $this->redirect(Yii::app()->createUrl($content->attributes['slug'])); |
151 | - } |
|
152 | - else |
|
154 | + } else |
|
153 | 155 | { |
154 | 156 | Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password')); |
155 | 157 | $_SESSION['password'][$id]['tries'] = $_SESSION['password'][$id]['tries'] + 1; |
@@ -168,8 +170,8 @@ discard block |
||
168 | 170 | * Displays a listing of all blog posts for all time in all categories |
169 | 171 | * Is used as a generic catch all behavior |
170 | 172 | */ |
171 | - public function actionList() |
|
172 | - { |
|
173 | + public function actionList() |
|
174 | + { |
|
173 | 175 | $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array( |
174 | 176 | '{{app_name}}' => Cii::getConfig('name', Yii::app()->name), |
175 | 177 | '{{label}}' => Yii::t('ciims.controllers.Content', 'All Content') |
@@ -206,8 +208,8 @@ discard block |
||
206 | 208 | /** |
207 | 209 | * No routing action |
208 | 210 | */ |
209 | - public function actionNR() |
|
210 | - { |
|
211 | + public function actionNR() |
|
212 | + { |
|
211 | 213 | $themeName = Cii::getConfig('theme', 'default'); |
212 | 214 | if (file_exists(Yii::getPathOfAlias('webroot.themes.') . DS . $themeName . DS . 'Theme.php')) |
213 | 215 | { |
@@ -215,9 +217,10 @@ discard block |
||
215 | 217 | $theme = new Theme; |
216 | 218 | } |
217 | 219 | |
218 | - if ($theme->noRouting !== false) |
|
219 | - $this->render('index'); |
|
220 | - else |
|
221 | - throw new CHttpException(404); |
|
220 | + if ($theme->noRouting !== false) { |
|
221 | + $this->render('index'); |
|
222 | + } else { |
|
223 | + throw new CHttpException(404); |
|
224 | + } |
|
222 | 225 | } |
223 | 226 | } |
@@ -47,24 +47,27 @@ discard block |
||
47 | 47 | public function actionIndex($id=NULL, $username=NULL) |
48 | 48 | { |
49 | 49 | // If an ID isn't provided, throw an error |
50 | - if ($id === NULL) |
|
51 | - throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!")); |
|
50 | + if ($id === NULL) { |
|
51 | + throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!")); |
|
52 | + } |
|
52 | 53 | |
53 | 54 | // For SEO, if the display name isn't in the url, reroute it |
54 | 55 | if ($id !== NULL && $username === NULL) |
55 | 56 | { |
56 | 57 | $model = Users::model()->findByPk($id); |
57 | - if ($model === NULL || $model->status == 0) |
|
58 | - throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!")); |
|
59 | - else |
|
60 | - $this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\da-z]/i', '', $model->username)); |
|
58 | + if ($model === NULL || $model->status == 0) { |
|
59 | + throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!")); |
|
60 | + } else { |
|
61 | + $this->redirect('/profile/' . $model->id . '/' . preg_replace('/[^\da-z]/i', '', $model->username)); |
|
62 | + } |
|
61 | 63 | } |
62 | 64 | |
63 | 65 | $model = Users::model()->findByPk($id); |
64 | 66 | |
65 | 67 | // Don't allow null signings or invalidated users to pollute our site |
66 | - if($model->status == 0) |
|
67 | - throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!")); |
|
68 | + if($model->status == 0) { |
|
69 | + throw new CHttpException(404, Yii::t('ciims.controllers.Profile', "Oops! That user doesn't exist on our network!")); |
|
70 | + } |
|
68 | 71 | |
69 | 72 | $this->pageTitle = Yii::t('ciims.controllers.Profile', 'User {{user}} - CiiMS | {{sitename}}', array('{{user}}' => $model->name, '{{sitename}}' => Cii::getConfig('name', Yii::app()->name))); |
70 | 73 | $this->render('index', array( |
@@ -93,9 +96,9 @@ discard block |
||
93 | 96 | 'id' => $model->id, |
94 | 97 | 'username' => $model->username |
95 | 98 | ))); |
99 | + } else { |
|
100 | + Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There were errors saving your profile. Please correct them before trying to save again.')); |
|
96 | 101 | } |
97 | - else |
|
98 | - Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There were errors saving your profile. Please correct them before trying to save again.')); |
|
99 | 102 | } |
100 | 103 | |
101 | 104 | $this->render('edit', array( |
@@ -113,15 +116,17 @@ discard block |
||
113 | 116 | |
114 | 117 | // If we don't have one on file, then someone the user got to a page they shouldn't have gotten to |
115 | 118 | // Seamlessly redirect them back |
116 | - if ($model->getNewEmail() == NULL) |
|
117 | - $this->redirect(Yii::app()->user->returnUrl); |
|
119 | + if ($model->getNewEmail() == NULL) { |
|
120 | + $this->redirect(Yii::app()->user->returnUrl); |
|
121 | + } |
|
118 | 122 | |
119 | - if ($model->sendVerificationEmail()) |
|
120 | - Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'A new verification email has been resent to {{user}}. Please check your email address.', array( |
|
123 | + if ($model->sendVerificationEmail()) { |
|
124 | + Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'A new verification email has been resent to {{user}}. Please check your email address.', array( |
|
121 | 125 | '{{user}}' => $model->getNewEmail() |
122 | 126 | ))); |
123 | - else |
|
124 | - Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There was an error resending the verification email. Please try again later.')); |
|
127 | + } else { |
|
128 | + Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Profile', 'There was an error resending the verification email. Please try again later.')); |
|
129 | + } |
|
125 | 130 | |
126 | 131 | $this->redirect($this->createUrl('profile/edit')); |
127 | 132 | } |
@@ -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; |