@@ -61,7 +61,7 @@ public function index($page = 1)
61
61
$ status = "0 " ;
62
62
}
63
63
}
64
-
64
+
65
65
// Get Search Keywords (If Any)
66
66
if (isset ($ _GET ['k ' ]))
67
67
{
@@ -77,7 +77,7 @@ public function index($page = 1)
77
77
// in the first 2 steps
78
78
$ keyword_raw = $ this ->input ->xss_clean ($ keyword_raw );
79
79
80
- $ filter . = " AND ( " .$ this ->_get_searchstring ($ keyword_raw ).") " ;
80
+ $ filter = " AND ( " .$ this ->_get_searchstring ($ keyword_raw ).") " ;
81
81
}
82
82
else
83
83
{
@@ -183,7 +183,8 @@ public function index($page = 1)
183
183
$ update ->incident_verified = '0 ' ;
184
184
$ verify ->verified_status = '0 ' ;
185
185
}
186
- else {
186
+ else
187
+ {
187
188
$ update ->incident_verified = '1 ' ;
188
189
$ verify ->verified_status = '2 ' ;
189
190
}
@@ -701,8 +702,7 @@ public function edit($id = FALSE, $saved = FALSE)
701
702
}
702
703
703
704
// Combine Everything
704
- $ incident_arr = array
705
- (
705
+ $ incident_arr = array (
706
706
'location_id ' => $ incident ->location ->id ,
707
707
'form_id ' => $ incident ->form_id ,
708
708
'locale ' => $ incident ->locale ,
@@ -806,7 +806,7 @@ public function edit($id = FALSE, $saved = FALSE)
806
806
/**
807
807
* Download Reports in CSV format
808
808
*/
809
- function download ()
809
+ public function download ()
810
810
{
811
811
// If user doesn't have access, redirect to dashboard
812
812
if ( ! admin::permissions ($ this ->user , "reports_download " ))
@@ -847,17 +847,20 @@ function download()
847
847
if (!empty ($ _POST ['from_date ' ]) OR !empty ($ _POST ['to_date ' ]))
848
848
{
849
849
// Valid FROM Date?
850
- if (empty ($ _POST ['from_date ' ]) OR (strtotime ($ _POST ['from_date ' ]) > strtotime ("today " ))) {
850
+ if (empty ($ _POST ['from_date ' ]) OR (strtotime ($ _POST ['from_date ' ]) > strtotime ("today " )))
851
+ {
851
852
$ post ->add_error ('from_date ' ,'range ' );
852
853
}
853
854
854
855
// Valid TO date?
855
- if (empty ($ _POST ['to_date ' ]) OR (strtotime ($ _POST ['to_date ' ]) > strtotime ("today " ))) {
856
+ if (empty ($ _POST ['to_date ' ]) OR (strtotime ($ _POST ['to_date ' ]) > strtotime ("today " )))
857
+ {
856
858
$ post ->add_error ('to_date ' ,'range ' );
857
859
}
858
860
859
861
// TO Date not greater than FROM Date?
860
- if (strtotime ($ _POST ['from_date ' ]) > strtotime ($ _POST ['to_date ' ])) {
862
+ if (strtotime ($ _POST ['from_date ' ]) > strtotime ($ _POST ['to_date ' ]))
863
+ {
861
864
$ post ->add_error ('to_date ' ,'range_greater ' );
862
865
}
863
866
}
@@ -894,9 +897,10 @@ function download()
894
897
$ filter .= ") " ;
895
898
896
899
// Report Date Filter
897
- if (! empty ($ post ->from_date ) AND !empty ($ post ->to_date ))
900
+ if ( ! empty ($ post ->from_date ) AND !empty ($ post ->to_date ))
898
901
{
899
- $ filter .= " AND ( incident_date >= ' " . date ("Y-m-d H:i:s " ,strtotime ($ post ->from_date )) . "' AND incident_date <= ' " . date ("Y-m-d H:i:s " ,strtotime ($ post ->to_date )) . "' ) " ;
902
+ $ filter .= " AND ( incident_date >= ' " . date ("Y-m-d H:i:s " ,strtotime ($ post ->from_date ))
903
+ . "' AND incident_date <= ' " . date ("Y-m-d H:i:s " ,strtotime ($ post ->to_date )) . "' ) " ;
900
904
}
901
905
902
906
// Retrieve reports
@@ -1121,7 +1125,7 @@ public function upload()
1121
1125
* @param bool|string $saved
1122
1126
*/
1123
1127
1124
- function translate ( $ id = false , $ saved = false )
1128
+ public function translate ( $ id = false , $ saved = FALSE )
1125
1129
{
1126
1130
$ this ->template ->content = new View ('admin/reports_translate ' );
1127
1131
$ this ->template ->content ->title = Kohana::lang ('ui_admin.translate_reports ' );
@@ -1152,23 +1156,17 @@ function translate( $id = false, $saved = false )
1152
1156
1153
1157
1154
1158
// Setup and initialize form field names
1155
- $ form = array
1156
- (
1159
+ $ form = array (
1157
1160
'locale ' => '' ,
1158
1161
'incident_title ' => '' ,
1159
1162
'incident_description ' => ''
1160
1163
);
1164
+
1161
1165
// Copy the form as errors, so the errors will be stored with keys corresponding to the form field names
1162
1166
$ errors = $ form ;
1163
1167
$ form_error = FALSE ;
1164
- if ($ saved == 'saved ' )
1165
- {
1166
- $ form_saved = TRUE ;
1167
- }
1168
- else
1169
- {
1170
- $ form_saved = FALSE ;
1171
- }
1168
+
1169
+ $ form_saved = ($ saved == 'saved ' )? TRUE : FALSE ;
1172
1170
1173
1171
// Locale (Language) Array
1174
1172
$ this ->template ->content ->locale_array = Kohana::config ('locale.all_languages ' );
@@ -1233,7 +1231,7 @@ function translate( $id = false, $saved = false )
1233
1231
}
1234
1232
else
1235
1233
{
1236
- if ( $ id )
1234
+ if ($ id )
1237
1235
{
1238
1236
// Retrieve Current Incident
1239
1237
$ incident_l = ORM ::factory ('incident_lang ' , $ id )->where ('incident_id ' , $ incident_id )->find ();
@@ -1267,7 +1265,7 @@ function translate( $id = false, $saved = false )
1267
1265
/**
1268
1266
* Save newly added dynamic categories
1269
1267
*/
1270
- function save_category ()
1268
+ public function save_category ()
1271
1269
{
1272
1270
$ this ->auto_render = FALSE ;
1273
1271
$ this ->template = "" ;
@@ -1300,7 +1298,6 @@ function save_category()
1300
1298
1301
1299
echo json_encode (array ("status " =>"saved " , "id " =>$ category ->id ));
1302
1300
}
1303
-
1304
1301
else
1305
1302
1306
1303
{
@@ -1317,36 +1314,42 @@ function save_category()
1317
1314
* Delete Photo
1318
1315
* @param int $id The unique id of the photo to be deleted
1319
1316
*/
1320
- function deletePhoto ( $ id )
1317
+ public function deletePhoto ($ id )
1321
1318
{
1322
1319
$ this ->auto_render = FALSE ;
1323
1320
$ this ->template = "" ;
1324
1321
1325
- if ( $ id )
1322
+ if ($ id )
1326
1323
{
1327
1324
$ photo = ORM ::factory ('media ' , $ id );
1328
1325
$ photo_large = $ photo ->media_link ;
1329
1326
$ photo_medium = $ photo ->media_medium ;
1330
1327
$ photo_thumb = $ photo ->media_thumb ;
1331
1328
1332
- if (file_exists (Kohana::config ('upload.directory ' , TRUE ).$ photo_large ))
1329
+ if (file_exists (Kohana::config ('upload.directory ' , TRUE ).$ photo_large ))
1333
1330
{
1334
1331
unlink (Kohana::config ('upload.directory ' , TRUE ).$ photo_large );
1335
- }elseif (Kohana::config ("cdn.cdn_store_dynamic_content " ) AND valid::url ($ photo_large )){
1332
+ }
1333
+ elseif (Kohana::config ("cdn.cdn_store_dynamic_content " ) AND valid::url ($ photo_large ))
1334
+ {
1336
1335
cdn::delete ($ photo_large );
1337
1336
}
1338
1337
1339
- if (file_exists (Kohana::config ('upload.directory ' , TRUE ).$ photo_medium ))
1338
+ if (file_exists (Kohana::config ('upload.directory ' , TRUE ).$ photo_medium ))
1340
1339
{
1341
1340
unlink (Kohana::config ('upload.directory ' , TRUE ).$ photo_medium );
1342
- }elseif (Kohana::config ("cdn.cdn_store_dynamic_content " ) AND valid::url ($ photo_medium )){
1341
+ }
1342
+ elseif (Kohana::config ("cdn.cdn_store_dynamic_content " ) AND valid::url ($ photo_medium ))
1343
+ {
1343
1344
cdn::delete ($ photo_medium );
1344
1345
}
1345
1346
1346
- if (file_exists (Kohana::config ('upload.directory ' , TRUE ).$ photo_thumb ))
1347
+ if (file_exists (Kohana::config ('upload.directory ' , TRUE ).$ photo_thumb ))
1347
1348
{
1348
1349
unlink (Kohana::config ('upload.directory ' , TRUE ).$ photo_thumb );
1349
- }elseif (Kohana::config ("cdn.cdn_store_dynamic_content " ) AND valid::url ($ photo_thumb )){
1350
+ }
1351
+ elseif (Kohana::config ("cdn.cdn_store_dynamic_content " ) AND valid::url ($ photo_thumb ))
1352
+ {
1350
1353
cdn::delete ($ photo_thumb );
1351
1354
}
1352
1355
@@ -1360,8 +1363,7 @@ function deletePhoto ( $id )
1360
1363
// Dynamic categories form fields
1361
1364
private function _new_categories_form_arr ()
1362
1365
{
1363
- return array
1364
- (
1366
+ return array (
1365
1367
'category_name ' => '' ,
1366
1368
'category_description ' => '' ,
1367
1369
'category_color ' => '' ,
@@ -1406,26 +1408,26 @@ private function _stroke_width_array()
1406
1408
}
1407
1409
1408
1410
// Javascript functions
1409
- private function _color_picker_js ()
1411
+ private function _color_picker_js ()
1410
1412
{
1411
- return "<script type= \"text/javascript \">
1412
- $(document).ready(function() {
1413
- $('#category_color').ColorPicker({
1414
- onSubmit: function(hsb, hex, rgb) {
1415
- $('#category_color').val(hex);
1416
- },
1417
- onChange: function(hsb, hex, rgb) {
1418
- $('#category_color').val(hex);
1419
- },
1420
- onBeforeShow: function () {
1421
- $(this).ColorPickerSetColor(this.value);
1422
- }
1423
- })
1424
- .bind('keyup', function(){
1425
- $(this).ColorPickerSetColor(this.value);
1426
- });
1427
- });
1428
- </script> " ;
1413
+ return "<script type= \"text/javascript \">
1414
+ $(document).ready(function() {
1415
+ $('#category_color').ColorPicker({
1416
+ onSubmit: function(hsb, hex, rgb) {
1417
+ $('#category_color').val(hex);
1418
+ },
1419
+ onChange: function(hsb, hex, rgb) {
1420
+ $('#category_color').val(hex);
1421
+ },
1422
+ onBeforeShow: function () {
1423
+ $(this).ColorPickerSetColor(this.value);
1424
+ }
1425
+ })
1426
+ .bind('keyup', function(){
1427
+ $(this).ColorPickerSetColor(this.value);
1428
+ });
1429
+ });
1430
+ </script> " ;
1429
1431
}
1430
1432
1431
1433
private function _date_picker_js ()
@@ -1502,33 +1504,30 @@ private function _get_searchstring($keyword_raw)
1502
1504
1503
1505
$ keywords = explode (' ' , $ keyword_raw );
1504
1506
1505
- if (is_array ($ keywords ) && !empty ($ keywords ))
1507
+ if (is_array ($ keywords ) AND !empty ($ keywords ))
1506
1508
{
1507
1509
array_change_key_case ($ keywords , CASE_LOWER );
1508
1510
$ i = 0 ;
1509
1511
1510
- foreach ($ keywords as $ value )
1512
+ foreach ($ keywords as $ value )
1511
1513
{
1512
- if (!in_array ($ value ,$ stop_words ) && !empty ($ value ))
1514
+ if (!in_array ($ value ,$ stop_words ) AND !empty ($ value ))
1513
1515
{
1514
- $ chunk = mysql_real_escape_string ($ value );
1515
- if ($ i > 0 ) {
1516
+ $ chunk = $ this ->db ->escape_str ($ value );
1517
+ if ($ i > 0 )
1518
+ {
1516
1519
$ or = ' OR ' ;
1517
1520
}
1518
- $ where_string = $ where_string .$ or ."incident_title LIKE '% $ chunk%' OR incident_description LIKE '% $ chunk%' OR location_name LIKE '% $ chunk%' " ;
1521
+ $ where_string = $ where_string
1522
+ .$ or
1523
+ ."incident_title LIKE '% $ chunk%' OR incident_description LIKE '% $ chunk%' OR location_name LIKE '% $ chunk%' " ;
1519
1524
$ i ++;
1520
1525
}
1521
1526
}
1522
1527
}
1523
-
1524
- if ($ where_string )
1525
- {
1526
- return $ where_string ;
1527
- }
1528
- else
1529
- {
1530
- return "1=1 " ;
1531
- }
1528
+
1529
+ // Return
1530
+ return (!empty ($ where_string )) ? $ where_string : "1=1 " ;
1532
1531
}
1533
1532
1534
1533
private function _csv_text ($ text )
0 commit comments