user_id = $user_id;
$this->path = 'block_global_info';
if ($this->is_block_visible_for_user($user_id)) {
//$this->courses = CourseManager::get_courses_followed_by_drh($user_id);
}
}
/**
* 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()
{
global $charset;
$column = 2;
$data = [];
$content = $this->get_content_html();
$html = '
'.get_lang('GlobalPlatformInformation').'
'.$content.'
';
$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 get_content_html()
{
$global_data = $this->get_global_information_data();
$content = ''.get_lang('GlobalPlatformInformation').'
';
$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 .= ''.$cell.' | ';
}
$data_table .= '
';
$i++;
}
$data_table .= '
';
} else {
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
}
$content .= $data_table;
return $content;
}
/**
* 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('CountUsers'), ''.Statistics::countUsers().''],
// Check only active users
[get_lang('NumberOfUsersActive'), ''.Statistics::countUsers(null, null, null, true).''],
// Check number of courses
[get_lang('NumberOfCoursesTotal'), ''.Statistics::countCourses().''],
[get_lang('NumberOfCoursesPublic'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_OPEN_WORLD).''],
[get_lang('NumberOfCoursesOpen'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_OPEN_PLATFORM).''],
[get_lang('NumberOfCoursesPrivate'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_REGISTERED).''],
[get_lang('NumberOfCoursesClosed'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_CLOSED).''],
[get_lang('NumberOfCoursesHidden'), ''.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_HIDDEN).''],
];
return $global_info;
}
}