Created
February 18, 2011 17:11
-
-
Save dkobia/834009 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/application/controllers/scheduler/s_email.php b/application/controllers/scheduler/s_email.php | |
index 1be52ca..0d7bfb0 100644 | |
--- a/application/controllers/scheduler/s_email.php | |
+++ b/application/controllers/scheduler/s_email.php | |
@@ -151,6 +151,54 @@ class S_Email_Controller extends Controller { | |
} | |
} | |
+ | |
+ // Auto-Create A Report if Reporter is Trusted | |
+ $reporter_weight = $reporter->level->level_weight; | |
+ $reporter_location = $reporter->location; | |
+ if ($reporter_weight > 0 AND $reporter_location) | |
+ { | |
+ // Create Incident | |
+ $incident = new Incident_Model(); | |
+ $incident->location_id = $reporter_location->id; | |
+ $incident->incident_title = $message['subject']; | |
+ $incident->incident_description = $message['body']; | |
+ $incident->incident_date = $message['date']; | |
+ $incident->incident_dateadd = date("Y-m-d H:i:s",time()); | |
+ $incident->incident_active = 1; | |
+ if ($reporter_weight == 2) | |
+ { | |
+ $incident->incident_verified = 1; | |
+ } | |
+ $incident->save(); | |
+ | |
+ // Update Message with Incident ID | |
+ $email->incident_id = $incident->id; | |
+ $email->save(); | |
+ | |
+ // Save Incident Category | |
+ $trusted_categories = ORM::factory("category") | |
+ ->where("category_trusted", 1) | |
+ ->find(); | |
+ if ($trusted_categories->loaded) | |
+ { | |
+ $incident_category = new Incident_Category_Model(); | |
+ $incident_category->incident_id = $incident->id; | |
+ $incident_category->category_id = $trusted_categories->id; | |
+ $incident_category->save(); | |
+ } | |
+ | |
+ // Add Attachments | |
+ $attachments = ORM::factory("media") | |
+ ->where("message_id", $email->id) | |
+ ->find_all(); | |
+ foreach ($attachments AS $attachment) | |
+ { | |
+ $attachment->incident_id = $incident->id; | |
+ $attachment->save(); | |
+ } | |
+ } | |
+ | |
+ | |
// Notify Admin Of New Email Message | |
$send = notifications::notify_admins( | |
"[".Kohana::config('settings.site_name')."] ". | |
@@ -161,52 +209,6 @@ class S_Email_Controller extends Controller { | |
// Action::message_email_add - Email Received! | |
Event::run('ushahidi_action.message_email_add', $email); | |
} | |
- | |
- // Auto-Create A Report if Reporter is Trusted | |
- $reporter_weight = $reporter->level->level_weight; | |
- $reporter_location = $reporter->location; | |
- if ($reporter_weight > 0 AND $reporter_location) | |
- { | |
- // Create Incident | |
- $incident = new Incident_Model(); | |
- $incident->location_id = $reporter_location->id; | |
- $incident->incident_title = $message['subject']; | |
- $incident->incident_description = $message['body']; | |
- $incident->incident_date = $message['date']; | |
- $incident->incident_dateadd = date("Y-m-d H:i:s",time()); | |
- $incident->incident_active = 1; | |
- if ($reporter_weight == 2) | |
- { | |
- $incident->incident_verified = 1; | |
- } | |
- $incident->save(); | |
- | |
- // Update Message with Incident ID | |
- $email->incident_id = $incident->id; | |
- $email->save(); | |
- | |
- // Save Incident Category | |
- $trusted_categories = ORM::factory("category") | |
- ->where("category_trusted", 1) | |
- ->find(); | |
- if ($trusted_categories->loaded) | |
- { | |
- $incident_category = new Incident_Category_Model(); | |
- $incident_category->incident_id = $incident->id; | |
- $incident_category->category_id = $trusted_categories->id; | |
- $incident_category->save(); | |
- } | |
- | |
- // Add Attachments | |
- $attachments = ORM::factory("media") | |
- ->where("message_id", $email->id) | |
- ->find_all(); | |
- foreach ($attachments AS $attachment) | |
- { | |
- $attachment->incident_id = $incident->id; | |
- $attachment->save(); | |
- } | |
- } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment