|
1
|
|
|
<?php |
|
2
|
|
|
/* See license terms in /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* This file is part of global info block plugin for dashboard, |
|
6
|
|
|
* it should be required inside the dashboard controller for |
|
7
|
|
|
* showing it into the dashboard interface. |
|
8
|
|
|
* |
|
9
|
|
|
* @package chamilo.dashboard |
|
10
|
|
|
* |
|
11
|
|
|
* @author Yannick Warnier |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* This class is used like controller for this global info block plugin |
|
16
|
|
|
* the class name must be registered inside path.info file |
|
17
|
|
|
* (e.g: controller = "BlockGlobalInfo"), so dashboard controller can |
|
18
|
|
|
* instantiate it. |
|
19
|
|
|
* |
|
20
|
|
|
* @package chamilo.dashboard |
|
21
|
|
|
*/ |
|
22
|
|
|
class BlockGlobalInfo extends Block |
|
23
|
|
|
{ |
|
24
|
|
|
private $user_id; |
|
25
|
|
|
private $courses; |
|
|
|
|
|
|
26
|
|
|
private $permission = []; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @param int $user_id |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct($user_id) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->user_id = $user_id; |
|
36
|
|
|
$this->path = 'block_global_info'; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* This method check if a user is allowed to see the block inside dashboard interface. |
|
41
|
|
|
* |
|
42
|
|
|
* @param int User id |
|
43
|
|
|
* |
|
44
|
|
|
* @return bool Is block visible for user |
|
45
|
|
|
*/ |
|
46
|
|
|
public function is_block_visible_for_user($user_id) |
|
47
|
|
|
{ |
|
48
|
|
|
$user_info = api_get_user_info($user_id); |
|
49
|
|
|
$user_status = $user_info['status']; |
|
50
|
|
|
$is_block_visible_for_user = false; |
|
51
|
|
|
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
52
|
|
|
$is_block_visible_for_user = true; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
return $is_block_visible_for_user; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* This method return content html containing information |
|
60
|
|
|
* about courses and its position for showing it inside dashboard interface |
|
61
|
|
|
* it's important to use the name 'get_block' for beeing used from dashboard controller. |
|
62
|
|
|
* |
|
63
|
|
|
* @return array column and content html |
|
64
|
|
|
*/ |
|
65
|
|
|
public function get_block() |
|
66
|
|
|
{ |
|
67
|
|
|
$column = 2; |
|
68
|
|
|
$data = []; |
|
69
|
|
|
$html = $this->getBlockCard( |
|
70
|
|
|
get_lang('GlobalPlatformInformation'), |
|
71
|
|
|
$this->getContent() |
|
72
|
|
|
); |
|
73
|
|
|
$data['column'] = $column; |
|
74
|
|
|
$data['content_html'] = $html; |
|
75
|
|
|
|
|
76
|
|
|
return $data; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface. |
|
81
|
|
|
* |
|
82
|
|
|
* @return string content html |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getContent() |
|
85
|
|
|
{ |
|
86
|
|
|
$global_data = $this->get_global_information_data(); |
|
87
|
|
|
$data_table = null; |
|
88
|
|
|
if (!empty($global_data)) { |
|
89
|
|
|
$data_table = '<table class="table table-bordered">'; |
|
90
|
|
|
$i = 1; |
|
91
|
|
|
foreach ($global_data as $data) { |
|
92
|
|
|
if ($i % 2 == 0) { |
|
93
|
|
|
$class_tr = 'row_odd'; |
|
94
|
|
|
} else { |
|
95
|
|
|
$class_tr = 'row_even'; |
|
96
|
|
|
} |
|
97
|
|
|
$data_table .= '<tr class="'.$class_tr.'">'; |
|
98
|
|
|
foreach ($data as $cell) { |
|
99
|
|
|
$data_table .= '<td align="right">'.$cell.'</td>'; |
|
100
|
|
|
} |
|
101
|
|
|
$data_table .= '</tr>'; |
|
102
|
|
|
$i++; |
|
103
|
|
|
} |
|
104
|
|
|
$data_table .= '</table>'; |
|
105
|
|
|
} else { |
|
106
|
|
|
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform'); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
return $data_table; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Get global information data. |
|
114
|
|
|
* |
|
115
|
|
|
* @return array |
|
116
|
|
|
*/ |
|
117
|
|
|
public function get_global_information_data() |
|
118
|
|
|
{ |
|
119
|
|
|
// Two-dimensional array with data about the system |
|
120
|
|
|
$path = api_get_path(WEB_CODE_PATH); |
|
121
|
|
|
// Check total number of users |
|
122
|
|
|
$global_info = [ |
|
123
|
|
|
[get_lang('CountUsers'), '<a href="'.$path.'admin/user_list.php">'.Statistics::countUsers().'</a>'], |
|
124
|
|
|
// Check only active users |
|
125
|
|
|
[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>'], |
|
126
|
|
|
// Check number of courses |
|
127
|
|
|
[get_lang('NumberOfCoursesTotal'), '<a href="'.$path.'admin/course_list.php">'.Statistics::countCourses().'</a>'], |
|
128
|
|
|
[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>'], |
|
129
|
|
|
[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>'], |
|
130
|
|
|
[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>'], |
|
131
|
|
|
[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>'], |
|
132
|
|
|
[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>'], |
|
133
|
|
|
]; |
|
134
|
|
|
|
|
135
|
|
|
return $global_info; |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|