Created
March 15, 2011 09:19
-
-
Save kamaulynder/870489 to your computer and use it in GitHub Desktop.
This file contains 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
public function _manipulate_incident() | |
{ | |
$incidents = Event::$data; | |
//die(print_r(Kohana::debug($incidents))); | |
$filter = $this->_filter(); | |
$auth = new Auth(); | |
$admin_section = $this->_get_admin_section($_SESSION['auth_user']->id); | |
$sections = $this->_get_admin_sections(); | |
$pagination = $this->_pagination(); | |
//If user is a moderator, manipulate report query | |
if (admin::permissions($this->user, "reports_view")) | |
{ | |
//if(strcasecmp($admin_section,in_array($admin_section,$sections)) == 0) | |
if(in_array($admin_section,$sections)) | |
{ | |
//echo $admin_section;exit; | |
if (strcasecmp($filter, "1=1")) | |
{ | |
$filter = "incident.id = monitor_report.incident_id "; | |
} | |
else | |
{ | |
$filter .= " AND | |
(".Kohana::config('database.default.table_prefix')."incident.id | |
=monitor_report.incident_id )"; | |
} | |
$incidents = ORM::factory('incident') | |
->join('monitor_report','incident.id','monitor_report.incident_id','INNER') | |
->join('location', 'incident.location_id', 'location.id','INNER') | |
->where($filter) | |
->orderby('incident_dateadd', 'desc') | |
->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset); | |
Event::$data = $incidents; | |
$admin_section = ""; | |
} | |
//else if (strcasecmp($admin_section, "crowd") == 0 ) | |
else if(in_array($admin_section,$sections)) | |
{ | |
//echo $admin_section;exit; | |
if (strcasecmp($filter, "1=1")) | |
{ | |
$filter = "incident.id = crowd_report.incident_id "; | |
} | |
else | |
{ | |
$filter .= " AND | |
(".Kohana::config('database.default.table_prefix')."incident.id | |
=crowd_report.incident_id )"; | |
} | |
$incidents = ORM::factory('incident') | |
->join('crowd_report','incident.id','crowd_report.incident_id','INNER') | |
->join('location', 'incident.location_id', 'location.id','INNER') | |
->where($filter) | |
->orderby('incident_dateadd', 'desc') | |
->find_all((int) Kohana::config('settings.items_per_page_admin'), $pagination->sql_offset); | |
Event::$data = $incidents; | |
$admin_section = ""; | |
} | |
else | |
{ | |
Event::$data = $incidents; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment