123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- /**
- * This file is part of global info block plugin for dashboard,
- * it should be required inside the dashboard controller for
- * showing it into the dashboard interface.
- * @package chamilo.dashboard
- * @author Yannick Warnier
- */
- /**
- * required files for getting data
- */
- /**
- * This class is used like controller for this global info block plugin
- * the class name must be registered inside path.info file
- * (e.g: controller = "BlockGlobalInfo"), so dashboard controller can
- * instantiate it
- * @package chamilo.dashboard
- */
- class BlockGlobalInfo extends Block
- {
- private $user_id;
- private $courses;
- private $path;
- private $permission = array();
- /**
- * Constructor
- */
- public function __construct ($user_id)
- {
- $this->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 = array();
- $content = $this->get_content_html();
- $html = '
- <div class="panel panel-default" id="intro">
- <div class="panel-heading">'.get_lang('GlobalPlatformInformation').'
- <div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
- <em class="fa fa-times"></em>
- </a></div>
- </div>
- <div class="panel-body">
- '.$content.'
- </div>
- </div>
- ';
- $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 = '<div style="margin:10px;">';
- $content = '<h4>'.get_lang('GlobalPlatformInformation').'</h4>';
- $data_table = null;
- if (!empty($global_data)) {
- $data_table = '<table class="table table-bordered" width:"95%">';
- $i = 1;
- foreach ($global_data as $data) {
- if ($i%2 == 0) {
- $class_tr = 'row_odd';
- } else {
- $class_tr = 'row_even';
- }
- $data_table .= '<tr class="'.$class_tr.'">';
- foreach ($data as $cell) {
- $data_table .= '<td align="right">'.$cell.'</td>';
- }
- $data_table .= '</tr>';
- $i++;
- }
- $data_table .= '</table>';
- } else {
- $data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
- }
- $content .= $data_table;
- //$content .= '</div>';
- return $content;
- }
- /**
- * Get global information data
- * @return array
- */
- 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 = array(
- array(get_lang('CountUsers'), '<a href="'.$path.'admin/user_list.php">'.Statistics::countUsers().'</a>'),
- // Check only active users
- array(get_lang('NumberOfUsersActive'), '<a href="'.$path.'admin/user_list.php?keyword_firstname=&keyword_lastname=&keyword_username=&keyword_email=&keyword_officialcode=&keyword_status=%25&keyword_active=1&submit=&_qf__advanced_search=">'.Statistics::countUsers(null, null, null, true).'</a>'),
- // Check number of courses
- array(get_lang('NumberOfCoursesTotal'), '<a href="'.$path.'admin/course_list.php">'.Statistics::countCourses().'</a>'),
- array(get_lang('NumberOfCoursesPublic'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_OPEN_WORLD.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_OPEN_WORLD).'</a>'),
- array(get_lang('NumberOfCoursesOpen'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_OPEN_PLATFORM.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_OPEN_PLATFORM).'</a>'),
- array(get_lang('NumberOfCoursesPrivate'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_REGISTERED.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_REGISTERED).'</a>'),
- array(get_lang('NumberOfCoursesClosed'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_CLOSED.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_CLOSED).'</a>'),
- array(get_lang('NumberOfCoursesHidden'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_HIDDEN.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility(COURSE_VISIBILITY_HIDDEN).'</a>')
- );
- return $global_info;
- }
- }
|