Completed
Push — master ( bf7fd9...9d2e77 )
by Charles
06:57
created
protected/config/install.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -1,62 +1,62 @@
 block discarded – undo
1 1
 <?php return array(
2
-	'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
3
-	'name' => 'CiiMS Installer',
4
-	'preload' => array(
5
-		'cii'
6
-	),
7
-	'import' => array(
8
-		'application.components.*',
9
-		'application.modules.install.*'
10
-	),
11
-	'modules' => array(
12
-		'install'
13
-	),
14
-	'components' => array(
15
-		'cii' => array(
16
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
17
-		),
18
-		'errorHandler' => array(
19
-			'errorAction' => '/install/default/error',
20
-		),
21
-		'session' => array(
22
-			'autoStart' => true,
23
-			'sessionName'   => 'CiiMS_Installer',
24
-			'cookieMode'    => 'only',
25
-		),
26
-		'cache' => array(
27
-			'class' => 'CFileCache'
28
-		),
29
-		'urlManager' => array(
30
-			'urlFormat' => 'path',
31
-			'showScriptName' => false,
32
-			'rules' => array(
33
-				'' => '/install/default/index',
34
-				'/migrate' => '/install/default/migrate',
35
-				'/runmigrations' => '/install/default/runmigrations',
36
-				'/createadmin' => '/install/default/createadmin',
37
-				'/admin' => '/install/default/admin'
38
-			),
39
-		),
40
-		'log' => array(
41
-			'class' => 'CLogRouter',
42
-			'routes' => array(
43
-				array(
44
-					'class' => 'CWebLogRoute',
45
-					'levels' => 'error, warning, trace, info',
46
-					'enabled' => true
47
-				),
48
-				array(
49
-					'class'=>'CProfileLogRoute',
50
-					'report'=>'summary',
51
-					'enabled' => true
52
-				)
53
-			)
54
-		),
55
-	),
56
-	'params' => array(
57
-		'stage' => 0,
58
-		'debug' => true,
59
-		'trace' => 3
60
-	),
2
+    'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
3
+    'name' => 'CiiMS Installer',
4
+    'preload' => array(
5
+        'cii'
6
+    ),
7
+    'import' => array(
8
+        'application.components.*',
9
+        'application.modules.install.*'
10
+    ),
11
+    'modules' => array(
12
+        'install'
13
+    ),
14
+    'components' => array(
15
+        'cii' => array(
16
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
17
+        ),
18
+        'errorHandler' => array(
19
+            'errorAction' => '/install/default/error',
20
+        ),
21
+        'session' => array(
22
+            'autoStart' => true,
23
+            'sessionName'   => 'CiiMS_Installer',
24
+            'cookieMode'    => 'only',
25
+        ),
26
+        'cache' => array(
27
+            'class' => 'CFileCache'
28
+        ),
29
+        'urlManager' => array(
30
+            'urlFormat' => 'path',
31
+            'showScriptName' => false,
32
+            'rules' => array(
33
+                '' => '/install/default/index',
34
+                '/migrate' => '/install/default/migrate',
35
+                '/runmigrations' => '/install/default/runmigrations',
36
+                '/createadmin' => '/install/default/createadmin',
37
+                '/admin' => '/install/default/admin'
38
+            ),
39
+        ),
40
+        'log' => array(
41
+            'class' => 'CLogRouter',
42
+            'routes' => array(
43
+                array(
44
+                    'class' => 'CWebLogRoute',
45
+                    'levels' => 'error, warning, trace, info',
46
+                    'enabled' => true
47
+                ),
48
+                array(
49
+                    'class'=>'CProfileLogRoute',
50
+                    'report'=>'summary',
51
+                    'enabled' => true
52
+                )
53
+            )
54
+        ),
55
+    ),
56
+    'params' => array(
57
+        'stage' => 0,
58
+        'debug' => true,
59
+        'trace' => 3
60
+    ),
61 61
 );
62 62
 
Please login to merge, or discard this patch.
protected/config/main.default.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -20,145 +20,145 @@
 block discarded – undo
20 20
 */
21 21
 $import = function($default=false) {
22 22
 
23
-	$modules = (require __DIR__ . DS . 'modules.php');
23
+    $modules = (require __DIR__ . DS . 'modules.php');
24 24
 
25
-	if ($default === true)
26
-		return $modules;
25
+    if ($default === true)
26
+        return $modules;
27 27
 
28
-	$m = array(
29
-		'application.models.*',
30
-		'application.models.forms.*',
31
-		'application.models.settings.*'
32
-	);
28
+    $m = array(
29
+        'application.models.*',
30
+        'application.models.forms.*',
31
+        'application.models.settings.*'
32
+    );
33 33
 
34
-	foreach ($modules as $k=>$v) {
35
-		$m[] = 'application.modules.'.$v.'.*';
36
-	}
34
+    foreach ($modules as $k=>$v) {
35
+        $m[] = 'application.modules.'.$v.'.*';
36
+    }
37 37
 
38
-	return $m;
38
+    return $m;
39 39
 };
40 40
 
41 41
 $ciimsCoreConfig = array(
42
-	'basePath' => __DIR__.DS.'..',
43
-	'name' => NULL,
44
-	'sourceLanguage' => 'en_US',
45
-	'preload' => array(
46
-		'cii',
47
-		'analytics'
48
-	),
49
-	'import' => $import(),
50
-	'modules' => $import(true),
51
-	'behaviors' => array(
52
-		'onBeginRequest' => array(
53
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior',
54
-		),
55
-	),
56
-	'components' => array(
57
-		'themeManager' => array(
58
-			'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes')
59
-		),
60
-		'messages' => array(
61
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource'
62
-		),
63
-			'newRelic' => array(
64
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.YiiNewRelic',
65
-			'setAppNameToYiiName' => false
66
-		),
67
-		'cii' => array(
68
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
69
-		),
70
-		'analytics' => array(
71
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiAnalytics',
72
-			'lowerBounceRate' => true,
73
-			'options' => array(),
74
-		),
75
-		'assetManager' => array(
76
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiAssetManager',
77
-		),
78
-		'clientScript' => array(
79
-			'class' => 'vendor.charlesportwoodii.cii.components.CiiClientScript',
80
-		),
81
-		'errorHandler' => array(
82
-			'errorAction' => 'site/error',
83
-		),
84
-		'session' => array(
85
-			'autoStart'     => true,
86
-			'sessionName'   => '_ciims',
87
-			'cookieMode'    => 'only',
88
-			'cookieParams'  => array(
89
-				'httponly' => true,
90
-				'secure' => (
91
-					(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || 
92
-					(!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || 
93
-					(!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
94
-				)
95
-			)
96
-		),
97
-		'urlManager' => array(
98
-			'class'          => 'vendor.charlesportwoodii.cii.components.CiiURLManager',
99
-			'urlFormat'      => 'path',
100
-			'showScriptName' => false
101
-		),
102
-		'user' => array(
103
-			'authTimeout'    		=> 900,
104
-			'absoluteAuthTimeout' 	=> 1900,
105
-			'autoRenewCookie' 		=> true
106
-		),
107
-		'db' => array(
108
-			'class'                 => 'CDbConnection',
109
-			'connectionString'      => NULL,
110
-			'emulatePrepare'        => true,
111
-			'username'              => NULL,
112
-			'password'              => NULL,
113
-			'charset'               => 'utf8',
114
-			'schemaCachingDuration' => 3600,
115
-			'enableProfiling'       => false,
116
-			'enableParamLogging'    => false
117
-		),
118
-		'log' => array(
119
-			'class' => 'CLogRouter',
120
-			'routes' => array(
121
-				array(
122
-					'class'=>'CFileLogRoute',
123
-					'levels'=>'error, warning',
124
-				)
125
-			)
126
-		),
127
-		'cache' => array(
128
-			'class' => 'CFileCache',
129
-		)
130
-	),
131
-	'params' => array(
132
-		'encryptionKey'       => NULL,
133
-		'debug'               => false,
134
-		'trace'               => 0,
135
-		'NewRelicAppName'     => null,
136
-		'max_fileupload_size' => (10 * 1024 * 1024),
137
-		'cards' => 'https://cards.ciims.io/1.0.0',
138
-	)
42
+    'basePath' => __DIR__.DS.'..',
43
+    'name' => NULL,
44
+    'sourceLanguage' => 'en_US',
45
+    'preload' => array(
46
+        'cii',
47
+        'analytics'
48
+    ),
49
+    'import' => $import(),
50
+    'modules' => $import(true),
51
+    'behaviors' => array(
52
+        'onBeginRequest' => array(
53
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior',
54
+        ),
55
+    ),
56
+    'components' => array(
57
+        'themeManager' => array(
58
+            'basePath' => (__DIR__ . DS . '..' . DS . '..' . DS . 'themes')
59
+        ),
60
+        'messages' => array(
61
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiPHPMessageSource'
62
+        ),
63
+            'newRelic' => array(
64
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.YiiNewRelic',
65
+            'setAppNameToYiiName' => false
66
+        ),
67
+        'cii' => array(
68
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiBase'
69
+        ),
70
+        'analytics' => array(
71
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiAnalytics',
72
+            'lowerBounceRate' => true,
73
+            'options' => array(),
74
+        ),
75
+        'assetManager' => array(
76
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiAssetManager',
77
+        ),
78
+        'clientScript' => array(
79
+            'class' => 'vendor.charlesportwoodii.cii.components.CiiClientScript',
80
+        ),
81
+        'errorHandler' => array(
82
+            'errorAction' => 'site/error',
83
+        ),
84
+        'session' => array(
85
+            'autoStart'     => true,
86
+            'sessionName'   => '_ciims',
87
+            'cookieMode'    => 'only',
88
+            'cookieParams'  => array(
89
+                'httponly' => true,
90
+                'secure' => (
91
+                    (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || 
92
+                    (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) || 
93
+                    (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
94
+                )
95
+            )
96
+        ),
97
+        'urlManager' => array(
98
+            'class'          => 'vendor.charlesportwoodii.cii.components.CiiURLManager',
99
+            'urlFormat'      => 'path',
100
+            'showScriptName' => false
101
+        ),
102
+        'user' => array(
103
+            'authTimeout'    		=> 900,
104
+            'absoluteAuthTimeout' 	=> 1900,
105
+            'autoRenewCookie' 		=> true
106
+        ),
107
+        'db' => array(
108
+            'class'                 => 'CDbConnection',
109
+            'connectionString'      => NULL,
110
+            'emulatePrepare'        => true,
111
+            'username'              => NULL,
112
+            'password'              => NULL,
113
+            'charset'               => 'utf8',
114
+            'schemaCachingDuration' => 3600,
115
+            'enableProfiling'       => false,
116
+            'enableParamLogging'    => false
117
+        ),
118
+        'log' => array(
119
+            'class' => 'CLogRouter',
120
+            'routes' => array(
121
+                array(
122
+                    'class'=>'CFileLogRoute',
123
+                    'levels'=>'error, warning',
124
+                )
125
+            )
126
+        ),
127
+        'cache' => array(
128
+            'class' => 'CFileCache',
129
+        )
130
+    ),
131
+    'params' => array(
132
+        'encryptionKey'       => NULL,
133
+        'debug'               => false,
134
+        'trace'               => 0,
135
+        'NewRelicAppName'     => null,
136
+        'max_fileupload_size' => (10 * 1024 * 1024),
137
+        'cards' => 'https://cards.ciims.io/1.0.0',
138
+    )
139 139
 );
140 140
 
141 141
 // CLI specific data
142 142
 if (php_sapi_name() == "cli")
143 143
 {
144
-	$ciimsCoreConfig['behaviors'] = array(
145
-		'onBeginRequest' => array(
146
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
147
-		),
148
-		'onEndRequest' => array(
149
-			'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
150
-		)
151
-	);
144
+    $ciimsCoreConfig['behaviors'] = array(
145
+        'onBeginRequest' => array(
146
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
147
+        ),
148
+        'onEndRequest' => array(
149
+            'class' => 'vendor.charlesportwoodii.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior',
150
+        )
151
+    );
152 152
 }
153 153
 
154 154
 if (php_sapi_name() != "cli" && YII_DEBUG)
155 155
 {
156
-	$ciimsCoreConfig['preload'][] = 'debug';
157
-	$ciimsCoreConfig['components']['debug'] = array(
158
-		'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug',
159
-		'enabled' => YII_DEBUG,
160
-		'allowedIPs' => array('*')
161
-	);
156
+    $ciimsCoreConfig['preload'][] = 'debug';
157
+    $ciimsCoreConfig['components']['debug'] = array(
158
+        'class' => 'vendor.zhuravljov.yii2-debug.Yii2Debug',
159
+        'enabled' => YII_DEBUG,
160
+        'allowedIPs' => array('*')
161
+    );
162 162
 }
163 163
 
164 164
 return $ciimsCoreConfig;
Please login to merge, or discard this patch.
protected/config/modules.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 // Attempt to load the cached file if it exists
8 8
 if (file_exists($cachedConfig))
9
-	return require($cachedConfig);
9
+    return require($cachedConfig);
10 10
 else
11 11
 {
12
-	// Otherwise generate one, and return it
13
-	$response = array();
12
+    // Otherwise generate one, and return it
13
+    $response = array();
14 14
 
15
-	// Find all the modules currently installed, and preload them
16
-	foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename)
17
-	{
18
-		// Don't import dot files
19
-		if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false)
20
-		{
21
-			$path = $filename->getPathname();
15
+    // Find all the modules currently installed, and preload them
16
+    foreach (new IteratorIterator(new DirectoryIterator($directory)) as $filename)
17
+    {
18
+        // Don't import dot files
19
+        if (!$filename->isDot() && strpos($filename->getFileName(), ".") === false)
20
+        {
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());
27
-		}
28
-	}
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
+        }
28
+    }
29 29
 
30
-	$encoded = serialize($response);
31
-	file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');');
30
+    $encoded = serialize($response);
31
+    file_put_contents($cachedConfig, '<?php return unserialize(\''.$encoded.'\');');
32 32
 
33
-	// return the response
34
-	return $response;
33
+    // return the response
34
+    return $response;
35 35
 }
Please login to merge, or discard this patch.
protected/controllers/CategoriesController.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -2,126 +2,126 @@
 block discarded – undo
2 2
 
3 3
 class CategoriesController extends CiiController
4 4
 {
5
-	/**
6
-	 * Base filter, allows logged in and non-logged in users to cache the page
7
-	 */
8
-	public function filters()
9
-	{
10
-		$id = Yii::app()->getRequest()->getQuery('id');
11
-
12
-		if ($id == NULL || $id === false)
13
-			throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
14
-
15
-		return CMap::mergeArray(parent::filters(), array(
16
-			array(
17
-				'CHttpCacheFilter + index',
18
-				'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
19
-				'etagSeed'=>$id
20
-			),
21
-			array(
22
-				'COutputCache + list',
23
-				'duration' => YII_DEBUG ? 1 : 86400,
24
-				'varyByParam' => array('page'),
25
-				'varyByLanguage' => true,
26
-				'dependency' => array(
27
-					'class'=>'CDbCacheDependency',
28
-					'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
29
-					'params' => array(':id' => $id)
30
-				)
31
-			),
32
-			array(
33
-				'COutputCache + rss',
34
-				'duration' => YII_DEBUG ? 1 : 86400,
35
-				'dependency' => array(
36
-					'class'=>'CDbCacheDependency',
37
-					'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
38
-					'params' => array(':id' => $id)
39
-				)
40
-			)
41
-		));
42
-	}
43
-
44
-	/**
45
-	 * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
46
-	 * Requests come in, are verified, and then pulled from the database dynamically
47
-	 * Shows all blog posts for a particular category_id
48
-	 * @param $id	- The content ID that we want to pull from the database
49
-	 **/
50
-	public function actionIndex($id=NULL)
51
-	{
52
-		// Run a pre check of our data
53
-		$this->beforeCiiAction($id);
54
-
55
-		// Retrieve the data
56
-		$category = Categories::model()->findByPk($id);
57
-
58
-		// Set the layout
59
-		$this->setLayout('default');
60
-
61
-		$this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
62
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
63
-			'{{label}}'    => $category->name
64
-		)));
65
-
66
-		$pageSize = Cii::getConfig('categoryPaginationSize', 10);
67
-
68
-		$criteria = Content::model()
69
-					->getBaseCriteria()
70
-					->addCondition('type_id >= 2')
71
-					->addCondition("category_id = " . $id)
72
-					->addCondition('password = ""');
73
-
74
-		$criteria->limit = $pageSize;
75
-		$criteria->order = 'created DESC';
76
-
77
-		$itemCount = Content::model()->count($criteria);
78
-		$pages=new CPagination($itemCount);
79
-		$pages->pageSize=$pageSize;
80
-
81
-
82
-		$criteria->offset = $criteria->limit*($pages->getCurrentPage());
83
-		$data = Content::model()->findAll($criteria);
84
-
85
-		$pages->applyLimit($criteria);
86
-
87
-		$this->render('index', array(
88
-			'id'		=> $id,
89
-			'category' 	=> $category,
90
-			'data' 		=> $data,
91
-			'itemCount' => $itemCount,
92
-			'pages' 	=> $pages,
93
-			'meta' 		=> array(
94
-				'description' => $category->getDescription()
95
-		)));
96
-	}
97
-
98
-	/**
99
-	 * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format
100
-	 * So that RSS Readers can access the website
101
-	 * @param  int $id
102
-	 */
103
-	public function actionRss($id=NULL)
104
-	{
105
-		Yii::app()->log->routes[0]->enabled = false;
106
-		ob_end_clean();
107
-		header('Content-type: text/xml; charset=utf-8');
108
-		$url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl;
109
-		$this->setLayout(null);
110
-		$criteria = Content::model()
111
-					->getBaseCriteria()
112
-					->addCondition('type_id >= 2')
113
-					->addCondition('password = ""');
114
-
115
-		if ($id !== NULL)
116
-			$criteria->addCondition("category_id = " . $id);
117
-
118
-		$criteria->order = 'created DESC';
119
-		$data = Content::model()->findAll($criteria);
120
-
121
-		$this->renderPartial('application.views.site/rss', array(
122
-			'data' 	=> $data, 
123
-			'url'	=> $url
124
-		));
125
-		return;
126
-	}
5
+    /**
6
+     * Base filter, allows logged in and non-logged in users to cache the page
7
+     */
8
+    public function filters()
9
+    {
10
+        $id = Yii::app()->getRequest()->getQuery('id');
11
+
12
+        if ($id == NULL || $id === false)
13
+            throw new CHttpException(400, Yii::t('ciims.controllers.Categories', 'Invalid routing'));
14
+
15
+        return CMap::mergeArray(parent::filters(), array(
16
+            array(
17
+                'CHttpCacheFilter + index',
18
+                'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
19
+                'etagSeed'=>$id
20
+            ),
21
+            array(
22
+                'COutputCache + list',
23
+                'duration' => YII_DEBUG ? 1 : 86400,
24
+                'varyByParam' => array('page'),
25
+                'varyByLanguage' => true,
26
+                'dependency' => array(
27
+                    'class'=>'CDbCacheDependency',
28
+                    'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
29
+                    'params' => array(':id' => $id)
30
+                )
31
+            ),
32
+            array(
33
+                'COutputCache + rss',
34
+                'duration' => YII_DEBUG ? 1 : 86400,
35
+                'dependency' => array(
36
+                    'class'=>'CDbCacheDependency',
37
+                    'sql'=>'SELECT MAX(updated) FROM content WHERE category_id = :id',
38
+                    'params' => array(':id' => $id)
39
+                )
40
+            )
41
+        ));
42
+    }
43
+
44
+    /**
45
+     * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
46
+     * Requests come in, are verified, and then pulled from the database dynamically
47
+     * Shows all blog posts for a particular category_id
48
+     * @param $id	- The content ID that we want to pull from the database
49
+     **/
50
+    public function actionIndex($id=NULL)
51
+    {
52
+        // Run a pre check of our data
53
+        $this->beforeCiiAction($id);
54
+
55
+        // Retrieve the data
56
+        $category = Categories::model()->findByPk($id);
57
+
58
+        // Set the layout
59
+        $this->setLayout('default');
60
+
61
+        $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array(
62
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
63
+            '{{label}}'    => $category->name
64
+        )));
65
+
66
+        $pageSize = Cii::getConfig('categoryPaginationSize', 10);
67
+
68
+        $criteria = Content::model()
69
+                    ->getBaseCriteria()
70
+                    ->addCondition('type_id >= 2')
71
+                    ->addCondition("category_id = " . $id)
72
+                    ->addCondition('password = ""');
73
+
74
+        $criteria->limit = $pageSize;
75
+        $criteria->order = 'created DESC';
76
+
77
+        $itemCount = Content::model()->count($criteria);
78
+        $pages=new CPagination($itemCount);
79
+        $pages->pageSize=$pageSize;
80
+
81
+
82
+        $criteria->offset = $criteria->limit*($pages->getCurrentPage());
83
+        $data = Content::model()->findAll($criteria);
84
+
85
+        $pages->applyLimit($criteria);
86
+
87
+        $this->render('index', array(
88
+            'id'		=> $id,
89
+            'category' 	=> $category,
90
+            'data' 		=> $data,
91
+            'itemCount' => $itemCount,
92
+            'pages' 	=> $pages,
93
+            'meta' 		=> array(
94
+                'description' => $category->getDescription()
95
+        )));
96
+    }
97
+
98
+    /**
99
+     * Displays either all posts or all posts for a particular category_id if an $id is set in RSS Format
100
+     * So that RSS Readers can access the website
101
+     * @param  int $id
102
+     */
103
+    public function actionRss($id=NULL)
104
+    {
105
+        Yii::app()->log->routes[0]->enabled = false;
106
+        ob_end_clean();
107
+        header('Content-type: text/xml; charset=utf-8');
108
+        $url = 'http://'.Yii::app()->request->serverName . Yii::app()->baseUrl;
109
+        $this->setLayout(null);
110
+        $criteria = Content::model()
111
+                    ->getBaseCriteria()
112
+                    ->addCondition('type_id >= 2')
113
+                    ->addCondition('password = ""');
114
+
115
+        if ($id !== NULL)
116
+            $criteria->addCondition("category_id = " . $id);
117
+
118
+        $criteria->order = 'created DESC';
119
+        $data = Content::model()->findAll($criteria);
120
+
121
+        $this->renderPartial('application.views.site/rss', array(
122
+            'data' 	=> $data, 
123
+            'url'	=> $url
124
+        ));
125
+        return;
126
+    }
127 127
 }
Please login to merge, or discard this patch.
protected/controllers/ContentController.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -2,212 +2,212 @@  discard block
 block discarded – undo
2 2
 
3 3
 class ContentController extends CiiController
4 4
 {
5
-	/**
6
-	 * Base filter, allows logged in and non-logged in users to cache the page
7
-	 */
8
-	public function filters()
9
-	{
10
-		$id = Yii::app()->getRequest()->getQuery('id');
11
-
12
-		if ($id != NULL)
13
-		{
14
-			$vid =  Yii::app()->getRequest()->getQuery('vid');
15
-			return array(
16
-				'accessControl',
17
-				array(
18
-					'CHttpCacheFilter + index',
19
-					'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
20
-					'etagSeed' => $id.$vid
21
-				),
22
-				array(
23
-					'COutputCache + index',
24
-					'duration' => YII_DEBUG ? 1 : 86400, // 24 hour cache duration
25
-					'varyByParam' => array('id', 'vid'),
26
-					'varyByLanguage' => true,
27
-					'varyByExpression' => 'Yii::app()->user->isGuest'
28
-				)
29
-			);
30
-		}
31
-
32
-		return CMap::mergeArray(parent::filters(), array(array(
33
-			'COutputCache + list',
34
-			'duration' => YII_DEBUG ? 1 : 86400,
35
-			'varyByParam' => array('page'),
36
-			'varyByLanguage' => true,
37
-			'dependency' => array(
38
-				'class'=>'CDbCacheDependency',
39
-				'sql'=>'SELECT MAX(updated) FROM content',
40
-			)
41
-		)));
42
-	}
43
-
44
-
45
-	/**
46
-	 * Specifies the access control rules.
47
-	 * This method is used by the 'accessControl' filter.
48
-	 * @return array access control rules
49
-	 */
50
-	public function accessRules()
51
-	{
52
-		return array(
53
-			array('allow',  // Allow all users to any section
54
-				'actions' => array('index', 'password', 'list'),
55
-				'users'=>array('*'),
56
-			),
57
-			array('deny',  // deny all users
58
-				'users'=>array('*'),
59
-			),
60
-		);
61
-	}
62
-
63
-	/**
64
-	 * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
65
-	 * Requests come in, are verified, and then pulled from the database dynamically
66
-	 * @param $id	- The content ID that we want to pull from the database
67
-	 **/
68
-	public function actionIndex($id=NULL, $vid=NULL)
69
-	{
70
-		// Set the ReturnURL to this page so that the user can be redirected back to here after login
71
-		Yii::app()->user->setReturnUrl($this->beforeCiiAction($id));
72
-
73
-		// Retrieve the data
74
-		$content = Content::model()->findByPk($id);
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.'));
78
-
79
-		// Check for a password
80
-		if (!empty($content->password))
81
-		{
82
-			// Check SESSION to see if a password is set
83
-			$tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL);
84
-
85
-			if ($tmpPassword != $content->password)
86
-				$this->redirect(Yii::app()->createUrl('/content/password/' . $id));
87
-		}
88
-
89
-		// Parse Metadata
90
-		$this->setLayout($content->layout);
91
-
92
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
93
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
94
-			'{{label}}'    => $content->title
95
-		)));
96
-
97
-		$this->params['meta']['description'] = $content->extract;
98
-		$this->render($content->view, array(
99
-			'id' 	=> $content->id,
100
-			'data' 	=> $content,
101
-			'meta' 	=> $content->parseMeta($content->id)
102
-		));
103
-	}
104
-
105
-	/**
106
-	 * Forces a password to be assigned before the user can proceed to the previous page
107
-	 * @param $id - ID of the content we want to investigate
108
-	 **/
109
-	public function actionPassword($id=NULL)
110
-	{
111
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
113
-			'{{label}}'    => Yii::t('ciims.controllers.Content', 'Password Required')
114
-		)));
115
-
116
-		if ($id == NULL)
117
-			$this->redirect(Yii::app()->user->returnUrl);
118
-
119
-		// 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);
122
-
123
-		// If the number of attempts is >= 3
124
-		if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
125
-		{
126
-			// If the expires time has already passed, unlock the account
127
-			if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time())
128
-			{
129
-				$_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
130
-			}
131
-			else
132
-			{
133
-				// Otherwise prevent access to it
134
-				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
135
-				unset($_POST['password']);
136
-				$_SESSION['password'][$id]['expires'] 	= time() + 300;
137
-			}
138
-		}
139
-
140
-		if (Cii::get($_POST, 'password', NULL) !== NULL)
141
-		{
142
-			$content = Content::model()->findByPk($id);
143
-
144
-			$encrypted = Cii::encrypt(Cii::get($_POST, 'password'));
145
-
146
-			if ($encrypted == $content->attributes['password'])
147
-			{
148
-				$_SESSION['password'][$id]['password'] = $encrypted;
149
-				$_SESSION['password'][$id]['tries'] = 0;
150
-				$this->redirect(Yii::app()->createUrl($content->attributes['slug']));
151
-			}
152
-			else
153
-			{
154
-				Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
155
-				$_SESSION['password'][$id]['tries'] 	= $_SESSION['password'][$id]['tries'] + 1;
156
-				$_SESSION['password'][$id]['expires'] 	= time() + 300;
157
-			}
158
-
159
-		}
160
-
161
-		$this->layout = 'password';
162
-		$this->render('password', array(
163
-			'id' => $id
164
-		));
165
-	}
166
-
167
-	/*
168
-	 * Displays a listing of all blog posts for all time in all categories
169
-	 * Is used as a generic catch all behavior
170
-	 */
171
-	public function actionList()
172
-	{
173
-		$this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174
-			'{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
175
-			'{{label}}'    => Yii::t('ciims.controllers.Content', 'All Content')
176
-		)));
177
-
178
-		$this->setLayout('default');
179
-
180
-		$pageSize = Cii::getConfig('contentPaginationSize', 10);
5
+    /**
6
+     * Base filter, allows logged in and non-logged in users to cache the page
7
+     */
8
+    public function filters()
9
+    {
10
+        $id = Yii::app()->getRequest()->getQuery('id');
11
+
12
+        if ($id != NULL)
13
+        {
14
+            $vid =  Yii::app()->getRequest()->getQuery('vid');
15
+            return array(
16
+                'accessControl',
17
+                array(
18
+                    'CHttpCacheFilter + index',
19
+                    'cacheControl'=>Cii::get(Yii::app()->user->id) == NULL ? 'public' : 'private' .', no-cache, must-revalidate',
20
+                    'etagSeed' => $id.$vid
21
+                ),
22
+                array(
23
+                    'COutputCache + index',
24
+                    'duration' => YII_DEBUG ? 1 : 86400, // 24 hour cache duration
25
+                    'varyByParam' => array('id', 'vid'),
26
+                    'varyByLanguage' => true,
27
+                    'varyByExpression' => 'Yii::app()->user->isGuest'
28
+                )
29
+            );
30
+        }
181 31
 
182
-		$criteria = Content::model()
183
-					->getBaseCriteria()
184
-					->addCondition('type_id >= 2')
185
-					->addCondition('password = ""');
32
+        return CMap::mergeArray(parent::filters(), array(array(
33
+            'COutputCache + list',
34
+            'duration' => YII_DEBUG ? 1 : 86400,
35
+            'varyByParam' => array('page'),
36
+            'varyByLanguage' => true,
37
+            'dependency' => array(
38
+                'class'=>'CDbCacheDependency',
39
+                'sql'=>'SELECT MAX(updated) FROM content',
40
+            )
41
+        )));
42
+    }
43
+
44
+
45
+    /**
46
+     * Specifies the access control rules.
47
+     * This method is used by the 'accessControl' filter.
48
+     * @return array access control rules
49
+     */
50
+    public function accessRules()
51
+    {
52
+        return array(
53
+            array('allow',  // Allow all users to any section
54
+                'actions' => array('index', 'password', 'list'),
55
+                'users'=>array('*'),
56
+            ),
57
+            array('deny',  // deny all users
58
+                'users'=>array('*'),
59
+            ),
60
+        );
61
+    }
62
+
63
+    /**
64
+     * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
65
+     * Requests come in, are verified, and then pulled from the database dynamically
66
+     * @param $id	- The content ID that we want to pull from the database
67
+     **/
68
+    public function actionIndex($id=NULL, $vid=NULL)
69
+    {
70
+        // Set the ReturnURL to this page so that the user can be redirected back to here after login
71
+        Yii::app()->user->setReturnUrl($this->beforeCiiAction($id));
72
+
73
+        // Retrieve the data
74
+        $content = Content::model()->findByPk($id);
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.'));
78
+
79
+        // Check for a password
80
+        if (!empty($content->password))
81
+        {
82
+            // Check SESSION to see if a password is set
83
+            $tmpPassword = Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'password', NULL);
186 84
 
187
-		$criteria->order = 'published DESC';
85
+            if ($tmpPassword != $content->password)
86
+                $this->redirect(Yii::app()->createUrl('/content/password/' . $id));
87
+        }
188 88
 
189
-		$criteria->limit = $pageSize;
89
+        // Parse Metadata
90
+        $this->setLayout($content->layout);
91
+
92
+        $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
93
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
94
+            '{{label}}'    => $content->title
95
+        )));
96
+
97
+        $this->params['meta']['description'] = $content->extract;
98
+        $this->render($content->view, array(
99
+            'id' 	=> $content->id,
100
+            'data' 	=> $content,
101
+            'meta' 	=> $content->parseMeta($content->id)
102
+        ));
103
+    }
104
+
105
+    /**
106
+     * Forces a password to be assigned before the user can proceed to the previous page
107
+     * @param $id - ID of the content we want to investigate
108
+     **/
109
+    public function actionPassword($id=NULL)
110
+    {
111
+        $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
112
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
113
+            '{{label}}'    => Yii::t('ciims.controllers.Content', 'Password Required')
114
+        )));
115
+
116
+        if ($id == NULL)
117
+            $this->redirect(Yii::app()->user->returnUrl);
118
+
119
+        // 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);
122
+
123
+        // If the number of attempts is >= 3
124
+        if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'tries', 0) >= 3)
125
+        {
126
+            // If the expires time has already passed, unlock the account
127
+            if (Cii::get(Cii::get(Cii::get($_SESSION, 'password', array()), $id, array()), 'expires', 0) <= time())
128
+            {
129
+                $_SESSION['password'][$id] = array('tries'=>0, 'expires' => time() + 300);
130
+            }
131
+            else
132
+            {
133
+                // Otherwise prevent access to it
134
+                Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Too many password attempts. Please try again in 5 minutes'));
135
+                unset($_POST['password']);
136
+                $_SESSION['password'][$id]['expires'] 	= time() + 300;
137
+            }
138
+        }
190 139
 
191
-		$itemCount = Content::model()->count($criteria);
192
-		$pages = new CPagination($itemCount);
193
-		$pages->pageSize=$pageSize;
140
+        if (Cii::get($_POST, 'password', NULL) !== NULL)
141
+        {
142
+            $content = Content::model()->findByPk($id);
143
+
144
+            $encrypted = Cii::encrypt(Cii::get($_POST, 'password'));
145
+
146
+            if ($encrypted == $content->attributes['password'])
147
+            {
148
+                $_SESSION['password'][$id]['password'] = $encrypted;
149
+                $_SESSION['password'][$id]['tries'] = 0;
150
+                $this->redirect(Yii::app()->createUrl($content->attributes['slug']));
151
+            }
152
+            else
153
+            {
154
+                Yii::app()->user->setFlash('error', Yii::t('ciims.controllers.Content', 'Incorrect password'));
155
+                $_SESSION['password'][$id]['tries'] 	= $_SESSION['password'][$id]['tries'] + 1;
156
+                $_SESSION['password'][$id]['expires'] 	= time() + 300;
157
+            }
194 158
 
195
-		$criteria->offset = $criteria->limit*($pages->getCurrentPage());
196
-		$data = Content::model()->findAll($criteria);
197
-		$pages->applyLimit($criteria);
159
+        }
198 160
 
199
-		$this->render('all', array(
200
-			'data'		=> $data,
201
-			'itemCount' => $itemCount,
202
-			'pages' 	=> $pages
203
-		));
204
-	}
161
+        $this->layout = 'password';
162
+        $this->render('password', array(
163
+            'id' => $id
164
+        ));
165
+    }
205 166
 
206
-	/**
207
-	 * No routing action
167
+    /*
168
+	 * Displays a listing of all blog posts for all time in all categories
169
+	 * Is used as a generic catch all behavior
208 170
 	 */
209
-	public function actionNR()
210
-	{
171
+    public function actionList()
172
+    {
173
+        $this->setPageTitle(Yii::t('ciims.controllers.Content', '{{app_name}} | {{label}}', array(
174
+            '{{app_name}}' => Cii::getConfig('name', Yii::app()->name),
175
+            '{{label}}'    => Yii::t('ciims.controllers.Content', 'All Content')
176
+        )));
177
+
178
+        $this->setLayout('default');
179
+
180
+        $pageSize = Cii::getConfig('contentPaginationSize', 10);
181
+
182
+        $criteria = Content::model()
183
+                    ->getBaseCriteria()
184
+                    ->addCondition('type_id >= 2')
185
+                    ->addCondition('password = ""');
186
+
187
+        $criteria->order = 'published DESC';
188
+
189
+        $criteria->limit = $pageSize;
190
+
191
+        $itemCount = Content::model()->count($criteria);
192
+        $pages = new CPagination($itemCount);
193
+        $pages->pageSize=$pageSize;
194
+
195
+        $criteria->offset = $criteria->limit*($pages->getCurrentPage());
196
+        $data = Content::model()->findAll($criteria);
197
+        $pages->applyLimit($criteria);
198
+
199
+        $this->render('all', array(
200
+            'data'		=> $data,
201
+            'itemCount' => $itemCount,
202
+            'pages' 	=> $pages
203
+        ));
204
+    }
205
+
206
+    /**
207
+     * No routing action
208
+     */
209
+    public function actionNR()
210
+    {
211 211
         $themeName = Cii::getConfig('theme', 'default');
212 212
         if (file_exists(Yii::getPathOfAlias('webroot.themes.') . DS . $themeName .  DS . 'Theme.php'))
213 213
         {
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
             $theme = new Theme;
216 216
         }
217 217
 
218
-		if ($theme->noRouting !== false)
219
-			$this->render('index');
220
-		else
221
-			throw new CHttpException(404);
222
-	}
218
+        if ($theme->noRouting !== false)
219
+            $this->render('index');
220
+        else
221
+            throw new CHttpException(404);
222
+    }
223 223
 }
Please login to merge, or discard this patch.
protected/controllers/ProfileController.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -3,126 +3,126 @@
 block discarded – undo
3 3
 class ProfileController extends CiiController
4 4
 {
5 5
 
6
-	/**
7
-	 * The layout to use for this controller
8
-	 * @var string
9
-	 */
10
-	public $layout = '//layouts/main';
11
-
12
-	/**
13
-	 * @return array action filters
14
-	 */
15
-	public function filters()
16
-	{
17
-		return CMap::mergeArray(parent::filters(), array('accessControl'));
18
-	}
19
-
20
-	/**
21
-	 * Specifies the access control rules.
22
-	 * This method is used by the 'accessControl' filter.
23
-	 * @return array access control rules
24
-	 */
25
-	public function accessRules()
26
-	{
27
-		return array(
28
-			array('allow',  // Allow all users to any section
29
-				'actions' => array('index'),
30
-				'users'=>array('*'),
31
-			),
32
-			array('allow',  // deny all users
33
-				'actions' => array('edit', 'resend'),
34
-				'users'=>array('@'),
35
-			),
36
-			array('deny',  // deny all users
37
-				'users'=>array('*'),
38
-			),
39
-		);
40
-	}
41
-
42
-	/**
43
-	 * Provides functionality to view a given profile
44
-	 * @param  int 	  $id          The ID belonging to the user
45
-	 * @param  string $username    The user's display name. This isn't super necessary, it just is better for SEO
46
-	 */
47
-	public function actionIndex($id=NULL, $username=NULL)
48
-	{
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!"));
52
-
53
-		// For SEO, if the display name isn't in the url, reroute it
54
-		if ($id !== NULL && $username === NULL)
55
-		{
56
-			$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));
61
-		}
62
-
63
-		$model = Users::model()->findByPk($id);
64
-
65
-		// 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
-
69
-		$this->pageTitle = Yii::t('ciims.controllers.Profile', 'User {{user}} - CiiMS | {{sitename}}', array('{{user}}' => $model->name, '{{sitename}}' => Cii::getConfig('name', Yii::app()->name)));
70
-		$this->render('index', array(
71
-			'model' => $model,
72
-			'md' => new CMarkdownParser
73
-		));
74
-	}
75
-
76
-	/**
77
-	 * Provides functionality for a user to edit their profile
78
-	 */
79
-	public function actionEdit()
80
-	{
81
-		$model = new ProfileForm;
82
-		$model->load(Yii::app()->user->id);
83
-
84
-		if (Cii::get($_POST, 'ProfileForm', NULL) !== NULL)
85
-		{
86
-			$model->attributes = $_POST['ProfileForm'];
87
-			$model->password_repeat = $_POST['ProfileForm']['password_repeat'];
88
-
89
-			if ($model->save())
90
-			{
91
-				Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'Your profile has been updated!'));
92
-				$this->redirect($this->createUrl('profile/index', array(
93
-					'id' => $model->id,
94
-					'username' => $model->username
95
-				)));
96
-			}
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
-		}
100
-
101
-		$this->render('edit', array(
102
-			'model' => $model
103
-		));
104
-	}
105
-
106
-	/**
107
-	 * Send a new verification email to the user
108
-	 */
109
-	public function actionResend()
110
-	{
111
-		$model = new ProfileForm;
112
-		$model->load(Yii::app()->user->id);
113
-
114
-		// If we don't have one on file, then someone the user got to a page they shouldn't have gotten to
115
-		// Seamlessly redirect them back
116
-		if ($model->getNewEmail() == NULL)
117
-			$this->redirect(Yii::app()->user->returnUrl);
118
-
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(
121
-				'{{user}}' => $model->getNewEmail()
122
-			)));
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.'));
125
-
126
-		$this->redirect($this->createUrl('profile/edit'));
127
-	}
6
+    /**
7
+     * The layout to use for this controller
8
+     * @var string
9
+     */
10
+    public $layout = '//layouts/main';
11
+
12
+    /**
13
+     * @return array action filters
14
+     */
15
+    public function filters()
16
+    {
17
+        return CMap::mergeArray(parent::filters(), array('accessControl'));
18
+    }
19
+
20
+    /**
21
+     * Specifies the access control rules.
22
+     * This method is used by the 'accessControl' filter.
23
+     * @return array access control rules
24
+     */
25
+    public function accessRules()
26
+    {
27
+        return array(
28
+            array('allow',  // Allow all users to any section
29
+                'actions' => array('index'),
30
+                'users'=>array('*'),
31
+            ),
32
+            array('allow',  // deny all users
33
+                'actions' => array('edit', 'resend'),
34
+                'users'=>array('@'),
35
+            ),
36
+            array('deny',  // deny all users
37
+                'users'=>array('*'),
38
+            ),
39
+        );
40
+    }
41
+
42
+    /**
43
+     * Provides functionality to view a given profile
44
+     * @param  int 	  $id          The ID belonging to the user
45
+     * @param  string $username    The user's display name. This isn't super necessary, it just is better for SEO
46
+     */
47
+    public function actionIndex($id=NULL, $username=NULL)
48
+    {
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!"));
52
+
53
+        // For SEO, if the display name isn't in the url, reroute it
54
+        if ($id !== NULL && $username === NULL)
55
+        {
56
+            $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));
61
+        }
62
+
63
+        $model = Users::model()->findByPk($id);
64
+
65
+        // 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
+
69
+        $this->pageTitle = Yii::t('ciims.controllers.Profile', 'User {{user}} - CiiMS | {{sitename}}', array('{{user}}' => $model->name, '{{sitename}}' => Cii::getConfig('name', Yii::app()->name)));
70
+        $this->render('index', array(
71
+            'model' => $model,
72
+            'md' => new CMarkdownParser
73
+        ));
74
+    }
75
+
76
+    /**
77
+     * Provides functionality for a user to edit their profile
78
+     */
79
+    public function actionEdit()
80
+    {
81
+        $model = new ProfileForm;
82
+        $model->load(Yii::app()->user->id);
83
+
84
+        if (Cii::get($_POST, 'ProfileForm', NULL) !== NULL)
85
+        {
86
+            $model->attributes = $_POST['ProfileForm'];
87
+            $model->password_repeat = $_POST['ProfileForm']['password_repeat'];
88
+
89
+            if ($model->save())
90
+            {
91
+                Yii::app()->user->setFlash('success', Yii::t('ciims.controllers.Profile', 'Your profile has been updated!'));
92
+                $this->redirect($this->createUrl('profile/index', array(
93
+                    'id' => $model->id,
94
+                    'username' => $model->username
95
+                )));
96
+            }
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
+        }
100
+
101
+        $this->render('edit', array(
102
+            'model' => $model
103
+        ));
104
+    }
105
+
106
+    /**
107
+     * Send a new verification email to the user
108
+     */
109
+    public function actionResend()
110
+    {
111
+        $model = new ProfileForm;
112
+        $model->load(Yii::app()->user->id);
113
+
114
+        // If we don't have one on file, then someone the user got to a page they shouldn't have gotten to
115
+        // Seamlessly redirect them back
116
+        if ($model->getNewEmail() == NULL)
117
+            $this->redirect(Yii::app()->user->returnUrl);
118
+
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(
121
+                '{{user}}' => $model->getNewEmail()
122
+            )));
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.'));
125
+
126
+        $this->redirect($this->createUrl('profile/edit'));
127
+    }
128 128
 }
Please login to merge, or discard this patch.
protected/messages/en_us/ProfileForm.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Message translations.
4
- *
5
- * This file is automatically generated by 'yiic ciimessage' command.
6
- * It contains the localizable messages extracted from source code.
7
- * You may modify this file by translating the extracted messages.
8
- *
9
- * Each array element represents the translation (value) of a message (key).
10
- * If the value is empty, the message is considered as not translated.
11
- * Messages that no longer need translation will have their translations
12
- * enclosed between a pair of '@@' marks.
13
- *
14
- * Message string can be used with plural forms format. Check i18n section
15
- * of the guide for details.
16
- *
17
- * NOTE, this file must be saved in UTF-8 encoding.
18
- */
3
+     * Message translations.
4
+     *
5
+     * This file is automatically generated by 'yiic ciimessage' command.
6
+     * It contains the localizable messages extracted from source code.
7
+     * You may modify this file by translating the extracted messages.
8
+     *
9
+     * Each array element represents the translation (value) of a message (key).
10
+     * If the value is empty, the message is considered as not translated.
11
+     * Messages that no longer need translation will have their translations
12
+     * enclosed between a pair of '@@' marks.
13
+     *
14
+     * Message string can be used with plural forms format. Check i18n section
15
+     * of the guide for details.
16
+     *
17
+     * NOTE, this file must be saved in UTF-8 encoding.
18
+     */
19 19
 return array (
20
-  'Unable to save change key' => '',
20
+    'Unable to save change key' => '',
21 21
 );
Please login to merge, or discard this patch.
protected/messages/en_us/controllers/Categories.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Message translations.
4
- *
5
- * This file is automatically generated by 'yiic ciimessage' command.
6
- * It contains the localizable messages extracted from source code.
7
- * You may modify this file by translating the extracted messages.
8
- *
9
- * Each array element represents the translation (value) of a message (key).
10
- * If the value is empty, the message is considered as not translated.
11
- * Messages that no longer need translation will have their translations
12
- * enclosed between a pair of '@@' marks.
13
- *
14
- * Message string can be used with plural forms format. Check i18n section
15
- * of the guide for details.
16
- *
17
- * NOTE, this file must be saved in UTF-8 encoding.
18
- */
3
+     * Message translations.
4
+     *
5
+     * This file is automatically generated by 'yiic ciimessage' command.
6
+     * It contains the localizable messages extracted from source code.
7
+     * You may modify this file by translating the extracted messages.
8
+     *
9
+     * Each array element represents the translation (value) of a message (key).
10
+     * If the value is empty, the message is considered as not translated.
11
+     * Messages that no longer need translation will have their translations
12
+     * enclosed between a pair of '@@' marks.
13
+     *
14
+     * Message string can be used with plural forms format. Check i18n section
15
+     * of the guide for details.
16
+     *
17
+     * NOTE, this file must be saved in UTF-8 encoding.
18
+     */
19 19
 return array (
20
-  'Invalid routing' => '',
21
-  '{{app_name}} | {{label}}' => '',
20
+    'Invalid routing' => '',
21
+    '{{app_name}} | {{label}}' => '',
22 22
 );
Please login to merge, or discard this patch.
protected/messages/en_us/controllers/Cii.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Message translations.
4
- *
5
- * This file is automatically generated by 'yiic message' command.
6
- * It contains the localizable messages extracted from source code.
7
- * You may modify this file by translating the extracted messages.
8
- *
9
- * Each array element represents the translation (value) of a message (key).
10
- * If the value is empty, the message is considered as not translated.
11
- * Messages that no longer need translation will have their translations
12
- * enclosed between a pair of '@@' marks.
13
- *
14
- * Message string can be used with plural forms format. Check i18n section
15
- * of the guide for details.
16
- *
17
- * NOTE, this file must be saved in UTF-8 encoding.
18
- */
3
+     * Message translations.
4
+     *
5
+     * This file is automatically generated by 'yiic message' command.
6
+     * It contains the localizable messages extracted from source code.
7
+     * You may modify this file by translating the extracted messages.
8
+     *
9
+     * Each array element represents the translation (value) of a message (key).
10
+     * If the value is empty, the message is considered as not translated.
11
+     * Messages that no longer need translation will have their translations
12
+     * enclosed between a pair of '@@' marks.
13
+     *
14
+     * Message string can be used with plural forms format. Check i18n section
15
+     * of the guide for details.
16
+     *
17
+     * NOTE, this file must be saved in UTF-8 encoding.
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
 );
Please login to merge, or discard this patch.