@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * |
18 | 18 | * @param int|array $course |
19 | - * @param int|array $annoucement |
|
19 | + * @param integer $announcement |
|
20 | 20 | * |
21 | 21 | * @return AnnouncementEmail |
22 | 22 | */ |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param string $key |
52 | 52 | * |
53 | - * @return array |
|
53 | + * @return string|null |
|
54 | 54 | */ |
55 | 55 | public function course($key = '') |
56 | 56 | { |
@@ -196,7 +196,7 @@ |
||
196 | 196 | * |
197 | 197 | * @return array |
198 | 198 | */ |
199 | - public function sender($key = '', $userId = '') |
|
199 | + public function sender($key = '', $userId = '') |
|
200 | 200 | { |
201 | 201 | $_user = api_get_user_info($userId); |
202 | 202 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
21 | - * @return array |
|
21 | + * @return string[] |
|
22 | 22 | */ |
23 | 23 | public static function get_tags() |
24 | 24 | { |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param string $course_code |
41 | 41 | * @param int $session_id |
42 | 42 | * |
43 | - * @return mixed |
|
43 | + * @return string |
|
44 | 44 | */ |
45 | 45 | public static function parse_content($userId, $content, $course_code, $session_id = 0) |
46 | 46 | { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @param array uploaded file $_FILES |
350 | 350 | * @param string Comment describing the attachment |
351 | 351 | * @param bool $sendToUsersInSession |
352 | - * @return int false on failure, ID of the announcement on success |
|
352 | + * @return false|string false on failure, ID of the announcement on success |
|
353 | 353 | */ |
354 | 354 | public static function add_announcement( |
355 | 355 | $emailTitle, |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param $to_users |
461 | 461 | * @param array $file |
462 | 462 | * @param string $file_comment |
463 | - * @return bool|int |
|
463 | + * @return false|string |
|
464 | 464 | */ |
465 | 465 | public static function add_group_announcement( |
466 | 466 | $emailTitle, |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | /** |
701 | 701 | * @param int $insert_id |
702 | - * @return bool |
|
702 | + * @return false|null |
|
703 | 703 | */ |
704 | 704 | public static function update_mail_sent($insert_id) |
705 | 705 | { |
@@ -719,6 +719,7 @@ discard block |
||
719 | 719 | * Gets all announcements from a user by course |
720 | 720 | * @param string course db |
721 | 721 | * @param int user id |
722 | + * @param integer $user_id |
|
722 | 723 | * @return array html with the content and count of announcements or false otherwise |
723 | 724 | */ |
724 | 725 | public static function get_all_annoucement_by_user_course($course_code, $user_id) |
@@ -1184,6 +1185,7 @@ discard block |
||
1184 | 1185 | * has been sent to |
1185 | 1186 | * @param string The tool (announcement, agenda, ...) |
1186 | 1187 | * @param int ID of the element of the corresponding type |
1188 | + * @param string $tool |
|
1187 | 1189 | * @return array Array of users and groups to whom the element has been sent |
1188 | 1190 | */ |
1189 | 1191 | public static function sent_to($tool, $id) |
@@ -1308,6 +1310,8 @@ discard block |
||
1308 | 1310 | * @param int attach id |
1309 | 1311 | * @param array uploaded file $_FILES |
1310 | 1312 | * @param string file comment |
1313 | + * @param integer $id_attach |
|
1314 | + * @param string $file_comment |
|
1311 | 1315 | * @return int |
1312 | 1316 | */ |
1313 | 1317 | public static function edit_announcement_attachment_file($id_attach, $file, $file_comment) |
@@ -1510,7 +1510,7 @@ |
||
1510 | 1510 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) |
1511 | 1511 | ) "; |
1512 | 1512 | } else { |
1513 | - $cond_user_id = " AND ( |
|
1513 | + $cond_user_id = " AND ( |
|
1514 | 1514 | ip.to_user_id=$user_id OR (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".api_get_group_id().")) |
1515 | 1515 | )"; |
1516 | 1516 | } |
@@ -216,8 +216,8 @@ discard block |
||
216 | 216 | announcement.id = '$announcement_id' AND |
217 | 217 | toolitemproperties.tool='announcement' AND |
218 | 218 | ( |
219 | - toolitemproperties.to_user_id='" . api_get_user_id() . "' OR |
|
220 | - toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list) . "') OR |
|
219 | + toolitemproperties.to_user_id='".api_get_user_id()."' OR |
|
220 | + toolitemproperties.to_group_id IN ('0', '" . implode("', '", $group_list)."') OR |
|
221 | 221 | toolitemproperties.to_group_id IS NULL |
222 | 222 | ) AND |
223 | 223 | toolitemproperties.visibility='1' AND |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | $title = $result['title']; |
247 | 247 | $content = $result['content']; |
248 | 248 | $html .= "<table height=\"100\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" class=\"data_table\">"; |
249 | - $html .= "<tr><td><h2>" . $title . "</h2></td></tr>"; |
|
249 | + $html .= "<tr><td><h2>".$title."</h2></td></tr>"; |
|
250 | 250 | |
251 | 251 | if (api_is_allowed_to_edit(false, true) || |
252 | 252 | (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
253 | 253 | ) { |
254 | - $modify_icons = "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=modify&id=" . $announcement_id . "\">" . |
|
255 | - Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>"; |
|
254 | + $modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$announcement_id."\">". |
|
255 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
256 | 256 | if ($result['visibility'] == 1) { |
257 | 257 | $image_visibility = "visible"; |
258 | 258 | $alt_visibility = get_lang('Hide'); |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | } |
263 | 263 | global $stok; |
264 | 264 | |
265 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . (!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '') . "&action=showhide&id=" . $announcement_id . "&sec_token=" . $stok . "\">" . |
|
266 | - Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . "</a>"; |
|
265 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '')."&action=showhide&id=".$announcement_id."&sec_token=".$stok."\">". |
|
266 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
267 | 267 | |
268 | 268 | if (api_is_allowed_to_edit(false, true)) { |
269 | - $modify_icons .= "<a href=\"" . api_get_self() . "?" . api_get_cidreq() . "&action=delete&id=" . $announcement_id . "&sec_token=" . $stok . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . |
|
270 | - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . |
|
269 | + $modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$announcement_id."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset))."')) return false;\">". |
|
270 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
271 | 271 | "</a>"; |
272 | 272 | } |
273 | 273 | $html .= "<tr><th style='text-align:right'>$modify_icons</th></tr>"; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $content = self::parse_content($result['to_user_id'], $content, api_get_course_id(), api_get_session_id()); |
277 | 277 | |
278 | 278 | $html .= "<tr><td>$content</td></tr>"; |
279 | - $html .= "<tr><td class=\"announcements_datum\">" . get_lang('LastUpdateDate') . " : " . api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG) . "</td></tr>"; |
|
279 | + $html .= "<tr><td class=\"announcements_datum\">".get_lang('LastUpdateDate')." : ".api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG)."</td></tr>"; |
|
280 | 280 | |
281 | 281 | // User or group icon |
282 | 282 | $sent_to_icon = ''; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | $sent_to_form = self::sent_to_form($sent_to); |
289 | 289 | $html .= Display::tag( |
290 | 290 | 'td', |
291 | - get_lang('SentTo') . ' : ' . $sent_to_form, |
|
291 | + get_lang('SentTo').' : '.$sent_to_form, |
|
292 | 292 | array('class' => 'announcements_datum') |
293 | 293 | ); |
294 | 294 | } |
@@ -298,15 +298,15 @@ discard block |
||
298 | 298 | $html .= "<tr><td>"; |
299 | 299 | $realname = $attachment_list['path']; |
300 | 300 | $user_filename = $attachment_list['filename']; |
301 | - $full_file_name = 'download.php?'.api_get_cidreq().'&file=' . $realname; |
|
301 | + $full_file_name = 'download.php?'.api_get_cidreq().'&file='.$realname; |
|
302 | 302 | $html .= '<br/>'; |
303 | 303 | $html .= Display::return_icon('attachment.gif', get_lang('Attachment')); |
304 | - $html .= '<a href="' . $full_file_name . ' "> ' . $user_filename . ' </a>'; |
|
305 | - $html .= ' - <span class="forum_attach_comment" >' . $attachment_list['comment'] . '</span>'; |
|
304 | + $html .= '<a href="'.$full_file_name.' "> '.$user_filename.' </a>'; |
|
305 | + $html .= ' - <span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; |
|
306 | 306 | if (api_is_allowed_to_edit(false, true)) { |
307 | 307 | $html .= Display::url( |
308 | 308 | Display::return_icon('delete.png', get_lang('Delete'), '', 16), |
309 | - api_get_self() . "?" . api_get_cidreq() . "&action=delete_attachment&id_attach=" . $attachment_list['id'] . "&sec_token=" . $stok |
|
309 | + api_get_self()."?".api_get_cidreq()."&action=delete_attachment&id_attach=".$attachment_list['id']."&sec_token=".$stok |
|
310 | 310 | ); |
311 | 311 | } |
312 | 312 | $html .= '</td></tr>'; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $order = 0; |
335 | 335 | if (Database::num_rows($res_max)) { |
336 | 336 | $row_max = Database::fetch_array($res_max); |
337 | - $order = intval($row_max[0])+1; |
|
337 | + $order = intval($row_max[0]) + 1; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | return $order; |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | $result = array(); |
755 | 755 | if ($num_rows > 0) { |
756 | 756 | while ($myrow = Database::fetch_array($rs)) { |
757 | - $content.= '<strong>' . $myrow['title'] . '</strong><br /><br />'; |
|
758 | - $content.= $myrow['content']; |
|
757 | + $content .= '<strong>'.$myrow['title'].'</strong><br /><br />'; |
|
758 | + $content .= $myrow['content']; |
|
759 | 759 | $i++; |
760 | 760 | } |
761 | 761 | $result['content'] = $content; |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | echo "<table id=\"recipient_list\" >"; |
787 | 787 | echo '<tr>'; |
788 | 788 | echo '<td>'; |
789 | - echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers') . "</label>"; |
|
789 | + echo '<label><input type="checkbox" id="send_to_all_users">'.get_lang('SendToAllUsers')."</label>"; |
|
790 | 790 | echo "</td>"; |
791 | 791 | echo '</tr>'; |
792 | 792 | echo '<tr>'; |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | |
795 | 795 | // the form containing all the groups and all the users of the course |
796 | 796 | echo '<td>'; |
797 | - echo "<strong>" . get_lang('Users') . "</strong><br />"; |
|
797 | + echo "<strong>".get_lang('Users')."</strong><br />"; |
|
798 | 798 | |
799 | 799 | self::construct_not_selected_select_form($groupList, $userList, $to_already_selected); |
800 | 800 | echo "</td>"; |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | echo "<td>"; |
810 | 810 | |
811 | 811 | // the form containing the selected groups and users |
812 | - echo "<strong>" . get_lang('DestinationUsers') . "</strong><br />"; |
|
812 | + echo "<strong>".get_lang('DestinationUsers')."</strong><br />"; |
|
813 | 813 | self::construct_selected_select_form($groupList, $userList, $to_already_selected); |
814 | 814 | echo "</td>"; |
815 | 815 | echo "</tr>"; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | echo "<select id=\"not_selected_form\" name=\"not_selected_form[]\" size=5 style=\"width:200px\" multiple>"; |
828 | 828 | $group_users = GroupManager::getStudentsAndTutors($group_id); |
829 | 829 | foreach ($group_users as $user) { |
830 | - echo '<option value="' . $user['user_id'] . '" title="' . sprintf(get_lang('LoginX'), $user['username']) . '" >' . |
|
831 | - api_get_person_name($user['firstname'], $user['lastname']) . |
|
830 | + echo '<option value="'.$user['user_id'].'" title="'.sprintf(get_lang('LoginX'), $user['username']).'" >'. |
|
831 | + api_get_person_name($user['firstname'], $user['lastname']). |
|
832 | 832 | '</option>'; |
833 | 833 | } |
834 | 834 | echo '</select>'; |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | if (!empty($groupList)) { |
867 | 867 | foreach ($groupList as $this_group) { |
868 | 868 | if (is_array($to_already_selected)) { |
869 | - if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) { |
|
869 | + if (!in_array("GROUP:".$this_group['id'], $to_already_selected)) { |
|
870 | 870 | // $to_already_selected is the array containing the groups (and users) that are already selected |
871 | - $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser') ; |
|
872 | - $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ; |
|
873 | - echo "<option $user_disabled value=\"GROUP:" . $this_group['id'] . "\">", |
|
874 | - "G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . $user_label . |
|
871 | + $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser'); |
|
872 | + $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled"; |
|
873 | + echo "<option $user_disabled value=\"GROUP:".$this_group['id']."\">", |
|
874 | + "G: ", $this_group['name'], " - ".$this_group['userNb']." ".$user_label. |
|
875 | 875 | "</option>"; |
876 | 876 | } |
877 | 877 | } |
@@ -885,15 +885,15 @@ discard block |
||
885 | 885 | if (!empty($userList)) { |
886 | 886 | foreach ($userList as $user) { |
887 | 887 | if (is_array($to_already_selected)) { |
888 | - if (!in_array("USER:" . $user['user_id'], $to_already_selected)) { |
|
888 | + if (!in_array("USER:".$user['user_id'], $to_already_selected)) { |
|
889 | 889 | // $to_already_selected is the array containing the users (and groups) that are already selected |
890 | - echo "<option value=\"USER:" . $user['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $user['username']) . "'>", |
|
890 | + echo "<option value=\"USER:".$user['user_id']."\" title='".sprintf(get_lang('LoginX'), $user['username'])."'>", |
|
891 | 891 | "", api_get_person_name($user['firstname'], $user['lastname']), |
892 | 892 | "</option>"; |
893 | 893 | |
894 | 894 | if (isset($user['drh_list']) && !empty($user['drh_list'])) { |
895 | 895 | foreach ($user['drh_list'] as $drh) { |
896 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
896 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
897 | 897 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
898 | 898 | "</option>"; |
899 | 899 | } |
@@ -925,16 +925,16 @@ discard block |
||
925 | 925 | foreach ($to_already_selected as $groupuser) { |
926 | 926 | list($type, $id) = explode(":", $groupuser); |
927 | 927 | if ($type == "GROUP") { |
928 | - echo "<option value=\"" . $groupuser . "\">G: " . $ref_array_groups[$id]['name'] . "</option>"; |
|
928 | + echo "<option value=\"".$groupuser."\">G: ".$ref_array_groups[$id]['name']."</option>"; |
|
929 | 929 | } else { |
930 | 930 | foreach ($ref_array_users as $key => $value) { |
931 | 931 | if ($value['user_id'] == $id) { |
932 | - echo "<option value=\"" . $groupuser . "\" title='" . sprintf(get_lang('LoginX'), $value['username']) . "'>" . |
|
933 | - api_get_person_name($value['firstname'], $value['lastname']) . "</option>"; |
|
932 | + echo "<option value=\"".$groupuser."\" title='".sprintf(get_lang('LoginX'), $value['username'])."'>". |
|
933 | + api_get_person_name($value['firstname'], $value['lastname'])."</option>"; |
|
934 | 934 | |
935 | 935 | if (isset($value['drh_list']) && !empty($value['drh_list'])) { |
936 | 936 | foreach ($value['drh_list'] as $drh) { |
937 | - echo "<option value=\"USER:" . $drh['user_id'] . "\" title='" . sprintf(get_lang('LoginX'), $drh['username']) . "'> ", |
|
937 | + echo "<option value=\"USER:".$drh['user_id']."\" title='".sprintf(get_lang('LoginX'), $drh['username'])."'> ", |
|
938 | 938 | "", api_get_person_name($drh['firstname'], $drh['lastname']), |
939 | 939 | "</option>"; |
940 | 940 | } |
@@ -950,17 +950,17 @@ discard block |
||
950 | 950 | if (is_array($ref_array_groups)) { |
951 | 951 | foreach ($ref_array_groups as $this_group) { |
952 | 952 | //api_display_normal_message("group " . $thisGroup[id] . $thisGroup[name]); |
953 | - if (!is_array($to_already_selected) || !in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
954 | - echo "<option value=\"GROUP:" . $this_group['id'] . "\">", |
|
955 | - "G: ", $this_group['name'], " – " . $this_group['userNb'] . " " . get_lang('Users') . |
|
953 | + if (!is_array($to_already_selected) || !in_array("GROUP:".$this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected |
|
954 | + echo "<option value=\"GROUP:".$this_group['id']."\">", |
|
955 | + "G: ", $this_group['name'], " – ".$this_group['userNb']." ".get_lang('Users'). |
|
956 | 956 | "</option>"; |
957 | 957 | } |
958 | 958 | } |
959 | 959 | } |
960 | 960 | // adding the individual users to the select form |
961 | 961 | foreach ($ref_array_users as $this_user) { |
962 | - if (!is_array($to_already_selected) || !in_array("USER:" . $this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
963 | - echo "<option value=\"USER:", $this_user['user_id'], "\" title='" . sprintf(get_lang('LoginX'), $this_user['username']) . "'>", |
|
962 | + if (!is_array($to_already_selected) || !in_array("USER:".$this_user['user_id'], $to_already_selected)) { // $to_already_selected is the array containing the users (and groups) that are already selected |
|
963 | + echo "<option value=\"USER:", $this_user['user_id'], "\" title='".sprintf(get_lang('LoginX'), $this_user['username'])."'>", |
|
964 | 964 | "", api_get_person_name($this_user['firstname'], $this_user['lastname']), |
965 | 965 | "</option>"; |
966 | 966 | } |
@@ -1073,14 +1073,14 @@ discard block |
||
1073 | 1073 | switch ($to_group) { |
1074 | 1074 | // it was send to one specific user |
1075 | 1075 | case null: |
1076 | - $to[] = "USER:" . $row['to_user_id']; |
|
1076 | + $to[] = "USER:".$row['to_user_id']; |
|
1077 | 1077 | break; |
1078 | 1078 | // it was sent to everyone |
1079 | 1079 | case 0: |
1080 | 1080 | return "everyone"; |
1081 | 1081 | break; |
1082 | 1082 | default: |
1083 | - $to[] = "GROUP:" . $row['to_group_id']; |
|
1083 | + $to[] = "GROUP:".$row['to_group_id']; |
|
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | return $to; |
@@ -1161,10 +1161,10 @@ discard block |
||
1161 | 1161 | $sent_to_array['groups'][0] !== 0 |
1162 | 1162 | ) { |
1163 | 1163 | $group_id = $sent_to_array['groups'][0]; |
1164 | - $output[] = " " . $group_names[$group_id]['name']; |
|
1164 | + $output[] = " ".$group_names[$group_id]['name']; |
|
1165 | 1165 | } |
1166 | 1166 | if (empty($sent_to_array['groups']) and empty($sent_to_array['users'])) { |
1167 | - $output[] = " " . get_lang('Everybody'); |
|
1167 | + $output[] = " ".get_lang('Everybody'); |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1199,7 +1199,7 @@ discard block |
||
1199 | 1199 | |
1200 | 1200 | $sql = "SELECT to_group_id, to_user_id |
1201 | 1201 | FROM $tbl_item_property |
1202 | - WHERE c_id = $course_id AND tool = '$tool' AND ref=" . $id; |
|
1202 | + WHERE c_id = $course_id AND tool = '$tool' AND ref=".$id; |
|
1203 | 1203 | $result = Database::query($sql); |
1204 | 1204 | |
1205 | 1205 | while ($row = Database::fetch_array($result)) { |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | $announcement_id = intval($announcement_id); |
1239 | 1239 | $course_id = api_get_course_int_id(); |
1240 | 1240 | $row = array(); |
1241 | - $sql = 'SELECT id, path, filename, comment FROM ' . $tbl_announcement_attachment . ' |
|
1242 | - WHERE c_id = ' . $course_id . ' AND announcement_id = ' . $announcement_id . ''; |
|
1241 | + $sql = 'SELECT id, path, filename, comment FROM '.$tbl_announcement_attachment.' |
|
1242 | + WHERE c_id = ' . $course_id.' AND announcement_id = '.$announcement_id.''; |
|
1243 | 1243 | $result = Database::query($sql); |
1244 | 1244 | if (Database::num_rows($result) != 0) { |
1245 | 1245 | $row = Database::fetch_array($result, 'ASSOC'); |
@@ -1264,9 +1264,9 @@ discard block |
||
1264 | 1264 | |
1265 | 1265 | if (is_array($file) && $file['error'] == 0) { |
1266 | 1266 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
1267 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
1267 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
1268 | 1268 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
1269 | - $updir = $sys_course_path . $courseDir; |
|
1269 | + $updir = $sys_course_path.$courseDir; |
|
1270 | 1270 | |
1271 | 1271 | // Try to add an extension to the file if it hasn't one |
1272 | 1272 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
1279 | 1279 | } else { |
1280 | 1280 | $new_file_name = uniqid(''); |
1281 | - $new_path = $updir . '/' . $new_file_name; |
|
1281 | + $new_path = $updir.'/'.$new_file_name; |
|
1282 | 1282 | move_uploaded_file($file['tmp_name'], $new_path); |
1283 | 1283 | |
1284 | 1284 | $params = [ |
@@ -1319,9 +1319,9 @@ discard block |
||
1319 | 1319 | |
1320 | 1320 | if (is_array($file) && $file['error'] == 0) { |
1321 | 1321 | // TODO: This path is obsolete. The new document repository scheme should be kept in mind here. |
1322 | - $courseDir = $_course['path'] . '/upload/announcements'; |
|
1322 | + $courseDir = $_course['path'].'/upload/announcements'; |
|
1323 | 1323 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
1324 | - $updir = $sys_course_path . $courseDir; |
|
1324 | + $updir = $sys_course_path.$courseDir; |
|
1325 | 1325 | |
1326 | 1326 | // Try to add an extension to the file if it hasn't one |
1327 | 1327 | $new_file_name = add_ext_on_mime(stripslashes($file['name']), $file['type']); |
@@ -1333,13 +1333,13 @@ discard block |
||
1333 | 1333 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
1334 | 1334 | } else { |
1335 | 1335 | $new_file_name = uniqid(''); |
1336 | - $new_path = $updir . '/' . $new_file_name; |
|
1336 | + $new_path = $updir.'/'.$new_file_name; |
|
1337 | 1337 | @move_uploaded_file($file['tmp_name'], $new_path); |
1338 | 1338 | $safe_file_comment = Database::escape_string($file_comment); |
1339 | 1339 | $safe_file_name = Database::escape_string($file_name); |
1340 | 1340 | $safe_new_file_name = Database::escape_string($new_file_name); |
1341 | 1341 | $id_attach = intval($id_attach); |
1342 | - $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='" . intval($file['size']) . "' |
|
1342 | + $sql = "UPDATE $tbl_announcement_attachment SET filename = '$safe_file_name', comment = '$safe_file_comment', path = '$safe_new_file_name', size ='".intval($file['size'])."' |
|
1343 | 1343 | WHERE c_id = $course_id AND id = '$id_attach'"; |
1344 | 1344 | $result = Database::query($sql); |
1345 | 1345 | if ($result === false) { |
@@ -1441,7 +1441,7 @@ discard block |
||
1441 | 1441 | |
1442 | 1442 | //if (!empty($user_id)) { |
1443 | 1443 | if (0) { |
1444 | - if (is_array($group_memberships) && count($group_memberships) > 0 ) { |
|
1444 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1445 | 1445 | $sql = "SELECT $select |
1446 | 1446 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1447 | 1447 | WHERE |
@@ -1524,7 +1524,7 @@ discard block |
||
1524 | 1524 | } |
1525 | 1525 | } else { |
1526 | 1526 | // STUDENT |
1527 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
1527 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1528 | 1528 | if ($allowUserEditSetting && !api_is_anonymous()) { |
1529 | 1529 | if (api_get_group_id() == 0) { |
1530 | 1530 | // No group |
@@ -1651,8 +1651,8 @@ discard block |
||
1651 | 1651 | $attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
1652 | 1652 | |
1653 | 1653 | $attachment_icon = ''; |
1654 | - if (count($attachment_list)>0) { |
|
1655 | - $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1654 | + if (count($attachment_list) > 0) { |
|
1655 | + $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | 1658 | /* TITLE */ |
@@ -1671,16 +1671,16 @@ discard block |
||
1671 | 1671 | || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
1672 | 1672 | ) { |
1673 | 1673 | $modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">". |
1674 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>"; |
|
1675 | - if ($myrow['visibility']==1) { |
|
1676 | - $image_visibility="visible"; |
|
1677 | - $alt_visibility=get_lang('Hide'); |
|
1674 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
1675 | + if ($myrow['visibility'] == 1) { |
|
1676 | + $image_visibility = "visible"; |
|
1677 | + $alt_visibility = get_lang('Hide'); |
|
1678 | 1678 | } else { |
1679 | - $image_visibility="invisible"; |
|
1680 | - $alt_visibility=get_lang('Visible'); |
|
1679 | + $image_visibility = "invisible"; |
|
1680 | + $alt_visibility = get_lang('Visible'); |
|
1681 | 1681 | } |
1682 | - $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
1683 | - Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>"; |
|
1682 | + $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
1683 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
1684 | 1684 | |
1685 | 1685 | // DISPLAY MOVE UP COMMAND only if it is not the top announcement |
1686 | 1686 | if ($iterator != 1) { |
@@ -1695,12 +1695,12 @@ discard block |
||
1695 | 1695 | } else { |
1696 | 1696 | $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); |
1697 | 1697 | } |
1698 | - if (api_is_allowed_to_edit(false,true)) { |
|
1699 | - $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding()))."')) return false;\">". |
|
1700 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). |
|
1698 | + if (api_is_allowed_to_edit(false, true)) { |
|
1699 | + $modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">". |
|
1700 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
1701 | 1701 | "</a>"; |
1702 | 1702 | } |
1703 | - $iterator ++; |
|
1703 | + $iterator++; |
|
1704 | 1704 | } else { |
1705 | 1705 | $modify_icons = Display::url( |
1706 | 1706 | Display::return_icon('default.png'), |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | public static function getNumberAnnouncements() |
1731 | 1731 | { |
1732 | 1732 | // Maximum title messages to display |
1733 | - $maximum = '12'; |
|
1733 | + $maximum = '12'; |
|
1734 | 1734 | // Database Table Definitions |
1735 | 1735 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
1736 | 1736 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
@@ -1741,7 +1741,7 @@ discard block |
||
1741 | 1741 | $userId = api_get_user_id(); |
1742 | 1742 | $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); |
1743 | 1743 | |
1744 | - if (api_is_allowed_to_edit(false,true)) { |
|
1744 | + if (api_is_allowed_to_edit(false, true)) { |
|
1745 | 1745 | // check teacher status |
1746 | 1746 | if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { |
1747 | 1747 | |
@@ -1804,7 +1804,7 @@ discard block |
||
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements |
1807 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
1807 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
1808 | 1808 | $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
1809 | 1809 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1810 | 1810 | WHERE |
@@ -1854,7 +1854,7 @@ discard block |
||
1854 | 1854 | } |
1855 | 1855 | |
1856 | 1856 | // the user is not identiefied => show only the general announcements |
1857 | - $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
1857 | + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
1858 | 1858 | FROM $tbl_announcement announcement, $tbl_item_property ip |
1859 | 1859 | WHERE |
1860 | 1860 | announcement.c_id = $course_id AND |
@@ -18,6 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Constructor, init tool path for rendering |
20 | 20 | * @param string tool name (optional) |
21 | + * @param string $template_path |
|
21 | 22 | */ |
22 | 23 | public function __construct($toolname = '', $template_path=null) |
23 | 24 | { |
@@ -50,6 +51,7 @@ discard block |
||
50 | 51 | /** |
51 | 52 | * Set layout view sent from a controller |
52 | 53 | * @param string layout view |
54 | + * @param string $layout |
|
53 | 55 | */ |
54 | 56 | public function set_layout( $layout ) |
55 | 57 | { |
@@ -59,6 +61,7 @@ discard block |
||
59 | 61 | /** |
60 | 62 | * Set template view sent from a controller |
61 | 63 | * @param string template view |
64 | + * @param string $template |
|
62 | 65 | */ |
63 | 66 | public function set_template($template) |
64 | 67 | { |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * Constructor, init tool path for rendering |
20 | 20 | * @param string tool name (optional) |
21 | 21 | */ |
22 | - public function __construct($toolname = '', $template_path=null) |
|
22 | + public function __construct($toolname = '', $template_path = null) |
|
23 | 23 | { |
24 | 24 | if (!empty($toolname)) { |
25 | 25 | if (isset($template_path)) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (is_dir($path)) { |
31 | 31 | $this->tool_path = $path; |
32 | 32 | } else { |
33 | - throw new ViewException('View::__construct() $path directory does not exist ' . $path); |
|
33 | + throw new ViewException('View::__construct() $path directory does not exist '.$path); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | public function set_data($data) |
43 | 43 | { |
44 | 44 | if (!is_array($data)) { |
45 | - throw new ViewException('View::set_data() $data must to be an array, you have sent a' . gettype( $data )); |
|
45 | + throw new ViewException('View::set_data() $data must to be an array, you have sent a'.gettype($data)); |
|
46 | 46 | } |
47 | 47 | $this->data = $data; |
48 | 48 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * Set layout view sent from a controller |
52 | 52 | * @param string layout view |
53 | 53 | */ |
54 | - public function set_layout( $layout ) |
|
54 | + public function set_layout($layout) |
|
55 | 55 | { |
56 | 56 | $this->layout = $layout; |
57 | 57 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * Set the name of the browser |
161 | - * @param $browser string The name of the Browser |
|
161 | + * @param string $browser string The name of the Browser |
|
162 | 162 | */ |
163 | 163 | public function setBrowser($browser) |
164 | 164 | { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Set the browser to be from AOL |
269 | - * @param $isAol |
|
269 | + * @param boolean $isAol |
|
270 | 270 | */ |
271 | 271 | public function setAol($isAol) |
272 | 272 | { |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | */ |
346 | 346 | public function __toString() |
347 | 347 | { |
348 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
349 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
350 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
348 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n". |
|
349 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n". |
|
350 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n". |
|
351 | 351 | "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
352 | 352 | } |
353 | 353 | |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); |
586 | 586 | $this->setBrowser(self::BROWSER_IE); |
587 | 587 | $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
588 | - if(stripos($this->_agent, 'IEMobile') !== false) { |
|
588 | + if (stripos($this->_agent, 'IEMobile') !== false) { |
|
589 | 589 | $this->setBrowser(self::BROWSER_POCKET_IE); |
590 | 590 | $this->setMobile(true); |
591 | 591 | } |
592 | 592 | return true; |
593 | 593 | } // Test for versions > IE 10 |
594 | - else if(stripos($this->_agent, 'trident') !== false) { |
|
594 | + else if (stripos($this->_agent, 'trident') !== false) { |
|
595 | 595 | $this->setBrowser(self::BROWSER_IE); |
596 | 596 | $result = explode('rv:', $this->_agent); |
597 | 597 | $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | protected function checkFacebookExternalHit() |
1014 | 1014 | { |
1015 | - if(stristr($this->_agent,'FacebookExternalHit')) |
|
1015 | + if (stristr($this->_agent, 'FacebookExternalHit')) |
|
1016 | 1016 | { |
1017 | 1017 | $this->setRobot(true); |
1018 | 1018 | $this->setFacebook(true); |
@@ -1027,7 +1027,7 @@ discard block |
||
1027 | 1027 | */ |
1028 | 1028 | protected function checkForFacebookIos() |
1029 | 1029 | { |
1030 | - if(stristr($this->_agent,'FBIOS')) |
|
1030 | + if (stristr($this->_agent, 'FBIOS')) |
|
1031 | 1031 | { |
1032 | 1032 | $this->setFacebook(true); |
1033 | 1033 | return true; |
@@ -1041,10 +1041,10 @@ discard block |
||
1041 | 1041 | */ |
1042 | 1042 | protected function getSafariVersionOnIos() |
1043 | 1043 | { |
1044 | - $aresult = explode('/',stristr($this->_agent,'Version')); |
|
1045 | - if( isset($aresult[1]) ) |
|
1044 | + $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
1045 | + if (isset($aresult[1])) |
|
1046 | 1046 | { |
1047 | - $aversion = explode(' ',$aresult[1]); |
|
1047 | + $aversion = explode(' ', $aresult[1]); |
|
1048 | 1048 | $this->setVersion($aversion[0]); |
1049 | 1049 | return true; |
1050 | 1050 | } |
@@ -1057,10 +1057,10 @@ discard block |
||
1057 | 1057 | */ |
1058 | 1058 | protected function getChromeVersionOnIos() |
1059 | 1059 | { |
1060 | - $aresult = explode('/',stristr($this->_agent,'CriOS')); |
|
1061 | - if( isset($aresult[1]) ) |
|
1060 | + $aresult = explode('/', stristr($this->_agent, 'CriOS')); |
|
1061 | + if (isset($aresult[1])) |
|
1062 | 1062 | { |
1063 | - $aversion = explode(' ',$aresult[1]); |
|
1063 | + $aversion = explode(' ', $aresult[1]); |
|
1064 | 1064 | $this->setVersion($aversion[0]); |
1065 | 1065 | $this->setBrowser(self::BROWSER_CHROME); |
1066 | 1066 | return true; |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | * @return boolean True if the browser is iPhone otherwise false |
1074 | 1074 | */ |
1075 | 1075 | protected function checkBrowseriPhone() { |
1076 | - if( stripos($this->_agent,'iPhone') !== false ) { |
|
1076 | + if (stripos($this->_agent, 'iPhone') !== false) { |
|
1077 | 1077 | $this->setVersion(self::VERSION_UNKNOWN); |
1078 | 1078 | $this->setBrowser(self::BROWSER_IPHONE); |
1079 | 1079 | $this->getSafariVersionOnIos(); |
@@ -1090,7 +1090,7 @@ discard block |
||
1090 | 1090 | * @return boolean True if the browser is iPad otherwise false |
1091 | 1091 | */ |
1092 | 1092 | protected function checkBrowseriPad() { |
1093 | - if( stripos($this->_agent,'iPad') !== false ) { |
|
1093 | + if (stripos($this->_agent, 'iPad') !== false) { |
|
1094 | 1094 | $this->setVersion(self::VERSION_UNKNOWN); |
1095 | 1095 | $this->setBrowser(self::BROWSER_IPAD); |
1096 | 1096 | $this->getSafariVersionOnIos(); |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | * @return boolean True if the browser is iPod otherwise false |
1108 | 1108 | */ |
1109 | 1109 | protected function checkBrowseriPod() { |
1110 | - if( stripos($this->_agent,'iPod') !== false ) { |
|
1110 | + if (stripos($this->_agent, 'iPod') !== false) { |
|
1111 | 1111 | $this->setVersion(self::VERSION_UNKNOWN); |
1112 | 1112 | $this->setBrowser(self::BROWSER_IPOD); |
1113 | 1113 | $this->getSafariVersionOnIos(); |
@@ -1152,68 +1152,52 @@ |
||
1152 | 1152 | if (stripos($this->_agent, 'windows') !== false) |
1153 | 1153 | { |
1154 | 1154 | $this->_platform = self::PLATFORM_WINDOWS; |
1155 | - } |
|
1156 | - else if (stripos($this->_agent, 'iPad') !== false) |
|
1155 | + } else if (stripos($this->_agent, 'iPad') !== false) |
|
1157 | 1156 | { |
1158 | 1157 | $this->_platform = self::PLATFORM_IPAD; |
1159 | - } |
|
1160 | - else if (stripos($this->_agent, 'iPod') !== false) |
|
1158 | + } else if (stripos($this->_agent, 'iPod') !== false) |
|
1161 | 1159 | { |
1162 | 1160 | $this->_platform = self::PLATFORM_IPOD; |
1163 | - } |
|
1164 | - else if (stripos($this->_agent, 'iPhone') !== false) |
|
1161 | + } else if (stripos($this->_agent, 'iPhone') !== false) |
|
1165 | 1162 | { |
1166 | 1163 | $this->_platform = self::PLATFORM_IPHONE; |
1167 | - } |
|
1168 | - elseif (stripos($this->_agent, 'mac') !== false) |
|
1164 | + } elseif (stripos($this->_agent, 'mac') !== false) |
|
1169 | 1165 | { |
1170 | 1166 | $this->_platform = self::PLATFORM_APPLE; |
1171 | - } |
|
1172 | - elseif (stripos($this->_agent, 'android') !== false) |
|
1167 | + } elseif (stripos($this->_agent, 'android') !== false) |
|
1173 | 1168 | { |
1174 | 1169 | $this->_platform = self::PLATFORM_ANDROID; |
1175 | - } |
|
1176 | - elseif (stripos($this->_agent, 'linux') !== false) |
|
1170 | + } elseif (stripos($this->_agent, 'linux') !== false) |
|
1177 | 1171 | { |
1178 | 1172 | $this->_platform = self::PLATFORM_LINUX; |
1179 | - } |
|
1180 | - else if (stripos($this->_agent, 'Nokia') !== false) |
|
1173 | + } else if (stripos($this->_agent, 'Nokia') !== false) |
|
1181 | 1174 | { |
1182 | 1175 | $this->_platform = self::PLATFORM_NOKIA; |
1183 | - } |
|
1184 | - else if (stripos($this->_agent, 'BlackBerry') !== false) |
|
1176 | + } else if (stripos($this->_agent, 'BlackBerry') !== false) |
|
1185 | 1177 | { |
1186 | 1178 | $this->_platform = self::PLATFORM_BLACKBERRY; |
1187 | - } |
|
1188 | - elseif (stripos($this->_agent, 'FreeBSD') !== false) |
|
1179 | + } elseif (stripos($this->_agent, 'FreeBSD') !== false) |
|
1189 | 1180 | { |
1190 | 1181 | $this->_platform = self::PLATFORM_FREEBSD; |
1191 | - } |
|
1192 | - elseif (stripos($this->_agent, 'OpenBSD') !== false) |
|
1182 | + } elseif (stripos($this->_agent, 'OpenBSD') !== false) |
|
1193 | 1183 | { |
1194 | 1184 | $this->_platform = self::PLATFORM_OPENBSD; |
1195 | - } |
|
1196 | - elseif (stripos($this->_agent, 'NetBSD') !== false) |
|
1185 | + } elseif (stripos($this->_agent, 'NetBSD') !== false) |
|
1197 | 1186 | { |
1198 | 1187 | $this->_platform = self::PLATFORM_NETBSD; |
1199 | - } |
|
1200 | - elseif (stripos($this->_agent, 'OpenSolaris') !== false) |
|
1188 | + } elseif (stripos($this->_agent, 'OpenSolaris') !== false) |
|
1201 | 1189 | { |
1202 | 1190 | $this->_platform = self::PLATFORM_OPENSOLARIS; |
1203 | - } |
|
1204 | - elseif (stripos($this->_agent, 'SunOS') !== false) |
|
1191 | + } elseif (stripos($this->_agent, 'SunOS') !== false) |
|
1205 | 1192 | { |
1206 | 1193 | $this->_platform = self::PLATFORM_SUNOS; |
1207 | - } |
|
1208 | - elseif (stripos($this->_agent, 'OS\/2') !== false) |
|
1194 | + } elseif (stripos($this->_agent, 'OS\/2') !== false) |
|
1209 | 1195 | { |
1210 | 1196 | $this->_platform = self::PLATFORM_OS2; |
1211 | - } |
|
1212 | - elseif (stripos($this->_agent, 'BeOS') !== false) |
|
1197 | + } elseif (stripos($this->_agent, 'BeOS') !== false) |
|
1213 | 1198 | { |
1214 | 1199 | $this->_platform = self::PLATFORM_BEOS; |
1215 | - } |
|
1216 | - elseif (stripos($this->_agent, 'win') !== false) |
|
1200 | + } elseif (stripos($this->_agent, 'win') !== false) |
|
1217 | 1201 | { |
1218 | 1202 | $this->_platform = self::PLATFORM_WINDOWS; |
1219 | 1203 | } |
@@ -1,38 +1,38 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * File: Browser.php |
|
4 | - * Author: Chris Schuld (http://chrisschuld.com/) |
|
5 | - * Last Modified: August 20th, 2010 |
|
6 | - * @version 1.9 |
|
7 | - * @package PegasusPHP |
|
8 | - * |
|
9 | - * Copyright (C) 2008-2010 Chris Schuld ([email protected]) |
|
10 | - * |
|
11 | - * This program is free software; you can redistribute it and/or |
|
12 | - * modify it under the terms of the GNU General Public License as |
|
13 | - * published by the Free Software Foundation; either version 2 of |
|
14 | - * the License, or (at your option) any later version. |
|
15 | - * |
|
16 | - * This program is distributed in the hope that it will be useful, |
|
17 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 | - * GNU General Public License for more details at: |
|
20 | - * http://www.gnu.org/copyleft/gpl.html |
|
21 | - * |
|
22 | - * |
|
23 | - * Typical Usage: |
|
24 | - * |
|
25 | - * $browser = new Browser(); |
|
26 | - * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) { |
|
27 | - * echo 'You have FireFox version 2 or greater'; |
|
28 | - * } |
|
29 | - * |
|
30 | - * User Agents Sampled from: http://www.useragentstring.com/ |
|
31 | - * |
|
32 | - * This implementation is based on the original work from Gary White |
|
33 | - * http://apptools.com/phptools/browser/ |
|
34 | - * Git and Packagist info: https://github.com/cbschuld/Browser.php |
|
35 | - */ |
|
3 | + * File: Browser.php |
|
4 | + * Author: Chris Schuld (http://chrisschuld.com/) |
|
5 | + * Last Modified: August 20th, 2010 |
|
6 | + * @version 1.9 |
|
7 | + * @package PegasusPHP |
|
8 | + * |
|
9 | + * Copyright (C) 2008-2010 Chris Schuld ([email protected]) |
|
10 | + * |
|
11 | + * This program is free software; you can redistribute it and/or |
|
12 | + * modify it under the terms of the GNU General Public License as |
|
13 | + * published by the Free Software Foundation; either version 2 of |
|
14 | + * the License, or (at your option) any later version. |
|
15 | + * |
|
16 | + * This program is distributed in the hope that it will be useful, |
|
17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 | + * GNU General Public License for more details at: |
|
20 | + * http://www.gnu.org/copyleft/gpl.html |
|
21 | + * |
|
22 | + * |
|
23 | + * Typical Usage: |
|
24 | + * |
|
25 | + * $browser = new Browser(); |
|
26 | + * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) { |
|
27 | + * echo 'You have FireFox version 2 or greater'; |
|
28 | + * } |
|
29 | + * |
|
30 | + * User Agents Sampled from: http://www.useragentstring.com/ |
|
31 | + * |
|
32 | + * This implementation is based on the original work from Gary White |
|
33 | + * http://apptools.com/phptools/browser/ |
|
34 | + * Git and Packagist info: https://github.com/cbschuld/Browser.php |
|
35 | + */ |
|
36 | 36 | |
37 | 37 | class Browser |
38 | 38 | { |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
259 | - * Is the browser from facebook? |
|
260 | - * @return boolean True if the browser is from facebook otherwise false |
|
261 | - */ |
|
259 | + * Is the browser from facebook? |
|
260 | + * @return boolean True if the browser is from facebook otherwise false |
|
261 | + */ |
|
262 | 262 | public function isFacebook() |
263 | 263 | { |
264 | 264 | return $this->_is_facebook; |
@@ -591,12 +591,12 @@ discard block |
||
591 | 591 | } |
592 | 592 | return true; |
593 | 593 | } // Test for versions > IE 10 |
594 | - else if(stripos($this->_agent, 'trident') !== false) { |
|
595 | - $this->setBrowser(self::BROWSER_IE); |
|
596 | - $result = explode('rv:', $this->_agent); |
|
597 | - $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
598 | - $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
599 | - } // Test for Pocket IE |
|
594 | + else if(stripos($this->_agent, 'trident') !== false) { |
|
595 | + $this->setBrowser(self::BROWSER_IE); |
|
596 | + $result = explode('rv:', $this->_agent); |
|
597 | + $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
598 | + $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
599 | + } // Test for Pocket IE |
|
600 | 600 | else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) { |
601 | 601 | $aresult = explode(' ', stristr($this->_agent, 'mspie')); |
602 | 602 | $this->setPlatform(self::PLATFORM_WINDOWS_CE); |
@@ -41,6 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * Set user chat status |
43 | 43 | * @param int 0 if disconnected, 1 if connected |
44 | + * @param integer $status |
|
44 | 45 | * |
45 | 46 | * @return void |
46 | 47 | */ |
@@ -164,6 +165,7 @@ discard block |
||
164 | 165 | /** |
165 | 166 | * Saves into session the fact that a chat window exists with the given user |
166 | 167 | * @param int The ID of the user with whom the current user is chatting |
168 | + * @param integer $user_id |
|
167 | 169 | * @return void |
168 | 170 | */ |
169 | 171 | public function save_window($user_id) |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $to_user_id, |
187 | 187 | $message, |
188 | 188 | $printResult = true, |
189 | - $sanitize = true |
|
189 | + $sanitize = true |
|
190 | 190 | ) |
191 | 191 | { |
192 | 192 | $user_friend_relation = SocialManager::get_relation_between_contacts( |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | $messagesan = $message; |
207 | 207 | } |
208 | 208 | |
209 | - error_log(print_r($sanitize) . '----' . $messagesan); |
|
209 | + error_log(print_r($sanitize).'----'.$messagesan); |
|
210 | 210 | |
211 | 211 | if (!isset($_SESSION['chatHistory'][$to_user_id])) { |
212 | 212 | $_SESSION['chatHistory'][$to_user_id] = array(); |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | */ |
290 | 290 | public static function disableChat() |
291 | 291 | { |
292 | - if (!empty($_SESSION['disable_chat'])){ |
|
292 | + if (!empty($_SESSION['disable_chat'])) { |
|
293 | 293 | $status = $_SESSION['disable_chat']; |
294 | - if ($status == true){ |
|
294 | + if ($status == true) { |
|
295 | 295 | $_SESSION['disable_chat'] = null; |
296 | 296 | return true; |
297 | 297 | } |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | - * Set user chat status |
|
48 | - * @param int 0 if disconnected, 1 if connected |
|
47 | + * Set user chat status |
|
48 | + * @param int 0 if disconnected, 1 if connected |
|
49 | 49 | * |
50 | - * @return void |
|
51 | - */ |
|
50 | + * @return void |
|
51 | + */ |
|
52 | 52 | public function setUserStatus($status) |
53 | 53 | { |
54 | 54 | UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | - * Returns an array of messages inside a chat session with a specific user |
|
153 | - * @param int The ID of the user with whom the current user is chatting |
|
154 | - * @return array Messages list |
|
155 | - */ |
|
152 | + * Returns an array of messages inside a chat session with a specific user |
|
153 | + * @param int The ID of the user with whom the current user is chatting |
|
154 | + * @return array Messages list |
|
155 | + */ |
|
156 | 156 | public function box_session($user_id) |
157 | 157 | { |
158 | 158 | $items = array(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * Get all data by description and session id, |
96 | 96 | * first you must set session_id property with the object CourseDescription |
97 | 97 | * @param int $description_type Description type |
98 | - * @param string $course_code Course code (optional) |
|
98 | + * @param string $courseId Course code (optional) |
|
99 | 99 | * @param int $session_id Session id (optional) |
100 | 100 | * @return array List of fields from the descriptions found of the given type |
101 | 101 | */ |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Get description titles by default |
362 | - * @return array |
|
362 | + * @return string[] |
|
363 | 363 | */ |
364 | 364 | public function get_default_description_title() |
365 | 365 | { |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | /** |
380 | 380 | * Get description titles editable by default |
381 | - * @return array |
|
381 | + * @return boolean[] |
|
382 | 382 | */ |
383 | 383 | public function get_default_description_title_editable() |
384 | 384 | { |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | /** |
399 | 399 | * Get description icons by default |
400 | - * @return array |
|
400 | + * @return string[] |
|
401 | 401 | */ |
402 | 402 | public function get_default_description_icon() |
403 | 403 | { |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Get questions by default for help |
420 | - * @return array |
|
420 | + * @return string[] |
|
421 | 421 | */ |
422 | 422 | public function get_default_question() |
423 | 423 | { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | |
437 | 437 | /** |
438 | 438 | * Get informations by default for help |
439 | - * @return array |
|
439 | + * @return string[] |
|
440 | 440 | */ |
441 | 441 | public function get_default_information() |
442 | 442 | { |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $sql = "SELECT MAX(description_type) as MAX |
178 | 178 | FROM $tbl_course_description |
179 | - WHERE c_id = $course_id AND session_id='" . $this->session_id . "'"; |
|
179 | + WHERE c_id = $course_id AND session_id='".$this->session_id."'"; |
|
180 | 180 | $rs = Database::query($sql); |
181 | 181 | $max = Database::fetch_array($rs); |
182 | 182 | $description_type = $max['MAX'] + 1; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | 'session_id' => $this->session_id |
212 | 212 | ]; |
213 | 213 | |
214 | - $last_id = Database::insert($table, $params); |
|
214 | + $last_id = Database::insert($table, $params); |
|
215 | 215 | |
216 | 216 | if ($last_id > 0) { |
217 | 217 | $sql = "UPDATE $table SET id = iid WHERE iid = $last_id"; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | $sql = "DELETE FROM $tbl_course_description |
320 | 320 | WHERE |
321 | 321 | c_id = $course_id AND |
322 | - id = '" . intval($this->id) . "' AND |
|
323 | - session_id = '" . intval($this->session_id) . "'"; |
|
322 | + id = '".intval($this->id)."' AND |
|
323 | + session_id = '" . intval($this->session_id)."'"; |
|
324 | 324 | $result = Database::query($sql); |
325 | 325 | $affected_rows = Database::affected_rows($result); |
326 | 326 | if ($this->id > 0) { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $course_id = api_get_course_int_id(); |
350 | 350 | |
351 | 351 | $sql = "SELECT id FROM $tbl_course_description |
352 | - WHERE c_id = $course_id AND description_type = '" . intval($description_type) . "'"; |
|
352 | + WHERE c_id = $course_id AND description_type = '".intval($description_type)."'"; |
|
353 | 353 | $rs = Database::query($sql); |
354 | 354 | $row = Database::fetch_array($rs); |
355 | 355 | $description_id = $row['id']; |
@@ -493,6 +493,7 @@ |
||
493 | 493 | * This function update extra user blocks data after closing a dashboard block |
494 | 494 | * @param int User id |
495 | 495 | * @param string plugin path |
496 | + * @param integer $user_id |
|
496 | 497 | * @return bool |
497 | 498 | */ |
498 | 499 | public static function close_user_block($user_id, $path) |
@@ -380,7 +380,9 @@ |
||
380 | 380 | // check if user is allowed to see the block |
381 | 381 | if (method_exists($obj_block, 'is_block_visible_for_user')) { |
382 | 382 | $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
383 | - if (!$is_block_visible_for_user) continue; |
|
383 | + if (!$is_block_visible_for_user) { |
|
384 | + continue; |
|
385 | + } |
|
384 | 386 | } |
385 | 387 | |
386 | 388 | echo '<tr>'; |
@@ -249,286 +249,286 @@ |
||
249 | 249 | return $affected_rows; |
250 | 250 | } |
251 | 251 | |
252 | - /** |
|
253 | - * Get all plugins path inside dashboard directory |
|
254 | - * @return array name plugins directories |
|
255 | - */ |
|
256 | - public static function getPossibleDashboardPluginsPath() |
|
252 | + /** |
|
253 | + * Get all plugins path inside dashboard directory |
|
254 | + * @return array name plugins directories |
|
255 | + */ |
|
256 | + public static function getPossibleDashboardPluginsPath() |
|
257 | 257 | { |
258 | - // get all plugins path inside plugin directory |
|
259 | - /* We scan the plugin directory. Each folder is a potential plugin. */ |
|
260 | - $possiblePlugins = array(); |
|
261 | - $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; |
|
262 | - $handle = @opendir($dashboard_pluginpath); |
|
263 | - while (false !== ($file = readdir($handle))) { |
|
264 | - if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { |
|
265 | - $possiblePlugins[] = $file; |
|
266 | - } |
|
267 | - } |
|
268 | - @closedir($handle); |
|
269 | - |
|
270 | - return $possiblePlugins; |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Get all blocks data without plugin directory |
|
275 | - * @return array Block data |
|
276 | - */ |
|
277 | - public static function get_block_data_without_plugin() |
|
258 | + // get all plugins path inside plugin directory |
|
259 | + /* We scan the plugin directory. Each folder is a potential plugin. */ |
|
260 | + $possiblePlugins = array(); |
|
261 | + $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; |
|
262 | + $handle = @opendir($dashboard_pluginpath); |
|
263 | + while (false !== ($file = readdir($handle))) { |
|
264 | + if ($file <> '.' AND $file <> '..' AND is_dir($dashboard_pluginpath.$file)) { |
|
265 | + $possiblePlugins[] = $file; |
|
266 | + } |
|
267 | + } |
|
268 | + @closedir($handle); |
|
269 | + |
|
270 | + return $possiblePlugins; |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Get all blocks data without plugin directory |
|
275 | + * @return array Block data |
|
276 | + */ |
|
277 | + public static function get_block_data_without_plugin() |
|
278 | 278 | { |
279 | - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
280 | - $possibleplugins = self::getPossibleDashboardPluginsPath(); |
|
281 | - |
|
282 | - // We check if plugin exists inside directory for updating active field |
|
283 | - $sql = "SELECT * FROM $tbl_block"; |
|
284 | - $rs = Database::query($sql); |
|
285 | - if (Database::num_rows($rs) > 0){ |
|
286 | - while ($row = Database::fetch_array($rs)) { |
|
287 | - $path = $row['path']; |
|
288 | - if (!in_array($row['path'],$possibleplugins)) { |
|
289 | - $active = 0; |
|
290 | - } else { |
|
291 | - $active = 1; |
|
292 | - } |
|
293 | - // update active |
|
294 | - $upd = "UPDATE $tbl_block SET active = '$active' |
|
279 | + $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
280 | + $possibleplugins = self::getPossibleDashboardPluginsPath(); |
|
281 | + |
|
282 | + // We check if plugin exists inside directory for updating active field |
|
283 | + $sql = "SELECT * FROM $tbl_block"; |
|
284 | + $rs = Database::query($sql); |
|
285 | + if (Database::num_rows($rs) > 0){ |
|
286 | + while ($row = Database::fetch_array($rs)) { |
|
287 | + $path = $row['path']; |
|
288 | + if (!in_array($row['path'],$possibleplugins)) { |
|
289 | + $active = 0; |
|
290 | + } else { |
|
291 | + $active = 1; |
|
292 | + } |
|
293 | + // update active |
|
294 | + $upd = "UPDATE $tbl_block SET active = '$active' |
|
295 | 295 | WHERE path = '".$row['path']."'"; |
296 | - Database::query($upd); |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - // get disabled block data |
|
301 | - $block_data = array(); |
|
302 | - $sql = "SELECT * FROM $tbl_block WHERE active = 0"; |
|
303 | - $rs_block = Database::query($sql); |
|
304 | - if (Database::num_rows($rs_block) > 0) { |
|
305 | - while ($row_block = Database::fetch_array($rs_block)) { |
|
306 | - $block_data[] = $row_block; |
|
307 | - } |
|
308 | - } |
|
309 | - |
|
310 | - return $block_data; |
|
311 | - |
|
312 | - } |
|
313 | - |
|
314 | - /** |
|
315 | - * get data about enabled dashboard block (stored insise block table) |
|
316 | - * @param string plugin path |
|
317 | - * @return array data |
|
318 | - */ |
|
319 | - public static function get_enabled_dashboard_blocks($path = '') |
|
296 | + Database::query($upd); |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + // get disabled block data |
|
301 | + $block_data = array(); |
|
302 | + $sql = "SELECT * FROM $tbl_block WHERE active = 0"; |
|
303 | + $rs_block = Database::query($sql); |
|
304 | + if (Database::num_rows($rs_block) > 0) { |
|
305 | + while ($row_block = Database::fetch_array($rs_block)) { |
|
306 | + $block_data[] = $row_block; |
|
307 | + } |
|
308 | + } |
|
309 | + |
|
310 | + return $block_data; |
|
311 | + |
|
312 | + } |
|
313 | + |
|
314 | + /** |
|
315 | + * get data about enabled dashboard block (stored insise block table) |
|
316 | + * @param string plugin path |
|
317 | + * @return array data |
|
318 | + */ |
|
319 | + public static function get_enabled_dashboard_blocks($path = '') |
|
320 | 320 | { |
321 | - $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
322 | - $condition_path = ''; |
|
323 | - if (!empty($path)) { |
|
324 | - $path = Database::escape_string($path); |
|
325 | - $condition_path = ' AND path = "'.$path.'" '; |
|
326 | - } |
|
327 | - |
|
328 | - $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; |
|
329 | - $rs = Database::query($sql); |
|
330 | - $block_data = array(); |
|
331 | - if (Database::num_rows($rs) > 0) { |
|
332 | - while ($row = Database::fetch_array($rs)) { |
|
333 | - $block_data[$row['path']] = $row; |
|
334 | - } |
|
335 | - } |
|
336 | - return $block_data; |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * display user dashboard list |
|
341 | - * @param int User id |
|
342 | - * @return void |
|
343 | - */ |
|
344 | - public static function display_user_dashboard_list($user_id) |
|
321 | + $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); |
|
322 | + $condition_path = ''; |
|
323 | + if (!empty($path)) { |
|
324 | + $path = Database::escape_string($path); |
|
325 | + $condition_path = ' AND path = "'.$path.'" '; |
|
326 | + } |
|
327 | + |
|
328 | + $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; |
|
329 | + $rs = Database::query($sql); |
|
330 | + $block_data = array(); |
|
331 | + if (Database::num_rows($rs) > 0) { |
|
332 | + while ($row = Database::fetch_array($rs)) { |
|
333 | + $block_data[$row['path']] = $row; |
|
334 | + } |
|
335 | + } |
|
336 | + return $block_data; |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * display user dashboard list |
|
341 | + * @param int User id |
|
342 | + * @return void |
|
343 | + */ |
|
344 | + public static function display_user_dashboard_list($user_id) |
|
345 | 345 | { |
346 | - $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks(); |
|
347 | - $user_block_data = self::get_user_block_data($user_id); |
|
348 | - |
|
349 | - if (count($enabled_dashboard_plugins) > 0) { |
|
350 | - echo '<div style="margin-top:20px">'; |
|
351 | - echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />'; |
|
352 | - echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">'; |
|
353 | - echo '<table class="data_table">'; |
|
354 | - echo '<tr>'; |
|
355 | - echo '<th width="5%">'; |
|
356 | - echo get_lang('Enabled'); |
|
357 | - echo '</th>'; |
|
358 | - echo '<th width="30%">'; |
|
359 | - echo get_lang('Name'); |
|
360 | - echo '</th>'; |
|
361 | - echo '<th width="40%">'; |
|
362 | - echo get_lang('Description'); |
|
363 | - echo '</th>'; |
|
364 | - echo '<th>'; |
|
365 | - echo get_lang('ColumnPosition'); |
|
366 | - echo '</th>'; |
|
367 | - echo '</tr>'; |
|
368 | - |
|
369 | - // We display all enabled plugins and the checkboxes |
|
370 | - foreach ($enabled_dashboard_plugins as $block) { |
|
371 | - |
|
372 | - $path = $block['path']; |
|
373 | - $controller_class = $block['controller']; |
|
374 | - $filename_controller = $path.'.class.php'; |
|
375 | - $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; |
|
376 | - require_once $dashboard_plugin_path.$filename_controller; |
|
377 | - if (class_exists($controller_class)) { |
|
378 | - $obj_block = new $controller_class($user_id); |
|
379 | - |
|
380 | - // check if user is allowed to see the block |
|
381 | - if (method_exists($obj_block, 'is_block_visible_for_user')) { |
|
382 | - $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
|
383 | - if (!$is_block_visible_for_user) continue; |
|
384 | - } |
|
385 | - |
|
386 | - echo '<tr>'; |
|
387 | - // checkboxes |
|
388 | - self::display_user_dashboard_list_checkboxes($user_id, $block['id']); |
|
389 | - echo '<td>'.$block['name'].'</td>'; |
|
390 | - echo '<td>'.$block['description'].'</td>'; |
|
391 | - echo '<td> |
|
346 | + $enabled_dashboard_plugins = self::get_enabled_dashboard_blocks(); |
|
347 | + $user_block_data = self::get_user_block_data($user_id); |
|
348 | + |
|
349 | + if (count($enabled_dashboard_plugins) > 0) { |
|
350 | + echo '<div style="margin-top:20px">'; |
|
351 | + echo '<div><strong>'.get_lang('SelectBlockForDisplayingInsideBlocksDashboardView').'</strong></div><br />'; |
|
352 | + echo '<form name="dashboard_list" method="post" action="index.php?action=store_user_block">'; |
|
353 | + echo '<table class="data_table">'; |
|
354 | + echo '<tr>'; |
|
355 | + echo '<th width="5%">'; |
|
356 | + echo get_lang('Enabled'); |
|
357 | + echo '</th>'; |
|
358 | + echo '<th width="30%">'; |
|
359 | + echo get_lang('Name'); |
|
360 | + echo '</th>'; |
|
361 | + echo '<th width="40%">'; |
|
362 | + echo get_lang('Description'); |
|
363 | + echo '</th>'; |
|
364 | + echo '<th>'; |
|
365 | + echo get_lang('ColumnPosition'); |
|
366 | + echo '</th>'; |
|
367 | + echo '</tr>'; |
|
368 | + |
|
369 | + // We display all enabled plugins and the checkboxes |
|
370 | + foreach ($enabled_dashboard_plugins as $block) { |
|
371 | + |
|
372 | + $path = $block['path']; |
|
373 | + $controller_class = $block['controller']; |
|
374 | + $filename_controller = $path.'.class.php'; |
|
375 | + $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; |
|
376 | + require_once $dashboard_plugin_path.$filename_controller; |
|
377 | + if (class_exists($controller_class)) { |
|
378 | + $obj_block = new $controller_class($user_id); |
|
379 | + |
|
380 | + // check if user is allowed to see the block |
|
381 | + if (method_exists($obj_block, 'is_block_visible_for_user')) { |
|
382 | + $is_block_visible_for_user = $obj_block->is_block_visible_for_user($user_id); |
|
383 | + if (!$is_block_visible_for_user) continue; |
|
384 | + } |
|
385 | + |
|
386 | + echo '<tr>'; |
|
387 | + // checkboxes |
|
388 | + self::display_user_dashboard_list_checkboxes($user_id, $block['id']); |
|
389 | + echo '<td>'.$block['name'].'</td>'; |
|
390 | + echo '<td>'.$block['description'].'</td>'; |
|
391 | + echo '<td> |
|
392 | 392 | <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']"> |
393 | 393 | <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option> |
394 | 394 | <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option> |
395 | 395 | </select> |
396 | 396 | </td>'; |
397 | - echo '</tr>'; |
|
398 | - } else { |
|
399 | - echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - echo '</table>'; |
|
404 | - echo '<div class="row"><div class="col-md-12">'; |
|
405 | - echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '. |
|
397 | + echo '</tr>'; |
|
398 | + } else { |
|
399 | + echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + echo '</table>'; |
|
404 | + echo '<div class="row"><div class="col-md-12">'; |
|
405 | + echo '<button class="btn btn-default" type="submit" name="submit_dashboard_list" value="'.get_lang('EnableDashboardBlock').'"><em class="fa fa-check-square"></em> '. |
|
406 | 406 | get_lang('EnableDashboardBlock').'</button></form>'; |
407 | - echo '</div></div>'; |
|
408 | - } else { |
|
409 | - echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>'; |
|
410 | - if (api_is_platform_admin()) { |
|
411 | - echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'. |
|
407 | + echo '</div></div>'; |
|
408 | + } else { |
|
409 | + echo '<div style="margin-top:20px">'.get_lang('ThereAreNoEnabledDashboardPlugins').'</div>'; |
|
410 | + if (api_is_platform_admin()) { |
|
411 | + echo '<a class="btn btn-default" href="'.api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins">'. |
|
412 | 412 | get_lang('ConfigureDashboardPlugin').'</a>'; |
413 | - } |
|
414 | - } |
|
415 | - } |
|
416 | - |
|
417 | - /** |
|
418 | - * display checkboxes for user dashboard list |
|
419 | - * @param int User id |
|
420 | - * @param int Block id |
|
421 | - * @return void |
|
422 | - */ |
|
423 | - public static function display_user_dashboard_list_checkboxes($user_id, $block_id) { |
|
424 | - |
|
425 | - $user_id = intval($user_id); |
|
426 | - $user_block_data = self::get_user_block_data($user_id); |
|
427 | - $enabled_blocks_id = array_keys($user_block_data); |
|
428 | - |
|
429 | - $checked = ''; |
|
430 | - if (in_array($block_id, $enabled_blocks_id)) { |
|
431 | - $checked = "checked"; |
|
432 | - } |
|
433 | - |
|
434 | - echo "<td align=\"center\">"; |
|
435 | - echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>'; |
|
436 | - echo "</td>"; |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields |
|
441 | - * @param int User id |
|
442 | - * @param array selected blocks |
|
443 | - * @param array columns position |
|
444 | - * @return bool |
|
445 | - */ |
|
446 | - public static function store_user_blocks($user_id, $enabled_blocks, $columns) { |
|
447 | - $selected_blocks_id = array(); |
|
448 | - if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { |
|
449 | - $selected_blocks_id = array_keys($enabled_blocks); |
|
450 | - } |
|
451 | - |
|
452 | - // build data for storing inside extra user field |
|
453 | - $fname = 'dashboard'; |
|
454 | - $fvalue = array(); |
|
455 | - foreach ($selected_blocks_id as $block_id) { |
|
456 | - $fvalue[] = $block_id.':'.$columns[$block_id]; |
|
457 | - } |
|
413 | + } |
|
414 | + } |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * display checkboxes for user dashboard list |
|
419 | + * @param int User id |
|
420 | + * @param int Block id |
|
421 | + * @return void |
|
422 | + */ |
|
423 | + public static function display_user_dashboard_list_checkboxes($user_id, $block_id) { |
|
424 | + |
|
425 | + $user_id = intval($user_id); |
|
426 | + $user_block_data = self::get_user_block_data($user_id); |
|
427 | + $enabled_blocks_id = array_keys($user_block_data); |
|
428 | + |
|
429 | + $checked = ''; |
|
430 | + if (in_array($block_id, $enabled_blocks_id)) { |
|
431 | + $checked = "checked"; |
|
432 | + } |
|
433 | + |
|
434 | + echo "<td align=\"center\">"; |
|
435 | + echo '<input type="checkbox" name="enabled_blocks['.$block_id.']" value="true" '.$checked.'/>'; |
|
436 | + echo "</td>"; |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * This function store enabled blocks id with its column position (block_id1:colum;block_id2:colum; ...) inside extra user fields |
|
441 | + * @param int User id |
|
442 | + * @param array selected blocks |
|
443 | + * @param array columns position |
|
444 | + * @return bool |
|
445 | + */ |
|
446 | + public static function store_user_blocks($user_id, $enabled_blocks, $columns) { |
|
447 | + $selected_blocks_id = array(); |
|
448 | + if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { |
|
449 | + $selected_blocks_id = array_keys($enabled_blocks); |
|
450 | + } |
|
451 | + |
|
452 | + // build data for storing inside extra user field |
|
453 | + $fname = 'dashboard'; |
|
454 | + $fvalue = array(); |
|
455 | + foreach ($selected_blocks_id as $block_id) { |
|
456 | + $fvalue[] = $block_id.':'.$columns[$block_id]; |
|
457 | + } |
|
458 | 458 | $upd_extra_field = UserManager::update_extra_field_value( |
459 | 459 | $user_id, |
460 | 460 | $fname, |
461 | 461 | $fvalue |
462 | 462 | ); |
463 | 463 | |
464 | - return $upd_extra_field; |
|
464 | + return $upd_extra_field; |
|
465 | 465 | |
466 | - } |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * This function get user block data (block id with its number of column) from extra user data |
|
470 | - * @param int User id |
|
471 | - * @return array data (block_id,column) |
|
472 | - */ |
|
473 | - public static function get_user_block_data($user_id) |
|
468 | + /** |
|
469 | + * This function get user block data (block id with its number of column) from extra user data |
|
470 | + * @param int User id |
|
471 | + * @return array data (block_id,column) |
|
472 | + */ |
|
473 | + public static function get_user_block_data($user_id) |
|
474 | 474 | { |
475 | - $user_id = intval($user_id); |
|
476 | - $field_variable = 'dashboard'; |
|
477 | - $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
|
475 | + $user_id = intval($user_id); |
|
476 | + $field_variable = 'dashboard'; |
|
477 | + $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); |
|
478 | 478 | |
479 | - if (isset($extra_user_data[$field_variable])) { |
|
479 | + if (isset($extra_user_data[$field_variable])) { |
|
480 | 480 | $extra_user_data = explode(';', $extra_user_data[$field_variable]); |
481 | 481 | } |
482 | 482 | |
483 | - $data = array(); |
|
484 | - foreach ($extra_user_data as $extra) { |
|
485 | - $split_extra = explode(':',$extra); |
|
486 | - if (!empty($split_extra)) { |
|
487 | - $block_id = $split_extra[0]; |
|
488 | - $column = isset($split_extra[1]) ? $split_extra[1] : null; |
|
489 | - $data[$block_id] = array('block_id' => $block_id, 'column' => $column); |
|
490 | - } |
|
491 | - } |
|
492 | - |
|
493 | - return $data; |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * This function update extra user blocks data after closing a dashboard block |
|
498 | - * @param int User id |
|
499 | - * @param string plugin path |
|
500 | - * @return bool |
|
501 | - */ |
|
502 | - public static function close_user_block($user_id, $path) |
|
483 | + $data = array(); |
|
484 | + foreach ($extra_user_data as $extra) { |
|
485 | + $split_extra = explode(':',$extra); |
|
486 | + if (!empty($split_extra)) { |
|
487 | + $block_id = $split_extra[0]; |
|
488 | + $column = isset($split_extra[1]) ? $split_extra[1] : null; |
|
489 | + $data[$block_id] = array('block_id' => $block_id, 'column' => $column); |
|
490 | + } |
|
491 | + } |
|
492 | + |
|
493 | + return $data; |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * This function update extra user blocks data after closing a dashboard block |
|
498 | + * @param int User id |
|
499 | + * @param string plugin path |
|
500 | + * @return bool |
|
501 | + */ |
|
502 | + public static function close_user_block($user_id, $path) |
|
503 | 503 | { |
504 | - $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
505 | - $user_block_data = self::get_user_block_data($user_id); |
|
506 | - |
|
507 | - foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
508 | - unset($user_block_data[$enabled_block['id']]); |
|
509 | - } |
|
510 | - |
|
511 | - // get columns and blocks id for updating extra user data |
|
512 | - $columns = array(); |
|
513 | - $user_blocks_id = array(); |
|
514 | - foreach ($user_block_data as $data) { |
|
515 | - $user_blocks_id[$data['block_id']] = true; |
|
516 | - $columns[$data['block_id']] = $data['column']; |
|
517 | - } |
|
518 | - |
|
519 | - // update extra user blocks data |
|
520 | - $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
521 | - |
|
522 | - return $upd_extra_field; |
|
523 | - } |
|
524 | - |
|
525 | - /** |
|
526 | - * get links for styles from dashboard plugins |
|
527 | - * @return string links |
|
528 | - */ |
|
529 | - public static function get_links_for_styles_from_dashboard_plugins() { |
|
530 | - |
|
531 | - return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
532 | - } |
|
504 | + $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
505 | + $user_block_data = self::get_user_block_data($user_id); |
|
506 | + |
|
507 | + foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
508 | + unset($user_block_data[$enabled_block['id']]); |
|
509 | + } |
|
510 | + |
|
511 | + // get columns and blocks id for updating extra user data |
|
512 | + $columns = array(); |
|
513 | + $user_blocks_id = array(); |
|
514 | + foreach ($user_block_data as $data) { |
|
515 | + $user_blocks_id[$data['block_id']] = true; |
|
516 | + $columns[$data['block_id']] = $data['column']; |
|
517 | + } |
|
518 | + |
|
519 | + // update extra user blocks data |
|
520 | + $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
521 | + |
|
522 | + return $upd_extra_field; |
|
523 | + } |
|
524 | + |
|
525 | + /** |
|
526 | + * get links for styles from dashboard plugins |
|
527 | + * @return string links |
|
528 | + */ |
|
529 | + public static function get_links_for_styles_from_dashboard_plugins() { |
|
530 | + |
|
531 | + return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
532 | + } |
|
533 | 533 | |
534 | 534 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | echo '<tr>'; |
54 | 54 | self::display_dashboard_plugin_checkboxes($testplugin); |
55 | - for ($i = 0 ; $i < count($table_cols); $i++) { |
|
55 | + for ($i = 0; $i < count($table_cols); $i++) { |
|
56 | 56 | if (isset($plugin_info[strtolower($table_cols[$i])])) { |
57 | 57 | echo '<td>'; |
58 | 58 | echo $plugin_info[$table_cols[$i]]; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | echo Display::tag( |
68 | 68 | 'tr', |
69 | 69 | Display::tag('td', |
70 | - get_lang('CheckFilePermissions') . ' ' . Security::remove_XSS($plugin_info_file), |
|
70 | + get_lang('CheckFilePermissions').' '.Security::remove_XSS($plugin_info_file), |
|
71 | 71 | array('colspan' => '3')) |
72 | 72 | ); |
73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | foreach ($disabled_blocks_data as $disabled_block) { |
80 | 80 | echo '<tr style="background-color:#eee">'; |
81 | 81 | echo '<td><center><input type="checkbox" name="disabled_block" value="true" checked disabled /></center>'; |
82 | - for ($j = 0 ; $j < count($table_cols); $j++) { |
|
82 | + for ($j = 0; $j < count($table_cols); $j++) { |
|
83 | 83 | if (isset($disabled_block[strtolower($table_cols[$j])])) { |
84 | 84 | if ($j == 2) { |
85 | 85 | echo '<td>'; |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | } |
190 | 190 | // clean from block data |
191 | 191 | if (!empty($not_selected_blocks_id)) { |
192 | - $sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")"; |
|
192 | + $sql_check = "SELECT id FROM $tbl_block WHERE id IN(".implode(',', $not_selected_blocks_id).")"; |
|
193 | 193 | $rs_check = Database::query($sql_check); |
194 | 194 | if (Database::num_rows($rs_check) > 0) { |
195 | - $del = "DELETE FROM $tbl_block WHERE id IN(".implode(',',$not_selected_blocks_id).")"; |
|
195 | + $del = "DELETE FROM $tbl_block WHERE id IN(".implode(',', $not_selected_blocks_id).")"; |
|
196 | 196 | Database::query($del); |
197 | 197 | } |
198 | 198 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $affected_rows = Database::affected_rows($result); |
213 | 213 | } else { |
214 | 214 | // insert |
215 | - $plugin_info_file = $dashboard_pluginpath . $testplugin . "/$testplugin.info"; |
|
215 | + $plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info"; |
|
216 | 216 | $plugin_info = array(); |
217 | 217 | if (file_exists($plugin_info_file)) { |
218 | 218 | $plugin_info = parse_info_file($plugin_info_file); |
@@ -282,10 +282,10 @@ discard block |
||
282 | 282 | // We check if plugin exists inside directory for updating active field |
283 | 283 | $sql = "SELECT * FROM $tbl_block"; |
284 | 284 | $rs = Database::query($sql); |
285 | - if (Database::num_rows($rs) > 0){ |
|
285 | + if (Database::num_rows($rs) > 0) { |
|
286 | 286 | while ($row = Database::fetch_array($rs)) { |
287 | 287 | $path = $row['path']; |
288 | - if (!in_array($row['path'],$possibleplugins)) { |
|
288 | + if (!in_array($row['path'], $possibleplugins)) { |
|
289 | 289 | $active = 0; |
290 | 290 | } else { |
291 | 291 | $active = 1; |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | echo '<td>'.$block['description'].'</td>'; |
391 | 391 | echo '<td> |
392 | 392 | <select class="selectpicker show-tick form-control" name="columns['.$block['id'].']"> |
393 | - <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==1?'selected':'').' >1</option> |
|
394 | - <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column']==2?'selected':'').' >2</option> |
|
393 | + <option value="1" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 1 ? 'selected' : '').' >1</option> |
|
394 | + <option value="2" '.(isset($user_block_data[$block['id']]) && $user_block_data[$block['id']]['column'] == 2 ? 'selected' : '').' >2</option> |
|
395 | 395 | </select> |
396 | 396 | </td>'; |
397 | 397 | echo '</tr>'; |
398 | 398 | } else { |
399 | - echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
399 | + echo Display::tag('tr', Display::tag('td', get_lang('Error').' '.$controller_class, array('colspan'=>'3'))); |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | |
483 | 483 | $data = array(); |
484 | 484 | foreach ($extra_user_data as $extra) { |
485 | - $split_extra = explode(':',$extra); |
|
485 | + $split_extra = explode(':', $extra); |
|
486 | 486 | if (!empty($split_extra)) { |
487 | 487 | $block_id = $split_extra[0]; |
488 | 488 | $column = isset($split_extra[1]) ? $split_extra[1] : null; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param string $table |
68 | 68 | * |
69 | - * @return mixed |
|
69 | + * @return string |
|
70 | 70 | */ |
71 | 71 | public static function get_main_table($table) |
72 | 72 | { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | /** |
267 | 267 | * Frees all the memory associated with the provided result identifier. |
268 | - * @return bool Returns TRUE on success or FALSE on failure. |
|
268 | + * @return boolean|null Returns TRUE on success or FALSE on failure. |
|
269 | 269 | * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets. |
270 | 270 | * Anyway, all associated result memory is automatically freed at the end of the script's execution. |
271 | 271 | */ |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @param array $attributes |
382 | 382 | * @param bool $show_query |
383 | 383 | * |
384 | - * @return bool|int |
|
384 | + * @return false|string |
|
385 | 385 | */ |
386 | 386 | public static function insert($table_name, $attributes, $show_query = false) |
387 | 387 | { |
@@ -115,8 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public static function getUTCDateTimeTypeClass() |
117 | 117 | { |
118 | - return isset(self::$utcDateTimeClass) ? self::$utcDateTimeClass : |
|
119 | - 'Application\DoctrineExtensions\DBAL\Types\UTCDateTimeType'; |
|
118 | + return isset(self::$utcDateTimeClass) ? self::$utcDateTimeClass : 'Application\DoctrineExtensions\DBAL\Types\UTCDateTimeType'; |
|
120 | 119 | } |
121 | 120 | |
122 | 121 | /** |
@@ -393,7 +392,7 @@ discard block |
||
393 | 392 | |
394 | 393 | if (!empty($params)) { |
395 | 394 | $sql = 'INSERT INTO '.$table_name.' ('.implode(',', $params).') |
396 | - VALUES (:'.implode(', :' ,$params).')'; |
|
395 | + VALUES (:'.implode(', :', $params).')'; |
|
397 | 396 | |
398 | 397 | $statement = self::getManager()->getConnection()->prepare($sql); |
399 | 398 | $result = $statement->execute($attributes); |
@@ -434,7 +433,7 @@ discard block |
||
434 | 433 | foreach ($attributes as $key => $value) { |
435 | 434 | $update_sql .= "$key = :$key "; |
436 | 435 | if ($count < count($attributes)) { |
437 | - $update_sql.=', '; |
|
436 | + $update_sql .= ', '; |
|
438 | 437 | } |
439 | 438 | $count++; |
440 | 439 | } |
@@ -481,7 +480,7 @@ discard block |
||
481 | 480 | if ($columns == '*') { |
482 | 481 | $clean_columns = '*'; |
483 | 482 | } else { |
484 | - $clean_columns = (string)$columns; |
|
483 | + $clean_columns = (string) $columns; |
|
485 | 484 | } |
486 | 485 | } |
487 | 486 | |
@@ -527,9 +526,9 @@ discard block |
||
527 | 526 | foreach ($condition_data as $condition => $value_array) { |
528 | 527 | if (is_array($value_array)) { |
529 | 528 | $clean_values = array(); |
530 | - foreach($value_array as $item) { |
|
529 | + foreach ($value_array as $item) { |
|
531 | 530 | $item = Database::escape_string($item); |
532 | - $clean_values[]= $item; |
|
531 | + $clean_values[] = $item; |
|
533 | 532 | } |
534 | 533 | } else { |
535 | 534 | $value_array = Database::escape_string($value_array); |
@@ -537,23 +536,23 @@ discard block |
||
537 | 536 | } |
538 | 537 | |
539 | 538 | if (!empty($condition) && $clean_values != '') { |
540 | - $condition = str_replace('%',"'@percentage@'", $condition); //replace "%" |
|
541 | - $condition = str_replace("'?'","%s", $condition); |
|
542 | - $condition = str_replace("?","%s", $condition); |
|
539 | + $condition = str_replace('%', "'@percentage@'", $condition); //replace "%" |
|
540 | + $condition = str_replace("'?'", "%s", $condition); |
|
541 | + $condition = str_replace("?", "%s", $condition); |
|
543 | 542 | |
544 | - $condition = str_replace("@%s@","@-@", $condition); |
|
545 | - $condition = str_replace("%s","'%s'", $condition); |
|
546 | - $condition = str_replace("@-@","@%s@", $condition); |
|
543 | + $condition = str_replace("@%s@", "@-@", $condition); |
|
544 | + $condition = str_replace("%s", "'%s'", $condition); |
|
545 | + $condition = str_replace("@-@", "@%s@", $condition); |
|
547 | 546 | |
548 | 547 | // Treat conditions as string |
549 | 548 | $condition = vsprintf($condition, $clean_values); |
550 | - $condition = str_replace('@percentage@','%', $condition); //replace "%" |
|
549 | + $condition = str_replace('@percentage@', '%', $condition); //replace "%" |
|
551 | 550 | $where_return .= $condition; |
552 | 551 | } |
553 | 552 | } |
554 | 553 | |
555 | 554 | if (!empty($where_return)) { |
556 | - $return_value = " WHERE $where_return" ; |
|
555 | + $return_value = " WHERE $where_return"; |
|
557 | 556 | } |
558 | 557 | break; |
559 | 558 | case 'order': |
@@ -565,7 +564,7 @@ discard block |
||
565 | 564 | $new_order_array = explode(',', $order_array); |
566 | 565 | $temp_value = array(); |
567 | 566 | |
568 | - foreach($new_order_array as $element) { |
|
567 | + foreach ($new_order_array as $element) { |
|
569 | 568 | $element = explode(' ', $element); |
570 | 569 | $element = array_filter($element); |
571 | 570 | $element = array_values($element); |
@@ -576,10 +575,10 @@ discard block |
||
576 | 575 | if (in_array($element[1], array('desc', 'asc'))) { |
577 | 576 | $order = $element[1]; |
578 | 577 | } |
579 | - $temp_value[]= $element[0].' '.$order.' '; |
|
578 | + $temp_value[] = $element[0].' '.$order.' '; |
|
580 | 579 | } else { |
581 | 580 | //by default DESC |
582 | - $temp_value[]= $element[0].' DESC '; |
|
581 | + $temp_value[] = $element[0].' DESC '; |
|
583 | 582 | } |
584 | 583 | } |
585 | 584 | if (!empty($temp_value)) { |
@@ -594,7 +593,7 @@ discard block |
||
594 | 593 | if (!empty($limit_array)) { |
595 | 594 | if (count($limit_array) > 1) { |
596 | 595 | $return_value .= ' LIMIT '.intval($limit_array[0]).' , '.intval($limit_array[1]); |
597 | - } else { |
|
596 | + } else { |
|
598 | 597 | $return_value .= ' LIMIT '.intval($limit_array[0]); |
599 | 598 | } |
600 | 599 | } |
@@ -594,7 +594,7 @@ |
||
594 | 594 | if (!empty($limit_array)) { |
595 | 595 | if (count($limit_array) > 1) { |
596 | 596 | $return_value .= ' LIMIT '.intval($limit_array[0]).' , '.intval($limit_array[1]); |
597 | - } else { |
|
597 | + } else { |
|
598 | 598 | $return_value .= ' LIMIT '.intval($limit_array[0]); |
599 | 599 | } |
600 | 600 | } |
@@ -351,6 +351,12 @@ |
||
351 | 351 | |
352 | 352 | /** |
353 | 353 | * Additional functions needed for fast integration |
354 | + * @param integer $status |
|
355 | + * @param string $section |
|
356 | + * @param string $title |
|
357 | + * @param string $url |
|
358 | + * @param string|null $formatter |
|
359 | + * @param string $comment |
|
354 | 360 | */ |
355 | 361 | public function build_setting($status, $section, $title, $url, $current_value, $expected_value, $formatter, $comment, $img_path = null) { |
356 | 362 | switch ($status) { |
@@ -401,19 +401,19 @@ |
||
401 | 401 | |
402 | 402 | public function format_yes_no_optional($value) |
403 | 403 | { |
404 | - $return = ''; |
|
405 | - switch($value) { |
|
406 | - case 0: |
|
407 | - $return = get_lang('No'); |
|
408 | - break; |
|
409 | - case 1: |
|
410 | - $return = get_lang('Yes'); |
|
411 | - break; |
|
412 | - case 2: |
|
413 | - $return = get_lang('Optional'); |
|
414 | - break; |
|
415 | - } |
|
416 | - return $return; |
|
404 | + $return = ''; |
|
405 | + switch($value) { |
|
406 | + case 0: |
|
407 | + $return = get_lang('No'); |
|
408 | + break; |
|
409 | + case 1: |
|
410 | + $return = get_lang('Yes'); |
|
411 | + break; |
|
412 | + case 2: |
|
413 | + $return = get_lang('Optional'); |
|
414 | + break; |
|
415 | + } |
|
416 | + return $return; |
|
417 | 417 | |
418 | 418 | } |
419 | 419 |
@@ -158,8 +158,9 @@ discard block |
||
158 | 158 | $array[] = $this->build_setting($status, '[INI]', 'display_errors', 'http://www.php.net/manual/en/ini.core.php#ini.display_errors', $setting, $req_setting, 'on_off', get_lang('DisplayErrorsInfo')); |
159 | 159 | |
160 | 160 | $setting = ini_get('default_charset'); |
161 | - if ($setting == '') |
|
162 | - $setting = null; |
|
161 | + if ($setting == '') { |
|
162 | + $setting = null; |
|
163 | + } |
|
163 | 164 | $req_setting = null; |
164 | 165 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_ERROR; |
165 | 166 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
@@ -177,22 +178,25 @@ discard block |
||
177 | 178 | $setting = ini_get('memory_limit'); |
178 | 179 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
179 | 180 | $status = self :: STATUS_ERROR; |
180 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
181 | - $status = self :: STATUS_OK; |
|
181 | + if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) { |
|
182 | + $status = self :: STATUS_OK; |
|
183 | + } |
|
182 | 184 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
183 | 185 | |
184 | 186 | $setting = ini_get('post_max_size'); |
185 | 187 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
186 | 188 | $status = self :: STATUS_ERROR; |
187 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
188 | - $status = self :: STATUS_OK; |
|
189 | + if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) { |
|
190 | + $status = self :: STATUS_OK; |
|
191 | + } |
|
189 | 192 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
190 | 193 | |
191 | 194 | $setting = ini_get('upload_max_filesize'); |
192 | 195 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
193 | 196 | $status = self :: STATUS_ERROR; |
194 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
195 | - $status = self :: STATUS_OK; |
|
197 | + if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) { |
|
198 | + $status = self :: STATUS_OK; |
|
199 | + } |
|
196 | 200 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
197 | 201 | |
198 | 202 | $setting = ini_get('variables_order'); |
@@ -205,7 +209,7 @@ discard block |
||
205 | 209 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
206 | 210 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
207 | 211 | |
208 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
212 | + if (api_check_browscap()){$setting = true;} else{$setting=false;} |
|
209 | 213 | $req_setting = true; |
210 | 214 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
211 | 215 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | { |
16 | 16 | const STATUS_OK = 1; |
17 | 17 | const STATUS_WARNING = 2; |
18 | - const STATUS_ERROR = 3; |
|
18 | + const STATUS_ERROR = 3; |
|
19 | 19 | const STATUS_INFORMATION = 4; |
20 | 20 | |
21 | 21 | /** |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | $html .= '<li>'; |
45 | 45 | } |
46 | 46 | $params['section'] = $section; |
47 | - $html .='<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
47 | + $html .= '<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>'; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | $html .= '</ul><div class="tab-pane">'; |
51 | 51 | |
52 | - $data = call_user_func(array($this, 'get_' . $current_section . '_data')); |
|
52 | + $data = call_user_func(array($this, 'get_'.$current_section.'_data')); |
|
53 | 53 | echo $html; |
54 | 54 | $table = new SortableTableFromArray($data, 1, 100); |
55 | 55 | |
56 | - $table->set_header(0,'', false); |
|
57 | - $table->set_header(1,get_lang('Section'), false); |
|
58 | - $table->set_header(2,get_lang('Setting'), false); |
|
59 | - $table->set_header(3,get_lang('Current'), false); |
|
60 | - $table->set_header(4,get_lang('Expected'), false); |
|
61 | - $table->set_header(5,get_lang('Comment'), false); |
|
56 | + $table->set_header(0, '', false); |
|
57 | + $table->set_header(1, get_lang('Section'), false); |
|
58 | + $table->set_header(2, get_lang('Setting'), false); |
|
59 | + $table->set_header(3, get_lang('Current'), false); |
|
60 | + $table->set_header(4, get_lang('Expected'), false); |
|
61 | + $table->set_header(5, get_lang('Comment'), false); |
|
62 | 62 | |
63 | 63 | $table->display(); |
64 | 64 | echo '</div></div>'; |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | { |
73 | 73 | $array = array(); |
74 | 74 | $writable_folders = array( |
75 | - api_get_path(SYS_APP_PATH) .'cache', |
|
75 | + api_get_path(SYS_APP_PATH).'cache', |
|
76 | 76 | api_get_path(SYS_COURSE_PATH), |
77 | - api_get_path(SYS_APP_PATH) .'home', |
|
78 | - api_get_path(SYS_APP_PATH) .'upload/users/', |
|
79 | - api_get_path(SYS_PATH) .'main/default_course_document/images/', |
|
77 | + api_get_path(SYS_APP_PATH).'home', |
|
78 | + api_get_path(SYS_APP_PATH).'upload/users/', |
|
79 | + api_get_path(SYS_PATH).'main/default_course_document/images/', |
|
80 | 80 | ); |
81 | 81 | foreach ($writable_folders as $index => $folder) { |
82 | 82 | $writable = is_writable($folder); |
@@ -95,10 +95,10 @@ discard block |
||
95 | 95 | |
96 | 96 | $exists = file_exists(api_get_path(SYS_CODE_PATH).'install'); |
97 | 97 | $status = $exists ? self :: STATUS_WARNING : self :: STATUS_OK; |
98 | - $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists') . ': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); |
|
98 | + $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists').': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved')); |
|
99 | 99 | |
100 | 100 | $app_version = api_get_setting('chamilo_database_version'); |
101 | - $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); |
|
101 | + $array[] = $this->build_setting(self :: STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version'); |
|
102 | 102 | |
103 | 103 | return $array; |
104 | 104 | } |
@@ -165,33 +165,33 @@ discard block |
||
165 | 165 | $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo')); |
166 | 166 | |
167 | 167 | $setting = ini_get('max_execution_time'); |
168 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
168 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
169 | 169 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
170 | 170 | $array[] = $this->build_setting($status, '[INI]', 'max_execution_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-execution-time', $setting, $req_setting, null, get_lang('MaxExecutionTimeInfo')); |
171 | 171 | |
172 | 172 | $setting = ini_get('max_input_time'); |
173 | - $req_setting = '300 (' . get_lang('Minimum') . ')'; |
|
173 | + $req_setting = '300 ('.get_lang('Minimum').')'; |
|
174 | 174 | $status = $setting >= 300 ? self :: STATUS_OK : self :: STATUS_WARNING; |
175 | 175 | $array[] = $this->build_setting($status, '[INI]', 'max_input_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-input-time', $setting, $req_setting, null, get_lang('MaxInputTimeInfo')); |
176 | 176 | |
177 | 177 | $setting = ini_get('memory_limit'); |
178 | 178 | $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M'; |
179 | 179 | $status = self :: STATUS_ERROR; |
180 | - if ((float)$setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
180 | + if ((float) $setting >= REQUIRED_MIN_MEMORY_LIMIT) |
|
181 | 181 | $status = self :: STATUS_OK; |
182 | 182 | $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo')); |
183 | 183 | |
184 | 184 | $setting = ini_get('post_max_size'); |
185 | 185 | $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M'; |
186 | 186 | $status = self :: STATUS_ERROR; |
187 | - if ((float)$setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
187 | + if ((float) $setting >= REQUIRED_MIN_POST_MAX_SIZE) |
|
188 | 188 | $status = self :: STATUS_OK; |
189 | 189 | $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo')); |
190 | 190 | |
191 | 191 | $setting = ini_get('upload_max_filesize'); |
192 | 192 | $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M'; |
193 | 193 | $status = self :: STATUS_ERROR; |
194 | - if ((float)$setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
194 | + if ((float) $setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE) |
|
195 | 195 | $status = self :: STATUS_OK; |
196 | 196 | $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo')); |
197 | 197 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
206 | 206 | $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo')); |
207 | 207 | |
208 | - if (api_check_browscap()){$setting = true;}else{$setting=false;} |
|
208 | + if (api_check_browscap()) {$setting = true; } else {$setting = false; } |
|
209 | 209 | $req_setting = true; |
210 | 210 | $status = $setting == $req_setting ? self :: STATUS_OK : self :: STATUS_WARNING; |
211 | 211 | $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo')); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $loaded = extension_loaded($extension); |
263 | 263 | $status = $loaded ? self :: STATUS_OK : self :: STATUS_ERROR; |
264 | - $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension') . ': ' . $extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
264 | + $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension').': '.$extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $array; |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | $formatted_expected_value = $expected_value; |
385 | 385 | |
386 | 386 | if ($formatter) { |
387 | - if (method_exists($this, 'format_' . $formatter)) { |
|
388 | - $formatted_current_value = call_user_func(array($this, 'format_' . $formatter), $current_value); |
|
389 | - $formatted_expected_value = call_user_func(array($this, 'format_' . $formatter), $expected_value); |
|
387 | + if (method_exists($this, 'format_'.$formatter)) { |
|
388 | + $formatted_current_value = call_user_func(array($this, 'format_'.$formatter), $current_value); |
|
389 | + $formatted_expected_value = call_user_func(array($this, 'format_'.$formatter), $expected_value); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
@@ -401,13 +401,13 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public function get_link($title, $url) |
403 | 403 | { |
404 | - return '<a href="' . $url . '" target="about:bank">' . $title . '</a>'; |
|
404 | + return '<a href="'.$url.'" target="about:bank">'.$title.'</a>'; |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | public function format_yes_no_optional($value) |
408 | 408 | { |
409 | 409 | $return = ''; |
410 | - switch($value) { |
|
410 | + switch ($value) { |
|
411 | 411 | case 0: |
412 | 412 | $return = get_lang('No'); |
413 | 413 | break; |