@@ -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 |
@@ -1652,8 +1652,8 @@ discard block |
||
| 1652 | 1652 | $attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
| 1653 | 1653 | |
| 1654 | 1654 | $attachment_icon = ''; |
| 1655 | - if (count($attachment_list)>0) { |
|
| 1656 | - $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1655 | + if (count($attachment_list) > 0) { |
|
| 1656 | + $attachment_icon = ' '.Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | 1659 | /* TITLE */ |
@@ -1672,16 +1672,16 @@ discard block |
||
| 1672 | 1672 | || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) |
| 1673 | 1673 | ) { |
| 1674 | 1674 | $modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">". |
| 1675 | - Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>"; |
|
| 1676 | - if ($myrow['visibility']==1) { |
|
| 1677 | - $image_visibility="visible"; |
|
| 1678 | - $alt_visibility=get_lang('Hide'); |
|
| 1675 | + Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL)."</a>"; |
|
| 1676 | + if ($myrow['visibility'] == 1) { |
|
| 1677 | + $image_visibility = "visible"; |
|
| 1678 | + $alt_visibility = get_lang('Hide'); |
|
| 1679 | 1679 | } else { |
| 1680 | - $image_visibility="invisible"; |
|
| 1681 | - $alt_visibility=get_lang('Visible'); |
|
| 1680 | + $image_visibility = "invisible"; |
|
| 1681 | + $alt_visibility = get_lang('Visible'); |
|
| 1682 | 1682 | } |
| 1683 | - $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
| 1684 | - Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL)."</a>"; |
|
| 1683 | + $modify_icons .= "<a href=\"".$actionUrl."&origin=".$origin."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
| 1684 | + Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
| 1685 | 1685 | |
| 1686 | 1686 | // DISPLAY MOVE UP COMMAND only if it is not the top announcement |
| 1687 | 1687 | if ($iterator != 1) { |
@@ -1696,12 +1696,12 @@ discard block |
||
| 1696 | 1696 | } else { |
| 1697 | 1697 | $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); |
| 1698 | 1698 | } |
| 1699 | - if (api_is_allowed_to_edit(false,true)) { |
|
| 1700 | - $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;\">". |
|
| 1701 | - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). |
|
| 1699 | + if (api_is_allowed_to_edit(false, true)) { |
|
| 1700 | + $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;\">". |
|
| 1701 | + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL). |
|
| 1702 | 1702 | "</a>"; |
| 1703 | 1703 | } |
| 1704 | - $iterator ++; |
|
| 1704 | + $iterator++; |
|
| 1705 | 1705 | } else { |
| 1706 | 1706 | $modify_icons = Display::url( |
| 1707 | 1707 | Display::return_icon('default.png'), |
@@ -1731,7 +1731,7 @@ discard block |
||
| 1731 | 1731 | public static function getNumberAnnouncements() |
| 1732 | 1732 | { |
| 1733 | 1733 | // Maximum title messages to display |
| 1734 | - $maximum = '12'; |
|
| 1734 | + $maximum = '12'; |
|
| 1735 | 1735 | // Database Table Definitions |
| 1736 | 1736 | $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); |
| 1737 | 1737 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
@@ -1742,7 +1742,7 @@ discard block |
||
| 1742 | 1742 | $userId = api_get_user_id(); |
| 1743 | 1743 | $condition_session = api_get_session_condition($session_id, true, true, 'announcement.session_id'); |
| 1744 | 1744 | |
| 1745 | - if (api_is_allowed_to_edit(false,true)) { |
|
| 1745 | + if (api_is_allowed_to_edit(false, true)) { |
|
| 1746 | 1746 | // check teacher status |
| 1747 | 1747 | if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { |
| 1748 | 1748 | |
@@ -1805,7 +1805,7 @@ discard block |
||
| 1805 | 1805 | } |
| 1806 | 1806 | |
| 1807 | 1807 | // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements |
| 1808 | - if (is_array($group_memberships) && count($group_memberships)>0) { |
|
| 1808 | + if (is_array($group_memberships) && count($group_memberships) > 0) { |
|
| 1809 | 1809 | $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
| 1810 | 1810 | FROM $tbl_announcement announcement, $tbl_item_property ip |
| 1811 | 1811 | WHERE |
@@ -1855,7 +1855,7 @@ discard block |
||
| 1855 | 1855 | } |
| 1856 | 1856 | |
| 1857 | 1857 | // the user is not identiefied => show only the general announcements |
| 1858 | - $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
| 1858 | + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
| 1859 | 1859 | FROM $tbl_announcement announcement, $tbl_item_property ip |
| 1860 | 1860 | WHERE |
| 1861 | 1861 | 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 | } |
@@ -147,6 +147,9 @@ discard block |
||
| 147 | 147 | return $customTabs; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | +/** |
|
| 151 | + * @param string $theme |
|
| 152 | + */ |
|
| 150 | 153 | function return_logo($theme) |
| 151 | 154 | { |
| 152 | 155 | $_course = api_get_course_info(); |
@@ -497,6 +500,9 @@ discard block |
||
| 497 | 500 | return $menu; |
| 498 | 501 | } |
| 499 | 502 | |
| 503 | +/** |
|
| 504 | + * @param string $nameTools |
|
| 505 | + */ |
|
| 500 | 506 | function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) |
| 501 | 507 | { |
| 502 | 508 | $session_id = api_get_session_id(); |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); |
| 43 | 43 | $navigation['myprofile']['title'] = get_lang('ModifyProfile'); |
| 44 | 44 | $navigation['myprofile']['key'] = 'profile'; |
| 45 | - // Link to my agenda |
|
| 45 | + // Link to my agenda |
|
| 46 | 46 | $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal'; |
| 47 | 47 | $navigation['myagenda']['title'] = get_lang('MyAgenda'); |
| 48 | 48 | $navigation['myagenda']['key'] = 'agenda'; |
| 49 | 49 | |
| 50 | - // Gradebook |
|
| 51 | - if (api_get_setting('gradebook_enable') == 'true') { |
|
| 50 | + // Gradebook |
|
| 51 | + if (api_get_setting('gradebook_enable') == 'true') { |
|
| 52 | 52 | $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); |
| 53 | 53 | $navigation['mygradebook']['title'] = get_lang('MyGradebook'); |
| 54 | 54 | $navigation['mygradebook']['key'] = 'gradebook'; |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - // Reporting |
|
| 58 | - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { |
|
| 57 | + // Reporting |
|
| 58 | + if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { |
|
| 59 | 59 | // Link to my space |
| 60 | 60 | $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':''); |
| 61 | 61 | $navigation['session_my_space']['title'] = get_lang('MySpace'); |
@@ -79,21 +79,21 @@ discard block |
||
| 79 | 79 | $navigation['session_my_progress']['key'] = 'my-progress'; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - // Social |
|
| 83 | - if (api_get_setting('allow_social_tool')=='true') { |
|
| 82 | + // Social |
|
| 83 | + if (api_get_setting('allow_social_tool')=='true') { |
|
| 84 | 84 | $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php'; |
| 85 | 85 | $navigation['social']['title'] = get_lang('SocialNetwork'); |
| 86 | 86 | $navigation['social']['key'] = 'social-network'; |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - // Dashboard |
|
| 90 | - if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
|
| 89 | + // Dashboard |
|
| 90 | + if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
|
| 91 | 91 | $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php'; |
| 92 | 92 | $navigation['dashboard']['title'] = get_lang('Dashboard'); |
| 93 | 93 | $navigation['dashboard']['key'] = 'dashboard'; |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - // Reports |
|
| 96 | + // Reports |
|
| 97 | 97 | /* |
| 98 | 98 | if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
| 99 | 99 | $navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php'; |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | } |
| 117 | 117 | // End Custom Tabs |
| 118 | 118 | |
| 119 | - // Platform administration |
|
| 120 | - if (api_is_platform_admin(true)) { |
|
| 119 | + // Platform administration |
|
| 120 | + if (api_is_platform_admin(true)) { |
|
| 121 | 121 | $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/'; |
| 122 | 122 | $navigation['platform_admin']['title'] = get_lang('PlatformAdmin'); |
| 123 | 123 | $navigation['platform_admin']['key'] = 'admin'; |
| 124 | - } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - return $navigation; |
|
| 126 | + return $navigation; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - // Reports |
|
| 354 | + // Reports |
|
| 355 | 355 | if (!empty($possible_tabs['reports'])) { |
| 356 | 356 | if (api_get_setting('show_tabs', 'reports') == 'true') { |
| 357 | 357 | if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) { |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | $menu = null; |
| 494 | 494 | if (!empty($lis)) { |
| 495 | - $menu .= $lis; |
|
| 495 | + $menu .= $lis; |
|
| 496 | 496 | } |
| 497 | 497 | return $menu; |
| 498 | 498 | } |
@@ -548,7 +548,7 @@ discard block |
||
| 548 | 548 | $navigation_item_my_courses['title'] = get_lang('MyCourses'); |
| 549 | 549 | $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php'; |
| 550 | 550 | $navigation[] = $navigation_item_my_courses; |
| 551 | - */ |
|
| 551 | + */ |
|
| 552 | 552 | $navigation[] = $navigation_item; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $navigation['mycourses']['key'] = 'my-course'; |
| 40 | 40 | |
| 41 | 41 | // My Profile |
| 42 | - $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); |
|
| 42 | + $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : ''); |
|
| 43 | 43 | $navigation['myprofile']['title'] = get_lang('ModifyProfile'); |
| 44 | 44 | $navigation['myprofile']['key'] = 'profile'; |
| 45 | 45 | // Link to my agenda |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Gradebook |
| 51 | 51 | if (api_get_setting('gradebook_enable') == 'true') { |
| 52 | - $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); |
|
| 52 | + $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : ''); |
|
| 53 | 53 | $navigation['mygradebook']['title'] = get_lang('MyGradebook'); |
| 54 | 54 | $navigation['mygradebook']['key'] = 'gradebook'; |
| 55 | 55 | } |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | // Reporting |
| 58 | 58 | if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { |
| 59 | 59 | // Link to my space |
| 60 | - $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':''); |
|
| 60 | + $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh() ? 'session.php' : ''); |
|
| 61 | 61 | $navigation['session_my_space']['title'] = get_lang('MySpace'); |
| 62 | 62 | $navigation['session_my_space']['key'] = 'my-space'; |
| 63 | 63 | } else if (api_is_student_boss()) { |
| 64 | - $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH) . 'mySpace/student.php'; |
|
| 64 | + $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/student.php'; |
|
| 65 | 65 | $navigation['session_my_space']['title'] = get_lang('MySpace'); |
| 66 | 66 | $navigation['session_my_space']['key'] = 'my-space'; |
| 67 | 67 | } else { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Social |
| 83 | - if (api_get_setting('allow_social_tool')=='true') { |
|
| 83 | + if (api_get_setting('allow_social_tool') == 'true') { |
|
| 84 | 84 | $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php'; |
| 85 | 85 | $navigation['social']['title'] = get_lang('SocialNetwork'); |
| 86 | 86 | $navigation['social']['key'] = 'social-network'; |
@@ -161,14 +161,14 @@ discard block |
||
| 161 | 161 | 'id' => 'header-logo' |
| 162 | 162 | ); |
| 163 | 163 | $testServer = api_get_setting('server_type'); |
| 164 | - if ($testServer == 'test' && is_file($logoBase . 'svg')) { |
|
| 165 | - $logo = $logoBase . 'svg'; |
|
| 164 | + if ($testServer == 'test' && is_file($logoBase.'svg')) { |
|
| 165 | + $logo = $logoBase.'svg'; |
|
| 166 | 166 | $attributes['width'] = '245'; |
| 167 | 167 | $attributes['height'] = '68'; |
| 168 | 168 | $imageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.svg'; |
| 169 | 169 | } else { |
| 170 | - $logo = $logoBase . 'png'; |
|
| 171 | - $customLogo = $customLogoBase . 'png'; |
|
| 170 | + $logo = $logoBase.'png'; |
|
| 171 | + $customLogo = $customLogoBase.'png'; |
|
| 172 | 172 | $imageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.png'; |
| 173 | 173 | $customImageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo-custom.png'; |
| 174 | 174 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $_course = api_get_course_info(); |
| 219 | 219 | $course_id = 0; |
| 220 | 220 | if (!empty($_course)) { |
| 221 | - $course_id = $_course['code']; |
|
| 221 | + $course_id = $_course['code']; |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | $user_id = api_get_user_id(); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | if (api_get_setting('gradebook_enable') == 'true') { |
| 316 | 316 | if (api_get_setting('show_tabs', 'my_gradebook') == 'true') { |
| 317 | 317 | $navigation['mygradebook'] = $possible_tabs['mygradebook']; |
| 318 | - } else{ |
|
| 318 | + } else { |
|
| 319 | 319 | $menu_navigation['mygradebook'] = $possible_tabs['mygradebook']; |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | if (api_get_setting('allow_social_tool') == 'true') { |
| 341 | 341 | $navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null; |
| 342 | 342 | } |
| 343 | - } else{ |
|
| 343 | + } else { |
|
| 344 | 344 | $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { |
| 350 | 350 | $navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null; |
| 351 | 351 | } |
| 352 | - } else{ |
|
| 352 | + } else { |
|
| 353 | 353 | $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null; |
| 354 | 354 | } |
| 355 | 355 | |
@@ -440,32 +440,32 @@ discard block |
||
| 440 | 440 | $home_top = ''; |
| 441 | 441 | |
| 442 | 442 | if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) { |
| 443 | - $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext); |
|
| 443 | + $home_top = @(string) file_get_contents($homep.$menutabs.'_'.$lang.$ext); |
|
| 444 | 444 | } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) { |
| 445 | - $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext); |
|
| 445 | + $home_top = @(string) file_get_contents($homep.$menutabs.$lang.$ext); |
|
| 446 | 446 | } else { |
| 447 | 447 | //$errorMsg = get_lang('HomePageFilesNotReadable'); |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); |
| 451 | 451 | |
| 452 | - $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top); |
|
| 452 | + $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top); |
|
| 453 | 453 | $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); |
| 454 | 454 | |
| 455 | 455 | $open_mtloggedin = ''; |
| 456 | 456 | if (api_get_user_id() && !api_is_anonymous()) { |
| 457 | 457 | if (is_file($homep.$mtloggedin.'_'.$lang.$ext) && is_readable($homep.$mtloggedin.'_'.$lang.$ext)) { |
| 458 | - $home_top = @(string)file_get_contents($homep.$mtloggedin.'_'.$lang.$ext); |
|
| 458 | + $home_top = @(string) file_get_contents($homep.$mtloggedin.'_'.$lang.$ext); |
|
| 459 | 459 | $home_top = str_replace('::private', '', $home_top); |
| 460 | 460 | } elseif (is_file($homep.$mtloggedin.$lang.$ext) && is_readable($homep.$mtloggedin.$lang.$ext)) { |
| 461 | - $home_top = @(string)file_get_contents($homep.$mtloggedin.$lang.$ext); |
|
| 461 | + $home_top = @(string) file_get_contents($homep.$mtloggedin.$lang.$ext); |
|
| 462 | 462 | $home_top = str_replace('::private', '', $home_top); |
| 463 | 463 | } else { |
| 464 | 464 | //$errorMsg = get_lang('HomePageFilesNotReadable'); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); |
| 468 | - $open_mtloggedin = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top); |
|
| 468 | + $open_mtloggedin = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top); |
|
| 469 | 469 | $open_mtloggedin = api_to_system_encoding($open_mtloggedin, api_detect_encoding(strip_tags($open_mtloggedin))); |
| 470 | 470 | } |
| 471 | 471 | |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | if (!empty($open) OR !empty($open_mtloggedin)) { |
| 475 | 475 | if (strpos($open.$open_mtloggedin, 'show_menu') === false) { |
| 476 | 476 | if (api_is_anonymous()) { |
| 477 | - $navigation[SECTION_CAMPUS] = null; |
|
| 477 | + $navigation[SECTION_CAMPUS] = null; |
|
| 478 | 478 | } |
| 479 | 479 | } else { |
| 480 | 480 | if (api_get_user_id() && !api_is_anonymous()) { |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | if (count($navigation) > 0 || !empty($lis)) { |
| 489 | 489 | $pre_lis = ''; |
| 490 | 490 | foreach ($navigation as $section => $navigation_info) { |
| 491 | - $key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:''); |
|
| 491 | + $key = (!empty($navigation_info['key']) ? 'tab-'.$navigation_info['key'] : ''); |
|
| 492 | 492 | if (isset($GLOBALS['this_section'])) { |
| 493 | 493 | $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active '.$key.'" ' : ' class="'.$key.'"'; |
| 494 | 494 | } else { |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | |
| 533 | 533 | if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) { |
| 534 | 534 | |
| 535 | - $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : ''); |
|
| 535 | + $navigation_item['url'] = $web_course_path.$_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : ''); |
|
| 536 | 536 | $_course['name'] = api_htmlentities($_course['name']); |
| 537 | 537 | $course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB); |
| 538 | 538 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; |
| 548 | 548 | break; |
| 549 | 549 | default: |
| 550 | - if (api_get_session_id() != -1 ) { |
|
| 550 | + if (api_get_session_id() != -1) { |
|
| 551 | 551 | $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; |
| 552 | 552 | } else { |
| 553 | 553 | $navigation_item['title'] = Display::img(api_get_path(WEB_IMG_PATH).'home.png', $_course['name']).' '.$course_title; |
@@ -581,22 +581,22 @@ discard block |
||
| 581 | 581 | // titles for shared folders |
| 582 | 582 | if ($breadcrumb_step['name'] == 'shared_folder') { |
| 583 | 583 | $navigation_item['title'] = get_lang('UserFolders'); |
| 584 | - } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) { |
|
| 584 | + } elseif (strstr($breadcrumb_step['name'], 'shared_folder_session_')) { |
|
| 585 | 585 | $navigation_item['title'] = get_lang('UserFolders'); |
| 586 | - } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) { |
|
| 586 | + } elseif (strstr($breadcrumb_step['name'], 'sf_user_')) { |
|
| 587 | 587 | $userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8)); |
| 588 | 588 | $navigation_item['title'] = $userinfo['complete_name']; |
| 589 | - } elseif($breadcrumb_step['name'] == 'chat_files') { |
|
| 589 | + } elseif ($breadcrumb_step['name'] == 'chat_files') { |
|
| 590 | 590 | $navigation_item['title'] = get_lang('ChatFiles'); |
| 591 | - } elseif($breadcrumb_step['name'] == 'images') { |
|
| 591 | + } elseif ($breadcrumb_step['name'] == 'images') { |
|
| 592 | 592 | $navigation_item['title'] = get_lang('Images'); |
| 593 | - } elseif($breadcrumb_step['name'] == 'video') { |
|
| 593 | + } elseif ($breadcrumb_step['name'] == 'video') { |
|
| 594 | 594 | $navigation_item['title'] = get_lang('Video'); |
| 595 | - } elseif($breadcrumb_step['name'] == 'audio') { |
|
| 595 | + } elseif ($breadcrumb_step['name'] == 'audio') { |
|
| 596 | 596 | $navigation_item['title'] = get_lang('Audio'); |
| 597 | - } elseif($breadcrumb_step['name'] == 'flash') { |
|
| 597 | + } elseif ($breadcrumb_step['name'] == 'flash') { |
|
| 598 | 598 | $navigation_item['title'] = get_lang('Flash'); |
| 599 | - } elseif($breadcrumb_step['name'] == 'gallery') { |
|
| 599 | + } elseif ($breadcrumb_step['name'] == 'gallery') { |
|
| 600 | 600 | $navigation_item['title'] = get_lang('Gallery'); |
| 601 | 601 | } |
| 602 | 602 | // Fixes breadcrumb title now we applied the Security::remove_XSS and |
@@ -663,35 +663,35 @@ discard block |
||
| 663 | 663 | if (!empty($final_navigation)) { |
| 664 | 664 | // $home_link.= '<span class="divider">/</span>'; |
| 665 | 665 | if (!empty($home_link)) { |
| 666 | - $lis.= Display::tag('li', $home_link); |
|
| 666 | + $lis .= Display::tag('li', $home_link); |
|
| 667 | 667 | } |
| 668 | 668 | |
| 669 | 669 | foreach ($final_navigation as $bread) { |
| 670 | 670 | $bread_check = trim(strip_tags($bread)); |
| 671 | 671 | if (!empty($bread_check)) { |
| 672 | - if ($final_navigation_count-1 > $i) { |
|
| 672 | + if ($final_navigation_count - 1 > $i) { |
|
| 673 | 673 | $bread .= ''; |
| 674 | 674 | } |
| 675 | - $lis.= Display::tag('li', $bread,array('class'=>'active')); |
|
| 675 | + $lis .= Display::tag('li', $bread, array('class'=>'active')); |
|
| 676 | 676 | $i++; |
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | } else { |
| 680 | 680 | if (!empty($home_link)) { |
| 681 | - $lis.= Display::tag('li', $home_link); |
|
| 681 | + $lis .= Display::tag('li', $home_link); |
|
| 682 | 682 | } |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // View as student/teacher link |
| 686 | 686 | $view = null; |
| 687 | 687 | if (!empty($view_as_student_link)) { |
| 688 | - $view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link','class' => 'pull-right')); |
|
| 688 | + $view .= Display::tag('div', $view_as_student_link, array('id' => 'view_as_link', 'class' => 'pull-right')); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | if (!empty($navigation_right)) { |
| 692 | - foreach($navigation_right as $item){ |
|
| 692 | + foreach ($navigation_right as $item) { |
|
| 693 | 693 | $extra_class = isset($item['class']) ? $item['class'] : null; |
| 694 | - $lis.= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right')); |
|
| 694 | + $lis .= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right')); |
|
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | |
@@ -96,9 +96,7 @@ discard block |
||
| 96 | 96 | /** |
| 97 | 97 | * Creates a new blog in the given course |
| 98 | 98 | * @author Toon Keppens |
| 99 | - * @param Integer $course_id Id |
|
| 100 | 99 | * @param String $title |
| 101 | - * @param Text $description |
|
| 102 | 100 | */ |
| 103 | 101 | public static function create_blog($title, $subtitle) |
| 104 | 102 | { |
@@ -186,9 +184,7 @@ discard block |
||
| 186 | 184 | /** |
| 187 | 185 | * Update title and subtitle of a blog in the given course |
| 188 | 186 | * @author Toon Keppens |
| 189 | - * @param Integer $course_id Id |
|
| 190 | 187 | * @param String $title |
| 191 | - * @param Text $description |
|
| 192 | 188 | */ |
| 193 | 189 | public static function edit_blog($blog_id, $title, $subtitle) |
| 194 | 190 | { |
@@ -714,7 +710,6 @@ discard block |
||
| 714 | 710 | /** |
| 715 | 711 | * Deletes an assigned task from a blog |
| 716 | 712 | * @param Integer $blog_id |
| 717 | - * @param Integer $assignment_id |
|
| 718 | 713 | */ |
| 719 | 714 | public static function delete_assigned_task($blog_id, $task_id, $user_id) |
| 720 | 715 | { |
@@ -1126,9 +1121,7 @@ discard block |
||
| 1126 | 1121 | * |
| 1127 | 1122 | * @param String $type |
| 1128 | 1123 | * @param Integer $blog_id |
| 1129 | - * @param Integer $item_id |
|
| 1130 | - * |
|
| 1131 | - *@return String |
|
| 1124 | + * @param integer $post_id |
|
| 1132 | 1125 | */ |
| 1133 | 1126 | public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
| 1134 | 1127 | { |
@@ -2113,7 +2106,7 @@ discard block |
||
| 2113 | 2106 | * |
| 2114 | 2107 | * @param Integer $blog_id |
| 2115 | 2108 | * |
| 2116 | - * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
| 2109 | + * @return false|null Form with sortable table with users to unsubcribe from a blog. |
|
| 2117 | 2110 | */ |
| 2118 | 2111 | public static function display_form_user_unsubscribe ($blog_id) |
| 2119 | 2112 | { |
@@ -2234,6 +2227,7 @@ discard block |
||
| 2234 | 2227 | * @author Toon Keppens |
| 2235 | 2228 | * |
| 2236 | 2229 | * @param Integer $blog_id |
| 2230 | + * @param integer $post_id |
|
| 2237 | 2231 | */ |
| 2238 | 2232 | public static function display_new_comment_form($blog_id, $post_id, $title) |
| 2239 | 2233 | { |
@@ -2282,10 +2276,8 @@ discard block |
||
| 2282 | 2276 | * @author Patrick Cool |
| 2283 | 2277 | * @author Toon Keppens |
| 2284 | 2278 | * |
| 2285 | - * @param Array $blogitems an array containing all the blog items for the given month |
|
| 2286 | 2279 | * @param Integer $month: the integer value of the month we are viewing |
| 2287 | 2280 | * @param Integer $year: the 4-digit year indication e.g. 2005 |
| 2288 | - * @param String $monthName: the language variable for the mont name |
|
| 2289 | 2281 | * |
| 2290 | 2282 | * @return html code |
| 2291 | 2283 | */ |
@@ -2579,6 +2571,7 @@ discard block |
||
| 2579 | 2571 | * @param the blog's id |
| 2580 | 2572 | * @param the post's id |
| 2581 | 2573 | * @param the comment's id |
| 2574 | + * @param integer $blog_id |
|
| 2582 | 2575 | * @return array with the post info according the parameters |
| 2583 | 2576 | * @author Julio Montoya Dokeos |
| 2584 | 2577 | * @version avril 2008, dokeos 1.8.5 |
@@ -2620,6 +2613,9 @@ discard block |
||
| 2620 | 2613 | * @param the blog's id |
| 2621 | 2614 | * @param the post's id |
| 2622 | 2615 | * @param the comment's id |
| 2616 | + * @param integer $blog_id |
|
| 2617 | + * @param integer $post_id |
|
| 2618 | + * @param integer $comment_id |
|
| 2623 | 2619 | * @author Julio Montoya Dokeos |
| 2624 | 2620 | * @version avril 2008, dokeos 1.8.5 |
| 2625 | 2621 | */ |
@@ -6,115 +6,114 @@ discard block |
||
| 6 | 6 | * |
| 7 | 7 | * Contains several functions dealing with displaying, |
| 8 | 8 | * editing,... of a blog |
| 9 | - |
|
| 10 | 9 | * @package chamilo.blogs |
| 11 | 10 | * @author Toon Keppens <[email protected]> |
| 12 | 11 | * @author Julio Montoya - Cleaning code |
| 13 | 12 | */ |
| 14 | 13 | class Blog |
| 15 | 14 | { |
| 16 | - /** |
|
| 17 | - * Get the title of a blog |
|
| 18 | - * @author Toon Keppens |
|
| 19 | - * |
|
| 20 | - * @param int $blog_id |
|
| 21 | - * |
|
| 22 | - * @return String Blog Title |
|
| 23 | - */ |
|
| 24 | - public static function get_blog_title ($blog_id) |
|
| 25 | - { |
|
| 26 | - $course_id = api_get_course_int_id(); |
|
| 27 | - |
|
| 28 | - if (is_numeric($blog_id)) { |
|
| 29 | - // init |
|
| 30 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 31 | - |
|
| 32 | - $sql = "SELECT blog_name |
|
| 15 | + /** |
|
| 16 | + * Get the title of a blog |
|
| 17 | + * @author Toon Keppens |
|
| 18 | + * |
|
| 19 | + * @param int $blog_id |
|
| 20 | + * |
|
| 21 | + * @return String Blog Title |
|
| 22 | + */ |
|
| 23 | + public static function get_blog_title ($blog_id) |
|
| 24 | + { |
|
| 25 | + $course_id = api_get_course_int_id(); |
|
| 26 | + |
|
| 27 | + if (is_numeric($blog_id)) { |
|
| 28 | + // init |
|
| 29 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 30 | + |
|
| 31 | + $sql = "SELECT blog_name |
|
| 33 | 32 | FROM " . $tbl_blogs . " |
| 34 | 33 | WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
| 35 | 34 | |
| 36 | - $result = Database::query($sql); |
|
| 37 | - $blog = Database::fetch_array($result); |
|
| 38 | - return stripslashes($blog['blog_name']); |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Get the description of a blog |
|
| 45 | - * @author Toon Keppens |
|
| 46 | - * |
|
| 47 | - * @param Integer $blog_id |
|
| 48 | - * |
|
| 49 | - * @return String Blog description |
|
| 50 | - */ |
|
| 51 | - public static function get_blog_subtitle($blog_id) |
|
| 52 | - { |
|
| 53 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 54 | - $course_id = api_get_course_int_id(); |
|
| 55 | - $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
| 35 | + $result = Database::query($sql); |
|
| 36 | + $blog = Database::fetch_array($result); |
|
| 37 | + return stripslashes($blog['blog_name']); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Get the description of a blog |
|
| 44 | + * @author Toon Keppens |
|
| 45 | + * |
|
| 46 | + * @param Integer $blog_id |
|
| 47 | + * |
|
| 48 | + * @return String Blog description |
|
| 49 | + */ |
|
| 50 | + public static function get_blog_subtitle($blog_id) |
|
| 51 | + { |
|
| 52 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 53 | + $course_id = api_get_course_int_id(); |
|
| 54 | + $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
| 56 | 55 | WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; |
| 57 | - $result = Database::query($sql); |
|
| 58 | - $blog = Database::fetch_array($result); |
|
| 59 | - |
|
| 60 | - return stripslashes($blog['blog_subtitle']); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Get the users of a blog |
|
| 65 | - * @author Toon Keppens |
|
| 66 | - * |
|
| 67 | - * @param Integer $blog_id |
|
| 68 | - * |
|
| 69 | - * @return Array Returns an array with [userid]=>[username] |
|
| 70 | - */ |
|
| 71 | - public static function get_blog_users($blog_id) |
|
| 72 | - { |
|
| 73 | - // Database table definitions |
|
| 74 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 75 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 76 | - |
|
| 77 | - $course_id = api_get_course_int_id(); |
|
| 78 | - |
|
| 79 | - // Get blog members |
|
| 80 | - $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
| 56 | + $result = Database::query($sql); |
|
| 57 | + $blog = Database::fetch_array($result); |
|
| 58 | + |
|
| 59 | + return stripslashes($blog['blog_subtitle']); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Get the users of a blog |
|
| 64 | + * @author Toon Keppens |
|
| 65 | + * |
|
| 66 | + * @param Integer $blog_id |
|
| 67 | + * |
|
| 68 | + * @return Array Returns an array with [userid]=>[username] |
|
| 69 | + */ |
|
| 70 | + public static function get_blog_users($blog_id) |
|
| 71 | + { |
|
| 72 | + // Database table definitions |
|
| 73 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 74 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 75 | + |
|
| 76 | + $course_id = api_get_course_int_id(); |
|
| 77 | + |
|
| 78 | + // Get blog members |
|
| 79 | + $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
| 81 | 80 | FROM " . $tbl_blogs_rel_user . " blogs_rel_user |
| 82 | 81 | INNER JOIN " . $tbl_users . " user |
| 83 | 82 | ON blogs_rel_user.user_id = user.user_id |
| 84 | 83 | WHERE |
| 85 | 84 | blogs_rel_user.c_id = $course_id AND |
| 86 | 85 | blogs_rel_user.blog_id = '" . (int)$blog_id."'"; |
| 87 | - $result = Database::query($sql); |
|
| 88 | - $blog_members = array (); |
|
| 89 | - while($user = Database::fetch_array($result)) { |
|
| 90 | - $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - return $blog_members; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Creates a new blog in the given course |
|
| 98 | - * @author Toon Keppens |
|
| 99 | - * @param Integer $course_id Id |
|
| 100 | - * @param String $title |
|
| 101 | - * @param Text $description |
|
| 102 | - */ |
|
| 103 | - public static function create_blog($title, $subtitle) |
|
| 104 | - { |
|
| 105 | - $_user = api_get_user_info(); |
|
| 86 | + $result = Database::query($sql); |
|
| 87 | + $blog_members = array (); |
|
| 88 | + while($user = Database::fetch_array($result)) { |
|
| 89 | + $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $blog_members; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Creates a new blog in the given course |
|
| 97 | + * @author Toon Keppens |
|
| 98 | + * @param Integer $course_id Id |
|
| 99 | + * @param String $title |
|
| 100 | + * @param Text $description |
|
| 101 | + */ |
|
| 102 | + public static function create_blog($title, $subtitle) |
|
| 103 | + { |
|
| 104 | + $_user = api_get_user_info(); |
|
| 106 | 105 | $course_id = api_get_course_int_id(); |
| 107 | 106 | |
| 108 | - $current_date=date('Y-m-d H:i:s',time()); |
|
| 109 | - $session_id = api_get_session_id(); |
|
| 110 | - // Tabel definitions |
|
| 107 | + $current_date=date('Y-m-d H:i:s',time()); |
|
| 108 | + $session_id = api_get_session_id(); |
|
| 109 | + // Tabel definitions |
|
| 111 | 110 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 112 | 111 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
| 113 | 112 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
| 114 | 113 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 115 | 114 | |
| 116 | - //verified if exist blog |
|
| 117 | - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
| 115 | + //verified if exist blog |
|
| 116 | + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
| 118 | 117 | WHERE |
| 119 | 118 | c_id = '.$course_id.' AND |
| 120 | 119 | blog_name="'.Database::escape_string($title).'" AND |
@@ -123,9 +122,9 @@ discard block |
||
| 123 | 122 | $info_count = Database::result($res, 0, 0); |
| 124 | 123 | |
| 125 | 124 | if ($info_count == 0) { |
| 126 | - // Create the blog |
|
| 125 | + // Create the blog |
|
| 127 | 126 | $params = [ |
| 128 | - 'blog_id' => 0, |
|
| 127 | + 'blog_id' => 0, |
|
| 129 | 128 | 'c_id' => $course_id, |
| 130 | 129 | 'blog_name' => $title, |
| 131 | 130 | 'blog_subtitle' => $subtitle, |
@@ -133,14 +132,14 @@ discard block |
||
| 133 | 132 | 'visibility' => 1 , |
| 134 | 133 | 'session_id' => $session_id, |
| 135 | 134 | ]; |
| 136 | - $this_blog_id = Database::insert($tbl_blogs, $params); |
|
| 135 | + $this_blog_id = Database::insert($tbl_blogs, $params); |
|
| 137 | 136 | |
| 138 | - if ($this_blog_id > 0) { |
|
| 137 | + if ($this_blog_id > 0) { |
|
| 139 | 138 | |
| 140 | 139 | $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id"; |
| 141 | 140 | Database::query($sql); |
| 142 | 141 | |
| 143 | - // insert into item_property |
|
| 142 | + // insert into item_property |
|
| 144 | 143 | api_item_property_update( |
| 145 | 144 | api_get_course_info(), |
| 146 | 145 | TOOL_BLOGS, |
@@ -148,12 +147,12 @@ discard block |
||
| 148 | 147 | 'BlogAdded', |
| 149 | 148 | api_get_user_id() |
| 150 | 149 | ); |
| 151 | - } |
|
| 150 | + } |
|
| 152 | 151 | |
| 153 | - // Make first post. :) |
|
| 152 | + // Make first post. :) |
|
| 154 | 153 | |
| 155 | 154 | $params = [ |
| 156 | - 'post_id' => 0, |
|
| 155 | + 'post_id' => 0, |
|
| 157 | 156 | 'c_id' => $course_id, |
| 158 | 157 | 'title' => get_lang("Welcome"), |
| 159 | 158 | 'full_text' => get_lang('FirstPostText'), |
@@ -167,10 +166,10 @@ discard block |
||
| 167 | 166 | Database::query($sql); |
| 168 | 167 | } |
| 169 | 168 | |
| 170 | - // Put it on course homepage |
|
| 171 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
| 169 | + // Put it on course homepage |
|
| 170 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
|
| 172 | 171 | VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; |
| 173 | - Database::query($sql); |
|
| 172 | + Database::query($sql); |
|
| 174 | 173 | |
| 175 | 174 | $toolId = Database::insert_id(); |
| 176 | 175 | if ($toolId) { |
@@ -178,37 +177,37 @@ discard block |
||
| 178 | 177 | Database::query($sql); |
| 179 | 178 | } |
| 180 | 179 | |
| 181 | - // Subscribe the teacher to this blog |
|
| 182 | - Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Update title and subtitle of a blog in the given course |
|
| 188 | - * @author Toon Keppens |
|
| 189 | - * @param Integer $course_id Id |
|
| 190 | - * @param String $title |
|
| 191 | - * @param Text $description |
|
| 192 | - */ |
|
| 193 | - public static function edit_blog($blog_id, $title, $subtitle) |
|
| 194 | - { |
|
| 195 | - // Table definitions |
|
| 196 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 197 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 180 | + // Subscribe the teacher to this blog |
|
| 181 | + Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Update title and subtitle of a blog in the given course |
|
| 187 | + * @author Toon Keppens |
|
| 188 | + * @param Integer $course_id Id |
|
| 189 | + * @param String $title |
|
| 190 | + * @param Text $description |
|
| 191 | + */ |
|
| 192 | + public static function edit_blog($blog_id, $title, $subtitle) |
|
| 193 | + { |
|
| 194 | + // Table definitions |
|
| 195 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 196 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 198 | 197 | |
| 199 | 198 | $course_id = api_get_course_int_id(); |
| 200 | 199 | |
| 201 | - // Update the blog |
|
| 202 | - $sql = "UPDATE $tbl_blogs SET |
|
| 200 | + // Update the blog |
|
| 201 | + $sql = "UPDATE $tbl_blogs SET |
|
| 203 | 202 | blog_name = '".Database::escape_string($title)."', |
| 204 | 203 | blog_subtitle = '".Database::escape_string($subtitle)."' |
| 205 | 204 | WHERE |
| 206 | 205 | c_id = $course_id AND |
| 207 | 206 | blog_id ='".Database::escape_string((int)$blog_id)."' |
| 208 | 207 | LIMIT 1"; |
| 209 | - Database::query($sql); |
|
| 208 | + Database::query($sql); |
|
| 210 | 209 | |
| 211 | - //update item_property (update) |
|
| 210 | + //update item_property (update) |
|
| 212 | 211 | api_item_property_update( |
| 213 | 212 | api_get_course_info(), |
| 214 | 213 | TOOL_BLOGS, |
@@ -217,60 +216,60 @@ discard block |
||
| 217 | 216 | api_get_user_id() |
| 218 | 217 | ); |
| 219 | 218 | |
| 220 | - // Update course homepage link |
|
| 221 | - $sql = "UPDATE $tbl_tool SET |
|
| 219 | + // Update course homepage link |
|
| 220 | + $sql = "UPDATE $tbl_tool SET |
|
| 222 | 221 | name = '".Database::escape_string($title)."' |
| 223 | 222 | WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
| 224 | - Database::query($sql); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * Deletes a blog and it's posts from the course database |
|
| 229 | - * @author Toon Keppens |
|
| 230 | - * @param Integer $blog_id |
|
| 231 | - */ |
|
| 232 | - public static function delete_blog($blog_id) |
|
| 233 | - { |
|
| 234 | - // Init |
|
| 223 | + Database::query($sql); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Deletes a blog and it's posts from the course database |
|
| 228 | + * @author Toon Keppens |
|
| 229 | + * @param Integer $blog_id |
|
| 230 | + */ |
|
| 231 | + public static function delete_blog($blog_id) |
|
| 232 | + { |
|
| 233 | + // Init |
|
| 235 | 234 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 236 | 235 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
| 237 | 236 | $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
| 238 | 237 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 239 | 238 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
| 240 | 239 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
| 241 | - $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 240 | + $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 242 | 241 | |
| 243 | 242 | $course_id = api_get_course_int_id(); |
| 244 | 243 | $blog_id = intval($blog_id); |
| 245 | 244 | |
| 246 | - // Delete posts from DB and the attachments |
|
| 247 | - delete_all_blog_attachment($blog_id); |
|
| 245 | + // Delete posts from DB and the attachments |
|
| 246 | + delete_all_blog_attachment($blog_id); |
|
| 248 | 247 | |
| 249 | - //Delete comments |
|
| 250 | - $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 251 | - Database::query($sql); |
|
| 248 | + //Delete comments |
|
| 249 | + $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 250 | + Database::query($sql); |
|
| 252 | 251 | |
| 253 | - // Delete posts |
|
| 254 | - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 255 | - Database::query($sql); |
|
| 252 | + // Delete posts |
|
| 253 | + $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 254 | + Database::query($sql); |
|
| 256 | 255 | |
| 257 | - // Delete tasks |
|
| 258 | - $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 259 | - Database::query($sql); |
|
| 256 | + // Delete tasks |
|
| 257 | + $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 258 | + Database::query($sql); |
|
| 260 | 259 | |
| 261 | - // Delete ratings |
|
| 262 | - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 263 | - Database::query($sql); |
|
| 260 | + // Delete ratings |
|
| 261 | + $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 262 | + Database::query($sql); |
|
| 264 | 263 | |
| 265 | - // Delete blog |
|
| 266 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 267 | - Database::query($sql); |
|
| 264 | + // Delete blog |
|
| 265 | + $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 266 | + Database::query($sql); |
|
| 268 | 267 | |
| 269 | - // Delete from course homepage |
|
| 270 | - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
| 271 | - Database::query($sql); |
|
| 268 | + // Delete from course homepage |
|
| 269 | + $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
| 270 | + Database::query($sql); |
|
| 272 | 271 | |
| 273 | - //update item_property (delete) |
|
| 272 | + //update item_property (delete) |
|
| 274 | 273 | api_item_property_update( |
| 275 | 274 | api_get_course_info(), |
| 276 | 275 | TOOL_BLOGS, |
@@ -278,152 +277,152 @@ discard block |
||
| 278 | 277 | 'delete', |
| 279 | 278 | api_get_user_id() |
| 280 | 279 | ); |
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * Creates a new post in a given blog |
|
| 285 | - * @author Toon Keppens |
|
| 286 | - * @param String $title |
|
| 287 | - * @param String $full_text |
|
| 288 | - * @param Integer $blog_id |
|
| 289 | - */ |
|
| 290 | - public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
| 291 | - { |
|
| 292 | - $_user = api_get_user_info(); |
|
| 293 | - $_course = api_get_course_info(); |
|
| 294 | - $course_id = $_course['real_id']; |
|
| 295 | - |
|
| 296 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 297 | - $upload_ok=true; |
|
| 298 | - $has_attachment=false; |
|
| 299 | - $current_date = api_get_utc_datetime(); |
|
| 300 | - |
|
| 301 | - if (!empty($_FILES['user_upload']['name'])) { |
|
| 302 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 303 | - $has_attachment=true; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - if ($upload_ok) { |
|
| 307 | - // Table Definitions |
|
| 308 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 309 | - |
|
| 310 | - // Create the post |
|
| 311 | - $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * Creates a new post in a given blog |
|
| 284 | + * @author Toon Keppens |
|
| 285 | + * @param String $title |
|
| 286 | + * @param String $full_text |
|
| 287 | + * @param Integer $blog_id |
|
| 288 | + */ |
|
| 289 | + public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
| 290 | + { |
|
| 291 | + $_user = api_get_user_info(); |
|
| 292 | + $_course = api_get_course_info(); |
|
| 293 | + $course_id = $_course['real_id']; |
|
| 294 | + |
|
| 295 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 296 | + $upload_ok=true; |
|
| 297 | + $has_attachment=false; |
|
| 298 | + $current_date = api_get_utc_datetime(); |
|
| 299 | + |
|
| 300 | + if (!empty($_FILES['user_upload']['name'])) { |
|
| 301 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 302 | + $has_attachment=true; |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + if ($upload_ok) { |
|
| 306 | + // Table Definitions |
|
| 307 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 308 | + |
|
| 309 | + // Create the post |
|
| 310 | + $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
| 312 | 311 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
| 313 | 312 | |
| 314 | - Database::query($sql); |
|
| 315 | - $last_post_id = Database::insert_id(); |
|
| 313 | + Database::query($sql); |
|
| 314 | + $last_post_id = Database::insert_id(); |
|
| 316 | 315 | |
| 317 | 316 | if ($last_post_id) { |
| 318 | 317 | $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id"; |
| 319 | 318 | Database::query($sql); |
| 320 | 319 | } |
| 321 | 320 | |
| 322 | - if ($has_attachment) { |
|
| 323 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 324 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 325 | - $updir = $sys_course_path.$courseDir; |
|
| 326 | - |
|
| 327 | - // Try to add an extension to the file if it hasn't one |
|
| 328 | - $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
| 329 | - |
|
| 330 | - // user's file name |
|
| 331 | - $file_name = $_FILES['user_upload']['name']; |
|
| 332 | - |
|
| 333 | - if (!filter_extension($new_file_name)) { |
|
| 334 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 335 | - } else { |
|
| 336 | - $new_file_name = uniqid(''); |
|
| 337 | - $new_path = $updir.'/'.$new_file_name; |
|
| 338 | - $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 339 | - $comment = Database::escape_string($file_comment); |
|
| 340 | - |
|
| 341 | - // Storing the attachments if any |
|
| 342 | - if ($result) { |
|
| 343 | - $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
| 344 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
| 345 | - Database::query($sql); |
|
| 321 | + if ($has_attachment) { |
|
| 322 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 323 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 324 | + $updir = $sys_course_path.$courseDir; |
|
| 325 | + |
|
| 326 | + // Try to add an extension to the file if it hasn't one |
|
| 327 | + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
| 328 | + |
|
| 329 | + // user's file name |
|
| 330 | + $file_name = $_FILES['user_upload']['name']; |
|
| 331 | + |
|
| 332 | + if (!filter_extension($new_file_name)) { |
|
| 333 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 334 | + } else { |
|
| 335 | + $new_file_name = uniqid(''); |
|
| 336 | + $new_path = $updir.'/'.$new_file_name; |
|
| 337 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 338 | + $comment = Database::escape_string($file_comment); |
|
| 339 | + |
|
| 340 | + // Storing the attachments if any |
|
| 341 | + if ($result) { |
|
| 342 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
| 343 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
| 344 | + Database::query($sql); |
|
| 346 | 345 | $id = Database::insert_id(); |
| 347 | 346 | if ($id) { |
| 348 | 347 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 349 | 348 | Database::query($sql); |
| 350 | 349 | } |
| 351 | - } |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } else { |
|
| 355 | - Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * Edits a post in a given blog |
|
| 361 | - * @author Toon Keppens |
|
| 362 | - * @param Integer $blog_id |
|
| 363 | - * @param String $title |
|
| 364 | - * @param String $full_text |
|
| 365 | - * @param Integer $blog_id |
|
| 366 | - */ |
|
| 367 | - public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
| 368 | - { |
|
| 369 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + } |
|
| 353 | + } else { |
|
| 354 | + Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * Edits a post in a given blog |
|
| 360 | + * @author Toon Keppens |
|
| 361 | + * @param Integer $blog_id |
|
| 362 | + * @param String $title |
|
| 363 | + * @param String $full_text |
|
| 364 | + * @param Integer $blog_id |
|
| 365 | + */ |
|
| 366 | + public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
| 367 | + { |
|
| 368 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 370 | 369 | $course_id = api_get_course_int_id(); |
| 371 | 370 | |
| 372 | - // Create the post |
|
| 373 | - $sql = "UPDATE $tbl_blogs_posts SET |
|
| 371 | + // Create the post |
|
| 372 | + $sql = "UPDATE $tbl_blogs_posts SET |
|
| 374 | 373 | title = '" . Database::escape_string($title)."', |
| 375 | 374 | full_text = '" . Database::escape_string($full_text)."' |
| 376 | 375 | WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
| 377 | 376 | LIMIT 1 "; |
| 378 | - Database::query($sql); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - /** |
|
| 382 | - * Deletes an article and it's comments |
|
| 383 | - * @author Toon Keppens |
|
| 384 | - * @param int $blog_id |
|
| 385 | - * @param int $post_id |
|
| 386 | - */ |
|
| 387 | - public static function delete_post($blog_id, $post_id) |
|
| 388 | - { |
|
| 389 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 390 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 391 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 377 | + Database::query($sql); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Deletes an article and it's comments |
|
| 382 | + * @author Toon Keppens |
|
| 383 | + * @param int $blog_id |
|
| 384 | + * @param int $post_id |
|
| 385 | + */ |
|
| 386 | + public static function delete_post($blog_id, $post_id) |
|
| 387 | + { |
|
| 388 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 389 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 390 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 392 | 391 | |
| 393 | 392 | $course_id = api_get_course_int_id(); |
| 394 | 393 | |
| 395 | - // Delete ratings on this comment |
|
| 396 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
| 394 | + // Delete ratings on this comment |
|
| 395 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
| 397 | 396 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
| 398 | - Database::query($sql); |
|
| 397 | + Database::query($sql); |
|
| 399 | 398 | |
| 400 | - // Delete the post |
|
| 401 | - $sql = "DELETE FROM $tbl_blogs_posts |
|
| 399 | + // Delete the post |
|
| 400 | + $sql = "DELETE FROM $tbl_blogs_posts |
|
| 402 | 401 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
| 403 | - Database::query($sql); |
|
| 402 | + Database::query($sql); |
|
| 404 | 403 | |
| 405 | - // Delete the comments |
|
| 406 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
| 404 | + // Delete the comments |
|
| 405 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
| 407 | 406 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
| 408 | - Database::query($sql); |
|
| 409 | - |
|
| 410 | - // Delete posts and attachments |
|
| 411 | - delete_all_blog_attachment($blog_id,$post_id); |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * Creates a comment on a post in a given blog |
|
| 416 | - * @author Toon Keppens |
|
| 417 | - * @param String $title |
|
| 418 | - * @param String $full_text |
|
| 419 | - * @param Integer $blog_id |
|
| 420 | - * @param Integer $post_id |
|
| 421 | - * @param Integer $parent_id |
|
| 422 | - */ |
|
| 423 | - public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
| 424 | - { |
|
| 425 | - $_user = api_get_user_info(); |
|
| 426 | - $_course = api_get_course_info(); |
|
| 407 | + Database::query($sql); |
|
| 408 | + |
|
| 409 | + // Delete posts and attachments |
|
| 410 | + delete_all_blog_attachment($blog_id,$post_id); |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * Creates a comment on a post in a given blog |
|
| 415 | + * @author Toon Keppens |
|
| 416 | + * @param String $title |
|
| 417 | + * @param String $full_text |
|
| 418 | + * @param Integer $blog_id |
|
| 419 | + * @param Integer $post_id |
|
| 420 | + * @param Integer $parent_id |
|
| 421 | + */ |
|
| 422 | + public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
| 423 | + { |
|
| 424 | + $_user = api_get_user_info(); |
|
| 425 | + $_course = api_get_course_info(); |
|
| 427 | 426 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
| 428 | 427 | |
| 429 | 428 | $upload_ok = true; |
@@ -431,55 +430,55 @@ discard block |
||
| 431 | 430 | $current_date = api_get_utc_datetime(); |
| 432 | 431 | $course_id = api_get_course_int_id(); |
| 433 | 432 | |
| 434 | - if (!empty($_FILES['user_upload']['name'])) { |
|
| 435 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 436 | - $has_attachment=true; |
|
| 437 | - } |
|
| 433 | + if (!empty($_FILES['user_upload']['name'])) { |
|
| 434 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
| 435 | + $has_attachment=true; |
|
| 436 | + } |
|
| 438 | 437 | |
| 439 | - if ($upload_ok) { |
|
| 440 | - // Table Definition |
|
| 441 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 438 | + if ($upload_ok) { |
|
| 439 | + // Table Definition |
|
| 440 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 442 | 441 | |
| 443 | - // Create the comment |
|
| 444 | - $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
| 442 | + // Create the comment |
|
| 443 | + $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
| 445 | 444 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')"; |
| 446 | - Database::query($sql); |
|
| 445 | + Database::query($sql); |
|
| 447 | 446 | |
| 448 | - // Empty post values, or they are shown on the page again |
|
| 449 | - $last_id = Database::insert_id(); |
|
| 447 | + // Empty post values, or they are shown on the page again |
|
| 448 | + $last_id = Database::insert_id(); |
|
| 450 | 449 | |
| 451 | 450 | if ($last_id) { |
| 452 | 451 | $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id"; |
| 453 | 452 | Database::query($sql); |
| 454 | 453 | } |
| 455 | 454 | |
| 456 | - if ($has_attachment) { |
|
| 457 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 458 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 459 | - $updir = $sys_course_path.$courseDir; |
|
| 460 | - |
|
| 461 | - // Try to add an extension to the file if it hasn't one |
|
| 462 | - $new_file_name = add_ext_on_mime( |
|
| 463 | - stripslashes($_FILES['user_upload']['name']), |
|
| 464 | - $_FILES['user_upload']['type'] |
|
| 465 | - ); |
|
| 466 | - |
|
| 467 | - // user's file name |
|
| 468 | - $file_name =$_FILES['user_upload']['name']; |
|
| 469 | - |
|
| 470 | - if (!filter_extension($new_file_name)) { |
|
| 471 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 472 | - } else { |
|
| 473 | - $new_file_name = uniqid(''); |
|
| 474 | - $new_path=$updir.'/'.$new_file_name; |
|
| 475 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 476 | - $comment = Database::escape_string($file_comment); |
|
| 477 | - |
|
| 478 | - // Storing the attachments if any |
|
| 479 | - if ($result) { |
|
| 480 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 481 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
| 482 | - Database::query($sql); |
|
| 455 | + if ($has_attachment) { |
|
| 456 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 457 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 458 | + $updir = $sys_course_path.$courseDir; |
|
| 459 | + |
|
| 460 | + // Try to add an extension to the file if it hasn't one |
|
| 461 | + $new_file_name = add_ext_on_mime( |
|
| 462 | + stripslashes($_FILES['user_upload']['name']), |
|
| 463 | + $_FILES['user_upload']['type'] |
|
| 464 | + ); |
|
| 465 | + |
|
| 466 | + // user's file name |
|
| 467 | + $file_name =$_FILES['user_upload']['name']; |
|
| 468 | + |
|
| 469 | + if (!filter_extension($new_file_name)) { |
|
| 470 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
| 471 | + } else { |
|
| 472 | + $new_file_name = uniqid(''); |
|
| 473 | + $new_path=$updir.'/'.$new_file_name; |
|
| 474 | + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 475 | + $comment = Database::escape_string($file_comment); |
|
| 476 | + |
|
| 477 | + // Storing the attachments if any |
|
| 478 | + if ($result) { |
|
| 479 | + $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 480 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
| 481 | + Database::query($sql); |
|
| 483 | 482 | |
| 484 | 483 | $id = Database::insert_id(); |
| 485 | 484 | |
@@ -487,92 +486,92 @@ discard block |
||
| 487 | 486 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
| 488 | 487 | Database::query($sql); |
| 489 | 488 | } |
| 490 | - } |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - } |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * Deletes a comment from a blogpost |
|
| 498 | - * @author Toon Keppens |
|
| 499 | - * @param int $blog_id |
|
| 500 | - * @param int $comment_id |
|
| 501 | - */ |
|
| 502 | - public static function delete_comment($blog_id, $post_id, $comment_id) |
|
| 503 | - { |
|
| 504 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 505 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 506 | - $blog_id = intval($blog_id); |
|
| 507 | - $post_id = intval($post_id); |
|
| 508 | - $comment_id = intval($comment_id); |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * Deletes a comment from a blogpost |
|
| 497 | + * @author Toon Keppens |
|
| 498 | + * @param int $blog_id |
|
| 499 | + * @param int $comment_id |
|
| 500 | + */ |
|
| 501 | + public static function delete_comment($blog_id, $post_id, $comment_id) |
|
| 502 | + { |
|
| 503 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 504 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 505 | + $blog_id = intval($blog_id); |
|
| 506 | + $post_id = intval($post_id); |
|
| 507 | + $comment_id = intval($comment_id); |
|
| 509 | 508 | $course_id = api_get_course_int_id(); |
| 510 | 509 | |
| 511 | - delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
| 510 | + delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
| 512 | 511 | |
| 513 | - // Delete ratings on this comment |
|
| 514 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
| 512 | + // Delete ratings on this comment |
|
| 513 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
| 515 | 514 | WHERE |
| 516 | 515 | c_id = $course_id AND |
| 517 | 516 | blog_id = '".$blog_id."' AND |
| 518 | 517 | item_id = '".$comment_id."' AND |
| 519 | 518 | rating_type = 'comment'"; |
| 520 | - Database::query($sql); |
|
| 519 | + Database::query($sql); |
|
| 521 | 520 | |
| 522 | - // select comments that have the selected comment as their parent |
|
| 523 | - $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
| 521 | + // select comments that have the selected comment as their parent |
|
| 522 | + $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
| 524 | 523 | WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'"; |
| 525 | - $result = Database::query($sql); |
|
| 524 | + $result = Database::query($sql); |
|
| 526 | 525 | |
| 527 | - // Delete them recursively |
|
| 528 | - while ($comment = Database::fetch_array($result)) { |
|
| 529 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
| 530 | - } |
|
| 526 | + // Delete them recursively |
|
| 527 | + while ($comment = Database::fetch_array($result)) { |
|
| 528 | + Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
| 529 | + } |
|
| 531 | 530 | |
| 532 | - // Finally, delete the selected comment to |
|
| 533 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
| 531 | + // Finally, delete the selected comment to |
|
| 532 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
| 534 | 533 | WHERE c_id = $course_id AND comment_id = '".$comment_id."'"; |
| 535 | - Database::query($sql); |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Creates a new task in a blog |
|
| 540 | - * @author Toon Keppens |
|
| 541 | - * @param Integer $blog_id |
|
| 542 | - * @param String $title |
|
| 543 | - * @param String $description |
|
| 544 | - * @param String $color |
|
| 545 | - */ |
|
| 546 | - public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 547 | - { |
|
| 548 | - // Init |
|
| 549 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 550 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 551 | - |
|
| 552 | - $course_id = api_get_course_int_id(); |
|
| 553 | - |
|
| 554 | - // Create the task |
|
| 555 | - $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
| 534 | + Database::query($sql); |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * Creates a new task in a blog |
|
| 539 | + * @author Toon Keppens |
|
| 540 | + * @param Integer $blog_id |
|
| 541 | + * @param String $title |
|
| 542 | + * @param String $description |
|
| 543 | + * @param String $color |
|
| 544 | + */ |
|
| 545 | + public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 546 | + { |
|
| 547 | + // Init |
|
| 548 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 549 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 550 | + |
|
| 551 | + $course_id = api_get_course_int_id(); |
|
| 552 | + |
|
| 553 | + // Create the task |
|
| 554 | + $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
| 556 | 555 | VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
| 557 | - Database::query($sql); |
|
| 556 | + Database::query($sql); |
|
| 558 | 557 | |
| 559 | - $task_id = Database::insert_id(); |
|
| 558 | + $task_id = Database::insert_id(); |
|
| 560 | 559 | |
| 561 | 560 | if ($task_id) { |
| 562 | 561 | $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
| 563 | 562 | Database::query($sql); |
| 564 | 563 | } |
| 565 | 564 | |
| 566 | - $tool = 'BLOG_' . $blog_id; |
|
| 565 | + $tool = 'BLOG_' . $blog_id; |
|
| 567 | 566 | |
| 568 | - if ($articleDelete == 'on') { |
|
| 569 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 567 | + if ($articleDelete == 'on') { |
|
| 568 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 570 | 569 | '" . (int)$course_id . "', |
| 571 | 570 | '" . (int)$task_id . "', |
| 572 | 571 | '" . Database::escape_string($tool) . "', |
| 573 | 572 | 'article_delete' |
| 574 | 573 | )"; |
| 575 | - Database::query($sql); |
|
| 574 | + Database::query($sql); |
|
| 576 | 575 | |
| 577 | 576 | $id = Database::insert_id(); |
| 578 | 577 | |
@@ -582,172 +581,172 @@ discard block |
||
| 582 | 581 | } |
| 583 | 582 | } |
| 584 | 583 | |
| 585 | - if ($articleEdit == 'on') { |
|
| 586 | - $sql = " |
|
| 584 | + if ($articleEdit == 'on') { |
|
| 585 | + $sql = " |
|
| 587 | 586 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
| 588 | 587 | '" . (int)$course_id . "', |
| 589 | 588 | '" . (int)$task_id . "', |
| 590 | 589 | '" . Database::escape_string($tool) . "', |
| 591 | 590 | 'article_edit' |
| 592 | 591 | )"; |
| 593 | - Database::query($sql); |
|
| 592 | + Database::query($sql); |
|
| 594 | 593 | $id = Database::insert_id(); |
| 595 | 594 | |
| 596 | 595 | if ($id) { |
| 597 | 596 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 598 | 597 | Database::query($sql); |
| 599 | 598 | } |
| 600 | - } |
|
| 599 | + } |
|
| 601 | 600 | |
| 602 | - if ($commentsDelete == 'on') { |
|
| 603 | - $sql = " |
|
| 601 | + if ($commentsDelete == 'on') { |
|
| 602 | + $sql = " |
|
| 604 | 603 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
| 605 | 604 | '" . (int)$course_id . "', |
| 606 | 605 | '" . (int)$task_id . "', |
| 607 | 606 | '" . Database::escape_string($tool) . "', |
| 608 | 607 | 'article_comments_delete' |
| 609 | 608 | )"; |
| 610 | - Database::query($sql); |
|
| 609 | + Database::query($sql); |
|
| 611 | 610 | $id = Database::insert_id(); |
| 612 | 611 | |
| 613 | 612 | if ($id) { |
| 614 | 613 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 615 | 614 | Database::query($sql); |
| 616 | 615 | } |
| 617 | - } |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * Edit a task in a blog |
|
| 622 | - * @author Toon Keppens |
|
| 623 | - * @param Integer $task_id |
|
| 624 | - * @param String $title |
|
| 625 | - * @param String $description |
|
| 626 | - * @param String $color |
|
| 627 | - */ |
|
| 628 | - public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 629 | - { |
|
| 630 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 631 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 616 | + } |
|
| 617 | + } |
|
| 618 | + |
|
| 619 | + /** |
|
| 620 | + * Edit a task in a blog |
|
| 621 | + * @author Toon Keppens |
|
| 622 | + * @param Integer $task_id |
|
| 623 | + * @param String $title |
|
| 624 | + * @param String $description |
|
| 625 | + * @param String $color |
|
| 626 | + */ |
|
| 627 | + public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
| 628 | + { |
|
| 629 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 630 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 632 | 631 | |
| 633 | 632 | $course_id = api_get_course_int_id(); |
| 634 | 633 | |
| 635 | - // Create the task |
|
| 636 | - $sql = "UPDATE $tbl_blogs_tasks SET |
|
| 634 | + // Create the task |
|
| 635 | + $sql = "UPDATE $tbl_blogs_tasks SET |
|
| 637 | 636 | title = '".Database::escape_string($title)."', |
| 638 | 637 | description = '".Database::escape_string($description)."', |
| 639 | 638 | color = '".Database::escape_string($color)."' |
| 640 | 639 | WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
| 641 | - Database::query($sql); |
|
| 640 | + Database::query($sql); |
|
| 642 | 641 | |
| 643 | - $tool = 'BLOG_' . $blog_id; |
|
| 642 | + $tool = 'BLOG_' . $blog_id; |
|
| 644 | 643 | |
| 645 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
| 644 | + $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
| 646 | 645 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
| 647 | - Database::query($sql); |
|
| 646 | + Database::query($sql); |
|
| 648 | 647 | |
| 649 | - if ($articleDelete == 'on') { |
|
| 650 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 648 | + if ($articleDelete == 'on') { |
|
| 649 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 651 | 650 | '" . (int)$course_id . "', |
| 652 | 651 | '" . (int)$task_id . "', |
| 653 | 652 | '" . Database::escape_string($tool) . "', |
| 654 | 653 | 'article_delete' |
| 655 | 654 | )"; |
| 656 | - Database::query($sql); |
|
| 655 | + Database::query($sql); |
|
| 657 | 656 | $id = Database::insert_id(); |
| 658 | 657 | |
| 659 | 658 | if ($id) { |
| 660 | 659 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 661 | 660 | Database::query($sql); |
| 662 | 661 | } |
| 663 | - } |
|
| 662 | + } |
|
| 664 | 663 | |
| 665 | - if ($articleEdit == 'on') { |
|
| 666 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 664 | + if ($articleEdit == 'on') { |
|
| 665 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 667 | 666 | '" . (int)$course_id . "', |
| 668 | 667 | '" . (int)$task_id . "', |
| 669 | 668 | '" . Database::escape_string($tool) . "', |
| 670 | 669 | 'article_edit' |
| 671 | 670 | )"; |
| 672 | - Database::query($sql); |
|
| 671 | + Database::query($sql); |
|
| 673 | 672 | $id = Database::insert_id(); |
| 674 | 673 | |
| 675 | 674 | if ($id) { |
| 676 | 675 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 677 | 676 | Database::query($sql); |
| 678 | 677 | } |
| 679 | - } |
|
| 678 | + } |
|
| 680 | 679 | |
| 681 | - if ($commentsDelete == 'on') { |
|
| 682 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 680 | + if ($commentsDelete == 'on') { |
|
| 681 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 683 | 682 | '" . (int)$course_id . "', |
| 684 | 683 | '" . (int)$task_id . "', |
| 685 | 684 | '" . Database::escape_string($tool) . "', |
| 686 | 685 | 'article_comments_delete' |
| 687 | 686 | )"; |
| 688 | - Database::query($sql); |
|
| 687 | + Database::query($sql); |
|
| 689 | 688 | $id = Database::insert_id(); |
| 690 | 689 | |
| 691 | 690 | if ($id) { |
| 692 | 691 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 693 | 692 | Database::query($sql); |
| 694 | 693 | } |
| 695 | - } |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - /** |
|
| 699 | - * Deletes a task from a blog |
|
| 700 | - * @param Integer $blog_id |
|
| 701 | - * @param Integer $task_id |
|
| 702 | - */ |
|
| 703 | - public static function delete_task($blog_id, $task_id) |
|
| 704 | - { |
|
| 705 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 706 | - $course_id = api_get_course_int_id(); |
|
| 707 | - |
|
| 708 | - // Delete posts |
|
| 709 | - $sql = "DELETE FROM $tbl_blogs_tasks |
|
| 694 | + } |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + /** |
|
| 698 | + * Deletes a task from a blog |
|
| 699 | + * @param Integer $blog_id |
|
| 700 | + * @param Integer $task_id |
|
| 701 | + */ |
|
| 702 | + public static function delete_task($blog_id, $task_id) |
|
| 703 | + { |
|
| 704 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 705 | + $course_id = api_get_course_int_id(); |
|
| 706 | + |
|
| 707 | + // Delete posts |
|
| 708 | + $sql = "DELETE FROM $tbl_blogs_tasks |
|
| 710 | 709 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
| 711 | - Database::query($sql); |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * Deletes an assigned task from a blog |
|
| 716 | - * @param Integer $blog_id |
|
| 717 | - * @param Integer $assignment_id |
|
| 718 | - */ |
|
| 719 | - public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
| 720 | - { |
|
| 721 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 710 | + Database::query($sql); |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + /** |
|
| 714 | + * Deletes an assigned task from a blog |
|
| 715 | + * @param Integer $blog_id |
|
| 716 | + * @param Integer $assignment_id |
|
| 717 | + */ |
|
| 718 | + public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
| 719 | + { |
|
| 720 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 722 | 721 | $course_id = api_get_course_int_id(); |
| 723 | 722 | |
| 724 | - // Delete posts |
|
| 725 | - $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
| 723 | + // Delete posts |
|
| 724 | + $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
| 726 | 725 | WHERE |
| 727 | 726 | c_id = $course_id AND |
| 728 | 727 | blog_id = '".(int)$blog_id."' AND |
| 729 | 728 | task_id = '".(int)$task_id."' AND |
| 730 | 729 | user_id = '".(int)$user_id."'"; |
| 731 | - Database::query($sql); |
|
| 732 | - } |
|
| 733 | - |
|
| 734 | - /** |
|
| 735 | - * Get personal task list |
|
| 736 | - * @author Toon Keppens |
|
| 737 | - * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
| 738 | - */ |
|
| 739 | - public static function get_personal_task_list() |
|
| 740 | - { |
|
| 741 | - $_user = api_get_user_info(); |
|
| 742 | - |
|
| 743 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 744 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 745 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 746 | - |
|
| 747 | - $course_id = api_get_course_int_id(); |
|
| 748 | - |
|
| 749 | - if ($_user['user_id']) { |
|
| 750 | - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
| 730 | + Database::query($sql); |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + /** |
|
| 734 | + * Get personal task list |
|
| 735 | + * @author Toon Keppens |
|
| 736 | + * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
| 737 | + */ |
|
| 738 | + public static function get_personal_task_list() |
|
| 739 | + { |
|
| 740 | + $_user = api_get_user_info(); |
|
| 741 | + |
|
| 742 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 743 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 744 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 745 | + |
|
| 746 | + $course_id = api_get_course_int_id(); |
|
| 747 | + |
|
| 748 | + if ($_user['user_id']) { |
|
| 749 | + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
| 751 | 750 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
| 752 | 751 | INNER JOIN $tbl_blogs_tasks task |
| 753 | 752 | ON task_rel_user.task_id = task.task_id |
@@ -761,85 +760,85 @@ discard block |
||
| 761 | 760 | task_rel_user.user_id = ".(int)$_user['user_id']." |
| 762 | 761 | ORDER BY target_date ASC"; |
| 763 | 762 | |
| 764 | - $result = Database::query($sql); |
|
| 765 | - |
|
| 766 | - if (Database::num_rows($result) > 0) { |
|
| 767 | - echo '<ul>'; |
|
| 768 | - while ($mytask = Database::fetch_array($result)) { |
|
| 769 | - echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
| 770 | - } |
|
| 771 | - echo '<ul>'; |
|
| 772 | - } else { |
|
| 773 | - echo get_lang('NoTasks'); |
|
| 774 | - } |
|
| 775 | - } else { |
|
| 776 | - echo get_lang('NoTasks'); |
|
| 777 | - } |
|
| 778 | - } |
|
| 779 | - |
|
| 780 | - /** |
|
| 781 | - * Changes the visibility of a blog |
|
| 782 | - * @author Toon Keppens |
|
| 783 | - * @param Integer $blog_id |
|
| 784 | - */ |
|
| 785 | - public static function change_blog_visibility($blog_id) |
|
| 786 | - { |
|
| 787 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 788 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 789 | - $course_id = api_get_course_int_id(); |
|
| 790 | - |
|
| 791 | - // Get blog properties |
|
| 792 | - $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
| 763 | + $result = Database::query($sql); |
|
| 764 | + |
|
| 765 | + if (Database::num_rows($result) > 0) { |
|
| 766 | + echo '<ul>'; |
|
| 767 | + while ($mytask = Database::fetch_array($result)) { |
|
| 768 | + echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
| 769 | + } |
|
| 770 | + echo '<ul>'; |
|
| 771 | + } else { |
|
| 772 | + echo get_lang('NoTasks'); |
|
| 773 | + } |
|
| 774 | + } else { |
|
| 775 | + echo get_lang('NoTasks'); |
|
| 776 | + } |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + /** |
|
| 780 | + * Changes the visibility of a blog |
|
| 781 | + * @author Toon Keppens |
|
| 782 | + * @param Integer $blog_id |
|
| 783 | + */ |
|
| 784 | + public static function change_blog_visibility($blog_id) |
|
| 785 | + { |
|
| 786 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 787 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
| 788 | + $course_id = api_get_course_int_id(); |
|
| 789 | + |
|
| 790 | + // Get blog properties |
|
| 791 | + $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
| 793 | 792 | WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
| 794 | - $result = Database::query($sql); |
|
| 795 | - $blog = Database::fetch_array($result); |
|
| 796 | - $visibility = $blog['visibility']; |
|
| 797 | - $title = $blog['blog_name']; |
|
| 798 | - |
|
| 799 | - if ($visibility == 1) { |
|
| 800 | - // Change visibility state, remove from course home. |
|
| 801 | - $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
| 793 | + $result = Database::query($sql); |
|
| 794 | + $blog = Database::fetch_array($result); |
|
| 795 | + $visibility = $blog['visibility']; |
|
| 796 | + $title = $blog['blog_name']; |
|
| 797 | + |
|
| 798 | + if ($visibility == 1) { |
|
| 799 | + // Change visibility state, remove from course home. |
|
| 800 | + $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
| 802 | 801 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
| 803 | - Database::query($sql); |
|
| 802 | + Database::query($sql); |
|
| 804 | 803 | |
| 805 | - $sql = "DELETE FROM $tbl_tool |
|
| 804 | + $sql = "DELETE FROM $tbl_tool |
|
| 806 | 805 | WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; |
| 807 | - Database::query($sql); |
|
| 808 | - } else { |
|
| 809 | - // Change visibility state, add to course home. |
|
| 810 | - $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
| 806 | + Database::query($sql); |
|
| 807 | + } else { |
|
| 808 | + // Change visibility state, add to course home. |
|
| 809 | + $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
| 811 | 810 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
| 812 | - Database::query($sql); |
|
| 811 | + Database::query($sql); |
|
| 813 | 812 | |
| 814 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
| 813 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
| 815 | 814 | VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
| 816 | - Database::query($sql); |
|
| 815 | + Database::query($sql); |
|
| 817 | 816 | $id = Database::insert_id(); |
| 818 | 817 | |
| 819 | 818 | if ($id) { |
| 820 | 819 | $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id"; |
| 821 | 820 | Database::query($sql); |
| 822 | 821 | } |
| 823 | - } |
|
| 824 | - } |
|
| 825 | - |
|
| 826 | - /** |
|
| 827 | - * Shows the posts of a blog |
|
| 828 | - * @author Toon Keppens |
|
| 829 | - * |
|
| 830 | - * @param Integer $blog_id |
|
| 831 | - */ |
|
| 832 | - public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
| 822 | + } |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + /** |
|
| 826 | + * Shows the posts of a blog |
|
| 827 | + * @author Toon Keppens |
|
| 828 | + * |
|
| 829 | + * @param Integer $blog_id |
|
| 830 | + */ |
|
| 831 | + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
| 833 | 832 | { |
| 834 | - // Init |
|
| 835 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 836 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 837 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 833 | + // Init |
|
| 834 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 835 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 836 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 838 | 837 | |
| 839 | - $course_id = api_get_course_int_id(); |
|
| 838 | + $course_id = api_get_course_int_id(); |
|
| 840 | 839 | |
| 841 | - // Get posts and authors |
|
| 842 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 840 | + // Get posts and authors |
|
| 841 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 843 | 842 | FROM $tbl_blogs_posts post |
| 844 | 843 | INNER JOIN $tbl_users user |
| 845 | 844 | ON post.author_id = user.user_id |
@@ -847,131 +846,131 @@ discard block |
||
| 847 | 846 | post.c_id = $course_id AND |
| 848 | 847 | $filter |
| 849 | 848 | ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
| 850 | - $result = Database::query($sql); |
|
| 851 | - |
|
| 852 | - // Display |
|
| 853 | - if(Database::num_rows($result) > 0) { |
|
| 854 | - $limit = 200; |
|
| 855 | - while ($blog_post = Database::fetch_array($result)) { |
|
| 856 | - // Get number of comments |
|
| 857 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
| 849 | + $result = Database::query($sql); |
|
| 850 | + |
|
| 851 | + // Display |
|
| 852 | + if(Database::num_rows($result) > 0) { |
|
| 853 | + $limit = 200; |
|
| 854 | + while ($blog_post = Database::fetch_array($result)) { |
|
| 855 | + // Get number of comments |
|
| 856 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
| 858 | 857 | FROM $tbl_blogs_comments |
| 859 | 858 | WHERE |
| 860 | 859 | c_id = $course_id AND |
| 861 | 860 | blog_id = '".(int)$blog_id."' AND |
| 862 | 861 | post_id = '" . (int)$blog_post['post_id']."'"; |
| 863 | - $tmp = Database::query($sql); |
|
| 864 | - $blog_post_comments = Database::fetch_array($tmp); |
|
| 865 | - |
|
| 866 | - // Prepare data |
|
| 867 | - $blog_post_id = $blog_post['post_id']; |
|
| 868 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 869 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 870 | - |
|
| 871 | - // Create an introduction text (but keep FULL sentences) |
|
| 872 | - $words = 0; |
|
| 873 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
| 874 | - $words = strlen($blog_post_text); |
|
| 875 | - |
|
| 876 | - if ($words >= $limit) { |
|
| 877 | - $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
| 878 | - $introduction_text = $blog_post_text_cut; |
|
| 879 | - } else { |
|
| 880 | - $introduction_text = $blog_post_text; |
|
| 881 | - $readMoreLink = ''; |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - $introduction_text = stripslashes($introduction_text); |
|
| 885 | - |
|
| 886 | - echo '<div class="blogpost">'; |
|
| 887 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 888 | - echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
| 889 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
| 890 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
| 891 | - |
|
| 892 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
| 893 | - |
|
| 894 | - if (!empty($file_name_array)) { |
|
| 895 | - echo '<br /><br />'; |
|
| 896 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 897 | - echo '<a href="download.php?file='; |
|
| 898 | - echo $file_name_array['path']; |
|
| 899 | - echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
| 900 | - echo '</span>'; |
|
| 901 | - } |
|
| 902 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 903 | - echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
| 904 | - echo '</div>'; |
|
| 905 | - } |
|
| 906 | - } else { |
|
| 907 | - if($filter == '1=1') { |
|
| 908 | - echo get_lang('NoArticles'); |
|
| 909 | - } else { |
|
| 910 | - echo get_lang('NoArticleMatches'); |
|
| 911 | - } |
|
| 912 | - } |
|
| 862 | + $tmp = Database::query($sql); |
|
| 863 | + $blog_post_comments = Database::fetch_array($tmp); |
|
| 864 | + |
|
| 865 | + // Prepare data |
|
| 866 | + $blog_post_id = $blog_post['post_id']; |
|
| 867 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 868 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 869 | + |
|
| 870 | + // Create an introduction text (but keep FULL sentences) |
|
| 871 | + $words = 0; |
|
| 872 | + $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
| 873 | + $words = strlen($blog_post_text); |
|
| 874 | + |
|
| 875 | + if ($words >= $limit) { |
|
| 876 | + $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
| 877 | + $introduction_text = $blog_post_text_cut; |
|
| 878 | + } else { |
|
| 879 | + $introduction_text = $blog_post_text; |
|
| 880 | + $readMoreLink = ''; |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + $introduction_text = stripslashes($introduction_text); |
|
| 884 | + |
|
| 885 | + echo '<div class="blogpost">'; |
|
| 886 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 887 | + echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
| 888 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
| 889 | + echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
| 890 | + |
|
| 891 | + $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
| 892 | + |
|
| 893 | + if (!empty($file_name_array)) { |
|
| 894 | + echo '<br /><br />'; |
|
| 895 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 896 | + echo '<a href="download.php?file='; |
|
| 897 | + echo $file_name_array['path']; |
|
| 898 | + echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
| 899 | + echo '</span>'; |
|
| 900 | + } |
|
| 901 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 902 | + echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
| 903 | + echo '</div>'; |
|
| 904 | + } |
|
| 905 | + } else { |
|
| 906 | + if($filter == '1=1') { |
|
| 907 | + echo get_lang('NoArticles'); |
|
| 908 | + } else { |
|
| 909 | + echo get_lang('NoArticleMatches'); |
|
| 910 | + } |
|
| 911 | + } |
|
| 913 | 912 | } |
| 914 | 913 | |
| 915 | - /** |
|
| 916 | - * Display the search results |
|
| 917 | - * |
|
| 918 | - * @param Integer $blog_id |
|
| 919 | - * @param String $query_string |
|
| 920 | - */ |
|
| 921 | - public static function display_search_results ($blog_id, $query_string) |
|
| 922 | - { |
|
| 923 | - // Init |
|
| 924 | - $query_string = Database::escape_string($query_string); |
|
| 925 | - $query_string_parts = explode(' ',$query_string); |
|
| 926 | - $query_string = array(); |
|
| 927 | - foreach ($query_string_parts as $query_part) { |
|
| 928 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
| 929 | - } |
|
| 930 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
| 931 | - |
|
| 932 | - // Display the posts |
|
| 933 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
| 934 | - Blog::display_blog_posts($blog_id, $query_string); |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - /** |
|
| 938 | - * Display posts from a certain date |
|
| 939 | - * |
|
| 940 | - * @param Integer $blog_id |
|
| 941 | - * @param String $query_string |
|
| 942 | - */ |
|
| 943 | - public static function display_day_results($blog_id, $query_string) |
|
| 944 | - { |
|
| 945 | - $date_output = $query_string; |
|
| 946 | - $date = explode('-',$query_string); |
|
| 947 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
| 948 | - |
|
| 949 | - // Put date in correct output format |
|
| 950 | - $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
| 951 | - |
|
| 952 | - // Display the posts |
|
| 953 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
| 954 | - Blog::display_blog_posts($blog_id, $query_string); |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * Displays a post and his comments |
|
| 959 | - * |
|
| 960 | - * @param Integer $blog_id |
|
| 961 | - * @param Integer $post_id |
|
| 962 | - */ |
|
| 963 | - public static function display_post($blog_id, $post_id) |
|
| 964 | - { |
|
| 965 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 966 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 967 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 968 | - |
|
| 969 | - global $charset, $dateFormatLong; |
|
| 970 | - |
|
| 971 | - $course_id = api_get_course_int_id(); |
|
| 972 | - |
|
| 973 | - // Get posts and author |
|
| 974 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 914 | + /** |
|
| 915 | + * Display the search results |
|
| 916 | + * |
|
| 917 | + * @param Integer $blog_id |
|
| 918 | + * @param String $query_string |
|
| 919 | + */ |
|
| 920 | + public static function display_search_results ($blog_id, $query_string) |
|
| 921 | + { |
|
| 922 | + // Init |
|
| 923 | + $query_string = Database::escape_string($query_string); |
|
| 924 | + $query_string_parts = explode(' ',$query_string); |
|
| 925 | + $query_string = array(); |
|
| 926 | + foreach ($query_string_parts as $query_part) { |
|
| 927 | + $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
| 928 | + } |
|
| 929 | + $query_string = '('.implode('OR',$query_string) . ')'; |
|
| 930 | + |
|
| 931 | + // Display the posts |
|
| 932 | + echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
| 933 | + Blog::display_blog_posts($blog_id, $query_string); |
|
| 934 | + } |
|
| 935 | + |
|
| 936 | + /** |
|
| 937 | + * Display posts from a certain date |
|
| 938 | + * |
|
| 939 | + * @param Integer $blog_id |
|
| 940 | + * @param String $query_string |
|
| 941 | + */ |
|
| 942 | + public static function display_day_results($blog_id, $query_string) |
|
| 943 | + { |
|
| 944 | + $date_output = $query_string; |
|
| 945 | + $date = explode('-',$query_string); |
|
| 946 | + $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
| 947 | + |
|
| 948 | + // Put date in correct output format |
|
| 949 | + $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
| 950 | + |
|
| 951 | + // Display the posts |
|
| 952 | + echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
| 953 | + Blog::display_blog_posts($blog_id, $query_string); |
|
| 954 | + } |
|
| 955 | + |
|
| 956 | + /** |
|
| 957 | + * Displays a post and his comments |
|
| 958 | + * |
|
| 959 | + * @param Integer $blog_id |
|
| 960 | + * @param Integer $post_id |
|
| 961 | + */ |
|
| 962 | + public static function display_post($blog_id, $post_id) |
|
| 963 | + { |
|
| 964 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 965 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 966 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 967 | + |
|
| 968 | + global $charset, $dateFormatLong; |
|
| 969 | + |
|
| 970 | + $course_id = api_get_course_int_id(); |
|
| 971 | + |
|
| 972 | + // Get posts and author |
|
| 973 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 975 | 974 | FROM $tbl_blogs_posts post |
| 976 | 975 | INNER JOIN $tbl_users user |
| 977 | 976 | ON post.author_id = user.user_id |
@@ -980,113 +979,113 @@ discard block |
||
| 980 | 979 | post.blog_id = '".(int)$blog_id."' AND |
| 981 | 980 | post.post_id = '".(int)$post_id."' |
| 982 | 981 | ORDER BY post_id DESC"; |
| 983 | - $result = Database::query($sql); |
|
| 984 | - $blog_post = Database::fetch_array($result); |
|
| 982 | + $result = Database::query($sql); |
|
| 983 | + $blog_post = Database::fetch_array($result); |
|
| 985 | 984 | |
| 986 | - // Get number of comments |
|
| 987 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
| 985 | + // Get number of comments |
|
| 986 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
| 988 | 987 | FROM $tbl_blogs_comments |
| 989 | 988 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
| 990 | - $result = Database::query($sql); |
|
| 991 | - $blog_post_comments = Database::fetch_array($result); |
|
| 989 | + $result = Database::query($sql); |
|
| 990 | + $blog_post_comments = Database::fetch_array($result); |
|
| 992 | 991 | |
| 993 | - // Prepare data |
|
| 994 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 995 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 996 | - $blog_post_actions = ""; |
|
| 992 | + // Prepare data |
|
| 993 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
| 994 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
| 995 | + $blog_post_actions = ""; |
|
| 997 | 996 | |
| 998 | - $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
| 997 | + $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
| 999 | 998 | |
| 1000 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
| 1001 | - $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
| 1002 | - $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 1003 | - $blog_post_actions .= '</a>'; |
|
| 999 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
| 1000 | + $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
| 1001 | + $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 1002 | + $blog_post_actions .= '</a>'; |
|
| 1004 | 1003 | } |
| 1005 | 1004 | |
| 1006 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
| 1007 | - $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
| 1005 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
| 1006 | + $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
| 1008 | 1007 | $blog_post_actions .= Display::return_icon('delete.png'); |
| 1009 | 1008 | $blog_post_actions .= '</a>'; |
| 1010 | 1009 | } |
| 1011 | 1010 | |
| 1012 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1013 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1011 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1012 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1014 | 1013 | |
| 1015 | - $blog_post_text=stripslashes($blog_post_text); |
|
| 1014 | + $blog_post_text=stripslashes($blog_post_text); |
|
| 1016 | 1015 | |
| 1017 | - // Display post |
|
| 1018 | - echo '<div class="blogpost">'; |
|
| 1019 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 1020 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
| 1021 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
| 1016 | + // Display post |
|
| 1017 | + echo '<div class="blogpost">'; |
|
| 1018 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 1019 | + echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
| 1020 | + echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
| 1022 | 1021 | |
| 1023 | - $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
| 1022 | + $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
| 1024 | 1023 | |
| 1025 | 1024 | if (!empty($file_name_array)) { |
| 1026 | - echo ' <br />'; |
|
| 1027 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1028 | - echo '<a href="download.php?file='; |
|
| 1029 | - echo $file_name_array['path']; |
|
| 1030 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1031 | - echo '</span>'; |
|
| 1032 | - echo '<span class="attachment_comment">'; |
|
| 1033 | - echo $file_name_array['comment']; |
|
| 1034 | - echo '</span>'; |
|
| 1035 | - echo '<br />'; |
|
| 1036 | - } |
|
| 1025 | + echo ' <br />'; |
|
| 1026 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1027 | + echo '<a href="download.php?file='; |
|
| 1028 | + echo $file_name_array['path']; |
|
| 1029 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1030 | + echo '</span>'; |
|
| 1031 | + echo '<span class="attachment_comment">'; |
|
| 1032 | + echo $file_name_array['comment']; |
|
| 1033 | + echo '</span>'; |
|
| 1034 | + echo '<br />'; |
|
| 1035 | + } |
|
| 1037 | 1036 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 1038 | - echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
| 1039 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
| 1040 | - echo '</div>'; |
|
| 1041 | - |
|
| 1042 | - // Display comments if there are any |
|
| 1043 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
| 1044 | - echo '<div class="comments">'; |
|
| 1045 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
| 1046 | - Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
| 1047 | - echo '</div>'; |
|
| 1048 | - } |
|
| 1049 | - |
|
| 1050 | - // Display comment form |
|
| 1051 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
| 1052 | - Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - |
|
| 1056 | - /** |
|
| 1057 | - * Adds rating to a certain post or comment |
|
| 1058 | - * @author Toon Keppens |
|
| 1059 | - * |
|
| 1060 | - * @param String $type |
|
| 1061 | - * @param Integer $blog_id |
|
| 1062 | - * @param Integer $item_id |
|
| 1063 | - * @param Integer $rating |
|
| 1064 | - * |
|
| 1065 | - * @return Boolean success |
|
| 1066 | - */ |
|
| 1067 | - public static function add_rating($type, $blog_id, $item_id, $rating) |
|
| 1068 | - { |
|
| 1069 | - $_user = api_get_user_info(); |
|
| 1070 | - |
|
| 1071 | - // Init |
|
| 1072 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1073 | - $course_id = api_get_course_int_id(); |
|
| 1074 | - |
|
| 1075 | - // Check if the user has already rated this post/comment |
|
| 1076 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1037 | + echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
| 1038 | + echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
| 1039 | + echo '</div>'; |
|
| 1040 | + |
|
| 1041 | + // Display comments if there are any |
|
| 1042 | + if($blog_post_comments['number_of_comments'] > 0) { |
|
| 1043 | + echo '<div class="comments">'; |
|
| 1044 | + echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
| 1045 | + Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
| 1046 | + echo '</div>'; |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + // Display comment form |
|
| 1050 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
| 1051 | + Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
| 1052 | + } |
|
| 1053 | + } |
|
| 1054 | + |
|
| 1055 | + /** |
|
| 1056 | + * Adds rating to a certain post or comment |
|
| 1057 | + * @author Toon Keppens |
|
| 1058 | + * |
|
| 1059 | + * @param String $type |
|
| 1060 | + * @param Integer $blog_id |
|
| 1061 | + * @param Integer $item_id |
|
| 1062 | + * @param Integer $rating |
|
| 1063 | + * |
|
| 1064 | + * @return Boolean success |
|
| 1065 | + */ |
|
| 1066 | + public static function add_rating($type, $blog_id, $item_id, $rating) |
|
| 1067 | + { |
|
| 1068 | + $_user = api_get_user_info(); |
|
| 1069 | + |
|
| 1070 | + // Init |
|
| 1071 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1072 | + $course_id = api_get_course_int_id(); |
|
| 1073 | + |
|
| 1074 | + // Check if the user has already rated this post/comment |
|
| 1075 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1077 | 1076 | WHERE |
| 1078 | 1077 | c_id = $course_id AND |
| 1079 | 1078 | blog_id = '".(int)$blog_id."' AND |
| 1080 | 1079 | item_id = '".(int)$item_id."' AND |
| 1081 | 1080 | rating_type = '".Database::escape_string($type)."' AND |
| 1082 | 1081 | user_id = '".(int)$_user['user_id']."'"; |
| 1083 | - $result = Database::query($sql); |
|
| 1082 | + $result = Database::query($sql); |
|
| 1084 | 1083 | |
| 1085 | 1084 | // Add rating |
| 1086 | - if (Database::num_rows($result) == 0) { |
|
| 1087 | - $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
| 1085 | + if (Database::num_rows($result) == 0) { |
|
| 1086 | + $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
| 1088 | 1087 | VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
| 1089 | - Database::query($sql); |
|
| 1088 | + Database::query($sql); |
|
| 1090 | 1089 | |
| 1091 | 1090 | $id = Database::insert_id(); |
| 1092 | 1091 | if ($id) { |
@@ -1094,107 +1093,107 @@ discard block |
||
| 1094 | 1093 | Database::query($sql); |
| 1095 | 1094 | } |
| 1096 | 1095 | |
| 1097 | - return true; |
|
| 1096 | + return true; |
|
| 1098 | 1097 | } else { |
| 1099 | - return false; |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1102 | - |
|
| 1103 | - /** |
|
| 1104 | - * Shows the rating of user |
|
| 1105 | - * |
|
| 1106 | - * @param String $type |
|
| 1107 | - * @param Integer $blog_id |
|
| 1108 | - * @param Integer $item_id |
|
| 1109 | - * |
|
| 1110 | - * @return array() |
|
| 1111 | - */ |
|
| 1112 | - public static function display_rating($type, $blog_id, $item_id) |
|
| 1113 | - { |
|
| 1114 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1115 | - $course_id = api_get_course_int_id(); |
|
| 1116 | - |
|
| 1117 | - // Calculate rating |
|
| 1118 | - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
| 1098 | + return false; |
|
| 1099 | + } |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + /** |
|
| 1103 | + * Shows the rating of user |
|
| 1104 | + * |
|
| 1105 | + * @param String $type |
|
| 1106 | + * @param Integer $blog_id |
|
| 1107 | + * @param Integer $item_id |
|
| 1108 | + * |
|
| 1109 | + * @return array() |
|
| 1110 | + */ |
|
| 1111 | + public static function display_rating($type, $blog_id, $item_id) |
|
| 1112 | + { |
|
| 1113 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1114 | + $course_id = api_get_course_int_id(); |
|
| 1115 | + |
|
| 1116 | + // Calculate rating |
|
| 1117 | + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
| 1119 | 1118 | WHERE |
| 1120 | 1119 | c_id = $course_id AND |
| 1121 | 1120 | blog_id = '".(int)$blog_id."' AND |
| 1122 | 1121 | item_id = '".(int)$item_id."' AND |
| 1123 | 1122 | rating_type = '".Database::escape_string($type)."' "; |
| 1124 | - $result = Database::query($sql); |
|
| 1125 | - $result = Database::fetch_array($result); |
|
| 1126 | - return round($result['rating'], 2); |
|
| 1127 | - } |
|
| 1128 | - |
|
| 1129 | - /** |
|
| 1130 | - * Shows the rating form if not already rated by that user |
|
| 1131 | - * @author Toon Keppens |
|
| 1132 | - * |
|
| 1133 | - * @param String $type |
|
| 1134 | - * @param Integer $blog_id |
|
| 1135 | - * @param Integer $item_id |
|
| 1136 | - * |
|
| 1137 | - *@return String |
|
| 1138 | - */ |
|
| 1139 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1140 | - { |
|
| 1141 | - $_user = api_get_user_info(); |
|
| 1142 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1123 | + $result = Database::query($sql); |
|
| 1124 | + $result = Database::fetch_array($result); |
|
| 1125 | + return round($result['rating'], 2); |
|
| 1126 | + } |
|
| 1127 | + |
|
| 1128 | + /** |
|
| 1129 | + * Shows the rating form if not already rated by that user |
|
| 1130 | + * @author Toon Keppens |
|
| 1131 | + * |
|
| 1132 | + * @param String $type |
|
| 1133 | + * @param Integer $blog_id |
|
| 1134 | + * @param Integer $item_id |
|
| 1135 | + * |
|
| 1136 | + *@return String |
|
| 1137 | + */ |
|
| 1138 | + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1139 | + { |
|
| 1140 | + $_user = api_get_user_info(); |
|
| 1141 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
| 1143 | 1142 | $course_id = api_get_course_int_id(); |
| 1144 | 1143 | |
| 1145 | 1144 | if ($type == 'post') { |
| 1146 | - // Check if the user has already rated this post |
|
| 1147 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1145 | + // Check if the user has already rated this post |
|
| 1146 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1148 | 1147 | WHERE c_id = $course_id AND |
| 1149 | 1148 | blog_id = '".(int)$blog_id."' |
| 1150 | 1149 | AND item_id = '".(int)$post_id."' |
| 1151 | 1150 | AND rating_type = '".Database::escape_string($type)."' |
| 1152 | 1151 | AND user_id = '".(int)$_user['user_id']."'"; |
| 1153 | - $result = Database::query($sql); |
|
| 1152 | + $result = Database::query($sql); |
|
| 1154 | 1153 | // Add rating |
| 1155 | 1154 | if (Database::num_rows($result) == 0) { |
| 1156 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
| 1155 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
| 1157 | 1156 | } else { |
| 1158 | - return ''; |
|
| 1159 | - } |
|
| 1160 | - } |
|
| 1157 | + return ''; |
|
| 1158 | + } |
|
| 1159 | + } |
|
| 1161 | 1160 | |
| 1162 | 1161 | if ($type = 'comment') { |
| 1163 | - // Check if the user has already rated this comment |
|
| 1164 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1162 | + // Check if the user has already rated this comment |
|
| 1163 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
| 1165 | 1164 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
| 1166 | 1165 | AND item_id = '".(int)$comment_id."' |
| 1167 | 1166 | AND rating_type = '".Database::escape_string($type)."' |
| 1168 | 1167 | AND user_id = '".(int)$_user['user_id']."'"; |
| 1169 | - $result = Database::query($sql); |
|
| 1168 | + $result = Database::query($sql); |
|
| 1170 | 1169 | |
| 1171 | 1170 | if (Database::num_rows($result) == 0) { |
| 1172 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
| 1171 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
| 1173 | 1172 | } else { |
| 1174 | - return ''; |
|
| 1175 | - } |
|
| 1176 | - } |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - /** |
|
| 1180 | - * This functions gets all replys to a post, threaded. |
|
| 1181 | - * |
|
| 1182 | - * @param Integer $current |
|
| 1183 | - * @param Integer $current_level |
|
| 1184 | - * @param Integer $blog_id |
|
| 1185 | - * @param Integer $post_id |
|
| 1186 | - */ |
|
| 1187 | - public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
| 1188 | - { |
|
| 1189 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 1190 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1191 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1192 | - global $charset; |
|
| 1193 | - |
|
| 1194 | - $course_id = api_get_course_int_id(); |
|
| 1195 | - |
|
| 1196 | - // Select top level comments |
|
| 1197 | - $next_level = $current_level + 1; |
|
| 1173 | + return ''; |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + /** |
|
| 1179 | + * This functions gets all replys to a post, threaded. |
|
| 1180 | + * |
|
| 1181 | + * @param Integer $current |
|
| 1182 | + * @param Integer $current_level |
|
| 1183 | + * @param Integer $blog_id |
|
| 1184 | + * @param Integer $post_id |
|
| 1185 | + */ |
|
| 1186 | + public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
| 1187 | + { |
|
| 1188 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
| 1189 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1190 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1191 | + global $charset; |
|
| 1192 | + |
|
| 1193 | + $course_id = api_get_course_int_id(); |
|
| 1194 | + |
|
| 1195 | + // Select top level comments |
|
| 1196 | + $next_level = $current_level + 1; |
|
| 1198 | 1197 | $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color |
| 1199 | 1198 | FROM $tbl_blogs_comments comments |
| 1200 | 1199 | INNER JOIN $tbl_users user |
@@ -1206,11 +1205,11 @@ discard block |
||
| 1206 | 1205 | parent_comment_id = $current AND |
| 1207 | 1206 | comments.blog_id = '".(int)$blog_id."' AND |
| 1208 | 1207 | comments.post_id = '".(int)$post_id."'"; |
| 1209 | - $result = Database::query($sql); |
|
| 1208 | + $result = Database::query($sql); |
|
| 1210 | 1209 | |
| 1211 | - while($comment = Database::fetch_array($result)) { |
|
| 1212 | - // Select the children recursivly |
|
| 1213 | - $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
| 1210 | + while($comment = Database::fetch_array($result)) { |
|
| 1211 | + // Select the children recursivly |
|
| 1212 | + $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
| 1214 | 1213 | FROM $tbl_blogs_comments comments |
| 1215 | 1214 | INNER JOIN $tbl_users user |
| 1216 | 1215 | ON comments.author_id = user.user_id |
@@ -1219,15 +1218,15 @@ discard block |
||
| 1219 | 1218 | comment_id = $current |
| 1220 | 1219 | AND blog_id = '".(int)$blog_id."' |
| 1221 | 1220 | AND post_id = '".(int)$post_id."'"; |
| 1222 | - $tmp = Database::query($tmp); |
|
| 1223 | - $tmp = Database::fetch_array($tmp); |
|
| 1224 | - $parent_cat = $tmp['parent_comment_id']; |
|
| 1225 | - $border_color = ''; |
|
| 1226 | - |
|
| 1227 | - // Prepare data |
|
| 1228 | - $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
| 1229 | - $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
| 1230 | - $blog_comment_actions = ""; |
|
| 1221 | + $tmp = Database::query($tmp); |
|
| 1222 | + $tmp = Database::fetch_array($tmp); |
|
| 1223 | + $parent_cat = $tmp['parent_comment_id']; |
|
| 1224 | + $border_color = ''; |
|
| 1225 | + |
|
| 1226 | + // Prepare data |
|
| 1227 | + $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
| 1228 | + $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
| 1229 | + $blog_comment_actions = ""; |
|
| 1231 | 1230 | if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { |
| 1232 | 1231 | $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang( |
| 1233 | 1232 | 'DeleteThisComment' |
@@ -1242,92 +1241,92 @@ discard block |
||
| 1242 | 1241 | $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); |
| 1243 | 1242 | } |
| 1244 | 1243 | |
| 1245 | - if (!is_null($comment['task_id'])) { |
|
| 1246 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
| 1247 | - } |
|
| 1248 | - |
|
| 1249 | - $comment_text = stripslashes($comment_text); |
|
| 1250 | - |
|
| 1251 | - // Output... |
|
| 1252 | - $margin = $current_level * 30; |
|
| 1253 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
| 1254 | - echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
| 1255 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
| 1256 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
| 1257 | - |
|
| 1258 | - $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
| 1259 | - if (!empty($file_name_array)) { |
|
| 1260 | - echo '<br /><br />'; |
|
| 1261 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1262 | - echo '<a href="download.php?file='; |
|
| 1263 | - echo $file_name_array['path']; |
|
| 1264 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1265 | - echo '<span class="attachment_comment">'; |
|
| 1266 | - echo $file_name_array['comment']; |
|
| 1267 | - echo '</span><br />'; |
|
| 1268 | - } |
|
| 1244 | + if (!is_null($comment['task_id'])) { |
|
| 1245 | + $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
| 1246 | + } |
|
| 1247 | + |
|
| 1248 | + $comment_text = stripslashes($comment_text); |
|
| 1249 | + |
|
| 1250 | + // Output... |
|
| 1251 | + $margin = $current_level * 30; |
|
| 1252 | + echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
| 1253 | + echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
| 1254 | + echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
| 1255 | + echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
| 1256 | + |
|
| 1257 | + $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
| 1258 | + if (!empty($file_name_array)) { |
|
| 1259 | + echo '<br /><br />'; |
|
| 1260 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1261 | + echo '<a href="download.php?file='; |
|
| 1262 | + echo $file_name_array['path']; |
|
| 1263 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
| 1264 | + echo '<span class="attachment_comment">'; |
|
| 1265 | + echo $file_name_array['comment']; |
|
| 1266 | + echo '</span><br />'; |
|
| 1267 | + } |
|
| 1269 | 1268 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
| 1270 | - echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
| 1271 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
| 1272 | - echo '</div>'; |
|
| 1273 | - |
|
| 1274 | - // Go further down the tree. |
|
| 1275 | - Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
| 1276 | - } |
|
| 1277 | - } |
|
| 1278 | - |
|
| 1279 | - /** |
|
| 1280 | - * Displays the form to create a new post |
|
| 1281 | - * @author Toon Keppens |
|
| 1282 | - * |
|
| 1283 | - * @param Integer $blog_id |
|
| 1284 | - */ |
|
| 1285 | - public static function display_form_new_post($blog_id) |
|
| 1286 | - { |
|
| 1287 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1288 | - $form = new FormValidator( |
|
| 1289 | - 'add_post', |
|
| 1290 | - 'post', |
|
| 1291 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
| 1292 | - null, |
|
| 1293 | - array('enctype' => 'multipart/form-data') |
|
| 1294 | - ); |
|
| 1295 | - $form->addHidden('post_title_edited', 'false'); |
|
| 1296 | - $form->addHeader(get_lang('NewPost')); |
|
| 1297 | - $form->addText('title', get_lang('Title')); |
|
| 1298 | - $config = array(); |
|
| 1299 | - if (!api_is_allowed_to_edit()) { |
|
| 1300 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1301 | - } else { |
|
| 1302 | - $config['ToolbarSet'] = 'Project'; |
|
| 1303 | - } |
|
| 1304 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1305 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 1306 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 1307 | - $form->addHidden('new_post_submit', 'true'); |
|
| 1308 | - $form->addButton('save', get_lang('Save')); |
|
| 1309 | - |
|
| 1310 | - $form->display(); |
|
| 1311 | - } else { |
|
| 1312 | - api_not_allowed(); |
|
| 1313 | - } |
|
| 1314 | - } |
|
| 1315 | - |
|
| 1316 | - /** |
|
| 1317 | - * Displays the form to edit a post |
|
| 1318 | - * @author Toon Keppens |
|
| 1319 | - * |
|
| 1320 | - * @param Integer $blog_id |
|
| 1321 | - */ |
|
| 1322 | - public static function display_form_edit_post($blog_id, $post_id) |
|
| 1323 | - { |
|
| 1324 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1325 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1326 | - |
|
| 1327 | - $course_id = api_get_course_int_id(); |
|
| 1328 | - |
|
| 1329 | - // Get posts and author |
|
| 1330 | - $sql = "SELECT post.*, user.lastname, user.firstname |
|
| 1269 | + echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
| 1270 | + echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
| 1271 | + echo '</div>'; |
|
| 1272 | + |
|
| 1273 | + // Go further down the tree. |
|
| 1274 | + Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
| 1275 | + } |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + /** |
|
| 1279 | + * Displays the form to create a new post |
|
| 1280 | + * @author Toon Keppens |
|
| 1281 | + * |
|
| 1282 | + * @param Integer $blog_id |
|
| 1283 | + */ |
|
| 1284 | + public static function display_form_new_post($blog_id) |
|
| 1285 | + { |
|
| 1286 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1287 | + $form = new FormValidator( |
|
| 1288 | + 'add_post', |
|
| 1289 | + 'post', |
|
| 1290 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
| 1291 | + null, |
|
| 1292 | + array('enctype' => 'multipart/form-data') |
|
| 1293 | + ); |
|
| 1294 | + $form->addHidden('post_title_edited', 'false'); |
|
| 1295 | + $form->addHeader(get_lang('NewPost')); |
|
| 1296 | + $form->addText('title', get_lang('Title')); |
|
| 1297 | + $config = array(); |
|
| 1298 | + if (!api_is_allowed_to_edit()) { |
|
| 1299 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1300 | + } else { |
|
| 1301 | + $config['ToolbarSet'] = 'Project'; |
|
| 1302 | + } |
|
| 1303 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1304 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 1305 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 1306 | + $form->addHidden('new_post_submit', 'true'); |
|
| 1307 | + $form->addButton('save', get_lang('Save')); |
|
| 1308 | + |
|
| 1309 | + $form->display(); |
|
| 1310 | + } else { |
|
| 1311 | + api_not_allowed(); |
|
| 1312 | + } |
|
| 1313 | + } |
|
| 1314 | + |
|
| 1315 | + /** |
|
| 1316 | + * Displays the form to edit a post |
|
| 1317 | + * @author Toon Keppens |
|
| 1318 | + * |
|
| 1319 | + * @param Integer $blog_id |
|
| 1320 | + */ |
|
| 1321 | + public static function display_form_edit_post($blog_id, $post_id) |
|
| 1322 | + { |
|
| 1323 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1324 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1325 | + |
|
| 1326 | + $course_id = api_get_course_int_id(); |
|
| 1327 | + |
|
| 1328 | + // Get posts and author |
|
| 1329 | + $sql = "SELECT post.*, user.lastname, user.firstname |
|
| 1331 | 1330 | FROM $tbl_blogs_posts post |
| 1332 | 1331 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1333 | 1332 | WHERE |
@@ -1335,74 +1334,74 @@ discard block |
||
| 1335 | 1334 | post.blog_id = '".(int)$blog_id ."' |
| 1336 | 1335 | AND post.post_id = '".(int)$post_id."' |
| 1337 | 1336 | ORDER BY post_id DESC"; |
| 1338 | - $result = Database::query($sql); |
|
| 1339 | - $blog_post = Database::fetch_array($result); |
|
| 1340 | - |
|
| 1341 | - // Form |
|
| 1342 | - $form = new FormValidator( |
|
| 1343 | - 'edit_post', |
|
| 1344 | - 'post', |
|
| 1345 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1346 | - ); |
|
| 1347 | - |
|
| 1348 | - $form->addHeader(get_lang('EditPost')); |
|
| 1349 | - $form->addText('title', get_lang('Title')); |
|
| 1350 | - |
|
| 1351 | - if (!api_is_allowed_to_edit()) { |
|
| 1352 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1353 | - } else { |
|
| 1354 | - $config['ToolbarSet'] = 'Project'; |
|
| 1355 | - } |
|
| 1356 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1357 | - |
|
| 1358 | - $form->addHidden('action', ''); |
|
| 1359 | - $form->addHidden('edit_post_submit', 'true'); |
|
| 1360 | - $form->addHidden('post_id', intval($_GET['post_id'])); |
|
| 1361 | - $form->addButton('save', get_lang('Save')); |
|
| 1362 | - $form->setDefaults($blog_post); |
|
| 1363 | - $form->display(); |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - /** |
|
| 1367 | - * Displays a list of tasks in this blog |
|
| 1368 | - * @author Toon Keppens |
|
| 1369 | - * |
|
| 1370 | - * @param Integer $blog_id |
|
| 1371 | - */ |
|
| 1372 | - public static function display_task_list($blog_id) |
|
| 1337 | + $result = Database::query($sql); |
|
| 1338 | + $blog_post = Database::fetch_array($result); |
|
| 1339 | + |
|
| 1340 | + // Form |
|
| 1341 | + $form = new FormValidator( |
|
| 1342 | + 'edit_post', |
|
| 1343 | + 'post', |
|
| 1344 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1345 | + ); |
|
| 1346 | + |
|
| 1347 | + $form->addHeader(get_lang('EditPost')); |
|
| 1348 | + $form->addText('title', get_lang('Title')); |
|
| 1349 | + |
|
| 1350 | + if (!api_is_allowed_to_edit()) { |
|
| 1351 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
| 1352 | + } else { |
|
| 1353 | + $config['ToolbarSet'] = 'Project'; |
|
| 1354 | + } |
|
| 1355 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
| 1356 | + |
|
| 1357 | + $form->addHidden('action', ''); |
|
| 1358 | + $form->addHidden('edit_post_submit', 'true'); |
|
| 1359 | + $form->addHidden('post_id', intval($_GET['post_id'])); |
|
| 1360 | + $form->addButton('save', get_lang('Save')); |
|
| 1361 | + $form->setDefaults($blog_post); |
|
| 1362 | + $form->display(); |
|
| 1363 | + } |
|
| 1364 | + |
|
| 1365 | + /** |
|
| 1366 | + * Displays a list of tasks in this blog |
|
| 1367 | + * @author Toon Keppens |
|
| 1368 | + * |
|
| 1369 | + * @param Integer $blog_id |
|
| 1370 | + */ |
|
| 1371 | + public static function display_task_list($blog_id) |
|
| 1373 | 1372 | { |
| 1374 | - global $charset; |
|
| 1373 | + global $charset; |
|
| 1375 | 1374 | $course_id = api_get_course_int_id(); |
| 1376 | 1375 | |
| 1377 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1378 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1379 | - $counter = 0; |
|
| 1380 | - global $color2; |
|
| 1376 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1377 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1378 | + $counter = 0; |
|
| 1379 | + global $color2; |
|
| 1381 | 1380 | |
| 1382 | - echo '<div class="actions">'; |
|
| 1383 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
| 1381 | + echo '<div class="actions">'; |
|
| 1382 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
| 1384 | 1383 | echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks')); |
| 1385 | 1384 | echo get_lang('AddTasks') . '</a> '; |
| 1386 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
| 1385 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
| 1387 | 1386 | echo Display::return_icon('blog_task.gif', get_lang('AssignTasks')); |
| 1388 | 1387 | echo get_lang('AssignTasks') . '</a>'; |
| 1389 | - ?> |
|
| 1388 | + ?> |
|
| 1390 | 1389 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"> |
| 1391 | 1390 | <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
| 1392 | 1391 | <?php |
| 1393 | - echo '</div>'; |
|
| 1392 | + echo '</div>'; |
|
| 1394 | 1393 | |
| 1395 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
| 1396 | - echo "<table class=\"data_table\">"; |
|
| 1397 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1398 | - "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
| 1399 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
| 1400 | - "<th><b>",get_lang('Color'),"</b></th>\n", |
|
| 1401 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
| 1402 | - "</tr>\n"; |
|
| 1394 | + echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
| 1395 | + echo "<table class=\"data_table\">"; |
|
| 1396 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1397 | + "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
| 1398 | + "<th><b>",get_lang('Description'),"</b></th>\n", |
|
| 1399 | + "<th><b>",get_lang('Color'),"</b></th>\n", |
|
| 1400 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
| 1401 | + "</tr>\n"; |
|
| 1403 | 1402 | |
| 1404 | 1403 | |
| 1405 | - $sql = " SELECT |
|
| 1404 | + $sql = " SELECT |
|
| 1406 | 1405 | blog_id, |
| 1407 | 1406 | task_id, |
| 1408 | 1407 | blog_id, |
@@ -1413,22 +1412,22 @@ discard block |
||
| 1413 | 1412 | FROM " . $tbl_blogs_tasks . " |
| 1414 | 1413 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
| 1415 | 1414 | ORDER BY system_task, title"; |
| 1416 | - $result = Database::query($sql); |
|
| 1417 | - |
|
| 1418 | - |
|
| 1419 | - while($task = Database::fetch_array($result)) { |
|
| 1420 | - $counter++; |
|
| 1421 | - $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
| 1422 | - $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
| 1423 | - $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1424 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
| 1425 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1426 | - |
|
| 1427 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
| 1428 | - '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
| 1429 | - '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
| 1430 | - '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
| 1431 | - '<td width="50">', |
|
| 1415 | + $result = Database::query($sql); |
|
| 1416 | + |
|
| 1417 | + |
|
| 1418 | + while($task = Database::fetch_array($result)) { |
|
| 1419 | + $counter++; |
|
| 1420 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
| 1421 | + $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
| 1422 | + $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1423 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
| 1424 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1425 | + |
|
| 1426 | + echo '<tr class="' . $css_class . '" valign="top">', |
|
| 1427 | + '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
| 1428 | + '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
| 1429 | + '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
| 1430 | + '<td width="50">', |
|
| 1432 | 1431 | '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
| 1433 | 1432 | '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
| 1434 | 1433 | "</a>\n", |
@@ -1436,41 +1435,41 @@ discard block |
||
| 1436 | 1435 | $delete_confirm, |
| 1437 | 1436 | '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
| 1438 | 1437 | "</a>\n", |
| 1439 | - '</td>', |
|
| 1438 | + '</td>', |
|
| 1440 | 1439 | '</tr>'; |
| 1441 | - } |
|
| 1442 | - echo "</table>"; |
|
| 1443 | - } |
|
| 1444 | - } |
|
| 1445 | - |
|
| 1446 | - /** |
|
| 1447 | - * Displays a list of tasks assigned to a user in this blog |
|
| 1448 | - * @author Toon Keppens |
|
| 1449 | - * |
|
| 1450 | - * @param Integer $blog_id |
|
| 1451 | - */ |
|
| 1452 | - public static function display_assigned_task_list ($blog_id) |
|
| 1440 | + } |
|
| 1441 | + echo "</table>"; |
|
| 1442 | + } |
|
| 1443 | + } |
|
| 1444 | + |
|
| 1445 | + /** |
|
| 1446 | + * Displays a list of tasks assigned to a user in this blog |
|
| 1447 | + * @author Toon Keppens |
|
| 1448 | + * |
|
| 1449 | + * @param Integer $blog_id |
|
| 1450 | + */ |
|
| 1451 | + public static function display_assigned_task_list ($blog_id) |
|
| 1453 | 1452 | { |
| 1454 | - // Init |
|
| 1455 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1456 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1457 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1458 | - $counter = 0; |
|
| 1459 | - global $charset,$color2; |
|
| 1460 | - |
|
| 1461 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
| 1462 | - echo "<table class=\"data_table\">"; |
|
| 1463 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1464 | - "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
| 1465 | - "<th><b>",get_lang('Task'),"</b></th>\n", |
|
| 1466 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
| 1467 | - "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
| 1468 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
| 1469 | - "</tr>"; |
|
| 1470 | - |
|
| 1471 | - $course_id = api_get_course_int_id(); |
|
| 1472 | - |
|
| 1473 | - $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
| 1453 | + // Init |
|
| 1454 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1455 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1456 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1457 | + $counter = 0; |
|
| 1458 | + global $charset,$color2; |
|
| 1459 | + |
|
| 1460 | + echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
| 1461 | + echo "<table class=\"data_table\">"; |
|
| 1462 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
| 1463 | + "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
| 1464 | + "<th><b>",get_lang('Task'),"</b></th>\n", |
|
| 1465 | + "<th><b>",get_lang('Description'),"</b></th>\n", |
|
| 1466 | + "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
| 1467 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
| 1468 | + "</tr>"; |
|
| 1469 | + |
|
| 1470 | + $course_id = api_get_course_int_id(); |
|
| 1471 | + |
|
| 1472 | + $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
| 1474 | 1473 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
| 1475 | 1474 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
| 1476 | 1475 | INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id |
@@ -1479,45 +1478,45 @@ discard block |
||
| 1479 | 1478 | task.c_id = $course_id AND |
| 1480 | 1479 | task_rel_user.blog_id = '".(int)$blog_id."' |
| 1481 | 1480 | ORDER BY target_date ASC"; |
| 1482 | - $result = Database::query($sql); |
|
| 1481 | + $result = Database::query($sql); |
|
| 1483 | 1482 | |
| 1484 | - while ($assignment = Database::fetch_array($result)) { |
|
| 1485 | - $counter++; |
|
| 1486 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
| 1487 | - $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
| 1488 | - $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1489 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
| 1490 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1483 | + while ($assignment = Database::fetch_array($result)) { |
|
| 1484 | + $counter++; |
|
| 1485 | + $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
| 1486 | + $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
|
| 1487 | + $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
| 1488 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
| 1489 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1491 | 1490 | |
| 1492 | 1491 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
| 1493 | 1492 | |
| 1494 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
| 1495 | - '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
| 1496 | - '<td>'.stripslashes($assignment['title']) . '</td>', |
|
| 1497 | - '<td>'.stripslashes($assignment['description']) . '</td>', |
|
| 1498 | - '<td>' . $assignment['target_date'] . '</td>', |
|
| 1499 | - '<td width="50">', |
|
| 1500 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', |
|
| 1501 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
| 1502 | - "</a>\n", |
|
| 1503 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', |
|
| 1504 | - 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
| 1505 | - '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
| 1506 | - "</a>\n", |
|
| 1507 | - '</td>', |
|
| 1508 | - '</tr>'; |
|
| 1509 | - } |
|
| 1510 | - echo "</table>"; |
|
| 1511 | - } |
|
| 1512 | - |
|
| 1513 | - /** |
|
| 1514 | - * Displays new task form |
|
| 1515 | - * @author Toon Keppens |
|
| 1516 | - * |
|
| 1517 | - */ |
|
| 1518 | - public static function display_new_task_form ($blog_id) |
|
| 1519 | - { |
|
| 1520 | - // Init |
|
| 1493 | + echo '<tr class="' . $css_class . '" valign="top">', |
|
| 1494 | + '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
| 1495 | + '<td>'.stripslashes($assignment['title']) . '</td>', |
|
| 1496 | + '<td>'.stripslashes($assignment['description']) . '</td>', |
|
| 1497 | + '<td>' . $assignment['target_date'] . '</td>', |
|
| 1498 | + '<td width="50">', |
|
| 1499 | + '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', |
|
| 1500 | + '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
| 1501 | + "</a>\n", |
|
| 1502 | + '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', |
|
| 1503 | + 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
| 1504 | + '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
| 1505 | + "</a>\n", |
|
| 1506 | + '</td>', |
|
| 1507 | + '</tr>'; |
|
| 1508 | + } |
|
| 1509 | + echo "</table>"; |
|
| 1510 | + } |
|
| 1511 | + |
|
| 1512 | + /** |
|
| 1513 | + * Displays new task form |
|
| 1514 | + * @author Toon Keppens |
|
| 1515 | + * |
|
| 1516 | + */ |
|
| 1517 | + public static function display_new_task_form ($blog_id) |
|
| 1518 | + { |
|
| 1519 | + // Init |
|
| 1521 | 1520 | $colors = array( |
| 1522 | 1521 | 'FFFFFF', |
| 1523 | 1522 | 'FFFF99', |
@@ -1536,14 +1535,14 @@ discard block |
||
| 1536 | 1535 | '000000' |
| 1537 | 1536 | ); |
| 1538 | 1537 | |
| 1539 | - // form |
|
| 1540 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
| 1538 | + // form |
|
| 1539 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
| 1541 | 1540 | |
| 1542 | - // form title |
|
| 1543 | - echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
| 1541 | + // form title |
|
| 1542 | + echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
| 1544 | 1543 | |
| 1545 | - // task title |
|
| 1546 | - echo ' <div class="control-group"> |
|
| 1544 | + // task title |
|
| 1545 | + echo ' <div class="control-group"> |
|
| 1547 | 1546 | <label class="control-label"> |
| 1548 | 1547 | <span class="form_required">*</span>' . get_lang('Title') . ' |
| 1549 | 1548 | </label> |
@@ -1552,8 +1551,8 @@ discard block |
||
| 1552 | 1551 | </div> |
| 1553 | 1552 | </div>'; |
| 1554 | 1553 | |
| 1555 | - // task comment |
|
| 1556 | - echo ' <div class="control-group"> |
|
| 1554 | + // task comment |
|
| 1555 | + echo ' <div class="control-group"> |
|
| 1557 | 1556 | <label class="control-label"> |
| 1558 | 1557 | ' . get_lang('Description') . ' |
| 1559 | 1558 | </label> |
@@ -1562,8 +1561,8 @@ discard block |
||
| 1562 | 1561 | </div> |
| 1563 | 1562 | </div>'; |
| 1564 | 1563 | |
| 1565 | - // task management |
|
| 1566 | - echo ' <div class="control-group"> |
|
| 1564 | + // task management |
|
| 1565 | + echo ' <div class="control-group"> |
|
| 1567 | 1566 | <label class="control-label"> |
| 1568 | 1567 | ' . get_lang('TaskManager') . ' |
| 1569 | 1568 | </label> |
@@ -1584,12 +1583,12 @@ discard block |
||
| 1584 | 1583 | echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
| 1585 | 1584 | echo '</tr>'; |
| 1586 | 1585 | echo '</table>'; |
| 1587 | - echo ' </div> |
|
| 1586 | + echo ' </div> |
|
| 1588 | 1587 | </div>'; |
| 1589 | 1588 | |
| 1590 | 1589 | |
| 1591 | - // task color |
|
| 1592 | - echo ' <div class="control-group"> |
|
| 1590 | + // task color |
|
| 1591 | + echo ' <div class="control-group"> |
|
| 1593 | 1592 | <label class="control-label"> |
| 1594 | 1593 | ' . get_lang('Color') . ' |
| 1595 | 1594 | </label> |
@@ -1600,40 +1599,40 @@ discard block |
||
| 1600 | 1599 | echo '<option value="' . $color . '" ' . $style . '> </option>'; |
| 1601 | 1600 | } |
| 1602 | 1601 | echo '</select>'; |
| 1603 | - echo ' </div> |
|
| 1602 | + echo ' </div> |
|
| 1604 | 1603 | </div>'; |
| 1605 | 1604 | |
| 1606 | - // submit |
|
| 1607 | - echo ' <div class="control-group"> |
|
| 1605 | + // submit |
|
| 1606 | + echo ' <div class="control-group"> |
|
| 1608 | 1607 | <div class="controls"> |
| 1609 | 1608 | <input type="hidden" name="action" value="" /> |
| 1610 | 1609 | <input type="hidden" name="new_task_submit" value="true" /> |
| 1611 | 1610 | <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
| 1612 | 1611 | </div> |
| 1613 | 1612 | </div>'; |
| 1614 | - echo '</form>'; |
|
| 1613 | + echo '</form>'; |
|
| 1615 | 1614 | |
| 1616 | - echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
| 1617 | - } |
|
| 1615 | + echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
| 1616 | + } |
|
| 1618 | 1617 | |
| 1619 | 1618 | |
| 1620 | - /** |
|
| 1621 | - * Displays edit task form |
|
| 1622 | - * @author Toon Keppens |
|
| 1623 | - * |
|
| 1624 | - */ |
|
| 1625 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
| 1626 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1619 | + /** |
|
| 1620 | + * Displays edit task form |
|
| 1621 | + * @author Toon Keppens |
|
| 1622 | + * |
|
| 1623 | + */ |
|
| 1624 | + public static function display_edit_task_form ($blog_id, $task_id) { |
|
| 1625 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1627 | 1626 | $course_id = api_get_course_int_id(); |
| 1628 | 1627 | |
| 1629 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
| 1628 | + $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
| 1630 | 1629 | |
| 1631 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
| 1632 | - $result = Database::query($sql); |
|
| 1633 | - $task = Database::fetch_array($result); |
|
| 1630 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
| 1631 | + $result = Database::query($sql); |
|
| 1632 | + $task = Database::fetch_array($result); |
|
| 1634 | 1633 | |
| 1635 | - // Display |
|
| 1636 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
| 1634 | + // Display |
|
| 1635 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
| 1637 | 1636 | <legend>' . get_lang('EditTask') . '</legend> |
| 1638 | 1637 | <table width="100%" border="0" cellspacing="2"> |
| 1639 | 1638 | <tr> |
@@ -1645,42 +1644,42 @@ discard block |
||
| 1645 | 1644 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
| 1646 | 1645 | </tr>'; |
| 1647 | 1646 | |
| 1648 | - /* edit by Kevin Van Den Haute ([email protected]) */ |
|
| 1649 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 1647 | + /* edit by Kevin Van Den Haute ([email protected]) */ |
|
| 1648 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
| 1650 | 1649 | |
| 1651 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
| 1650 | + $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
| 1652 | 1651 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
| 1653 | - $result = Database::query($sql); |
|
| 1654 | - |
|
| 1655 | - $arrPermissions = array(); |
|
| 1656 | - |
|
| 1657 | - while ($row = Database::fetch_array($result)) |
|
| 1658 | - $arrPermissions[] = $row['action']; |
|
| 1659 | - |
|
| 1660 | - echo '<tr>'; |
|
| 1661 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
| 1662 | - echo '<td>'; |
|
| 1663 | - echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
| 1664 | - echo '<tr>'; |
|
| 1665 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1666 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1667 | - echo '</tr>'; |
|
| 1668 | - echo '<tr>'; |
|
| 1669 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1670 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1671 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1672 | - echo '</tr>'; |
|
| 1673 | - echo '<tr>'; |
|
| 1674 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1675 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1676 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1677 | - echo '</tr>'; |
|
| 1678 | - echo '</table>'; |
|
| 1679 | - echo '</td>'; |
|
| 1680 | - echo '</tr>'; |
|
| 1681 | - /* end of edit */ |
|
| 1682 | - |
|
| 1683 | - echo '<tr> |
|
| 1652 | + $result = Database::query($sql); |
|
| 1653 | + |
|
| 1654 | + $arrPermissions = array(); |
|
| 1655 | + |
|
| 1656 | + while ($row = Database::fetch_array($result)) |
|
| 1657 | + $arrPermissions[] = $row['action']; |
|
| 1658 | + |
|
| 1659 | + echo '<tr>'; |
|
| 1660 | + echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
| 1661 | + echo '<td>'; |
|
| 1662 | + echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
| 1663 | + echo '<tr>'; |
|
| 1664 | + echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1665 | + echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1666 | + echo '</tr>'; |
|
| 1667 | + echo '<tr>'; |
|
| 1668 | + echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1669 | + echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1670 | + echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1671 | + echo '</tr>'; |
|
| 1672 | + echo '<tr>'; |
|
| 1673 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1674 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1675 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1676 | + echo '</tr>'; |
|
| 1677 | + echo '</table>'; |
|
| 1678 | + echo '</td>'; |
|
| 1679 | + echo '</tr>'; |
|
| 1680 | + /* end of edit */ |
|
| 1681 | + |
|
| 1682 | + echo '<tr> |
|
| 1684 | 1683 | <td align="right">' . get_lang('Color') . ': </td> |
| 1685 | 1684 | <td> |
| 1686 | 1685 | <select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
@@ -1689,7 +1688,7 @@ discard block |
||
| 1689 | 1688 | $style = 'style="background-color: #' . $color . '"'; |
| 1690 | 1689 | echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
| 1691 | 1690 | } |
| 1692 | - echo ' </select> |
|
| 1691 | + echo ' </select> |
|
| 1693 | 1692 | </td> |
| 1694 | 1693 | </tr> |
| 1695 | 1694 | <tr> |
@@ -1702,34 +1701,34 @@ discard block |
||
| 1702 | 1701 | </tr> |
| 1703 | 1702 | </table> |
| 1704 | 1703 | </form>'; |
| 1705 | - } |
|
| 1706 | - |
|
| 1707 | - /** |
|
| 1708 | - * @param $blog_id |
|
| 1709 | - * @return FormValidator |
|
| 1710 | - */ |
|
| 1711 | - public static function getTaskForm($blog_id) |
|
| 1712 | - { |
|
| 1713 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1714 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1715 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1716 | - $course_id = api_get_course_int_id(); |
|
| 1717 | - |
|
| 1718 | - // Get users in this blog / make select list of it |
|
| 1719 | - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
| 1704 | + } |
|
| 1705 | + |
|
| 1706 | + /** |
|
| 1707 | + * @param $blog_id |
|
| 1708 | + * @return FormValidator |
|
| 1709 | + */ |
|
| 1710 | + public static function getTaskForm($blog_id) |
|
| 1711 | + { |
|
| 1712 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1713 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1714 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1715 | + $course_id = api_get_course_int_id(); |
|
| 1716 | + |
|
| 1717 | + // Get users in this blog / make select list of it |
|
| 1718 | + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
| 1720 | 1719 | FROM $tbl_users user |
| 1721 | 1720 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 1722 | 1721 | ON user.user_id = blogs_rel_user.user_id |
| 1723 | 1722 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
| 1724 | - $result = Database::query($sql); |
|
| 1723 | + $result = Database::query($sql); |
|
| 1725 | 1724 | |
| 1726 | - $options = array(); |
|
| 1727 | - while ($user = Database::fetch_array($result)) { |
|
| 1728 | - $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
| 1729 | - } |
|
| 1725 | + $options = array(); |
|
| 1726 | + while ($user = Database::fetch_array($result)) { |
|
| 1727 | + $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
| 1728 | + } |
|
| 1730 | 1729 | |
| 1731 | - // Get tasks in this blog / make select list of it |
|
| 1732 | - $sql = " |
|
| 1730 | + // Get tasks in this blog / make select list of it |
|
| 1731 | + $sql = " |
|
| 1733 | 1732 | SELECT |
| 1734 | 1733 | blog_id, |
| 1735 | 1734 | task_id, |
@@ -1741,97 +1740,97 @@ discard block |
||
| 1741 | 1740 | FROM $tbl_blogs_tasks |
| 1742 | 1741 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
| 1743 | 1742 | ORDER BY system_task, title"; |
| 1744 | - $result = Database::query($sql); |
|
| 1745 | - |
|
| 1746 | - $taskOptions = array(); |
|
| 1747 | - while ($task = Database::fetch_array($result)) { |
|
| 1748 | - $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
| 1749 | - } |
|
| 1750 | - |
|
| 1751 | - $form = new FormValidator( |
|
| 1752 | - 'assign_task', |
|
| 1753 | - 'post', |
|
| 1754 | - api_get_path( |
|
| 1755 | - WEB_CODE_PATH |
|
| 1756 | - ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
| 1757 | - ); |
|
| 1758 | - |
|
| 1759 | - $form->addHeader(get_lang('AssignTask')); |
|
| 1760 | - $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
| 1761 | - $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
| 1762 | - $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
| 1763 | - |
|
| 1764 | - $form->addHidden('action', ''); |
|
| 1765 | - $form->addButtonSave(get_lang('Ok')); |
|
| 1766 | - |
|
| 1767 | - return $form; |
|
| 1768 | - } |
|
| 1769 | - |
|
| 1770 | - /** |
|
| 1771 | - * Displays assign task form |
|
| 1772 | - * @author Toon Keppens |
|
| 1773 | - * |
|
| 1774 | - */ |
|
| 1775 | - public static function display_assign_task_form($blog_id) |
|
| 1776 | - { |
|
| 1777 | - $form = self::getTaskForm($blog_id); |
|
| 1778 | - $form->addHidden('assign_task_submit', 'true'); |
|
| 1779 | - $form->display(); |
|
| 1780 | - echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - /** |
|
| 1784 | - * Displays assign task form |
|
| 1785 | - * @author Toon Keppens |
|
| 1786 | - * |
|
| 1787 | - */ |
|
| 1788 | - public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
| 1789 | - { |
|
| 1790 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1791 | - |
|
| 1792 | - $course_id = api_get_course_int_id(); |
|
| 1793 | - |
|
| 1794 | - // Get assignd date; |
|
| 1795 | - $sql = " |
|
| 1743 | + $result = Database::query($sql); |
|
| 1744 | + |
|
| 1745 | + $taskOptions = array(); |
|
| 1746 | + while ($task = Database::fetch_array($result)) { |
|
| 1747 | + $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
| 1748 | + } |
|
| 1749 | + |
|
| 1750 | + $form = new FormValidator( |
|
| 1751 | + 'assign_task', |
|
| 1752 | + 'post', |
|
| 1753 | + api_get_path( |
|
| 1754 | + WEB_CODE_PATH |
|
| 1755 | + ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
| 1756 | + ); |
|
| 1757 | + |
|
| 1758 | + $form->addHeader(get_lang('AssignTask')); |
|
| 1759 | + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
| 1760 | + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
| 1761 | + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
| 1762 | + |
|
| 1763 | + $form->addHidden('action', ''); |
|
| 1764 | + $form->addButtonSave(get_lang('Ok')); |
|
| 1765 | + |
|
| 1766 | + return $form; |
|
| 1767 | + } |
|
| 1768 | + |
|
| 1769 | + /** |
|
| 1770 | + * Displays assign task form |
|
| 1771 | + * @author Toon Keppens |
|
| 1772 | + * |
|
| 1773 | + */ |
|
| 1774 | + public static function display_assign_task_form($blog_id) |
|
| 1775 | + { |
|
| 1776 | + $form = self::getTaskForm($blog_id); |
|
| 1777 | + $form->addHidden('assign_task_submit', 'true'); |
|
| 1778 | + $form->display(); |
|
| 1779 | + echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
| 1780 | + } |
|
| 1781 | + |
|
| 1782 | + /** |
|
| 1783 | + * Displays assign task form |
|
| 1784 | + * @author Toon Keppens |
|
| 1785 | + * |
|
| 1786 | + */ |
|
| 1787 | + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
| 1788 | + { |
|
| 1789 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1790 | + |
|
| 1791 | + $course_id = api_get_course_int_id(); |
|
| 1792 | + |
|
| 1793 | + // Get assignd date; |
|
| 1794 | + $sql = " |
|
| 1796 | 1795 | SELECT target_date |
| 1797 | 1796 | FROM $tbl_blogs_tasks_rel_user |
| 1798 | 1797 | WHERE c_id = $course_id AND |
| 1799 | 1798 | blog_id = '".(int)$blog_id."' AND |
| 1800 | 1799 | user_id = '".(int)$user_id."' AND |
| 1801 | 1800 | task_id = '".(int)$task_id."'"; |
| 1802 | - $result = Database::query($sql); |
|
| 1803 | - $row = Database::fetch_assoc($result); |
|
| 1804 | - |
|
| 1805 | - $date = $row['target_date']; |
|
| 1806 | - |
|
| 1807 | - $defaults = [ |
|
| 1808 | - 'task_user_id' => $user_id, |
|
| 1809 | - 'task_task_id' => $task_id, |
|
| 1810 | - 'task_day' => $date |
|
| 1811 | - ]; |
|
| 1812 | - $form = self::getTaskForm($blog_id); |
|
| 1813 | - $form->addHidden('old_task_id', $task_id); |
|
| 1814 | - $form->addHidden('old_user_id', $user_id); |
|
| 1815 | - $form->addHidden('old_target_date', $date); |
|
| 1816 | - $form->addHidden('assign_task_edit_submit', 'true'); |
|
| 1817 | - $form->setDefaults($defaults); |
|
| 1818 | - $form->display(); |
|
| 1819 | - } |
|
| 1820 | - |
|
| 1821 | - /** |
|
| 1822 | - * Assigns a task to a user in a blog |
|
| 1823 | - * |
|
| 1824 | - * @param Integer $blog_id |
|
| 1825 | - * @param Integer $user_id |
|
| 1826 | - * @param Integer $task_id |
|
| 1827 | - * @param Date $target_date |
|
| 1828 | - */ |
|
| 1829 | - public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
| 1830 | - { |
|
| 1831 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1832 | - $course_id = api_get_course_int_id(); |
|
| 1833 | - |
|
| 1834 | - $sql = " |
|
| 1801 | + $result = Database::query($sql); |
|
| 1802 | + $row = Database::fetch_assoc($result); |
|
| 1803 | + |
|
| 1804 | + $date = $row['target_date']; |
|
| 1805 | + |
|
| 1806 | + $defaults = [ |
|
| 1807 | + 'task_user_id' => $user_id, |
|
| 1808 | + 'task_task_id' => $task_id, |
|
| 1809 | + 'task_day' => $date |
|
| 1810 | + ]; |
|
| 1811 | + $form = self::getTaskForm($blog_id); |
|
| 1812 | + $form->addHidden('old_task_id', $task_id); |
|
| 1813 | + $form->addHidden('old_user_id', $user_id); |
|
| 1814 | + $form->addHidden('old_target_date', $date); |
|
| 1815 | + $form->addHidden('assign_task_edit_submit', 'true'); |
|
| 1816 | + $form->setDefaults($defaults); |
|
| 1817 | + $form->display(); |
|
| 1818 | + } |
|
| 1819 | + |
|
| 1820 | + /** |
|
| 1821 | + * Assigns a task to a user in a blog |
|
| 1822 | + * |
|
| 1823 | + * @param Integer $blog_id |
|
| 1824 | + * @param Integer $user_id |
|
| 1825 | + * @param Integer $task_id |
|
| 1826 | + * @param Date $target_date |
|
| 1827 | + */ |
|
| 1828 | + public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
| 1829 | + { |
|
| 1830 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1831 | + $course_id = api_get_course_int_id(); |
|
| 1832 | + |
|
| 1833 | + $sql = " |
|
| 1835 | 1834 | SELECT COUNT(*) as 'number' |
| 1836 | 1835 | FROM " . $tbl_blogs_tasks_rel_user . " |
| 1837 | 1836 | WHERE c_id = $course_id AND |
@@ -1840,11 +1839,11 @@ discard block |
||
| 1840 | 1839 | AND task_id = " . (int)$task_id . " |
| 1841 | 1840 | "; |
| 1842 | 1841 | |
| 1843 | - $result = Database::query($sql); |
|
| 1844 | - $row = Database::fetch_assoc($result); |
|
| 1842 | + $result = Database::query($sql); |
|
| 1843 | + $row = Database::fetch_assoc($result); |
|
| 1845 | 1844 | |
| 1846 | - if ($row['number'] == 0) { |
|
| 1847 | - $sql = " |
|
| 1845 | + if ($row['number'] == 0) { |
|
| 1846 | + $sql = " |
|
| 1848 | 1847 | INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
| 1849 | 1848 | c_id, |
| 1850 | 1849 | blog_id, |
@@ -1859,9 +1858,9 @@ discard block |
||
| 1859 | 1858 | '" . Database::escape_string($target_date) . "' |
| 1860 | 1859 | )"; |
| 1861 | 1860 | |
| 1862 | - Database::query($sql); |
|
| 1863 | - } |
|
| 1864 | - } |
|
| 1861 | + Database::query($sql); |
|
| 1862 | + } |
|
| 1863 | + } |
|
| 1865 | 1864 | |
| 1866 | 1865 | /** |
| 1867 | 1866 | * @param $blog_id |
@@ -1881,11 +1880,11 @@ discard block |
||
| 1881 | 1880 | $old_task_id, |
| 1882 | 1881 | $old_target_date |
| 1883 | 1882 | ) { |
| 1884 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1883 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1885 | 1884 | |
| 1886 | - $course_id = api_get_course_int_id(); |
|
| 1885 | + $course_id = api_get_course_int_id(); |
|
| 1887 | 1886 | |
| 1888 | - $sql = "SELECT COUNT(*) as 'number' |
|
| 1887 | + $sql = "SELECT COUNT(*) as 'number' |
|
| 1889 | 1888 | FROM " . $tbl_blogs_tasks_rel_user . " |
| 1890 | 1889 | WHERE |
| 1891 | 1890 | c_id = $course_id AND |
@@ -1894,11 +1893,11 @@ discard block |
||
| 1894 | 1893 | task_id = " . (int)$task_id . " |
| 1895 | 1894 | "; |
| 1896 | 1895 | |
| 1897 | - $result = Database::query($sql); |
|
| 1898 | - $row = Database::fetch_assoc($result); |
|
| 1896 | + $result = Database::query($sql); |
|
| 1897 | + $row = Database::fetch_assoc($result); |
|
| 1899 | 1898 | |
| 1900 | - if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
| 1901 | - $sql = " |
|
| 1899 | + if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
| 1900 | + $sql = " |
|
| 1902 | 1901 | UPDATE " . $tbl_blogs_tasks_rel_user . " |
| 1903 | 1902 | SET |
| 1904 | 1903 | user_id = " . (int)$user_id . ", |
@@ -1911,76 +1910,76 @@ discard block |
||
| 1911 | 1910 | task_id = " . (int)$old_task_id . " AND |
| 1912 | 1911 | target_date = '" . Database::escape_string($old_target_date) . "' |
| 1913 | 1912 | "; |
| 1914 | - Database::query($sql); |
|
| 1915 | - } |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - /** |
|
| 1919 | - * Displays a list with posts a user can select to execute his task. |
|
| 1920 | - * |
|
| 1921 | - * @param Integer $blog_id |
|
| 1922 | - * @param unknown_type $task_id |
|
| 1923 | - */ |
|
| 1924 | - public static function display_select_task_post($blog_id, $task_id) |
|
| 1913 | + Database::query($sql); |
|
| 1914 | + } |
|
| 1915 | + } |
|
| 1916 | + |
|
| 1917 | + /** |
|
| 1918 | + * Displays a list with posts a user can select to execute his task. |
|
| 1919 | + * |
|
| 1920 | + * @param Integer $blog_id |
|
| 1921 | + * @param unknown_type $task_id |
|
| 1922 | + */ |
|
| 1923 | + public static function display_select_task_post($blog_id, $task_id) |
|
| 1925 | 1924 | { |
| 1926 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1927 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1928 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1929 | - $course_id = api_get_course_int_id(); |
|
| 1925 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 1926 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 1927 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 1928 | + $course_id = api_get_course_int_id(); |
|
| 1930 | 1929 | |
| 1931 | 1930 | |
| 1932 | - $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
| 1931 | + $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
| 1933 | 1932 | WHERE task_id = '".(int)$task_id."' |
| 1934 | 1933 | AND c_id = $course_id"; |
| 1935 | - $result = Database::query($sql); |
|
| 1936 | - $row = Database::fetch_assoc($result); |
|
| 1937 | - // Get posts and authors |
|
| 1938 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 1934 | + $result = Database::query($sql); |
|
| 1935 | + $row = Database::fetch_assoc($result); |
|
| 1936 | + // Get posts and authors |
|
| 1937 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
| 1939 | 1938 | FROM $tbl_blogs_posts post |
| 1940 | 1939 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1941 | 1940 | WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
| 1942 | 1941 | ORDER BY post_id DESC |
| 1943 | 1942 | LIMIT 0, 100"; |
| 1944 | - $result = Database::query($sql); |
|
| 1943 | + $result = Database::query($sql); |
|
| 1945 | 1944 | |
| 1946 | - // Display |
|
| 1947 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
| 1948 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
| 1945 | + // Display |
|
| 1946 | + echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
| 1947 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
| 1949 | 1948 | |
| 1950 | - if (Database::num_rows($result) > 0) { |
|
| 1951 | - while($blog_post = Database::fetch_array($result)) { |
|
| 1952 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 1953 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
| 1954 | - } |
|
| 1949 | + if (Database::num_rows($result) > 0) { |
|
| 1950 | + while($blog_post = Database::fetch_array($result)) { |
|
| 1951 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
| 1952 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
| 1953 | + } |
|
| 1955 | 1954 | } else { |
| 1956 | 1955 | echo get_lang('NoArticles'); |
| 1957 | 1956 | } |
| 1958 | - } |
|
| 1959 | - |
|
| 1960 | - /** |
|
| 1961 | - * Subscribes a user to a given blog |
|
| 1962 | - * @author Toon Keppens |
|
| 1963 | - * |
|
| 1964 | - * @param Integer $blog_id |
|
| 1965 | - * @param Integer $user_id |
|
| 1966 | - */ |
|
| 1967 | - public static function set_user_subscribed($blog_id, $user_id) |
|
| 1957 | + } |
|
| 1958 | + |
|
| 1959 | + /** |
|
| 1960 | + * Subscribes a user to a given blog |
|
| 1961 | + * @author Toon Keppens |
|
| 1962 | + * |
|
| 1963 | + * @param Integer $blog_id |
|
| 1964 | + * @param Integer $user_id |
|
| 1965 | + */ |
|
| 1966 | + public static function set_user_subscribed($blog_id, $user_id) |
|
| 1968 | 1967 | { |
| 1969 | - // Init |
|
| 1970 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1971 | - $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 1968 | + // Init |
|
| 1969 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 1970 | + $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
| 1972 | 1971 | |
| 1973 | - $course_id = api_get_course_int_id(); |
|
| 1972 | + $course_id = api_get_course_int_id(); |
|
| 1974 | 1973 | |
| 1975 | - // Subscribe the user |
|
| 1976 | - $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
| 1974 | + // Subscribe the user |
|
| 1975 | + $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
| 1977 | 1976 | VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
| 1978 | - Database::query($sql); |
|
| 1977 | + Database::query($sql); |
|
| 1979 | 1978 | |
| 1980 | - // Give this user basic rights |
|
| 1981 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1979 | + // Give this user basic rights |
|
| 1980 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1982 | 1981 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
| 1983 | - Database::query($sql); |
|
| 1982 | + Database::query($sql); |
|
| 1984 | 1983 | |
| 1985 | 1984 | $id = Database::insert_id(); |
| 1986 | 1985 | if ($id) { |
@@ -1988,9 +1987,9 @@ discard block |
||
| 1988 | 1987 | Database::query($sql); |
| 1989 | 1988 | } |
| 1990 | 1989 | |
| 1991 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1990 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
| 1992 | 1991 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
| 1993 | - Database::query($sql); |
|
| 1992 | + Database::query($sql); |
|
| 1994 | 1993 | |
| 1995 | 1994 | $id = Database::insert_id(); |
| 1996 | 1995 | if ($id) { |
@@ -1998,197 +1997,197 @@ discard block |
||
| 1998 | 1997 | Database::query($sql); |
| 1999 | 1998 | } |
| 2000 | 1999 | |
| 2001 | - } |
|
| 2000 | + } |
|
| 2002 | 2001 | |
| 2003 | - /** |
|
| 2004 | - * Unsubscribe a user from a given blog |
|
| 2005 | - * @author Toon Keppens |
|
| 2006 | - * |
|
| 2007 | - * @param Integer $blog_id |
|
| 2008 | - * @param Integer $user_id |
|
| 2009 | - */ |
|
| 2010 | - public static function set_user_unsubscribed($blog_id, $user_id) |
|
| 2002 | + /** |
|
| 2003 | + * Unsubscribe a user from a given blog |
|
| 2004 | + * @author Toon Keppens |
|
| 2005 | + * |
|
| 2006 | + * @param Integer $blog_id |
|
| 2007 | + * @param Integer $user_id |
|
| 2008 | + */ |
|
| 2009 | + public static function set_user_unsubscribed($blog_id, $user_id) |
|
| 2011 | 2010 | { |
| 2012 | - // Init |
|
| 2011 | + // Init |
|
| 2013 | 2012 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
| 2014 | 2013 | $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
| 2015 | 2014 | |
| 2016 | - // Unsubscribe the user |
|
| 2017 | - $sql = "DELETE FROM $tbl_blogs_rel_user |
|
| 2015 | + // Unsubscribe the user |
|
| 2016 | + $sql = "DELETE FROM $tbl_blogs_rel_user |
|
| 2018 | 2017 | WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
| 2019 | - Database::query($sql); |
|
| 2018 | + Database::query($sql); |
|
| 2020 | 2019 | |
| 2021 | - // Remove this user's permissions. |
|
| 2022 | - $sql = "DELETE FROM $tbl_user_permissions |
|
| 2020 | + // Remove this user's permissions. |
|
| 2021 | + $sql = "DELETE FROM $tbl_user_permissions |
|
| 2023 | 2022 | WHERE user_id = '".(int)$user_id."'"; |
| 2024 | - Database::query($sql); |
|
| 2025 | - } |
|
| 2026 | - |
|
| 2027 | - /** |
|
| 2028 | - * Displays the form to register users in a blog (in a course) |
|
| 2029 | - * The listed users are users subcribed in the course. |
|
| 2030 | - * @author Toon Keppens |
|
| 2031 | - * |
|
| 2032 | - * @param Integer $blog_id |
|
| 2033 | - * |
|
| 2034 | - * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
| 2035 | - */ |
|
| 2036 | - public static function display_form_user_subscribe($blog_id) |
|
| 2037 | - { |
|
| 2038 | - $_course = api_get_course_info(); |
|
| 2039 | - $is_western_name_order = api_is_western_name_order(); |
|
| 2040 | - $session_id = api_get_session_id(); |
|
| 2041 | - $course_id = $_course['real_id']; |
|
| 2042 | - |
|
| 2043 | - $currentCourse = $_course['code']; |
|
| 2044 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2045 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2046 | - |
|
| 2047 | - echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
| 2048 | - |
|
| 2049 | - $properties["width"] = "100%"; |
|
| 2050 | - |
|
| 2051 | - // Get blog members' id. |
|
| 2052 | - $sql = "SELECT user.user_id FROM $tbl_users user |
|
| 2023 | + Database::query($sql); |
|
| 2024 | + } |
|
| 2025 | + |
|
| 2026 | + /** |
|
| 2027 | + * Displays the form to register users in a blog (in a course) |
|
| 2028 | + * The listed users are users subcribed in the course. |
|
| 2029 | + * @author Toon Keppens |
|
| 2030 | + * |
|
| 2031 | + * @param Integer $blog_id |
|
| 2032 | + * |
|
| 2033 | + * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
| 2034 | + */ |
|
| 2035 | + public static function display_form_user_subscribe($blog_id) |
|
| 2036 | + { |
|
| 2037 | + $_course = api_get_course_info(); |
|
| 2038 | + $is_western_name_order = api_is_western_name_order(); |
|
| 2039 | + $session_id = api_get_session_id(); |
|
| 2040 | + $course_id = $_course['real_id']; |
|
| 2041 | + |
|
| 2042 | + $currentCourse = $_course['code']; |
|
| 2043 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2044 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2045 | + |
|
| 2046 | + echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
| 2047 | + |
|
| 2048 | + $properties["width"] = "100%"; |
|
| 2049 | + |
|
| 2050 | + // Get blog members' id. |
|
| 2051 | + $sql = "SELECT user.user_id FROM $tbl_users user |
|
| 2053 | 2052 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 2054 | 2053 | ON user.user_id = blogs_rel_user.user_id |
| 2055 | 2054 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'"; |
| 2056 | - $result = Database::query($sql); |
|
| 2057 | - |
|
| 2058 | - $blog_member_ids = array(); |
|
| 2059 | - while($user = Database::fetch_array($result)) { |
|
| 2060 | - $blog_member_ids[] = $user['user_id']; |
|
| 2061 | - } |
|
| 2062 | - |
|
| 2063 | - // Set table headers |
|
| 2064 | - $column_header[] = array ('', false, ''); |
|
| 2065 | - if ($is_western_name_order) { |
|
| 2066 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2067 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2068 | - } else { |
|
| 2069 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2070 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2071 | - } |
|
| 2072 | - $column_header[] = array(get_lang('Email'), false, ''); |
|
| 2073 | - $column_header[] = array(get_lang('Register'), false, ''); |
|
| 2055 | + $result = Database::query($sql); |
|
| 2056 | + |
|
| 2057 | + $blog_member_ids = array(); |
|
| 2058 | + while($user = Database::fetch_array($result)) { |
|
| 2059 | + $blog_member_ids[] = $user['user_id']; |
|
| 2060 | + } |
|
| 2061 | + |
|
| 2062 | + // Set table headers |
|
| 2063 | + $column_header[] = array ('', false, ''); |
|
| 2064 | + if ($is_western_name_order) { |
|
| 2065 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2066 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2067 | + } else { |
|
| 2068 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2069 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2070 | + } |
|
| 2071 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
| 2072 | + $column_header[] = array(get_lang('Register'), false, ''); |
|
| 2074 | 2073 | |
| 2075 | 2074 | $student_list = CourseManager:: get_student_list_from_course_code( |
| 2076 | 2075 | $currentCourse, |
| 2077 | 2076 | false, |
| 2078 | 2077 | $session_id |
| 2079 | 2078 | ); |
| 2080 | - $user_data = array(); |
|
| 2081 | - |
|
| 2082 | - // Add users that are not in this blog to the list. |
|
| 2083 | - foreach ($student_list as $key=>$user) { |
|
| 2084 | - if(isset($user['id_user'])) { |
|
| 2085 | - $user['user_id'] = $user['id_user']; |
|
| 2086 | - } |
|
| 2087 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
| 2088 | - $a_infosUser = api_get_user_info($user['user_id']); |
|
| 2089 | - $row = array (); |
|
| 2090 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2091 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
| 2092 | - if ($is_western_name_order) { |
|
| 2093 | - $row[] = $a_infosUser["firstname"]; |
|
| 2094 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2095 | - } else { |
|
| 2096 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2097 | - $row[] = $a_infosUser["firstname"]; |
|
| 2098 | - } |
|
| 2099 | - $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
| 2100 | - |
|
| 2101 | - //Link to register users |
|
| 2102 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
| 2103 | - $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
| 2104 | - } else { |
|
| 2105 | - $row[] = ''; |
|
| 2106 | - } |
|
| 2107 | - $user_data[] = $row; |
|
| 2108 | - } |
|
| 2109 | - } |
|
| 2110 | - |
|
| 2111 | - // Display |
|
| 2112 | - $query_vars['action'] = 'manage_members'; |
|
| 2113 | - $query_vars['blog_id'] = $blog_id; |
|
| 2114 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2115 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2116 | - $link = ''; |
|
| 2117 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
| 2118 | - $link .= "blog_id=$blog_id&"; |
|
| 2119 | - |
|
| 2120 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2121 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2122 | - echo get_lang('WithSelected') . ' : '; |
|
| 2123 | - echo '<select name="action">'; |
|
| 2124 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
| 2125 | - echo '</select>'; |
|
| 2126 | - echo '<input type="hidden" name="register" value="true" />'; |
|
| 2127 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2128 | - echo '</form>'; |
|
| 2129 | - } |
|
| 2130 | - |
|
| 2131 | - /** |
|
| 2132 | - * Displays the form to register users in a blog (in a course) |
|
| 2133 | - * The listed users are users subcribed in the course. |
|
| 2134 | - * @author Toon Keppens |
|
| 2135 | - * |
|
| 2136 | - * @param Integer $blog_id |
|
| 2137 | - * |
|
| 2138 | - * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
| 2139 | - */ |
|
| 2140 | - public static function display_form_user_unsubscribe ($blog_id) |
|
| 2141 | - { |
|
| 2142 | - $_user = api_get_user_info(); |
|
| 2143 | - $is_western_name_order = api_is_western_name_order(); |
|
| 2144 | - |
|
| 2145 | - // Init |
|
| 2146 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2147 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2148 | - |
|
| 2149 | - echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
| 2150 | - |
|
| 2151 | - $properties["width"] = "100%"; |
|
| 2152 | - //table column titles |
|
| 2153 | - $column_header[] = array ('', false, ''); |
|
| 2154 | - if ($is_western_name_order) { |
|
| 2155 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2156 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2157 | - } else { |
|
| 2158 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2159 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2160 | - } |
|
| 2161 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
| 2162 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
| 2163 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
| 2164 | - |
|
| 2165 | - $course_id = api_get_course_int_id(); |
|
| 2166 | - |
|
| 2167 | - $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
| 2079 | + $user_data = array(); |
|
| 2080 | + |
|
| 2081 | + // Add users that are not in this blog to the list. |
|
| 2082 | + foreach ($student_list as $key=>$user) { |
|
| 2083 | + if(isset($user['id_user'])) { |
|
| 2084 | + $user['user_id'] = $user['id_user']; |
|
| 2085 | + } |
|
| 2086 | + if(!in_array($user['user_id'],$blog_member_ids)) { |
|
| 2087 | + $a_infosUser = api_get_user_info($user['user_id']); |
|
| 2088 | + $row = array (); |
|
| 2089 | + $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2090 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
| 2091 | + if ($is_western_name_order) { |
|
| 2092 | + $row[] = $a_infosUser["firstname"]; |
|
| 2093 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2094 | + } else { |
|
| 2095 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
| 2096 | + $row[] = $a_infosUser["firstname"]; |
|
| 2097 | + } |
|
| 2098 | + $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
| 2099 | + |
|
| 2100 | + //Link to register users |
|
| 2101 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
| 2102 | + $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
| 2103 | + } else { |
|
| 2104 | + $row[] = ''; |
|
| 2105 | + } |
|
| 2106 | + $user_data[] = $row; |
|
| 2107 | + } |
|
| 2108 | + } |
|
| 2109 | + |
|
| 2110 | + // Display |
|
| 2111 | + $query_vars['action'] = 'manage_members'; |
|
| 2112 | + $query_vars['blog_id'] = $blog_id; |
|
| 2113 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2114 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2115 | + $link = ''; |
|
| 2116 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
| 2117 | + $link .= "blog_id=$blog_id&"; |
|
| 2118 | + |
|
| 2119 | + echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2120 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2121 | + echo get_lang('WithSelected') . ' : '; |
|
| 2122 | + echo '<select name="action">'; |
|
| 2123 | + echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
| 2124 | + echo '</select>'; |
|
| 2125 | + echo '<input type="hidden" name="register" value="true" />'; |
|
| 2126 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2127 | + echo '</form>'; |
|
| 2128 | + } |
|
| 2129 | + |
|
| 2130 | + /** |
|
| 2131 | + * Displays the form to register users in a blog (in a course) |
|
| 2132 | + * The listed users are users subcribed in the course. |
|
| 2133 | + * @author Toon Keppens |
|
| 2134 | + * |
|
| 2135 | + * @param Integer $blog_id |
|
| 2136 | + * |
|
| 2137 | + * @return Html Form with sortable table with users to unsubcribe from a blog. |
|
| 2138 | + */ |
|
| 2139 | + public static function display_form_user_unsubscribe ($blog_id) |
|
| 2140 | + { |
|
| 2141 | + $_user = api_get_user_info(); |
|
| 2142 | + $is_western_name_order = api_is_western_name_order(); |
|
| 2143 | + |
|
| 2144 | + // Init |
|
| 2145 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2146 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
| 2147 | + |
|
| 2148 | + echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
| 2149 | + |
|
| 2150 | + $properties["width"] = "100%"; |
|
| 2151 | + //table column titles |
|
| 2152 | + $column_header[] = array ('', false, ''); |
|
| 2153 | + if ($is_western_name_order) { |
|
| 2154 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2155 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2156 | + } else { |
|
| 2157 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2158 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2159 | + } |
|
| 2160 | + $column_header[] = array (get_lang('Email'), false, ''); |
|
| 2161 | + $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
| 2162 | + $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
| 2163 | + |
|
| 2164 | + $course_id = api_get_course_int_id(); |
|
| 2165 | + |
|
| 2166 | + $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
| 2168 | 2167 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 2169 | 2168 | ON user.user_id = blogs_rel_user.user_id |
| 2170 | 2169 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
| 2171 | 2170 | |
| 2172 | - if (!($sql_result = Database::query($sql))) { |
|
| 2173 | - return false; |
|
| 2174 | - } |
|
| 2175 | - |
|
| 2176 | - $user_data = array (); |
|
| 2177 | - |
|
| 2178 | - while ($myrow = Database::fetch_array($sql_result)) { |
|
| 2179 | - $row = array (); |
|
| 2180 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2181 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
| 2182 | - if ($is_western_name_order) { |
|
| 2183 | - $row[] = $myrow["firstname"]; |
|
| 2184 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2185 | - } else { |
|
| 2186 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2187 | - $row[] = $myrow["firstname"]; |
|
| 2188 | - } |
|
| 2189 | - $row[] = Display::icon_mailto_link($myrow["email"]); |
|
| 2190 | - |
|
| 2191 | - $sql = "SELECT bt.title task |
|
| 2171 | + if (!($sql_result = Database::query($sql))) { |
|
| 2172 | + return false; |
|
| 2173 | + } |
|
| 2174 | + |
|
| 2175 | + $user_data = array (); |
|
| 2176 | + |
|
| 2177 | + while ($myrow = Database::fetch_array($sql_result)) { |
|
| 2178 | + $row = array (); |
|
| 2179 | + $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2180 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
| 2181 | + if ($is_western_name_order) { |
|
| 2182 | + $row[] = $myrow["firstname"]; |
|
| 2183 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2184 | + } else { |
|
| 2185 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
| 2186 | + $row[] = $myrow["firstname"]; |
|
| 2187 | + } |
|
| 2188 | + $row[] = Display::icon_mailto_link($myrow["email"]); |
|
| 2189 | + |
|
| 2190 | + $sql = "SELECT bt.title task |
|
| 2192 | 2191 | FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
| 2193 | 2192 | INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
| 2194 | 2193 | ON btu.task_id = bt.task_id |
@@ -2196,158 +2195,158 @@ discard block |
||
| 2196 | 2195 | bt.c_id = $course_id AND |
| 2197 | 2196 | btu.blog_id = $blog_id AND |
| 2198 | 2197 | btu.user_id = " . $myrow['user_id']; |
| 2199 | - $sql_res = Database::query($sql); |
|
| 2200 | - |
|
| 2201 | - $task = ''; |
|
| 2202 | - |
|
| 2203 | - while($r = Database::fetch_array($sql_res)) { |
|
| 2204 | - $task .= stripslashes($r['task']) . ', '; |
|
| 2205 | - } |
|
| 2206 | - //echo $task; |
|
| 2207 | - $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
| 2208 | - $row[] = $task; |
|
| 2209 | - //Link to register users |
|
| 2210 | - |
|
| 2211 | - if ($myrow["user_id"] != $_user['user_id']) { |
|
| 2212 | - $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
| 2213 | - } else { |
|
| 2214 | - $row[] = ''; |
|
| 2215 | - } |
|
| 2216 | - |
|
| 2217 | - $user_data[] = $row; |
|
| 2218 | - } |
|
| 2219 | - |
|
| 2220 | - $query_vars['action'] = 'manage_members'; |
|
| 2221 | - $query_vars['blog_id'] = $blog_id; |
|
| 2222 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2223 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2224 | - $link = ''; |
|
| 2225 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
| 2226 | - $link .= "blog_id=$blog_id&"; |
|
| 2227 | - |
|
| 2228 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2229 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2230 | - echo get_lang('WithSelected') . ' : '; |
|
| 2231 | - echo '<select name="action">'; |
|
| 2232 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
| 2233 | - echo '</select>'; |
|
| 2234 | - echo '<input type="hidden" name="unregister" value="true" />'; |
|
| 2235 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2236 | - echo '</form>'; |
|
| 2237 | - } |
|
| 2238 | - |
|
| 2239 | - /** |
|
| 2240 | - * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
| 2241 | - * The blog admin can thus select what a certain user can do in the current blog |
|
| 2242 | - * |
|
| 2243 | - * @param Integer $blog_id |
|
| 2244 | - */ |
|
| 2245 | - public static function display_form_user_rights ($blog_id) |
|
| 2198 | + $sql_res = Database::query($sql); |
|
| 2199 | + |
|
| 2200 | + $task = ''; |
|
| 2201 | + |
|
| 2202 | + while($r = Database::fetch_array($sql_res)) { |
|
| 2203 | + $task .= stripslashes($r['task']) . ', '; |
|
| 2204 | + } |
|
| 2205 | + //echo $task; |
|
| 2206 | + $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
| 2207 | + $row[] = $task; |
|
| 2208 | + //Link to register users |
|
| 2209 | + |
|
| 2210 | + if ($myrow["user_id"] != $_user['user_id']) { |
|
| 2211 | + $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
| 2212 | + } else { |
|
| 2213 | + $row[] = ''; |
|
| 2214 | + } |
|
| 2215 | + |
|
| 2216 | + $user_data[] = $row; |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + $query_vars['action'] = 'manage_members'; |
|
| 2220 | + $query_vars['blog_id'] = $blog_id; |
|
| 2221 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2222 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2223 | + $link = ''; |
|
| 2224 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
| 2225 | + $link .= "blog_id=$blog_id&"; |
|
| 2226 | + |
|
| 2227 | + echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2228 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2229 | + echo get_lang('WithSelected') . ' : '; |
|
| 2230 | + echo '<select name="action">'; |
|
| 2231 | + echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
| 2232 | + echo '</select>'; |
|
| 2233 | + echo '<input type="hidden" name="unregister" value="true" />'; |
|
| 2234 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2235 | + echo '</form>'; |
|
| 2236 | + } |
|
| 2237 | + |
|
| 2238 | + /** |
|
| 2239 | + * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
| 2240 | + * The blog admin can thus select what a certain user can do in the current blog |
|
| 2241 | + * |
|
| 2242 | + * @param Integer $blog_id |
|
| 2243 | + */ |
|
| 2244 | + public static function display_form_user_rights ($blog_id) |
|
| 2245 | + { |
|
| 2246 | + echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
| 2247 | + echo '<br />'; |
|
| 2248 | + |
|
| 2249 | + // Integration of patricks permissions system. |
|
| 2250 | + require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
| 2251 | + } |
|
| 2252 | + |
|
| 2253 | + /** |
|
| 2254 | + * Displays the form to create a new post |
|
| 2255 | + * @author Toon Keppens |
|
| 2256 | + * |
|
| 2257 | + * @param Integer $blog_id |
|
| 2258 | + */ |
|
| 2259 | + public static function display_new_comment_form($blog_id, $post_id, $title) |
|
| 2260 | + { |
|
| 2261 | + $form = new FormValidator( |
|
| 2262 | + 'add_post', |
|
| 2263 | + 'post', |
|
| 2264 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
| 2265 | + null, |
|
| 2266 | + array('enctype' => 'multipart/form-data') |
|
| 2267 | + ); |
|
| 2268 | + |
|
| 2269 | + $header = get_lang('AddNewComment'); |
|
| 2270 | + if (isset($_GET['task_id'])) { |
|
| 2271 | + $header = get_lang('ExecuteThisTask'); |
|
| 2272 | + } |
|
| 2273 | + $form->addHeader($header); |
|
| 2274 | + $form->addText('title', get_lang('Title')); |
|
| 2275 | + |
|
| 2276 | + $config = array(); |
|
| 2277 | + if (!api_is_allowed_to_edit()) { |
|
| 2278 | + $config['ToolbarSet'] = 'ProjectComment'; |
|
| 2279 | + } else { |
|
| 2280 | + $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
| 2281 | + } |
|
| 2282 | + $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
| 2283 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 2284 | + |
|
| 2285 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 2286 | + |
|
| 2287 | + $form->addHidden('action', null); |
|
| 2288 | + $form->addHidden('comment_parent_id', 0); |
|
| 2289 | + |
|
| 2290 | + if (isset($_GET['task_id'])) { |
|
| 2291 | + $form->addHidden('new_task_execution_submit', 'true'); |
|
| 2292 | + $form->addHidden('task_id', intval($_GET['task_id'])); |
|
| 2293 | + } else { |
|
| 2294 | + $form->addHidden('new_comment_submit', 'true'); |
|
| 2295 | + } |
|
| 2296 | + $form->addButton('save', get_lang('Save')); |
|
| 2297 | + $form->display(); |
|
| 2298 | + } |
|
| 2299 | + |
|
| 2300 | + |
|
| 2301 | + /** |
|
| 2302 | + * show the calender of the given month |
|
| 2303 | + * @author Patrick Cool |
|
| 2304 | + * @author Toon Keppens |
|
| 2305 | + * |
|
| 2306 | + * @param Array $blogitems an array containing all the blog items for the given month |
|
| 2307 | + * @param Integer $month: the integer value of the month we are viewing |
|
| 2308 | + * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
| 2309 | + * @param String $monthName: the language variable for the mont name |
|
| 2310 | + * |
|
| 2311 | + * @return html code |
|
| 2312 | + */ |
|
| 2313 | + public static function display_minimonthcalendar($month, $year, $blog_id) |
|
| 2246 | 2314 | { |
| 2247 | - echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
| 2248 | - echo '<br />'; |
|
| 2249 | - |
|
| 2250 | - // Integration of patricks permissions system. |
|
| 2251 | - require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
| 2252 | - } |
|
| 2253 | - |
|
| 2254 | - /** |
|
| 2255 | - * Displays the form to create a new post |
|
| 2256 | - * @author Toon Keppens |
|
| 2257 | - * |
|
| 2258 | - * @param Integer $blog_id |
|
| 2259 | - */ |
|
| 2260 | - public static function display_new_comment_form($blog_id, $post_id, $title) |
|
| 2261 | - { |
|
| 2262 | - $form = new FormValidator( |
|
| 2263 | - 'add_post', |
|
| 2264 | - 'post', |
|
| 2265 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
| 2266 | - null, |
|
| 2267 | - array('enctype' => 'multipart/form-data') |
|
| 2268 | - ); |
|
| 2269 | - |
|
| 2270 | - $header = get_lang('AddNewComment'); |
|
| 2271 | - if (isset($_GET['task_id'])) { |
|
| 2272 | - $header = get_lang('ExecuteThisTask'); |
|
| 2273 | - } |
|
| 2274 | - $form->addHeader($header); |
|
| 2275 | - $form->addText('title', get_lang('Title')); |
|
| 2276 | - |
|
| 2277 | - $config = array(); |
|
| 2278 | - if (!api_is_allowed_to_edit()) { |
|
| 2279 | - $config['ToolbarSet'] = 'ProjectComment'; |
|
| 2280 | - } else { |
|
| 2281 | - $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
| 2282 | - } |
|
| 2283 | - $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
| 2284 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
| 2285 | - |
|
| 2286 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
| 2287 | - |
|
| 2288 | - $form->addHidden('action', null); |
|
| 2289 | - $form->addHidden('comment_parent_id', 0); |
|
| 2290 | - |
|
| 2291 | - if (isset($_GET['task_id'])) { |
|
| 2292 | - $form->addHidden('new_task_execution_submit', 'true'); |
|
| 2293 | - $form->addHidden('task_id', intval($_GET['task_id'])); |
|
| 2294 | - } else { |
|
| 2295 | - $form->addHidden('new_comment_submit', 'true'); |
|
| 2296 | - } |
|
| 2297 | - $form->addButton('save', get_lang('Save')); |
|
| 2298 | - $form->display(); |
|
| 2299 | - } |
|
| 2300 | - |
|
| 2301 | - |
|
| 2302 | - /** |
|
| 2303 | - * show the calender of the given month |
|
| 2304 | - * @author Patrick Cool |
|
| 2305 | - * @author Toon Keppens |
|
| 2306 | - * |
|
| 2307 | - * @param Array $blogitems an array containing all the blog items for the given month |
|
| 2308 | - * @param Integer $month: the integer value of the month we are viewing |
|
| 2309 | - * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
| 2310 | - * @param String $monthName: the language variable for the mont name |
|
| 2311 | - * |
|
| 2312 | - * @return html code |
|
| 2313 | - */ |
|
| 2314 | - public static function display_minimonthcalendar($month, $year, $blog_id) |
|
| 2315 | - { |
|
| 2316 | - // Init |
|
| 2317 | - $_user = api_get_user_info(); |
|
| 2318 | - global $DaysShort; |
|
| 2319 | - global $MonthsLong; |
|
| 2320 | - |
|
| 2321 | - $posts = array(); |
|
| 2322 | - $tasks = array(); |
|
| 2323 | - |
|
| 2324 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2325 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2326 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 2327 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 2328 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2329 | - |
|
| 2330 | - $course_id = api_get_course_int_id(); |
|
| 2331 | - |
|
| 2332 | - //Handle leap year |
|
| 2333 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2334 | - |
|
| 2335 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2336 | - $numberofdays[2] = 29; |
|
| 2337 | - |
|
| 2338 | - //Get the first day of the month |
|
| 2339 | - $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
| 2340 | - $monthName = $MonthsLong[$month-1]; |
|
| 2341 | - |
|
| 2342 | - //Start the week on monday |
|
| 2343 | - $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
| 2344 | - $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
| 2345 | - $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
| 2346 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
| 2347 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
| 2348 | - |
|
| 2349 | - // Get posts for this month |
|
| 2350 | - $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
| 2315 | + // Init |
|
| 2316 | + $_user = api_get_user_info(); |
|
| 2317 | + global $DaysShort; |
|
| 2318 | + global $MonthsLong; |
|
| 2319 | + |
|
| 2320 | + $posts = array(); |
|
| 2321 | + $tasks = array(); |
|
| 2322 | + |
|
| 2323 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2324 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2325 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
| 2326 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 2327 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2328 | + |
|
| 2329 | + $course_id = api_get_course_int_id(); |
|
| 2330 | + |
|
| 2331 | + //Handle leap year |
|
| 2332 | + $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2333 | + |
|
| 2334 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2335 | + $numberofdays[2] = 29; |
|
| 2336 | + |
|
| 2337 | + //Get the first day of the month |
|
| 2338 | + $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
| 2339 | + $monthName = $MonthsLong[$month-1]; |
|
| 2340 | + |
|
| 2341 | + //Start the week on monday |
|
| 2342 | + $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
| 2343 | + $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
| 2344 | + $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
| 2345 | + $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
| 2346 | + $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
| 2347 | + |
|
| 2348 | + // Get posts for this month |
|
| 2349 | + $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
| 2351 | 2350 | FROM $tbl_blogs_posts post |
| 2352 | 2351 | INNER JOIN $tbl_users user |
| 2353 | 2352 | ON post.author_id = user.user_id |
@@ -2357,20 +2356,20 @@ discard block |
||
| 2357 | 2356 | MONTH(date_creation) = '".(int)$month."' AND |
| 2358 | 2357 | YEAR(date_creation) = '".(int)$year."' |
| 2359 | 2358 | ORDER BY date_creation"; |
| 2360 | - $result = Database::query($sql); |
|
| 2361 | - |
|
| 2362 | - // We will create an array of days on which there are posts. |
|
| 2363 | - if( Database::num_rows($result) > 0) { |
|
| 2364 | - while($blog_post = Database::fetch_array($result)) { |
|
| 2365 | - // If the day of this post is not yet in the array, add it. |
|
| 2366 | - if (!in_array($blog_post['post_day'], $posts)) |
|
| 2367 | - $posts[] = $blog_post['post_day']; |
|
| 2368 | - } |
|
| 2369 | - } |
|
| 2370 | - |
|
| 2371 | - // Get tasks for this month |
|
| 2372 | - if ($_user['user_id']) { |
|
| 2373 | - $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
| 2359 | + $result = Database::query($sql); |
|
| 2360 | + |
|
| 2361 | + // We will create an array of days on which there are posts. |
|
| 2362 | + if( Database::num_rows($result) > 0) { |
|
| 2363 | + while($blog_post = Database::fetch_array($result)) { |
|
| 2364 | + // If the day of this post is not yet in the array, add it. |
|
| 2365 | + if (!in_array($blog_post['post_day'], $posts)) |
|
| 2366 | + $posts[] = $blog_post['post_day']; |
|
| 2367 | + } |
|
| 2368 | + } |
|
| 2369 | + |
|
| 2370 | + // Get tasks for this month |
|
| 2371 | + if ($_user['user_id']) { |
|
| 2372 | + $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
| 2374 | 2373 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
| 2375 | 2374 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
| 2376 | 2375 | INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id |
@@ -2382,84 +2381,84 @@ discard block |
||
| 2382 | 2381 | MONTH(target_date) = '".(int)$month."' AND |
| 2383 | 2382 | YEAR(target_date) = '".(int)$year."' |
| 2384 | 2383 | ORDER BY target_date ASC"; |
| 2385 | - $result = Database::query($sql); |
|
| 2386 | - |
|
| 2387 | - if (Database::num_rows($result) > 0) { |
|
| 2388 | - while ($mytask = Database::fetch_array($result)) { |
|
| 2389 | - $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
| 2390 | - $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
| 2391 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
| 2392 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
| 2393 | - $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
| 2394 | - } |
|
| 2395 | - } |
|
| 2396 | - } |
|
| 2397 | - |
|
| 2398 | - echo '<table id="smallcalendar" class="table table-responsive">', |
|
| 2399 | - "<tr id=\"title\">\n", |
|
| 2400 | - "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>\n", |
|
| 2401 | - "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", |
|
| 2402 | - "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>\n", "</tr>"; |
|
| 2403 | - |
|
| 2404 | - echo "<tr>\n"; |
|
| 2405 | - |
|
| 2406 | - for($ii = 1; $ii < 8; $ii ++) |
|
| 2407 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
| 2408 | - |
|
| 2409 | - echo "</tr>"; |
|
| 2410 | - |
|
| 2411 | - $curday = -1; |
|
| 2412 | - $today = getdate(); |
|
| 2413 | - |
|
| 2414 | - while ($curday <= $numberofdays[$month]) { |
|
| 2415 | - echo "<tr>"; |
|
| 2416 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
| 2417 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
| 2418 | - $curday = 1; |
|
| 2419 | - |
|
| 2420 | - if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
| 2421 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
| 2422 | - $dayheader = "$curday"; |
|
| 2423 | - |
|
| 2424 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2425 | - $dayheader = "$curday"; |
|
| 2426 | - $class = "class=\"days_today\""; |
|
| 2427 | - } |
|
| 2428 | - |
|
| 2429 | - echo "<td " . $class.">"; |
|
| 2430 | - |
|
| 2431 | - // If there are posts on this day, create a filter link. |
|
| 2432 | - if(in_array($curday, $posts)) |
|
| 2433 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2434 | - else |
|
| 2435 | - echo $dayheader; |
|
| 2436 | - |
|
| 2437 | - if (count($tasks) > 0) { |
|
| 2438 | - if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
| 2439 | - // Add tasks to calendar |
|
| 2440 | - foreach ($tasks[$curday] as $task) { |
|
| 2441 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '"> |
|
| 2384 | + $result = Database::query($sql); |
|
| 2385 | + |
|
| 2386 | + if (Database::num_rows($result) > 0) { |
|
| 2387 | + while ($mytask = Database::fetch_array($result)) { |
|
| 2388 | + $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
| 2389 | + $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
| 2390 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
| 2391 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
| 2392 | + $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
| 2393 | + } |
|
| 2394 | + } |
|
| 2395 | + } |
|
| 2396 | + |
|
| 2397 | + echo '<table id="smallcalendar" class="table table-responsive">', |
|
| 2398 | + "<tr id=\"title\">\n", |
|
| 2399 | + "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>\n", |
|
| 2400 | + "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n", |
|
| 2401 | + "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>\n", "</tr>"; |
|
| 2402 | + |
|
| 2403 | + echo "<tr>\n"; |
|
| 2404 | + |
|
| 2405 | + for($ii = 1; $ii < 8; $ii ++) |
|
| 2406 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
| 2407 | + |
|
| 2408 | + echo "</tr>"; |
|
| 2409 | + |
|
| 2410 | + $curday = -1; |
|
| 2411 | + $today = getdate(); |
|
| 2412 | + |
|
| 2413 | + while ($curday <= $numberofdays[$month]) { |
|
| 2414 | + echo "<tr>"; |
|
| 2415 | + for ($ii = 0; $ii < 7; $ii ++) { |
|
| 2416 | + if (($curday == -1) && ($ii == $startdayofweek)) |
|
| 2417 | + $curday = 1; |
|
| 2418 | + |
|
| 2419 | + if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
| 2420 | + $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
| 2421 | + $dayheader = "$curday"; |
|
| 2422 | + |
|
| 2423 | + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2424 | + $dayheader = "$curday"; |
|
| 2425 | + $class = "class=\"days_today\""; |
|
| 2426 | + } |
|
| 2427 | + |
|
| 2428 | + echo "<td " . $class.">"; |
|
| 2429 | + |
|
| 2430 | + // If there are posts on this day, create a filter link. |
|
| 2431 | + if(in_array($curday, $posts)) |
|
| 2432 | + echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2433 | + else |
|
| 2434 | + echo $dayheader; |
|
| 2435 | + |
|
| 2436 | + if (count($tasks) > 0) { |
|
| 2437 | + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
| 2438 | + // Add tasks to calendar |
|
| 2439 | + foreach ($tasks[$curday] as $task) { |
|
| 2440 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '"> |
|
| 2442 | 2441 | <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>'; |
| 2443 | - } |
|
| 2444 | - } |
|
| 2445 | - } |
|
| 2446 | - |
|
| 2447 | - echo "</td>"; |
|
| 2448 | - $curday ++; |
|
| 2449 | - } else |
|
| 2450 | - echo "<td> </td>"; |
|
| 2451 | - } |
|
| 2452 | - echo "</tr>"; |
|
| 2453 | - } |
|
| 2454 | - echo "</table>"; |
|
| 2455 | - } |
|
| 2456 | - |
|
| 2457 | - /** |
|
| 2458 | - * Blog admin | Display the form to add a new blog. |
|
| 2459 | - * |
|
| 2460 | - */ |
|
| 2461 | - public static function display_new_blog_form() |
|
| 2462 | - { |
|
| 2442 | + } |
|
| 2443 | + } |
|
| 2444 | + } |
|
| 2445 | + |
|
| 2446 | + echo "</td>"; |
|
| 2447 | + $curday ++; |
|
| 2448 | + } else |
|
| 2449 | + echo "<td> </td>"; |
|
| 2450 | + } |
|
| 2451 | + echo "</tr>"; |
|
| 2452 | + } |
|
| 2453 | + echo "</table>"; |
|
| 2454 | + } |
|
| 2455 | + |
|
| 2456 | + /** |
|
| 2457 | + * Blog admin | Display the form to add a new blog. |
|
| 2458 | + * |
|
| 2459 | + */ |
|
| 2460 | + public static function display_new_blog_form() |
|
| 2461 | + { |
|
| 2463 | 2462 | $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add'); |
| 2464 | 2463 | $form->addElement('header', get_lang('AddBlog')); |
| 2465 | 2464 | $form->addElement('text', 'blog_name', get_lang('Title')); |
@@ -2469,34 +2468,34 @@ discard block |
||
| 2469 | 2468 | $form->addButtonSave(get_lang('SaveProject')); |
| 2470 | 2469 | |
| 2471 | 2470 | $defaults = array( |
| 2472 | - 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
| 2473 | - 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
| 2474 | - ); |
|
| 2471 | + 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
| 2472 | + 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
| 2473 | + ); |
|
| 2475 | 2474 | $form->setDefaults($defaults); |
| 2476 | 2475 | $form->display(); |
| 2477 | - } |
|
| 2478 | - |
|
| 2479 | - /** |
|
| 2480 | - * Blog admin | Display the form to edit a blog. |
|
| 2481 | - * |
|
| 2482 | - */ |
|
| 2483 | - public static function display_edit_blog_form($blog_id) |
|
| 2484 | - { |
|
| 2485 | - $course_id = api_get_course_int_id(); |
|
| 2486 | - $blog_id= intval($blog_id); |
|
| 2487 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2488 | - |
|
| 2489 | - $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
| 2476 | + } |
|
| 2477 | + |
|
| 2478 | + /** |
|
| 2479 | + * Blog admin | Display the form to edit a blog. |
|
| 2480 | + * |
|
| 2481 | + */ |
|
| 2482 | + public static function display_edit_blog_form($blog_id) |
|
| 2483 | + { |
|
| 2484 | + $course_id = api_get_course_int_id(); |
|
| 2485 | + $blog_id= intval($blog_id); |
|
| 2486 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2487 | + |
|
| 2488 | + $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
| 2490 | 2489 | FROM $tbl_blogs |
| 2491 | 2490 | WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; |
| 2492 | - $result = Database::query($sql); |
|
| 2493 | - $blog = Database::fetch_array($result); |
|
| 2491 | + $result = Database::query($sql); |
|
| 2492 | + $blog = Database::fetch_array($result); |
|
| 2494 | 2493 | |
| 2495 | - // the form contained errors but we do not want to lose the changes the user already did |
|
| 2496 | - if ($_POST) { |
|
| 2497 | - $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
| 2498 | - $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
| 2499 | - } |
|
| 2494 | + // the form contained errors but we do not want to lose the changes the user already did |
|
| 2495 | + if ($_POST) { |
|
| 2496 | + $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
| 2497 | + $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
| 2498 | + } |
|
| 2500 | 2499 | |
| 2501 | 2500 | $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
| 2502 | 2501 | $form->addElement('header', get_lang('EditBlog')); |
@@ -2512,82 +2511,82 @@ discard block |
||
| 2512 | 2511 | $defaults['blog_subtitle'] = $blog['blog_subtitle']; |
| 2513 | 2512 | $form->setDefaults($defaults); |
| 2514 | 2513 | $form->display(); |
| 2515 | - } |
|
| 2514 | + } |
|
| 2516 | 2515 | |
| 2517 | - /** |
|
| 2518 | - * Blog admin | Returns table with blogs in this course |
|
| 2519 | - */ |
|
| 2520 | - public static function display_blog_list() |
|
| 2516 | + /** |
|
| 2517 | + * Blog admin | Returns table with blogs in this course |
|
| 2518 | + */ |
|
| 2519 | + public static function display_blog_list() |
|
| 2521 | 2520 | { |
| 2522 | - global $charset; |
|
| 2523 | - $_user = api_get_user_info(); |
|
| 2521 | + global $charset; |
|
| 2522 | + $_user = api_get_user_info(); |
|
| 2524 | 2523 | $course_id = api_get_course_int_id(); |
| 2525 | 2524 | |
| 2526 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2525 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2527 | 2526 | |
| 2528 | - //condition for the session |
|
| 2529 | - $session_id = api_get_session_id(); |
|
| 2530 | - $condition_session = api_get_session_condition($session_id, false); |
|
| 2527 | + //condition for the session |
|
| 2528 | + $session_id = api_get_session_id(); |
|
| 2529 | + $condition_session = api_get_session_condition($session_id, false); |
|
| 2531 | 2530 | |
| 2532 | - $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
| 2531 | + $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
| 2533 | 2532 | FROM $tbl_blogs WHERE c_id = $course_id |
| 2534 | 2533 | ORDER BY date_creation DESC"; |
| 2535 | - $result = Database::query($sql); |
|
| 2536 | - $list_info = array(); |
|
| 2537 | - if (Database::num_rows($result)) { |
|
| 2538 | - while ($row_project=Database::fetch_row($result)) { |
|
| 2539 | - $list_info[]=$row_project; |
|
| 2540 | - } |
|
| 2541 | - } |
|
| 2542 | - |
|
| 2543 | - $list_content_blog = array(); |
|
| 2544 | - $list_body_blog = array(); |
|
| 2545 | - |
|
| 2546 | - if (is_array($list_info)) { |
|
| 2547 | - foreach ($list_info as $key => $info_log) { |
|
| 2548 | - // Validation when belongs to a session |
|
| 2549 | - $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
| 2550 | - |
|
| 2551 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
| 2552 | - $title = $info_log[0]; |
|
| 2534 | + $result = Database::query($sql); |
|
| 2535 | + $list_info = array(); |
|
| 2536 | + if (Database::num_rows($result)) { |
|
| 2537 | + while ($row_project=Database::fetch_row($result)) { |
|
| 2538 | + $list_info[]=$row_project; |
|
| 2539 | + } |
|
| 2540 | + } |
|
| 2541 | + |
|
| 2542 | + $list_content_blog = array(); |
|
| 2543 | + $list_body_blog = array(); |
|
| 2544 | + |
|
| 2545 | + if (is_array($list_info)) { |
|
| 2546 | + foreach ($list_info as $key => $info_log) { |
|
| 2547 | + // Validation when belongs to a session |
|
| 2548 | + $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
| 2549 | + |
|
| 2550 | + $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
| 2551 | + $title = $info_log[0]; |
|
| 2553 | 2552 | $image = Display::return_icon('blog.png', $title); |
| 2554 | - $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
| 2553 | + $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
| 2555 | 2554 | |
| 2556 | - $list_body_blog[] = $list_name; |
|
| 2557 | - $list_body_blog[] = $info_log[1]; |
|
| 2555 | + $list_body_blog[] = $list_name; |
|
| 2556 | + $list_body_blog[] = $info_log[1]; |
|
| 2558 | 2557 | |
| 2559 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
| 2560 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
| 2561 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
| 2558 | + $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
| 2559 | + $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
| 2560 | + $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
| 2562 | 2561 | $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
| 2563 | 2562 | |
| 2564 | - $my_image.= "</a>\n"; |
|
| 2565 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
| 2566 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
| 2563 | + $my_image.= "</a>\n"; |
|
| 2564 | + $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
| 2565 | + $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
| 2567 | 2566 | $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
| 2568 | 2567 | |
| 2569 | - $my_image.= "</a>\n"; |
|
| 2570 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
| 2568 | + $my_image.= "</a>\n"; |
|
| 2569 | + $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
| 2571 | 2570 | $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
| 2572 | 2571 | |
| 2573 | - $my_image.= "</a>\n"; |
|
| 2572 | + $my_image.= "</a>\n"; |
|
| 2574 | 2573 | |
| 2575 | - $list_body_blog[]=$my_image; |
|
| 2574 | + $list_body_blog[]=$my_image; |
|
| 2576 | 2575 | |
| 2577 | - $list_content_blog[]=$list_body_blog; |
|
| 2578 | - $list_body_blog = array(); |
|
| 2576 | + $list_content_blog[]=$list_body_blog; |
|
| 2577 | + $list_body_blog = array(); |
|
| 2579 | 2578 | |
| 2580 | - } |
|
| 2581 | - $parameters=''; |
|
| 2582 | - //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
|
| 2583 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
| 2584 | - //$table->set_additional_parameters($parameters); |
|
| 2585 | - $table->set_header(0, get_lang('Title')); |
|
| 2586 | - $table->set_header(1, get_lang('SubTitle')); |
|
| 2587 | - $table->set_header(2, get_lang('Modify')); |
|
| 2588 | - $table->display(); |
|
| 2589 | - } |
|
| 2590 | - } |
|
| 2579 | + } |
|
| 2580 | + $parameters=''; |
|
| 2581 | + //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
|
| 2582 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
| 2583 | + //$table->set_additional_parameters($parameters); |
|
| 2584 | + $table->set_header(0, get_lang('Title')); |
|
| 2585 | + $table->set_header(1, get_lang('SubTitle')); |
|
| 2586 | + $table->set_header(2, get_lang('Modify')); |
|
| 2587 | + $table->display(); |
|
| 2588 | + } |
|
| 2589 | + } |
|
| 2591 | 2590 | } |
| 2592 | 2591 | |
| 2593 | 2592 | /** |
@@ -2607,34 +2606,34 @@ discard block |
||
| 2607 | 2606 | */ |
| 2608 | 2607 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
| 2609 | 2608 | { |
| 2610 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2611 | - |
|
| 2612 | - $blog_id = intval($blog_id); |
|
| 2613 | - $comment_id = intval($comment_id); |
|
| 2614 | - $post_id = intval($post_id); |
|
| 2615 | - $row=array(); |
|
| 2616 | - $where=''; |
|
| 2617 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
| 2618 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
| 2619 | - } |
|
| 2620 | - |
|
| 2621 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
| 2622 | - if (!empty ($post_id)) { |
|
| 2623 | - $where.= ' AND '; |
|
| 2624 | - } |
|
| 2625 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
| 2626 | - } |
|
| 2609 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2610 | + |
|
| 2611 | + $blog_id = intval($blog_id); |
|
| 2612 | + $comment_id = intval($comment_id); |
|
| 2613 | + $post_id = intval($post_id); |
|
| 2614 | + $row=array(); |
|
| 2615 | + $where=''; |
|
| 2616 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
| 2617 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
| 2618 | + } |
|
| 2619 | + |
|
| 2620 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
| 2621 | + if (!empty ($post_id)) { |
|
| 2622 | + $where.= ' AND '; |
|
| 2623 | + } |
|
| 2624 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
| 2625 | + } |
|
| 2627 | 2626 | |
| 2628 | 2627 | $course_id = api_get_course_int_id(); |
| 2629 | 2628 | |
| 2630 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
| 2629 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
| 2631 | 2630 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2632 | 2631 | |
| 2633 | - $result=Database::query($sql); |
|
| 2634 | - if (Database::num_rows($result)!=0) { |
|
| 2635 | - $row=Database::fetch_array($result); |
|
| 2636 | - } |
|
| 2637 | - return $row; |
|
| 2632 | + $result=Database::query($sql); |
|
| 2633 | + if (Database::num_rows($result)!=0) { |
|
| 2634 | + $row=Database::fetch_array($result); |
|
| 2635 | + } |
|
| 2636 | + return $row; |
|
| 2638 | 2637 | } |
| 2639 | 2638 | |
| 2640 | 2639 | /** |
@@ -2648,16 +2647,16 @@ discard block |
||
| 2648 | 2647 | |
| 2649 | 2648 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
| 2650 | 2649 | { |
| 2651 | - $_course = api_get_course_info(); |
|
| 2652 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2653 | - $blog_id = intval($blog_id); |
|
| 2654 | - $comment_id = intval($comment_id); |
|
| 2655 | - $post_id = intval($post_id); |
|
| 2650 | + $_course = api_get_course_info(); |
|
| 2651 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 2652 | + $blog_id = intval($blog_id); |
|
| 2653 | + $comment_id = intval($comment_id); |
|
| 2654 | + $post_id = intval($post_id); |
|
| 2656 | 2655 | |
| 2657 | 2656 | $course_id = api_get_course_int_id(); |
| 2658 | - $where = null; |
|
| 2657 | + $where = null; |
|
| 2659 | 2658 | |
| 2660 | - // delete files in DB |
|
| 2659 | + // delete files in DB |
|
| 2661 | 2660 | if (!empty ($post_id) && is_numeric($post_id)) { |
| 2662 | 2661 | $where .= ' AND post_id ="'.$post_id.'" '; |
| 2663 | 2662 | } |
@@ -2669,25 +2668,25 @@ discard block |
||
| 2669 | 2668 | $where .= ' comment_id ="'.$comment_id.'" '; |
| 2670 | 2669 | } |
| 2671 | 2670 | |
| 2672 | - // delete all files in directory |
|
| 2673 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 2674 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 2675 | - $updir = $sys_course_path.$courseDir; |
|
| 2671 | + // delete all files in directory |
|
| 2672 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 2673 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
| 2674 | + $updir = $sys_course_path.$courseDir; |
|
| 2676 | 2675 | |
| 2677 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
| 2676 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
| 2678 | 2677 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2679 | - $result=Database::query($sql); |
|
| 2680 | - |
|
| 2681 | - while ($row=Database::fetch_row($result)) { |
|
| 2682 | - $file=$updir.'/'.$row[0]; |
|
| 2683 | - if (Security::check_abs_path($file,$updir) ) |
|
| 2684 | - { |
|
| 2685 | - @ unlink($file); |
|
| 2686 | - } |
|
| 2687 | - } |
|
| 2688 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
| 2678 | + $result=Database::query($sql); |
|
| 2679 | + |
|
| 2680 | + while ($row=Database::fetch_row($result)) { |
|
| 2681 | + $file=$updir.'/'.$row[0]; |
|
| 2682 | + if (Security::check_abs_path($file,$updir) ) |
|
| 2683 | + { |
|
| 2684 | + @ unlink($file); |
|
| 2685 | + } |
|
| 2686 | + } |
|
| 2687 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
| 2689 | 2688 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2690 | - Database::query($sql); |
|
| 2689 | + Database::query($sql); |
|
| 2691 | 2690 | } |
| 2692 | 2691 | |
| 2693 | 2692 | /** |
@@ -2697,12 +2696,12 @@ discard block |
||
| 2697 | 2696 | */ |
| 2698 | 2697 | function get_blog_post_from_user($course_code, $user_id) |
| 2699 | 2698 | { |
| 2700 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2701 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2702 | - $course_info = api_get_course_info($course_code); |
|
| 2703 | - $course_id = $course_info['real_id']; |
|
| 2699 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
| 2700 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2701 | + $course_info = api_get_course_info($course_code); |
|
| 2702 | + $course_id = $course_info['real_id']; |
|
| 2704 | 2703 | |
| 2705 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
| 2704 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
| 2706 | 2705 | FROM $tbl_blogs blog |
| 2707 | 2706 | INNER JOIN $tbl_blog_post post |
| 2708 | 2707 | ON (blog.blog_id = post.blog_id) |
@@ -2711,19 +2710,19 @@ discard block |
||
| 2711 | 2710 | post.c_id = $course_id AND |
| 2712 | 2711 | author_id = $user_id AND visibility = 1 |
| 2713 | 2712 | ORDER BY post.date_creation DESC "; |
| 2714 | - $result = Database::query($sql); |
|
| 2715 | - $return_data = ''; |
|
| 2716 | - |
|
| 2717 | - if (Database::num_rows($result)!=0) { |
|
| 2718 | - while ($row=Database::fetch_array($result)) { |
|
| 2719 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2720 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2721 | - $return_data.= '<br / >'; |
|
| 2722 | - $return_data.= $row['full_text']; |
|
| 2723 | - $return_data.= '<br /><br />'; |
|
| 2724 | - } |
|
| 2725 | - } |
|
| 2726 | - return $return_data; |
|
| 2713 | + $result = Database::query($sql); |
|
| 2714 | + $return_data = ''; |
|
| 2715 | + |
|
| 2716 | + if (Database::num_rows($result)!=0) { |
|
| 2717 | + while ($row=Database::fetch_array($result)) { |
|
| 2718 | + $return_data.= '<div class="clear"></div><br />'; |
|
| 2719 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2720 | + $return_data.= '<br / >'; |
|
| 2721 | + $return_data.= $row['full_text']; |
|
| 2722 | + $return_data.= '<br /><br />'; |
|
| 2723 | + } |
|
| 2724 | + } |
|
| 2725 | + return $return_data; |
|
| 2727 | 2726 | } |
| 2728 | 2727 | |
| 2729 | 2728 | /** |
@@ -2740,7 +2739,7 @@ discard block |
||
| 2740 | 2739 | $course_info = api_get_course_info($course_code); |
| 2741 | 2740 | $course_id = $course_info['real_id']; |
| 2742 | 2741 | |
| 2743 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
| 2742 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
| 2744 | 2743 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
| 2745 | 2744 | ON (blog.blog_id = comment.blog_id) |
| 2746 | 2745 | WHERE blog.c_id = $course_id AND |
@@ -2748,18 +2747,18 @@ discard block |
||
| 2748 | 2747 | author_id = $user_id AND |
| 2749 | 2748 | visibility = 1 |
| 2750 | 2749 | ORDER BY blog_name"; |
| 2751 | - $result = Database::query($sql); |
|
| 2752 | - $return_data = ''; |
|
| 2753 | - if (Database::num_rows($result)!=0) { |
|
| 2754 | - while ($row=Database::fetch_array($result)) { |
|
| 2755 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2756 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2757 | - $return_data.= '<br / >'; |
|
| 2758 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
| 2759 | - $return_data.= $row['comment']; |
|
| 2760 | - $return_data.= '<br />'; |
|
| 2761 | - } |
|
| 2762 | - } |
|
| 2763 | - return $return_data; |
|
| 2750 | + $result = Database::query($sql); |
|
| 2751 | + $return_data = ''; |
|
| 2752 | + if (Database::num_rows($result)!=0) { |
|
| 2753 | + while ($row=Database::fetch_array($result)) { |
|
| 2754 | + $return_data.= '<div class="clear"></div><br />'; |
|
| 2755 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2756 | + $return_data.= '<br / >'; |
|
| 2757 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
| 2758 | + $return_data.= $row['comment']; |
|
| 2759 | + $return_data.= '<br />'; |
|
| 2760 | + } |
|
| 2761 | + } |
|
| 2762 | + return $return_data; |
|
| 2764 | 2763 | } |
| 2765 | 2764 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return String Blog Title |
| 23 | 23 | */ |
| 24 | - public static function get_blog_title ($blog_id) |
|
| 24 | + public static function get_blog_title($blog_id) |
|
| 25 | 25 | { |
| 26 | 26 | $course_id = api_get_course_int_id(); |
| 27 | 27 | |
@@ -30,8 +30,8 @@ discard block |
||
| 30 | 30 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 31 | 31 | |
| 32 | 32 | $sql = "SELECT blog_name |
| 33 | - FROM " . $tbl_blogs . " |
|
| 34 | - WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
|
| 33 | + FROM " . $tbl_blogs." |
|
| 34 | + WHERE c_id = $course_id AND blog_id = ".intval($blog_id); |
|
| 35 | 35 | |
| 36 | 36 | $result = Database::query($sql); |
| 37 | 37 | $blog = Database::fetch_array($result); |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | // Get blog members |
| 80 | 80 | $sql = "SELECT user.user_id, user.firstname, user.lastname |
| 81 | - FROM " . $tbl_blogs_rel_user . " blogs_rel_user |
|
| 82 | - INNER JOIN " . $tbl_users . " user |
|
| 81 | + FROM " . $tbl_blogs_rel_user." blogs_rel_user |
|
| 82 | + INNER JOIN " . $tbl_users." user |
|
| 83 | 83 | ON blogs_rel_user.user_id = user.user_id |
| 84 | 84 | WHERE |
| 85 | 85 | blogs_rel_user.c_id = $course_id AND |
| 86 | - blogs_rel_user.blog_id = '" . (int)$blog_id."'"; |
|
| 86 | + blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
| 87 | 87 | $result = Database::query($sql); |
| 88 | - $blog_members = array (); |
|
| 89 | - while($user = Database::fetch_array($result)) { |
|
| 88 | + $blog_members = array(); |
|
| 89 | + while ($user = Database::fetch_array($result)) { |
|
| 90 | 90 | $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $_user = api_get_user_info(); |
| 106 | 106 | $course_id = api_get_course_int_id(); |
| 107 | 107 | |
| 108 | - $current_date=date('Y-m-d H:i:s',time()); |
|
| 108 | + $current_date = date('Y-m-d H:i:s', time()); |
|
| 109 | 109 | $session_id = api_get_session_id(); |
| 110 | 110 | // Tabel definitions |
| 111 | 111 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | 'blog_name' => $title, |
| 131 | 131 | 'blog_subtitle' => $subtitle, |
| 132 | 132 | 'date_creation' => $current_date, |
| 133 | - 'visibility' => 1 , |
|
| 133 | + 'visibility' => 1, |
|
| 134 | 134 | 'session_id' => $session_id, |
| 135 | 135 | ]; |
| 136 | 136 | $this_blog_id = Database::insert($tbl_blogs, $params); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | |
| 170 | 170 | // Put it on course homepage |
| 171 | 171 | $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) |
| 172 | - VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; |
|
| 172 | + VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int) $this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')"; |
|
| 173 | 173 | Database::query($sql); |
| 174 | 174 | |
| 175 | 175 | $toolId = Database::insert_id(); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | blog_subtitle = '".Database::escape_string($subtitle)."' |
| 205 | 205 | WHERE |
| 206 | 206 | c_id = $course_id AND |
| 207 | - blog_id ='".Database::escape_string((int)$blog_id)."' |
|
| 207 | + blog_id ='".Database::escape_string((int) $blog_id)."' |
|
| 208 | 208 | LIMIT 1"; |
| 209 | 209 | Database::query($sql); |
| 210 | 210 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | // Update course homepage link |
| 221 | 221 | $sql = "UPDATE $tbl_tool SET |
| 222 | 222 | name = '".Database::escape_string($title)."' |
| 223 | - WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
|
| 223 | + WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int) $blog_id."' LIMIT 1"; |
|
| 224 | 224 | Database::query($sql); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | Database::query($sql); |
| 264 | 264 | |
| 265 | 265 | // Delete blog |
| 266 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 266 | + $sql = "DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
| 267 | 267 | Database::query($sql); |
| 268 | 268 | |
| 269 | 269 | // Delete from course homepage |
@@ -294,13 +294,13 @@ discard block |
||
| 294 | 294 | $course_id = $_course['real_id']; |
| 295 | 295 | |
| 296 | 296 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
| 297 | - $upload_ok=true; |
|
| 298 | - $has_attachment=false; |
|
| 297 | + $upload_ok = true; |
|
| 298 | + $has_attachment = false; |
|
| 299 | 299 | $current_date = api_get_utc_datetime(); |
| 300 | 300 | |
| 301 | 301 | if (!empty($_FILES['user_upload']['name'])) { |
| 302 | 302 | $upload_ok = process_uploaded_file($_FILES['user_upload']); |
| 303 | - $has_attachment=true; |
|
| 303 | + $has_attachment = true; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | if ($upload_ok) { |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | // Create the post |
| 311 | 311 | $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
| 312 | - VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
|
| 312 | + VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int) $blog_id."', '".(int) $_user['user_id']."');"; |
|
| 313 | 313 | |
| 314 | 314 | Database::query($sql); |
| 315 | 315 | $last_post_id = Database::insert_id(); |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | if ($has_attachment) { |
| 323 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 323 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 324 | 324 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 325 | 325 | $updir = $sys_course_path.$courseDir; |
| 326 | 326 | |
@@ -371,9 +371,9 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | // Create the post |
| 373 | 373 | $sql = "UPDATE $tbl_blogs_posts SET |
| 374 | - title = '" . Database::escape_string($title)."', |
|
| 374 | + title = '".Database::escape_string($title)."', |
|
| 375 | 375 | full_text = '" . Database::escape_string($full_text)."' |
| 376 | - WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
|
| 376 | + WHERE c_id = $course_id AND post_id ='".(int) $post_id."' AND blog_id ='".(int) $blog_id."' |
|
| 377 | 377 | LIMIT 1 "; |
| 378 | 378 | Database::query($sql); |
| 379 | 379 | } |
@@ -394,21 +394,21 @@ discard block |
||
| 394 | 394 | |
| 395 | 395 | // Delete ratings on this comment |
| 396 | 396 | $sql = "DELETE FROM $tbl_blogs_rating |
| 397 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
|
| 397 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND item_id = '".(int) $post_id."' AND rating_type = 'post'"; |
|
| 398 | 398 | Database::query($sql); |
| 399 | 399 | |
| 400 | 400 | // Delete the post |
| 401 | 401 | $sql = "DELETE FROM $tbl_blogs_posts |
| 402 | - WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
|
| 402 | + WHERE c_id = $course_id AND post_id = '".(int) $post_id."'"; |
|
| 403 | 403 | Database::query($sql); |
| 404 | 404 | |
| 405 | 405 | // Delete the comments |
| 406 | 406 | $sql = "DELETE FROM $tbl_blogs_comments |
| 407 | - WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
|
| 407 | + WHERE c_id = $course_id AND post_id = '".(int) $post_id."' AND blog_id = '".(int) $blog_id."'"; |
|
| 408 | 408 | Database::query($sql); |
| 409 | 409 | |
| 410 | 410 | // Delete posts and attachments |
| 411 | - delete_all_blog_attachment($blog_id,$post_id); |
|
| 411 | + delete_all_blog_attachment($blog_id, $post_id); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | { |
| 425 | 425 | $_user = api_get_user_info(); |
| 426 | 426 | $_course = api_get_course_info(); |
| 427 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 427 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
| 428 | 428 | |
| 429 | 429 | $upload_ok = true; |
| 430 | 430 | $has_attachment = false; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | if (!empty($_FILES['user_upload']['name'])) { |
| 435 | 435 | $upload_ok = process_uploaded_file($_FILES['user_upload']); |
| 436 | - $has_attachment=true; |
|
| 436 | + $has_attachment = true; |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | if ($upload_ok) { |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | |
| 443 | 443 | // Create the comment |
| 444 | 444 | $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
| 445 | - VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')"; |
|
| 445 | + VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int) $_user['user_id']."','".$current_date."', '".(int) $blog_id."', '".(int) $post_id."', '".(int) $parent_id."', '".(int) $task_id."')"; |
|
| 446 | 446 | Database::query($sql); |
| 447 | 447 | |
| 448 | 448 | // Empty post values, or they are shown on the page again |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | if ($has_attachment) { |
| 457 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 457 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 458 | 458 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 459 | 459 | $updir = $sys_course_path.$courseDir; |
| 460 | 460 | |
@@ -465,19 +465,19 @@ discard block |
||
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | 467 | // user's file name |
| 468 | - $file_name =$_FILES['user_upload']['name']; |
|
| 468 | + $file_name = $_FILES['user_upload']['name']; |
|
| 469 | 469 | |
| 470 | 470 | if (!filter_extension($new_file_name)) { |
| 471 | 471 | Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
| 472 | 472 | } else { |
| 473 | 473 | $new_file_name = uniqid(''); |
| 474 | - $new_path=$updir.'/'.$new_file_name; |
|
| 475 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 474 | + $new_path = $updir.'/'.$new_file_name; |
|
| 475 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
| 476 | 476 | $comment = Database::escape_string($file_comment); |
| 477 | 477 | |
| 478 | 478 | // Storing the attachments if any |
| 479 | 479 | if ($result) { |
| 480 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 480 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
| 481 | 481 | "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
| 482 | 482 | Database::query($sql); |
| 483 | 483 | |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | // Delete them recursively |
| 528 | 528 | while ($comment = Database::fetch_array($result)) { |
| 529 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
| 529 | + Blog::delete_comment($blog_id, $post_id, $comment['comment_id']); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | // Finally, delete the selected comment to |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | |
| 554 | 554 | // Create the task |
| 555 | 555 | $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
| 556 | - VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
|
| 556 | + VALUES ($course_id , '".(int) $blog_id."', '".Database::escape_string($title)."', '".Database::escape_string($description)."', '".Database::escape_string($color)."', '0');"; |
|
| 557 | 557 | Database::query($sql); |
| 558 | 558 | |
| 559 | 559 | $task_id = Database::insert_id(); |
@@ -563,13 +563,13 @@ discard block |
||
| 563 | 563 | Database::query($sql); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - $tool = 'BLOG_' . $blog_id; |
|
| 566 | + $tool = 'BLOG_'.$blog_id; |
|
| 567 | 567 | |
| 568 | 568 | if ($articleDelete == 'on') { |
| 569 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 570 | - '" . (int)$course_id . "', |
|
| 571 | - '" . (int)$task_id . "', |
|
| 572 | - '" . Database::escape_string($tool) . "', |
|
| 569 | + $sql = " INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES ( |
|
| 570 | + '" . (int) $course_id."', |
|
| 571 | + '" . (int) $task_id."', |
|
| 572 | + '" . Database::escape_string($tool)."', |
|
| 573 | 573 | 'article_delete' |
| 574 | 574 | )"; |
| 575 | 575 | Database::query($sql); |
@@ -584,10 +584,10 @@ discard block |
||
| 584 | 584 | |
| 585 | 585 | if ($articleEdit == 'on') { |
| 586 | 586 | $sql = " |
| 587 | - INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
|
| 588 | - '" . (int)$course_id . "', |
|
| 589 | - '" . (int)$task_id . "', |
|
| 590 | - '" . Database::escape_string($tool) . "', |
|
| 587 | + INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES ( |
|
| 588 | + '" . (int) $course_id."', |
|
| 589 | + '" . (int) $task_id."', |
|
| 590 | + '" . Database::escape_string($tool)."', |
|
| 591 | 591 | 'article_edit' |
| 592 | 592 | )"; |
| 593 | 593 | Database::query($sql); |
@@ -601,10 +601,10 @@ discard block |
||
| 601 | 601 | |
| 602 | 602 | if ($commentsDelete == 'on') { |
| 603 | 603 | $sql = " |
| 604 | - INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
|
| 605 | - '" . (int)$course_id . "', |
|
| 606 | - '" . (int)$task_id . "', |
|
| 607 | - '" . Database::escape_string($tool) . "', |
|
| 604 | + INSERT INTO " . $tbl_tasks_permissions." (c_id, task_id, tool, action ) VALUES ( |
|
| 605 | + '" . (int) $course_id."', |
|
| 606 | + '" . (int) $task_id."', |
|
| 607 | + '" . Database::escape_string($tool)."', |
|
| 608 | 608 | 'article_comments_delete' |
| 609 | 609 | )"; |
| 610 | 610 | Database::query($sql); |
@@ -637,20 +637,20 @@ discard block |
||
| 637 | 637 | title = '".Database::escape_string($title)."', |
| 638 | 638 | description = '".Database::escape_string($description)."', |
| 639 | 639 | color = '".Database::escape_string($color)."' |
| 640 | - WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
|
| 640 | + WHERE c_id = $course_id AND task_id ='".(int) $task_id."' LIMIT 1"; |
|
| 641 | 641 | Database::query($sql); |
| 642 | 642 | |
| 643 | - $tool = 'BLOG_' . $blog_id; |
|
| 643 | + $tool = 'BLOG_'.$blog_id; |
|
| 644 | 644 | |
| 645 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
| 646 | - WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
|
| 645 | + $sql = "DELETE FROM ".$tbl_tasks_permissions." |
|
| 646 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
| 647 | 647 | Database::query($sql); |
| 648 | 648 | |
| 649 | 649 | if ($articleDelete == 'on') { |
| 650 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
| 651 | - '" . (int)$course_id . "', |
|
| 652 | - '" . (int)$task_id . "', |
|
| 653 | - '" . Database::escape_string($tool) . "', |
|
| 650 | + $sql = "INSERT INTO ".$tbl_tasks_permissions." ( c_id, task_id, tool, action) VALUES ( |
|
| 651 | + '" . (int) $course_id."', |
|
| 652 | + '" . (int) $task_id."', |
|
| 653 | + '" . Database::escape_string($tool)."', |
|
| 654 | 654 | 'article_delete' |
| 655 | 655 | )"; |
| 656 | 656 | Database::query($sql); |
@@ -663,10 +663,10 @@ discard block |
||
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | if ($articleEdit == 'on') { |
| 666 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 667 | - '" . (int)$course_id . "', |
|
| 668 | - '" . (int)$task_id . "', |
|
| 669 | - '" . Database::escape_string($tool) . "', |
|
| 666 | + $sql = "INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES ( |
|
| 667 | + '" . (int) $course_id."', |
|
| 668 | + '" . (int) $task_id."', |
|
| 669 | + '" . Database::escape_string($tool)."', |
|
| 670 | 670 | 'article_edit' |
| 671 | 671 | )"; |
| 672 | 672 | Database::query($sql); |
@@ -679,10 +679,10 @@ discard block |
||
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | if ($commentsDelete == 'on') { |
| 682 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
| 683 | - '" . (int)$course_id . "', |
|
| 684 | - '" . (int)$task_id . "', |
|
| 685 | - '" . Database::escape_string($tool) . "', |
|
| 682 | + $sql = " INSERT INTO ".$tbl_tasks_permissions." (c_id, task_id, tool, action) VALUES ( |
|
| 683 | + '" . (int) $course_id."', |
|
| 684 | + '" . (int) $task_id."', |
|
| 685 | + '" . Database::escape_string($tool)."', |
|
| 686 | 686 | 'article_comments_delete' |
| 687 | 687 | )"; |
| 688 | 688 | Database::query($sql); |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | |
| 708 | 708 | // Delete posts |
| 709 | 709 | $sql = "DELETE FROM $tbl_blogs_tasks |
| 710 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
|
| 710 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND task_id = '".(int) $task_id."'"; |
|
| 711 | 711 | Database::query($sql); |
| 712 | 712 | } |
| 713 | 713 | |
@@ -725,9 +725,9 @@ discard block |
||
| 725 | 725 | $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
| 726 | 726 | WHERE |
| 727 | 727 | c_id = $course_id AND |
| 728 | - blog_id = '".(int)$blog_id."' AND |
|
| 729 | - task_id = '".(int)$task_id."' AND |
|
| 730 | - user_id = '".(int)$user_id."'"; |
|
| 728 | + blog_id = '".(int) $blog_id."' AND |
|
| 729 | + task_id = '".(int) $task_id."' AND |
|
| 730 | + user_id = '".(int) $user_id."'"; |
|
| 731 | 731 | Database::query($sql); |
| 732 | 732 | } |
| 733 | 733 | |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | $_user = api_get_user_info(); |
| 742 | 742 | |
| 743 | 743 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 744 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 744 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 745 | 745 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 746 | 746 | |
| 747 | 747 | $course_id = api_get_course_int_id(); |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | task.c_id = $course_id AND |
| 759 | 759 | blog.c_id = $course_id AND |
| 760 | 760 | task_rel_user.c_id = $course_id AND |
| 761 | - task_rel_user.user_id = ".(int)$_user['user_id']." |
|
| 761 | + task_rel_user.user_id = ".(int) $_user['user_id']." |
|
| 762 | 762 | ORDER BY target_date ASC"; |
| 763 | 763 | |
| 764 | 764 | $result = Database::query($sql); |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | if (Database::num_rows($result) > 0) { |
| 767 | 767 | echo '<ul>'; |
| 768 | 768 | while ($mytask = Database::fetch_array($result)) { |
| 769 | - echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
| 769 | + echo '<li><a href="blog.php?action=execute_task&blog_id='.$mytask['blog_id'].'&task_id='.stripslashes($mytask['task_id']).'" title="[Blog: '.stripslashes($mytask['blog_name']).'] '.get_lang('ExecuteThisTask').'">'.stripslashes($mytask['title']).'</a></li>'; |
|
| 770 | 770 | } |
| 771 | 771 | echo '<ul>'; |
| 772 | 772 | } else { |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | |
| 791 | 791 | // Get blog properties |
| 792 | 792 | $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
| 793 | - WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
|
| 793 | + WHERE c_id = $course_id AND blog_id='".(int) $blog_id."'"; |
|
| 794 | 794 | $result = Database::query($sql); |
| 795 | 795 | $blog = Database::fetch_array($result); |
| 796 | 796 | $visibility = $blog['visibility']; |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | if ($visibility == 1) { |
| 800 | 800 | // Change visibility state, remove from course home. |
| 801 | 801 | $sql = "UPDATE $tbl_blogs SET visibility = '0' |
| 802 | - WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
|
| 802 | + WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1"; |
|
| 803 | 803 | Database::query($sql); |
| 804 | 804 | |
| 805 | 805 | $sql = "DELETE FROM $tbl_tool |
@@ -808,11 +808,11 @@ discard block |
||
| 808 | 808 | } else { |
| 809 | 809 | // Change visibility state, add to course home. |
| 810 | 810 | $sql = "UPDATE $tbl_blogs SET visibility = '1' |
| 811 | - WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
|
| 811 | + WHERE c_id = $course_id AND blog_id ='".(int) $blog_id."' LIMIT 1"; |
|
| 812 | 812 | Database::query($sql); |
| 813 | 813 | |
| 814 | 814 | $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
| 815 | - VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
|
| 815 | + VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int) $blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
|
| 816 | 816 | Database::query($sql); |
| 817 | 817 | $id = Database::insert_id(); |
| 818 | 818 | |
@@ -843,14 +843,14 @@ discard block |
||
| 843 | 843 | FROM $tbl_blogs_posts post |
| 844 | 844 | INNER JOIN $tbl_users user |
| 845 | 845 | ON post.author_id = user.user_id |
| 846 | - WHERE post.blog_id = '".(int)$blog_id."' AND |
|
| 846 | + WHERE post.blog_id = '".(int) $blog_id."' AND |
|
| 847 | 847 | post.c_id = $course_id AND |
| 848 | 848 | $filter |
| 849 | - ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
|
| 849 | + ORDER BY post_id DESC LIMIT 0,".(int) $max_number_of_posts; |
|
| 850 | 850 | $result = Database::query($sql); |
| 851 | 851 | |
| 852 | 852 | // Display |
| 853 | - if(Database::num_rows($result) > 0) { |
|
| 853 | + if (Database::num_rows($result) > 0) { |
|
| 854 | 854 | $limit = 200; |
| 855 | 855 | while ($blog_post = Database::fetch_array($result)) { |
| 856 | 856 | // Get number of comments |
@@ -858,8 +858,8 @@ discard block |
||
| 858 | 858 | FROM $tbl_blogs_comments |
| 859 | 859 | WHERE |
| 860 | 860 | c_id = $course_id AND |
| 861 | - blog_id = '".(int)$blog_id."' AND |
|
| 862 | - post_id = '" . (int)$blog_post['post_id']."'"; |
|
| 861 | + blog_id = '".(int) $blog_id."' AND |
|
| 862 | + post_id = '" . (int) $blog_post['post_id']."'"; |
|
| 863 | 863 | $tmp = Database::query($sql); |
| 864 | 864 | $blog_post_comments = Database::fetch_array($tmp); |
| 865 | 865 | |
@@ -870,11 +870,11 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | // Create an introduction text (but keep FULL sentences) |
| 872 | 872 | $words = 0; |
| 873 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
| 873 | + $blog_post_text_cut = cut($blog_post_text, $limit); |
|
| 874 | 874 | $words = strlen($blog_post_text); |
| 875 | 875 | |
| 876 | 876 | if ($words >= $limit) { |
| 877 | - $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
| 877 | + $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_'.$blog_post_id.'\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_'.$blog_post_id.'\').style.display=\'none\'">'.get_lang('ReadMore').'</div>'; |
|
| 878 | 878 | $introduction_text = $blog_post_text_cut; |
| 879 | 879 | } else { |
| 880 | 880 | $introduction_text = $blog_post_text; |
@@ -884,27 +884,27 @@ discard block |
||
| 884 | 884 | $introduction_text = stripslashes($introduction_text); |
| 885 | 885 | |
| 886 | 886 | echo '<div class="blogpost">'; |
| 887 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 888 | - echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
| 889 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
| 890 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
| 887 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>'; |
|
| 888 | + echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.$blog_post_date.'</a></span>'; |
|
| 889 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">'.$introduction_text.$readMoreLink.'</div>'; |
|
| 890 | + echo '<div class="blogpost_text" id="blogpost_text_'.$blog_post_id.'" style="display: none">'.$blog_post_text.'</div>'; |
|
| 891 | 891 | |
| 892 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
| 892 | + $file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0); |
|
| 893 | 893 | |
| 894 | 894 | if (!empty($file_name_array)) { |
| 895 | 895 | echo '<br /><br />'; |
| 896 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 896 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 897 | 897 | echo '<a href="download.php?file='; |
| 898 | 898 | echo $file_name_array['path']; |
| 899 | 899 | echo ' "> '.$file_name_array['filename'].' </a><br />'; |
| 900 | 900 | echo '</span>'; |
| 901 | 901 | } |
| 902 | 902 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 903 | - echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
| 903 | + echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - <a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'#add_comment" title="'.get_lang('ReadPost').'" >'.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].'</a></span>'; |
|
| 904 | 904 | echo '</div>'; |
| 905 | 905 | } |
| 906 | 906 | } else { |
| 907 | - if($filter == '1=1') { |
|
| 907 | + if ($filter == '1=1') { |
|
| 908 | 908 | echo get_lang('NoArticles'); |
| 909 | 909 | } else { |
| 910 | 910 | echo get_lang('NoArticleMatches'); |
@@ -918,19 +918,19 @@ discard block |
||
| 918 | 918 | * @param Integer $blog_id |
| 919 | 919 | * @param String $query_string |
| 920 | 920 | */ |
| 921 | - public static function display_search_results ($blog_id, $query_string) |
|
| 921 | + public static function display_search_results($blog_id, $query_string) |
|
| 922 | 922 | { |
| 923 | 923 | // Init |
| 924 | 924 | $query_string = Database::escape_string($query_string); |
| 925 | - $query_string_parts = explode(' ',$query_string); |
|
| 925 | + $query_string_parts = explode(' ', $query_string); |
|
| 926 | 926 | $query_string = array(); |
| 927 | 927 | foreach ($query_string_parts as $query_part) { |
| 928 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
| 928 | + $query_string[] = " full_text LIKE '%".$query_part."%' OR title LIKE '%".$query_part."%' "; |
|
| 929 | 929 | } |
| 930 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
| 930 | + $query_string = '('.implode('OR', $query_string).')'; |
|
| 931 | 931 | |
| 932 | 932 | // Display the posts |
| 933 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
| 933 | + echo '<span class="blogpost_title">'.get_lang('SearchResults').'</span>'; |
|
| 934 | 934 | Blog::display_blog_posts($blog_id, $query_string); |
| 935 | 935 | } |
| 936 | 936 | |
@@ -943,14 +943,14 @@ discard block |
||
| 943 | 943 | public static function display_day_results($blog_id, $query_string) |
| 944 | 944 | { |
| 945 | 945 | $date_output = $query_string; |
| 946 | - $date = explode('-',$query_string); |
|
| 947 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
| 946 | + $date = explode('-', $query_string); |
|
| 947 | + $query_string = ' DAYOFMONTH(date_creation) ='.intval($date[2]).' AND MONTH(date_creation) ='.intval($date[1]).' AND YEAR(date_creation) ='.intval($date[0]); |
|
| 948 | 948 | |
| 949 | 949 | // Put date in correct output format |
| 950 | 950 | $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
| 951 | 951 | |
| 952 | 952 | // Display the posts |
| 953 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
| 953 | + echo '<span class="blogpost_title">'.get_lang('PostsOf').': '.$date_output.'</span>'; |
|
| 954 | 954 | Blog::display_blog_posts($blog_id, $query_string); |
| 955 | 955 | } |
| 956 | 956 | |
@@ -977,8 +977,8 @@ discard block |
||
| 977 | 977 | ON post.author_id = user.user_id |
| 978 | 978 | WHERE |
| 979 | 979 | post.c_id = $course_id AND |
| 980 | - post.blog_id = '".(int)$blog_id."' AND |
|
| 981 | - post.post_id = '".(int)$post_id."' |
|
| 980 | + post.blog_id = '".(int) $blog_id."' AND |
|
| 981 | + post.post_id = '".(int) $post_id."' |
|
| 982 | 982 | ORDER BY post_id DESC"; |
| 983 | 983 | $result = Database::query($sql); |
| 984 | 984 | $blog_post = Database::fetch_array($result); |
@@ -986,7 +986,7 @@ discard block |
||
| 986 | 986 | // Get number of comments |
| 987 | 987 | $sql = "SELECT COUNT(1) as number_of_comments |
| 988 | 988 | FROM $tbl_blogs_comments |
| 989 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
|
| 989 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' AND post_id = '".(int) $post_id."'"; |
|
| 990 | 990 | $result = Database::query($sql); |
| 991 | 991 | $blog_post_comments = Database::fetch_array($result); |
| 992 | 992 | |
@@ -997,34 +997,34 @@ discard block |
||
| 997 | 997 | |
| 998 | 998 | $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
| 999 | 999 | |
| 1000 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
| 1001 | - $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
| 1002 | - $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 1000 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) { |
|
| 1001 | + $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id='.$blog_id.'&post_id='.$post_id.'&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('EditThisPost').'">'; |
|
| 1002 | + $blog_post_actions .= Display::return_icon('edit.png'); |
|
| 1003 | 1003 | $blog_post_actions .= '</a>'; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
| 1007 | - $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
| 1006 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) { |
|
| 1007 | + $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_article&article_id='.$blog_post['post_id'].'&task_id='.$task_id.'" title="'.get_lang('DeleteThisArticle').'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;">'; |
|
| 1008 | 1008 | $blog_post_actions .= Display::return_icon('delete.png'); |
| 1009 | 1009 | $blog_post_actions .= '</a>'; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1013 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1012 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) |
|
| 1013 | + $rating_select = Blog::display_rating_form('post', $blog_id, $post_id); |
|
| 1014 | 1014 | |
| 1015 | - $blog_post_text=stripslashes($blog_post_text); |
|
| 1015 | + $blog_post_text = stripslashes($blog_post_text); |
|
| 1016 | 1016 | |
| 1017 | 1017 | // Display post |
| 1018 | 1018 | echo '<div class="blogpost">'; |
| 1019 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
| 1020 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
| 1021 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
| 1019 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$blog_post['post_id'].'" title="'.get_lang('ReadPost').'" >'.stripslashes($blog_post['title']).'</a></span>'; |
|
| 1020 | + echo '<span class="blogpost_date">'.$blog_post_date.'</span>'; |
|
| 1021 | + echo '<span class="blogpost_text">'.$blog_post_text.'</span><br />'; |
|
| 1022 | 1022 | |
| 1023 | 1023 | $file_name_array = get_blog_attachment($blog_id, $post_id); |
| 1024 | 1024 | |
| 1025 | 1025 | if (!empty($file_name_array)) { |
| 1026 | 1026 | echo ' <br />'; |
| 1027 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1027 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 1028 | 1028 | echo '<a href="download.php?file='; |
| 1029 | 1029 | echo $file_name_array['path']; |
| 1030 | 1030 | echo ' "> '.$file_name_array['filename'].' </a>'; |
@@ -1035,20 +1035,20 @@ discard block |
||
| 1035 | 1035 | echo '<br />'; |
| 1036 | 1036 | } |
| 1037 | 1037 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 1038 | - echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
| 1039 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
| 1038 | + echo '<span class="blogpost_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post', $blog_id, $post_id).$rating_select.'</span>'; |
|
| 1039 | + echo '<span class="blogpost_actions">'.$blog_post_actions.'</span>'; |
|
| 1040 | 1040 | echo '</div>'; |
| 1041 | 1041 | |
| 1042 | 1042 | // Display comments if there are any |
| 1043 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
| 1043 | + if ($blog_post_comments['number_of_comments'] > 0) { |
|
| 1044 | 1044 | echo '<div class="comments">'; |
| 1045 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
| 1045 | + echo '<span class="blogpost_title">'.get_lang('Comments').'</span><br />'; |
|
| 1046 | 1046 | Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
| 1047 | 1047 | echo '</div>'; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | 1050 | // Display comment form |
| 1051 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
| 1051 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) { |
|
| 1052 | 1052 | Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
| 1053 | 1053 | } |
| 1054 | 1054 | } |
@@ -1076,16 +1076,16 @@ discard block |
||
| 1076 | 1076 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
| 1077 | 1077 | WHERE |
| 1078 | 1078 | c_id = $course_id AND |
| 1079 | - blog_id = '".(int)$blog_id."' AND |
|
| 1080 | - item_id = '".(int)$item_id."' AND |
|
| 1079 | + blog_id = '".(int) $blog_id."' AND |
|
| 1080 | + item_id = '".(int) $item_id."' AND |
|
| 1081 | 1081 | rating_type = '".Database::escape_string($type)."' AND |
| 1082 | - user_id = '".(int)$_user['user_id']."'"; |
|
| 1082 | + user_id = '".(int) $_user['user_id']."'"; |
|
| 1083 | 1083 | $result = Database::query($sql); |
| 1084 | 1084 | |
| 1085 | 1085 | // Add rating |
| 1086 | 1086 | if (Database::num_rows($result) == 0) { |
| 1087 | 1087 | $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
| 1088 | - VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
|
| 1088 | + VALUES ($course_id, '".(int) $blog_id."', '".Database::escape_string($type)."', '".(int) $item_id."', '".(int) $_user['user_id']."', '".Database::escape_string($rating)."')"; |
|
| 1089 | 1089 | Database::query($sql); |
| 1090 | 1090 | |
| 1091 | 1091 | $id = Database::insert_id(); |
@@ -1118,8 +1118,8 @@ discard block |
||
| 1118 | 1118 | $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
| 1119 | 1119 | WHERE |
| 1120 | 1120 | c_id = $course_id AND |
| 1121 | - blog_id = '".(int)$blog_id."' AND |
|
| 1122 | - item_id = '".(int)$item_id."' AND |
|
| 1121 | + blog_id = '".(int) $blog_id."' AND |
|
| 1122 | + item_id = '".(int) $item_id."' AND |
|
| 1123 | 1123 | rating_type = '".Database::escape_string($type)."' "; |
| 1124 | 1124 | $result = Database::query($sql); |
| 1125 | 1125 | $result = Database::fetch_array($result); |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | * |
| 1137 | 1137 | *@return String |
| 1138 | 1138 | */ |
| 1139 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1139 | + public static function display_rating_form($type, $blog_id, $post_id, $comment_id = NULL) |
|
| 1140 | 1140 | { |
| 1141 | 1141 | $_user = api_get_user_info(); |
| 1142 | 1142 | $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
@@ -1146,14 +1146,14 @@ discard block |
||
| 1146 | 1146 | // Check if the user has already rated this post |
| 1147 | 1147 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
| 1148 | 1148 | WHERE c_id = $course_id AND |
| 1149 | - blog_id = '".(int)$blog_id."' |
|
| 1150 | - AND item_id = '".(int)$post_id."' |
|
| 1149 | + blog_id = '".(int) $blog_id."' |
|
| 1150 | + AND item_id = '".(int) $post_id."' |
|
| 1151 | 1151 | AND rating_type = '".Database::escape_string($type)."' |
| 1152 | - AND user_id = '".(int)$_user['user_id']."'"; |
|
| 1152 | + AND user_id = '".(int) $_user['user_id']."'"; |
|
| 1153 | 1153 | $result = Database::query($sql); |
| 1154 | 1154 | // Add rating |
| 1155 | 1155 | if (Database::num_rows($result) == 0) { |
| 1156 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
| 1156 | + return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" style="display: inline" id="frm_rating_'.$type.'_'.$post_id.'" name="frm_rating_'.$type.'_'.$post_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$post_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /></form>'; |
|
| 1157 | 1157 | } else { |
| 1158 | 1158 | return ''; |
| 1159 | 1159 | } |
@@ -1162,14 +1162,14 @@ discard block |
||
| 1162 | 1162 | if ($type = 'comment') { |
| 1163 | 1163 | // Check if the user has already rated this comment |
| 1164 | 1164 | $sql = "SELECT rating_id FROM $tbl_blogs_rating |
| 1165 | - WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
|
| 1166 | - AND item_id = '".(int)$comment_id."' |
|
| 1165 | + WHERE c_id = $course_id AND blog_id = '".(int) $blog_id."' |
|
| 1166 | + AND item_id = '".(int) $comment_id."' |
|
| 1167 | 1167 | AND rating_type = '".Database::escape_string($type)."' |
| 1168 | - AND user_id = '".(int)$_user['user_id']."'"; |
|
| 1168 | + AND user_id = '".(int) $_user['user_id']."'"; |
|
| 1169 | 1169 | $result = Database::query($sql); |
| 1170 | 1170 | |
| 1171 | 1171 | if (Database::num_rows($result) == 0) { |
| 1172 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
| 1172 | + return ' - '.get_lang('RateThis').': <form method="get" action="blog.php" style="display: inline" id="frm_rating_'.$type.'_'.$comment_id.'" name="frm_rating_'.$type.'_'.$comment_id.'"><select name="rating" onchange="document.forms[\'frm_rating_'.$type.'_'.$comment_id.'\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="'.$type.'" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="'.$blog_id.'" /><input type="hidden" name="post_id" value="'.$post_id.'" /><input type="hidden" name="comment_id" value="'.$comment_id.'" /></form>'; |
|
| 1173 | 1173 | } else { |
| 1174 | 1174 | return ''; |
| 1175 | 1175 | } |
@@ -1204,11 +1204,11 @@ discard block |
||
| 1204 | 1204 | WHERE |
| 1205 | 1205 | comments.c_id = $course_id AND |
| 1206 | 1206 | parent_comment_id = $current AND |
| 1207 | - comments.blog_id = '".(int)$blog_id."' AND |
|
| 1208 | - comments.post_id = '".(int)$post_id."'"; |
|
| 1207 | + comments.blog_id = '".(int) $blog_id."' AND |
|
| 1208 | + comments.post_id = '".(int) $post_id."'"; |
|
| 1209 | 1209 | $result = Database::query($sql); |
| 1210 | 1210 | |
| 1211 | - while($comment = Database::fetch_array($result)) { |
|
| 1211 | + while ($comment = Database::fetch_array($result)) { |
|
| 1212 | 1212 | // Select the children recursivly |
| 1213 | 1213 | $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
| 1214 | 1214 | FROM $tbl_blogs_comments comments |
@@ -1217,8 +1217,8 @@ discard block |
||
| 1217 | 1217 | WHERE |
| 1218 | 1218 | comments.c_id = $course_id AND |
| 1219 | 1219 | comment_id = $current |
| 1220 | - AND blog_id = '".(int)$blog_id."' |
|
| 1221 | - AND post_id = '".(int)$post_id."'"; |
|
| 1220 | + AND blog_id = '".(int) $blog_id."' |
|
| 1221 | + AND post_id = '".(int) $post_id."'"; |
|
| 1222 | 1222 | $tmp = Database::query($tmp); |
| 1223 | 1223 | $tmp = Database::fetch_array($tmp); |
| 1224 | 1224 | $parent_cat = $tmp['parent_comment_id']; |
@@ -1243,22 +1243,22 @@ discard block |
||
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | if (!is_null($comment['task_id'])) { |
| 1246 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
| 1246 | + $border_color = ' border-left: 3px solid #'.$comment['color']; |
|
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | $comment_text = stripslashes($comment_text); |
| 1250 | 1250 | |
| 1251 | 1251 | // Output... |
| 1252 | 1252 | $margin = $current_level * 30; |
| 1253 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
| 1254 | - echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
| 1255 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
| 1256 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
| 1253 | + echo '<div class="blogpost_comment" style="margin-left: '.$margin.'px;'.$border_color.'">'; |
|
| 1254 | + echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\''.$comment['comment_id'].'\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']).'\'" title="'.get_lang('ReplyToThisComment').'" >'.stripslashes($comment['title']).'</a></span>'; |
|
| 1255 | + echo '<span class="blogpost_comment_date">'.$blog_comment_date.'</span>'; |
|
| 1256 | + echo '<span class="blogpost_text">'.$comment_text.'</span>'; |
|
| 1257 | 1257 | |
| 1258 | - $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
| 1258 | + $file_name_array = get_blog_attachment($blog_id, $post_id, $comment['comment_id']); |
|
| 1259 | 1259 | if (!empty($file_name_array)) { |
| 1260 | 1260 | echo '<br /><br />'; |
| 1261 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
| 1261 | + echo Display::return_icon('attachment.gif', get_lang('Attachment')); |
|
| 1262 | 1262 | echo '<a href="download.php?file='; |
| 1263 | 1263 | echo $file_name_array['path']; |
| 1264 | 1264 | echo ' "> '.$file_name_array['filename'].' </a>'; |
@@ -1268,7 +1268,7 @@ discard block |
||
| 1268 | 1268 | } |
| 1269 | 1269 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
| 1270 | 1270 | echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
| 1271 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
| 1271 | + echo '<span class="blogpost_actions">'.$blog_comment_actions.'</span>'; |
|
| 1272 | 1272 | echo '</div>'; |
| 1273 | 1273 | |
| 1274 | 1274 | // Go further down the tree. |
@@ -1284,11 +1284,11 @@ discard block |
||
| 1284 | 1284 | */ |
| 1285 | 1285 | public static function display_form_new_post($blog_id) |
| 1286 | 1286 | { |
| 1287 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1287 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) { |
|
| 1288 | 1288 | $form = new FormValidator( |
| 1289 | 1289 | 'add_post', |
| 1290 | 1290 | 'post', |
| 1291 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
| 1291 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=".$blog_id."&".api_get_cidreq(), |
|
| 1292 | 1292 | null, |
| 1293 | 1293 | array('enctype' => 'multipart/form-data') |
| 1294 | 1294 | ); |
@@ -1332,8 +1332,8 @@ discard block |
||
| 1332 | 1332 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1333 | 1333 | WHERE |
| 1334 | 1334 | post.c_id = $course_id AND |
| 1335 | - post.blog_id = '".(int)$blog_id ."' |
|
| 1336 | - AND post.post_id = '".(int)$post_id."' |
|
| 1335 | + post.blog_id = '".(int) $blog_id."' |
|
| 1336 | + AND post.post_id = '".(int) $post_id."' |
|
| 1337 | 1337 | ORDER BY post_id DESC"; |
| 1338 | 1338 | $result = Database::query($sql); |
| 1339 | 1339 | $blog_post = Database::fetch_array($result); |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | $form = new FormValidator( |
| 1343 | 1343 | 'edit_post', |
| 1344 | 1344 | 'post', |
| 1345 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1345 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id='.intval($_GET['post_id']).'&blog_id='.intval($blog_id).'&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
| 1346 | 1346 | ); |
| 1347 | 1347 | |
| 1348 | 1348 | $form->addHeader(get_lang('EditPost')); |
@@ -1374,31 +1374,31 @@ discard block |
||
| 1374 | 1374 | global $charset; |
| 1375 | 1375 | $course_id = api_get_course_int_id(); |
| 1376 | 1376 | |
| 1377 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
| 1377 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add')) { |
|
| 1378 | 1378 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 1379 | 1379 | $counter = 0; |
| 1380 | 1380 | global $color2; |
| 1381 | 1381 | |
| 1382 | 1382 | echo '<div class="actions">'; |
| 1383 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
| 1383 | + echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=add">'; |
|
| 1384 | 1384 | echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks')); |
| 1385 | - echo get_lang('AddTasks') . '</a> '; |
|
| 1386 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
| 1385 | + echo get_lang('AddTasks').'</a> '; |
|
| 1386 | + echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$blog_id.'&do=assign">'; |
|
| 1387 | 1387 | echo Display::return_icon('blog_task.gif', get_lang('AssignTasks')); |
| 1388 | - echo get_lang('AssignTasks') . '</a>'; |
|
| 1388 | + echo get_lang('AssignTasks').'</a>'; |
|
| 1389 | 1389 | ?> |
| 1390 | 1390 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"> |
| 1391 | - <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
|
| 1391 | + <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'), '', ICON_SIZE_SMALL).get_lang('RightsManager') ?></a> |
|
| 1392 | 1392 | <?php |
| 1393 | 1393 | echo '</div>'; |
| 1394 | 1394 | |
| 1395 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
| 1395 | + echo '<span class="blogpost_title">'.get_lang('TaskList').'</span><br />'; |
|
| 1396 | 1396 | echo "<table class=\"data_table\">"; |
| 1397 | 1397 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
| 1398 | - "<th width='240'><b>",get_lang('Title'),"</b></th>\n", |
|
| 1399 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
| 1400 | - "<th><b>",get_lang('Color'),"</b></th>\n", |
|
| 1401 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
| 1398 | + "<th width='240'><b>", get_lang('Title'), "</b></th>\n", |
|
| 1399 | + "<th><b>", get_lang('Description'), "</b></th>\n", |
|
| 1400 | + "<th><b>", get_lang('Color'), "</b></th>\n", |
|
| 1401 | + "<th width='50'><b>", get_lang('Modify'), "</b></th>\n", |
|
| 1402 | 1402 | "</tr>\n"; |
| 1403 | 1403 | |
| 1404 | 1404 | |
@@ -1410,31 +1410,31 @@ discard block |
||
| 1410 | 1410 | description, |
| 1411 | 1411 | color, |
| 1412 | 1412 | system_task |
| 1413 | - FROM " . $tbl_blogs_tasks . " |
|
| 1414 | - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
|
| 1413 | + FROM " . $tbl_blogs_tasks." |
|
| 1414 | + WHERE c_id = $course_id AND blog_id = ".(int) $blog_id." |
|
| 1415 | 1415 | ORDER BY system_task, title"; |
| 1416 | 1416 | $result = Database::query($sql); |
| 1417 | 1417 | |
| 1418 | 1418 | |
| 1419 | - while($task = Database::fetch_array($result)) { |
|
| 1419 | + while ($task = Database::fetch_array($result)) { |
|
| 1420 | 1420 | $counter++; |
| 1421 | 1421 | $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
| 1422 | 1422 | $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
| 1423 | 1423 | $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
| 1424 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
| 1425 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1424 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=delete&task_id='.$task['task_id']; |
|
| 1425 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
| 1426 | 1426 | |
| 1427 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
| 1428 | - '<td width="240">' . Security::remove_XSS($task['title']) . '</td>', |
|
| 1429 | - '<td>' . Security::remove_XSS($task['description']) . '</td>', |
|
| 1430 | - '<td><span style="background-color: #' . $task['color'] . '"> </span></td>', |
|
| 1427 | + echo '<tr class="'.$css_class.'" valign="top">', |
|
| 1428 | + '<td width="240">'.Security::remove_XSS($task['title']).'</td>', |
|
| 1429 | + '<td>'.Security::remove_XSS($task['description']).'</td>', |
|
| 1430 | + '<td><span style="background-color: #'.$task['color'].'"> </span></td>', |
|
| 1431 | 1431 | '<td width="50">', |
| 1432 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">', |
|
| 1433 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
| 1432 | + '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">', |
|
| 1433 | + '<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />', |
|
| 1434 | 1434 | "</a>\n", |
| 1435 | - '<a href="' . $delete_link . '"', |
|
| 1435 | + '<a href="'.$delete_link.'"', |
|
| 1436 | 1436 | $delete_confirm, |
| 1437 | - '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
| 1437 | + '><img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />', |
|
| 1438 | 1438 | "</a>\n", |
| 1439 | 1439 | '</td>', |
| 1440 | 1440 | '</tr>'; |
@@ -1449,23 +1449,23 @@ discard block |
||
| 1449 | 1449 | * |
| 1450 | 1450 | * @param Integer $blog_id |
| 1451 | 1451 | */ |
| 1452 | - public static function display_assigned_task_list ($blog_id) |
|
| 1452 | + public static function display_assigned_task_list($blog_id) |
|
| 1453 | 1453 | { |
| 1454 | 1454 | // Init |
| 1455 | 1455 | $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
| 1456 | 1456 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 1457 | 1457 | $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
| 1458 | 1458 | $counter = 0; |
| 1459 | - global $charset,$color2; |
|
| 1459 | + global $charset, $color2; |
|
| 1460 | 1460 | |
| 1461 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
| 1461 | + echo '<span class="blogpost_title">'.get_lang('AssignedTasks').'</span><br />'; |
|
| 1462 | 1462 | echo "<table class=\"data_table\">"; |
| 1463 | 1463 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
| 1464 | - "<th width='240'><b>",get_lang('Member'),"</b></th>\n", |
|
| 1465 | - "<th><b>",get_lang('Task'),"</b></th>\n", |
|
| 1466 | - "<th><b>",get_lang('Description'),"</b></th>\n", |
|
| 1467 | - "<th><b>",get_lang('TargetDate'),"</b></th>\n", |
|
| 1468 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>\n", |
|
| 1464 | + "<th width='240'><b>", get_lang('Member'), "</b></th>\n", |
|
| 1465 | + "<th><b>", get_lang('Task'), "</b></th>\n", |
|
| 1466 | + "<th><b>", get_lang('Description'), "</b></th>\n", |
|
| 1467 | + "<th><b>", get_lang('TargetDate'), "</b></th>\n", |
|
| 1468 | + "<th width='50'><b>", get_lang('Modify'), "</b></th>\n", |
|
| 1469 | 1469 | "</tr>"; |
| 1470 | 1470 | |
| 1471 | 1471 | $course_id = api_get_course_int_id(); |
@@ -1477,32 +1477,32 @@ discard block |
||
| 1477 | 1477 | WHERE |
| 1478 | 1478 | task_rel_user.c_id = $course_id AND |
| 1479 | 1479 | task.c_id = $course_id AND |
| 1480 | - task_rel_user.blog_id = '".(int)$blog_id."' |
|
| 1480 | + task_rel_user.blog_id = '".(int) $blog_id."' |
|
| 1481 | 1481 | ORDER BY target_date ASC"; |
| 1482 | 1482 | $result = Database::query($sql); |
| 1483 | 1483 | |
| 1484 | 1484 | while ($assignment = Database::fetch_array($result)) { |
| 1485 | 1485 | $counter++; |
| 1486 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
| 1486 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
| 1487 | 1487 | $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif"; |
| 1488 | 1488 | $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
| 1489 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
| 1490 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
| 1489 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete&task_id='.$assignment['task_id']; |
|
| 1490 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
| 1491 | 1491 | |
| 1492 | 1492 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
| 1493 | 1493 | |
| 1494 | - echo '<tr class="' . $css_class . '" valign="top">', |
|
| 1495 | - '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>', |
|
| 1496 | - '<td>'.stripslashes($assignment['title']) . '</td>', |
|
| 1497 | - '<td>'.stripslashes($assignment['description']) . '</td>', |
|
| 1498 | - '<td>' . $assignment['target_date'] . '</td>', |
|
| 1494 | + echo '<tr class="'.$css_class.'" valign="top">', |
|
| 1495 | + '<td width="240">'.Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)).'</td>', |
|
| 1496 | + '<td>'.stripslashes($assignment['title']).'</td>', |
|
| 1497 | + '<td>'.stripslashes($assignment['description']).'</td>', |
|
| 1498 | + '<td>'.$assignment['target_date'].'</td>', |
|
| 1499 | 1499 | '<td width="50">', |
| 1500 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">', |
|
| 1501 | - '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />', |
|
| 1500 | + '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">', |
|
| 1501 | + '<img src="../img/edit.gif" border="0" title="'.get_lang('EditTask').'" />', |
|
| 1502 | 1502 | "</a>\n", |
| 1503 | - '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ', |
|
| 1504 | - 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"', |
|
| 1505 | - '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />', |
|
| 1503 | + '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" ', |
|
| 1504 | + 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"', |
|
| 1505 | + '<img src="../img/'.$delete_icon.'" border="0" title="'.$delete_title.'" />', |
|
| 1506 | 1506 | "</a>\n", |
| 1507 | 1507 | '</td>', |
| 1508 | 1508 | '</tr>'; |
@@ -1515,7 +1515,7 @@ discard block |
||
| 1515 | 1515 | * @author Toon Keppens |
| 1516 | 1516 | * |
| 1517 | 1517 | */ |
| 1518 | - public static function display_new_task_form ($blog_id) |
|
| 1518 | + public static function display_new_task_form($blog_id) |
|
| 1519 | 1519 | { |
| 1520 | 1520 | // Init |
| 1521 | 1521 | $colors = array( |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | ); |
| 1538 | 1538 | |
| 1539 | 1539 | // form |
| 1540 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
| 1540 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'">'; |
|
| 1541 | 1541 | |
| 1542 | 1542 | // form title |
| 1543 | 1543 | echo '<legend>'.get_lang('AddTask').'</legend>'; |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | // task title |
| 1546 | 1546 | echo ' <div class="control-group"> |
| 1547 | 1547 | <label class="control-label"> |
| 1548 | - <span class="form_required">*</span>' . get_lang('Title') . ' |
|
| 1548 | + <span class="form_required">*</span>' . get_lang('Title').' |
|
| 1549 | 1549 | </label> |
| 1550 | 1550 | <div class="controls"> |
| 1551 | 1551 | <input name="task_name" type="text" size="70" /> |
@@ -1555,7 +1555,7 @@ discard block |
||
| 1555 | 1555 | // task comment |
| 1556 | 1556 | echo ' <div class="control-group"> |
| 1557 | 1557 | <label class="control-label"> |
| 1558 | - ' . get_lang('Description') . ' |
|
| 1558 | + ' . get_lang('Description').' |
|
| 1559 | 1559 | </label> |
| 1560 | 1560 | <div class="controls"> |
| 1561 | 1561 | <textarea name="task_description" cols="45"></textarea> |
@@ -1565,18 +1565,18 @@ discard block |
||
| 1565 | 1565 | // task management |
| 1566 | 1566 | echo ' <div class="control-group"> |
| 1567 | 1567 | <label class="control-label"> |
| 1568 | - ' . get_lang('TaskManager') . ' |
|
| 1568 | + ' . get_lang('TaskManager').' |
|
| 1569 | 1569 | </label> |
| 1570 | 1570 | <div class="controls">'; |
| 1571 | 1571 | echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
| 1572 | 1572 | echo '<tr>'; |
| 1573 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1574 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1573 | + echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>'; |
|
| 1574 | + echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
| 1575 | 1575 | echo '</tr>'; |
| 1576 | 1576 | echo '<tr>'; |
| 1577 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1578 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1579 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1577 | + echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1578 | + echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>'; |
|
| 1579 | + echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1580 | 1580 | echo '</tr>'; |
| 1581 | 1581 | echo '<tr>'; |
| 1582 | 1582 | echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
@@ -1591,13 +1591,13 @@ discard block |
||
| 1591 | 1591 | // task color |
| 1592 | 1592 | echo ' <div class="control-group"> |
| 1593 | 1593 | <label class="control-label"> |
| 1594 | - ' . get_lang('Color') . ' |
|
| 1594 | + ' . get_lang('Color').' |
|
| 1595 | 1595 | </label> |
| 1596 | 1596 | <div class="controls">'; |
| 1597 | 1597 | echo '<select name="task_color" id="color" style="width: 150px; background-color: #eeeeee" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
| 1598 | 1598 | foreach ($colors as $color) { |
| 1599 | - $style = 'style="background-color: #' . $color . '"'; |
|
| 1600 | - echo '<option value="' . $color . '" ' . $style . '> </option>'; |
|
| 1599 | + $style = 'style="background-color: #'.$color.'"'; |
|
| 1600 | + echo '<option value="'.$color.'" '.$style.'> </option>'; |
|
| 1601 | 1601 | } |
| 1602 | 1602 | echo '</select>'; |
| 1603 | 1603 | echo ' </div> |
@@ -1608,7 +1608,7 @@ discard block |
||
| 1608 | 1608 | <div class="controls"> |
| 1609 | 1609 | <input type="hidden" name="action" value="" /> |
| 1610 | 1610 | <input type="hidden" name="new_task_submit" value="true" /> |
| 1611 | - <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
|
| 1611 | + <button class="save" type="submit" name="Submit">' . get_lang('Save').'</button> |
|
| 1612 | 1612 | </div> |
| 1613 | 1613 | </div>'; |
| 1614 | 1614 | echo '</form>'; |
@@ -1622,34 +1622,34 @@ discard block |
||
| 1622 | 1622 | * @author Toon Keppens |
| 1623 | 1623 | * |
| 1624 | 1624 | */ |
| 1625 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
| 1625 | + public static function display_edit_task_form($blog_id, $task_id) { |
|
| 1626 | 1626 | $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 1627 | 1627 | $course_id = api_get_course_int_id(); |
| 1628 | 1628 | |
| 1629 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
| 1629 | + $colors = array('FFFFFF', 'FFFF99', 'FFCC99', 'FF9933', 'FF6699', 'CCFF99', 'CC9966', '66FF00', '9966FF', 'CF3F3F', '990033', '669933', '0033FF', '003366', '000000'); |
|
| 1630 | 1630 | |
| 1631 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
| 1631 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
| 1632 | 1632 | $result = Database::query($sql); |
| 1633 | 1633 | $task = Database::fetch_array($result); |
| 1634 | 1634 | |
| 1635 | 1635 | // Display |
| 1636 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
| 1637 | - <legend>' . get_lang('EditTask') . '</legend> |
|
| 1636 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id='.$blog_id.'"> |
|
| 1637 | + <legend>' . get_lang('EditTask').'</legend> |
|
| 1638 | 1638 | <table width="100%" border="0" cellspacing="2"> |
| 1639 | 1639 | <tr> |
| 1640 | - <td align="right">' . get_lang('Title') . ': </td> |
|
| 1641 | - <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']) . '" /></td> |
|
| 1640 | + <td align="right">' . get_lang('Title').': </td> |
|
| 1641 | + <td><input name="task_name" type="text" size="70" value="'.Security::remove_XSS($task['title']).'" /></td> |
|
| 1642 | 1642 | </tr> |
| 1643 | 1643 | <tr> |
| 1644 | - <td align="right">' . get_lang('Description') . ': </td> |
|
| 1644 | + <td align="right">' . get_lang('Description').': </td> |
|
| 1645 | 1645 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
| 1646 | 1646 | </tr>'; |
| 1647 | 1647 | |
| 1648 | 1648 | /* edit by Kevin Van Den Haute ([email protected]) */ |
| 1649 | 1649 | $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
| 1650 | 1650 | |
| 1651 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
| 1652 | - WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
|
| 1651 | + $sql = " SELECT id, action FROM ".$tbl_tasks_permissions." |
|
| 1652 | + WHERE c_id = $course_id AND task_id = '".(int) $task_id."'"; |
|
| 1653 | 1653 | $result = Database::query($sql); |
| 1654 | 1654 | |
| 1655 | 1655 | $arrPermissions = array(); |
@@ -1658,22 +1658,22 @@ discard block |
||
| 1658 | 1658 | $arrPermissions[] = $row['action']; |
| 1659 | 1659 | |
| 1660 | 1660 | echo '<tr>'; |
| 1661 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
| 1661 | + echo '<td style="text-align:right; vertical-align:top;">'.get_lang('TaskManager').': </td>'; |
|
| 1662 | 1662 | echo '<td>'; |
| 1663 | 1663 | echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
| 1664 | 1664 | echo '<tr>'; |
| 1665 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
| 1666 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
| 1665 | + echo '<th colspan="2" style="width:223px;">'.get_lang('ArticleManager').'</th>'; |
|
| 1666 | + echo '<th width:223px;>'.get_lang('CommentManager').'</th>'; |
|
| 1667 | 1667 | echo '</tr>'; |
| 1668 | 1668 | echo '<tr>'; |
| 1669 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1670 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
| 1671 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
| 1669 | + echo '<th style="width:111px;"><label for="articleDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1670 | + echo '<th style="width:112px;"><label for="articleEdit">'.get_lang('Edit').'</label></th>'; |
|
| 1671 | + echo '<th style="width:223px;"><label for="commentsDelete">'.get_lang('Delete').'</label></th>'; |
|
| 1672 | 1672 | echo '</tr>'; |
| 1673 | 1673 | echo '<tr>'; |
| 1674 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1675 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1676 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1674 | + echo '<td style="text-align:center;"><input '.((in_array('article_delete', $arrPermissions)) ? 'checked ' : '').'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
| 1675 | + echo '<td style="text-align:center;"><input '.((in_array('article_edit', $arrPermissions)) ? 'checked ' : '').'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
| 1676 | + echo '<td style="text-align:center;"><input '.((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '').'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
| 1677 | 1677 | echo '</tr>'; |
| 1678 | 1678 | echo '</table>'; |
| 1679 | 1679 | echo '</td>'; |
@@ -1681,13 +1681,13 @@ discard block |
||
| 1681 | 1681 | /* end of edit */ |
| 1682 | 1682 | |
| 1683 | 1683 | echo '<tr> |
| 1684 | - <td align="right">' . get_lang('Color') . ': </td> |
|
| 1684 | + <td align="right">' . get_lang('Color').': </td> |
|
| 1685 | 1685 | <td> |
| 1686 | - <select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
|
| 1686 | + <select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'].'" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
|
| 1687 | 1687 | foreach ($colors as $color) { |
| 1688 | 1688 | $selected = ($color == $task['color']) ? ' selected' : ''; |
| 1689 | - $style = 'style="background-color: #' . $color . '"'; |
|
| 1690 | - echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
|
| 1689 | + $style = 'style="background-color: #'.$color.'"'; |
|
| 1690 | + echo '<option value="'.$color.'" '.$style.' '.$selected.' > </option>'; |
|
| 1691 | 1691 | } |
| 1692 | 1692 | echo ' </select> |
| 1693 | 1693 | </td> |
@@ -1696,9 +1696,9 @@ discard block |
||
| 1696 | 1696 | <td align="right"> </td> |
| 1697 | 1697 | <td><br /><input type="hidden" name="action" value="" /> |
| 1698 | 1698 | <input type="hidden" name="edit_task_submit" value="true" /> |
| 1699 | - <input type="hidden" name="task_id" value="' . $task['task_id'] . '" /> |
|
| 1700 | - <input type="hidden" name="blog_id" value="' . $task['blog_id'] . '" /> |
|
| 1701 | - <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button></td> |
|
| 1699 | + <input type="hidden" name="task_id" value="' . $task['task_id'].'" /> |
|
| 1700 | + <input type="hidden" name="blog_id" value="' . $task['blog_id'].'" /> |
|
| 1701 | + <button class="save" type="submit" name="Submit">' . get_lang('Save').'</button></td> |
|
| 1702 | 1702 | </tr> |
| 1703 | 1703 | </table> |
| 1704 | 1704 | </form>'; |
@@ -1720,7 +1720,7 @@ discard block |
||
| 1720 | 1720 | FROM $tbl_users user |
| 1721 | 1721 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 1722 | 1722 | ON user.user_id = blogs_rel_user.user_id |
| 1723 | - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
|
| 1723 | + WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
| 1724 | 1724 | $result = Database::query($sql); |
| 1725 | 1725 | |
| 1726 | 1726 | $options = array(); |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | color, |
| 1740 | 1740 | system_task |
| 1741 | 1741 | FROM $tbl_blogs_tasks |
| 1742 | - WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
|
| 1742 | + WHERE c_id = $course_id AND blog_id = ".(int) $blog_id." |
|
| 1743 | 1743 | ORDER BY system_task, title"; |
| 1744 | 1744 | $result = Database::query($sql); |
| 1745 | 1745 | |
@@ -1787,7 +1787,7 @@ discard block |
||
| 1787 | 1787 | */ |
| 1788 | 1788 | public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
| 1789 | 1789 | { |
| 1790 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1790 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
| 1791 | 1791 | |
| 1792 | 1792 | $course_id = api_get_course_int_id(); |
| 1793 | 1793 | |
@@ -1796,9 +1796,9 @@ discard block |
||
| 1796 | 1796 | SELECT target_date |
| 1797 | 1797 | FROM $tbl_blogs_tasks_rel_user |
| 1798 | 1798 | WHERE c_id = $course_id AND |
| 1799 | - blog_id = '".(int)$blog_id."' AND |
|
| 1800 | - user_id = '".(int)$user_id."' AND |
|
| 1801 | - task_id = '".(int)$task_id."'"; |
|
| 1799 | + blog_id = '".(int) $blog_id."' AND |
|
| 1800 | + user_id = '".(int) $user_id."' AND |
|
| 1801 | + task_id = '".(int) $task_id."'"; |
|
| 1802 | 1802 | $result = Database::query($sql); |
| 1803 | 1803 | $row = Database::fetch_assoc($result); |
| 1804 | 1804 | |
@@ -1833,11 +1833,11 @@ discard block |
||
| 1833 | 1833 | |
| 1834 | 1834 | $sql = " |
| 1835 | 1835 | SELECT COUNT(*) as 'number' |
| 1836 | - FROM " . $tbl_blogs_tasks_rel_user . " |
|
| 1836 | + FROM " . $tbl_blogs_tasks_rel_user." |
|
| 1837 | 1837 | WHERE c_id = $course_id AND |
| 1838 | - blog_id = " . (int)$blog_id . " |
|
| 1839 | - AND user_id = " . (int)$user_id . " |
|
| 1840 | - AND task_id = " . (int)$task_id . " |
|
| 1838 | + blog_id = ".(int) $blog_id." |
|
| 1839 | + AND user_id = " . (int) $user_id." |
|
| 1840 | + AND task_id = " . (int) $task_id." |
|
| 1841 | 1841 | "; |
| 1842 | 1842 | |
| 1843 | 1843 | $result = Database::query($sql); |
@@ -1845,18 +1845,18 @@ discard block |
||
| 1845 | 1845 | |
| 1846 | 1846 | if ($row['number'] == 0) { |
| 1847 | 1847 | $sql = " |
| 1848 | - INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
|
| 1848 | + INSERT INTO " . $tbl_blogs_tasks_rel_user." ( |
|
| 1849 | 1849 | c_id, |
| 1850 | 1850 | blog_id, |
| 1851 | 1851 | user_id, |
| 1852 | 1852 | task_id, |
| 1853 | 1853 | target_date |
| 1854 | 1854 | ) VALUES ( |
| 1855 | - '" . (int)$course_id . "', |
|
| 1856 | - '" . (int)$blog_id . "', |
|
| 1857 | - '" . (int)$user_id . "', |
|
| 1858 | - '" . (int)$task_id . "', |
|
| 1859 | - '" . Database::escape_string($target_date) . "' |
|
| 1855 | + '" . (int) $course_id."', |
|
| 1856 | + '" . (int) $blog_id."', |
|
| 1857 | + '" . (int) $user_id."', |
|
| 1858 | + '" . (int) $task_id."', |
|
| 1859 | + '" . Database::escape_string($target_date)."' |
|
| 1860 | 1860 | )"; |
| 1861 | 1861 | |
| 1862 | 1862 | Database::query($sql); |
@@ -1886,12 +1886,12 @@ discard block |
||
| 1886 | 1886 | $course_id = api_get_course_int_id(); |
| 1887 | 1887 | |
| 1888 | 1888 | $sql = "SELECT COUNT(*) as 'number' |
| 1889 | - FROM " . $tbl_blogs_tasks_rel_user . " |
|
| 1889 | + FROM " . $tbl_blogs_tasks_rel_user." |
|
| 1890 | 1890 | WHERE |
| 1891 | 1891 | c_id = $course_id AND |
| 1892 | - blog_id = " . (int)$blog_id . " AND |
|
| 1893 | - user_id = " . (int)$user_id . " AND |
|
| 1894 | - task_id = " . (int)$task_id . " |
|
| 1892 | + blog_id = ".(int) $blog_id." AND |
|
| 1893 | + user_id = " . (int) $user_id." AND |
|
| 1894 | + task_id = " . (int) $task_id." |
|
| 1895 | 1895 | "; |
| 1896 | 1896 | |
| 1897 | 1897 | $result = Database::query($sql); |
@@ -1899,17 +1899,17 @@ discard block |
||
| 1899 | 1899 | |
| 1900 | 1900 | if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
| 1901 | 1901 | $sql = " |
| 1902 | - UPDATE " . $tbl_blogs_tasks_rel_user . " |
|
| 1902 | + UPDATE " . $tbl_blogs_tasks_rel_user." |
|
| 1903 | 1903 | SET |
| 1904 | - user_id = " . (int)$user_id . ", |
|
| 1905 | - task_id = " . (int)$task_id . ", |
|
| 1906 | - target_date = '" . Database::escape_string($target_date) . "' |
|
| 1904 | + user_id = " . (int) $user_id.", |
|
| 1905 | + task_id = " . (int) $task_id.", |
|
| 1906 | + target_date = '" . Database::escape_string($target_date)."' |
|
| 1907 | 1907 | WHERE |
| 1908 | 1908 | c_id = $course_id AND |
| 1909 | - blog_id = " . (int)$blog_id . " AND |
|
| 1910 | - user_id = " . (int)$old_user_id . " AND |
|
| 1911 | - task_id = " . (int)$old_task_id . " AND |
|
| 1912 | - target_date = '" . Database::escape_string($old_target_date) . "' |
|
| 1909 | + blog_id = ".(int) $blog_id." AND |
|
| 1910 | + user_id = " . (int) $old_user_id." AND |
|
| 1911 | + task_id = " . (int) $old_task_id." AND |
|
| 1912 | + target_date = '" . Database::escape_string($old_target_date)."' |
|
| 1913 | 1913 | "; |
| 1914 | 1914 | Database::query($sql); |
| 1915 | 1915 | } |
@@ -1930,7 +1930,7 @@ discard block |
||
| 1930 | 1930 | |
| 1931 | 1931 | |
| 1932 | 1932 | $sql = "SELECT title, description FROM $tbl_blogs_tasks |
| 1933 | - WHERE task_id = '".(int)$task_id."' |
|
| 1933 | + WHERE task_id = '".(int) $task_id."' |
|
| 1934 | 1934 | AND c_id = $course_id"; |
| 1935 | 1935 | $result = Database::query($sql); |
| 1936 | 1936 | $row = Database::fetch_assoc($result); |
@@ -1938,19 +1938,19 @@ discard block |
||
| 1938 | 1938 | $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
| 1939 | 1939 | FROM $tbl_blogs_posts post |
| 1940 | 1940 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
| 1941 | - WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
|
| 1941 | + WHERE post.blog_id = '".(int) $blog_id."' AND post.c_id = $course_id |
|
| 1942 | 1942 | ORDER BY post_id DESC |
| 1943 | 1943 | LIMIT 0, 100"; |
| 1944 | 1944 | $result = Database::query($sql); |
| 1945 | 1945 | |
| 1946 | 1946 | // Display |
| 1947 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
| 1948 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
| 1947 | + echo '<span class="blogpost_title">'.get_lang('SelectTaskArticle').' "'.stripslashes($row['title']).'"</span>'; |
|
| 1948 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']).'</span><br><br>'; |
|
| 1949 | 1949 | |
| 1950 | 1950 | if (Database::num_rows($result) > 0) { |
| 1951 | - while($blog_post = Database::fetch_array($result)) { |
|
| 1951 | + while ($blog_post = Database::fetch_array($result)) { |
|
| 1952 | 1952 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
| 1953 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
| 1953 | + echo '<a href="blog.php?action=execute_task&blog_id='.$blog_id.'&task_id='.$task_id.'&post_id='.$blog_post['post_id'].'#add_comment">'.stripslashes($blog_post['title']).'</a>, '.get_lang('WrittenBy').' '.stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))).'<br />'; |
|
| 1954 | 1954 | } |
| 1955 | 1955 | } else { |
| 1956 | 1956 | echo get_lang('NoArticles'); |
@@ -1974,12 +1974,12 @@ discard block |
||
| 1974 | 1974 | |
| 1975 | 1975 | // Subscribe the user |
| 1976 | 1976 | $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
| 1977 | - VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
|
| 1977 | + VALUES ($course_id, '".(int) $blog_id."', '".(int) $user_id."');"; |
|
| 1978 | 1978 | Database::query($sql); |
| 1979 | 1979 | |
| 1980 | 1980 | // Give this user basic rights |
| 1981 | 1981 | $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
| 1982 | - VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
|
| 1982 | + VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_add')"; |
|
| 1983 | 1983 | Database::query($sql); |
| 1984 | 1984 | |
| 1985 | 1985 | $id = Database::insert_id(); |
@@ -1989,7 +1989,7 @@ discard block |
||
| 1989 | 1989 | } |
| 1990 | 1990 | |
| 1991 | 1991 | $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
| 1992 | - VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
|
| 1992 | + VALUES ($course_id, '".(int) $user_id."','BLOG_".(int) $blog_id."','article_comments_add')"; |
|
| 1993 | 1993 | Database::query($sql); |
| 1994 | 1994 | |
| 1995 | 1995 | $id = Database::insert_id(); |
@@ -2015,12 +2015,12 @@ discard block |
||
| 2015 | 2015 | |
| 2016 | 2016 | // Unsubscribe the user |
| 2017 | 2017 | $sql = "DELETE FROM $tbl_blogs_rel_user |
| 2018 | - WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
|
| 2018 | + WHERE blog_id = '".(int) $blog_id."' AND user_id = '".(int) $user_id."'"; |
|
| 2019 | 2019 | Database::query($sql); |
| 2020 | 2020 | |
| 2021 | 2021 | // Remove this user's permissions. |
| 2022 | 2022 | $sql = "DELETE FROM $tbl_user_permissions |
| 2023 | - WHERE user_id = '".(int)$user_id."'"; |
|
| 2023 | + WHERE user_id = '".(int) $user_id."'"; |
|
| 2024 | 2024 | Database::query($sql); |
| 2025 | 2025 | } |
| 2026 | 2026 | |
@@ -2041,7 +2041,7 @@ discard block |
||
| 2041 | 2041 | $course_id = $_course['real_id']; |
| 2042 | 2042 | |
| 2043 | 2043 | $currentCourse = $_course['code']; |
| 2044 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2044 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
| 2045 | 2045 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
| 2046 | 2046 | |
| 2047 | 2047 | echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
@@ -2056,12 +2056,12 @@ discard block |
||
| 2056 | 2056 | $result = Database::query($sql); |
| 2057 | 2057 | |
| 2058 | 2058 | $blog_member_ids = array(); |
| 2059 | - while($user = Database::fetch_array($result)) { |
|
| 2059 | + while ($user = Database::fetch_array($result)) { |
|
| 2060 | 2060 | $blog_member_ids[] = $user['user_id']; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | 2063 | // Set table headers |
| 2064 | - $column_header[] = array ('', false, ''); |
|
| 2064 | + $column_header[] = array('', false, ''); |
|
| 2065 | 2065 | if ($is_western_name_order) { |
| 2066 | 2066 | $column_header[] = array(get_lang('FirstName'), true, ''); |
| 2067 | 2067 | $column_header[] = array(get_lang('LastName'), true, ''); |
@@ -2081,13 +2081,13 @@ discard block |
||
| 2081 | 2081 | |
| 2082 | 2082 | // Add users that are not in this blog to the list. |
| 2083 | 2083 | foreach ($student_list as $key=>$user) { |
| 2084 | - if(isset($user['id_user'])) { |
|
| 2084 | + if (isset($user['id_user'])) { |
|
| 2085 | 2085 | $user['user_id'] = $user['id_user']; |
| 2086 | 2086 | } |
| 2087 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
| 2087 | + if (!in_array($user['user_id'], $blog_member_ids)) { |
|
| 2088 | 2088 | $a_infosUser = api_get_user_info($user['user_id']); |
| 2089 | - $row = array (); |
|
| 2090 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2089 | + $row = array(); |
|
| 2090 | + $row[] = '<input type="checkbox" name="user[]" value="'.$a_infosUser['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '').'/>'; |
|
| 2091 | 2091 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
| 2092 | 2092 | if ($is_western_name_order) { |
| 2093 | 2093 | $row[] = $a_infosUser["firstname"]; |
@@ -2099,8 +2099,8 @@ discard block |
||
| 2099 | 2099 | $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
| 2100 | 2100 | |
| 2101 | 2101 | //Link to register users |
| 2102 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
| 2103 | - $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
| 2102 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']) { |
|
| 2103 | + $row[] = "<a class=\"btn btn-primary \" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=".$a_infosUser["user_id"]."\">".get_lang('Register')."</a>"; |
|
| 2104 | 2104 | } else { |
| 2105 | 2105 | $row[] = ''; |
| 2106 | 2106 | } |
@@ -2111,20 +2111,20 @@ discard block |
||
| 2111 | 2111 | // Display |
| 2112 | 2112 | $query_vars['action'] = 'manage_members'; |
| 2113 | 2113 | $query_vars['blog_id'] = $blog_id; |
| 2114 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2115 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2114 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">'; |
|
| 2115 | + Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); |
|
| 2116 | 2116 | $link = ''; |
| 2117 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
| 2117 | + $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : ''; |
|
| 2118 | 2118 | $link .= "blog_id=$blog_id&"; |
| 2119 | 2119 | |
| 2120 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2121 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2122 | - echo get_lang('WithSelected') . ' : '; |
|
| 2120 | + echo '<a href="blog.php?'.$link.'selectall=subscribe">'.get_lang('SelectAll').'</a> - '; |
|
| 2121 | + echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> '; |
|
| 2122 | + echo get_lang('WithSelected').' : '; |
|
| 2123 | 2123 | echo '<select name="action">'; |
| 2124 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
| 2124 | + echo '<option value="select_subscribe">'.get_lang('Register').'</option>'; |
|
| 2125 | 2125 | echo '</select>'; |
| 2126 | 2126 | echo '<input type="hidden" name="register" value="true" />'; |
| 2127 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2127 | + echo '<button class="save" type="submit">'.get_lang('Ok').'</button>'; |
|
| 2128 | 2128 | echo '</form>'; |
| 2129 | 2129 | } |
| 2130 | 2130 | |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | * |
| 2138 | 2138 | * @return Html Form with sortable table with users to unsubcribe from a blog. |
| 2139 | 2139 | */ |
| 2140 | - public static function display_form_user_unsubscribe ($blog_id) |
|
| 2140 | + public static function display_form_user_unsubscribe($blog_id) |
|
| 2141 | 2141 | { |
| 2142 | 2142 | $_user = api_get_user_info(); |
| 2143 | 2143 | $is_western_name_order = api_is_western_name_order(); |
@@ -2150,34 +2150,34 @@ discard block |
||
| 2150 | 2150 | |
| 2151 | 2151 | $properties["width"] = "100%"; |
| 2152 | 2152 | //table column titles |
| 2153 | - $column_header[] = array ('', false, ''); |
|
| 2153 | + $column_header[] = array('', false, ''); |
|
| 2154 | 2154 | if ($is_western_name_order) { |
| 2155 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2156 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2155 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2156 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2157 | 2157 | } else { |
| 2158 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
| 2159 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
| 2158 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
| 2159 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
| 2160 | 2160 | } |
| 2161 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
| 2162 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
| 2163 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
| 2161 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
| 2162 | + $column_header[] = array(get_lang('TaskManager'), true, ''); |
|
| 2163 | + $column_header[] = array(get_lang('UnRegister'), false, ''); |
|
| 2164 | 2164 | |
| 2165 | 2165 | $course_id = api_get_course_int_id(); |
| 2166 | 2166 | |
| 2167 | 2167 | $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
| 2168 | 2168 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
| 2169 | 2169 | ON user.user_id = blogs_rel_user.user_id |
| 2170 | - WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
|
| 2170 | + WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int) $blog_id."'"; |
|
| 2171 | 2171 | |
| 2172 | 2172 | if (!($sql_result = Database::query($sql))) { |
| 2173 | 2173 | return false; |
| 2174 | 2174 | } |
| 2175 | 2175 | |
| 2176 | - $user_data = array (); |
|
| 2176 | + $user_data = array(); |
|
| 2177 | 2177 | |
| 2178 | 2178 | while ($myrow = Database::fetch_array($sql_result)) { |
| 2179 | - $row = array (); |
|
| 2180 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
| 2179 | + $row = array(); |
|
| 2180 | + $row[] = '<input type="checkbox" name="user[]" value="'.$myrow['user_id'].'" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '').'/>'; |
|
| 2181 | 2181 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
| 2182 | 2182 | if ($is_western_name_order) { |
| 2183 | 2183 | $row[] = $myrow["firstname"]; |
@@ -2189,19 +2189,19 @@ discard block |
||
| 2189 | 2189 | $row[] = Display::icon_mailto_link($myrow["email"]); |
| 2190 | 2190 | |
| 2191 | 2191 | $sql = "SELECT bt.title task |
| 2192 | - FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
|
| 2193 | - INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
|
| 2192 | + FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." btu |
|
| 2193 | + INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS)." bt |
|
| 2194 | 2194 | ON btu.task_id = bt.task_id |
| 2195 | 2195 | WHERE btu.c_id = $course_id AND |
| 2196 | 2196 | bt.c_id = $course_id AND |
| 2197 | 2197 | btu.blog_id = $blog_id AND |
| 2198 | - btu.user_id = " . $myrow['user_id']; |
|
| 2198 | + btu.user_id = ".$myrow['user_id']; |
|
| 2199 | 2199 | $sql_res = Database::query($sql); |
| 2200 | 2200 | |
| 2201 | 2201 | $task = ''; |
| 2202 | 2202 | |
| 2203 | - while($r = Database::fetch_array($sql_res)) { |
|
| 2204 | - $task .= stripslashes($r['task']) . ', '; |
|
| 2203 | + while ($r = Database::fetch_array($sql_res)) { |
|
| 2204 | + $task .= stripslashes($r['task']).', '; |
|
| 2205 | 2205 | } |
| 2206 | 2206 | //echo $task; |
| 2207 | 2207 | $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
@@ -2209,7 +2209,7 @@ discard block |
||
| 2209 | 2209 | //Link to register users |
| 2210 | 2210 | |
| 2211 | 2211 | if ($myrow["user_id"] != $_user['user_id']) { |
| 2212 | - $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
| 2212 | + $row[] = "<a class=\"btn btn-primary\" href=\"".api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=".$myrow['user_id']."\">".get_lang('UnRegister')."</a>"; |
|
| 2213 | 2213 | } else { |
| 2214 | 2214 | $row[] = ''; |
| 2215 | 2215 | } |
@@ -2219,20 +2219,20 @@ discard block |
||
| 2219 | 2219 | |
| 2220 | 2220 | $query_vars['action'] = 'manage_members'; |
| 2221 | 2221 | $query_vars['blog_id'] = $blog_id; |
| 2222 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
| 2223 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
| 2222 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id='.$blog_id.'">'; |
|
| 2223 | + Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); |
|
| 2224 | 2224 | $link = ''; |
| 2225 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
| 2225 | + $link .= isset ($_GET['action']) ? 'action='.Security::remove_XSS($_GET['action']).'&' : ''; |
|
| 2226 | 2226 | $link .= "blog_id=$blog_id&"; |
| 2227 | 2227 | |
| 2228 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
| 2229 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
| 2230 | - echo get_lang('WithSelected') . ' : '; |
|
| 2228 | + echo '<a href="blog.php?'.$link.'selectall=unsubscribe">'.get_lang('SelectAll').'</a> - '; |
|
| 2229 | + echo '<a href="blog.php?'.$link.'">'.get_lang('UnSelectAll').'</a> '; |
|
| 2230 | + echo get_lang('WithSelected').' : '; |
|
| 2231 | 2231 | echo '<select name="action">'; |
| 2232 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
| 2232 | + echo '<option value="select_unsubscribe">'.get_lang('UnRegister').'</option>'; |
|
| 2233 | 2233 | echo '</select>'; |
| 2234 | 2234 | echo '<input type="hidden" name="unregister" value="true" />'; |
| 2235 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
| 2235 | + echo '<button class="save" type="submit">'.get_lang('Ok').'</button>'; |
|
| 2236 | 2236 | echo '</form>'; |
| 2237 | 2237 | } |
| 2238 | 2238 | |
@@ -2242,7 +2242,7 @@ discard block |
||
| 2242 | 2242 | * |
| 2243 | 2243 | * @param Integer $blog_id |
| 2244 | 2244 | */ |
| 2245 | - public static function display_form_user_rights ($blog_id) |
|
| 2245 | + public static function display_form_user_rights($blog_id) |
|
| 2246 | 2246 | { |
| 2247 | 2247 | echo '<legend>'.get_lang('RightsManager').'</legend>'; |
| 2248 | 2248 | echo '<br />'; |
@@ -2262,7 +2262,7 @@ discard block |
||
| 2262 | 2262 | $form = new FormValidator( |
| 2263 | 2263 | 'add_post', |
| 2264 | 2264 | 'post', |
| 2265 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
| 2265 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=".intval($blog_id)."&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
| 2266 | 2266 | null, |
| 2267 | 2267 | array('enctype' => 'multipart/form-data') |
| 2268 | 2268 | ); |
@@ -2330,21 +2330,21 @@ discard block |
||
| 2330 | 2330 | $course_id = api_get_course_int_id(); |
| 2331 | 2331 | |
| 2332 | 2332 | //Handle leap year |
| 2333 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2333 | + $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
| 2334 | 2334 | |
| 2335 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2335 | + if (($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2336 | 2336 | $numberofdays[2] = 29; |
| 2337 | 2337 | |
| 2338 | 2338 | //Get the first day of the month |
| 2339 | 2339 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
| 2340 | - $monthName = $MonthsLong[$month-1]; |
|
| 2340 | + $monthName = $MonthsLong[$month - 1]; |
|
| 2341 | 2341 | |
| 2342 | 2342 | //Start the week on monday |
| 2343 | 2343 | $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
| 2344 | 2344 | $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
| 2345 | 2345 | $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
| 2346 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
| 2347 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
| 2346 | + $backwardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 1 ? 12 : $month - 1)."&year=".($month == 1 ? $year - 1 : $year); |
|
| 2347 | + $forewardsURL = api_get_self()."?blog_id=".$blogId."&filter=".$filter."&month=".($month == 12 ? 1 : $month + 1)."&year=".($month == 12 ? $year + 1 : $year); |
|
| 2348 | 2348 | |
| 2349 | 2349 | // Get posts for this month |
| 2350 | 2350 | $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
@@ -2353,15 +2353,15 @@ discard block |
||
| 2353 | 2353 | ON post.author_id = user.user_id |
| 2354 | 2354 | WHERE |
| 2355 | 2355 | post.c_id = $course_id AND |
| 2356 | - post.blog_id = '".(int)$blog_id."' AND |
|
| 2357 | - MONTH(date_creation) = '".(int)$month."' AND |
|
| 2358 | - YEAR(date_creation) = '".(int)$year."' |
|
| 2356 | + post.blog_id = '".(int) $blog_id."' AND |
|
| 2357 | + MONTH(date_creation) = '".(int) $month."' AND |
|
| 2358 | + YEAR(date_creation) = '".(int) $year."' |
|
| 2359 | 2359 | ORDER BY date_creation"; |
| 2360 | 2360 | $result = Database::query($sql); |
| 2361 | 2361 | |
| 2362 | 2362 | // We will create an array of days on which there are posts. |
| 2363 | - if( Database::num_rows($result) > 0) { |
|
| 2364 | - while($blog_post = Database::fetch_array($result)) { |
|
| 2363 | + if (Database::num_rows($result) > 0) { |
|
| 2364 | + while ($blog_post = Database::fetch_array($result)) { |
|
| 2365 | 2365 | // If the day of this post is not yet in the array, add it. |
| 2366 | 2366 | if (!in_array($blog_post['post_day'], $posts)) |
| 2367 | 2367 | $posts[] = $blog_post['post_day']; |
@@ -2378,9 +2378,9 @@ discard block |
||
| 2378 | 2378 | task_rel_user.c_id = $course_id AND |
| 2379 | 2379 | task.c_id = $course_id AND |
| 2380 | 2380 | blog.c_id = $course_id AND |
| 2381 | - task_rel_user.user_id = '".(int)$_user['user_id']."' AND |
|
| 2382 | - MONTH(target_date) = '".(int)$month."' AND |
|
| 2383 | - YEAR(target_date) = '".(int)$year."' |
|
| 2381 | + task_rel_user.user_id = '".(int) $_user['user_id']."' AND |
|
| 2382 | + MONTH(target_date) = '".(int) $month."' AND |
|
| 2383 | + YEAR(target_date) = '".(int) $year."' |
|
| 2384 | 2384 | ORDER BY target_date ASC"; |
| 2385 | 2385 | $result = Database::query($sql); |
| 2386 | 2386 | |
@@ -2403,7 +2403,7 @@ discard block |
||
| 2403 | 2403 | |
| 2404 | 2404 | echo "<tr>\n"; |
| 2405 | 2405 | |
| 2406 | - for($ii = 1; $ii < 8; $ii ++) |
|
| 2406 | + for ($ii = 1; $ii < 8; $ii++) |
|
| 2407 | 2407 | echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
| 2408 | 2408 | |
| 2409 | 2409 | echo "</tr>"; |
@@ -2413,24 +2413,24 @@ discard block |
||
| 2413 | 2413 | |
| 2414 | 2414 | while ($curday <= $numberofdays[$month]) { |
| 2415 | 2415 | echo "<tr>"; |
| 2416 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
| 2416 | + for ($ii = 0; $ii < 7; $ii++) { |
|
| 2417 | 2417 | if (($curday == -1) && ($ii == $startdayofweek)) |
| 2418 | 2418 | $curday = 1; |
| 2419 | 2419 | |
| 2420 | 2420 | if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
| 2421 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
| 2421 | + $bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\""; |
|
| 2422 | 2422 | $dayheader = "$curday"; |
| 2423 | 2423 | |
| 2424 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2424 | + if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
| 2425 | 2425 | $dayheader = "$curday"; |
| 2426 | 2426 | $class = "class=\"days_today\""; |
| 2427 | 2427 | } |
| 2428 | 2428 | |
| 2429 | - echo "<td " . $class.">"; |
|
| 2429 | + echo "<td ".$class.">"; |
|
| 2430 | 2430 | |
| 2431 | 2431 | // If there are posts on this day, create a filter link. |
| 2432 | - if(in_array($curday, $posts)) |
|
| 2433 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2432 | + if (in_array($curday, $posts)) |
|
| 2433 | + echo '<a href="blog.php?blog_id='.$blog_id.'&filter='.$year.'-'.$month.'-'.$curday.'&month='.$month.'&year='.$year.'" title="'.get_lang('ViewPostsOfThisDay').'">'.$curday.'</a>'; |
|
| 2434 | 2434 | else |
| 2435 | 2435 | echo $dayheader; |
| 2436 | 2436 | |
@@ -2438,14 +2438,14 @@ discard block |
||
| 2438 | 2438 | if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
| 2439 | 2439 | // Add tasks to calendar |
| 2440 | 2440 | foreach ($tasks[$curday] as $task) { |
| 2441 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '"> |
|
| 2442 | - <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>'; |
|
| 2441 | + echo '<a href="blog.php?action=execute_task&blog_id='.$task['blog_id'].'&task_id='.stripslashes($task['task_id']).'" title="'.$task['title'].' : '.get_lang('InBlog').' : '.$task['blog_name'].' - '.get_lang('ExecuteThisTask').'"> |
|
| 2442 | + <img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask').'" /></a>'; |
|
| 2443 | 2443 | } |
| 2444 | 2444 | } |
| 2445 | 2445 | } |
| 2446 | 2446 | |
| 2447 | 2447 | echo "</td>"; |
| 2448 | - $curday ++; |
|
| 2448 | + $curday++; |
|
| 2449 | 2449 | } else |
| 2450 | 2450 | echo "<td> </td>"; |
| 2451 | 2451 | } |
@@ -2483,7 +2483,7 @@ discard block |
||
| 2483 | 2483 | public static function display_edit_blog_form($blog_id) |
| 2484 | 2484 | { |
| 2485 | 2485 | $course_id = api_get_course_int_id(); |
| 2486 | - $blog_id= intval($blog_id); |
|
| 2486 | + $blog_id = intval($blog_id); |
|
| 2487 | 2487 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 2488 | 2488 | |
| 2489 | 2489 | $sql = "SELECT blog_id, blog_name, blog_subtitle |
@@ -2498,7 +2498,7 @@ discard block |
||
| 2498 | 2498 | $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
| 2499 | 2499 | } |
| 2500 | 2500 | |
| 2501 | - $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
|
| 2501 | + $form = new FormValidator('edit_blog', 'post', 'blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
|
| 2502 | 2502 | $form->addElement('header', get_lang('EditBlog')); |
| 2503 | 2503 | $form->addElement('text', 'blog_name', get_lang('Title')); |
| 2504 | 2504 | $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle')); |
@@ -2535,8 +2535,8 @@ discard block |
||
| 2535 | 2535 | $result = Database::query($sql); |
| 2536 | 2536 | $list_info = array(); |
| 2537 | 2537 | if (Database::num_rows($result)) { |
| 2538 | - while ($row_project=Database::fetch_row($result)) { |
|
| 2539 | - $list_info[]=$row_project; |
|
| 2538 | + while ($row_project = Database::fetch_row($result)) { |
|
| 2539 | + $list_info[] = $row_project; |
|
| 2540 | 2540 | } |
| 2541 | 2541 | } |
| 2542 | 2542 | |
@@ -2548,39 +2548,39 @@ discard block |
||
| 2548 | 2548 | // Validation when belongs to a session |
| 2549 | 2549 | $session_img = api_get_session_image($info_log[4], $_user['status']); |
| 2550 | 2550 | |
| 2551 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
| 2551 | + $url_start_blog = 'blog.php'."?"."blog_id=".$info_log[3]."&".api_get_cidreq(); |
|
| 2552 | 2552 | $title = $info_log[0]; |
| 2553 | 2553 | $image = Display::return_icon('blog.png', $title); |
| 2554 | - $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
| 2554 | + $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">'.$image.'</a></div><a href="'.$url_start_blog.'">'.$title.'</a>'.$session_img; |
|
| 2555 | 2555 | |
| 2556 | 2556 | $list_body_blog[] = $list_name; |
| 2557 | 2557 | $list_body_blog[] = $info_log[1]; |
| 2558 | 2558 | |
| 2559 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
| 2560 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
| 2561 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
| 2562 | - $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
|
| 2559 | + $visibility_icon = ($info_log[2] == 0) ? 'invisible' : 'visible'; |
|
| 2560 | + $visibility_info = ($info_log[2] == 0) ? 'Visible' : 'Invisible'; |
|
| 2561 | + $my_image = '<a href="'.api_get_self().'?action=edit&blog_id='.$info_log[3].'">'; |
|
| 2562 | + $my_image .= Display::return_icon('edit.png', get_lang('EditBlog')); |
|
| 2563 | 2563 | |
| 2564 | - $my_image.= "</a>\n"; |
|
| 2565 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
| 2566 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
| 2567 | - $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
|
| 2564 | + $my_image .= "</a>\n"; |
|
| 2565 | + $my_image .= '<a href="'.api_get_self().'?action=delete&blog_id='.$info_log[3].'" '; |
|
| 2566 | + $my_image .= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;" >'; |
|
| 2567 | + $my_image .= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
|
| 2568 | 2568 | |
| 2569 | - $my_image.= "</a>\n"; |
|
| 2570 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
| 2571 | - $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
|
| 2569 | + $my_image .= "</a>\n"; |
|
| 2570 | + $my_image .= '<a href="'.api_get_self().'?action=visibility&blog_id='.$info_log[3].'">'; |
|
| 2571 | + $my_image .= Display::return_icon($visibility_icon.'.gif', get_lang($visibility_info)); |
|
| 2572 | 2572 | |
| 2573 | - $my_image.= "</a>\n"; |
|
| 2573 | + $my_image .= "</a>\n"; |
|
| 2574 | 2574 | |
| 2575 | - $list_body_blog[]=$my_image; |
|
| 2575 | + $list_body_blog[] = $my_image; |
|
| 2576 | 2576 | |
| 2577 | - $list_content_blog[]=$list_body_blog; |
|
| 2577 | + $list_content_blog[] = $list_body_blog; |
|
| 2578 | 2578 | $list_body_blog = array(); |
| 2579 | 2579 | |
| 2580 | 2580 | } |
| 2581 | - $parameters=''; |
|
| 2581 | + $parameters = ''; |
|
| 2582 | 2582 | //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); |
| 2583 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
| 2583 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project'); |
|
| 2584 | 2584 | //$table->set_additional_parameters($parameters); |
| 2585 | 2585 | $table->set_header(0, get_lang('Title')); |
| 2586 | 2586 | $table->set_header(1, get_lang('SubTitle')); |
@@ -2605,34 +2605,34 @@ discard block |
||
| 2605 | 2605 | * @author Julio Montoya Dokeos |
| 2606 | 2606 | * @version avril 2008, dokeos 1.8.5 |
| 2607 | 2607 | */ |
| 2608 | -function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
|
| 2608 | +function get_blog_attachment($blog_id, $post_id = null, $comment_id = null) |
|
| 2609 | 2609 | { |
| 2610 | 2610 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
| 2611 | 2611 | |
| 2612 | 2612 | $blog_id = intval($blog_id); |
| 2613 | 2613 | $comment_id = intval($comment_id); |
| 2614 | 2614 | $post_id = intval($post_id); |
| 2615 | - $row=array(); |
|
| 2616 | - $where=''; |
|
| 2615 | + $row = array(); |
|
| 2616 | + $where = ''; |
|
| 2617 | 2617 | if (!empty ($post_id) && is_numeric($post_id)) { |
| 2618 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
| 2618 | + $where .= ' AND post_id ="'.$post_id.'" '; |
|
| 2619 | 2619 | } |
| 2620 | 2620 | |
| 2621 | 2621 | if (!empty ($comment_id) && is_numeric($comment_id)) { |
| 2622 | 2622 | if (!empty ($post_id)) { |
| 2623 | - $where.= ' AND '; |
|
| 2623 | + $where .= ' AND '; |
|
| 2624 | 2624 | } |
| 2625 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
| 2625 | + $where .= ' comment_id ="'.$comment_id.'" '; |
|
| 2626 | 2626 | } |
| 2627 | 2627 | |
| 2628 | 2628 | $course_id = api_get_course_int_id(); |
| 2629 | 2629 | |
| 2630 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
| 2630 | + $sql = 'SELECT path, filename, comment FROM '.$blog_table_attachment.' |
|
| 2631 | 2631 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2632 | 2632 | |
| 2633 | - $result=Database::query($sql); |
|
| 2634 | - if (Database::num_rows($result)!=0) { |
|
| 2635 | - $row=Database::fetch_array($result); |
|
| 2633 | + $result = Database::query($sql); |
|
| 2634 | + if (Database::num_rows($result) != 0) { |
|
| 2635 | + $row = Database::fetch_array($result); |
|
| 2636 | 2636 | } |
| 2637 | 2637 | return $row; |
| 2638 | 2638 | } |
@@ -2646,7 +2646,7 @@ discard block |
||
| 2646 | 2646 | * @version avril 2008, dokeos 1.8.5 |
| 2647 | 2647 | */ |
| 2648 | 2648 | |
| 2649 | -function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
|
| 2649 | +function delete_all_blog_attachment($blog_id, $post_id = null, $comment_id = null) |
|
| 2650 | 2650 | { |
| 2651 | 2651 | $_course = api_get_course_info(); |
| 2652 | 2652 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
@@ -2670,22 +2670,22 @@ discard block |
||
| 2670 | 2670 | } |
| 2671 | 2671 | |
| 2672 | 2672 | // delete all files in directory |
| 2673 | - $courseDir = $_course['path'].'/upload/blog'; |
|
| 2673 | + $courseDir = $_course['path'].'/upload/blog'; |
|
| 2674 | 2674 | $sys_course_path = api_get_path(SYS_COURSE_PATH); |
| 2675 | 2675 | $updir = $sys_course_path.$courseDir; |
| 2676 | 2676 | |
| 2677 | 2677 | $sql = 'SELECT path FROM '.$blog_table_attachment.' |
| 2678 | 2678 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2679 | - $result=Database::query($sql); |
|
| 2679 | + $result = Database::query($sql); |
|
| 2680 | 2680 | |
| 2681 | - while ($row=Database::fetch_row($result)) { |
|
| 2682 | - $file=$updir.'/'.$row[0]; |
|
| 2683 | - if (Security::check_abs_path($file,$updir) ) |
|
| 2681 | + while ($row = Database::fetch_row($result)) { |
|
| 2682 | + $file = $updir.'/'.$row[0]; |
|
| 2683 | + if (Security::check_abs_path($file, $updir)) |
|
| 2684 | 2684 | { |
| 2685 | 2685 | @ unlink($file); |
| 2686 | 2686 | } |
| 2687 | 2687 | } |
| 2688 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
| 2688 | + $sql = 'DELETE FROM '.$blog_table_attachment.' |
|
| 2689 | 2689 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
| 2690 | 2690 | Database::query($sql); |
| 2691 | 2691 | } |
@@ -2698,8 +2698,8 @@ discard block |
||
| 2698 | 2698 | function get_blog_post_from_user($course_code, $user_id) |
| 2699 | 2699 | { |
| 2700 | 2700 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
| 2701 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2702 | - $course_info = api_get_course_info($course_code); |
|
| 2701 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
| 2702 | + $course_info = api_get_course_info($course_code); |
|
| 2703 | 2703 | $course_id = $course_info['real_id']; |
| 2704 | 2704 | |
| 2705 | 2705 | $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
@@ -2714,13 +2714,13 @@ discard block |
||
| 2714 | 2714 | $result = Database::query($sql); |
| 2715 | 2715 | $return_data = ''; |
| 2716 | 2716 | |
| 2717 | - if (Database::num_rows($result)!=0) { |
|
| 2718 | - while ($row=Database::fetch_array($result)) { |
|
| 2719 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2720 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2721 | - $return_data.= '<br / >'; |
|
| 2722 | - $return_data.= $row['full_text']; |
|
| 2723 | - $return_data.= '<br /><br />'; |
|
| 2717 | + if (Database::num_rows($result) != 0) { |
|
| 2718 | + while ($row = Database::fetch_array($result)) { |
|
| 2719 | + $return_data .= '<div class="clear"></div><br />'; |
|
| 2720 | + $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png', get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2721 | + $return_data .= '<br / >'; |
|
| 2722 | + $return_data .= $row['full_text']; |
|
| 2723 | + $return_data .= '<br /><br />'; |
|
| 2724 | 2724 | } |
| 2725 | 2725 | } |
| 2726 | 2726 | return $return_data; |
@@ -2750,14 +2750,14 @@ discard block |
||
| 2750 | 2750 | ORDER BY blog_name"; |
| 2751 | 2751 | $result = Database::query($sql); |
| 2752 | 2752 | $return_data = ''; |
| 2753 | - if (Database::num_rows($result)!=0) { |
|
| 2754 | - while ($row=Database::fetch_array($result)) { |
|
| 2755 | - $return_data.= '<div class="clear"></div><br />'; |
|
| 2756 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2757 | - $return_data.= '<br / >'; |
|
| 2753 | + if (Database::num_rows($result) != 0) { |
|
| 2754 | + while ($row = Database::fetch_array($result)) { |
|
| 2755 | + $return_data .= '<div class="clear"></div><br />'; |
|
| 2756 | + $return_data .= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
| 2757 | + $return_data .= '<br / >'; |
|
| 2758 | 2758 | //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
| 2759 | - $return_data.= $row['comment']; |
|
| 2760 | - $return_data.= '<br />'; |
|
| 2759 | + $return_data .= $row['comment']; |
|
| 2760 | + $return_data .= '<br />'; |
|
| 2761 | 2761 | } |
| 2762 | 2762 | } |
| 2763 | 2763 | return $return_data; |
@@ -1009,8 +1009,9 @@ discard block |
||
| 1009 | 1009 | $blog_post_actions .= '</a>'; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
| 1013 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1012 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) { |
|
| 1013 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
| 1014 | + } |
|
| 1014 | 1015 | |
| 1015 | 1016 | $blog_post_text=stripslashes($blog_post_text); |
| 1016 | 1017 | |
@@ -1654,8 +1655,9 @@ discard block |
||
| 1654 | 1655 | |
| 1655 | 1656 | $arrPermissions = array(); |
| 1656 | 1657 | |
| 1657 | - while ($row = Database::fetch_array($result)) |
|
| 1658 | - $arrPermissions[] = $row['action']; |
|
| 1658 | + while ($row = Database::fetch_array($result)) { |
|
| 1659 | + $arrPermissions[] = $row['action']; |
|
| 1660 | + } |
|
| 1659 | 1661 | |
| 1660 | 1662 | echo '<tr>'; |
| 1661 | 1663 | echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
@@ -2332,8 +2334,9 @@ discard block |
||
| 2332 | 2334 | //Handle leap year |
| 2333 | 2335 | $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
| 2334 | 2336 | |
| 2335 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
| 2336 | - $numberofdays[2] = 29; |
|
| 2337 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) { |
|
| 2338 | + $numberofdays[2] = 29; |
|
| 2339 | + } |
|
| 2337 | 2340 | |
| 2338 | 2341 | //Get the first day of the month |
| 2339 | 2342 | $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
@@ -2363,8 +2366,9 @@ discard block |
||
| 2363 | 2366 | if( Database::num_rows($result) > 0) { |
| 2364 | 2367 | while($blog_post = Database::fetch_array($result)) { |
| 2365 | 2368 | // If the day of this post is not yet in the array, add it. |
| 2366 | - if (!in_array($blog_post['post_day'], $posts)) |
|
| 2367 | - $posts[] = $blog_post['post_day']; |
|
| 2369 | + if (!in_array($blog_post['post_day'], $posts)) { |
|
| 2370 | + $posts[] = $blog_post['post_day']; |
|
| 2371 | + } |
|
| 2368 | 2372 | } |
| 2369 | 2373 | } |
| 2370 | 2374 | |
@@ -2403,8 +2407,9 @@ discard block |
||
| 2403 | 2407 | |
| 2404 | 2408 | echo "<tr>\n"; |
| 2405 | 2409 | |
| 2406 | - for($ii = 1; $ii < 8; $ii ++) |
|
| 2407 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
| 2410 | + for($ii = 1; $ii < 8; $ii ++) { |
|
| 2411 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
| 2412 | + } |
|
| 2408 | 2413 | |
| 2409 | 2414 | echo "</tr>"; |
| 2410 | 2415 | |
@@ -2414,8 +2419,9 @@ discard block |
||
| 2414 | 2419 | while ($curday <= $numberofdays[$month]) { |
| 2415 | 2420 | echo "<tr>"; |
| 2416 | 2421 | for ($ii = 0; $ii < 7; $ii ++) { |
| 2417 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
| 2418 | - $curday = 1; |
|
| 2422 | + if (($curday == -1) && ($ii == $startdayofweek)) { |
|
| 2423 | + $curday = 1; |
|
| 2424 | + } |
|
| 2419 | 2425 | |
| 2420 | 2426 | if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
| 2421 | 2427 | $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
@@ -2429,10 +2435,11 @@ discard block |
||
| 2429 | 2435 | echo "<td " . $class.">"; |
| 2430 | 2436 | |
| 2431 | 2437 | // If there are posts on this day, create a filter link. |
| 2432 | - if(in_array($curday, $posts)) |
|
| 2433 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2434 | - else |
|
| 2435 | - echo $dayheader; |
|
| 2438 | + if(in_array($curday, $posts)) { |
|
| 2439 | + echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
| 2440 | + } else { |
|
| 2441 | + echo $dayheader; |
|
| 2442 | + } |
|
| 2436 | 2443 | |
| 2437 | 2444 | if (count($tasks) > 0) { |
| 2438 | 2445 | if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
@@ -2446,8 +2453,9 @@ discard block |
||
| 2446 | 2453 | |
| 2447 | 2454 | echo "</td>"; |
| 2448 | 2455 | $curday ++; |
| 2449 | - } else |
|
| 2450 | - echo "<td> </td>"; |
|
| 2456 | + } else { |
|
| 2457 | + echo "<td> </td>"; |
|
| 2458 | + } |
|
| 2451 | 2459 | } |
| 2452 | 2460 | echo "</tr>"; |
| 2453 | 2461 | } |
@@ -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) |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Set user chat status |
|
| 43 | - * @param int 0 if disconnected, 1 if connected |
|
| 42 | + * Set user chat status |
|
| 43 | + * @param int 0 if disconnected, 1 if connected |
|
| 44 | 44 | * |
| 45 | - * @return void |
|
| 46 | - */ |
|
| 45 | + * @return void |
|
| 46 | + */ |
|
| 47 | 47 | public function setUserStatus($status) |
| 48 | 48 | { |
| 49 | 49 | UserManager::update_extra_field_value(api_get_user_id(), 'user_chat_status', $status); |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Returns an array of messages inside a chat session with a specific user |
|
| 151 | - * @param int The ID of the user with whom the current user is chatting |
|
| 152 | - * @return array Messages list |
|
| 153 | - */ |
|
| 150 | + * Returns an array of messages inside a chat session with a specific user |
|
| 151 | + * @param int The ID of the user with whom the current user is chatting |
|
| 152 | + * @return array Messages list |
|
| 153 | + */ |
|
| 154 | 154 | public function box_session($user_id) |
| 155 | 155 | { |
| 156 | 156 | $items = array(); |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - return false; |
|
| 300 | + return false; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | public function is_chat_blocked_by_exercises() |
@@ -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 | } |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | * @param int $status (optional) The user's status in the course |
| 717 | 717 | * @param int The user category in which this subscription will be classified |
| 718 | 718 | * |
| 719 | - * @return boolean true if subscription succeeds, boolean false otherwise. |
|
| 719 | + * @return false|string true if subscription succeeds, boolean false otherwise. |
|
| 720 | 720 | * @assert ('', '') === false |
| 721 | 721 | */ |
| 722 | 722 | public static function add_user_to_course($user_id, $courseCode, $status = STUDENT, $userCourseCategoryId = 0) |
@@ -788,7 +788,7 @@ discard block |
||
| 788 | 788 | * Checks wether a parameter exists. |
| 789 | 789 | * If it doesn't, the function displays an error message. |
| 790 | 790 | * |
| 791 | - * @return true if parameter is set and not empty, false otherwise |
|
| 791 | + * @return boolean if parameter is set and not empty, false otherwise |
|
| 792 | 792 | * @todo move function to better place, main_api ? |
| 793 | 793 | */ |
| 794 | 794 | public static function check_parameter($parameter, $error_message) |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | /** |
| 815 | - * @return true if there already are one or more courses |
|
| 815 | + * @return boolean if there already are one or more courses |
|
| 816 | 816 | * with the same code OR visual_code (visualcode), false otherwise |
| 817 | 817 | */ |
| 818 | 818 | public static function course_code_exists($wanted_course_code) |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | /** |
| 986 | 986 | * @param int $userId |
| 987 | 987 | * @param array $courseInfo |
| 988 | - * @return bool |
|
| 988 | + * @return boolean|null |
|
| 989 | 989 | */ |
| 990 | 990 | public static function isUserSubscribedInCourseAsDrh($userId, $courseInfo) |
| 991 | 991 | { |
@@ -1091,10 +1091,10 @@ discard block |
||
| 1091 | 1091 | /** |
| 1092 | 1092 | * Is the user a teacher in the given course? |
| 1093 | 1093 | * |
| 1094 | - * @param $user_id , the id (int) of the user |
|
| 1094 | + * @param integer $user_id , the id (int) of the user |
|
| 1095 | 1095 | * @param $course_code , the course code |
| 1096 | 1096 | * |
| 1097 | - * @return true if the user is a teacher in the course, false otherwise |
|
| 1097 | + * @return boolean if the user is a teacher in the course, false otherwise |
|
| 1098 | 1098 | */ |
| 1099 | 1099 | public static function is_course_teacher($user_id, $course_code) |
| 1100 | 1100 | { |
@@ -1123,7 +1123,7 @@ discard block |
||
| 1123 | 1123 | * @param int the id of the user |
| 1124 | 1124 | * @param int $courseId |
| 1125 | 1125 | * @deprecated linked_courses definition doesn't exists |
| 1126 | - * @return true if the user is registered in the real course or linked courses, false otherwise |
|
| 1126 | + * @return boolean if the user is registered in the real course or linked courses, false otherwise |
|
| 1127 | 1127 | */ |
| 1128 | 1128 | public static function is_user_subscribed_in_real_or_linked_course($user_id, $courseId, $session_id = '') |
| 1129 | 1129 | { |
@@ -1194,9 +1194,9 @@ discard block |
||
| 1194 | 1194 | * @param string $order_by the field to order the users by. |
| 1195 | 1195 | * Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement |
| 1196 | 1196 | * that starts with ORDER BY ... |
| 1197 | - * @param null $filter_by_status if using the session_id: 0 or 2 (student, coach), |
|
| 1197 | + * @param integer|null $filter_by_status if using the session_id: 0 or 2 (student, coach), |
|
| 1198 | 1198 | * if using session_id = 0 STUDENT or COURSEMANAGER |
| 1199 | - * @param null $return_count |
|
| 1199 | + * @param boolean|null $return_count |
|
| 1200 | 1200 | * @param bool $add_reports |
| 1201 | 1201 | * @param bool $resumed_report |
| 1202 | 1202 | * @param array $extra_field |
@@ -1943,7 +1943,7 @@ discard block |
||
| 1943 | 1943 | * @param int $courseId |
| 1944 | 1944 | * @param string $separator |
| 1945 | 1945 | * @param bool $add_link_to_profile |
| 1946 | - * @return null|string |
|
| 1946 | + * @return string |
|
| 1947 | 1947 | */ |
| 1948 | 1948 | public static function get_coachs_from_course_to_string( |
| 1949 | 1949 | $session_id = 0, |
@@ -2016,7 +2016,7 @@ discard block |
||
| 2016 | 2016 | * Get the list of groups from the course |
| 2017 | 2017 | * @param string $course_code |
| 2018 | 2018 | * @param int $session_id Session ID (optional) |
| 2019 | - * @param boolean $in_get_empty_group get empty groups (optional) |
|
| 2019 | + * @param integer $in_get_empty_group get empty groups (optional) |
|
| 2020 | 2020 | * @return array List of groups info |
| 2021 | 2021 | */ |
| 2022 | 2022 | public static function get_group_list_of_course($course_code, $session_id = 0, $in_get_empty_group = 0) |
@@ -2072,6 +2072,7 @@ discard block |
||
| 2072 | 2072 | * course. |
| 2073 | 2073 | * |
| 2074 | 2074 | * @param string The code of the course to delete |
| 2075 | + * @param string $code |
|
| 2075 | 2076 | * @todo When deleting a virtual course: unsubscribe users from that virtual |
| 2076 | 2077 | * course from the groups in the real course if they are not subscribed in |
| 2077 | 2078 | * that real course. |
@@ -2283,6 +2284,7 @@ discard block |
||
| 2283 | 2284 | * Sort courses for a specific user ?? |
| 2284 | 2285 | * @param int User ID |
| 2285 | 2286 | * @param string Course code |
| 2287 | + * @param integer $user_id |
|
| 2286 | 2288 | * @return int Minimum course order |
| 2287 | 2289 | * @todo Review documentation |
| 2288 | 2290 | */ |
@@ -2360,7 +2362,7 @@ discard block |
||
| 2360 | 2362 | * check if course exists |
| 2361 | 2363 | * @param string course_code |
| 2362 | 2364 | * @param string whether to accept virtual course codes or not |
| 2363 | - * @return true if exists, false else |
|
| 2365 | + * @return integer if exists, false else |
|
| 2364 | 2366 | */ |
| 2365 | 2367 | public static function course_exists($course_code, $accept_virtual = false) |
| 2366 | 2368 | { |
@@ -2379,9 +2381,9 @@ discard block |
||
| 2379 | 2381 | * Send an email to tutor after the auth-suscription of a student in your course |
| 2380 | 2382 | * @author Carlos Vargas <[email protected]>, Dokeos Latino |
| 2381 | 2383 | * @param int $user_id the id of the user |
| 2382 | - * @param string $course_code the course code |
|
| 2384 | + * @param string $courseId the course code |
|
| 2383 | 2385 | * @param bool $send_to_tutor_also |
| 2384 | - * @return string we return the message that is displayed when the action is successful |
|
| 2386 | + * @return false|null we return the message that is displayed when the action is successful |
|
| 2385 | 2387 | */ |
| 2386 | 2388 | public static function email_to_tutor($user_id, $courseId, $send_to_tutor_also = false) |
| 2387 | 2389 | { |
@@ -2624,6 +2626,7 @@ discard block |
||
| 2624 | 2626 | /** |
| 2625 | 2627 | * Get emails of tutors to course |
| 2626 | 2628 | * @param string Visual code |
| 2629 | + * @param integer $courseId |
|
| 2627 | 2630 | * @return array List of emails of tutors to course |
| 2628 | 2631 | * @author @author Carlos Vargas <[email protected]>, Dokeos Latino |
| 2629 | 2632 | * */ |
@@ -2647,6 +2650,7 @@ discard block |
||
| 2647 | 2650 | * Get coaches emails by session |
| 2648 | 2651 | * @param int session id |
| 2649 | 2652 | * @param int $courseId |
| 2653 | + * @param integer $session_id |
|
| 2650 | 2654 | * @return array array(email => name_tutor) by coach |
| 2651 | 2655 | * @author Carlos Vargas <[email protected]> |
| 2652 | 2656 | */ |
@@ -2695,7 +2699,9 @@ discard block |
||
| 2695 | 2699 | * @param string Field's internal variable name |
| 2696 | 2700 | * @param int Field's type |
| 2697 | 2701 | * @param string Field's language var name |
| 2698 | - * @return int new extra field id |
|
| 2702 | + * @param integer $fieldType |
|
| 2703 | + * @param string $default |
|
| 2704 | + * @return boolean new extra field id |
|
| 2699 | 2705 | */ |
| 2700 | 2706 | public static function create_course_extra_field($variable, $fieldType, $displayText, $default) |
| 2701 | 2707 | { |
@@ -2717,7 +2723,7 @@ discard block |
||
| 2717 | 2723 | * @param int Course id |
| 2718 | 2724 | * @param string Attribute name |
| 2719 | 2725 | * @param string Attribute value |
| 2720 | - * @return bool True if attribute was successfully updated, |
|
| 2726 | + * @return Doctrine\DBAL\Driver\Statement|null True if attribute was successfully updated, |
|
| 2721 | 2727 | * false if course was not found or attribute name is invalid |
| 2722 | 2728 | */ |
| 2723 | 2729 | public static function update_attribute($id, $name, $value) |
@@ -2735,7 +2741,7 @@ discard block |
||
| 2735 | 2741 | * |
| 2736 | 2742 | * @param int Course id |
| 2737 | 2743 | * @param array Associative array with field names as keys and field values as values |
| 2738 | - * @return bool True if update was successful, false otherwise |
|
| 2744 | + * @return Doctrine\DBAL\Driver\Statement|null True if update was successful, false otherwise |
|
| 2739 | 2745 | */ |
| 2740 | 2746 | public static function update_attributes($id, $attributes) |
| 2741 | 2747 | { |
@@ -2761,7 +2767,7 @@ discard block |
||
| 2761 | 2767 | * @param integer Course ID |
| 2762 | 2768 | * @param string Field variable name |
| 2763 | 2769 | * @param string Field value |
| 2764 | - * @return boolean true if field updated, false otherwise |
|
| 2770 | + * @return boolean|null true if field updated, false otherwise |
|
| 2765 | 2771 | */ |
| 2766 | 2772 | public static function update_course_extra_field_value($course_code, $variable, $value = '') |
| 2767 | 2773 | { |
@@ -3483,6 +3489,7 @@ discard block |
||
| 3483 | 3489 | * @uses displayCoursesInCategory() to display the courses themselves |
| 3484 | 3490 | * @param int user id |
| 3485 | 3491 | * @param bool Whether to show the document quick-loader or not |
| 3492 | + * @param integer $user_id |
|
| 3486 | 3493 | * @return string |
| 3487 | 3494 | */ |
| 3488 | 3495 | public static function display_courses($user_id, $load_dirs = false) |
@@ -4057,6 +4064,8 @@ discard block |
||
| 4057 | 4064 | * @param int source session id |
| 4058 | 4065 | * @param string destination course code |
| 4059 | 4066 | * @param int destination session id |
| 4067 | + * @param integer $source_session_id |
|
| 4068 | + * @param integer $destination_session_id |
|
| 4060 | 4069 | * @return bool |
| 4061 | 4070 | */ |
| 4062 | 4071 | public static function copy_course( |
@@ -4091,6 +4100,7 @@ discard block |
||
| 4091 | 4100 | * @param int source session id |
| 4092 | 4101 | * @param int destination session id |
| 4093 | 4102 | * @param bool new copied tools (Exercises and LPs)will be set to invisible by default? |
| 4103 | + * @param string $new_title |
|
| 4094 | 4104 | * |
| 4095 | 4105 | * @return array |
| 4096 | 4106 | */ |
@@ -4344,6 +4354,7 @@ discard block |
||
| 4344 | 4354 | * @param int course id |
| 4345 | 4355 | * @param int session id |
| 4346 | 4356 | * @param id url id |
| 4357 | + * @param integer $session_id |
|
| 4347 | 4358 | * @return array |
| 4348 | 4359 | **/ |
| 4349 | 4360 | public static function update_course_ranking( |
@@ -4426,7 +4437,7 @@ discard block |
||
| 4426 | 4437 | * @param int course id |
| 4427 | 4438 | * @param int session id |
| 4428 | 4439 | * @param int url id (access_url_id) |
| 4429 | - * @return mixed 'added', 'updated' or 'nothing' |
|
| 4440 | + * @return false|string 'added', 'updated' or 'nothing' |
|
| 4430 | 4441 | */ |
| 4431 | 4442 | public static function add_course_vote($user_id, $vote, $course_id, $session_id = null, $url_id = null) |
| 4432 | 4443 | { |
@@ -4681,6 +4692,7 @@ discard block |
||
| 4681 | 4692 | * Get courses count |
| 4682 | 4693 | * @param int Access URL ID (optional) |
| 4683 | 4694 | * @param int $visibility |
| 4695 | + * @param integer $access_url_id |
|
| 4684 | 4696 | * |
| 4685 | 4697 | * @return int Number of courses |
| 4686 | 4698 | */ |
@@ -4737,6 +4749,7 @@ discard block |
||
| 4737 | 4749 | /** |
| 4738 | 4750 | * Get available le courses count |
| 4739 | 4751 | * @param int Access URL ID (optional) |
| 4752 | + * @param integer $accessUrlId |
|
| 4740 | 4753 | * @return int Number of courses |
| 4741 | 4754 | */ |
| 4742 | 4755 | public static function countAvailableCourses($accessUrlId = null) |
@@ -4781,6 +4794,7 @@ discard block |
||
| 4781 | 4794 | * @param int User ID |
| 4782 | 4795 | * @param array Course details array |
| 4783 | 4796 | * @param array List of courses to which the user is subscribed (if not provided, will be generated) |
| 4797 | + * @param integer $uid |
|
| 4784 | 4798 | * @return mixed 'enter' for a link to go to the course or 'register' for a link to subscribe, or false if no access |
| 4785 | 4799 | */ |
| 4786 | 4800 | static function get_access_link_by_user($uid, $course, $user_courses = array()) |
@@ -4851,7 +4865,7 @@ discard block |
||
| 4851 | 4865 | * @param bool $deleteTeachersNotInList |
| 4852 | 4866 | * @param bool $editTeacherInSessions |
| 4853 | 4867 | * @param bool $deleteSessionTeacherNotInList |
| 4854 | - * @return bool |
|
| 4868 | + * @return false|null |
|
| 4855 | 4869 | */ |
| 4856 | 4870 | public static function updateTeachers( |
| 4857 | 4871 | $courseId, |
@@ -1679,7 +1679,7 @@ discard block |
||
| 1679 | 1679 | |
| 1680 | 1680 | // We get the coach for the given course in a given session. |
| 1681 | 1681 | $sql = 'SELECT user_id FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . |
| 1682 | - ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2'; |
|
| 1682 | + ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2'; |
|
| 1683 | 1683 | $rs = Database::query($sql); |
| 1684 | 1684 | while ($user = Database::fetch_array($rs)) { |
| 1685 | 1685 | $user_info = api_get_user_info($user['user_id']); |
@@ -3972,7 +3972,7 @@ discard block |
||
| 3972 | 3972 | } |
| 3973 | 3973 | |
| 3974 | 3974 | $session_title .= isset($course['special_course']) ? ' ' . |
| 3975 | - Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : ''; |
|
| 3975 | + Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : ''; |
|
| 3976 | 3976 | |
| 3977 | 3977 | $params['title'] = $session_title; |
| 3978 | 3978 | $params['extra'] = ''; |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | $template = api_get_setting('course_creation_use_template'); |
| 129 | 129 | if (!empty($template)) { |
| 130 | 130 | // Include the necessary libraries to generate a course copy |
| 131 | - require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseBuilder.class.php'; |
|
| 132 | - require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseRestorer.class.php'; |
|
| 133 | - require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseSelectForm.class.php'; |
|
| 131 | + require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/CourseBuilder.class.php'; |
|
| 132 | + require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/CourseRestorer.class.php'; |
|
| 133 | + require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/CourseSelectForm.class.php'; |
|
| 134 | 134 | // Call the course copy object |
| 135 | 135 | $originCourse = api_get_course_info_by_id($template); |
| 136 | 136 | $originCourse['official_code'] = $originCourse['code']; |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | { |
| 167 | 167 | return Database::fetch_array( |
| 168 | 168 | Database::query( |
| 169 | - "SELECT *, id as real_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " |
|
| 170 | - WHERE code='" . Database::escape_string($course_code) . "'"), 'ASSOC' |
|
| 169 | + "SELECT *, id as real_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." |
|
| 170 | + WHERE code='" . Database::escape_string($course_code)."'"), 'ASSOC' |
|
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | $alsoSearchCode = false, |
| 196 | 196 | $conditionsLike = array() |
| 197 | 197 | ) { |
| 198 | - $sql = "SELECT course.* FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " course "; |
|
| 198 | + $sql = "SELECT course.* FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course "; |
|
| 199 | 199 | |
| 200 | 200 | if (!empty($urlId)) { |
| 201 | 201 | $table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); |
@@ -203,9 +203,9 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | if (!empty($startwith)) { |
| 206 | - $sql .= "WHERE (title LIKE '" . Database::escape_string($startwith) . "%' "; |
|
| 206 | + $sql .= "WHERE (title LIKE '".Database::escape_string($startwith)."%' "; |
|
| 207 | 207 | if ($alsoSearchCode) { |
| 208 | - $sql .= "OR code LIKE '" . Database::escape_string($startwith) . "%' "; |
|
| 208 | + $sql .= "OR code LIKE '".Database::escape_string($startwith)."%' "; |
|
| 209 | 209 | } |
| 210 | 210 | $sql .= ') '; |
| 211 | 211 | if ($visibility !== -1 && $visibility == strval(intval($visibility))) { |
@@ -239,19 +239,19 @@ discard block |
||
| 239 | 239 | $value = Database::escape_string($value); |
| 240 | 240 | $simple_like = false; |
| 241 | 241 | if ($simple_like) { |
| 242 | - $temp_conditions[] = $field . " LIKE '$value%'"; |
|
| 242 | + $temp_conditions[] = $field." LIKE '$value%'"; |
|
| 243 | 243 | } else { |
| 244 | - $temp_conditions[] = $field . ' LIKE \'%' . $value . '%\''; |
|
| 244 | + $temp_conditions[] = $field.' LIKE \'%'.$value.'%\''; |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | $condition = ' AND '; |
| 248 | 248 | if (!empty($temp_conditions)) { |
| 249 | - $sql .= implode(' ' . $condition . ' ', $temp_conditions); |
|
| 249 | + $sql .= implode(' '.$condition.' ', $temp_conditions); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | if (!empty($orderby)) { |
| 254 | - $sql .= " ORDER BY " . Database::escape_string($orderby) . " "; |
|
| 254 | + $sql .= " ORDER BY ".Database::escape_string($orderby)." "; |
|
| 255 | 255 | } else { |
| 256 | 256 | $sql .= " ORDER BY 1 "; |
| 257 | 257 | } |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | if (!empty($howmany) && is_int($howmany) and $howmany > 0) { |
| 266 | - $sql .= ' LIMIT ' . Database::escape_string($howmany); |
|
| 266 | + $sql .= ' LIMIT '.Database::escape_string($howmany); |
|
| 267 | 267 | } else { |
| 268 | 268 | $sql .= ' LIMIT 1000000'; //virtually no limit |
| 269 | 269 | } |
| 270 | 270 | if (!empty($from)) { |
| 271 | 271 | $from = intval($from); |
| 272 | - $sql .= ' OFFSET ' . intval($from); |
|
| 272 | + $sql .= ' OFFSET '.intval($from); |
|
| 273 | 273 | } else { |
| 274 | 274 | $sql .= ' OFFSET 0'; |
| 275 | 275 | } |
@@ -293,8 +293,8 @@ discard block |
||
| 293 | 293 | return Database::fetch_array( |
| 294 | 294 | Database::query( |
| 295 | 295 | "SELECT visibility, subscribe, unsubscribe |
| 296 | - FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " |
|
| 297 | - WHERE code = '" . Database::escape_string($course_code) . "'" |
|
| 296 | + FROM " . Database::get_main_table(TABLE_MAIN_COURSE)." |
|
| 297 | + WHERE code = '" . Database::escape_string($course_code)."'" |
|
| 298 | 298 | ) |
| 299 | 299 | ); |
| 300 | 300 | } |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | $courseId = $courseInfo['real_id']; |
| 313 | 313 | $result = Database::fetch_array( |
| 314 | 314 | Database::query( |
| 315 | - "SELECT status FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 315 | + "SELECT status FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 316 | 316 | WHERE |
| 317 | 317 | c_id = $courseId AND |
| 318 | - user_id = " . intval($user_id) |
|
| 318 | + user_id = ".intval($user_id) |
|
| 319 | 319 | ) |
| 320 | 320 | ); |
| 321 | 321 | |
@@ -333,9 +333,9 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | $result = Database::fetch_array( |
| 335 | 335 | Database::query(" |
| 336 | - SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 336 | + SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 337 | 337 | WHERE |
| 338 | - c_id = '" . intval($courseId). "' AND |
|
| 338 | + c_id = '" . intval($courseId)."' AND |
|
| 339 | 339 | user_id = " . intval($userId) |
| 340 | 340 | ) |
| 341 | 341 | ); |
@@ -382,9 +382,9 @@ discard block |
||
| 382 | 382 | $result = Database::fetch_array( |
| 383 | 383 | Database::query(" |
| 384 | 384 | SELECT is_tutor |
| 385 | - FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 385 | + FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 386 | 386 | WHERE |
| 387 | - course_code = '" . Database::escape_string($course_code) . "' AND |
|
| 387 | + course_code = '" . Database::escape_string($course_code)."' AND |
|
| 388 | 388 | user_id = " . intval($user_id) |
| 389 | 389 | ) |
| 390 | 390 | ); |
@@ -437,17 +437,17 @@ discard block |
||
| 437 | 437 | $course_id = $course_info['real_id']; |
| 438 | 438 | |
| 439 | 439 | // Unsubscribe user from all groups in the course. |
| 440 | - $sql = "DELETE FROM " . Database::get_course_table(TABLE_GROUP_USER) . " |
|
| 441 | - WHERE c_id = $course_id AND user_id IN (" . $user_ids . ")"; |
|
| 440 | + $sql = "DELETE FROM ".Database::get_course_table(TABLE_GROUP_USER)." |
|
| 441 | + WHERE c_id = $course_id AND user_id IN (".$user_ids.")"; |
|
| 442 | 442 | Database::query($sql); |
| 443 | - $sql = "DELETE FROM " . Database::get_course_table(TABLE_GROUP_TUTOR) . " |
|
| 444 | - WHERE c_id = $course_id AND user_id IN (" . $user_ids . ")"; |
|
| 443 | + $sql = "DELETE FROM ".Database::get_course_table(TABLE_GROUP_TUTOR)." |
|
| 444 | + WHERE c_id = $course_id AND user_id IN (".$user_ids.")"; |
|
| 445 | 445 | Database::query($sql); |
| 446 | 446 | |
| 447 | 447 | // Erase user student publications (works) in the course - by André Boivin |
| 448 | 448 | |
| 449 | 449 | if (!empty($user_list)) { |
| 450 | - require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php'; |
|
| 450 | + require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; |
|
| 451 | 451 | foreach ($user_list as $userId) { |
| 452 | 452 | // Getting all work from user |
| 453 | 453 | $workList = getWorkPerUser($userId); |
@@ -466,74 +466,74 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Unsubscribe user from all blogs in the course. |
| 469 | - Database::query("DELETE FROM " . Database::get_course_table(TABLE_BLOGS_REL_USER) . " WHERE c_id = $course_id AND user_id IN (" . $user_ids . ")"); |
|
| 470 | - Database::query("DELETE FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " WHERE c_id = $course_id AND user_id IN (" . $user_ids . ")"); |
|
| 469 | + Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_REL_USER)." WHERE c_id = $course_id AND user_id IN (".$user_ids.")"); |
|
| 470 | + Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." WHERE c_id = $course_id AND user_id IN (".$user_ids.")"); |
|
| 471 | 471 | |
| 472 | 472 | // Deleting users in forum_notification and mailqueue course tables |
| 473 | - $sql = "DELETE FROM " . Database::get_course_table(TABLE_FORUM_NOTIFICATION) . " |
|
| 474 | - WHERE c_id = $course_id AND user_id IN (" . $user_ids . ")"; |
|
| 473 | + $sql = "DELETE FROM ".Database::get_course_table(TABLE_FORUM_NOTIFICATION)." |
|
| 474 | + WHERE c_id = $course_id AND user_id IN (".$user_ids.")"; |
|
| 475 | 475 | Database::query($sql); |
| 476 | 476 | |
| 477 | - $sql = "DELETE FROM " . Database::get_course_table(TABLE_FORUM_MAIL_QUEUE) . " |
|
| 478 | - WHERE c_id = $course_id AND user_id IN (" . $user_ids . ")"; |
|
| 477 | + $sql = "DELETE FROM ".Database::get_course_table(TABLE_FORUM_MAIL_QUEUE)." |
|
| 478 | + WHERE c_id = $course_id AND user_id IN (".$user_ids.")"; |
|
| 479 | 479 | Database::query($sql); |
| 480 | 480 | |
| 481 | 481 | // Unsubscribe user from the course. |
| 482 | 482 | if (!empty($session_id)) { |
| 483 | 483 | |
| 484 | 484 | // Delete in table session_rel_course_rel_user |
| 485 | - $sql = "DELETE FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " |
|
| 485 | + $sql = "DELETE FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." |
|
| 486 | 486 | WHERE |
| 487 | - session_id ='" . $session_id . "' AND |
|
| 488 | - c_id = '" . $course_id . "' AND |
|
| 487 | + session_id ='" . $session_id."' AND |
|
| 488 | + c_id = '" . $course_id."' AND |
|
| 489 | 489 | user_id IN ($user_ids)"; |
| 490 | 490 | Database::query($sql); |
| 491 | 491 | |
| 492 | 492 | foreach ($user_list as $uid) { |
| 493 | 493 | // check if a user is register in the session with other course |
| 494 | - $sql = "SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " |
|
| 494 | + $sql = "SELECT user_id FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." |
|
| 495 | 495 | WHERE session_id='$session_id' AND user_id='$uid'"; |
| 496 | 496 | $rs = Database::query($sql); |
| 497 | 497 | |
| 498 | 498 | if (Database::num_rows($rs) == 0) { |
| 499 | 499 | // Delete in table session_rel_user |
| 500 | - $sql = "DELETE FROM " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " |
|
| 500 | + $sql = "DELETE FROM ".Database::get_main_table(TABLE_MAIN_SESSION_USER)." |
|
| 501 | 501 | WHERE |
| 502 | - session_id ='" . $session_id . "' AND |
|
| 502 | + session_id ='" . $session_id."' AND |
|
| 503 | 503 | user_id = '$uid' AND |
| 504 | - relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""; |
|
| 504 | + relation_type<>".SESSION_RELATION_TYPE_RRHH.""; |
|
| 505 | 505 | Database::query($sql); |
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // Update the table session |
| 510 | - $sql = "SELECT COUNT(*) FROM " . Database::get_main_table(TABLE_MAIN_SESSION_USER) . " |
|
| 511 | - WHERE session_id = '" . $session_id . "' AND relation_type <> " . SESSION_RELATION_TYPE_RRHH; |
|
| 510 | + $sql = "SELECT COUNT(*) FROM ".Database::get_main_table(TABLE_MAIN_SESSION_USER)." |
|
| 511 | + WHERE session_id = '" . $session_id."' AND relation_type <> ".SESSION_RELATION_TYPE_RRHH; |
|
| 512 | 512 | $row = Database::fetch_array(Database::query($sql)); |
| 513 | 513 | $count = $row[0]; |
| 514 | 514 | // number of users by session |
| 515 | - $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_SESSION) . " SET nbr_users = '$count' |
|
| 516 | - WHERE id = '" . $session_id . "'"; |
|
| 515 | + $sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_SESSION)." SET nbr_users = '$count' |
|
| 516 | + WHERE id = '".$session_id."'"; |
|
| 517 | 517 | Database::query($sql); |
| 518 | 518 | |
| 519 | 519 | // Update the table session_rel_course |
| 520 | - $sql = "SELECT COUNT(*) FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " |
|
| 520 | + $sql = "SELECT COUNT(*) FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." |
|
| 521 | 521 | WHERE session_id = '$session_id' AND c_id = '$course_id' AND status<>2"; |
| 522 | 522 | $row = Database::fetch_array(@Database::query($sql)); |
| 523 | 523 | $count = $row[0]; |
| 524 | 524 | |
| 525 | 525 | // number of users by session and course |
| 526 | - $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . " |
|
| 526 | + $sql = "UPDATE ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE)." |
|
| 527 | 527 | SET nbr_users = '$count' |
| 528 | 528 | WHERE session_id = '$session_id' AND c_id = '$course_id'"; |
| 529 | 529 | Database::query($sql); |
| 530 | 530 | |
| 531 | 531 | } else { |
| 532 | - $sql = "DELETE FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 532 | + $sql = "DELETE FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 533 | 533 | WHERE |
| 534 | - user_id IN (" . $user_ids . ") AND |
|
| 535 | - relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND |
|
| 536 | - c_id = '" . $course_id . "'"; |
|
| 534 | + user_id IN (" . $user_ids.") AND |
|
| 535 | + relation_type<>" . COURSE_RELATION_TYPE_RRHH." AND |
|
| 536 | + c_id = '" . $course_id."'"; |
|
| 537 | 537 | Database::query($sql); |
| 538 | 538 | |
| 539 | 539 | // add event to system log |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | // A preliminary check whether the user has bben already registered on the platform. |
| 605 | 605 | if (Database::num_rows(Database::query( |
| 606 | - "SELECT status FROM " . Database::get_main_table(TABLE_MAIN_USER) . " |
|
| 606 | + "SELECT status FROM ".Database::get_main_table(TABLE_MAIN_USER)." |
|
| 607 | 607 | WHERE user_id = '$user_id' ")) == 0 |
| 608 | 608 | ) { |
| 609 | 609 | return false; // The user has not been registered to the platform. |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | |
| 614 | 614 | if (empty($session_id)) { |
| 615 | 615 | if (Database::num_rows(Database::query(" |
| 616 | - SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 617 | - WHERE user_id = '$user_id' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND c_id = '$courseId'")) > 0 |
|
| 616 | + SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 617 | + WHERE user_id = '$user_id' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." AND c_id = '$courseId'")) > 0 |
|
| 618 | 618 | ) { |
| 619 | 619 | // The user has been already subscribed to the course. |
| 620 | 620 | return false; |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | $courseId = $courseInfo['real_id']; |
| 737 | 737 | |
| 738 | 738 | // Check in advance whether the user has already been registered on the platform. |
| 739 | - $sql = "SELECT status FROM " . $user_table . " WHERE user_id = $user_id "; |
|
| 739 | + $sql = "SELECT status FROM ".$user_table." WHERE user_id = $user_id "; |
|
| 740 | 740 | if (Database::num_rows(Database::query($sql)) == 0) { |
| 741 | 741 | if ($debug) { |
| 742 | 742 | error_log('The user has not been registered to the platform'); |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | $sql = "SELECT * FROM $course_user_table |
| 749 | 749 | WHERE |
| 750 | 750 | user_id = $user_id AND |
| 751 | - relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND |
|
| 751 | + relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND |
|
| 752 | 752 | c_id = $courseId"; |
| 753 | 753 | if (Database::num_rows(Database::query($sql)) > 0) { |
| 754 | 754 | if ($debug) { |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | if (!api_is_course_admin()) { |
| 761 | 761 | // Check in advance whether subscription is allowed or not for this course. |
| 762 | 762 | $sql = "SELECT code, visibility FROM $course_table |
| 763 | - WHERE id = $courseId AND subscribe = '" . SUBSCRIBE_NOT_ALLOWED . "'"; |
|
| 763 | + WHERE id = $courseId AND subscribe = '".SUBSCRIBE_NOT_ALLOWED."'"; |
|
| 764 | 764 | if (Database::num_rows(Database::query($sql)) > 0) { |
| 765 | 765 | if ($debug) { |
| 766 | 766 | error_log('Subscription is not allowed for this course'); |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | { |
| 820 | 820 | $wanted_course_code = Database::escape_string($wanted_course_code); |
| 821 | 821 | $sql = "SELECT COUNT(*) as number |
| 822 | - FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " |
|
| 822 | + FROM " . Database::get_main_table(TABLE_MAIN_COURSE)." |
|
| 823 | 823 | WHERE code = '$wanted_course_code' OR visual_code = '$wanted_course_code'"; |
| 824 | 824 | $result = Database::fetch_array(Database::query($sql)); |
| 825 | 825 | |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | $sql = "SELECT * FROM $table |
| 1006 | 1006 | WHERE |
| 1007 | 1007 | user_id = $userId AND |
| 1008 | - relation_type = " . COURSE_RELATION_TYPE_RRHH . " AND |
|
| 1008 | + relation_type = ".COURSE_RELATION_TYPE_RRHH." AND |
|
| 1009 | 1009 | c_id = $courseId"; |
| 1010 | 1010 | |
| 1011 | 1011 | $result = Database::fetch_array(Database::query($sql)); |
@@ -1044,13 +1044,13 @@ discard block |
||
| 1044 | 1044 | return false; |
| 1045 | 1045 | } |
| 1046 | 1046 | $courseId = $courseInfo['real_id']; |
| 1047 | - $condition_course = ' AND c_id = ' . $courseId; |
|
| 1047 | + $condition_course = ' AND c_id = '.$courseId; |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 1050 | + $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 1051 | 1051 | WHERE |
| 1052 | 1052 | user_id = $user_id AND |
| 1053 | - relation_type<>" . COURSE_RELATION_TYPE_RRHH . " |
|
| 1053 | + relation_type<>".COURSE_RELATION_TYPE_RRHH." |
|
| 1054 | 1054 | $condition_course "; |
| 1055 | 1055 | |
| 1056 | 1056 | $result = Database::fetch_array(Database::query($sql)); |
@@ -1066,20 +1066,20 @@ discard block |
||
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | 1068 | $tableSessionCourseUser = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); |
| 1069 | - $sql = 'SELECT 1 FROM ' . $tableSessionCourseUser . |
|
| 1070 | - ' WHERE user_id = ' . $user_id . ' ' . $condition_course; |
|
| 1069 | + $sql = 'SELECT 1 FROM '.$tableSessionCourseUser. |
|
| 1070 | + ' WHERE user_id = '.$user_id.' '.$condition_course; |
|
| 1071 | 1071 | if (Database::num_rows(Database::query($sql)) > 0) { |
| 1072 | 1072 | return true; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - $sql = 'SELECT 1 FROM ' . $tableSessionCourseUser . |
|
| 1076 | - ' WHERE user_id = ' . $user_id . ' AND status=2 ' . $condition_course; |
|
| 1075 | + $sql = 'SELECT 1 FROM '.$tableSessionCourseUser. |
|
| 1076 | + ' WHERE user_id = '.$user_id.' AND status=2 '.$condition_course; |
|
| 1077 | 1077 | if (Database::num_rows(Database::query($sql)) > 0) { |
| 1078 | 1078 | return true; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_SESSION) . |
|
| 1082 | - ' WHERE id = ' . $session_id . ' AND id_coach=' . $user_id; |
|
| 1081 | + $sql = 'SELECT 1 FROM '.Database::get_main_table(TABLE_MAIN_SESSION). |
|
| 1082 | + ' WHERE id = '.$session_id.' AND id_coach='.$user_id; |
|
| 1083 | 1083 | |
| 1084 | 1084 | if (Database::num_rows(Database::query($sql)) > 0) { |
| 1085 | 1085 | return true; |
@@ -1106,8 +1106,8 @@ discard block |
||
| 1106 | 1106 | $courseId = $courseInfo['real_id']; |
| 1107 | 1107 | |
| 1108 | 1108 | $result = Database::query( |
| 1109 | - 'SELECT status FROM ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . |
|
| 1110 | - ' WHERE c_id = ' . $courseId . ' AND user_id = ' . $user_id . '' |
|
| 1109 | + 'SELECT status FROM '.Database::get_main_table(TABLE_MAIN_COURSE_USER). |
|
| 1110 | + ' WHERE c_id = '.$courseId.' AND user_id = '.$user_id.'' |
|
| 1111 | 1111 | ); |
| 1112 | 1112 | |
| 1113 | 1113 | if (Database::num_rows($result) > 0) { |
@@ -1137,12 +1137,12 @@ discard block |
||
| 1137 | 1137 | $result = Database::fetch_array( |
| 1138 | 1138 | Database::query( |
| 1139 | 1139 | "SELECT * |
| 1140 | - FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " course |
|
| 1141 | - LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " course_user |
|
| 1140 | + FROM " . Database::get_main_table(TABLE_MAIN_COURSE)." course |
|
| 1141 | + LEFT JOIN " . Database::get_main_table(TABLE_MAIN_COURSE_USER)." course_user |
|
| 1142 | 1142 | ON course.id = course_user.c_id |
| 1143 | 1143 | WHERE |
| 1144 | 1144 | course_user.user_id = '$user_id' AND |
| 1145 | - course_user.relation_type<>" . COURSE_RELATION_TYPE_RRHH . " AND |
|
| 1145 | + course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." AND |
|
| 1146 | 1146 | ( course.id = '$courseId')" |
| 1147 | 1147 | ) |
| 1148 | 1148 | ); |
@@ -1156,8 +1156,8 @@ discard block |
||
| 1156 | 1156 | |
| 1157 | 1157 | // A user? |
| 1158 | 1158 | if (Database::num_rows(Database::query("SELECT user_id |
| 1159 | - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " |
|
| 1160 | - WHERE session_id='" . $session_id . "' |
|
| 1159 | + FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." |
|
| 1160 | + WHERE session_id='" . $session_id."' |
|
| 1161 | 1161 | AND user_id ='$user_id'")) |
| 1162 | 1162 | ) { |
| 1163 | 1163 | return true; |
@@ -1165,8 +1165,8 @@ discard block |
||
| 1165 | 1165 | |
| 1166 | 1166 | // A course coach? |
| 1167 | 1167 | if (Database::num_rows(Database::query("SELECT user_id |
| 1168 | - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " |
|
| 1169 | - WHERE session_id='" . $session_id . "' |
|
| 1168 | + FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." |
|
| 1169 | + WHERE session_id='" . $session_id."' |
|
| 1170 | 1170 | AND user_id = '$user_id' AND status = 2 |
| 1171 | 1171 | AND c_id ='$courseId'")) |
| 1172 | 1172 | ) { |
@@ -1175,8 +1175,8 @@ discard block |
||
| 1175 | 1175 | |
| 1176 | 1176 | // A session coach? |
| 1177 | 1177 | if (Database::num_rows(Database::query("SELECT id_coach |
| 1178 | - FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . " AS session |
|
| 1179 | - WHERE session.id='" . $session_id . "' |
|
| 1178 | + FROM " . Database::get_main_table(TABLE_MAIN_SESSION)." AS session |
|
| 1179 | + WHERE session.id='" . $session_id."' |
|
| 1180 | 1180 | AND id_coach='$user_id'")) |
| 1181 | 1181 | ) { |
| 1182 | 1182 | return true; |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | // we have to check if it is a valid field that can be sorted on |
| 1245 | 1245 | if (!strstr($order_by, 'ORDER BY')) { |
| 1246 | 1246 | if (!empty($order_by)) { |
| 1247 | - $order_by = 'ORDER BY ' . $order_by; |
|
| 1247 | + $order_by = 'ORDER BY '.$order_by; |
|
| 1248 | 1248 | } else { |
| 1249 | 1249 | $order_by = ''; |
| 1250 | 1250 | } |
@@ -1276,11 +1276,11 @@ discard block |
||
| 1276 | 1276 | if (!empty($courseCodeList)) { |
| 1277 | 1277 | $courseCodeListForSession = array_map(array('Database', 'escape_string'), $courseCodeList); |
| 1278 | 1278 | $courseCodeListForSession = implode('","', $courseCodeListForSession); |
| 1279 | - $courseCondition = ' course.code IN ("' . $courseCodeListForSession . '") '; |
|
| 1279 | + $courseCondition = ' course.code IN ("'.$courseCodeListForSession.'") '; |
|
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | - $sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; |
|
| 1283 | - $sql .= " LEFT JOIN ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " as session_course_user |
|
| 1282 | + $sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user '; |
|
| 1283 | + $sql .= " LEFT JOIN ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." as session_course_user |
|
| 1284 | 1284 | ON |
| 1285 | 1285 | user.user_id = session_course_user.user_id AND |
| 1286 | 1286 | $sessionCondition |
@@ -1322,14 +1322,14 @@ discard block |
||
| 1322 | 1322 | } |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | - $sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; |
|
| 1326 | - $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . ' as course_rel_user |
|
| 1325 | + $sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user '; |
|
| 1326 | + $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_COURSE_USER).' as course_rel_user |
|
| 1327 | 1327 | ON user.user_id = course_rel_user.user_id AND |
| 1328 | - course_rel_user.relation_type <> ' . COURSE_RELATION_TYPE_RRHH . ' '; |
|
| 1328 | + course_rel_user.relation_type <> ' . COURSE_RELATION_TYPE_RRHH.' '; |
|
| 1329 | 1329 | $sql .= " INNER JOIN $course_table course ON course_rel_user.c_id = course.id "; |
| 1330 | 1330 | |
| 1331 | 1331 | if (!empty($course_code)) { |
| 1332 | - $sql .= ' AND course_rel_user.c_id="' . $courseId . '"'; |
|
| 1332 | + $sql .= ' AND course_rel_user.c_id="'.$courseId.'"'; |
|
| 1333 | 1333 | } |
| 1334 | 1334 | $where[] = ' course_rel_user.c_id IS NOT NULL '; |
| 1335 | 1335 | |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | |
| 1342 | 1342 | $multiple_access_url = api_get_multiple_access_url(); |
| 1343 | 1343 | if ($multiple_access_url) { |
| 1344 | - $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au |
|
| 1344 | + $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au |
|
| 1345 | 1345 | ON (au.user_id = user.user_id) '; |
| 1346 | 1346 | } |
| 1347 | 1347 | |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | } |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | - $sql .= ' WHERE ' . $filter_by_status_condition . ' ' . implode(' OR ', $where); |
|
| 1364 | + $sql .= ' WHERE '.$filter_by_status_condition.' '.implode(' OR ', $where); |
|
| 1365 | 1365 | |
| 1366 | 1366 | if ($multiple_access_url) { |
| 1367 | 1367 | $current_access_url_id = api_get_current_access_url_id(); |
@@ -1383,15 +1383,15 @@ discard block |
||
| 1383 | 1383 | if (!empty($userIdList)) { |
| 1384 | 1384 | $userIdList = array_map('intval', $userIdList); |
| 1385 | 1385 | $userIdList = implode('","', $userIdList); |
| 1386 | - $sql .= ' AND user.user_id IN ("' . $userIdList . '")'; |
|
| 1386 | + $sql .= ' AND user.user_id IN ("'.$userIdList.'")'; |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | if (isset($filterByActive)) { |
| 1390 | 1390 | $filterByActive = intval($filterByActive); |
| 1391 | - $sql .= ' AND user.active = ' . $filterByActive; |
|
| 1391 | + $sql .= ' AND user.active = '.$filterByActive; |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - $sql .= ' ' . $order_by . ' ' . $limit; |
|
| 1394 | + $sql .= ' '.$order_by.' '.$limit; |
|
| 1395 | 1395 | |
| 1396 | 1396 | $rs = Database::query($sql); |
| 1397 | 1397 | $users = array(); |
@@ -1548,7 +1548,7 @@ discard block |
||
| 1548 | 1548 | ) |
| 1549 | 1549 | ); |
| 1550 | 1550 | $report_info['progress_100'] = $progress == 100 ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No')); |
| 1551 | - $report_info['progress'] = $progress . "%"; |
|
| 1551 | + $report_info['progress'] = $progress."%"; |
|
| 1552 | 1552 | |
| 1553 | 1553 | foreach ($extra_fields as $extra) { |
| 1554 | 1554 | $user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']); |
@@ -1617,32 +1617,32 @@ discard block |
||
| 1617 | 1617 | $courseInfo = api_get_course_info($course_code); |
| 1618 | 1618 | $courseId = $courseInfo['real_id']; |
| 1619 | 1619 | |
| 1620 | - $sql = 'SELECT DISTINCT count(*) as count FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user '; |
|
| 1620 | + $sql = 'SELECT DISTINCT count(*) as count FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user '; |
|
| 1621 | 1621 | $where = array(); |
| 1622 | 1622 | if (!empty($session_id)) { |
| 1623 | - $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' as session_course_user |
|
| 1623 | + $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' as session_course_user |
|
| 1624 | 1624 | ON |
| 1625 | 1625 | user.user_id = session_course_user.user_id AND |
| 1626 | - session_course_user.c_id = "' . $courseId . '" AND |
|
| 1626 | + session_course_user.c_id = "' . $courseId.'" AND |
|
| 1627 | 1627 | session_course_user.session_id = ' . $session_id; |
| 1628 | 1628 | |
| 1629 | 1629 | $where[] = ' session_course_user.c_id IS NOT NULL '; |
| 1630 | 1630 | } else { |
| 1631 | - $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . ' as course_rel_user |
|
| 1631 | + $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_COURSE_USER).' as course_rel_user |
|
| 1632 | 1632 | ON |
| 1633 | 1633 | user.user_id = course_rel_user.user_id AND |
| 1634 | - course_rel_user.relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND |
|
| 1635 | - course_rel_user.c_id = ' . $courseId ; |
|
| 1634 | + course_rel_user.relation_type<>' . COURSE_RELATION_TYPE_RRHH.' AND |
|
| 1635 | + course_rel_user.c_id = ' . $courseId; |
|
| 1636 | 1636 | $where[] = ' course_rel_user.c_id IS NOT NULL '; |
| 1637 | 1637 | } |
| 1638 | 1638 | |
| 1639 | 1639 | $multiple_access_url = api_get_multiple_access_url(); |
| 1640 | 1640 | if ($multiple_access_url) { |
| 1641 | - $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au |
|
| 1641 | + $sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au |
|
| 1642 | 1642 | ON (au.user_id = user.user_id) '; |
| 1643 | 1643 | } |
| 1644 | 1644 | |
| 1645 | - $sql .= ' WHERE ' . implode(' OR ', $where); |
|
| 1645 | + $sql .= ' WHERE '.implode(' OR ', $where); |
|
| 1646 | 1646 | |
| 1647 | 1647 | if ($multiple_access_url) { |
| 1648 | 1648 | $current_access_url_id = api_get_current_access_url_id(); |
@@ -1678,8 +1678,8 @@ discard block |
||
| 1678 | 1678 | $users = array(); |
| 1679 | 1679 | |
| 1680 | 1680 | // We get the coach for the given course in a given session. |
| 1681 | - $sql = 'SELECT user_id FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . |
|
| 1682 | - ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2'; |
|
| 1681 | + $sql = 'SELECT user_id FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER). |
|
| 1682 | + ' WHERE session_id ="'.$session_id.'" AND c_id="'.$courseId.'" AND status = 2'; |
|
| 1683 | 1683 | $rs = Database::query($sql); |
| 1684 | 1684 | while ($user = Database::fetch_array($rs)) { |
| 1685 | 1685 | $user_info = api_get_user_info($user['user_id']); |
@@ -1691,7 +1691,7 @@ discard block |
||
| 1691 | 1691 | |
| 1692 | 1692 | $table = Database::get_main_table(TABLE_MAIN_SESSION); |
| 1693 | 1693 | // We get the session coach. |
| 1694 | - $sql = 'SELECT id_coach FROM ' . $table . ' WHERE id=' . $session_id; |
|
| 1694 | + $sql = 'SELECT id_coach FROM '.$table.' WHERE id='.$session_id; |
|
| 1695 | 1695 | $rs = Database::query($sql); |
| 1696 | 1696 | $session_id_coach = Database::result($rs, 0, 'id_coach'); |
| 1697 | 1697 | $user_info = api_get_user_info($session_id_coach); |
@@ -1767,11 +1767,11 @@ discard block |
||
| 1767 | 1767 | $joinSession = ""; |
| 1768 | 1768 | //Session creation date |
| 1769 | 1769 | if (!empty($date_from) && !empty($date_to)) { |
| 1770 | - $joinSession = "INNER JOIN " . Database::get_main_table(TABLE_MAIN_SESSION) . " s"; |
|
| 1770 | + $joinSession = "INNER JOIN ".Database::get_main_table(TABLE_MAIN_SESSION)." s"; |
|
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | 1773 | $sql_query = "SELECT * |
| 1774 | - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " scu |
|
| 1774 | + FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." scu |
|
| 1775 | 1775 | $joinSession |
| 1776 | 1776 | INNER JOIN $userTable u ON scu.user_id = u.user_id |
| 1777 | 1777 | WHERE scu.c_id = '$courseId' AND scu.status <> 2"; |
@@ -1783,11 +1783,11 @@ discard block |
||
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | 1785 | if ($session_id != 0) { |
| 1786 | - $sql_query .= ' AND scu.session_id = ' . $session_id; |
|
| 1786 | + $sql_query .= ' AND scu.session_id = '.$session_id; |
|
| 1787 | 1787 | } |
| 1788 | 1788 | |
| 1789 | 1789 | if (!$includeInvitedUsers) { |
| 1790 | - $sql_query .= " AND u.status != " . INVITEE; |
|
| 1790 | + $sql_query .= " AND u.status != ".INVITEE; |
|
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | 1793 | $rs = Database::query($sql_query); |
@@ -1821,8 +1821,8 @@ discard block |
||
| 1821 | 1821 | u.email, |
| 1822 | 1822 | u.username, |
| 1823 | 1823 | u.status |
| 1824 | - FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " cu |
|
| 1825 | - INNER JOIN " . Database::get_main_table(TABLE_MAIN_USER) . " u |
|
| 1824 | + FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu |
|
| 1825 | + INNER JOIN " . Database::get_main_table(TABLE_MAIN_USER)." u |
|
| 1826 | 1826 | ON (cu.user_id = u.id) |
| 1827 | 1827 | WHERE |
| 1828 | 1828 | cu.c_id = $courseId AND |
@@ -1860,7 +1860,7 @@ discard block |
||
| 1860 | 1860 | $teacher['lastname'] |
| 1861 | 1861 | ); |
| 1862 | 1862 | if ($add_link_to_profile) { |
| 1863 | - $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&user_id=' . $teacher['user_id']; |
|
| 1863 | + $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$teacher['user_id']; |
|
| 1864 | 1864 | $teacher_name = Display::url( |
| 1865 | 1865 | $teacher_name, |
| 1866 | 1866 | $url, |
@@ -1874,13 +1874,13 @@ discard block |
||
| 1874 | 1874 | } |
| 1875 | 1875 | |
| 1876 | 1876 | if (!empty($list)) { |
| 1877 | - if ($orderList === true){ |
|
| 1877 | + if ($orderList === true) { |
|
| 1878 | 1878 | $html .= '<ul class="user-teacher">'; |
| 1879 | - foreach ($list as $teacher){ |
|
| 1880 | - $html .= Display::tag('li', Display::return_icon('teacher.png', $teacher, null, ICON_SIZE_TINY) . ' ' . $teacher); |
|
| 1879 | + foreach ($list as $teacher) { |
|
| 1880 | + $html .= Display::tag('li', Display::return_icon('teacher.png', $teacher, null, ICON_SIZE_TINY).' '.$teacher); |
|
| 1881 | 1881 | } |
| 1882 | 1882 | $html .= '</ul>'; |
| 1883 | - }else{ |
|
| 1883 | + } else { |
|
| 1884 | 1884 | $html .= array_to_string($list, $separator); |
| 1885 | 1885 | } |
| 1886 | 1886 | } |
@@ -1959,7 +1959,7 @@ discard block |
||
| 1959 | 1959 | foreach ($coachs_course as $coach_course) { |
| 1960 | 1960 | $coach_name = api_get_person_name($coach_course['firstname'], $coach_course['lastname']); |
| 1961 | 1961 | if ($add_link_to_profile) { |
| 1962 | - $url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?a=get_user_popup&user_id=' . $coach_course['user_id']; |
|
| 1962 | + $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coach_course['user_id']; |
|
| 1963 | 1963 | $coach_name = Display::url( |
| 1964 | 1964 | $coach_name, |
| 1965 | 1965 | $url, |
@@ -1975,10 +1975,10 @@ discard block |
||
| 1975 | 1975 | $coaches_to_string = null; |
| 1976 | 1976 | |
| 1977 | 1977 | if (!empty($course_coachs)) { |
| 1978 | - if ($orderList === true){ |
|
| 1978 | + if ($orderList === true) { |
|
| 1979 | 1979 | $html .= '<ul class="user-coachs">'; |
| 1980 | - foreach ($course_coachs as $coachs){ |
|
| 1981 | - $html .= Display::tag('li', Display::return_icon('teacher.png', $coachs, null, ICON_SIZE_TINY) . ' ' . $coachs); |
|
| 1980 | + foreach ($course_coachs as $coachs) { |
|
| 1981 | + $html .= Display::tag('li', Display::return_icon('teacher.png', $coachs, null, ICON_SIZE_TINY).' '.$coachs); |
|
| 1982 | 1982 | } |
| 1983 | 1983 | $html .= '</ul>'; |
| 1984 | 1984 | } else { |
@@ -2033,20 +2033,20 @@ discard block |
||
| 2033 | 2033 | } |
| 2034 | 2034 | |
| 2035 | 2035 | $group_list = array(); |
| 2036 | - $session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,' . intval($session_id) . ')' : $session_condition = ' WHERE g.session_id = 0'; |
|
| 2036 | + $session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0'; |
|
| 2037 | 2037 | |
| 2038 | 2038 | if ($in_get_empty_group == 0) { |
| 2039 | 2039 | // get only groups that are not empty |
| 2040 | 2040 | $sql = "SELECT DISTINCT g.id, g.name |
| 2041 | - FROM " . Database::get_course_table(TABLE_GROUP) . " AS g |
|
| 2042 | - INNER JOIN " . Database::get_course_table(TABLE_GROUP_USER) . " gu |
|
| 2041 | + FROM " . Database::get_course_table(TABLE_GROUP)." AS g |
|
| 2042 | + INNER JOIN " . Database::get_course_table(TABLE_GROUP_USER)." gu |
|
| 2043 | 2043 | ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id) |
| 2044 | 2044 | $session_condition |
| 2045 | 2045 | ORDER BY g.name"; |
| 2046 | 2046 | } else { |
| 2047 | 2047 | // get all groups even if they are empty |
| 2048 | 2048 | $sql = "SELECT g.id, g.name |
| 2049 | - FROM " . Database::get_course_table(TABLE_GROUP) . " AS g |
|
| 2049 | + FROM " . Database::get_course_table(TABLE_GROUP)." AS g |
|
| 2050 | 2050 | $session_condition |
| 2051 | 2051 | AND c_id = $course_id"; |
| 2052 | 2052 | } |
@@ -2101,7 +2101,7 @@ discard block |
||
| 2101 | 2101 | $table_stats_uploads = Database::get_main_table(TABLE_STATISTIC_TRACK_E_UPLOADS); |
| 2102 | 2102 | |
| 2103 | 2103 | $codeFiltered = Database::escape_string($code); |
| 2104 | - $sql = "SELECT * FROM $table_course WHERE code='" . $codeFiltered . "'"; |
|
| 2104 | + $sql = "SELECT * FROM $table_course WHERE code='".$codeFiltered."'"; |
|
| 2105 | 2105 | $res = Database::query($sql); |
| 2106 | 2106 | |
| 2107 | 2107 | if (Database::num_rows($res) == 0) { |
@@ -2109,7 +2109,7 @@ discard block |
||
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | $sql = "SELECT * FROM $table_course |
| 2112 | - WHERE code = '" . $codeFiltered . "'"; |
|
| 2112 | + WHERE code = '".$codeFiltered."'"; |
|
| 2113 | 2113 | $res = Database::query($sql); |
| 2114 | 2114 | $course = Database::fetch_array($res); |
| 2115 | 2115 | $courseId = $course['id']; |
@@ -2154,34 +2154,34 @@ discard block |
||
| 2154 | 2154 | } |
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | - $course_dir = api_get_path(SYS_COURSE_PATH) . $course['directory']; |
|
| 2158 | - $archive_dir = api_get_path(SYS_ARCHIVE_PATH) . $course['directory'] . '_' . time(); |
|
| 2157 | + $course_dir = api_get_path(SYS_COURSE_PATH).$course['directory']; |
|
| 2158 | + $archive_dir = api_get_path(SYS_ARCHIVE_PATH).$course['directory'].'_'.time(); |
|
| 2159 | 2159 | if (is_dir($course_dir)) { |
| 2160 | 2160 | rename($course_dir, $archive_dir); |
| 2161 | 2161 | } |
| 2162 | 2162 | |
| 2163 | 2163 | // Unsubscribe all users from the course |
| 2164 | - $sql = "DELETE FROM $table_course_user WHERE c_id='" . $courseId . "'"; |
|
| 2164 | + $sql = "DELETE FROM $table_course_user WHERE c_id='".$courseId."'"; |
|
| 2165 | 2165 | Database::query($sql); |
| 2166 | 2166 | // Delete the course from the sessions tables |
| 2167 | - $sql = "DELETE FROM $table_session_course WHERE c_id='" . $courseId . "'"; |
|
| 2167 | + $sql = "DELETE FROM $table_session_course WHERE c_id='".$courseId."'"; |
|
| 2168 | 2168 | Database::query($sql); |
| 2169 | - $sql = "DELETE FROM $table_session_course_user WHERE c_id='" . $courseId . "'"; |
|
| 2169 | + $sql = "DELETE FROM $table_session_course_user WHERE c_id='".$courseId."'"; |
|
| 2170 | 2170 | Database::query($sql); |
| 2171 | 2171 | |
| 2172 | 2172 | // Delete from Course - URL |
| 2173 | - $sql = "DELETE FROM $table_course_rel_url WHERE c_id = '" . $courseId. "'"; |
|
| 2173 | + $sql = "DELETE FROM $table_course_rel_url WHERE c_id = '".$courseId."'"; |
|
| 2174 | 2174 | Database::query($sql); |
| 2175 | 2175 | |
| 2176 | - $sql = 'SELECT survey_id FROM ' . $table_course_survey . ' WHERE course_code="' . $codeFiltered . '"'; |
|
| 2176 | + $sql = 'SELECT survey_id FROM '.$table_course_survey.' WHERE course_code="'.$codeFiltered.'"'; |
|
| 2177 | 2177 | $result_surveys = Database::query($sql); |
| 2178 | 2178 | while ($surveys = Database::fetch_array($result_surveys)) { |
| 2179 | 2179 | $survey_id = $surveys[0]; |
| 2180 | - $sql = 'DELETE FROM ' . $table_course_survey_question . ' WHERE survey_id="' . $survey_id . '"'; |
|
| 2180 | + $sql = 'DELETE FROM '.$table_course_survey_question.' WHERE survey_id="'.$survey_id.'"'; |
|
| 2181 | 2181 | Database::query($sql); |
| 2182 | - $sql = 'DELETE FROM ' . $table_course_survey_question_option . ' WHERE survey_id="' . $survey_id . '"'; |
|
| 2182 | + $sql = 'DELETE FROM '.$table_course_survey_question_option.' WHERE survey_id="'.$survey_id.'"'; |
|
| 2183 | 2183 | Database::query($sql); |
| 2184 | - $sql = 'DELETE FROM ' . $table_course_survey . ' WHERE survey_id="' . $survey_id . '"'; |
|
| 2184 | + $sql = 'DELETE FROM '.$table_course_survey.' WHERE survey_id="'.$survey_id.'"'; |
|
| 2185 | 2185 | Database::query($sql); |
| 2186 | 2186 | } |
| 2187 | 2187 | |
@@ -2214,7 +2214,7 @@ discard block |
||
| 2214 | 2214 | Database::query($sql); |
| 2215 | 2215 | |
| 2216 | 2216 | // Delete the course from the database |
| 2217 | - $sql = "DELETE FROM $table_course WHERE code = '" . $codeFiltered . "'"; |
|
| 2217 | + $sql = "DELETE FROM $table_course WHERE code = '".$codeFiltered."'"; |
|
| 2218 | 2218 | Database::query($sql); |
| 2219 | 2219 | |
| 2220 | 2220 | // delete extra course fields |
@@ -2260,15 +2260,15 @@ discard block |
||
| 2260 | 2260 | while ($row = Database::fetch_array($res_table, 'ASSOC')) { |
| 2261 | 2261 | $row_to_save = array(); |
| 2262 | 2262 | foreach ($row as $key => $value) { |
| 2263 | - $row_to_save[$key] = $key . "='" . Database::escape_string($row[$key]) . "'"; |
|
| 2263 | + $row_to_save[$key] = $key."='".Database::escape_string($row[$key])."'"; |
|
| 2264 | 2264 | } |
| 2265 | - $sql_dump .= "\nINSERT INTO $table SET " . implode(', ', $row_to_save) . ';'; |
|
| 2265 | + $sql_dump .= "\nINSERT INTO $table SET ".implode(', ', $row_to_save).';'; |
|
| 2266 | 2266 | } |
| 2267 | 2267 | } |
| 2268 | 2268 | } |
| 2269 | 2269 | |
| 2270 | - if (is_dir(api_get_path(SYS_COURSE_PATH) . $course['directory'])) { |
|
| 2271 | - $file_name = api_get_path(SYS_COURSE_PATH) . $course['directory'] . '/mysql_dump.sql'; |
|
| 2270 | + if (is_dir(api_get_path(SYS_COURSE_PATH).$course['directory'])) { |
|
| 2271 | + $file_name = api_get_path(SYS_COURSE_PATH).$course['directory'].'/mysql_dump.sql'; |
|
| 2272 | 2272 | $handle = fopen($file_name, 'a+'); |
| 2273 | 2273 | if ($handle !== false) { |
| 2274 | 2274 | fwrite($handle, $sql_dump); |
@@ -2296,13 +2296,13 @@ discard block |
||
| 2296 | 2296 | $TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE); |
| 2297 | 2297 | $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER); |
| 2298 | 2298 | |
| 2299 | - $course_title = Database::result(Database::query('SELECT title FROM ' . $TABLECOURSE . ' WHERE code="' . $course_code . '"'), |
|
| 2299 | + $course_title = Database::result(Database::query('SELECT title FROM '.$TABLECOURSE.' WHERE code="'.$course_code.'"'), |
|
| 2300 | 2300 | 0, 0); |
| 2301 | 2301 | |
| 2302 | 2302 | $sql = 'SELECT course.code as code, course.title as title, cu.sort as sort |
| 2303 | - FROM ' . $TABLECOURSUSER . ' as cu, ' . $TABLECOURSE . ' as course |
|
| 2304 | - WHERE course.id = cu.c_id AND user_id = "' . $user_id . '" AND |
|
| 2305 | - cu.relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND |
|
| 2303 | + FROM ' . $TABLECOURSUSER.' as cu, '.$TABLECOURSE.' as course |
|
| 2304 | + WHERE course.id = cu.c_id AND user_id = "' . $user_id.'" AND |
|
| 2305 | + cu.relation_type<>' . COURSE_RELATION_TYPE_RRHH.' AND |
|
| 2306 | 2306 | user_course_cat = 0 |
| 2307 | 2307 | ORDER BY cu.sort'; |
| 2308 | 2308 | $result = Database::query($sql); |
@@ -2321,21 +2321,21 @@ discard block |
||
| 2321 | 2321 | $course_found = true; |
| 2322 | 2322 | $course_sort = $courses['sort']; |
| 2323 | 2323 | if ($counter == 0) { |
| 2324 | - $sql = 'UPDATE ' . $TABLECOURSUSER . ' |
|
| 2324 | + $sql = 'UPDATE '.$TABLECOURSUSER.' |
|
| 2325 | 2325 | SET sort = sort+1 |
| 2326 | 2326 | WHERE |
| 2327 | - user_id= "' . $user_id . '" AND |
|
| 2328 | - relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' |
|
| 2327 | + user_id= "' . $user_id.'" AND |
|
| 2328 | + relation_type<>' . COURSE_RELATION_TYPE_RRHH.' |
|
| 2329 | 2329 | AND user_course_cat="0" |
| 2330 | - AND sort > "' . $course_sort . '"'; |
|
| 2330 | + AND sort > "' . $course_sort.'"'; |
|
| 2331 | 2331 | $course_sort++; |
| 2332 | 2332 | } else { |
| 2333 | - $sql = 'UPDATE ' . $TABLECOURSUSER . ' SET sort = sort+1 |
|
| 2333 | + $sql = 'UPDATE '.$TABLECOURSUSER.' SET sort = sort+1 |
|
| 2334 | 2334 | WHERE |
| 2335 | - user_id= "' . $user_id . '" AND |
|
| 2336 | - relation_type<>' . COURSE_RELATION_TYPE_RRHH . ' AND |
|
| 2335 | + user_id= "' . $user_id.'" AND |
|
| 2336 | + relation_type<>' . COURSE_RELATION_TYPE_RRHH.' AND |
|
| 2337 | 2337 | user_course_cat="0" AND |
| 2338 | - sort >= "' . $course_sort . '"'; |
|
| 2338 | + sort >= "' . $course_sort.'"'; |
|
| 2339 | 2339 | } |
| 2340 | 2340 | Database::query($sql); |
| 2341 | 2341 | break; |
@@ -2348,9 +2348,9 @@ discard block |
||
| 2348 | 2348 | |
| 2349 | 2349 | // We must register the course in the beginning of the list |
| 2350 | 2350 | if (!$course_found) { |
| 2351 | - $course_sort = Database::result(Database::query('SELECT min(sort) as min_sort FROM ' . $TABLECOURSUSER . ' WHERE user_id="' . $user_id . '" AND user_course_cat="0"'), |
|
| 2351 | + $course_sort = Database::result(Database::query('SELECT min(sort) as min_sort FROM '.$TABLECOURSUSER.' WHERE user_id="'.$user_id.'" AND user_course_cat="0"'), |
|
| 2352 | 2352 | 0, 0); |
| 2353 | - Database::query('UPDATE ' . $TABLECOURSUSER . ' SET sort = sort+1 WHERE user_id= "' . $user_id . '" AND user_course_cat="0"'); |
|
| 2353 | + Database::query('UPDATE '.$TABLECOURSUSER.' SET sort = sort+1 WHERE user_id= "'.$user_id.'" AND user_course_cat="0"'); |
|
| 2354 | 2354 | } |
| 2355 | 2355 | } |
| 2356 | 2356 | return $course_sort; |
@@ -2365,11 +2365,11 @@ discard block |
||
| 2365 | 2365 | public static function course_exists($course_code, $accept_virtual = false) |
| 2366 | 2366 | { |
| 2367 | 2367 | if ($accept_virtual === true) { |
| 2368 | - $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' |
|
| 2369 | - WHERE code="' . Database::escape_string($course_code) . '" OR visual_code="' . Database::escape_string($course_code) . '"'; |
|
| 2368 | + $sql = 'SELECT 1 FROM '.Database::get_main_table(TABLE_MAIN_COURSE).' |
|
| 2369 | + WHERE code="' . Database::escape_string($course_code).'" OR visual_code="'.Database::escape_string($course_code).'"'; |
|
| 2370 | 2370 | } else { |
| 2371 | - $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' |
|
| 2372 | - WHERE code="' . Database::escape_string($course_code) . '"'; |
|
| 2371 | + $sql = 'SELECT 1 FROM '.Database::get_main_table(TABLE_MAIN_COURSE).' |
|
| 2372 | + WHERE code="' . Database::escape_string($course_code).'"'; |
|
| 2373 | 2373 | } |
| 2374 | 2374 | |
| 2375 | 2375 | return Database::num_rows(Database::query($sql)); |
@@ -2395,7 +2395,7 @@ discard block |
||
| 2395 | 2395 | $student = api_get_user_info($user_id); |
| 2396 | 2396 | |
| 2397 | 2397 | $name_course = $information['title']; |
| 2398 | - $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " WHERE c_id ='" . $courseId . "'"; |
|
| 2398 | + $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." WHERE c_id ='".$courseId."'"; |
|
| 2399 | 2399 | |
| 2400 | 2400 | // TODO: Ivan: This is a mistake, please, have a look at it. Intention here is diffcult to be guessed. |
| 2401 | 2401 | //if ($send_to_tutor_also = true) |
@@ -2410,18 +2410,18 @@ discard block |
||
| 2410 | 2410 | while ($row = Database::fetch_array($result)) { |
| 2411 | 2411 | $tutor = api_get_user_info($row['user_id']); |
| 2412 | 2412 | $emailto = $tutor['email']; |
| 2413 | - $emailsubject = get_lang('NewUserInTheCourse') . ': ' . $name_course; |
|
| 2414 | - $emailbody = get_lang('Dear') . ': ' . api_get_person_name($tutor['firstname'], $tutor['lastname']) . "\n"; |
|
| 2415 | - $emailbody .= get_lang('MessageNewUserInTheCourse') . ': ' . $name_course . "\n"; |
|
| 2416 | - $emailbody .= get_lang('UserName') . ': ' . $student['username'] . "\n"; |
|
| 2413 | + $emailsubject = get_lang('NewUserInTheCourse').': '.$name_course; |
|
| 2414 | + $emailbody = get_lang('Dear').': '.api_get_person_name($tutor['firstname'], $tutor['lastname'])."\n"; |
|
| 2415 | + $emailbody .= get_lang('MessageNewUserInTheCourse').': '.$name_course."\n"; |
|
| 2416 | + $emailbody .= get_lang('UserName').': '.$student['username']."\n"; |
|
| 2417 | 2417 | if (api_is_western_name_order()) { |
| 2418 | - $emailbody .= get_lang('FirstName') . ': ' . $student['firstname'] . "\n"; |
|
| 2419 | - $emailbody .= get_lang('LastName') . ': ' . $student['lastname'] . "\n"; |
|
| 2418 | + $emailbody .= get_lang('FirstName').': '.$student['firstname']."\n"; |
|
| 2419 | + $emailbody .= get_lang('LastName').': '.$student['lastname']."\n"; |
|
| 2420 | 2420 | } else { |
| 2421 | - $emailbody .= get_lang('LastName') . ': ' . $student['lastname'] . "\n"; |
|
| 2422 | - $emailbody .= get_lang('FirstName') . ': ' . $student['firstname'] . "\n"; |
|
| 2421 | + $emailbody .= get_lang('LastName').': '.$student['lastname']."\n"; |
|
| 2422 | + $emailbody .= get_lang('FirstName').': '.$student['firstname']."\n"; |
|
| 2423 | 2423 | } |
| 2424 | - $emailbody .= get_lang('Email') . ': <a href="mailto:' . $student['email'] . '">' . $student['email'] ."</a>\n\n"; |
|
| 2424 | + $emailbody .= get_lang('Email').': <a href="mailto:'.$student['email'].'">'.$student['email']."</a>\n\n"; |
|
| 2425 | 2425 | $recipient_name = api_get_person_name($tutor['firstname'], $tutor['lastname'], null, |
| 2426 | 2426 | PERSON_NAME_EMAIL_ADDRESS); |
| 2427 | 2427 | $sender_name = api_get_person_name(api_get_setting('administratorName'), |
@@ -2523,9 +2523,9 @@ discard block |
||
| 2523 | 2523 | |
| 2524 | 2524 | $with_special_courses = $without_special_courses = ''; |
| 2525 | 2525 | if (!empty($special_course_list)) { |
| 2526 | - $sc_string = '"' . implode('","', $special_course_list) . '"'; |
|
| 2527 | - $with_special_courses = ' course.code IN (' . $sc_string . ')'; |
|
| 2528 | - $without_special_courses = ' AND course.code NOT IN (' . $sc_string . ')'; |
|
| 2526 | + $sc_string = '"'.implode('","', $special_course_list).'"'; |
|
| 2527 | + $with_special_courses = ' course.code IN ('.$sc_string.')'; |
|
| 2528 | + $without_special_courses = ' AND course.code NOT IN ('.$sc_string.')'; |
|
| 2529 | 2529 | } |
| 2530 | 2530 | |
| 2531 | 2531 | if (!empty($with_special_courses)) { |
@@ -2569,8 +2569,8 @@ discard block |
||
| 2569 | 2569 | |
| 2570 | 2570 | if ($include_sessions === true) { |
| 2571 | 2571 | $sql = "SELECT DISTINCT(c.code), c.id as real_id |
| 2572 | - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " s, |
|
| 2573 | - " . Database::get_main_table(TABLE_MAIN_COURSE) . " c |
|
| 2572 | + FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." s, |
|
| 2573 | + " . Database::get_main_table(TABLE_MAIN_COURSE)." c |
|
| 2574 | 2574 | WHERE user_id = $user_id AND s.c_id = c.id"; |
| 2575 | 2575 | $r = Database::query($sql); |
| 2576 | 2576 | while ($row = Database::fetch_array($r, 'ASSOC')) { |
@@ -2591,7 +2591,7 @@ discard block |
||
| 2591 | 2591 | public static function get_course_id_from_path($path) |
| 2592 | 2592 | { |
| 2593 | 2593 | $path = Database::escape_string(str_replace('.', '', str_replace('/', '', $path))); |
| 2594 | - $res = Database::query("SELECT code FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " |
|
| 2594 | + $res = Database::query("SELECT code FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." |
|
| 2595 | 2595 | WHERE directory LIKE BINARY '$path'"); |
| 2596 | 2596 | if ($res === false) { |
| 2597 | 2597 | return false; |
@@ -2613,8 +2613,8 @@ discard block |
||
| 2613 | 2613 | public static function get_courses_info_from_visual_code($code) |
| 2614 | 2614 | { |
| 2615 | 2615 | $result = array(); |
| 2616 | - $sql_result = Database::query("SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . " |
|
| 2617 | - WHERE visual_code = '" . Database::escape_string($code) . "'"); |
|
| 2616 | + $sql_result = Database::query("SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." |
|
| 2617 | + WHERE visual_code = '" . Database::escape_string($code)."'"); |
|
| 2618 | 2618 | while ($virtual_course = Database::fetch_array($sql_result)) { |
| 2619 | 2619 | $result[] = $virtual_course; |
| 2620 | 2620 | } |
@@ -2630,10 +2630,10 @@ discard block |
||
| 2630 | 2630 | public static function get_emails_of_tutors_to_course($courseId) |
| 2631 | 2631 | { |
| 2632 | 2632 | $list = array(); |
| 2633 | - $res = Database::query("SELECT user_id FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . " |
|
| 2634 | - WHERE c_id ='" . intval($courseId) . "' AND status=1"); |
|
| 2633 | + $res = Database::query("SELECT user_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." |
|
| 2634 | + WHERE c_id ='" . intval($courseId)."' AND status=1"); |
|
| 2635 | 2635 | while ($list_users = Database::fetch_array($res)) { |
| 2636 | - $result = Database::query("SELECT * FROM " . Database::get_main_table(TABLE_MAIN_USER) . " |
|
| 2636 | + $result = Database::query("SELECT * FROM ".Database::get_main_table(TABLE_MAIN_USER)." |
|
| 2637 | 2637 | WHERE user_id=" . $list_users['user_id']); |
| 2638 | 2638 | while ($row_user = Database::fetch_array($result)) { |
| 2639 | 2639 | $name_teacher = api_get_person_name($row_user['firstname'], $row_user['lastname']); |
@@ -2676,7 +2676,7 @@ discard block |
||
| 2676 | 2676 | } |
| 2677 | 2677 | |
| 2678 | 2678 | $sql = "SELECT firstname, lastname, email FROM $tbl_user |
| 2679 | - WHERE user_id IN (" . implode(",", $user_ids) . ")"; |
|
| 2679 | + WHERE user_id IN (".implode(",", $user_ids).")"; |
|
| 2680 | 2680 | $rs_user = Database::query($sql); |
| 2681 | 2681 | |
| 2682 | 2682 | while ($row_emails = Database::fetch_array($rs_user)) { |
@@ -2722,9 +2722,9 @@ discard block |
||
| 2722 | 2722 | */ |
| 2723 | 2723 | public static function update_attribute($id, $name, $value) |
| 2724 | 2724 | { |
| 2725 | - $id = (int)$id; |
|
| 2725 | + $id = (int) $id; |
|
| 2726 | 2726 | $table = Database::get_main_table(TABLE_MAIN_COURSE); |
| 2727 | - $sql = "UPDATE $table SET $name = '" . Database::escape_string($value) . "' |
|
| 2727 | + $sql = "UPDATE $table SET $name = '".Database::escape_string($value)."' |
|
| 2728 | 2728 | WHERE id = '$id';"; |
| 2729 | 2729 | return Database::query($sql); |
| 2730 | 2730 | } |
@@ -2739,7 +2739,7 @@ discard block |
||
| 2739 | 2739 | */ |
| 2740 | 2740 | public static function update_attributes($id, $attributes) |
| 2741 | 2741 | { |
| 2742 | - $id = (int)$id; |
|
| 2742 | + $id = (int) $id; |
|
| 2743 | 2743 | $table = Database::get_main_table(TABLE_MAIN_COURSE); |
| 2744 | 2744 | $sql = "UPDATE $table SET "; |
| 2745 | 2745 | $i = 0; |
@@ -2748,7 +2748,7 @@ discard block |
||
| 2748 | 2748 | if ($i > 0) { |
| 2749 | 2749 | $sql .= ", "; |
| 2750 | 2750 | } |
| 2751 | - $sql .= " $name = '" . Database::escape_string($value) . "'"; |
|
| 2751 | + $sql .= " $name = '".Database::escape_string($value)."'"; |
|
| 2752 | 2752 | $i++; |
| 2753 | 2753 | } |
| 2754 | 2754 | } |
@@ -2785,9 +2785,9 @@ discard block |
||
| 2785 | 2785 | { |
| 2786 | 2786 | return Database::result( |
| 2787 | 2787 | Database::query('SELECT sc.id session_category |
| 2788 | - FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY) . ' sc |
|
| 2789 | - INNER JOIN ' . Database::get_main_table(TABLE_MAIN_SESSION) . ' s |
|
| 2790 | - ON sc.id=s.session_category_id WHERE s.id="' . Database::escape_string($session_id) . '"'), |
|
| 2788 | + FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY).' sc |
|
| 2789 | + INNER JOIN ' . Database::get_main_table(TABLE_MAIN_SESSION).' s |
|
| 2790 | + ON sc.id=s.session_category_id WHERE s.id="' . Database::escape_string($session_id).'"'), |
|
| 2791 | 2791 | 0, |
| 2792 | 2792 | 'session_category' |
| 2793 | 2793 | ); |
@@ -2830,13 +2830,13 @@ discard block |
||
| 2830 | 2830 | $data .= '<div class="sectiontitle">'; |
| 2831 | 2831 | if (api_is_allowed_to_edit() && $action_show) { |
| 2832 | 2832 | //delete |
| 2833 | - $data .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete&description_id=' . $description->id . '" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), |
|
| 2834 | - ENT_QUOTES, $charset)) . '\')) return false;">'; |
|
| 2833 | + $data .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&description_id='.$description->id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), |
|
| 2834 | + ENT_QUOTES, $charset)).'\')) return false;">'; |
|
| 2835 | 2835 | $data .= Display::return_icon('delete.gif', get_lang('Delete'), |
| 2836 | 2836 | array('style' => 'vertical-align:middle;float:right;')); |
| 2837 | 2837 | $data .= '</a> '; |
| 2838 | 2838 | //edit |
| 2839 | - $data .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&description_id=' . $description->id . '">'; |
|
| 2839 | + $data .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&description_id='.$description->id.'">'; |
|
| 2840 | 2840 | $data .= Display::return_icon('edit.png', get_lang('Edit'), |
| 2841 | 2841 | array('style' => 'vertical-align:middle;float:right; padding-right:4px;'), ICON_SIZE_SMALL); |
| 2842 | 2842 | $data .= '</a> '; |
@@ -2848,7 +2848,7 @@ discard block |
||
| 2848 | 2848 | $data .= '</div>'; |
| 2849 | 2849 | } |
| 2850 | 2850 | } else { |
| 2851 | - $data .= '<em>' . get_lang('ThisCourseDescriptionIsEmpty') . '</em>'; |
|
| 2851 | + $data .= '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>'; |
|
| 2852 | 2852 | } |
| 2853 | 2853 | |
| 2854 | 2854 | return $data; |
@@ -2915,11 +2915,11 @@ discard block |
||
| 2915 | 2915 | ON (a.c_id = s.c_id) |
| 2916 | 2916 | WHERE |
| 2917 | 2917 | user_id = $hr_manager_id AND |
| 2918 | - relation_type=" . COURSE_RELATION_TYPE_RRHH . " AND |
|
| 2919 | - access_url_id = " . api_get_current_access_url_id() . ""; |
|
| 2918 | + relation_type=".COURSE_RELATION_TYPE_RRHH." AND |
|
| 2919 | + access_url_id = " . api_get_current_access_url_id().""; |
|
| 2920 | 2920 | } else { |
| 2921 | 2921 | $sql = "SELECT c_id FROM $tbl_course_rel_user |
| 2922 | - WHERE user_id = $hr_manager_id AND relation_type=" . COURSE_RELATION_TYPE_RRHH . " "; |
|
| 2922 | + WHERE user_id = $hr_manager_id AND relation_type=".COURSE_RELATION_TYPE_RRHH." "; |
|
| 2923 | 2923 | } |
| 2924 | 2924 | $result = Database::query($sql); |
| 2925 | 2925 | if (Database::num_rows($result) > 0) { |
@@ -2928,7 +2928,7 @@ discard block |
||
| 2928 | 2928 | WHERE |
| 2929 | 2929 | c_id = '{$row['c_id']}' AND |
| 2930 | 2930 | user_id = $hr_manager_id AND |
| 2931 | - relation_type=" . COURSE_RELATION_TYPE_RRHH . " "; |
|
| 2931 | + relation_type=".COURSE_RELATION_TYPE_RRHH." "; |
|
| 2932 | 2932 | Database::query($sql); |
| 2933 | 2933 | } |
| 2934 | 2934 | } |
@@ -2939,7 +2939,7 @@ discard block |
||
| 2939 | 2939 | $courseInfo = api_get_course_info($course_code); |
| 2940 | 2940 | $courseId = $courseInfo['real_id']; |
| 2941 | 2941 | $sql = "INSERT IGNORE INTO $tbl_course_rel_user(c_id, user_id, status, relation_type) |
| 2942 | - VALUES($courseId, $hr_manager_id, '" . DRH . "', '" . COURSE_RELATION_TYPE_RRHH . "')"; |
|
| 2942 | + VALUES($courseId, $hr_manager_id, '".DRH."', '".COURSE_RELATION_TYPE_RRHH."')"; |
|
| 2943 | 2943 | $result = Database::query($sql); |
| 2944 | 2944 | if (Database::affected_rows($result)) { |
| 2945 | 2945 | $affected_rows++; |
@@ -3022,16 +3022,16 @@ discard block |
||
| 3022 | 3022 | case COURSEMANAGER: |
| 3023 | 3023 | $whereConditions .= " AND cru.user_id = '$user_id'"; |
| 3024 | 3024 | if (!$showAllAssignedCourses) { |
| 3025 | - $whereConditions .= " AND status = " . COURSEMANAGER; |
|
| 3025 | + $whereConditions .= " AND status = ".COURSEMANAGER; |
|
| 3026 | 3026 | } else { |
| 3027 | - $whereConditions .= " AND relation_type = " . COURSE_RELATION_TYPE_COURSE_MANAGER; |
|
| 3027 | + $whereConditions .= " AND relation_type = ".COURSE_RELATION_TYPE_COURSE_MANAGER; |
|
| 3028 | 3028 | } |
| 3029 | 3029 | break; |
| 3030 | 3030 | case DRH: |
| 3031 | 3031 | $whereConditions .= " AND |
| 3032 | 3032 | cru.user_id = '$user_id' AND |
| 3033 | - status = " . DRH . " AND |
|
| 3034 | - relation_type = '" . COURSE_RELATION_TYPE_RRHH . "' |
|
| 3033 | + status = ".DRH." AND |
|
| 3034 | + relation_type = '" . COURSE_RELATION_TYPE_RRHH."' |
|
| 3035 | 3035 | "; |
| 3036 | 3036 | break; |
| 3037 | 3037 | } |
@@ -3052,7 +3052,7 @@ discard block |
||
| 3052 | 3052 | ); |
| 3053 | 3053 | if (!empty($courseList)) { |
| 3054 | 3054 | $courseListToString = implode("','", array_keys($courseList)); |
| 3055 | - $whereConditions .= " AND c.id IN ('" . $courseListToString . "')"; |
|
| 3055 | + $whereConditions .= " AND c.id IN ('".$courseListToString."')"; |
|
| 3056 | 3056 | } |
| 3057 | 3057 | $tableSessionRelCourse = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); |
| 3058 | 3058 | $orderBy = ' ORDER BY position'; |
@@ -3068,7 +3068,7 @@ discard block |
||
| 3068 | 3068 | INNER JOIN $tbl_course_rel_access_url a ON (a.c_id = c.id) |
| 3069 | 3069 | $extraInnerJoin |
| 3070 | 3070 | WHERE |
| 3071 | - access_url_id = " . api_get_current_access_url_id() . " |
|
| 3071 | + access_url_id = ".api_get_current_access_url_id()." |
|
| 3072 | 3072 | $whereConditions |
| 3073 | 3073 | $orderBy |
| 3074 | 3074 | "; |
@@ -3128,10 +3128,10 @@ discard block |
||
| 3128 | 3128 | { |
| 3129 | 3129 | $course_info = api_get_course_info($course_code); |
| 3130 | 3130 | // course path |
| 3131 | - $store_path = api_get_path(SYS_COURSE_PATH) . $course_info['path']; |
|
| 3131 | + $store_path = api_get_path(SYS_COURSE_PATH).$course_info['path']; |
|
| 3132 | 3132 | // image name for courses |
| 3133 | - $course_image = $store_path . '/course-pic.png'; |
|
| 3134 | - $course_medium_image = $store_path . '/course-pic85x85.png'; |
|
| 3133 | + $course_image = $store_path.'/course-pic.png'; |
|
| 3134 | + $course_medium_image = $store_path.'/course-pic85x85.png'; |
|
| 3135 | 3135 | |
| 3136 | 3136 | if (file_exists($course_image)) { |
| 3137 | 3137 | unlink($course_image); |
@@ -3165,11 +3165,11 @@ discard block |
||
| 3165 | 3165 | { |
| 3166 | 3166 | $course_info = api_get_course_info($courseCode); |
| 3167 | 3167 | // course path |
| 3168 | - $storePath = api_get_path(SYS_COURSE_PATH) . $course_info['path']; |
|
| 3168 | + $storePath = api_get_path(SYS_COURSE_PATH).$course_info['path']; |
|
| 3169 | 3169 | // image name for courses |
| 3170 | - $courseImage = $storePath . '/course-pic.png'; |
|
| 3171 | - $courseMediumImage = $storePath . '/course-pic85x85.png'; |
|
| 3172 | - $courseSmallImage = $storePath . '/course-pic32.png'; |
|
| 3170 | + $courseImage = $storePath.'/course-pic.png'; |
|
| 3171 | + $courseMediumImage = $storePath.'/course-pic85x85.png'; |
|
| 3172 | + $courseSmallImage = $storePath.'/course-pic32.png'; |
|
| 3173 | 3173 | |
| 3174 | 3174 | if (file_exists($courseImage)) { |
| 3175 | 3175 | unlink($courseImage); |
@@ -3197,26 +3197,26 @@ discard block |
||
| 3197 | 3197 | |
| 3198 | 3198 | $notifications = isset($params['notifications']) ? $params['notifications'] : null; |
| 3199 | 3199 | |
| 3200 | - $html .= '<h3>' . $params['title'] . $notifications . '</h3> '; |
|
| 3200 | + $html .= '<h3>'.$params['title'].$notifications.'</h3> '; |
|
| 3201 | 3201 | |
| 3202 | 3202 | if (isset($params['description'])) { |
| 3203 | - $html .= '<p>' . $params['description'] . '</p>'; |
|
| 3203 | + $html .= '<p>'.$params['description'].'</p>'; |
|
| 3204 | 3204 | } |
| 3205 | 3205 | if (!empty($params['subtitle'])) { |
| 3206 | - $html .= '<small>' . $params['subtitle'] . '</small>'; |
|
| 3206 | + $html .= '<small>'.$params['subtitle'].'</small>'; |
|
| 3207 | 3207 | } |
| 3208 | 3208 | if (!empty($params['teachers'])) { |
| 3209 | - $html .= '<h5 class="teacher">' . Display::return_icon('teacher.png', get_lang('Teacher'), array(), |
|
| 3210 | - ICON_SIZE_TINY) . $params['teachers'] . '</h5>'; |
|
| 3209 | + $html .= '<h5 class="teacher">'.Display::return_icon('teacher.png', get_lang('Teacher'), array(), |
|
| 3210 | + ICON_SIZE_TINY).$params['teachers'].'</h5>'; |
|
| 3211 | 3211 | } |
| 3212 | 3212 | if (!empty($params['coaches'])) { |
| 3213 | - $html .= '<h5 class="teacher">' . Display::return_icon('teacher.png', get_lang('Coach'), array(), |
|
| 3214 | - ICON_SIZE_TINY) . $params['coaches'] . '</h5>'; |
|
| 3213 | + $html .= '<h5 class="teacher">'.Display::return_icon('teacher.png', get_lang('Coach'), array(), |
|
| 3214 | + ICON_SIZE_TINY).$params['coaches'].'</h5>'; |
|
| 3215 | 3215 | } |
| 3216 | 3216 | |
| 3217 | 3217 | $html .= '</div>'; |
| 3218 | 3218 | $params['right_actions'] = isset($params['right_actions']) ? $params['right_actions'] : null; |
| 3219 | - $html .= '<div class="pull-right course-box-actions">' . $params['right_actions'] . '</div>'; |
|
| 3219 | + $html .= '<div class="pull-right course-box-actions">'.$params['right_actions'].'</div>'; |
|
| 3220 | 3220 | $html .= '</div>'; |
| 3221 | 3221 | $html .= '</div>'; |
| 3222 | 3222 | return $html; |
@@ -3232,11 +3232,11 @@ discard block |
||
| 3232 | 3232 | $html = ''; |
| 3233 | 3233 | $html .= '<div class="row">'; |
| 3234 | 3234 | $html .= '<div class="col-md-2">'; |
| 3235 | - if (!empty($params['link'])){ |
|
| 3235 | + if (!empty($params['link'])) { |
|
| 3236 | 3236 | $html .= '<a class="thumbnail" href="'.$params['link'].'">'; |
| 3237 | 3237 | $html .= $params['icon']; |
| 3238 | 3238 | $html .= '</a>'; |
| 3239 | - }else{ |
|
| 3239 | + } else { |
|
| 3240 | 3240 | $html .= $params['icon']; |
| 3241 | 3241 | } |
| 3242 | 3242 | $html .= '</div>'; |
@@ -3263,13 +3263,13 @@ discard block |
||
| 3263 | 3263 | if ($is_sub_content) { |
| 3264 | 3264 | $class = "course_item"; |
| 3265 | 3265 | } |
| 3266 | - $html .= '<div class="' . $class . '">'; |
|
| 3266 | + $html .= '<div class="'.$class.'">'; |
|
| 3267 | 3267 | $html .= '<div class="panel-body">'; |
| 3268 | 3268 | $html .= '<div class="course-items">'; |
| 3269 | 3269 | $html .= ' <div class="row">'; |
| 3270 | 3270 | $html .= '<div class="col-md-2">'; |
| 3271 | 3271 | if (!empty($params['link'])) { |
| 3272 | - $html .= '<a class="thumbnail" href="' . $params['link'] . '">'; |
|
| 3272 | + $html .= '<a class="thumbnail" href="'.$params['link'].'">'; |
|
| 3273 | 3273 | $html .= $params['icon']; |
| 3274 | 3274 | $html .= '</a>'; |
| 3275 | 3275 | } else { |
@@ -3282,25 +3282,25 @@ discard block |
||
| 3282 | 3282 | $param_class = isset($params['class']) ? $params['class'] : ''; |
| 3283 | 3283 | $params['right_actions'] = isset($params['right_actions']) ? $params['right_actions'] : ''; |
| 3284 | 3284 | |
| 3285 | - $html .= '<div class="col-md-10 ' . $param_class . '">'; |
|
| 3286 | - $html .= '<div class="pull-right">' . $params['right_actions'] . '</div>'; |
|
| 3287 | - $html .= '<h4 class="course-items-title">' . $params['title'] . $notifications . '</h4> '; |
|
| 3285 | + $html .= '<div class="col-md-10 '.$param_class.'">'; |
|
| 3286 | + $html .= '<div class="pull-right">'.$params['right_actions'].'</div>'; |
|
| 3287 | + $html .= '<h4 class="course-items-title">'.$params['title'].$notifications.'</h4> '; |
|
| 3288 | 3288 | |
| 3289 | 3289 | if (isset($params['show_description'], $params['description']) && $params['show_description'] == 1) { |
| 3290 | - $html .= '<p class="description-session">' . $params['description'] . '</p>'; |
|
| 3290 | + $html .= '<p class="description-session">'.$params['description'].'</p>'; |
|
| 3291 | 3291 | } |
| 3292 | 3292 | if (!empty($params['subtitle'])) { |
| 3293 | - $html .= '<div class="subtitle-session">' . $params['subtitle'] . '</div>'; |
|
| 3293 | + $html .= '<div class="subtitle-session">'.$params['subtitle'].'</div>'; |
|
| 3294 | 3294 | } |
| 3295 | 3295 | if (!empty($params['teachers'])) { |
| 3296 | - $html .= '<h5 class="course-items-session">' . |
|
| 3297 | - Display::return_icon('teacher.png', get_lang('Teacher'), array(), ICON_SIZE_TINY) . |
|
| 3298 | - $params['teachers'] . '</h5>'; |
|
| 3296 | + $html .= '<h5 class="course-items-session">'. |
|
| 3297 | + Display::return_icon('teacher.png', get_lang('Teacher'), array(), ICON_SIZE_TINY). |
|
| 3298 | + $params['teachers'].'</h5>'; |
|
| 3299 | 3299 | } |
| 3300 | 3300 | if (!empty($params['coaches'])) { |
| 3301 | - $html .= '<h5 class="course-items-session">' . |
|
| 3302 | - Display::return_icon('teacher.png', get_lang('Coach'), array(), ICON_SIZE_TINY) . |
|
| 3303 | - $params['coaches'] . '</h5>'; |
|
| 3301 | + $html .= '<h5 class="course-items-session">'. |
|
| 3302 | + Display::return_icon('teacher.png', get_lang('Coach'), array(), ICON_SIZE_TINY). |
|
| 3303 | + $params['coaches'].'</h5>'; |
|
| 3304 | 3304 | } |
| 3305 | 3305 | |
| 3306 | 3306 | $html .= '</div>'; |
@@ -3321,7 +3321,7 @@ discard block |
||
| 3321 | 3321 | */ |
| 3322 | 3322 | public static function course_item_parent($main_content, $sub_content, $sub_sub_content = null) |
| 3323 | 3323 | { |
| 3324 | - return '<div class="panel panel-default">' . $main_content . $sub_content . $sub_sub_content . '</div>'; |
|
| 3324 | + return '<div class="panel panel-default">'.$main_content.$sub_content.$sub_sub_content.'</div>'; |
|
| 3325 | 3325 | } |
| 3326 | 3326 | |
| 3327 | 3327 | /** |
@@ -3343,7 +3343,7 @@ discard block |
||
| 3343 | 3343 | |
| 3344 | 3344 | $with_special_courses = $without_special_courses = ''; |
| 3345 | 3345 | if (!empty($special_course_list)) { |
| 3346 | - $with_special_courses = ' course.code IN ("' . implode('","', $special_course_list) . '")'; |
|
| 3346 | + $with_special_courses = ' course.code IN ("'.implode('","', $special_course_list).'")'; |
|
| 3347 | 3347 | } |
| 3348 | 3348 | $html = null; |
| 3349 | 3349 | $courseCount = 0; |
@@ -3394,14 +3394,14 @@ discard block |
||
| 3394 | 3394 | $params['right_actions'] = ''; |
| 3395 | 3395 | if (api_is_platform_admin()) { |
| 3396 | 3396 | if ($load_dirs) { |
| 3397 | - $params['right_actions'] .= '<a id="document_preview_' . $course['id'] . '_0" class="document_preview" href="javascript:void(0);">' . |
|
| 3397 | + $params['right_actions'] .= '<a id="document_preview_'.$course['id'].'_0" class="document_preview" href="javascript:void(0);">'. |
|
| 3398 | 3398 | Display::return_icon( |
| 3399 | 3399 | 'folder.png', |
| 3400 | 3400 | get_lang('Documents'), |
| 3401 | 3401 | array('align' => 'absmiddle'), |
| 3402 | 3402 | ICON_SIZE_SMALL |
| 3403 | 3403 | ).'</a>'; |
| 3404 | - $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . |
|
| 3404 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'. |
|
| 3405 | 3405 | Display::return_icon( |
| 3406 | 3406 | 'edit.png', |
| 3407 | 3407 | get_lang('Edit'), |
@@ -3409,13 +3409,13 @@ discard block |
||
| 3409 | 3409 | ICON_SIZE_SMALL |
| 3410 | 3410 | ).'</a>'; |
| 3411 | 3411 | $params['right_actions'] .= Display::div('', array( |
| 3412 | - 'id' => 'document_result_' . $course['id'] . '_0', |
|
| 3412 | + 'id' => 'document_result_'.$course['id'].'_0', |
|
| 3413 | 3413 | 'class' => 'document_preview_container' |
| 3414 | 3414 | )); |
| 3415 | 3415 | } else { |
| 3416 | - $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . |
|
| 3416 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'. |
|
| 3417 | 3417 | Display::return_icon('edit.png', |
| 3418 | - get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; |
|
| 3418 | + get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 3419 | 3419 | } |
| 3420 | 3420 | if ($course['status'] == COURSEMANAGER) { |
| 3421 | 3421 | //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;')); |
@@ -3423,7 +3423,7 @@ discard block |
||
| 3423 | 3423 | } else { |
| 3424 | 3424 | if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { |
| 3425 | 3425 | if ($load_dirs) { |
| 3426 | - $params['right_actions'] .= '<a id="document_preview_' . $course['id'] . '_0" class="document_preview" href="javascript:void(0);">' . |
|
| 3426 | + $params['right_actions'] .= '<a id="document_preview_'.$course['id'].'_0" class="document_preview" href="javascript:void(0);">'. |
|
| 3427 | 3427 | Display::return_icon( |
| 3428 | 3428 | 'folder.png', |
| 3429 | 3429 | get_lang('Documents'), |
@@ -3431,7 +3431,7 @@ discard block |
||
| 3431 | 3431 | ICON_SIZE_SMALL |
| 3432 | 3432 | ).'</a>'; |
| 3433 | 3433 | $params['right_actions'] .= Display::div('', array( |
| 3434 | - 'id' => 'document_result_' . $course['id'] . '_0', |
|
| 3434 | + 'id' => 'document_result_'.$course['id'].'_0', |
|
| 3435 | 3435 | 'class' => 'document_preview_container' |
| 3436 | 3436 | )); |
| 3437 | 3437 | } |
@@ -3439,14 +3439,14 @@ discard block |
||
| 3439 | 3439 | } |
| 3440 | 3440 | |
| 3441 | 3441 | if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) { |
| 3442 | - $course_title = '<a href="' . $course_info['course_public_url'] . '?id_session=0&autoreg=1">' . $course_info['title'] . '</a>'; |
|
| 3442 | + $course_title = '<a href="'.$course_info['course_public_url'].'?id_session=0&autoreg=1">'.$course_info['title'].'</a>'; |
|
| 3443 | 3443 | } else { |
| 3444 | - $course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'), |
|
| 3444 | + $course_title = $course_info['title']." ".Display::tag('span', get_lang('CourseClosed'), |
|
| 3445 | 3445 | array('class' => 'item_closed')); |
| 3446 | 3446 | } |
| 3447 | 3447 | |
| 3448 | 3448 | if (api_get_setting('display_coursecode_in_courselist') == 'true') { |
| 3449 | - $course_title .= ' (' . $course_info['visual_code'] . ') '; |
|
| 3449 | + $course_title .= ' ('.$course_info['visual_code'].') '; |
|
| 3450 | 3450 | } |
| 3451 | 3451 | if (api_get_setting('display_teacher_in_courselist') == 'true') { |
| 3452 | 3452 | $params['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string( |
@@ -3495,7 +3495,7 @@ discard block |
||
| 3495 | 3495 | // Step 1: We get all the categories of the user |
| 3496 | 3496 | $table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); |
| 3497 | 3497 | $sql = "SELECT id, title FROM $table |
| 3498 | - WHERE user_id = '" . $user_id . "' |
|
| 3498 | + WHERE user_id = '".$user_id."' |
|
| 3499 | 3499 | ORDER BY sort ASC"; |
| 3500 | 3500 | $result = Database::query($sql); |
| 3501 | 3501 | $html = null; |
@@ -3556,7 +3556,7 @@ discard block |
||
| 3556 | 3556 | |
| 3557 | 3557 | $without_special_courses = ''; |
| 3558 | 3558 | if (!empty($special_course_list)) { |
| 3559 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; |
|
| 3559 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $special_course_list).'")'; |
|
| 3560 | 3560 | } |
| 3561 | 3561 | |
| 3562 | 3562 | //AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." |
@@ -3575,14 +3575,14 @@ discard block |
||
| 3575 | 3575 | WHERE |
| 3576 | 3576 | course.id = course_rel_user.c_id AND |
| 3577 | 3577 | url.c_id = course.id AND |
| 3578 | - course_rel_user.user_id = '" . $user_id . "' AND |
|
| 3579 | - course_rel_user.user_course_cat = '" . $user_category_id . "' |
|
| 3578 | + course_rel_user.user_id = '".$user_id."' AND |
|
| 3579 | + course_rel_user.user_course_cat = '" . $user_category_id."' |
|
| 3580 | 3580 | $without_special_courses "; |
| 3581 | 3581 | |
| 3582 | 3582 | // If multiple URL access mode is enabled, only fetch courses |
| 3583 | 3583 | // corresponding to the current URL. |
| 3584 | 3584 | if (api_get_multiple_access_url() && $current_url_id != -1) { |
| 3585 | - $sql .= " AND url.c_id = course.id AND access_url_id='" . $current_url_id . "'"; |
|
| 3585 | + $sql .= " AND url.c_id = course.id AND access_url_id='".$current_url_id."'"; |
|
| 3586 | 3586 | } |
| 3587 | 3587 | // Use user's classification for courses (if any). |
| 3588 | 3588 | $sql .= " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC"; |
@@ -3638,17 +3638,17 @@ discard block |
||
| 3638 | 3638 | |
| 3639 | 3639 | if (api_is_platform_admin()) { |
| 3640 | 3640 | if ($load_dirs) { |
| 3641 | - $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', |
|
| 3642 | - get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; |
|
| 3643 | - $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', |
|
| 3644 | - get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; |
|
| 3641 | + $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', |
|
| 3642 | + get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 3643 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', |
|
| 3644 | + get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 3645 | 3645 | $params['right_actions'] .= Display::div('', array( |
| 3646 | - 'id' => 'document_result_' . $course_info['real_id'] . '_0', |
|
| 3646 | + 'id' => 'document_result_'.$course_info['real_id'].'_0', |
|
| 3647 | 3647 | 'class' => 'document_preview_container' |
| 3648 | 3648 | )); |
| 3649 | 3649 | } else { |
| 3650 | - $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', |
|
| 3651 | - get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; |
|
| 3650 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', |
|
| 3651 | + get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 3652 | 3652 | } |
| 3653 | 3653 | |
| 3654 | 3654 | if ($course_info['status'] == COURSEMANAGER) { |
@@ -3657,16 +3657,16 @@ discard block |
||
| 3657 | 3657 | } else { |
| 3658 | 3658 | if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { |
| 3659 | 3659 | if ($load_dirs) { |
| 3660 | - $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_0" class="document_preview" href="javascript:void(0);">' . Display::return_icon('folder.png', |
|
| 3661 | - get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; |
|
| 3660 | + $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', |
|
| 3661 | + get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 3662 | 3662 | $params['right_actions'] .= Display::div('', array( |
| 3663 | - 'id' => 'document_result_' . $course_info['real_id'] . '_0', |
|
| 3663 | + 'id' => 'document_result_'.$course_info['real_id'].'_0', |
|
| 3664 | 3664 | 'class' => 'document_preview_container' |
| 3665 | 3665 | )); |
| 3666 | 3666 | } else { |
| 3667 | 3667 | if ($course_info['status'] == COURSEMANAGER) { |
| 3668 | - $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' . Display::return_icon('edit.png', |
|
| 3669 | - get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>'; |
|
| 3668 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', |
|
| 3669 | + get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 3670 | 3670 | } |
| 3671 | 3671 | } |
| 3672 | 3672 | } |
@@ -3674,16 +3674,16 @@ discard block |
||
| 3674 | 3674 | |
| 3675 | 3675 | $course_title_url = ''; |
| 3676 | 3676 | if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) { |
| 3677 | - $course_title_url = api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?id_session=0'; |
|
| 3677 | + $course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0'; |
|
| 3678 | 3678 | $course_title = Display::url($course_info['title'], $course_title_url); |
| 3679 | 3679 | } else { |
| 3680 | - $course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'), |
|
| 3680 | + $course_title = $course_info['title']." ".Display::tag('span', get_lang('CourseClosed'), |
|
| 3681 | 3681 | array('class' => 'item_closed')); |
| 3682 | 3682 | } |
| 3683 | 3683 | |
| 3684 | 3684 | // Start displaying the course block itself |
| 3685 | 3685 | if (api_get_setting('display_coursecode_in_courselist') == 'true') { |
| 3686 | - $course_title .= ' (' . $course_info['visual_code'] . ') '; |
|
| 3686 | + $course_title .= ' ('.$course_info['visual_code'].') '; |
|
| 3687 | 3687 | } |
| 3688 | 3688 | |
| 3689 | 3689 | if (api_get_setting('display_teacher_in_courselist') == 'true') { |
@@ -3896,14 +3896,14 @@ discard block |
||
| 3896 | 3896 | } |
| 3897 | 3897 | |
| 3898 | 3898 | if ($user_in_course_status == COURSEMANAGER || $sessionCourseAvailable) { |
| 3899 | - $session_url = $course_info['course_public_url'] . '?id_session=' . $course_info['id_session']; |
|
| 3900 | - $session_title = '<h4><a href="' . $session_url. '">'. $course_info['name'] . '</a>'.$notifications.'</h4>'; |
|
| 3899 | + $session_url = $course_info['course_public_url'].'?id_session='.$course_info['id_session']; |
|
| 3900 | + $session_title = '<h4><a href="'.$session_url.'">'.$course_info['name'].'</a>'.$notifications.'</h4>'; |
|
| 3901 | 3901 | } else { |
| 3902 | 3902 | $session_title = $course_info['name']; |
| 3903 | 3903 | } |
| 3904 | 3904 | |
| 3905 | 3905 | } else { |
| 3906 | - $session_title = $course_info['name'] . ' ' . Display::tag('span', get_lang('CourseClosed'), |
|
| 3906 | + $session_title = $course_info['name'].' '.Display::tag('span', get_lang('CourseClosed'), |
|
| 3907 | 3907 | array('class' => 'item_closed')); |
| 3908 | 3908 | } |
| 3909 | 3909 | } else { |
@@ -3928,21 +3928,21 @@ discard block |
||
| 3928 | 3928 | $course_visibility != COURSE_VISIBILITY_HIDDEN |
| 3929 | 3929 | ) { |
| 3930 | 3930 | if ($load_dirs) { |
| 3931 | - $params['right_actions'] .= '<a id="document_preview_' . $course_info['real_id'] . '_' . $course_info['id_session'] . '" class="document_preview" href="javascript:void(0);">' . |
|
| 3931 | + $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_'.$course_info['id_session'].'" class="document_preview" href="javascript:void(0);">'. |
|
| 3932 | 3932 | Display::return_icon('folder.png', |
| 3933 | 3933 | get_lang('Documents'), |
| 3934 | 3934 | array('align' => 'absmiddle'), |
| 3935 | 3935 | ICON_SIZE_SMALL |
| 3936 | - ) . '</a>'; |
|
| 3936 | + ).'</a>'; |
|
| 3937 | 3937 | $params['right_actions'] .= Display::div('', array( |
| 3938 | - 'id' => 'document_result_' . $course_info['real_id'] . '_' . $course_info['id_session'], |
|
| 3938 | + 'id' => 'document_result_'.$course_info['real_id'].'_'.$course_info['id_session'], |
|
| 3939 | 3939 | 'class' => 'document_preview_container' |
| 3940 | 3940 | )); |
| 3941 | 3941 | } |
| 3942 | 3942 | } |
| 3943 | 3943 | |
| 3944 | 3944 | if (api_get_setting('display_coursecode_in_courselist') == 'true') { |
| 3945 | - $session_title .= ' (' . $course_info['visual_code'] . ') '; |
|
| 3945 | + $session_title .= ' ('.$course_info['visual_code'].') '; |
|
| 3946 | 3946 | } |
| 3947 | 3947 | |
| 3948 | 3948 | if (api_get_setting('display_teacher_in_courselist') == 'true') { |
@@ -3971,7 +3971,7 @@ discard block |
||
| 3971 | 3971 | } |
| 3972 | 3972 | } |
| 3973 | 3973 | |
| 3974 | - $session_title .= isset($course['special_course']) ? ' ' . |
|
| 3974 | + $session_title .= isset($course['special_course']) ? ' '. |
|
| 3975 | 3975 | Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : ''; |
| 3976 | 3976 | |
| 3977 | 3977 | $params['title'] = $session_title; |
@@ -3987,12 +3987,12 @@ discard block |
||
| 3987 | 3987 | |
| 3988 | 3988 | // Request for the name of the general coach |
| 3989 | 3989 | $sql = 'SELECT lastname, firstname,sc.name |
| 3990 | - FROM ' . $tbl_session . ' ts |
|
| 3991 | - LEFT JOIN ' . $main_user_table . ' tu |
|
| 3990 | + FROM ' . $tbl_session.' ts |
|
| 3991 | + LEFT JOIN ' . $main_user_table.' tu |
|
| 3992 | 3992 | ON ts.id_coach = tu.user_id |
| 3993 | - INNER JOIN ' . $tbl_session_category . ' sc |
|
| 3993 | + INNER JOIN ' . $tbl_session_category.' sc |
|
| 3994 | 3994 | ON ts.session_category_id = sc.id |
| 3995 | - WHERE ts.id=' . (int)$course_info['id_session'] . ' |
|
| 3995 | + WHERE ts.id=' . (int) $course_info['id_session'].' |
|
| 3996 | 3996 | LIMIT 1'; |
| 3997 | 3997 | |
| 3998 | 3998 | $rs = Database::query($sql); |
@@ -4007,14 +4007,14 @@ discard block |
||
| 4007 | 4007 | //$session['dates'] = get_lang('WithoutTimeLimits'); |
| 4008 | 4008 | $session['dates'] = ''; |
| 4009 | 4009 | if (api_get_setting('show_session_coach') === 'true') { |
| 4010 | - $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name($sessioncoach['firstname'], |
|
| 4010 | + $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], |
|
| 4011 | 4011 | $sessioncoach['lastname']); |
| 4012 | 4012 | } |
| 4013 | 4013 | $active = true; |
| 4014 | 4014 | } else { |
| 4015 | - $session ['dates'] = ' - ' . get_lang('From') . ' ' . $course_info['access_start_date'] . ' ' . get_lang('To') . ' ' . $course_info['access_end_date']; |
|
| 4015 | + $session ['dates'] = ' - '.get_lang('From').' '.$course_info['access_start_date'].' '.get_lang('To').' '.$course_info['access_end_date']; |
|
| 4016 | 4016 | if (api_get_setting('show_session_coach') === 'true') { |
| 4017 | - $session['coach'] = get_lang('GeneralCoach') . ': ' . api_get_person_name($sessioncoach['firstname'], |
|
| 4017 | + $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], |
|
| 4018 | 4018 | $sessioncoach['lastname']); |
| 4019 | 4019 | } |
| 4020 | 4020 | $active = ($date_start <= $now && $date_end >= $now); |
@@ -4066,9 +4066,9 @@ discard block |
||
| 4066 | 4066 | $destination_session_id, |
| 4067 | 4067 | $params = array() |
| 4068 | 4068 | ) { |
| 4069 | - require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseBuilder.class.php'; |
|
| 4070 | - require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseRestorer.class.php'; |
|
| 4071 | - require_once api_get_path(SYS_CODE_PATH) . 'coursecopy/classes/CourseSelectForm.class.php'; |
|
| 4069 | + require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/CourseBuilder.class.php'; |
|
| 4070 | + require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/CourseRestorer.class.php'; |
|
| 4071 | + require_once api_get_path(SYS_CODE_PATH).'coursecopy/classes/CourseSelectForm.class.php'; |
|
| 4072 | 4072 | |
| 4073 | 4073 | $course_info = api_get_course_info($source_course_code); |
| 4074 | 4074 | |
@@ -4141,7 +4141,7 @@ discard block |
||
| 4141 | 4141 | if (Database::num_rows($result) > 0) { |
| 4142 | 4142 | $row = Database::fetch_array($result); |
| 4143 | 4143 | $count = $row['count'] + 1; |
| 4144 | - $wanted_code = $wanted_code . '_' . $count; |
|
| 4144 | + $wanted_code = $wanted_code.'_'.$count; |
|
| 4145 | 4145 | $result = api_get_course_info($wanted_code); |
| 4146 | 4146 | if (empty($result)) { |
| 4147 | 4147 | return $wanted_code; |
@@ -4175,7 +4175,7 @@ discard block |
||
| 4175 | 4175 | $enabled = api_get_plugin_setting('courselegal', 'tool_enable'); |
| 4176 | 4176 | |
| 4177 | 4177 | if ($enabled == 'true') { |
| 4178 | - require_once api_get_path(SYS_PLUGIN_PATH) . 'courselegal/config.php'; |
|
| 4178 | + require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php'; |
|
| 4179 | 4179 | $plugin = CourseLegalPlugin::create(); |
| 4180 | 4180 | return $plugin->isUserAcceptedLegal($user_id, $course_code, $session_id); |
| 4181 | 4181 | } |
@@ -4220,7 +4220,7 @@ discard block |
||
| 4220 | 4220 | $enabled = api_get_plugin_setting('courselegal', 'tool_enable'); |
| 4221 | 4221 | |
| 4222 | 4222 | if ($enabled == 'true') { |
| 4223 | - require_once api_get_path(SYS_PLUGIN_PATH) . 'courselegal/config.php'; |
|
| 4223 | + require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php'; |
|
| 4224 | 4224 | $plugin = CourseLegalPlugin::create(); |
| 4225 | 4225 | return $plugin->saveUserLegal($user_id, $course_code, $session_id); |
| 4226 | 4226 | } |
@@ -4561,10 +4561,10 @@ discard block |
||
| 4561 | 4561 | INNER JOIN $table_course_url u |
| 4562 | 4562 | ON u.c_id = c.id |
| 4563 | 4563 | WHERE |
| 4564 | - u.access_url_id = " . api_get_current_access_url_id() . " AND |
|
| 4564 | + u.access_url_id = ".api_get_current_access_url_id()." AND |
|
| 4565 | 4565 | login_course_date <= '$now' AND |
| 4566 | 4566 | login_course_date > DATE_SUB('$now', INTERVAL $days DAY) AND |
| 4567 | - visibility <> '" . COURSE_VISIBILITY_CLOSED . "' AND visibility <> '" . COURSE_VISIBILITY_HIDDEN . "' |
|
| 4567 | + visibility <> '".COURSE_VISIBILITY_CLOSED."' AND visibility <> '".COURSE_VISIBILITY_HIDDEN."' |
|
| 4568 | 4568 | GROUP BY a.c_id |
| 4569 | 4569 | ORDER BY course_count DESC |
| 4570 | 4570 | LIMIT $limit |
@@ -4590,7 +4590,7 @@ discard block |
||
| 4590 | 4590 | { |
| 4591 | 4591 | $hotCourses = []; |
| 4592 | 4592 | |
| 4593 | - $ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote'; |
|
| 4593 | + $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; |
|
| 4594 | 4594 | |
| 4595 | 4595 | $stok = Security::get_existing_token(); |
| 4596 | 4596 | |
@@ -4612,7 +4612,7 @@ discard block |
||
| 4612 | 4612 | if ($access_link && in_array('register', $access_link)) { |
| 4613 | 4613 | $my_course['extra_info']['register_button'] = Display::url( |
| 4614 | 4614 | Display::returnFontAwesomeIcon('sign-in'), |
| 4615 | - api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?action=subscribe&sec_token=' . $stok, |
|
| 4615 | + api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?action=subscribe&sec_token='.$stok, |
|
| 4616 | 4616 | array('class' => 'btn btn-success btn-sm', 'title' => get_lang('Subscribe'))); |
| 4617 | 4617 | } |
| 4618 | 4618 | |
@@ -4621,14 +4621,14 @@ discard block |
||
| 4621 | 4621 | ) { |
| 4622 | 4622 | $my_course['extra_info']['go_to_course_button'] = Display::url( |
| 4623 | 4623 | Display::returnFontAwesomeIcon('share'), |
| 4624 | - api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php', |
|
| 4624 | + api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', |
|
| 4625 | 4625 | array('class' => 'btn btn-default btn-sm', 'title' => get_lang('GoToCourse'))); |
| 4626 | 4626 | } |
| 4627 | 4627 | |
| 4628 | 4628 | if ($access_link && in_array('unsubscribe', $access_link)) { |
| 4629 | 4629 | $my_course['extra_info']['unsubscribe_button'] = Display::url( |
| 4630 | 4630 | Display::returnFontAwesomeIcon('sign-out'), |
| 4631 | - api_get_path(WEB_CODE_PATH) . 'auth/courses.php?action=unsubscribe&unsubscribe=' . $courseCode . '&sec_token=' . $stok . '&category_code=' . $categoryCode, |
|
| 4631 | + api_get_path(WEB_CODE_PATH).'auth/courses.php?action=unsubscribe&unsubscribe='.$courseCode.'&sec_token='.$stok.'&category_code='.$categoryCode, |
|
| 4632 | 4632 | array('class' => 'btn btn-danger btn-sm', 'title' => get_lang('Unreg'))); |
| 4633 | 4633 | } |
| 4634 | 4634 | |
@@ -4639,7 +4639,7 @@ discard block |
||
| 4639 | 4639 | ) { */ |
| 4640 | 4640 | $my_course['extra_info']['description_button'] = Display::url( |
| 4641 | 4641 | Display::returnFontAwesomeIcon('info-circle'), |
| 4642 | - api_get_path(WEB_AJAX_PATH) . 'course_home.ajax.php?a=show_course_information&code=' . $course_info['code'], |
|
| 4642 | + api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], |
|
| 4643 | 4643 | [ |
| 4644 | 4644 | 'class' => 'btn btn-default btn-sm ajax', |
| 4645 | 4645 | 'data-title' => get_lang('Description'), |
@@ -4650,8 +4650,8 @@ discard block |
||
| 4650 | 4650 | /* get_lang('Description') */ |
| 4651 | 4651 | $my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']); |
| 4652 | 4652 | $point_info = self::get_course_ranking($course_info['real_id'], 0); |
| 4653 | - $my_course['extra_info']['rating_html'] = Display::return_rating_system('star_' . $course_info['real_id'], |
|
| 4654 | - $ajax_url . '&course_id=' . $course_info['real_id'], $point_info); |
|
| 4653 | + $my_course['extra_info']['rating_html'] = Display::return_rating_system('star_'.$course_info['real_id'], |
|
| 4654 | + $ajax_url.'&course_id='.$course_info['real_id'], $point_info); |
|
| 4655 | 4655 | |
| 4656 | 4656 | $hotCourses[] = $my_course; |
| 4657 | 4657 | } |
@@ -4725,9 +4725,9 @@ discard block |
||
| 4725 | 4725 | WHERE |
| 4726 | 4726 | c.id = u.c_id AND |
| 4727 | 4727 | u.access_url_id = $urlId AND |
| 4728 | - visibility <> " . COURSE_VISIBILITY_HIDDEN; |
|
| 4728 | + visibility <> ".COURSE_VISIBILITY_HIDDEN; |
|
| 4729 | 4729 | } else { |
| 4730 | - $sql .= " WHERE visibility <> " . COURSE_VISIBILITY_HIDDEN; |
|
| 4730 | + $sql .= " WHERE visibility <> ".COURSE_VISIBILITY_HIDDEN; |
|
| 4731 | 4731 | } |
| 4732 | 4732 | $res = Database::query($sql); |
| 4733 | 4733 | $row = Database::fetch_row($res); |
@@ -4747,7 +4747,7 @@ discard block |
||
| 4747 | 4747 | |
| 4748 | 4748 | $withoutSpecialCourses = ''; |
| 4749 | 4749 | if (!empty($specialCourseList)) { |
| 4750 | - $withoutSpecialCourses = ' AND c.code NOT IN ("' . implode('","', $specialCourseList) . '")'; |
|
| 4750 | + $withoutSpecialCourses = ' AND c.code NOT IN ("'.implode('","', $specialCourseList).'")'; |
|
| 4751 | 4751 | } |
| 4752 | 4752 | |
| 4753 | 4753 | $visibilityCondition = null; |
@@ -4881,12 +4881,12 @@ discard block |
||
| 4881 | 4881 | if (count($teachers) > 0) { |
| 4882 | 4882 | foreach ($teachers as $key) { |
| 4883 | 4883 | $key = Database::escape_string($key); |
| 4884 | - $cond .= " AND user_id <> '" . $key . "'"; |
|
| 4884 | + $cond .= " AND user_id <> '".$key."'"; |
|
| 4885 | 4885 | } |
| 4886 | 4886 | } |
| 4887 | 4887 | |
| 4888 | - $sql = 'DELETE FROM ' . $course_user_table . ' |
|
| 4889 | - WHERE c_id ="' . $courseId . '" AND status="1" AND relation_type = 0 ' . $cond; |
|
| 4888 | + $sql = 'DELETE FROM '.$course_user_table.' |
|
| 4889 | + WHERE c_id ="' . $courseId.'" AND status="1" AND relation_type = 0 '.$cond; |
|
| 4890 | 4890 | Database::query($sql); |
| 4891 | 4891 | } |
| 4892 | 4892 | |
@@ -4894,12 +4894,12 @@ discard block |
||
| 4894 | 4894 | foreach ($teachers as $userId) { |
| 4895 | 4895 | $userId = intval($userId); |
| 4896 | 4896 | // We check if the teacher is already subscribed in this course |
| 4897 | - $sql = 'SELECT 1 FROM ' . $course_user_table . ' |
|
| 4898 | - WHERE user_id = "' . $userId . '" AND c_id = "' . $courseId . '" '; |
|
| 4897 | + $sql = 'SELECT 1 FROM '.$course_user_table.' |
|
| 4898 | + WHERE user_id = "' . $userId.'" AND c_id = "'.$courseId.'" '; |
|
| 4899 | 4899 | $result = Database::query($sql); |
| 4900 | 4900 | if (Database::num_rows($result)) { |
| 4901 | - $sql = 'UPDATE ' . $course_user_table . ' SET status = "1" |
|
| 4902 | - WHERE c_id = "' . $courseId . '" AND user_id = "' . $userId . '" '; |
|
| 4901 | + $sql = 'UPDATE '.$course_user_table.' SET status = "1" |
|
| 4902 | + WHERE c_id = "' . $courseId.'" AND user_id = "'.$userId.'" '; |
|
| 4903 | 4903 | } else { |
| 4904 | 4904 | $userCourseCategory = '0'; |
| 4905 | 4905 | if (isset($teacherBackup[$userId]) && |
@@ -4909,9 +4909,9 @@ discard block |
||
| 4909 | 4909 | $userCourseCategory = $courseUserData['user_course_cat']; |
| 4910 | 4910 | } |
| 4911 | 4911 | |
| 4912 | - $sql = "INSERT INTO " . $course_user_table . " SET |
|
| 4913 | - c_id = " . $courseId . ", |
|
| 4914 | - user_id = " . $userId . ", |
|
| 4912 | + $sql = "INSERT INTO ".$course_user_table." SET |
|
| 4913 | + c_id = " . $courseId.", |
|
| 4914 | + user_id = " . $userId.", |
|
| 4915 | 4915 | status = '1', |
| 4916 | 4916 | is_tutor = '0', |
| 4917 | 4917 | sort = '0', |
@@ -5247,8 +5247,8 @@ discard block |
||
| 5247 | 5247 | { |
| 5248 | 5248 | $tbl_main_categories = Database:: get_main_table(TABLE_MAIN_COURSE); |
| 5249 | 5249 | $sql = 'SELECT title |
| 5250 | - FROM ' . $tbl_main_categories . ' |
|
| 5251 | - WHERE code = "' . Database::escape_string($code) . '"'; |
|
| 5250 | + FROM ' . $tbl_main_categories.' |
|
| 5251 | + WHERE code = "' . Database::escape_string($code).'"'; |
|
| 5252 | 5252 | $result = Database::query($sql); |
| 5253 | 5253 | if ($col = Database::fetch_array($result)) { |
| 5254 | 5254 | return $col['title']; |
@@ -5431,7 +5431,7 @@ discard block |
||
| 5431 | 5431 | foreach ($group_list as $this_group) { |
| 5432 | 5432 | if (is_array($to_already_selected)) { |
| 5433 | 5433 | if (!in_array( |
| 5434 | - "GROUP:" . $this_group['id'], |
|
| 5434 | + "GROUP:".$this_group['id'], |
|
| 5435 | 5435 | $to_already_selected |
| 5436 | 5436 | ) |
| 5437 | 5437 | ) { // $to_already_selected is the array containing the groups (and users) that are already selected |
@@ -5439,8 +5439,8 @@ discard block |
||
| 5439 | 5439 | $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled"; |
| 5440 | 5440 | $result[] = array( |
| 5441 | 5441 | 'disabled' => $user_disabled, |
| 5442 | - 'value' => "GROUP:" . $this_group['id'], |
|
| 5443 | - 'content' => "G: " . $this_group['name'] . " - " . $this_group['userNb'] . " " . $user_label |
|
| 5442 | + 'value' => "GROUP:".$this_group['id'], |
|
| 5443 | + 'content' => "G: ".$this_group['name']." - ".$this_group['userNb']." ".$user_label |
|
| 5444 | 5444 | ); |
| 5445 | 5445 | } |
| 5446 | 5446 | } |
@@ -5452,13 +5452,13 @@ discard block |
||
| 5452 | 5452 | foreach ($user_list as $user) { |
| 5453 | 5453 | if (is_array($to_already_selected)) { |
| 5454 | 5454 | if (!in_array( |
| 5455 | - "USER:" . $user['user_id'], |
|
| 5455 | + "USER:".$user['user_id'], |
|
| 5456 | 5456 | $to_already_selected |
| 5457 | 5457 | ) |
| 5458 | 5458 | ) { // $to_already_selected is the array containing the users (and groups) that are already selected |
| 5459 | 5459 | |
| 5460 | 5460 | $result[] = array( |
| 5461 | - 'value' => "USER:" . $user['user_id'], |
|
| 5461 | + 'value' => "USER:".$user['user_id'], |
|
| 5462 | 5462 | 'content' => api_get_person_name($user['firstname'], $user['lastname']) |
| 5463 | 5463 | ); |
| 5464 | 5464 | } |
@@ -5487,7 +5487,7 @@ discard block |
||
| 5487 | 5487 | { |
| 5488 | 5488 | $category_id = intval($category_id); |
| 5489 | 5489 | $info = Database::fetch_array( |
| 5490 | - Database::query('SELECT course_code FROM ' . Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY) . ' |
|
| 5490 | + Database::query('SELECT course_code FROM '.Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY).' |
|
| 5491 | 5491 | WHERE id=' . $category_id), 'ASSOC' |
| 5492 | 5492 | ); |
| 5493 | 5493 | return $info ? $info['course_code'] : false; |
@@ -5503,15 +5503,14 @@ discard block |
||
| 5503 | 5503 | public static function getCoursesWithoutSession($startDate = null, $endDate = null, $includeClosed = false) |
| 5504 | 5504 | { |
| 5505 | 5505 | $dateConditional = ($startDate && $endDate) ? |
| 5506 | - " WHERE session_id IN (SELECT id FROM " . Database::get_main_table(TABLE_MAIN_SESSION) . |
|
| 5507 | - " WHERE access_start_date = '$startDate' AND access_end_date = '$endDate')" : |
|
| 5508 | - null; |
|
| 5506 | + " WHERE session_id IN (SELECT id FROM ".Database::get_main_table(TABLE_MAIN_SESSION). |
|
| 5507 | + " WHERE access_start_date = '$startDate' AND access_end_date = '$endDate')" : null; |
|
| 5509 | 5508 | $visibility = ($includeClosed ? '' : 'visibility NOT IN (0, 4) AND '); |
| 5510 | 5509 | |
| 5511 | 5510 | $query = "SELECT id, code, title |
| 5512 | - FROM " . Database::get_main_table(TABLE_MAIN_COURSE). " |
|
| 5511 | + FROM " . Database::get_main_table(TABLE_MAIN_COURSE)." |
|
| 5513 | 5512 | WHERE $visibility code NOT IN ( |
| 5514 | - SELECT DISTINCT course_code FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE) . $dateConditional . ") |
|
| 5513 | + SELECT DISTINCT course_code FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE).$dateConditional.") |
|
| 5515 | 5514 | ORDER BY id"; |
| 5516 | 5515 | |
| 5517 | 5516 | $result = Database::query($query); |
@@ -5544,7 +5543,7 @@ discard block |
||
| 5544 | 5543 | FROM $courseTable c |
| 5545 | 5544 | INNER JOIN $courseUserTable cru ON c.id = cru.c_id |
| 5546 | 5545 | WHERE ( |
| 5547 | - cru.user_id IN (" . implode(', ', $userIdList) . ") |
|
| 5546 | + cru.user_id IN (".implode(', ', $userIdList).") |
|
| 5548 | 5547 | AND cru.relation_type = 0 |
| 5549 | 5548 | )"; |
| 5550 | 5549 | |
@@ -5559,7 +5558,7 @@ discard block |
||
| 5559 | 5558 | INNER JOIN $courseAccessUrlTable crau ON c.id = crau.c_id |
| 5560 | 5559 | WHERE crau.access_url_id = $accessUrlId |
| 5561 | 5560 | AND ( |
| 5562 | - cru.id_user IN (" . implode(', ', $userIdList) . ") AND |
|
| 5561 | + cru.id_user IN (".implode(', ', $userIdList).") AND |
|
| 5563 | 5562 | cru.relation_type = 0 |
| 5564 | 5563 | )"; |
| 5565 | 5564 | } |
@@ -5668,7 +5667,7 @@ discard block |
||
| 5668 | 5667 | |
| 5669 | 5668 | $without_special_courses = ''; |
| 5670 | 5669 | if (!empty($special_course_list)) { |
| 5671 | - $without_special_courses = ' AND course.code NOT IN ("'.implode('","',$special_course_list).'")'; |
|
| 5670 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $special_course_list).'")'; |
|
| 5672 | 5671 | } |
| 5673 | 5672 | |
| 5674 | 5673 | //AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." |
@@ -5724,11 +5723,11 @@ discard block |
||
| 5724 | 5723 | |
| 5725 | 5724 | if (api_is_platform_admin()) { |
| 5726 | 5725 | if ($loadDirs) { |
| 5727 | - $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>'; |
|
| 5728 | - $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>'; |
|
| 5726 | + $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 5727 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 5729 | 5728 | $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class'=>'document_preview_container')); |
| 5730 | 5729 | } else { |
| 5731 | - $params['right_actions'].= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>'; |
|
| 5730 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 5732 | 5731 | } |
| 5733 | 5732 | |
| 5734 | 5733 | if ($course_info['status'] == COURSEMANAGER) { |
@@ -5737,11 +5736,11 @@ discard block |
||
| 5737 | 5736 | } else { |
| 5738 | 5737 | if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { |
| 5739 | 5738 | if ($loadDirs) { |
| 5740 | - $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>'; |
|
| 5739 | + $params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 5741 | 5740 | $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class'=>'document_preview_container')); |
| 5742 | 5741 | } else { |
| 5743 | 5742 | if ($course_info['status'] == COURSEMANAGER) { |
| 5744 | - $params['right_actions'].= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>'; |
|
| 5743 | + $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>'; |
|
| 5745 | 5744 | } |
| 5746 | 5745 | } |
| 5747 | 5746 | } |
@@ -5752,7 +5751,7 @@ discard block |
||
| 5752 | 5751 | $course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0'; |
| 5753 | 5752 | $course_title = Display::url($course_info['title'], $course_title_url); |
| 5754 | 5753 | } else { |
| 5755 | - $course_title = $course_info['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed')); |
|
| 5754 | + $course_title = $course_info['title']." ".Display::tag('span', get_lang('CourseClosed'), array('class'=>'item_closed')); |
|
| 5756 | 5755 | } |
| 5757 | 5756 | |
| 5758 | 5757 | // Start displaying the course block itself |
@@ -1880,7 +1880,7 @@ discard block |
||
| 1880 | 1880 | $html .= Display::tag('li', Display::return_icon('teacher.png', $teacher, null, ICON_SIZE_TINY) . ' ' . $teacher); |
| 1881 | 1881 | } |
| 1882 | 1882 | $html .= '</ul>'; |
| 1883 | - }else{ |
|
| 1883 | + } else{ |
|
| 1884 | 1884 | $html .= array_to_string($list, $separator); |
| 1885 | 1885 | } |
| 1886 | 1886 | } |
@@ -3236,7 +3236,7 @@ discard block |
||
| 3236 | 3236 | $html .= '<a class="thumbnail" href="'.$params['link'].'">'; |
| 3237 | 3237 | $html .= $params['icon']; |
| 3238 | 3238 | $html .= '</a>'; |
| 3239 | - }else{ |
|
| 3239 | + } else{ |
|
| 3240 | 3240 | $html .= $params['icon']; |
| 3241 | 3241 | } |
| 3242 | 3242 | $html .= '</div>'; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @param string $canHaveCourses |
| 112 | 112 | * @param int $parent_id |
| 113 | 113 | * |
| 114 | - * @return bool |
|
| 114 | + * @return false|string |
|
| 115 | 115 | */ |
| 116 | 116 | function addNode($code, $name, $canHaveCourses, $parent_id) |
| 117 | 117 | { |
@@ -306,8 +306,7 @@ discard block |
||
| 306 | 306 | /** |
| 307 | 307 | * Counts the number of children categories a category has |
| 308 | 308 | * @param int $categoryId The ID of the category of which we want to count the children |
| 309 | - * @param int $count The number of subcategories we counted this far |
|
| 310 | - * @return mixed The number of subcategories this category has |
|
| 309 | + * @return integer The number of subcategories this category has |
|
| 311 | 310 | */ |
| 312 | 311 | function courseCategoryChildrenCount($categoryId) |
| 313 | 312 | { |
@@ -474,7 +473,7 @@ discard block |
||
| 474 | 473 | /** |
| 475 | 474 | * @param int $id |
| 476 | 475 | * |
| 477 | - * @return bool |
|
| 476 | + * @return false|null |
|
| 478 | 477 | */ |
| 479 | 478 | function addToUrl($id) |
| 480 | 479 | { |
@@ -970,7 +969,7 @@ discard block |
||
| 970 | 969 | * Get Pagination HTML div |
| 971 | 970 | * @param $pageCurrent |
| 972 | 971 | * @param $pageLength |
| 973 | - * @param $pageTotal |
|
| 972 | + * @param integer $pageTotal |
|
| 974 | 973 | * @return string |
| 975 | 974 | */ |
| 976 | 975 | function getCataloguePagination($pageCurrent, $pageLength, $pageTotal) |
@@ -1109,10 +1109,10 @@ |
||
| 1109 | 1109 | ); |
| 1110 | 1110 | } |
| 1111 | 1111 | /** |
| 1112 | - * Return the name tool by action |
|
| 1113 | - * @param string $action |
|
| 1114 | - * @return string |
|
| 1115 | - */ |
|
| 1112 | + * Return the name tool by action |
|
| 1113 | + * @param string $action |
|
| 1114 | + * @return string |
|
| 1115 | + */ |
|
| 1116 | 1116 | function getCourseCatalogNameTools($action) |
| 1117 | 1117 | { |
| 1118 | 1118 | $nameTools = get_lang('SortMyCourses'); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $parentIdCondition = " AND (t1.parent_id IS NULL OR t1.parent_id = '' )"; |
| 70 | 70 | if (!empty($category)) { |
| 71 | - $parentIdCondition = " AND t1.parent_id = '$category' "; |
|
| 71 | + $parentIdCondition = " AND t1.parent_id = '$category' "; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $sql = "SELECT |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | $categories = Database::store_result($result); |
| 101 | 101 | foreach ($categories as $category) { |
| 102 | - $category['nbr_courses'] = 1; |
|
| 102 | + $category['nbr_courses'] = 1; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | return $categories; |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | if ($row = Database::fetch_array($result)) { |
| 197 | 197 | if (!empty($row['parent_id'])) { |
| 198 | 198 | Database::query("UPDATE $tbl_course SET category_code = '".$row['parent_id']."' WHERE category_code='$node'"); |
| 199 | - Database::query("UPDATE $tbl_category SET parent_id='" . $row['parent_id'] . "' WHERE parent_id='$node'"); |
|
| 199 | + Database::query("UPDATE $tbl_category SET parent_id='".$row['parent_id']."' WHERE parent_id='$node'"); |
|
| 200 | 200 | } else { |
| 201 | 201 | Database::query("UPDATE $tbl_course SET category_code='' WHERE category_code='$node'"); |
| 202 | 202 | Database::query("UPDATE $tbl_category SET parent_id=NULL WHERE parent_id='$node'"); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '" . $row['tree_pos'] . "'"); |
|
| 205 | + Database::query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '".$row['tree_pos']."'"); |
|
| 206 | 206 | Database::query("DELETE FROM $tbl_category WHERE code='$node'"); |
| 207 | 207 | |
| 208 | 208 | if (!empty($row['parent_id'])) { |
@@ -291,13 +291,13 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | $sql = "UPDATE $tbl_category |
| 294 | - SET tree_pos ='" . $row['tree_pos'] . "' |
|
| 294 | + SET tree_pos ='".$row['tree_pos']."' |
|
| 295 | 295 | WHERE code='$code'"; |
| 296 | 296 | Database::query($sql); |
| 297 | 297 | |
| 298 | 298 | $sql = "UPDATE $tbl_category |
| 299 | 299 | SET tree_pos = '$tree_pos' |
| 300 | - WHERE code= '" . $row['code'] . "'"; |
|
| 300 | + WHERE code= '".$row['code']."'"; |
|
| 301 | 301 | Database::query($sql); |
| 302 | 302 | |
| 303 | 303 | return true; |
@@ -424,12 +424,12 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | $editIcon = Display::return_icon('edit.png', get_lang('EditNode'), null, ICON_SIZE_SMALL); |
| 426 | 426 | $deleteIcon = Display::return_icon('delete.png', get_lang('DeleteNode'), null, ICON_SIZE_SMALL); |
| 427 | - $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); |
|
| 427 | + $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); |
|
| 428 | 428 | |
| 429 | 429 | foreach ($categories as $category) { |
| 430 | 430 | |
| 431 | 431 | $editUrl = $mainUrl.'&id='.$category['code'].'&action=edit'; |
| 432 | - $moveUrl = $mainUrl.'&id='.$category['code'].'&action=moveUp&tree_pos='.$category['tree_pos']; |
|
| 432 | + $moveUrl = $mainUrl.'&id='.$category['code'].'&action=moveUp&tree_pos='.$category['tree_pos']; |
|
| 433 | 433 | $deleteUrl = $mainUrl.'&id='.$category['code'].'&action=delete'; |
| 434 | 434 | |
| 435 | 435 | $actions = Display::url($editIcon, $editUrl).Display::url($moveIcon, $moveUrl).Display::url($deleteIcon, $deleteUrl); |
@@ -563,12 +563,12 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | $count_courses = countCoursesInCategory(); |
| 565 | 565 | |
| 566 | - $categories[0][count($categories[0])+1] = array( |
|
| 566 | + $categories[0][count($categories[0]) + 1] = array( |
|
| 567 | 567 | 'id' =>0, |
| 568 | 568 | 'name' => get_lang('None'), |
| 569 | 569 | 'code' => 'NONE', |
| 570 | 570 | 'parent_id' => null, |
| 571 | - 'tree_pos' => $row['tree_pos']+1, |
|
| 571 | + 'tree_pos' => $row['tree_pos'] + 1, |
|
| 572 | 572 | 'children_count' => 0, |
| 573 | 573 | 'auth_course_child' => true, |
| 574 | 574 | 'auth_cat_child' => true, |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * @param string $searchTerm |
| 584 | 584 | * @return int |
| 585 | 585 | */ |
| 586 | -function countCoursesInCategory($category_code="", $searchTerm = '') |
|
| 586 | +function countCoursesInCategory($category_code = "", $searchTerm = '') |
|
| 587 | 587 | { |
| 588 | 588 | $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); |
| 589 | 589 | $categoryCode = Database::escape_string($category_code); |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | |
| 596 | 596 | $without_special_courses = ''; |
| 597 | 597 | if (!empty($specialCourseList)) { |
| 598 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; |
|
| 598 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $special_course_list).'")'; |
|
| 599 | 599 | } |
| 600 | 600 | |
| 601 | 601 | $visibilityCondition = null; |
@@ -609,15 +609,15 @@ discard block |
||
| 609 | 609 | if ($categoryCode == 'ALL') { |
| 610 | 610 | // Nothing to do |
| 611 | 611 | } elseif ($categoryCode == 'NONE') { |
| 612 | - $categoryFilter = ' AND category_code = "" '; |
|
| 612 | + $categoryFilter = ' AND category_code = "" '; |
|
| 613 | 613 | } else { |
| 614 | - $categoryFilter = ' AND category_code = "' . $categoryCode . '" '; |
|
| 614 | + $categoryFilter = ' AND category_code = "'.$categoryCode.'" '; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | if (!empty($searchTerm)) { |
| 618 | - $searchFilter = ' AND (code LIKE "%' . $searchTerm . '%" |
|
| 619 | - OR title LIKE "%' . $searchTerm . '%" |
|
| 620 | - OR tutor_name LIKE "%' . $searchTerm . '%") '; |
|
| 618 | + $searchFilter = ' AND (code LIKE "%'.$searchTerm.'%" |
|
| 619 | + OR title LIKE "%' . $searchTerm.'%" |
|
| 620 | + OR tutor_name LIKE "%' . $searchTerm.'%") '; |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | $sql = "SELECT * FROM $tbl_course |
@@ -668,7 +668,7 @@ discard block |
||
| 668 | 668 | |
| 669 | 669 | $without_special_courses = ''; |
| 670 | 670 | if (!empty($specialCourseList)) { |
| 671 | - $without_special_courses = ' AND course.code NOT IN ("' . implode('","', $special_course_list) . '")'; |
|
| 671 | + $without_special_courses = ' AND course.code NOT IN ("'.implode('","', $special_course_list).'")'; |
|
| 672 | 672 | } |
| 673 | 673 | $visibilityCondition = null; |
| 674 | 674 | $hidePrivate = api_get_setting('course_catalog_hide_private'); |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | $id_in = null; |
| 717 | 717 | while (list($id) = Database::fetch_row($result)) { |
| 718 | 718 | if ($id_in) { |
| 719 | - $id_in.=",$id"; |
|
| 719 | + $id_in .= ",$id"; |
|
| 720 | 720 | } else { |
| 721 | 721 | $id_in = "$id"; |
| 722 | 722 | } |
@@ -937,11 +937,9 @@ discard block |
||
| 937 | 937 | function getLimitArray() |
| 938 | 938 | { |
| 939 | 939 | $pageCurrent = isset($_REQUEST['pageCurrent']) ? |
| 940 | - intval($_GET['pageCurrent']) : |
|
| 941 | - 1; |
|
| 940 | + intval($_GET['pageCurrent']) : 1; |
|
| 942 | 941 | $pageLength = isset($_REQUEST['pageLength']) ? |
| 943 | - intval($_GET['pageLength']) : |
|
| 944 | - 10; |
|
| 942 | + intval($_GET['pageLength']) : 10; |
|
| 945 | 943 | return array( |
| 946 | 944 | 'start' => ($pageCurrent - 1) * $pageLength, |
| 947 | 945 | 'current' => $pageCurrent, |
@@ -960,7 +958,7 @@ discard block |
||
| 960 | 958 | if (!empty($limit) && is_array($limit)) { |
| 961 | 959 | $limitStart = isset($limit['start']) ? $limit['start'] : 0; |
| 962 | 960 | $limitLength = isset($limit['length']) ? $limit['length'] : 10; |
| 963 | - $limitFilter = 'LIMIT ' . $limitStart . ', ' . $limitLength; |
|
| 961 | + $limitFilter = 'LIMIT '.$limitStart.', '.$limitLength; |
|
| 964 | 962 | } |
| 965 | 963 | |
| 966 | 964 | return $limitFilter; |
@@ -977,7 +975,7 @@ discard block |
||
| 977 | 975 | { |
| 978 | 976 | // Start empty html |
| 979 | 977 | $pageDiv = ''; |
| 980 | - $html=''; |
|
| 978 | + $html = ''; |
|
| 981 | 979 | $pageBottom = max(1, $pageCurrent - 3); |
| 982 | 980 | $pageTop = min($pageTotal, $pageCurrent + 3); |
| 983 | 981 | |
@@ -1048,21 +1046,21 @@ discard block |
||
| 1048 | 1046 | $hiddenLinks = isset($hiddenLinks) ? Security::remove_XSS($hiddenLinksRequest) : $categoryCodeRequest; |
| 1049 | 1047 | |
| 1050 | 1048 | // Start URL with params |
| 1051 | - $pageUrl = api_get_self() . |
|
| 1052 | - '?action=' . $action . |
|
| 1053 | - '&category_code=' .$categoryCode. |
|
| 1054 | - '&hidden_links=' .$hiddenLinks. |
|
| 1055 | - '&pageCurrent=' . $pageCurrent . |
|
| 1056 | - '&pageLength=' . $pageLength |
|
| 1049 | + $pageUrl = api_get_self(). |
|
| 1050 | + '?action='.$action. |
|
| 1051 | + '&category_code='.$categoryCode. |
|
| 1052 | + '&hidden_links='.$hiddenLinks. |
|
| 1053 | + '&pageCurrent='.$pageCurrent. |
|
| 1054 | + '&pageLength='.$pageLength |
|
| 1057 | 1055 | ; |
| 1058 | 1056 | |
| 1059 | 1057 | switch ($action) { |
| 1060 | 1058 | case 'subscribe' : |
| 1061 | 1059 | // for search |
| 1062 | 1060 | $pageUrl .= |
| 1063 | - '&search_term=' . $searchTerm . |
|
| 1064 | - '&search_course=1' . |
|
| 1065 | - '&sec_token=' . $_SESSION['sec_token']; |
|
| 1061 | + '&search_term='.$searchTerm. |
|
| 1062 | + '&search_course=1'. |
|
| 1063 | + '&sec_token='.$_SESSION['sec_token']; |
|
| 1066 | 1064 | break; |
| 1067 | 1065 | case 'display_courses' : |
| 1068 | 1066 | // No break |
@@ -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']; |