user_id = $user_id; $this->path = 'block_global_info'; } /** * This method check if a user is allowed to see the block inside dashboard interface. * * @param int User id * * @return bool Is block visible for user */ public function is_block_visible_for_user($user_id) { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { $is_block_visible_for_user = true; } return $is_block_visible_for_user; } /** * This method return content html containing information * about courses and its position for showing it inside dashboard interface * it's important to use the name 'get_block' for beeing used from dashboard controller. * * @return array column and content html */ public function get_block() { $column = 2; $data = []; $html = $this->getBlockCard( get_lang('Global platform information'), $this->getContent() ); $data['column'] = $column; $data['content_html'] = $html; return $data; } /** * This method return a content html, it's used inside get_block method for showing it inside dashboard interface. * * @return string content html */ public function getContent() { $global_data = $this->get_global_information_data(); $data_table = null; if (!empty($global_data)) { $data_table = ''; $i = 1; foreach ($global_data as $data) { if ($i % 2 == 0) { $class_tr = 'row_odd'; } else { $class_tr = 'row_even'; } $data_table .= ''; foreach ($data as $cell) { $data_table .= ''; } $data_table .= ''; $i++; } $data_table .= '
'.$cell.'
'; } else { $data_table .= get_lang('ThereIsNoInformationAboutThePlatform'); } return $data_table; } /** * Get global information data. * * @return array */ public function get_global_information_data() { // Two-dimensional array with data about the system $path = api_get_path(WEB_CODE_PATH); // Check total number of users $global_info = [ [get_lang('Number of users'), ''.Statistics::countUsers().''], // Check only active users [get_lang('Number of active users'), ''.Statistics::countUsers(null, null, null, true).''], // Check number of courses [get_lang('Total number of courses'), ''.Statistics::countCourses().''], [get_lang('Number of public courses'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_OPEN_WORLD).''], [get_lang('Number of open courses'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_OPEN_PLATFORM).''], [get_lang('Number of private courses'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_REGISTERED).''], [get_lang('Number of closed courses'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_CLOSED).''], [get_lang('Number of hidden courses'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_HIDDEN).''], ]; return $global_info; } }