diff --git a/application/controllers/admin/reports.php b/application/controllers/admin/reports.php index 4cdc1c5a..22d96d8c 100755 --- a/application/controllers/admin/reports.php +++ b/application/controllers/admin/reports.php @@ -353,6 +353,7 @@ public function edit($id = FALSE, $saved = FALSE) 'custom_field' => array(), 'incident_active' => '', 'incident_verified' => '', + 'incident_status' => '', 'incident_zoom' => '' ); @@ -771,6 +772,7 @@ public function edit($id = FALSE, $saved = FALSE) 'custom_field' => customforms::get_custom_form_fields($id, $incident->form_id, TRUE, 'submit'), 'incident_active' => $incident->incident_active, 'incident_verified' => $incident->incident_verified, + 'incident_status' => $incident->incident_status, 'incident_zoom' => $incident->incident_zoom ); diff --git a/application/controllers/json.php b/application/controllers/json.php index 165489f7..f068ced8 100644 --- a/application/controllers/json.php +++ b/application/controllers/json.php @@ -175,7 +175,7 @@ protected function markers_geojson($incidents, $category_id, $color, $icon, $inc $first_incident_id = (isset($_GET['i']) AND intval($_GET['i']) > 0)? intval($_GET['i']) : 0; $media_type = (isset($_GET['m']) AND intval($_GET['m']) > 0)? intval($_GET['m']) : 0; - + $status = (isset($_GET['st']) AND intval($_GET['st']) > 0)? intval($_GET['st']) : 0; foreach ($incidents as $marker) { // Handle both reports::fetch_incidents() response and actual ORM objects @@ -592,6 +592,15 @@ public function timeline($category_id = 0) $params[':mtype'] = $_GET['m']; $incident_id_in .= " AND i.id IN ( $query ) "; } + + // Apply project status filters + if (isset($_GET['st'])) + { + $query = "SELECT id FROM".$this->table_prefix."incident" + . "WHERE incident_status = :status "; + $params[':status'] = $_GET['st']; + $incident_id_in .= " AND i.id IN ( $query ) "; + } // Fetch the timeline data $query = 'SELECT UNIX_TIMESTAMP('.$select_date_text.') AS time, COUNT(i.id) AS number ' diff --git a/application/helpers/reports.php b/application/helpers/reports.php index 6d834e51..dc92e04d 100644 --- a/application/helpers/reports.php +++ b/application/helpers/reports.php @@ -278,6 +278,12 @@ public static function save_report($post, $incident, $location_id) { $incident->incident_verified = $post->incident_verified; } + + // Project status: Only set if user has permission + if (isset($post->incident_status) AND Auth::instance()->has_permission('reports_status')) + { + $incident->incident_status = $post->incident_status; + } // Incident zoom if ( ! empty($post->incident_zoom)) @@ -760,7 +766,7 @@ public static function fetch_incidents($paginate = FALSE, $items_per_page = 0) // Split selected parameters on "," // For simplicity, always turn them into arrays even theres just one value - $exclude_params = array('c', 'v', 'm', 'mode', 'sw', 'ne', 'start_loc'); + $exclude_params = array('c', 'v', 'm', 'mode', 'st', 'sw', 'ne', 'start_loc'); foreach ($url_data as $key => $value) { if (in_array($key, $exclude_params) AND ! is_array($value)) @@ -935,6 +941,28 @@ public static function fetch_incidents($paginate = FALSE, $items_per_page = 0) } + // + // Check for status parameter + // + if (isset($url_data['st']) AND is_array($url_data['st'])) + { + $incident_status = array(); + foreach ($url_data['st'] as $status) + { + if (intval($status) >= 0) + { + $incident_status[] = intval($status); + } + } + + if (count($incident_status) > 0) + { + array_push(self::$params, + 'i.incident_status IN ('.implode(",", $incident_status).')' + ); + } + } + // // Check if the verification status has been specified // diff --git a/application/i18n b/application/i18n index fc788997..82e23c96 160000 --- a/application/i18n +++ b/application/i18n @@ -1 +1 @@ -Subproject commit fc788997a2e8a16917da4f96bd9f9856c40bbcd4 +Subproject commit 82e23c96bcc7fd15511e99bc4a9235162654e39b diff --git a/application/views/admin/reports/edit.php b/application/views/admin/reports/edit.php index 144a4fb7..925e79eb 100755 --- a/application/views/admin/reports/edit.php +++ b/application/views/admin/reports/edit.php @@ -488,6 +488,23 @@ +
+
?
+ has_permission('incident_status')): ?> + > + > + + + +
diff --git a/media/js/ushahidi.js b/media/js/ushahidi.js index 2be969fd..5b8a37b1 100644 --- a/media/js/ushahidi.js +++ b/media/js/ushahidi.js @@ -716,6 +716,7 @@ * z - {Number} The zoom level * c - {Number} The category id * m - {Number} The media type (0 - All, 1 - Pictures, 2 - Video 4 - News) + * st - {Number} Project Status (0 - All, 1 - Ended, 2 - Ongoing) * s - {Number} Start date - Earliest date by which to filter the reports * e - {Number} End date - Latest date by which to filter the reports */ diff --git a/sql/upgrade117-118.sql b/sql/upgrade117-118.sql new file mode 100644 index 00000000..8284b34b --- /dev/null +++ b/sql/upgrade117-118.sql @@ -0,0 +1,5 @@ +-- UPDATE incidents +ALTER TABLE `incident` ADD incident_status tinyint(4); + +-- Update DB Version -- +UPDATE `settings` SET `value` = '118' WHERE `key` = 'db_version'; diff --git a/sql/ushahidi.sql b/sql/ushahidi.sql index b42eb6ad..983be094 100755 --- a/sql/ushahidi.sql +++ b/sql/ushahidi.sql @@ -780,6 +780,7 @@ CREATE TABLE IF NOT EXISTS `incident` ( `incident_datemodify` datetime DEFAULT NULL, `incident_alert_status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0 - Not Tagged for Sending, 1 - Tagged for Sending, 2 - Alerts Have Been Sent', `incident_zoom` tinyint(4) DEFAULT NULL, + `incident_status` tinyint(4) DEFAULT NULL, PRIMARY KEY (`id`), KEY `location_id` (`location_id`), KEY `incident_active` (`incident_active`), diff --git a/themes/default/views/main/layout.php b/themes/default/views/main/layout.php index 3f60a635..6fe8945a 100755 --- a/themes/default/views/main/layout.php +++ b/themes/default/views/main/layout.php @@ -229,17 +229,18 @@
-
+
  • +
  • +
- - +