Exemple #1
0
 public function profile($username, $videos_offset = 0)
 {
     // TODO handle user not found
     $user_id = $this->session->userdata('user_id');
     if ($user_id) {
         if (intval($user_id) & USER_ROLE_ADMIN) {
             $allow_unactivated = TRUE;
         } else {
             $allow_unactivated = FALSE;
         }
     } else {
         $allow_unactivated = FALSE;
     }
     $this->load->config('localization');
     $this->load->helper('date');
     $this->lang->load('date');
     // **
     // ** LOADING MODEL
     // **
     // Logged in user time zone
     $time_zone = $this->session->userdata('time_zone');
     // User data
     $userdata = $this->users_model->get_userdata($username);
     $userdata['roles'] = Users_model::roles_to_string($userdata['roles']);
     $country_list = $this->config->item('country_list');
     $userdata['country_name'] = $country_list[$userdata['country']];
     $userdata['last_login'] = human_gmt_to_human_local($userdata['last_login'], $time_zone);
     $userdata['time_zone'] = $this->lang->line($userdata['time_zone']);
     // User's videos
     $this->load->model('videos_model');
     $vs_data['videos'] = $this->videos_model->get_videos_summary(NULL, $username, intval($videos_offset), $this->config->item('videos_per_page'), 'hottest', $allow_unactivated);
     // Pagination
     $this->load->library('pagination');
     $pg_config['base_url'] = site_url("user/profile/{$username}/");
     $pg_config['uri_segment'] = 4;
     $pg_config['total_rows'] = $this->videos_model->get_videos_count(NULL, $username, $allow_unactivated);
     $pg_config['per_page'] = $this->config->item('videos_per_page');
     $this->pagination->initialize($pg_config);
     $vs_data['pagination'] = $this->pagination->create_links();
     $vs_data['title'] = NULL;
     $vs_data['category_name'] = '';
     // TODO videos_summary with AJAX
     $params = array('title' => $this->lang->line('user_appelation') . ' ' . $username . ' – ' . $this->config->item('site_name'), 'css' => array('catalog.css'), 'js' => array('jquery.ui.thumbs.js'));
     $this->load->library('html_head_params', $params);
     // Current user profile tab
     $tab = !$videos_offset ? 0 : 1;
     // **
     // ** LOADING VIEWS
     // **
     $this->load->view('html_begin', $this->html_head_params);
     $this->load->view('header', array());
     $vs = $this->load->view('catalog/videos_summary_view', $vs_data, TRUE);
     $main_params['content'] = $this->load->view('user/profile_view', array('userdata' => $userdata, 'videos_summary' => $vs, 'tab' => $tab), TRUE);
     $main_params['side'] = $this->load->view('side_default', NULL, TRUE);
     $this->load->view('main', $main_params);
     $this->load->view('footer');
     $this->load->view('html_end');
 }