13
13
App::import ('Lib ' , 'toolkit ' );
14
14
App::import ('Lib ' , 'breadcrumb ' );
15
15
16
+ /**
17
+ * _t
18
+ * because CakePHP 1.3's internationalization __() call is stupid and wants
19
+ * you to pass an extra parameter for no reason to get a string, use this
20
+ * instead.
21
+ *
22
+ * @param mixed $str
23
+ *
24
+ * @access public
25
+ * @return void
26
+ */
27
+ function _t ($ str ) {
28
+ return __ ($ str , true );
29
+ }
30
+
16
31
/**
17
32
* AppController the base controller
18
33
*
@@ -30,6 +45,7 @@ class AppController extends Controller
30
45
public $ access = array ();
31
46
public $ actionList = array ();
32
47
public $ breadcrumb ;
48
+ public $ validTZ ;
33
49
34
50
/**
35
51
* if this request has session transfer data
@@ -51,6 +67,7 @@ class AppController extends Controller
51
67
public function __construct ()
52
68
{
53
69
parent ::__construct ();
70
+ $ this ->validTZ = array_flip (DateTimeZone::listIdentifiers (DateTimeZone::ALL_WITH_BC ));
54
71
}
55
72
56
73
/**
@@ -61,6 +78,18 @@ public function __construct()
61
78
*/
62
79
public function beforeFilter ()
63
80
{
81
+ $ timezone = $ this ->SysParameter ->findByParameterCode ('system.timezone ' );
82
+ // default to UTC if no timezone is set
83
+ if (!(empty ($ timezone ) || empty ($ timezone ['SysParameter ' ]['parameter_value ' ]))) {
84
+ $ timezone = $ timezone ['SysParameter ' ]['parameter_value ' ];
85
+ // check that the timezone is valid
86
+ if (isset ($ this ->validTZ [$ timezone ])) {
87
+ date_default_timezone_set ($ timezone );
88
+ } else {
89
+ $ this ->Session ->setFlash (__ ('An invalid timezone is provided, please edit "system.timezone" ' , true ));
90
+ }
91
+ }
92
+
64
93
$ this ->Auth ->autoRedirect = false ;
65
94
// backward compatible with original ipeer hash method
66
95
Security::setHash ('md5 ' );
@@ -97,6 +126,14 @@ public function beforeFilter()
97
126
$ this ->_checkDatabaseVersion ();
98
127
}
99
128
129
+ // for setting up google analytics
130
+ $ trackingId = $ this ->SysParameter ->findByParameterCode ('google_analytics.tracking_id ' );
131
+ $ domain = $ this ->SysParameter ->findByParameterCode ('google_analytics.domain ' );
132
+ $ customLogo = $ this ->SysParameter ->findByParameterCode ('banner.custom_logo ' );
133
+ $ this ->set ('trackingId ' , $ trackingId );
134
+ $ this ->set ('domain ' , $ domain );
135
+ $ this ->set ('customLogo ' , $ customLogo );
136
+
100
137
parent ::beforeFilter ();
101
138
}
102
139
@@ -210,6 +247,7 @@ public function _afterLogin($isRedirect = true)
210
247
// after login stuff
211
248
$ this ->User ->loadRoles (User::get ('id ' ));
212
249
$ this ->AccessControl ->loadPermissions ();
250
+ $ this ->SysParameter ->reload ();
213
251
//TODO logging!
214
252
}
215
253
0 commit comments