@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | // defined terms, and this should prove the concept that there are much |
69 | 69 | // more variables than what we really use |
70 | 70 | if (count($usedTerms)<1) { |
71 | - die("No used terms<br />\n"); |
|
71 | + die("No used terms<br />\n"); |
|
72 | 72 | } else { |
73 | - echo "The following terms were defined but never used: <br />\n<table>"; |
|
73 | + echo "The following terms were defined but never used: <br />\n<table>"; |
|
74 | 74 | } |
75 | 75 | $i = 1; |
76 | 76 | foreach ($defined_terms as $term => $file) { |
77 | - // remove "lang" prefix just in case |
|
78 | - if (substr($term,0,4)=='lang') { $term = substr($term,4); } |
|
79 | - if (!isset($usedTerms[$term])) { |
|
77 | + // remove "lang" prefix just in case |
|
78 | + if (substr($term,0,4)=='lang') { $term = substr($term,4); } |
|
79 | + if (!isset($usedTerms[$term])) { |
|
80 | 80 | echo "<tr><td>$i</td><td>$term</td></tr>\n"; |
81 | 81 | $i++; |
82 | - } |
|
82 | + } |
|
83 | 83 | } |
84 | 84 | echo "</table>\n"; |
85 | 85 | |
@@ -88,17 +88,17 @@ discard block |
||
88 | 88 | $list = scandir($base_path); |
89 | 89 | $files = array(); |
90 | 90 | foreach ($list as $item) { |
91 | - if (substr($item,0,1)=='.') {continue;} |
|
91 | + if (substr($item,0,1)=='.') {continue;} |
|
92 | 92 | $special_dirs = array(api_get_path(SYS_TEST_PATH),api_get_path(SYS_COURSE_PATH),api_get_path(SYS_LANG_PATH),api_get_path(SYS_ARCHIVE_PATH)); |
93 | 93 | if (in_array($base_path.$item.'/',$special_dirs)) {continue;} |
94 | 94 | if (is_dir($base_path.$item)) { |
95 | - $files = array_merge($files,get_all_php_files($base_path.$item.'/')); |
|
95 | + $files = array_merge($files,get_all_php_files($base_path.$item.'/')); |
|
96 | 96 | } else { |
97 | 97 | //only analyse php files |
98 | 98 | $sub = substr($item,-4); |
99 | - if ($sub == '.php' or $sub == '.tpl') { |
|
99 | + if ($sub == '.php' or $sub == '.tpl') { |
|
100 | 100 | $files[] = $base_path.$item; |
101 | - } |
|
101 | + } |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | $list = null; |
@@ -351,9 +351,9 @@ |
||
351 | 351 | . '&externalRoomType=' . $room->externalRoomType; |
352 | 352 | if ($room->allowRecording) { |
353 | 353 | $url .= '&allowUserQuestions=' . $this->var_to_str($room->allowUserQuestions) |
354 | - . '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly) |
|
355 | - . '&waitForRecording=' . $this->var_to_str($room->waitForRecording) |
|
356 | - . '&allowRecording=' . $this->var_to_str($room->allowRecording); |
|
354 | + . '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly) |
|
355 | + . '&waitForRecording=' . $this->var_to_str($room->waitForRecording) |
|
356 | + . '&allowRecording=' . $this->var_to_str($room->allowRecording); |
|
357 | 357 | } elseif ($room->isAudioOnly) { |
358 | 358 | $url .= '&isAudioOnly=' . $this->var_to_str($room->isAudioOnly); |
359 | 359 | } |
@@ -36,114 +36,114 @@ |
||
36 | 36 | */ |
37 | 37 | class LoggerRendererMap { |
38 | 38 | |
39 | - /** |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - private $map; |
|
39 | + /** |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + private $map; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var LoggerDefaultRenderer |
|
46 | - */ |
|
47 | - private $defaultRenderer; |
|
44 | + /** |
|
45 | + * @var LoggerDefaultRenderer |
|
46 | + */ |
|
47 | + private $defaultRenderer; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Constructor |
|
51 | - */ |
|
52 | - public function __construct() { |
|
53 | - $this->map = array(); |
|
54 | - $this->defaultRenderer = new LoggerRendererDefault(); |
|
55 | - } |
|
49 | + /** |
|
50 | + * Constructor |
|
51 | + */ |
|
52 | + public function __construct() { |
|
53 | + $this->map = array(); |
|
54 | + $this->defaultRenderer = new LoggerRendererDefault(); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Add a renderer to a hierarchy passed as parameter. |
|
59 | - * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
60 | - * |
|
61 | - * @param LoggerHierarchy $repository a logger repository. |
|
62 | - * @param string $renderedClassName |
|
63 | - * @param string $renderingClassName |
|
64 | - * @static |
|
65 | - */ |
|
66 | - public function addRenderer($renderedClassName, $renderingClassName) { |
|
67 | - $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
|
68 | - if($renderer == null) { |
|
69 | - return; |
|
70 | - } else { |
|
71 | - $this->put($renderedClassName, $renderer); |
|
72 | - } |
|
73 | - } |
|
57 | + /** |
|
58 | + * Add a renderer to a hierarchy passed as parameter. |
|
59 | + * Note that hierarchy must implement getRendererMap() and setRenderer() methods. |
|
60 | + * |
|
61 | + * @param LoggerHierarchy $repository a logger repository. |
|
62 | + * @param string $renderedClassName |
|
63 | + * @param string $renderingClassName |
|
64 | + * @static |
|
65 | + */ |
|
66 | + public function addRenderer($renderedClassName, $renderingClassName) { |
|
67 | + $renderer = LoggerReflectionUtils::createObject($renderingClassName); |
|
68 | + if($renderer == null) { |
|
69 | + return; |
|
70 | + } else { |
|
71 | + $this->put($renderedClassName, $renderer); |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * Find the appropriate renderer for the class type of the |
|
78 | - * <var>o</var> parameter. |
|
79 | - * |
|
80 | - * This is accomplished by calling the {@link getByObject()} |
|
81 | - * method if <var>o</var> is object or using {@link LoggerRendererDefault}. |
|
82 | - * Once a renderer is found, it is applied on the object <var>o</var> and |
|
83 | - * the result is returned as a string. |
|
84 | - * |
|
85 | - * @param mixed $o |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function findAndRender($o) { |
|
89 | - if($o == null) { |
|
90 | - return null; |
|
91 | - } else { |
|
92 | - if(is_object($o)) { |
|
93 | - $renderer = $this->getByObject($o); |
|
94 | - if($renderer !== null) { |
|
95 | - return $renderer->render($o); |
|
96 | - } else { |
|
97 | - return null; |
|
98 | - } |
|
99 | - } else { |
|
100 | - $renderer = $this->defaultRenderer; |
|
101 | - return $renderer->render($o); |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
76 | + /** |
|
77 | + * Find the appropriate renderer for the class type of the |
|
78 | + * <var>o</var> parameter. |
|
79 | + * |
|
80 | + * This is accomplished by calling the {@link getByObject()} |
|
81 | + * method if <var>o</var> is object or using {@link LoggerRendererDefault}. |
|
82 | + * Once a renderer is found, it is applied on the object <var>o</var> and |
|
83 | + * the result is returned as a string. |
|
84 | + * |
|
85 | + * @param mixed $o |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function findAndRender($o) { |
|
89 | + if($o == null) { |
|
90 | + return null; |
|
91 | + } else { |
|
92 | + if(is_object($o)) { |
|
93 | + $renderer = $this->getByObject($o); |
|
94 | + if($renderer !== null) { |
|
95 | + return $renderer->render($o); |
|
96 | + } else { |
|
97 | + return null; |
|
98 | + } |
|
99 | + } else { |
|
100 | + $renderer = $this->defaultRenderer; |
|
101 | + return $renderer->render($o); |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
108 | - * class of the object parameter. |
|
109 | - * |
|
110 | - * @param mixed $o |
|
111 | - * @return string |
|
112 | - */ |
|
113 | - public function getByObject($o) { |
|
114 | - return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
115 | - } |
|
106 | + /** |
|
107 | + * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the |
|
108 | + * class of the object parameter. |
|
109 | + * |
|
110 | + * @param mixed $o |
|
111 | + * @return string |
|
112 | + */ |
|
113 | + public function getByObject($o) { |
|
114 | + return ($o == null) ? null : $this->getByClassName(get_class($o)); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * Search the parents of <var>clazz</var> for a renderer. |
|
120 | - * |
|
121 | - * The renderer closest in the hierarchy will be returned. If no |
|
122 | - * renderers could be found, then the default renderer is returned. |
|
123 | - * |
|
124 | - * @param string $class |
|
125 | - * @return LoggerRendererObject |
|
126 | - */ |
|
127 | - public function getByClassName($class) { |
|
128 | - $r = null; |
|
129 | - for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
130 | - if(isset($this->map[$c])) { |
|
131 | - return $this->map[$c]; |
|
132 | - } |
|
133 | - } |
|
134 | - return $this->defaultRenderer; |
|
135 | - } |
|
118 | + /** |
|
119 | + * Search the parents of <var>clazz</var> for a renderer. |
|
120 | + * |
|
121 | + * The renderer closest in the hierarchy will be returned. If no |
|
122 | + * renderers could be found, then the default renderer is returned. |
|
123 | + * |
|
124 | + * @param string $class |
|
125 | + * @return LoggerRendererObject |
|
126 | + */ |
|
127 | + public function getByClassName($class) { |
|
128 | + $r = null; |
|
129 | + for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) { |
|
130 | + if(isset($this->map[$c])) { |
|
131 | + return $this->map[$c]; |
|
132 | + } |
|
133 | + } |
|
134 | + return $this->defaultRenderer; |
|
135 | + } |
|
136 | 136 | |
137 | - public function clear() { |
|
138 | - $this->map = array(); |
|
139 | - } |
|
137 | + public function clear() { |
|
138 | + $this->map = array(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * Register a {@link LoggerRendererObject} for <var>clazz</var>. |
|
143 | - * @param string $class |
|
144 | - * @param LoggerRendererObject $or |
|
145 | - */ |
|
146 | - private function put($class, $or) { |
|
147 | - $this->map[strtolower($class)] = $or; |
|
148 | - } |
|
141 | + /** |
|
142 | + * Register a {@link LoggerRendererObject} for <var>clazz</var>. |
|
143 | + * @param string $class |
|
144 | + * @param LoggerRendererObject $or |
|
145 | + */ |
|
146 | + private function put($class, $or) { |
|
147 | + $this->map[strtolower($class)] = $or; |
|
148 | + } |
|
149 | 149 | } |
@@ -24,32 +24,32 @@ discard block |
||
24 | 24 | private $path; |
25 | 25 | private $permission = array(DRH); |
26 | 26 | |
27 | - /** |
|
28 | - * Controller |
|
29 | - */ |
|
27 | + /** |
|
28 | + * Controller |
|
29 | + */ |
|
30 | 30 | public function __construct ($user_id) |
31 | 31 | { |
32 | - $this->user_id = $user_id; |
|
33 | - $this->path = 'block_teacher'; |
|
34 | - if ($this->is_block_visible_for_user($user_id)) { |
|
35 | - $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); |
|
36 | - } |
|
32 | + $this->user_id = $user_id; |
|
33 | + $this->path = 'block_teacher'; |
|
34 | + if ($this->is_block_visible_for_user($user_id)) { |
|
35 | + $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | - * This method check if a user is allowed to see the block inside dashboard interface |
|
41 | - * @param int User id |
|
42 | - * @return bool Is block visible for user |
|
43 | - */ |
|
40 | + * This method check if a user is allowed to see the block inside dashboard interface |
|
41 | + * @param int User id |
|
42 | + * @return bool Is block visible for user |
|
43 | + */ |
|
44 | 44 | public function is_block_visible_for_user($user_id) |
45 | 45 | { |
46 | - $user_info = api_get_user_info($user_id); |
|
47 | - $user_status = $user_info['status']; |
|
48 | - $is_block_visible_for_user = false; |
|
49 | - if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
50 | - $is_block_visible_for_user = true; |
|
51 | - } |
|
52 | - return $is_block_visible_for_user; |
|
46 | + $user_info = api_get_user_info($user_id); |
|
47 | + $user_status = $user_info['status']; |
|
48 | + $is_block_visible_for_user = false; |
|
49 | + if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { |
|
50 | + $is_block_visible_for_user = true; |
|
51 | + } |
|
52 | + return $is_block_visible_for_user; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | public function get_block() |
61 | 61 | { |
62 | 62 | |
63 | - global $charset; |
|
64 | - $column = 1; |
|
65 | - $data = array(); |
|
66 | - $teacher_content_html = $this->get_teachers_content_html_for_drh(); |
|
63 | + global $charset; |
|
64 | + $column = 1; |
|
65 | + $data = array(); |
|
66 | + $teacher_content_html = $this->get_teachers_content_html_for_drh(); |
|
67 | 67 | |
68 | - $html = ' |
|
68 | + $html = ' |
|
69 | 69 | <div class="panel panel-default" id="intro"> |
70 | 70 | <div class="panel-heading"> |
71 | 71 | '.get_lang('TeachersInformationsList').' |
@@ -79,27 +79,27 @@ discard block |
||
79 | 79 | </div> |
80 | 80 | '; |
81 | 81 | |
82 | - $data['column'] = $column; |
|
83 | - $data['content_html'] = $html; |
|
82 | + $data['column'] = $column; |
|
83 | + $data['content_html'] = $html; |
|
84 | 84 | |
85 | - return $data; |
|
85 | + return $data; |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * This method return a content html, it's used inside get_block method for showing it inside dashboard interface |
|
91 | - * @return string content html |
|
92 | - */ |
|
90 | + * This method return a content html, it's used inside get_block method for showing it inside dashboard interface |
|
91 | + * @return string content html |
|
92 | + */ |
|
93 | 93 | public function get_teachers_content_html_for_platform_admin() |
94 | 94 | { |
95 | - $teachers = $this->teachers; |
|
96 | - //$content = '<div style="margin:10px;">'; |
|
97 | - $content = '<h4>'.get_lang('YourTeachers').'</h4>'; |
|
95 | + $teachers = $this->teachers; |
|
96 | + //$content = '<div style="margin:10px;">'; |
|
97 | + $content = '<h4>'.get_lang('YourTeachers').'</h4>'; |
|
98 | 98 | |
99 | 99 | $teachers_table = null; |
100 | - if (count($teachers) > 0) { |
|
101 | - $teachers_table .= '<table class="data_table" width:"95%">'; |
|
102 | - $teachers_table .= ' |
|
100 | + if (count($teachers) > 0) { |
|
101 | + $teachers_table .= '<table class="data_table" width:"95%">'; |
|
102 | + $teachers_table .= ' |
|
103 | 103 | <tr> |
104 | 104 | <th>'.get_lang('User').'</th> |
105 | 105 | <th>'.get_lang('TimeSpentOnThePlatform').'</th> |
@@ -107,103 +107,103 @@ discard block |
||
107 | 107 | </tr> |
108 | 108 | '; |
109 | 109 | |
110 | - $i = 1; |
|
111 | - foreach ($teachers as $teacher) { |
|
110 | + $i = 1; |
|
111 | + foreach ($teachers as $teacher) { |
|
112 | 112 | |
113 | - $teacher_id = $teacher['user_id']; |
|
114 | - $firstname = $teacher['firstname']; |
|
115 | - $lastname = $teacher['lastname']; |
|
116 | - $username = $teacher['username']; |
|
113 | + $teacher_id = $teacher['user_id']; |
|
114 | + $firstname = $teacher['firstname']; |
|
115 | + $lastname = $teacher['lastname']; |
|
116 | + $username = $teacher['username']; |
|
117 | 117 | |
118 | - $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id)); |
|
119 | - $last_connection = Tracking :: get_last_connection_date($teacher_id); |
|
118 | + $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id)); |
|
119 | + $last_connection = Tracking :: get_last_connection_date($teacher_id); |
|
120 | 120 | |
121 | - if ($i%2 == 0) $class_tr = 'row_odd'; |
|
122 | - else $class_tr = 'row_even'; |
|
121 | + if ($i%2 == 0) $class_tr = 'row_odd'; |
|
122 | + else $class_tr = 'row_even'; |
|
123 | 123 | |
124 | - $teachers_table .= ' |
|
124 | + $teachers_table .= ' |
|
125 | 125 | <tr class="'.$class_tr.'"> |
126 | 126 | <td>'.api_get_person_name($firstname,$lastname).' ('.$username.')</td> |
127 | 127 | <td align="right">'.$time_on_platform.'</td> |
128 | 128 | <td align="right">'.$last_connection.'</td> |
129 | 129 | </tr> |
130 | 130 | '; |
131 | - $i++; |
|
132 | - } |
|
133 | - $teachers_table .= '</table>'; |
|
134 | - } else { |
|
135 | - $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); |
|
136 | - } |
|
131 | + $i++; |
|
132 | + } |
|
133 | + $teachers_table .= '</table>'; |
|
134 | + } else { |
|
135 | + $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); |
|
136 | + } |
|
137 | 137 | |
138 | - $content .= $teachers_table; |
|
138 | + $content .= $teachers_table; |
|
139 | 139 | |
140 | - if (count($teachers) > 0) { |
|
141 | - $content .= '<div style="text-align:right;margin-top:10px;"> |
|
140 | + if (count($teachers) > 0) { |
|
141 | + $content .= '<div style="text-align:right;margin-top:10px;"> |
|
142 | 142 | <a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin">'.get_lang('SeeMore').'</a></div>'; |
143 | - } |
|
143 | + } |
|
144 | 144 | |
145 | - //$content .= '</div>'; |
|
145 | + //$content .= '</div>'; |
|
146 | 146 | |
147 | - return $content; |
|
148 | - } |
|
147 | + return $content; |
|
148 | + } |
|
149 | 149 | |
150 | - public function get_teachers_content_html_for_drh() |
|
150 | + public function get_teachers_content_html_for_drh() |
|
151 | 151 | { |
152 | - $teachers = $this->teachers; |
|
153 | - //$content = '<div style="margin:10px;">'; |
|
154 | - $content = '<h4>'.get_lang('YourTeachers').'</h4>'; |
|
152 | + $teachers = $this->teachers; |
|
153 | + //$content = '<div style="margin:10px;">'; |
|
154 | + $content = '<h4>'.get_lang('YourTeachers').'</h4>'; |
|
155 | 155 | $teachers_table = null; |
156 | - if (count($teachers) > 0) { |
|
157 | - $a_last_week = get_last_week(); |
|
158 | - $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); |
|
156 | + if (count($teachers) > 0) { |
|
157 | + $a_last_week = get_last_week(); |
|
158 | + $last_week = date('Y-m-d',$a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]); |
|
159 | 159 | |
160 | - $teachers_table .= '<table class="data_table" width:"95%">'; |
|
161 | - $teachers_table .= ' |
|
160 | + $teachers_table .= '<table class="data_table" width:"95%">'; |
|
161 | + $teachers_table .= ' |
|
162 | 162 | <tr> |
163 | 163 | <th>'.get_lang('User').'</th> |
164 | 164 | <th>'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th> |
165 | 165 | </tr> |
166 | 166 | '; |
167 | 167 | |
168 | - $i = 1; |
|
169 | - foreach ($teachers as $teacher) { |
|
168 | + $i = 1; |
|
169 | + foreach ($teachers as $teacher) { |
|
170 | 170 | |
171 | - $teacher_id = $teacher['user_id']; |
|
172 | - $firstname = $teacher['firstname']; |
|
173 | - $lastname = $teacher['lastname']; |
|
174 | - $username = $teacher['username']; |
|
175 | - $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id,true)); |
|
171 | + $teacher_id = $teacher['user_id']; |
|
172 | + $firstname = $teacher['firstname']; |
|
173 | + $lastname = $teacher['lastname']; |
|
174 | + $username = $teacher['username']; |
|
175 | + $time_on_platform = api_time_to_hms(Tracking :: get_time_spent_on_the_platform($teacher_id,true)); |
|
176 | 176 | |
177 | - if ($i%2 == 0) $class_tr = 'row_odd'; |
|
178 | - else $class_tr = 'row_even'; |
|
179 | - $teachers_table .= '<tr class="'.$class_tr.'"> |
|
177 | + if ($i%2 == 0) $class_tr = 'row_odd'; |
|
178 | + else $class_tr = 'row_even'; |
|
179 | + $teachers_table .= '<tr class="'.$class_tr.'"> |
|
180 | 180 | <td>'.api_get_person_name($firstname,$lastname).' ('.$username.')</td> |
181 | 181 | <td align="right">'.$time_on_platform.'</td> |
182 | 182 | </tr>'; |
183 | 183 | |
184 | - $i++; |
|
185 | - } |
|
186 | - $teachers_table .= '</table>'; |
|
187 | - } else { |
|
188 | - $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); |
|
189 | - } |
|
184 | + $i++; |
|
185 | + } |
|
186 | + $teachers_table .= '</table>'; |
|
187 | + } else { |
|
188 | + $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); |
|
189 | + } |
|
190 | 190 | |
191 | - $content .= $teachers_table; |
|
191 | + $content .= $teachers_table; |
|
192 | 192 | |
193 | - if (count($teachers) > 0) { |
|
194 | - $content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/teachers.php">'.get_lang('SeeMore').'</a></div>'; |
|
195 | - } |
|
196 | - //$content .= '</div>'; |
|
193 | + if (count($teachers) > 0) { |
|
194 | + $content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/teachers.php">'.get_lang('SeeMore').'</a></div>'; |
|
195 | + } |
|
196 | + //$content .= '</div>'; |
|
197 | 197 | |
198 | - return $content; |
|
199 | - } |
|
198 | + return $content; |
|
199 | + } |
|
200 | 200 | |
201 | 201 | /** |
202 | - * Get number of teachers |
|
203 | - * @return int |
|
204 | - */ |
|
205 | - function get_number_of_teachers() |
|
202 | + * Get number of teachers |
|
203 | + * @return int |
|
204 | + */ |
|
205 | + function get_number_of_teachers() |
|
206 | 206 | { |
207 | - return count($this->teachers); |
|
208 | - } |
|
207 | + return count($this->teachers); |
|
208 | + } |
|
209 | 209 | } |
@@ -64,83 +64,83 @@ |
||
64 | 64 | */ |
65 | 65 | class LoggerFilterLevelRange extends LoggerFilter { |
66 | 66 | |
67 | - /** |
|
68 | - * @var boolean |
|
69 | - */ |
|
70 | - private $acceptOnMatch = true; |
|
67 | + /** |
|
68 | + * @var boolean |
|
69 | + */ |
|
70 | + private $acceptOnMatch = true; |
|
71 | 71 | |
72 | - /** |
|
73 | - * @var LoggerLevel |
|
74 | - */ |
|
75 | - private $levelMin; |
|
72 | + /** |
|
73 | + * @var LoggerLevel |
|
74 | + */ |
|
75 | + private $levelMin; |
|
76 | 76 | |
77 | - /** |
|
78 | - * @var LoggerLevel |
|
79 | - */ |
|
80 | - private $levelMax; |
|
77 | + /** |
|
78 | + * @var LoggerLevel |
|
79 | + */ |
|
80 | + private $levelMax; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param boolean $acceptOnMatch |
|
84 | - */ |
|
85 | - public function setAcceptOnMatch($acceptOnMatch) { |
|
86 | - $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
87 | - } |
|
82 | + /** |
|
83 | + * @param boolean $acceptOnMatch |
|
84 | + */ |
|
85 | + public function setAcceptOnMatch($acceptOnMatch) { |
|
86 | + $this->acceptOnMatch = LoggerOptionConverter::toBoolean($acceptOnMatch, true); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @param string $l the level min to match |
|
91 | - */ |
|
92 | - public function setLevelMin($l) { |
|
93 | - if($l instanceof LoggerLevel) { |
|
94 | - $this->levelMin = $l; |
|
95 | - } else { |
|
96 | - $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
97 | - } |
|
98 | - } |
|
89 | + /** |
|
90 | + * @param string $l the level min to match |
|
91 | + */ |
|
92 | + public function setLevelMin($l) { |
|
93 | + if($l instanceof LoggerLevel) { |
|
94 | + $this->levelMin = $l; |
|
95 | + } else { |
|
96 | + $this->levelMin = LoggerOptionConverter::toLevel($l, null); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | - /** |
|
101 | - * @param string $l the level max to match |
|
102 | - */ |
|
103 | - public function setLevelMax($l) { |
|
104 | - if($l instanceof LoggerLevel) { |
|
105 | - $this->levelMax = $l; |
|
106 | - } else { |
|
107 | - $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
108 | - } |
|
109 | - } |
|
100 | + /** |
|
101 | + * @param string $l the level max to match |
|
102 | + */ |
|
103 | + public function setLevelMax($l) { |
|
104 | + if($l instanceof LoggerLevel) { |
|
105 | + $this->levelMax = $l; |
|
106 | + } else { |
|
107 | + $this->levelMax = LoggerOptionConverter::toLevel($l, null); |
|
108 | + } |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Return the decision of this filter. |
|
113 | - * |
|
114 | - * @param LoggerLoggingEvent $event |
|
115 | - * @return integer |
|
116 | - */ |
|
117 | - public function decide(LoggerLoggingEvent $event) { |
|
118 | - $level = $event->getLevel(); |
|
111 | + /** |
|
112 | + * Return the decision of this filter. |
|
113 | + * |
|
114 | + * @param LoggerLoggingEvent $event |
|
115 | + * @return integer |
|
116 | + */ |
|
117 | + public function decide(LoggerLoggingEvent $event) { |
|
118 | + $level = $event->getLevel(); |
|
119 | 119 | |
120 | - if($this->levelMin !== null) { |
|
121 | - if($level->isGreaterOrEqual($this->levelMin) == false) { |
|
122 | - // level of event is less than minimum |
|
123 | - return LoggerFilter::DENY; |
|
124 | - } |
|
125 | - } |
|
120 | + if($this->levelMin !== null) { |
|
121 | + if($level->isGreaterOrEqual($this->levelMin) == false) { |
|
122 | + // level of event is less than minimum |
|
123 | + return LoggerFilter::DENY; |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | - if($this->levelMax !== null) { |
|
128 | - if($level->toInt() > $this->levelMax->toInt()) { |
|
129 | - // level of event is greater than maximum |
|
130 | - // Alas, there is no Level.isGreater method. and using |
|
131 | - // a combo of isGreaterOrEqual && !Equal seems worse than |
|
132 | - // checking the int values of the level objects.. |
|
133 | - return LoggerFilter::DENY; |
|
134 | - } |
|
135 | - } |
|
127 | + if($this->levelMax !== null) { |
|
128 | + if($level->toInt() > $this->levelMax->toInt()) { |
|
129 | + // level of event is greater than maximum |
|
130 | + // Alas, there is no Level.isGreater method. and using |
|
131 | + // a combo of isGreaterOrEqual && !Equal seems worse than |
|
132 | + // checking the int values of the level objects.. |
|
133 | + return LoggerFilter::DENY; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - if($this->acceptOnMatch) { |
|
138 | - // this filter set up to bypass later filters and always return |
|
139 | - // accept if level in range |
|
140 | - return LoggerFilter::ACCEPT; |
|
141 | - } else { |
|
142 | - // event is ok for this filter; allow later filters to have a look.. |
|
143 | - return LoggerFilter::NEUTRAL; |
|
144 | - } |
|
145 | - } |
|
137 | + if($this->acceptOnMatch) { |
|
138 | + // this filter set up to bypass later filters and always return |
|
139 | + // accept if level in range |
|
140 | + return LoggerFilter::ACCEPT; |
|
141 | + } else { |
|
142 | + // event is ok for this filter; allow later filters to have a look.. |
|
143 | + return LoggerFilter::NEUTRAL; |
|
144 | + } |
|
145 | + } |
|
146 | 146 | } |
@@ -48,7 +48,7 @@ |
||
48 | 48 | while ($session = Database :: fetch_array($rs)) { |
49 | 49 | $i++; |
50 | 50 | if ($i<=10) { |
51 | - $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />'; |
|
51 | + $return .= '<a href="#" onclick="add_user_to_url(\''.addslashes($session['id']).'\',\''.addslashes($session['name']).' ('.addslashes($session['id']).')'.'\')">'.$session['name'].' </a><br />'; |
|
52 | 52 | } else { |
53 | 53 | $return .= '...<br />'; |
54 | 54 | } |
@@ -24,28 +24,28 @@ |
||
24 | 24 | function search_courses($needle,$type) |
25 | 25 | { |
26 | 26 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
27 | - $xajax_response = new xajaxResponse(); |
|
28 | - $return = ''; |
|
29 | - if(!empty($needle) && !empty($type)) { |
|
30 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
31 | - $charset = api_get_system_encoding(); |
|
32 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
33 | - $needle = Database::escape_string($needle); |
|
27 | + $xajax_response = new xajaxResponse(); |
|
28 | + $return = ''; |
|
29 | + if(!empty($needle) && !empty($type)) { |
|
30 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
31 | + $charset = api_get_system_encoding(); |
|
32 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
33 | + $needle = Database::escape_string($needle); |
|
34 | 34 | |
35 | - $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
35 | + $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
36 | 36 | |
37 | - $rs = Database::query($sql); |
|
38 | - $course_list = array(); |
|
37 | + $rs = Database::query($sql); |
|
38 | + $course_list = array(); |
|
39 | 39 | |
40 | - $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
41 | - while($course = Database :: fetch_array($rs)) { |
|
42 | - $course_list[] = $course['id']; |
|
43 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | - } |
|
45 | - $return .= '</select>'; |
|
46 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
47 | - } |
|
48 | - $_SESSION['course_list'] = $course_list; |
|
49 | - return $xajax_response; |
|
50 | - } |
|
40 | + $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
41 | + while($course = Database :: fetch_array($rs)) { |
|
42 | + $course_list[] = $course['id']; |
|
43 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | + } |
|
45 | + $return .= '</select>'; |
|
46 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
47 | + } |
|
48 | + $_SESSION['course_list'] = $course_list; |
|
49 | + return $xajax_response; |
|
50 | + } |
|
51 | 51 | } |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | CONST VISIBLE_STUDENT = 2; |
11 | 11 | CONST VISIBLE_TEACHER = 3; |
12 | 12 | |
13 | - /** |
|
14 | - * Displays all announcements |
|
15 | - * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
16 | - * @param int $id The identifier of the announcement to display |
|
17 | - */ |
|
18 | - public static function display_announcements($visible, $id = -1) |
|
13 | + /** |
|
14 | + * Displays all announcements |
|
15 | + * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
16 | + * @param int $id The identifier of the announcement to display |
|
17 | + */ |
|
18 | + public static function display_announcements($visible, $id = -1) |
|
19 | 19 | { |
20 | - $user_selected_language = api_get_interface_language(); |
|
21 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
20 | + $user_selected_language = api_get_interface_language(); |
|
21 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
22 | 22 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
23 | - $userGroup = new UserGroup(); |
|
23 | + $userGroup = new UserGroup(); |
|
24 | 24 | |
25 | 25 | $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
26 | 26 | $groups = array(); |
@@ -55,47 +55,47 @@ discard block |
||
55 | 55 | WHERE group_id in $groups_string |
56 | 56 | ) "; |
57 | 57 | } |
58 | - $current_access_url_id = 1; |
|
59 | - if (api_is_multiple_url_enabled()) { |
|
60 | - $current_access_url_id = api_get_current_access_url_id(); |
|
61 | - } |
|
62 | - $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
63 | - $sql .= " ORDER BY date_start DESC LIMIT 0,7"; |
|
64 | - |
|
65 | - $announcements = Database::query($sql); |
|
66 | - if (Database::num_rows($announcements) > 0) { |
|
67 | - $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
68 | - $query_string = ereg_replace('&$', '', $query_string); |
|
69 | - $url = api_get_self(); |
|
70 | - echo '<div class="system_announcements">'; |
|
71 | - echo '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
72 | - echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>'; |
|
73 | - |
|
74 | - while ($announcement = Database::fetch_object($announcements)) { |
|
75 | - if ($id != $announcement->id) { |
|
76 | - if (strlen($query_string) > 0) { |
|
77 | - $show_url = 'news_list.php#'.$announcement->id; |
|
78 | - } else { |
|
79 | - $show_url = 'news_list.php#'.$announcement->id; |
|
80 | - } |
|
81 | - $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
82 | - echo '<a name="'.$announcement->id.'"></a> |
|
58 | + $current_access_url_id = 1; |
|
59 | + if (api_is_multiple_url_enabled()) { |
|
60 | + $current_access_url_id = api_get_current_access_url_id(); |
|
61 | + } |
|
62 | + $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
63 | + $sql .= " ORDER BY date_start DESC LIMIT 0,7"; |
|
64 | + |
|
65 | + $announcements = Database::query($sql); |
|
66 | + if (Database::num_rows($announcements) > 0) { |
|
67 | + $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
68 | + $query_string = ereg_replace('&$', '', $query_string); |
|
69 | + $url = api_get_self(); |
|
70 | + echo '<div class="system_announcements">'; |
|
71 | + echo '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
72 | + echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>'; |
|
73 | + |
|
74 | + while ($announcement = Database::fetch_object($announcements)) { |
|
75 | + if ($id != $announcement->id) { |
|
76 | + if (strlen($query_string) > 0) { |
|
77 | + $show_url = 'news_list.php#'.$announcement->id; |
|
78 | + } else { |
|
79 | + $show_url = 'news_list.php#'.$announcement->id; |
|
80 | + } |
|
81 | + $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
82 | + echo '<a name="'.$announcement->id.'"></a> |
|
83 | 83 | <div class="system_announcement"> |
84 | 84 | <div class="system_announcement_title"><a name="ann'.$announcement->id.'" href="'.$show_url.'">'.$announcement->title.'</a></div><div class="system_announcement_date">'.$display_date.'</div> |
85 | 85 | </div>'; |
86 | - } else { |
|
87 | - echo '<div class="system_announcement"> |
|
86 | + } else { |
|
87 | + echo '<div class="system_announcement"> |
|
88 | 88 | <div class="system_announcement_title">' |
89 | - .$announcement->display_date.' |
|
89 | + .$announcement->display_date.' |
|
90 | 90 | <a name="ann'.$announcement->id.'" href="'.$url.'?'.$query_string.'#ann'.$announcement->id.'">'.$announcement->title.'</a> |
91 | 91 | </div>'; |
92 | - } |
|
93 | - echo '<br />'; |
|
94 | - } |
|
95 | - echo '</div>'; |
|
96 | - } |
|
97 | - return; |
|
98 | - } |
|
92 | + } |
|
93 | + echo '<br />'; |
|
94 | + } |
|
95 | + echo '</div>'; |
|
96 | + } |
|
97 | + return; |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @param $visible |
@@ -106,100 +106,100 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public static function display_all_announcements($visible, $id = -1, $start = 0,$user_id='') |
108 | 108 | { |
109 | - $user_selected_language = api_get_interface_language(); |
|
110 | - $start = intval($start); |
|
109 | + $user_selected_language = api_get_interface_language(); |
|
110 | + $start = intval($start); |
|
111 | 111 | $userGroup = new UserGroup(); |
112 | - $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
|
113 | - $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
112 | + $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
|
113 | + $temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(),0); |
|
114 | 114 | $groups = array(); |
115 | - foreach ($temp_user_groups as $user_group) { |
|
116 | - $groups = array_merge($groups, array($user_group['id'])); |
|
117 | - $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); |
|
118 | - } |
|
115 | + foreach ($temp_user_groups as $user_group) { |
|
116 | + $groups = array_merge($groups, array($user_group['id'])); |
|
117 | + $groups = array_merge($groups, $userGroup->get_parent_groups($user_group['id'])); |
|
118 | + } |
|
119 | 119 | |
120 | - // Checks if tables exists to not break platform not updated |
|
121 | - $groups_string = '('.implode($groups,',').')'; |
|
120 | + // Checks if tables exists to not break platform not updated |
|
121 | + $groups_string = '('.implode($groups,',').')'; |
|
122 | 122 | |
123 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
124 | - $now = api_get_utc_datetime(); |
|
123 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
124 | + $now = api_get_utc_datetime(); |
|
125 | 125 | |
126 | - $sql = "SELECT * FROM ".$db_table." |
|
126 | + $sql = "SELECT * FROM ".$db_table." |
|
127 | 127 | WHERE |
128 | 128 | (lang = '$user_selected_language' OR lang IS NULL) AND |
129 | 129 | ( '$now' >= date_start AND '$now' <= date_end) "; |
130 | 130 | |
131 | - switch ($visible) { |
|
132 | - case self::VISIBLE_GUEST : |
|
133 | - $sql .= " AND visible_guest = 1 "; |
|
134 | - break; |
|
135 | - case self::VISIBLE_STUDENT : |
|
136 | - $sql .= " AND visible_student = 1 "; |
|
137 | - break; |
|
138 | - case self::VISIBLE_TEACHER : |
|
139 | - $sql .= " AND visible_teacher = 1 "; |
|
140 | - break; |
|
141 | - } |
|
142 | - |
|
143 | - if (count($groups) > 0) { |
|
131 | + switch ($visible) { |
|
132 | + case self::VISIBLE_GUEST : |
|
133 | + $sql .= " AND visible_guest = 1 "; |
|
134 | + break; |
|
135 | + case self::VISIBLE_STUDENT : |
|
136 | + $sql .= " AND visible_student = 1 "; |
|
137 | + break; |
|
138 | + case self::VISIBLE_TEACHER : |
|
139 | + $sql .= " AND visible_teacher = 1 "; |
|
140 | + break; |
|
141 | + } |
|
142 | + |
|
143 | + if (count($groups) > 0) { |
|
144 | 144 | $sql .= " OR id IN ( |
145 | 145 | SELECT announcement_id FROM $tbl_announcement_group |
146 | 146 | WHERE group_id in $groups_string |
147 | 147 | ) "; |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | - if (api_is_multiple_url_enabled()) { |
|
151 | - $current_access_url_id = api_get_current_access_url_id(); |
|
150 | + if (api_is_multiple_url_enabled()) { |
|
151 | + $current_access_url_id = api_get_current_access_url_id(); |
|
152 | 152 | $sql .= " AND access_url_id IN ('1', '$current_access_url_id')"; |
153 | - } |
|
154 | - |
|
155 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
156 | - $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; |
|
157 | - } else { |
|
158 | - $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; |
|
159 | - } |
|
160 | - $announcements = Database::query($sql); |
|
161 | - $content = ''; |
|
162 | - if (Database::num_rows($announcements) > 0) { |
|
163 | - $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
164 | - $query_string = ereg_replace('&$', '', $query_string); |
|
165 | - $url = api_get_self(); |
|
166 | - $content .= '<div class="system_announcements">'; |
|
167 | - $content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
168 | - $content .= '<table align="center">'; |
|
169 | - $content .= '<tr>'; |
|
170 | - $content .= '<td>'; |
|
171 | - $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
172 | - $content .= '</td>'; |
|
173 | - $content .= '</tr>'; |
|
174 | - $content .= '</table>'; |
|
175 | - $content .= '<table align="center" border="0" width="900px">'; |
|
176 | - while ($announcement = Database::fetch_object($announcements)) { |
|
177 | - $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
178 | - $content .= '<tr><td>'; |
|
179 | - $content .= '<a name="'.$announcement->id.'"></a> |
|
153 | + } |
|
154 | + |
|
155 | + if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
156 | + $sql .= " ORDER BY date_start DESC LIMIT ".$start.",20"; |
|
157 | + } else { |
|
158 | + $sql .= " ORDER BY date_start DESC LIMIT ".($start+1).",20"; |
|
159 | + } |
|
160 | + $announcements = Database::query($sql); |
|
161 | + $content = ''; |
|
162 | + if (Database::num_rows($announcements) > 0) { |
|
163 | + $query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']); |
|
164 | + $query_string = ereg_replace('&$', '', $query_string); |
|
165 | + $url = api_get_self(); |
|
166 | + $content .= '<div class="system_announcements">'; |
|
167 | + $content .= '<h3>'.get_lang('SystemAnnouncements').'</h3>'; |
|
168 | + $content .= '<table align="center">'; |
|
169 | + $content .= '<tr>'; |
|
170 | + $content .= '<td>'; |
|
171 | + $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
172 | + $content .= '</td>'; |
|
173 | + $content .= '</tr>'; |
|
174 | + $content .= '</table>'; |
|
175 | + $content .= '<table align="center" border="0" width="900px">'; |
|
176 | + while ($announcement = Database::fetch_object($announcements)) { |
|
177 | + $display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG); |
|
178 | + $content .= '<tr><td>'; |
|
179 | + $content .= '<a name="'.$announcement->id.'"></a> |
|
180 | 180 | <div class="system_announcement"> |
181 | 181 | <h2>'.$announcement->title.'</h2><div class="system_announcement_date">'.$display_date.'</div> |
182 | 182 | <br /> |
183 | 183 | <div class="system_announcement_content">' |
184 | - .$announcement->content.' |
|
184 | + .$announcement->content.' |
|
185 | 185 | </div> |
186 | 186 | </div><br />'; |
187 | - $content .= '</tr></td>'; |
|
188 | - } |
|
189 | - $content .= '</table>'; |
|
190 | - |
|
191 | - $content .= '<table align="center">'; |
|
192 | - $content .= '<tr>'; |
|
193 | - $content .= '<td>'; |
|
194 | - $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
195 | - $content .= '</td>'; |
|
196 | - $content .= '</tr>'; |
|
197 | - $content .= '</table>'; |
|
198 | - $content .= '</div>'; |
|
199 | - } |
|
200 | - |
|
201 | - return $content; |
|
202 | - } |
|
187 | + $content .= '</tr></td>'; |
|
188 | + } |
|
189 | + $content .= '</table>'; |
|
190 | + |
|
191 | + $content .= '<table align="center">'; |
|
192 | + $content .= '<tr>'; |
|
193 | + $content .= '<td>'; |
|
194 | + $content .= SystemAnnouncementManager :: display_arrow($user_id); |
|
195 | + $content .= '</td>'; |
|
196 | + $content .= '</tr>'; |
|
197 | + $content .= '</table>'; |
|
198 | + $content .= '</div>'; |
|
199 | + } |
|
200 | + |
|
201 | + return $content; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @param int $user_id |
@@ -207,23 +207,23 @@ discard block |
||
207 | 207 | */ |
208 | 208 | public static function display_arrow($user_id) |
209 | 209 | { |
210 | - $start = (int)$_GET['start']; |
|
211 | - $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id); |
|
212 | - $next = ((int)$_GET['start']+19); |
|
213 | - $prev = ((int)$_GET['start']-19); |
|
214 | - $content = ''; |
|
215 | - if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
216 | - if($nb_announcement > 20) { |
|
217 | - $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
218 | - } |
|
219 | - } else { |
|
220 | - echo '<a href="news_list.php?start='.$prev.'"> << '.get_lang('Prev').'</a>'; |
|
221 | - if ($nb_announcement > 20) { |
|
222 | - $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
223 | - } |
|
224 | - } |
|
225 | - return $content; |
|
226 | - } |
|
210 | + $start = (int)$_GET['start']; |
|
211 | + $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id); |
|
212 | + $next = ((int)$_GET['start']+19); |
|
213 | + $prev = ((int)$_GET['start']-19); |
|
214 | + $content = ''; |
|
215 | + if(!isset($_GET['start']) || $_GET['start'] == 0) { |
|
216 | + if($nb_announcement > 20) { |
|
217 | + $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
218 | + } |
|
219 | + } else { |
|
220 | + echo '<a href="news_list.php?start='.$prev.'"> << '.get_lang('Prev').'</a>'; |
|
221 | + if ($nb_announcement > 20) { |
|
222 | + $content .= '<a href="news_list.php?start='.$next.'">'.get_lang('NextBis').' >> </a>'; |
|
223 | + } |
|
224 | + } |
|
225 | + return $content; |
|
226 | + } |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * @param int $start |
@@ -232,82 +232,82 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public static function count_nb_announcement($start = 0, $user_id = '') |
234 | 234 | { |
235 | - $start = intval($start); |
|
236 | - $visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT; |
|
237 | - $user_selected_language = api_get_interface_language(); |
|
238 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
239 | - $sql = 'SELECT id FROM '.$db_table.' |
|
235 | + $start = intval($start); |
|
236 | + $visibility = api_is_allowed_to_create_course() ? self::VISIBLE_TEACHER : self::VISIBLE_STUDENT; |
|
237 | + $user_selected_language = api_get_interface_language(); |
|
238 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
239 | + $sql = 'SELECT id FROM '.$db_table.' |
|
240 | 240 | WHERE (lang="'.$user_selected_language.'" OR lang IS NULL) '; |
241 | - if (isset($user_id)) { |
|
242 | - switch ($visibility) { |
|
243 | - case self::VISIBLE_GUEST : |
|
244 | - $sql .= " AND visible_guest = 1 "; |
|
245 | - break; |
|
246 | - case self::VISIBLE_STUDENT : |
|
247 | - $sql .= " AND visible_student = 1 "; |
|
248 | - break; |
|
249 | - case self::VISIBLE_TEACHER : |
|
250 | - $sql .= " AND visible_teacher = 1 "; |
|
251 | - break; |
|
252 | - } |
|
253 | - } |
|
254 | - |
|
255 | - $current_access_url_id = 1; |
|
256 | - if (api_is_multiple_url_enabled()) { |
|
257 | - $current_access_url_id = api_get_current_access_url_id(); |
|
258 | - } |
|
259 | - $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
260 | - |
|
261 | - |
|
262 | - $sql .= 'LIMIT '.$start.', 21'; |
|
263 | - $announcements = Database::query($sql); |
|
264 | - $i = 0; |
|
265 | - while ($rows = Database::fetch_array($announcements)) { |
|
266 | - $i++; |
|
267 | - } |
|
268 | - return $i; |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Get all announcements |
|
273 | - * @return array An array with all available system announcements (as php |
|
274 | - * objects) |
|
275 | - */ |
|
276 | - public static function get_all_announcements() |
|
241 | + if (isset($user_id)) { |
|
242 | + switch ($visibility) { |
|
243 | + case self::VISIBLE_GUEST : |
|
244 | + $sql .= " AND visible_guest = 1 "; |
|
245 | + break; |
|
246 | + case self::VISIBLE_STUDENT : |
|
247 | + $sql .= " AND visible_student = 1 "; |
|
248 | + break; |
|
249 | + case self::VISIBLE_TEACHER : |
|
250 | + $sql .= " AND visible_teacher = 1 "; |
|
251 | + break; |
|
252 | + } |
|
253 | + } |
|
254 | + |
|
255 | + $current_access_url_id = 1; |
|
256 | + if (api_is_multiple_url_enabled()) { |
|
257 | + $current_access_url_id = api_get_current_access_url_id(); |
|
258 | + } |
|
259 | + $sql .= " AND access_url_id = '$current_access_url_id' "; |
|
260 | + |
|
261 | + |
|
262 | + $sql .= 'LIMIT '.$start.', 21'; |
|
263 | + $announcements = Database::query($sql); |
|
264 | + $i = 0; |
|
265 | + while ($rows = Database::fetch_array($announcements)) { |
|
266 | + $i++; |
|
267 | + } |
|
268 | + return $i; |
|
269 | + } |
|
270 | + |
|
271 | + /** |
|
272 | + * Get all announcements |
|
273 | + * @return array An array with all available system announcements (as php |
|
274 | + * objects) |
|
275 | + */ |
|
276 | + public static function get_all_announcements() |
|
277 | 277 | { |
278 | - $table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
279 | - $now = api_get_utc_datetime(); |
|
280 | - $sql = "SELECT *, IF ( '$now' >= date_start AND '$now' <= date_end, '1', '0') AS visible |
|
278 | + $table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
279 | + $now = api_get_utc_datetime(); |
|
280 | + $sql = "SELECT *, IF ( '$now' >= date_start AND '$now' <= date_end, '1', '0') AS visible |
|
281 | 281 | FROM $table"; |
282 | 282 | |
283 | - $current_access_url_id = 1; |
|
284 | - if (api_is_multiple_url_enabled()) { |
|
285 | - $current_access_url_id = api_get_current_access_url_id(); |
|
286 | - } |
|
287 | - $sql .= " WHERE access_url_id = '$current_access_url_id' "; |
|
288 | - $sql .= " ORDER BY date_start ASC"; |
|
289 | - |
|
290 | - $announcements = Database::query($sql); |
|
291 | - $all_announcements = array(); |
|
292 | - while ($announcement = Database::fetch_object($announcements)) { |
|
293 | - $all_announcements[] = $announcement; |
|
294 | - } |
|
295 | - return $all_announcements; |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Adds an announcement to the database |
|
300 | - * @param string Title of the announcement |
|
301 | - * @param string Content of the announcement |
|
302 | - * @param string Start date (YYYY-MM-DD HH:II: SS) |
|
303 | - * @param string End date (YYYY-MM-DD HH:II: SS) |
|
304 | - * @param int Whether the announcement should be visible to teachers (1) or not (0) |
|
305 | - * @param int Whether the announcement should be visible to students (1) or not (0) |
|
306 | - * @param int Whether the announcement should be visible to anonymous users (1) or not (0) |
|
307 | - * @param string The language for which the announvement should be shown. Leave null for all langages |
|
308 | - * @param int Whether to send an e-mail to all users (1) or not (0) |
|
309 | - * @return mixed insert_id on success, false on failure |
|
310 | - */ |
|
283 | + $current_access_url_id = 1; |
|
284 | + if (api_is_multiple_url_enabled()) { |
|
285 | + $current_access_url_id = api_get_current_access_url_id(); |
|
286 | + } |
|
287 | + $sql .= " WHERE access_url_id = '$current_access_url_id' "; |
|
288 | + $sql .= " ORDER BY date_start ASC"; |
|
289 | + |
|
290 | + $announcements = Database::query($sql); |
|
291 | + $all_announcements = array(); |
|
292 | + while ($announcement = Database::fetch_object($announcements)) { |
|
293 | + $all_announcements[] = $announcement; |
|
294 | + } |
|
295 | + return $all_announcements; |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Adds an announcement to the database |
|
300 | + * @param string Title of the announcement |
|
301 | + * @param string Content of the announcement |
|
302 | + * @param string Start date (YYYY-MM-DD HH:II: SS) |
|
303 | + * @param string End date (YYYY-MM-DD HH:II: SS) |
|
304 | + * @param int Whether the announcement should be visible to teachers (1) or not (0) |
|
305 | + * @param int Whether the announcement should be visible to students (1) or not (0) |
|
306 | + * @param int Whether the announcement should be visible to anonymous users (1) or not (0) |
|
307 | + * @param string The language for which the announvement should be shown. Leave null for all langages |
|
308 | + * @param int Whether to send an e-mail to all users (1) or not (0) |
|
309 | + * @return mixed insert_id on success, false on failure |
|
310 | + */ |
|
311 | 311 | public static function add_announcement( |
312 | 312 | $title, |
313 | 313 | $content, |
@@ -321,112 +321,112 @@ discard block |
||
321 | 321 | $add_to_calendar = false, |
322 | 322 | $sendEmailTest = false |
323 | 323 | ) { |
324 | - $original_content = $content; |
|
325 | - $a_dateS = explode(' ',$date_start); |
|
326 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
327 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
328 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
324 | + $original_content = $content; |
|
325 | + $a_dateS = explode(' ',$date_start); |
|
326 | + $a_arraySD = explode('-',$a_dateS[0]); |
|
327 | + $a_arraySH = explode(':',$a_dateS[1]); |
|
328 | + $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
329 | 329 | |
330 | - $a_dateE = explode(' ',$date_end); |
|
331 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
332 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
333 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
330 | + $a_dateE = explode(' ',$date_end); |
|
331 | + $a_arrayED = explode('-',$a_dateE[0]); |
|
332 | + $a_arrayEH = explode(':',$a_dateE[1]); |
|
333 | + $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
334 | 334 | |
335 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
335 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
336 | 336 | |
337 | - if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
338 | - Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
339 | - return false; |
|
340 | - } |
|
337 | + if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
338 | + Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
339 | + return false; |
|
340 | + } |
|
341 | 341 | |
342 | - if (($date_end_to_compare[1] || |
|
342 | + if (($date_end_to_compare[1] || |
|
343 | 343 | $date_end_to_compare[2] || |
344 | 344 | $date_end_to_compare[0]) && |
345 | 345 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
346 | 346 | ) { |
347 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
348 | - return false; |
|
349 | - } |
|
350 | - if (strlen(trim($title)) == 0) { |
|
351 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
352 | - return false; |
|
353 | - } |
|
354 | - |
|
355 | - $start = api_get_utc_datetime($date_start); |
|
347 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
348 | + return false; |
|
349 | + } |
|
350 | + if (strlen(trim($title)) == 0) { |
|
351 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
352 | + return false; |
|
353 | + } |
|
354 | + |
|
355 | + $start = api_get_utc_datetime($date_start); |
|
356 | 356 | $end = api_get_utc_datetime($date_end); |
357 | 357 | |
358 | - //Fixing urls that are sent by email |
|
359 | - $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
360 | - $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
358 | + //Fixing urls that are sent by email |
|
359 | + $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
360 | + $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
361 | 361 | |
362 | 362 | $lang = is_null($lang) ? '' : $lang; |
363 | 363 | |
364 | - $current_access_url_id = 1; |
|
365 | - if (api_is_multiple_url_enabled()) { |
|
366 | - $current_access_url_id = api_get_current_access_url_id(); |
|
367 | - } |
|
368 | - |
|
369 | - $params = [ |
|
370 | - 'title' => $title, |
|
371 | - 'content' => $content, |
|
372 | - 'date_start' => $start, |
|
373 | - 'date_end' => $end, |
|
374 | - 'visible_teacher' => $visible_teacher, |
|
375 | - 'visible_student' => $visible_student, |
|
376 | - 'visible_guest' => $visible_guest, |
|
377 | - 'lang' => $lang, |
|
378 | - 'access_url_id' => $current_access_url_id, |
|
379 | - ]; |
|
380 | - |
|
381 | - $resultId = Database::insert($db_table, $params); |
|
382 | - |
|
383 | - if ($resultId) { |
|
384 | - |
|
385 | - if ($sendEmailTest) { |
|
386 | - SystemAnnouncementManager::send_system_announcement_by_email( |
|
387 | - $title, |
|
388 | - $content, |
|
389 | - $visible_teacher, |
|
390 | - $visible_student, |
|
391 | - $lang, |
|
392 | - true |
|
393 | - ); |
|
394 | - } else { |
|
395 | - if ($send_mail == 1) { |
|
396 | - SystemAnnouncementManager::send_system_announcement_by_email( |
|
397 | - $title, |
|
398 | - $content, |
|
399 | - $visible_teacher, |
|
400 | - $visible_student, |
|
401 | - $lang |
|
402 | - ); |
|
403 | - } |
|
404 | - } |
|
405 | - |
|
406 | - if ($add_to_calendar) { |
|
407 | - $agenda = new Agenda(); |
|
408 | - $agenda->setType('admin'); |
|
409 | - $agenda->addEvent( |
|
410 | - $date_start, |
|
411 | - $date_end, |
|
412 | - false, |
|
413 | - $title, |
|
414 | - $original_content |
|
415 | - ); |
|
416 | - } |
|
417 | - |
|
418 | - return $resultId; |
|
419 | - |
|
420 | - } |
|
421 | - |
|
422 | - return false; |
|
423 | - } |
|
364 | + $current_access_url_id = 1; |
|
365 | + if (api_is_multiple_url_enabled()) { |
|
366 | + $current_access_url_id = api_get_current_access_url_id(); |
|
367 | + } |
|
368 | + |
|
369 | + $params = [ |
|
370 | + 'title' => $title, |
|
371 | + 'content' => $content, |
|
372 | + 'date_start' => $start, |
|
373 | + 'date_end' => $end, |
|
374 | + 'visible_teacher' => $visible_teacher, |
|
375 | + 'visible_student' => $visible_student, |
|
376 | + 'visible_guest' => $visible_guest, |
|
377 | + 'lang' => $lang, |
|
378 | + 'access_url_id' => $current_access_url_id, |
|
379 | + ]; |
|
380 | + |
|
381 | + $resultId = Database::insert($db_table, $params); |
|
382 | + |
|
383 | + if ($resultId) { |
|
384 | + |
|
385 | + if ($sendEmailTest) { |
|
386 | + SystemAnnouncementManager::send_system_announcement_by_email( |
|
387 | + $title, |
|
388 | + $content, |
|
389 | + $visible_teacher, |
|
390 | + $visible_student, |
|
391 | + $lang, |
|
392 | + true |
|
393 | + ); |
|
394 | + } else { |
|
395 | + if ($send_mail == 1) { |
|
396 | + SystemAnnouncementManager::send_system_announcement_by_email( |
|
397 | + $title, |
|
398 | + $content, |
|
399 | + $visible_teacher, |
|
400 | + $visible_student, |
|
401 | + $lang |
|
402 | + ); |
|
403 | + } |
|
404 | + } |
|
405 | + |
|
406 | + if ($add_to_calendar) { |
|
407 | + $agenda = new Agenda(); |
|
408 | + $agenda->setType('admin'); |
|
409 | + $agenda->addEvent( |
|
410 | + $date_start, |
|
411 | + $date_end, |
|
412 | + false, |
|
413 | + $title, |
|
414 | + $original_content |
|
415 | + ); |
|
416 | + } |
|
417 | + |
|
418 | + return $resultId; |
|
419 | + |
|
420 | + } |
|
421 | + |
|
422 | + return false; |
|
423 | + } |
|
424 | 424 | |
425 | 425 | /** |
426 | - * Makes the announcement id visible only for groups in groups_array |
|
427 | - * @param int announcement id |
|
428 | - * @param array array of group id |
|
429 | - **/ |
|
426 | + * Makes the announcement id visible only for groups in groups_array |
|
427 | + * @param int announcement id |
|
428 | + * @param array array of group id |
|
429 | + **/ |
|
430 | 430 | public static function announcement_for_groups($announcement_id, $group_array) |
431 | 431 | { |
432 | 432 | $tbl_announcement_group = Database:: get_main_table( |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
463 | - * Gets the groups of this announce |
|
464 | - * @param int announcement id |
|
465 | - * @return array array of group id |
|
466 | - **/ |
|
463 | + * Gets the groups of this announce |
|
464 | + * @param int announcement id |
|
465 | + * @return array array of group id |
|
466 | + **/ |
|
467 | 467 | public static function get_announcement_groups($announcement_id) |
468 | 468 | { |
469 | 469 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
@@ -482,15 +482,15 @@ discard block |
||
482 | 482 | return $groups; |
483 | 483 | } |
484 | 484 | |
485 | - /** |
|
486 | - * Updates an announcement to the database |
|
487 | - * @param integer $id : id of the announcement |
|
488 | - * @param string $title : title of the announcement |
|
489 | - * @param string $content : content of the announcement |
|
490 | - * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
491 | - * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
492 | - * @return bool True on success, false on failure |
|
493 | - */ |
|
485 | + /** |
|
486 | + * Updates an announcement to the database |
|
487 | + * @param integer $id : id of the announcement |
|
488 | + * @param string $title : title of the announcement |
|
489 | + * @param string $content : content of the announcement |
|
490 | + * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
491 | + * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
492 | + * @return bool True on success, false on failure |
|
493 | + */ |
|
494 | 494 | public static function update_announcement( |
495 | 495 | $id, |
496 | 496 | $title, |
@@ -506,43 +506,43 @@ discard block |
||
506 | 506 | ) { |
507 | 507 | $em = Database::getManager(); |
508 | 508 | |
509 | - $a_dateS = explode(' ',$date_start); |
|
510 | - $a_arraySD = explode('-',$a_dateS[0]); |
|
511 | - $a_arraySH = explode(':',$a_dateS[1]); |
|
512 | - $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
509 | + $a_dateS = explode(' ',$date_start); |
|
510 | + $a_arraySD = explode('-',$a_dateS[0]); |
|
511 | + $a_arraySH = explode(':',$a_dateS[1]); |
|
512 | + $date_start_to_compare = array_merge($a_arraySD,$a_arraySH); |
|
513 | 513 | |
514 | - $a_dateE = explode(' ',$date_end); |
|
515 | - $a_arrayED = explode('-',$a_dateE[0]); |
|
516 | - $a_arrayEH = explode(':',$a_dateE[1]); |
|
517 | - $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
514 | + $a_dateE = explode(' ',$date_end); |
|
515 | + $a_arrayED = explode('-',$a_dateE[0]); |
|
516 | + $a_arrayEH = explode(':',$a_dateE[1]); |
|
517 | + $date_end_to_compare = array_merge($a_arrayED,$a_arrayEH); |
|
518 | 518 | |
519 | 519 | $lang = is_null($lang) ? '' : $lang; |
520 | 520 | |
521 | - if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
522 | - Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
523 | - return false; |
|
524 | - } |
|
521 | + if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) { |
|
522 | + Display :: display_normal_message(get_lang('InvalidStartDate')); |
|
523 | + return false; |
|
524 | + } |
|
525 | 525 | |
526 | - if (($date_end_to_compare[1] || |
|
526 | + if (($date_end_to_compare[1] || |
|
527 | 527 | $date_end_to_compare[2] || |
528 | 528 | $date_end_to_compare[0]) && |
529 | 529 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
530 | 530 | ) { |
531 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
532 | - return false; |
|
533 | - } |
|
531 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
532 | + return false; |
|
533 | + } |
|
534 | 534 | |
535 | - if (strlen(trim($title)) == 0) { |
|
536 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
537 | - return false; |
|
538 | - } |
|
535 | + if (strlen(trim($title)) == 0) { |
|
536 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
537 | + return false; |
|
538 | + } |
|
539 | 539 | |
540 | - $start = api_get_utc_datetime($date_start); |
|
540 | + $start = api_get_utc_datetime($date_start); |
|
541 | 541 | $end = api_get_utc_datetime($date_end); |
542 | 542 | |
543 | - //Fixing urls that are sent by email |
|
544 | - $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
545 | - $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
543 | + //Fixing urls that are sent by email |
|
544 | + $content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
545 | + $content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
546 | 546 | |
547 | 547 | $id = intval($id); |
548 | 548 | |
@@ -591,84 +591,84 @@ discard block |
||
591 | 591 | $em->merge($announcement); |
592 | 592 | $em->flush(); |
593 | 593 | |
594 | - return true; |
|
595 | - } |
|
594 | + return true; |
|
595 | + } |
|
596 | 596 | |
597 | - /** |
|
598 | - * Deletes an announcement |
|
599 | - * @param int $id The identifier of the announcement that should be |
|
600 | - * @return bool True on success, false on failure |
|
601 | - */ |
|
602 | - public static function delete_announcement($id) |
|
597 | + /** |
|
598 | + * Deletes an announcement |
|
599 | + * @param int $id The identifier of the announcement that should be |
|
600 | + * @return bool True on success, false on failure |
|
601 | + */ |
|
602 | + public static function delete_announcement($id) |
|
603 | 603 | { |
604 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
605 | - $id = intval($id); |
|
606 | - $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
607 | - $res = Database::query($sql); |
|
608 | - if ($res === false) { |
|
609 | - |
|
610 | - return false; |
|
611 | - } |
|
612 | - return true; |
|
613 | - } |
|
614 | - |
|
615 | - /** |
|
616 | - * Gets an announcement |
|
617 | - * @param int $id The identifier of the announcement that should be |
|
618 | - * @return object Object of class StdClass or the required class, containing the query result row |
|
619 | - */ |
|
620 | - public static function get_announcement($id) |
|
604 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
605 | + $id = intval($id); |
|
606 | + $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
607 | + $res = Database::query($sql); |
|
608 | + if ($res === false) { |
|
609 | + |
|
610 | + return false; |
|
611 | + } |
|
612 | + return true; |
|
613 | + } |
|
614 | + |
|
615 | + /** |
|
616 | + * Gets an announcement |
|
617 | + * @param int $id The identifier of the announcement that should be |
|
618 | + * @return object Object of class StdClass or the required class, containing the query result row |
|
619 | + */ |
|
620 | + public static function get_announcement($id) |
|
621 | 621 | { |
622 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
623 | - $id = intval($id); |
|
624 | - $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
625 | - $announcement = Database::fetch_object(Database::query($sql)); |
|
626 | - |
|
627 | - return $announcement; |
|
628 | - } |
|
629 | - |
|
630 | - /** |
|
631 | - * Change the visibility of an announcement |
|
632 | - * @param int $announcement_id |
|
633 | - * @param int $user For who should the visibility be changed |
|
622 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
623 | + $id = intval($id); |
|
624 | + $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
625 | + $announcement = Database::fetch_object(Database::query($sql)); |
|
626 | + |
|
627 | + return $announcement; |
|
628 | + } |
|
629 | + |
|
630 | + /** |
|
631 | + * Change the visibility of an announcement |
|
632 | + * @param int $announcement_id |
|
633 | + * @param int $user For who should the visibility be changed |
|
634 | 634 | * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST) |
635 | - * @return bool True on success, false on failure |
|
636 | - */ |
|
637 | - public static function set_visibility($announcement_id, $user, $visible) |
|
635 | + * @return bool True on success, false on failure |
|
636 | + */ |
|
637 | + public static function set_visibility($announcement_id, $user, $visible) |
|
638 | 638 | { |
639 | - $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
640 | - $visible = intval($visible); |
|
641 | - $announcement_id = intval($announcement_id); |
|
639 | + $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
640 | + $visible = intval($visible); |
|
641 | + $announcement_id = intval($announcement_id); |
|
642 | 642 | |
643 | 643 | if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) { |
644 | 644 | return false; |
645 | 645 | } |
646 | 646 | |
647 | - $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
647 | + $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
648 | 648 | |
649 | - $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
649 | + $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
650 | 650 | WHERE id='".$announcement_id."'"; |
651 | - $res = Database::query($sql); |
|
652 | - |
|
653 | - if ($res === false) { |
|
654 | - return false; |
|
655 | - } |
|
656 | - |
|
657 | - return true; |
|
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
662 | - * @param string Title |
|
663 | - * @param string Content |
|
664 | - * @param int Whether to send to all teachers (1) or not (0) |
|
665 | - * @param int Whether to send to all students (1) or not (0) |
|
666 | - * @param string Language (optional, considered for all languages if left empty) |
|
651 | + $res = Database::query($sql); |
|
652 | + |
|
653 | + if ($res === false) { |
|
654 | + return false; |
|
655 | + } |
|
656 | + |
|
657 | + return true; |
|
658 | + } |
|
659 | + |
|
660 | + /** |
|
661 | + * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
662 | + * @param string Title |
|
663 | + * @param string Content |
|
664 | + * @param int Whether to send to all teachers (1) or not (0) |
|
665 | + * @param int Whether to send to all students (1) or not (0) |
|
666 | + * @param string Language (optional, considered for all languages if left empty) |
|
667 | 667 | * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
668 | - */ |
|
669 | - public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
|
668 | + */ |
|
669 | + public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) |
|
670 | 670 | { |
671 | - global $charset; |
|
671 | + global $charset; |
|
672 | 672 | |
673 | 673 | $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); |
674 | 674 | $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset); |
@@ -687,22 +687,22 @@ discard block |
||
687 | 687 | } |
688 | 688 | |
689 | 689 | if ($teacher <> 0 AND $student == 0) { |
690 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
691 | - } |
|
690 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
691 | + } |
|
692 | 692 | |
693 | - if ($teacher == 0 AND $student <> 0) { |
|
694 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
695 | - } |
|
693 | + if ($teacher == 0 AND $student <> 0) { |
|
694 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
695 | + } |
|
696 | 696 | |
697 | - if ($teacher<> 0 AND $student <> 0) { |
|
698 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
699 | - } |
|
697 | + if ($teacher<> 0 AND $student <> 0) { |
|
698 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
699 | + } |
|
700 | 700 | |
701 | - if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
702 | - $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
703 | - } |
|
701 | + if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
702 | + $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
703 | + } |
|
704 | 704 | |
705 | - if (api_is_multiple_url_enabled()) { |
|
705 | + if (api_is_multiple_url_enabled()) { |
|
706 | 706 | $sql .= " AND access_url_id = '".$current_access_url_id."' "; |
707 | 707 | } |
708 | 708 | |
@@ -712,25 +712,25 @@ discard block |
||
712 | 712 | // Expiration date |
713 | 713 | $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') "; |
714 | 714 | |
715 | - if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
716 | - return true; |
|
717 | - } |
|
715 | + if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
716 | + return true; |
|
717 | + } |
|
718 | 718 | |
719 | - $result = Database::query($sql); |
|
720 | - if ($result === false) { |
|
721 | - return false; |
|
722 | - } |
|
719 | + $result = Database::query($sql); |
|
720 | + if ($result === false) { |
|
721 | + return false; |
|
722 | + } |
|
723 | 723 | |
724 | 724 | $message_sent = false; |
725 | 725 | |
726 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
726 | + while ($row = Database::fetch_array($result,'ASSOC')) { |
|
727 | 727 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
728 | 728 | $message_sent = true; |
729 | - } |
|
730 | - return $message_sent; //true if at least one e-mail was sent |
|
731 | - } |
|
729 | + } |
|
730 | + return $message_sent; //true if at least one e-mail was sent |
|
731 | + } |
|
732 | 732 | |
733 | - /** |
|
733 | + /** |
|
734 | 734 | * Displays announcements as an slideshow |
735 | 735 | * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
736 | 736 | * @param int $id The identifier of the announcement to display |
@@ -47,43 +47,43 @@ |
||
47 | 47 | */ |
48 | 48 | class LoggerFilterStringMatch extends LoggerFilter { |
49 | 49 | |
50 | - /** |
|
51 | - * @var boolean |
|
52 | - */ |
|
53 | - private $acceptOnMatch = true; |
|
50 | + /** |
|
51 | + * @var boolean |
|
52 | + */ |
|
53 | + private $acceptOnMatch = true; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
58 | - private $stringToMatch = null; |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | + private $stringToMatch = null; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
62 | - */ |
|
63 | - public function setAcceptOnMatch($acceptOnMatch) { |
|
64 | - $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true'); |
|
65 | - } |
|
60 | + /** |
|
61 | + * @param mixed $acceptOnMatch a boolean or a string ('true' or 'false') |
|
62 | + */ |
|
63 | + public function setAcceptOnMatch($acceptOnMatch) { |
|
64 | + $this->acceptOnMatch = is_bool($acceptOnMatch) ? $acceptOnMatch : (bool)(strtolower($acceptOnMatch) == 'true'); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param string $s the string to match |
|
69 | - */ |
|
70 | - public function setStringToMatch($s) { |
|
71 | - $this->stringToMatch = $s; |
|
72 | - } |
|
67 | + /** |
|
68 | + * @param string $s the string to match |
|
69 | + */ |
|
70 | + public function setStringToMatch($s) { |
|
71 | + $this->stringToMatch = $s; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
76 | - */ |
|
77 | - public function decide(LoggerLoggingEvent $event) { |
|
78 | - $msg = $event->getRenderedMessage(); |
|
74 | + /** |
|
75 | + * @return integer a {@link LOGGER_FILTER_NEUTRAL} is there is no string match. |
|
76 | + */ |
|
77 | + public function decide(LoggerLoggingEvent $event) { |
|
78 | + $msg = $event->getRenderedMessage(); |
|
79 | 79 | |
80 | - if($msg === null or $this->stringToMatch === null) { |
|
81 | - return LoggerFilter::NEUTRAL; |
|
82 | - } |
|
80 | + if($msg === null or $this->stringToMatch === null) { |
|
81 | + return LoggerFilter::NEUTRAL; |
|
82 | + } |
|
83 | 83 | |
84 | - if(strpos($msg, $this->stringToMatch) !== false ) { |
|
85 | - return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY; |
|
86 | - } |
|
87 | - return LoggerFilter::NEUTRAL; |
|
88 | - } |
|
84 | + if(strpos($msg, $this->stringToMatch) !== false ) { |
|
85 | + return ($this->acceptOnMatch) ? LoggerFilter::ACCEPT : LoggerFilter::DENY; |
|
86 | + } |
|
87 | + return LoggerFilter::NEUTRAL; |
|
88 | + } |
|
89 | 89 | } |