Ejemplo n.º 1
0
 function index()
 {
     $this->template->content = new View('admin/dashboard');
     $this->template->content->title = Kohana::lang('ui_admin.dashboard');
     $this->template->this_page = 'dashboard';
     // Retrieve Dashboard Count...
     // Total Reports
     $this->template->content->reports_total = ORM::factory('incident')->count_all();
     // Total Unapproved Reports
     $this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->count_all();
     // Total Unverified Reports
     $this->template->content->reports_unverified = ORM::factory('incident')->where('incident_verified', '0')->count_all();
     // Total Categories
     $this->template->content->categories = ORM::factory('category')->count_all();
     // Total Locations
     $this->template->content->locations = ORM::factory('location')->count_all();
     // Total Incoming Media
     $this->template->content->incoming_media = ORM::factory('feed_item')->count_all();
     // Messages By Service
     $total_message_count = 0;
     $message_services = array();
     $services = ORM::factory('service')->find_all();
     foreach ($services as $service) {
         $message_count = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service->id)->where('message_type', '1')->count_all();
         $message_services[] = array('id' => $service->id, 'name' => $service->service_name, 'count' => $message_count);
         $total_message_count += $message_count;
     }
     $this->template->content->message_services = $message_services;
     // Total Messages
     $this->template->content->message_count = $total_message_count;
     // Get reports for display
     $incidents = ORM::factory('incident')->limit(5)->orderby('incident_dateadd', 'desc')->find_all();
     $this->template->content->incidents = $incidents;
     // Get Incoming Media (We'll Use NewsFeeds for now)
     $this->template->content->feeds = ORM::factory('feed_item')->limit('3')->orderby('item_date', 'desc')->find_all();
     /*
     // Javascript Header
     $this->template->flot_enabled = TRUE;
     $this->template->js = new View('admin/dashboard_js');
     // Graph
     $this->template->js->all_graphs = Incident_Model::get_incidents_by_interval('ALL',NULL,NULL,'all');
     $this->template->js->current_date = date('Y') . '/' . date('m') . '/01';
     */
     // Javascript Header
     $this->template->protochart_enabled = TRUE;
     $this->template->js = new View('admin/stats_js');
     $this->template->content->failure = '';
     // Build dashboard chart
     // Set the date range (how many days in the past from today?)
     //    default to one year
     $range = isset($_GET['range']) ? $_GET['range'] : 365;
     if (isset($_GET['range']) and $_GET['range'] == 0) {
         $range = NULL;
     }
     $this->template->content->range = $range;
     $incident_data = Incident_Model::get_number_reports_by_date($range);
     $data = array('Reports' => $incident_data);
     $options = array('xaxis' => array('mode' => '"time"'));
     $this->template->content->report_chart = protochart::chart('report_chart', $data, $options, array('Reports' => 'CC0000'), 410, 310);
 }
Ejemplo n.º 2
0
 function index()
 {
     $this->template->content = new View('members/dashboard');
     $this->template->content->title = Kohana::lang('ui_admin.dashboard');
     $this->template->this_page = 'dashboard';
     // User
     $this->template->content->user = $this->user;
     // User Reputation Score
     $this->template->content->reputation = reputation::calculate($this->user->id);
     // Get Badges
     $this->template->content->badges = Badge_Model::users_badges($this->user->id);
     // Retrieve Dashboard Counts...
     // Total Reports
     $this->template->content->reports_total = ORM::factory('incident')->where("user_id", $this->user->id)->count_all();
     // Total Unapproved Reports
     $this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->where("user_id", $this->user->id)->count_all();
     // Total Checkins
     $this->template->content->checkins = ORM::factory('checkin')->where("user_id", $this->user->id)->count_all();
     // Total Alerts
     $this->template->content->alerts = ORM::factory('alert')->where("user_id", $this->user->id)->count_all();
     // Total Votes
     $this->template->content->votes = ORM::factory('rating')->where("user_id", $this->user->id)->count_all();
     // Total Votes Positive
     $this->template->content->votes_up = ORM::factory('rating')->where("user_id", $this->user->id)->where("rating", "1")->count_all();
     // Total Votes Negative
     $this->template->content->votes_down = ORM::factory('rating')->where("user_id", $this->user->id)->where("rating", "-1")->count_all();
     // Get reports for display
     $this->template->content->incidents = ORM::factory('incident')->where("user_id", $this->user->id)->limit(5)->orderby('incident_dateadd', 'desc')->find_all();
     // To support the "welcome" or "not enough info on user" form
     if ($this->user->public_profile == 1) {
         $this->template->content->profile_public = TRUE;
         $this->template->content->profile_private = FALSE;
     } else {
         $this->template->content->profile_public = FALSE;
         $this->template->content->profile_private = TRUE;
     }
     $this->template->content->hidden_welcome_fields = array('email' => $this->user->email, 'notify' => $this->user->notify, 'color' => $this->user->color, 'password' => '', 'needinfo' => 0);
     /*
     // Javascript Header
     $this->template->flot_enabled = TRUE;
     $this->template->js = new View('admin/dashboard_js');
     // Graph
     $this->template->js->all_graphs = Incident_Model::get_incidents_by_interval('ALL',NULL,NULL,'all');
     $this->template->js->current_date = date('Y') . '/' . date('m') . '/01';
     */
     // Javascript Header
     $this->template->protochart_enabled = TRUE;
     $this->template->js = new View('admin/stats_js');
     $this->template->content->failure = '';
     // Build dashboard chart
     // Set the date range (how many days in the past from today?)
     // Default to one year if invalid or not set
     $range = (isset($_GET['range']) and preg_match('/^\\d+$/', $_GET['range']) > 0) ? (int) $_GET['range'] : 365;
     // Phase 3 - Invoke Kohana's XSS cleaning mechanism just incase an outlier wasn't caught
     $range = $this->input->xss_clean($range);
     $incident_data = Incident_Model::get_number_reports_by_date($range, $this->user->id);
     $data = array('Reports' => $incident_data);
     $options = array('xaxis' => array('mode' => '"time"'));
     $this->template->content->report_chart = protochart::chart('report_chart', $data, $options, array('Reports' => 'CC0000'), 410, 310);
 }
Ejemplo n.º 3
0
 public function index()
 {
     $this->template->content = new View('admin/dashboard');
     $this->template->content->title = Kohana::lang('ui_admin.dashboard');
     $this->template->this_page = 'dashboard';
     // Retrieve Dashboard Count...
     // Total Reports
     $this->template->content->reports_total = ORM::factory('incident')->count_all();
     // Total Unapproved Reports
     $this->template->content->reports_unapproved = ORM::factory('incident')->where('incident_active', '0')->count_all();
     // Total Unverified Reports
     $this->template->content->reports_unverified = ORM::factory('incident')->where('incident_verified', '0')->count_all();
     // Total Categories
     $this->template->content->categories = ORM::factory('category')->count_all();
     // Total Locations
     $this->template->content->locations = ORM::factory('location')->count_all();
     // Total Incoming Media
     $this->template->content->incoming_media = ORM::factory('feed_item')->count_all();
     // Messages By Service
     $total_message_count = 0;
     $message_services = array();
     $services = ORM::factory('service')->find_all();
     foreach ($services as $service) {
         $message_count = ORM::factory('message')->join('reporter', 'message.reporter_id', 'reporter.id')->where('service_id', $service->id)->where('message_type', '1')->count_all();
         $message_services[] = array('id' => $service->id, 'name' => $service->service_name, 'count' => $message_count);
         $total_message_count += $message_count;
     }
     $this->template->content->message_services = $message_services;
     // Total Messages
     $this->template->content->message_count = $total_message_count;
     // Get reports for display
     $incidents = ORM::factory('incident')->limit(5)->orderby('incident_dateadd', 'desc')->find_all();
     $this->template->content->incidents = $incidents;
     // Get Incoming Media (We'll Use NewsFeeds for now)
     $this->template->content->feeds = ORM::factory('feed_item')->limit('3')->orderby('item_date', 'desc')->find_all();
     // Javascript Header
     $this->template->protochart_enabled = TRUE;
     $this->template->js = new View('admin/stats_js');
     $this->template->content->failure = '';
     // Build dashboard chart
     // Set the date range (how many days in the past from today?)
     // Default to one year if invalid or not set
     $range = 0;
     if (isset($_GET['range'])) {
         // Sanitize the range parameter
         $range = $this->input->xss_clean($_GET['range']);
         $range = intval($range) > 0 ? intval($range) : 0;
     }
     $incident_data = Incident_Model::get_number_reports_by_date($range);
     $data = array('Reports' => $incident_data);
     $options = array('xaxis' => array('mode' => '"time"'));
     $this->template->content->report_chart = protochart::chart('report_chart', $data, $options, array('Reports' => 'CC0000'), 410, 310);
     // Render version sync checks if enabled
     $this->template->content->version_sync = NULL;
     if (Kohana::config('config.enable_ver_sync_warning') == TRUE) {
         $this->template->content->version_sync = View::factory('admin/version_sync');
     }
     // Render security checks if enabled
     $this->template->content->security_info = NULL;
     if (Kohana::config('config.enable_security_info') == TRUE) {
         $this->template->content->security_info = View::factory('admin/security_info');
     }
 }