Permalink
Browse files

add design response

  • Loading branch information...
1 parent ee56fac commit 982ce90f09ae60827d65b30bca7e6efda51d6423 @rmarianski committed Sep 15, 2011
@@ -376,7 +376,8 @@ function edit( $id = false, $saved = false )
'incident_active' => '',
'incident_verified' => '',
'incident_source' => '',
- 'incident_information' => ''
+ 'incident_information' => '',
+ 'design_response' => '',
);
// copy the form as errors, so the errors will be stored with keys corresponding to the form field names
@@ -704,9 +705,20 @@ function edit( $id = false, $saved = false )
$incident->incident_verified = $post->incident_verified;
$incident->incident_source = $post->incident_source;
$incident->incident_information = $post->incident_information;
+
//Save
$incident->save();
+ // design response
+ ORM::factory('Design_Response')->where('incident_id',$incident->id)->delete_all();
+ if ($post->design_response && trim($post->design_response)) {
+ $design_response_str = trim($post->design_response);
+ $design_response = new Design_Response_Model();
+ $design_response->incident_id = $incident->id;
+ $design_response->text = $design_response_str;
+ $design_response->save();
+ }
+
// Tag this as a report that needs to be sent out as an alert
if ($incident->incident_active == '1' AND $incident->incident_alert_status != '2')
{ // 2 = report that has had an alert sent
@@ -744,7 +756,6 @@ function edit( $id = false, $saved = false )
}
$verify->save();
-
// STEP 3: SAVE CATEGORIES
ORM::factory('Incident_Category')->where('incident_id',$incident->id)->delete_all(); // Delete Previous Entries
foreach($post->incident_category as $item)
@@ -755,7 +766,6 @@ function edit( $id = false, $saved = false )
$incident_category->save();
}
-
// STEP 4: SAVE MEDIA
ORM::factory('Media')->where('incident_id',$incident->id)->where('media_type <> 1')->delete_all(); // Delete Previous Entries
// a. News
@@ -964,6 +974,14 @@ function edit( $id = false, $saved = false )
}
}
+ // fetch design response
+ $design_response_obj = ORM::factory('design_response')->where('incident_id', $incident->id)->find();
+ if ($design_response_obj) {
+ $design_response = $design_response_obj->text;
+ } else {
+ $design_response = '';
+ }
+
// Combine Everything
$incident_arr = array
(
@@ -992,7 +1010,8 @@ function edit( $id = false, $saved = false )
'incident_active' => $incident->incident_active,
'incident_verified' => $incident->incident_verified,
'incident_source' => $incident->incident_source,
- 'incident_information' => $incident->incident_information
+ 'incident_information' => $incident->incident_information,
+ 'design_response' => $design_response,
);
// Merge To Form Array For Display
@@ -0,0 +1,24 @@
+<?php defined('SYSPATH') or die('No direct script access.');
+
+/**
+ * Model for reported Incidents
+ *
+ *
+ * PHP version 5
+ * LICENSE: This source file is subject to LGPL license
+ * that is available through the world-wide-web at the following URI:
+ * http://www.gnu.org/copyleft/lesser.html
+ * @author Robert Marianski
+ * @package Ushahidi - http://source.ushahididev.com
+ * @module Design Response Model
+ * @copyright PPS - http://www.pps.org/
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
+ */
+
+class Design_Response_Model extends ORM
+{
+ protected $has_one = array('incident');
+
+ // Database table name
+ protected $table_name = 'design_response';
+}
@@ -19,7 +19,7 @@ class Incident_Model extends ORM
{
protected $has_many = array('category' => 'incident_category', 'media', 'verify', 'comment',
'rating', 'alert' => 'alert_sent', 'incident_lang', 'form_response','cluster' => 'cluster_incident');
- protected $has_one = array('location','incident_person','user','message','twitter','form');
+ protected $has_one = array('location','incident_person','user','message','twitter','form','design_response');
protected $belongs_to = array('sharing');
// Database table name
@@ -150,6 +150,10 @@
?>
</div>
</div>
+<div class="row">
+<h4>Design Response</h4>
+<?php echo form::textarea('design_response', $form['design_response'], ' style="height: 50px" rows="3"'); ?>
+</div>
<div class="row">
<h4><a href="#" id="category_toggle" class="new-cat"><?php echo Kohana::lang('ui_main.new_category');?></a><?php echo Kohana::lang('ui_main.categories');?>
<span><?php echo Kohana::lang('ui_main.select_multiple');?>.</span></h4>
@@ -0,0 +1,8 @@
+-- add a design_response column to the incident table
+
+CREATE TABLE `design_response` (
+id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+incident_id INT NOT NULL,
+text VARCHAR(2048),
+FOREIGN KEY (incident_id) REFERENCES incident(id)
+);

0 comments on commit 982ce90

Please sign in to comment.