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); }
/** * Displays a profile page for a user */ public function user() { // Cacheable Controller $this->is_cachable = TRUE; $this->template->header->this_page = 'profile'; // Check if we are looking for a user. Argument must be set to continue. if (!isset(Router::$arguments[0])) { url::redirect('profile'); } $username = Router::$arguments[0]; // We won't allow profiles to be public if the username is an email address if (valid::email($username)) { url::redirect('profile'); } $user = User_Model::get_user_by_username($username); // We only want to show public profiles here if ($user->public_profile == 1) { $this->template->content = new View('profile/user'); $this->template->content->user = $user; // User Reputation Score $this->template->content->reputation = reputation::calculate($user->id); // All users reports $this->template->content->reports = ORM::factory('incident')->where(array('user_id' => $user->id, 'incident_active' => 1))->with('incident:location')->find_all(); // Get Badges $this->template->content->badges = Badge_Model::users_badges($user->id); // Logged in user id (false if not logged in) $logged_in_id = FALSE; if (isset(Auth::instance()->get_user()->id)) { $logged_in_id = Auth::instance()->get_user()->id; } $this->template->content->logged_in_id = $logged_in_id; // Is this the logged in user? $logged_in_user = FALSE; if ($logged_in_id == $user->id) { $logged_in_user = TRUE; } $this->template->content->logged_in_user = $logged_in_user; } else { // this is a private profile so get out of here url::redirect('profile'); } $this->template->header->page_title .= $user->name . Kohana::config('settings.title_delimiter'); $this->template->header->header_block = $this->themes->header_block(); $this->template->footer->footer_block = $this->themes->footer_block(); }