Skip to content

Instantly share code, notes, and snippets.

@kamaulynder
Created March 14, 2011 21:05
Show Gist options
  • Save kamaulynder/869884 to your computer and use it in GitHub Desktop.
Save kamaulynder/869884 to your computer and use it in GitHub Desktop.
/**
* Manipulate view
*/
public function _manipulate_incident()
{
$incidents = Event::$data;
$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 = $filter;
$admin_section = "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment