From 6a10a2b11199c9cd229a74bd5e779f4e1d7bf7d2 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 25 Nov 2014 14:30:04 +0100 Subject: [PATCH] Format code. --- .../announcement_email.class.php | 7 +- main/announcements/announcements.inc.php | 16 +- main/announcements/announcements.php | 1057 ++++++++--------- main/announcements/download.php | 44 +- main/gradebook/exercise_jump.php | 17 +- main/gradebook/gradebook.php | 840 +++++++------ main/gradebook/gradebook_add_cat.php | 75 +- main/gradebook/gradebook_add_eval.php | 22 +- main/gradebook/gradebook_add_link.php | 6 +- .../gradebook_add_link_select_course.php | 23 +- main/gradebook/gradebook_add_result.php | 47 +- main/gradebook/gradebook_add_user.php | 5 +- .../gradebook_display_certificate.php | 39 +- main/gradebook/gradebook_edit_all.php | 88 +- main/gradebook/gradebook_edit_cat.php | 55 +- main/gradebook/gradebook_edit_eval.php | 90 +- main/gradebook/gradebook_edit_link.php | 56 +- main/gradebook/gradebook_edit_result.php | 44 +- main/gradebook/gradebook_flatview.php | 65 +- main/gradebook/gradebook_result.class.php | 474 ++++---- main/gradebook/gradebook_scoring_system.php | 5 +- main/gradebook/gradebook_showlog_eval.php | 28 +- main/gradebook/gradebook_showlog_link.php | 14 +- main/gradebook/gradebook_statistics.php | 114 +- main/gradebook/gradebook_view_result.php | 11 +- main/gradebook/index.php | 869 +++++++------- main/gradebook/user_info.php | 36 +- main/gradebook/user_stats.php | 68 +- 28 files changed, 2092 insertions(+), 2123 deletions(-) diff --git a/main/announcements/announcement_email.class.php b/main/announcements/announcement_email.class.php index db2fe9687e..a03d3a8ad1 100755 --- a/main/announcements/announcement_email.class.php +++ b/main/announcements/announcement_email.class.php @@ -1,5 +1,6 @@ '; $result .= Display::url( - $attachment['filename'], - api_get_path(WEB_CODE_PATH).'announcements/download.php?file='.basename($attachment['path']).'&'.$course_param - ).'
'; + $attachment['filename'], + api_get_path(WEB_CODE_PATH).'announcements/download.php?file='.basename($attachment['path']).'&'.$course_param + ).'
'; } $result .= '
'; diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index b8fb4ad689..9abc9a1fc2 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -224,12 +224,12 @@ class AnnouncementManager global $stok; $modify_icons .= "" . - Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . ""; + Display::return_icon($image_visibility . '.png', $alt_visibility, '', ICON_SIZE_SMALL) . ""; if (api_is_allowed_to_edit(false, true)) { $modify_icons .= "" . - Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . - ""; + Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . + ""; } echo "$modify_icons"; } @@ -522,8 +522,8 @@ class AnnouncementManager } /** - * @param int $announcementId - */ + * @param int $announcementId + */ public static function addAnnouncementToAllUsersInSessions($announcementId) { $courseCode = api_get_course_id(); @@ -720,7 +720,7 @@ class AnnouncementManager $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ; echo ""; + ""; } } } @@ -786,7 +786,7 @@ class AnnouncementManager 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 echo ""; + ""; } } } @@ -1138,7 +1138,7 @@ class AnnouncementManager $safe_new_file_name = Database::escape_string($new_file_name); // Storing the attachments if any $sql = 'INSERT INTO ' . $tbl_announcement_attachment . ' (c_id, filename, comment, path, announcement_id, size) ' . - "VALUES ($course_id, '$safe_file_name', '$file_comment', '$safe_new_file_name' , '$announcement_id', '" . intval($file['size']) . "' )"; + "VALUES ($course_id, '$safe_file_name', '$file_comment', '$safe_new_file_name' , '$announcement_id', '" . intval($file['size']) . "' )"; $result = Database::query($sql); $return = 1; } diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index de92825ee9..883e5cdf98 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -12,12 +12,9 @@ * @todo make AWACS out of the configuration settings * @todo this file is 1300+ lines without any functions -> needs to be split into * multiple functions -*/ -/* - INIT SECTION -*/ -// name of the language file that needs to be included + */ +// name of the language file that needs to be included use \ChamiloSession as Session; $language_file = array('announcements', 'group', 'survey', 'document'); @@ -33,7 +30,7 @@ $nameTools = get_lang('ToolAnnouncement'); //session if(isset($_GET['id_session'])) { - $_SESSION['id_session'] = intval($_GET['id_session']); + $_SESSION['id_session'] = intval($_GET['id_session']); } /* ACCESS RIGHTS */ @@ -79,12 +76,12 @@ $safe_newContent = isset($_POST['newContent']) ? $_POST['newContent'] : null; $content_to_modify = $title_to_modify = ''; if (!empty($_POST['To'])) { - if (api_get_session_id()!=0 && + if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false, true) == false ) { - api_not_allowed(true); - } - $display_form = true; + api_not_allowed(true); + } + $display_form = true; $form_elements = array( 'emailTitle' => $safe_emailTitle, @@ -95,9 +92,9 @@ if (!empty($_POST['To'])) { $_SESSION['formelements'] = $form_elements; $form_elements = $_SESSION['formelements']; - $title_to_modify = $form_elements["emailTitle"]; - $content_to_modify = $form_elements["newContent"]; - $announcement_to_modify = $form_elements["id"]; + $title_to_modify = $form_elements["emailTitle"]; + $content_to_modify = $form_elements["newContent"]; + $announcement_to_modify = $form_elements["id"]; } /* @@ -106,14 +103,14 @@ if (!empty($_POST['To'])) { $setting_select_groupusers = true; if (empty($_POST['To']) and !isset($_SESSION['select_groupusers'])) { - $_SESSION['select_groupusers'] = "hide"; + $_SESSION['select_groupusers'] = "hide"; } $select_groupusers_status = isset($_SESSION['select_groupusers']) ? $_SESSION['select_groupusers']:null; if (!empty($_POST['To']) and ($select_groupusers_status=="hide")) { - $_SESSION['select_groupusers'] = "show"; + $_SESSION['select_groupusers'] = "show"; } if (!empty($_POST['To']) and ($select_groupusers_status=="show")) { - $_SESSION['select_groupusers'] = "hide"; + $_SESSION['select_groupusers'] = "hide"; } $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; @@ -124,15 +121,15 @@ $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To']) ) { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true) == false) { - api_not_allowed(true); - } - $display_form = true; + if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true) == false) { + api_not_allowed(true); + } + $display_form = true; } // clear all resources if ((empty($originalresource) || ($originalresource!=='no')) and (!empty($action) && $action=='add')) { - $_SESSION['formelements']=null; + $_SESSION['formelements']=null; } $htmlHeadXtra[] = AnnouncementManager::to_javascript(); @@ -140,14 +137,14 @@ $htmlHeadXtra[] = AnnouncementManager::to_javascript(); /* Filter user/group */ if(!empty($_GET['toolgroup'])){ - if($_GET['toolgroup'] == strval(intval($_GET['toolgroup']))){ - //check is integer - $toolgroup = intval($_GET['toolgroup']); - $_SESSION['select_groupusers'] = 'hide'; - } else { - $toolgroup = 0; - } - Session::write("toolgroup", $toolgroup); + if($_GET['toolgroup'] == strval(intval($_GET['toolgroup']))){ + //check is integer + $toolgroup = intval($_GET['toolgroup']); + $_SESSION['select_groupusers'] = 'hide'; + } else { + $toolgroup = 0; + } + Session::write("toolgroup", $toolgroup); } /* Sessions */ @@ -161,32 +158,32 @@ if (!empty($_SESSION['formelements']) and !empty($_GET['originalresource']) and $_GET['originalresource'] == 'no' ) { - $form_elements = $_SESSION['formelements']; - $title_to_modify = $form_elements['emailTitle']; - $content_to_modify = $form_elements['newContent']; - $announcement_to_modify = $form_elements['id']; - $to = $form_elements['to']; - $email_ann = $form_elements['emailoption']; + $form_elements = $_SESSION['formelements']; + $title_to_modify = $form_elements['emailTitle']; + $content_to_modify = $form_elements['newContent']; + $announcement_to_modify = $form_elements['id']; + $to = $form_elements['to']; + $email_ann = $form_elements['emailoption']; } if (!empty($_GET['remind_inactive'])) { - $to[] = 'USER:'.intval($_GET['remind_inactive']); + $to[] = 'USER:'.intval($_GET['remind_inactive']); } $group_id = api_get_group_id(); if (!empty($group_id)) { - $group_properties = GroupManager :: get_group_properties($group_id); - $interbreadcrumb[] = array("url" => "../group/group.php", "name" => get_lang('Groups')); - $interbreadcrumb[] = array("url"=>"../group/group_space.php?gidReq=".$group_id, "name"=> get_lang('GroupSpace').' '.$group_properties['name']); + $group_properties = GroupManager :: get_group_properties($group_id); + $interbreadcrumb[] = array("url" => "../group/group.php", "name" => get_lang('Groups')); + $interbreadcrumb[] = array("url"=>"../group/group_space.php?gidReq=".$group_id, "name"=> get_lang('GroupSpace').' '.$group_properties['name']); } $announcement_id = isset($_GET['id']) ? intval($_GET['id']) : null; $message = null; if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { - //we are not in the learning path - Display::display_header($nameTools,get_lang('Announcements')); + //we are not in the learning path + Display::display_header($nameTools,get_lang('Announcements')); } if (api_is_allowed_to_edit(false,true) OR @@ -195,45 +192,45 @@ if (api_is_allowed_to_edit(false,true) OR /* Change visibility of announcement */ - // $_GET['isStudentView']<>"false" is added to prevent that the visibility - // is changed after you do the following: - // change visibility -> studentview -> course manager view - if (!isset($_GET['isStudentView']) || $_GET['isStudentView']!='false') { - if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide") { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { - api_not_allowed(); - } - if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])) { - if ($ctok == $_GET['sec_token']) { - AnnouncementManager::change_visibility_announcement($_course, $_GET['id']); - $message = get_lang('VisibilityChanged'); - } - } - } - } - - /* Delete announcement */ - if (!empty($_GET['action']) && $_GET['action']=='delete' && isset($_GET['id'])) { - $id = intval($_GET['id']); - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false, true) == false) { - api_not_allowed(); - } - - if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) { - // tooledit : visibility = 2 : only visible for platform administrator - if ($ctok == $_GET['sec_token']) { - AnnouncementManager::delete_announcement($_course, $id); - //delete_added_resource("Ad_Valvas", $delete); - - $id = null; - $emailTitle = null; - $newContent = null; - $message = get_lang('AnnouncementDeleted'); - } - } - } - - //delete attachment file + // $_GET['isStudentView']<>"false" is added to prevent that the visibility + // is changed after you do the following: + // change visibility -> studentview -> course manager view + if (!isset($_GET['isStudentView']) || $_GET['isStudentView']!='false') { + if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide") { + if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { + api_not_allowed(); + } + if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])) { + if ($ctok == $_GET['sec_token']) { + AnnouncementManager::change_visibility_announcement($_course, $_GET['id']); + $message = get_lang('VisibilityChanged'); + } + } + } + } + + /* Delete announcement */ + if (!empty($_GET['action']) && $_GET['action']=='delete' && isset($_GET['id'])) { + $id = intval($_GET['id']); + if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false, true) == false) { + api_not_allowed(); + } + + if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) { + // tooledit : visibility = 2 : only visible for platform administrator + if ($ctok == $_GET['sec_token']) { + AnnouncementManager::delete_announcement($_course, $id); + //delete_added_resource("Ad_Valvas", $delete); + + $id = null; + $emailTitle = null; + $newContent = null; + $message = get_lang('AnnouncementDeleted'); + } + } + } + + //delete attachment file if (isset($_GET['action']) && $_GET['action'] == 'delete_attachment') { $id = $_GET['id_attach']; if ($ctok == $_GET['sec_token']) { @@ -243,78 +240,78 @@ if (api_is_allowed_to_edit(false,true) OR } } - /* Delete all announcements */ - if (!empty($_GET['action']) and $_GET['action']=='delete_all') { - if (api_is_allowed_to_edit()) { - AnnouncementManager::delete_all_announcements($_course); - $id = null; - $emailTitle = null; - $newContent = null; - $message = get_lang('AnnouncementDeletedAll'); - } - } - - /* Modify announcement */ - if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) { - if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { - api_not_allowed(); - } - - $display_form = true; - - // RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY - $id = intval($_GET['id']); - - if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) { - $sql="SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id = '$id'"; - $rs = Database::query($sql); - $myrow = Database::fetch_array($rs); - $last_id = $id; + /* Delete all announcements */ + if (!empty($_GET['action']) and $_GET['action']=='delete_all') { + if (api_is_allowed_to_edit()) { + AnnouncementManager::delete_all_announcements($_course); + $id = null; + $emailTitle = null; + $newContent = null; + $message = get_lang('AnnouncementDeletedAll'); + } + } + + /* Modify announcement */ + if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) { + if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { + api_not_allowed(); + } + + $display_form = true; + + // RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY + $id = intval($_GET['id']); + + if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $id)) { + $sql="SELECT * FROM $tbl_announcement WHERE c_id = $course_id AND id = '$id'"; + $rs = Database::query($sql); + $myrow = Database::fetch_array($rs); + $last_id = $id; $userUpload = isset($_FILES['user_upload']) ? $_FILES['user_upload'] : null; - $edit_attachment = AnnouncementManager::edit_announcement_attachment_file( + $edit_attachment = AnnouncementManager::edit_announcement_attachment_file( $last_id, $userUpload, $file_comment ); - if ($myrow) { - $announcement_to_modify = $myrow['id']; - $content_to_modify = $myrow['content']; - $title_to_modify = $myrow['title']; - - if ($originalresource!=="no") { - $to = AnnouncementManager::load_edit_users("announcement", $announcement_to_modify); - } - $display_announcement_list = false; - } - - if ($to=="everyone" OR !empty($group_id)) { - $_SESSION['select_groupusers']="hide"; - } else { - $_SESSION['select_groupusers']="show"; - } - } - } - - /* Move announcement up/down */ - if (isset($_GET['sec_token']) && $ctok == $_GET['sec_token']) { - if (!empty($_GET['down'])) { - $thisAnnouncementId = intval($_GET['down']); - $sortDirection = "DESC"; - } - - if (!empty($_GET['up'])) { - $thisAnnouncementId = intval($_GET['up']); - $sortDirection = "ASC"; - } - } - - if (!empty($sortDirection)) { - if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) { - $sortDirection='ASC'; - } - - $sql = "SELECT announcement.id, announcement.display_order + if ($myrow) { + $announcement_to_modify = $myrow['id']; + $content_to_modify = $myrow['content']; + $title_to_modify = $myrow['title']; + + if ($originalresource!=="no") { + $to = AnnouncementManager::load_edit_users("announcement", $announcement_to_modify); + } + $display_announcement_list = false; + } + + if ($to=="everyone" OR !empty($group_id)) { + $_SESSION['select_groupusers']="hide"; + } else { + $_SESSION['select_groupusers']="show"; + } + } + } + + /* Move announcement up/down */ + if (isset($_GET['sec_token']) && $ctok == $_GET['sec_token']) { + if (!empty($_GET['down'])) { + $thisAnnouncementId = intval($_GET['down']); + $sortDirection = "DESC"; + } + + if (!empty($_GET['up'])) { + $thisAnnouncementId = intval($_GET['up']); + $sortDirection = "ASC"; + } + } + + if (!empty($sortDirection)) { + if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) { + $sortDirection='ASC'; + } + + $sql = "SELECT announcement.id, announcement.display_order FROM $tbl_announcement announcement, $tbl_item_property itemproperty WHERE @@ -324,51 +321,51 @@ if (api_is_allowed_to_edit(false,true) OR itemproperty.tool='".TOOL_ANNOUNCEMENT."' AND itemproperty.visibility<>2 ORDER BY display_order $sortDirection"; - $result = Database::query($sql); - - while (list ($announcementId, $announcementOrder) = Database::fetch_row($result)) { - // STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER. - // COMMIT ORDER SWAP ON THE DB - - if ($thisAnnouncementOrderFound) { - $nextAnnouncementId = $announcementId; - $nextAnnouncementOrder = $announcementOrder; - Database::query("UPDATE $tbl_announcement SET display_order = '$nextAnnouncementOrder' WHERE c_id = $course_id AND id = '$thisAnnouncementId'"); - Database::query("UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder' WHERE c_id = $course_id AND id = '$nextAnnouncementId.'"); - break; - } - // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT - if ($announcementId == $thisAnnouncementId) { - $thisAnnouncementOrder = $announcementOrder; - $thisAnnouncementOrderFound = true; - } - } - // show message - $message = get_lang('AnnouncementMoved'); - } - - /* Submit announcement */ - - $emailTitle = (!empty($_POST['emailTitle'])?$safe_emailTitle:''); - $newContent = (!empty($_POST['newContent'])?$safe_newContent:''); - $submitAnnouncement = isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0; - - $id = 0; - if (!empty($_POST['id'])) { - $id=intval($_POST['id']); - } - - if ($submitAnnouncement && empty($emailTitle)) { - $error_message = get_lang('TitleIsRequired'); - $content_to_modify = $newContent; - } else if ($submitAnnouncement) { + $result = Database::query($sql); + + while (list ($announcementId, $announcementOrder) = Database::fetch_row($result)) { + // STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER. + // COMMIT ORDER SWAP ON THE DB + + if ($thisAnnouncementOrderFound) { + $nextAnnouncementId = $announcementId; + $nextAnnouncementOrder = $announcementOrder; + Database::query("UPDATE $tbl_announcement SET display_order = '$nextAnnouncementOrder' WHERE c_id = $course_id AND id = '$thisAnnouncementId'"); + Database::query("UPDATE $tbl_announcement SET display_order = '$thisAnnouncementOrder' WHERE c_id = $course_id AND id = '$nextAnnouncementId.'"); + break; + } + // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT + if ($announcementId == $thisAnnouncementId) { + $thisAnnouncementOrder = $announcementOrder; + $thisAnnouncementOrderFound = true; + } + } + // show message + $message = get_lang('AnnouncementMoved'); + } + + /* Submit announcement */ + + $emailTitle = (!empty($_POST['emailTitle'])?$safe_emailTitle:''); + $newContent = (!empty($_POST['newContent'])?$safe_newContent:''); + $submitAnnouncement = isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0; + + $id = 0; + if (!empty($_POST['id'])) { + $id=intval($_POST['id']); + } + + if ($submitAnnouncement && empty($emailTitle)) { + $error_message = get_lang('TitleIsRequired'); + $content_to_modify = $newContent; + } else if ($submitAnnouncement) { $sendToUsersInSession = isset($_POST['send_to_users_in_session']) ? true : false; - if (isset($id) && $id) { - // there is an Id => the announcement already exists => update mode - if ($ctok == $_POST['sec_token']) { - $file_comment = $_POST['file_comment']; - $file = $_FILES['user_upload']; + if (isset($id) && $id) { + // there is an Id => the announcement already exists => update mode + if ($ctok == $_POST['sec_token']) { + $file_comment = $_POST['file_comment']; + $file = $_FILES['user_upload']; AnnouncementManager::edit_announcement( $id, $emailTitle, @@ -383,11 +380,11 @@ if (api_is_allowed_to_edit(false,true) OR if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) { AnnouncementManager::send_email($id, $sendToUsersInSession); } - $message = get_lang('AnnouncementModified'); - } - } else { - //insert mode - if ($ctok == $_POST['sec_token']) { + $message = get_lang('AnnouncementModified'); + } + } else { + //insert mode + if ($ctok == $_POST['sec_token']) { $file = $_FILES['user_upload']; $file_comment = $_POST['file_comment']; if (!empty($group_id)) { @@ -419,28 +416,28 @@ if (api_is_allowed_to_edit(false,true) OR AnnouncementManager::send_email($insert_id, $sendToUsersInSession); } - } // end condition token - } // isset + } // end condition token + } // isset - // UNSET VARIABLES - unset($form_elements); - $_SESSION['formelements']=null; + // UNSET VARIABLES + unset($form_elements); + $_SESSION['formelements']=null; - $newContent = null; - $emailTitle = null; + $newContent = null; + $emailTitle = null; - unset($emailTitle); - unset($newContent); - unset($content_to_modify); - unset($title_to_modify); + unset($emailTitle); + unset($newContent); + unset($content_to_modify); + unset($title_to_modify); - } // if $submit Announcement + } // if $submit Announcement } /* Tool introduction */ if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') { - Display::display_introduction_section(TOOL_ANNOUNCEMENT); + Display::display_introduction_section(TOOL_ANNOUNCEMENT); } /* DISPLAY LEFT COLUMN */ @@ -450,15 +447,15 @@ $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id, true, true); if (api_is_allowed_to_edit(false,true)) { - // check teacher status - if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { - - if (api_get_group_id() == 0) { - $group_condition = ""; - } else { - $group_condition = " AND (ip.to_group_id='".api_get_group_id()."' OR ip.to_group_id = 0)"; - } - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id + // check teacher status + if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { + + if (api_get_group_id() == 0) { + $group_condition = ""; + } else { + $group_condition = " AND (ip.to_group_id='".api_get_group_id()."' OR ip.to_group_id = 0)"; + } + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND ip.c_id = $course_id AND @@ -470,9 +467,9 @@ if (api_is_allowed_to_edit(false,true)) { GROUP BY ip.ref ORDER BY display_order DESC LIMIT 0,$maximum"; - } + } } else { - // students only get to see the visible announcements + // students only get to see the visible announcements if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { $group_memberships=GroupManager::get_group_ids($_course['real_id'], $_user['user_id']); @@ -487,12 +484,12 @@ if (api_is_allowed_to_edit(false,true)) { } } else { if (api_get_group_id() == 0) { - $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" . - "OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) "; - } else { - $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" . - "OR ip.to_group_id IN (0, ".api_get_group_id().")) "; - } + $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" . + "OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) "; + } else { + $cond_user_id = " AND ( ip.to_user_id='".$_user['user_id']."'" . + "OR ip.to_group_id IN (0, ".api_get_group_id().")) "; + } } // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements @@ -569,13 +566,13 @@ $announcement_number = Database::num_rows($result); $show_actions = false; if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) { - echo '
'; - if (isset($_GET['action']) && in_array($_GET['action'], array('add', 'modify','view'))) { + echo '
'; + if (isset($_GET['action']) && in_array($_GET['action'], array('add', 'modify','view'))) { echo "".Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).""; - } else { - echo "".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM).""; - } - $show_actions = true; + } else { + echo "".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM).""; + } + $show_actions = true; } else { if (in_array($_GET['action'], array('view'))) { echo '
'; @@ -585,14 +582,14 @@ if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_e } if (api_is_allowed_to_edit() && $announcement_number > 1) { - if (api_get_group_id() == 0 ) { - if (!$show_actions) - echo '
'; - if (!isset($_GET['action'])) { - echo "". - Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM).""; - } - } // if announcementNumber > 1 + if (api_get_group_id() == 0 ) { + if (!$show_actions) + echo '
'; + if (!isset($_GET['action'])) { + echo "". + Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM).""; + } + } // if announcementNumber > 1 } if ($show_actions) @@ -602,14 +599,14 @@ if ($show_actions) // ANNOUNCEMENTS LIST if ($message) { - Display::display_confirmation_message($message); - $display_announcement_list = true; - $display_form = false; + Display::display_confirmation_message($message); + $display_announcement_list = true; + $display_form = false; } if (!empty($error_message)) { - Display::display_error_message($error_message); - $display_announcement_list = false; - $display_form = true; + Display::display_error_message($error_message); + $display_announcement_list = false; + $display_form = true; } /* @@ -618,64 +615,64 @@ if (!empty($error_message)) { if ($display_form) { - $content_to_modify = stripslashes($content_to_modify); - $title_to_modify = stripslashes($title_to_modify); - - // DISPLAY ADD ANNOUNCEMENT COMMAND - //echo '
'; - $id = isset($_GET['id']) ? intval($_GET['id']) : 0; - echo ''; - if (empty($_GET['id'])) { - $form_name = get_lang('AddAnnouncement'); - } else { - $form_name = get_lang('ModifyAnnouncement'); - } - echo ''.$form_name.''; - - //this variable defines if the course administrator can send a message to a specific user / group or not + $content_to_modify = stripslashes($content_to_modify); + $title_to_modify = stripslashes($title_to_modify); + + // DISPLAY ADD ANNOUNCEMENT COMMAND + //echo ''; + $id = isset($_GET['id']) ? intval($_GET['id']) : 0; + echo ''; + if (empty($_GET['id'])) { + $form_name = get_lang('AddAnnouncement'); + } else { + $form_name = get_lang('ModifyAnnouncement'); + } + echo ''.$form_name.''; + + //this variable defines if the course administrator can send a message to a specific user / group or not //@todo use formvalidator - if (empty($group_id)) { - echo '
+ if (empty($group_id)) { + echo '
'; - if (isset($_GET['remind_inactive'])) { - $email_ann = '1'; - $_SESSION['select_groupusers']="show"; - $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'), api_get_setting('siteName'), 7); - $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName')); - } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives']=='true') { - // we want to remind inactive users. The $_GET['since'] parameter determines which users have to be warned (i.e the users who have been inactive for x days or more - $since = isset($_GET['since']) ? intval($_GET['since']) : 6; - // getting the users who have to be reminded - $to = Tracking :: get_inactives_students_in_course($_course['id'],$since, api_get_session_id()); - // setting the variables for the form elements: the users who need to receive the message - foreach($to as &$user) { - $user = 'USER:'.$user; - } - // setting the variables for the form elements: the 'visible to' form element has to be expanded - $_SESSION['select_groupusers']="show"; - // setting the variables for the form elements: the message has to be sent by email - $email_ann = '1'; - // setting the variables for the form elements: the title of the email - //$title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName'),' > ',$_course['name']); - $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName')); - // setting the variables for the form elements: the message of the email - //$content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),' > ',$_course['name'],$since); - $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),$since); - // when we want to remind the users who have never been active then we have a different subject and content for the announcement - if ($_GET['since'] == 'never') { - $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName')); - $content_to_modify = get_lang('YourAccountIsActiveYouCanLoginAndCheckYourCourses'); - } - } else { - //echo '' . get_lang('Everybody') . ''; - } - AnnouncementManager::show_to_form($to); - echo '
+ if (isset($_GET['remind_inactive'])) { + $email_ann = '1'; + $_SESSION['select_groupusers']="show"; + $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'), api_get_setting('siteName'), 7); + $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName')); + } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives']=='true') { + // we want to remind inactive users. The $_GET['since'] parameter determines which users have to be warned (i.e the users who have been inactive for x days or more + $since = isset($_GET['since']) ? intval($_GET['since']) : 6; + // getting the users who have to be reminded + $to = Tracking :: get_inactives_students_in_course($_course['id'],$since, api_get_session_id()); + // setting the variables for the form elements: the users who need to receive the message + foreach($to as &$user) { + $user = 'USER:'.$user; + } + // setting the variables for the form elements: the 'visible to' form element has to be expanded + $_SESSION['select_groupusers']="show"; + // setting the variables for the form elements: the message has to be sent by email + $email_ann = '1'; + // setting the variables for the form elements: the title of the email + //$title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName'),' > ',$_course['name']); + $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName')); + // setting the variables for the form elements: the message of the email + //$content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),' > ',$_course['name'],$since); + $content_to_modify = sprintf(get_lang('RemindInactiveLearnersMailContent'),api_get_setting('siteName'),$since); + // when we want to remind the users who have never been active then we have a different subject and content for the announcement + if ($_GET['since'] == 'never') { + $title_to_modify = sprintf(get_lang('RemindInactiveLearnersMailSubject'), api_get_setting('siteName')); + $content_to_modify = get_lang('YourAccountIsActiveYouCanLoginAndCheckYourCourses'); + } + } else { + //echo '' . get_lang('Everybody') . ''; + } + AnnouncementManager::show_to_form($to); + echo '
'; if (api_get_session_id() == 0) { @@ -684,7 +681,7 @@ if ($display_form) { echo '
'; } - if (!isset($announcement_to_modify) ) $announcement_to_modify =''; + if (!isset($announcement_to_modify) ) $announcement_to_modify =''; ($email_ann=='1')?$checked='checked':$checked=''; echo '
@@ -695,10 +692,10 @@ if ($display_form) {
'; - } else { - if (!isset($announcement_to_modify) ) { - $announcement_to_modify =""; - } + } else { + if (!isset($announcement_to_modify) ) { + $announcement_to_modify =""; + } ($email_ann=='1' || !empty($surveyid))?$checked='checked':$checked=''; echo '
@@ -706,12 +703,12 @@ if ($display_form) { '.get_lang('EmailOption').': '.get_lang('MyGroup').' '.get_lang('ModifyRecipientList').''; - AnnouncementManager::show_to_form_group($group_id); + AnnouncementManager::show_to_form_group($group_id); echo '
'; - } + } - // the announcement title - echo '
+ // the announcement title + echo '
'; - unset($title_to_modify); - $title_to_modify = null; + unset($title_to_modify); + $title_to_modify = null; - if (!isset($announcement_to_modify) ) $announcement_to_modify =""; - if (!isset($content_to_modify) ) $content_to_modify =""; - if (!isset($title_to_modify)) $title_to_modify = ""; + if (!isset($announcement_to_modify) ) $announcement_to_modify =""; + if (!isset($content_to_modify) ) $content_to_modify =""; + if (!isset($title_to_modify)) $title_to_modify = ""; - echo ''; + echo ''; $oFCKeditor = new FCKeditor('newContent') ; - $oFCKeditor->Width = '100%'; - $oFCKeditor->Height = '300'; + $oFCKeditor->Width = '100%'; + $oFCKeditor->Height = '300'; - if(!api_is_allowed_to_edit()) { - $oFCKeditor->ToolbarSet = "AnnouncementsStudent"; - } else { - $oFCKeditor->ToolbarSet = "Announcements"; - } + if(!api_is_allowed_to_edit()) { + $oFCKeditor->ToolbarSet = "AnnouncementsStudent"; + } else { + $oFCKeditor->ToolbarSet = "Announcements"; + } - $oFCKeditor->Value = $content_to_modify; + $oFCKeditor->Value = $content_to_modify; - echo '
'; + echo '
'; - echo Display::display_normal_message(get_lang('Tags').'

'.implode('
', AnnouncementManager::get_tags()), false); + echo Display::display_normal_message(get_lang('Tags').'

'.implode('
', AnnouncementManager::get_tags()), false); - echo $oFCKeditor->CreateHtml(); - echo '
'; + echo $oFCKeditor->CreateHtml(); + echo '
'; //File attachment - echo '
+ echo '
 '.get_lang('AddAnAttachment').'
@@ -771,24 +768,24 @@ if ($display_form) {
'; - echo'
'; - echo '
'; - - if (empty($group_id)) { - echo ''; - echo ''; - echo '

'; - } else { - echo ''; - echo ''; - echo '

'; - } - echo '
'; - echo '
'; - - if ((isset($_GET['action']) && isset($_GET['id']) && is_array($to))||isset($_GET['remindallinactives'])||isset($_GET['remind_inactive'])) { - echo ''; - } + echo'
'; + echo '
'; + + if (empty($group_id)) { + echo ''; + echo ''; + echo '

'; + } else { + echo ''; + echo ''; + echo '

'; + } + echo '
'; + echo '
'; + + if ((isset($_GET['action']) && isset($_GET['id']) && is_array($to))||isset($_GET['remindallinactives'])||isset($_GET['remind_inactive'])) { + echo ''; + } } // end of displayform for announcement creation/edition @@ -799,29 +796,29 @@ $course_id = api_get_course_int_id(); //if ($display_announcement_list && !$surveyid) { if ($display_announcement_list) { - // by default we use the id of the current user. The course administrator can see the announcement of other users by using the user / group filter - //$user_id=$_user['user_id']; - if (isset($_SESSION['user'])) { - //$user_id=$_SESSION['user']; - } - $user_id = api_get_user_id(); + // by default we use the id of the current user. The course administrator can see the announcement of other users by using the user / group filter + //$user_id=$_user['user_id']; + if (isset($_SESSION['user'])) { + //$user_id=$_SESSION['user']; + } + $user_id = api_get_user_id(); - if (isset($_SESSION['group'])) { - //$group_id=$_SESSION['group']; - } - $group_id = api_get_group_id(); + if (isset($_SESSION['group'])) { + //$group_id=$_SESSION['group']; + } + $group_id = api_get_group_id(); - $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id()); + $group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id()); - //$is_group_member = GroupManager :: is_tutor(api_get_user_id()); + //$is_group_member = GroupManager :: is_tutor(api_get_user_id()); - if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { - // A.1. you are a course admin with a USER filter - // => see only the messages of this specific user + the messages of the group (s)he is member of. - if (!empty($_SESSION['user'])) { + if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + // A.1. you are a course admin with a USER filter + // => see only the messages of this specific user + the messages of the group (s)he is member of. + if (!empty($_SESSION['user'])) { - if (is_array($group_memberships) && count($group_memberships) > 0 ) { - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + if (is_array($group_memberships) && count($group_memberships) > 0 ) { + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND ip.c_id = $course_id AND @@ -832,8 +829,8 @@ if ($display_announcement_list) { ORDER BY display_order DESC"; - } else { - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + } else { + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND ip.c_id = $course_id AND @@ -844,11 +841,11 @@ if ($display_announcement_list) { $condition_session ORDER BY display_order DESC"; - } - } elseif (api_get_group_id() != 0 ) { - // A.2. you are a course admin with a GROUP filter - // => see only the messages of this specific group - $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + } + } elseif (api_get_group_id() != 0 ) { + // A.2. you are a course admin with a GROUP filter + // => see only the messages of this specific group + $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND ip.c_id = $course_id AND @@ -859,14 +856,14 @@ if ($display_announcement_list) { $condition_session GROUP BY ip.ref ORDER BY display_order DESC"; - } else { + } else { - // A.3 you are a course admin without any group or user filter - // A.3.a you are a course admin without user or group filter but WITH studentview - // => see all the messages of all the users and groups without editing possibilities + // A.3 you are a course admin without any group or user filter + // A.3.a you are a course admin without user or group filter but WITH studentview + // => see all the messages of all the users and groups without editing possibilities - if (isset($isStudentView) and $isStudentView=="true") { - $sql="SELECT + if (isset($isStudentView) and $isStudentView=="true") { + $sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND @@ -877,10 +874,10 @@ if ($display_announcement_list) { $condition_session GROUP BY ip.ref ORDER BY display_order DESC"; - } else { - // A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view) - // => see all the messages of all the users and groups with editing possibilities - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + } else { + // A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view) + // => see all the messages of all the users and groups with editing possibilities + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND ip.c_id = $course_id AND @@ -890,32 +887,32 @@ if ($display_announcement_list) { $condition_session GROUP BY ip.ref ORDER BY display_order DESC"; - } - } - } else { - //STUDENT - - if (is_array($group_memberships) && count($group_memberships)>0) { - if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { - if (api_get_group_id() == 0) { - //No group - $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" . - " OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) "; - } else { - $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' + } + } + } else { + //STUDENT + + if (is_array($group_memberships) && count($group_memberships)>0) { + if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + if (api_get_group_id() == 0) { + //No group + $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ( ip.to_user_id='".$_user['user_id']."'" . + " OR ip.to_group_id IN (0, ".implode(", ", $group_memberships)."))) "; + } else { + $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id IN (0, ".api_get_group_id()."))"; - } - //$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )) "; - - } else { - if (api_get_group_id() == 0) { - $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) "; - } else { - $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".api_get_group_id()."))"; - } - } - - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + } + //$cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )) "; + + } else { + if (api_get_group_id() == 0) { + $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) "; + } else { + $cond_user_id = " AND (ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".api_get_group_id()."))"; + } + } + + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND ip.c_id = $course_id AND @@ -925,15 +922,15 @@ if ($display_announcement_list) { $condition_session AND ip.visibility='1' ORDER BY display_order DESC"; - } else { - if ($_user['user_id']) { - if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { - $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) "; - } else { - $cond_user_id = " AND (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') "; - } - - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + } else { + if ($_user['user_id']) { + if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0')) "; + } else { + $cond_user_id = " AND (ip.to_user_id='".$_user['user_id']."' OR ip.to_group_id='0') "; + } + + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND @@ -945,15 +942,15 @@ if ($display_announcement_list) { AND ip.visibility='1' AND announcement.session_id IN(0,".api_get_session_id().") ORDER BY display_order DESC"; - } else { + } else { - if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { - $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' ) "; - } else { - $cond_user_id = " AND ip.to_group_id='0' "; - } + if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + $cond_user_id = " AND (ip.lastedit_user_id = '".api_get_user_id()."' OR ip.to_group_id='0' ) "; + } else { + $cond_user_id = " AND ip.to_group_id='0' "; + } - $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date + $sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date FROM $tbl_announcement announcement, $tbl_item_property ip WHERE announcement.c_id = $course_id AND @@ -964,140 +961,140 @@ if ($display_announcement_list) { $condition_session AND ip.visibility='1' AND announcement.session_id IN(0,".api_get_session_id().")"; - } - } - } + } + } + } - $result = Database::query($sql); - $num_rows = Database::num_rows($result); + $result = Database::query($sql); + $num_rows = Database::num_rows($result); // DISPLAY: NO ITEMS - if (!isset($_GET['action']) || !in_array($_GET['action'], array('add', 'modify','view'))) - if ($num_rows == 0) { - if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) { - echo '
'; - echo '

'.get_lang('Announcements').'

'; - echo Display::return_icon('valves.png', '', array(), 64); - echo '
'; - echo Display::url(get_lang('AddAnnouncement'), api_get_self()."?".api_get_cidreq()."&action=add&origin=".$origin, array('class' => 'btn')); - echo '
'; - echo '
'; - } else { - //echo "".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM).""; - Display::display_warning_message(get_lang('NoAnnouncements')); - } + if (!isset($_GET['action']) || !in_array($_GET['action'], array('add', 'modify','view'))) + if ($num_rows == 0) { + if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) and (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')) { + echo '
'; + echo '

'.get_lang('Announcements').'

'; + echo Display::return_icon('valves.png', '', array(), 64); + echo '
'; + echo Display::url(get_lang('AddAnnouncement'), api_get_self()."?".api_get_cidreq()."&action=add&origin=".$origin, array('class' => 'btn')); + echo '
'; + echo '
'; + } else { + //echo "".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM).""; + Display::display_warning_message(get_lang('NoAnnouncements')); + } - } else { - $iterator = 1; - $bottomAnnouncement = $announcement_number; - - echo ''; - $ths = Display::tag('th', get_lang('Title')); - $ths .= Display::tag('th', get_lang('By') ); - $ths .= Display::tag('th', get_lang('LastUpdateDate') ); - if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) - OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { - $ths .= Display::tag('th', get_lang('Modify')); - } + } else { + $iterator = 1; + $bottomAnnouncement = $announcement_number; + + echo '
'; + $ths = Display::tag('th', get_lang('Title')); + $ths .= Display::tag('th', get_lang('By') ); + $ths .= Display::tag('th', get_lang('LastUpdateDate') ); + if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) + OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + $ths .= Display::tag('th', get_lang('Modify')); + } - echo Display::tag('tr', $ths); - $displayed = array(); + echo Display::tag('tr', $ths); + $displayed = array(); - while ($myrow = Database::fetch_array($result, 'ASSOC')) { - if (!in_array($myrow['id'], $displayed)) { - $sent_to_icon = ''; - // the email icon - if ($myrow['email_sent'] == '1') { - $sent_to_icon = ' '.Display::return_icon('email.gif', get_lang('AnnounceSentByEmail')); - } + while ($myrow = Database::fetch_array($result, 'ASSOC')) { + if (!in_array($myrow['id'], $displayed)) { + $sent_to_icon = ''; + // the email icon + if ($myrow['email_sent'] == '1') { + $sent_to_icon = ' '.Display::return_icon('email.gif', get_lang('AnnounceSentByEmail')); + } - $title = $myrow['title'].$sent_to_icon; + $title = $myrow['title'].$sent_to_icon; - /* DATE */ - $last_post_datetime = $myrow['end_date']; + /* DATE */ + $last_post_datetime = $myrow['end_date']; - $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id); - $myrow['visibility'] = $item_visibility; + $item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id); + $myrow['visibility'] = $item_visibility; - // the styles - if ($myrow['visibility'] == '0') { - $style='invisible'; - } else { - $style = ''; - } + // the styles + if ($myrow['visibility'] == '0') { + $style='invisible'; + } else { + $style = ''; + } - echo ''; + echo ''; - // show attachment list - $attachment_list = array(); - $attachment_list = AnnouncementManager::get_attachment($myrow['id']); + // show attachment list + $attachment_list = array(); + $attachment_list = AnnouncementManager::get_attachment($myrow['id']); - $attachment_icon = ''; - if (count($attachment_list)>0) { - $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); - } + $attachment_icon = ''; + if (count($attachment_list)>0) { + $attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); + } - /* TITLE */ - $title = Display::url($title.$attachment_icon, api_get_self().'?'.api_get_cidreq().'&action=view&id='.$myrow['id']); - echo Display::tag('td', Security::remove_XSS($title), array('class' => 'announcements-list-line-title '.$style)); - - $user_info = api_get_user_info($myrow['insert_user_id']); - $username = sprintf(get_lang("LoginX"), $user_info['username']); - $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title'=>$username)); - echo Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user')); - echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), array('class' => 'announcements-list-line-datetime')); - - // we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on - $modify_icons = ''; - if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id'])) - OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { - - $modify_icons = "".Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).""; - if ($myrow['visibility']==1) { - $image_visibility="visible"; - $alt_visibility=get_lang('Hide'); - } else { - $image_visibility="invisible"; - $alt_visibility=get_lang('Visible'); - } - $modify_icons .= "". - Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL).""; - - // DISPLAY MOVE UP COMMAND only if it is not the top announcement - if ($iterator != 1) { - $modify_icons .= "".Display::return_icon('up.gif', get_lang('Up')).""; - } else { - $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up')); - } - if ($iterator < $bottomAnnouncement) { - $modify_icons .= "".Display::return_icon('down.gif', get_lang('Down')).""; - } else { - $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); - } - if (api_is_allowed_to_edit(false,true)) { - $modify_icons .= "". - Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). - ""; + /* TITLE */ + $title = Display::url($title.$attachment_icon, api_get_self().'?'.api_get_cidreq().'&action=view&id='.$myrow['id']); + echo Display::tag('td', Security::remove_XSS($title), array('class' => 'announcements-list-line-title '.$style)); + + $user_info = api_get_user_info($myrow['insert_user_id']); + $username = sprintf(get_lang("LoginX"), $user_info['username']); + $username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title'=>$username)); + echo Display::tag('td', $username_span, array('class' => 'announcements-list-line-by-user')); + echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG), array('class' => 'announcements-list-line-datetime')); + + // we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on + $modify_icons = ''; + if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id'])) + OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + + $modify_icons = "".Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).""; + if ($myrow['visibility']==1) { + $image_visibility="visible"; + $alt_visibility=get_lang('Hide'); + } else { + $image_visibility="invisible"; + $alt_visibility=get_lang('Visible'); + } + $modify_icons .= "". + Display::return_icon($image_visibility.'.png', $alt_visibility,'',ICON_SIZE_SMALL).""; + + // DISPLAY MOVE UP COMMAND only if it is not the top announcement + if ($iterator != 1) { + $modify_icons .= "".Display::return_icon('up.gif', get_lang('Up')).""; + } else { + $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up')); + } + if ($iterator < $bottomAnnouncement) { + $modify_icons .= "".Display::return_icon('down.gif', get_lang('Down')).""; + } else { + $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); + } + if (api_is_allowed_to_edit(false,true)) { + $modify_icons .= "". + Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). + ""; + } + $iterator ++; + echo Display::tag('td', $modify_icons, array('class' => 'announcements-list-line-actions')); } - $iterator ++; - echo Display::tag('td', $modify_icons, array('class' => 'announcements-list-line-actions')); - } - echo ""; - } - $displayed[]=$myrow['id']; - } // end while - echo "
"; - } + echo ""; + } + $displayed[]=$myrow['id']; + } // end while + echo ""; + } } // end: if ($displayAnnoucementList) if (isset($_GET['action']) && $_GET['action'] == 'view') { - AnnouncementManager::display_announcement($announcement_id); + AnnouncementManager::display_announcement($announcement_id); } /* FOOTER */ if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { - //we are not in learnpath tool - Display::display_footer(); + //we are not in learnpath tool + Display::display_footer(); } diff --git a/main/announcements/download.php b/main/announcements/download.php index 67ffa25045..cdefb0d93c 100755 --- a/main/announcements/download.php +++ b/main/announcements/download.php @@ -1,17 +1,13 @@ 0) { $row= Database::fetch_array($result); $title = str_replace(' ','_', $row['filename']); - if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/announcements/')) { + if (Security::check_abs_path($full_file_name, + api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/upload/announcements/') + ) { DocumentManager::file_send_for_download($full_file_name,TRUE, $title); } } -exit; \ No newline at end of file +exit; diff --git a/main/gradebook/exercise_jump.php b/main/gradebook/exercise_jump.php index 625c6505e7..7d8261548e 100755 --- a/main/gradebook/exercise_jump.php +++ b/main/gradebook/exercise_jump.php @@ -9,9 +9,6 @@ * @author Bert Steppé * @package chamilo.gradebook */ -/** - * Init - */ require_once '../inc/global.inc.php'; api_block_anonymous_users(); @@ -39,12 +36,12 @@ $_course['name'] = $course_title; $_course['official_code'] = $course_code; if (isset($_GET['doexercise'])) { - header('Location: '.$doExerciseUrl); - exit; + header('Location: '.$doExerciseUrl); + exit; } else { - if (isset($_GET['gradebook'])) { - $add_url = '&gradebook=view&exerciseId='.intval($_GET['exerciseId']); - } - header('Location: '.api_get_path(WEB_CODE_PATH).'exercice/overview.php?session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq).'&'.$add_url); - exit; + if (isset($_GET['gradebook'])) { + $add_url = '&gradebook=view&exerciseId='.intval($_GET['exerciseId']); + } + header('Location: '.api_get_path(WEB_CODE_PATH).'exercice/overview.php?session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq).'&'.$add_url); + exit; } diff --git a/main/gradebook/gradebook.php b/main/gradebook/gradebook.php index 2d254f3bc4..976e233086 100755 --- a/main/gradebook/gradebook.php +++ b/main/gradebook/gradebook.php @@ -4,9 +4,7 @@ * Script * @package chamilo.gradebook */ -/** - * Init - */ + $language_file= 'gradebook'; // $cidReset : This is the main difference with gradebook.php, here we say, // basically, that we are inside a course, and many things depend from that @@ -15,12 +13,12 @@ $_in_course = false; //make sure the destination for scripts is index.php instead of gradebook.php require_once '../inc/global.inc.php'; if (!empty($_GET['course'])) { - $_SESSION['gradebook_dest'] = 'index.php'; - $this_section = SECTION_COURSES; + $_SESSION['gradebook_dest'] = 'index.php'; + $this_section = SECTION_COURSES; } else { - $_SESSION['gradebook_dest'] = 'gradebook.php'; - $this_section = SECTION_MYGRADEBOOK; - unset($_GET['course']); + $_SESSION['gradebook_dest'] = 'gradebook.php'; + $this_section = SECTION_MYGRADEBOOK; + unset($_GET['course']); } require_once 'lib/be.inc.php'; require_once 'lib/scoredisplay.class.php'; @@ -60,541 +58,541 @@ $filter_warning_msg = true; //this is called when there is no data for the course admin if (isset ($_GET['createallcategories'])) { - block_students(); - $coursecat= Category :: get_not_created_course_categories(api_get_user_id()); - if (!count($coursecat) == 0) { - foreach ($coursecat as $row) { - $cat= new Category(); - $cat->set_name($row[1]); - $cat->set_course_code($row[0]); - $cat->set_description(null); - $cat->set_user_id(api_get_user_id()); - $cat->set_parent_id(0); - $cat->set_weight(0); - $cat->set_visible(0); - $cat->add(); - unset ($cat); - } - } - header('Location: '.$_SESSION['gradebook_dest'].'?addallcat=&selectcat=0'); - exit; + block_students(); + $coursecat= Category :: get_not_created_course_categories(api_get_user_id()); + if (!count($coursecat) == 0) { + foreach ($coursecat as $row) { + $cat= new Category(); + $cat->set_name($row[1]); + $cat->set_course_code($row[0]); + $cat->set_description(null); + $cat->set_user_id(api_get_user_id()); + $cat->set_parent_id(0); + $cat->set_weight(0); + $cat->set_visible(0); + $cat->add(); + unset ($cat); + } + } + header('Location: '.$_SESSION['gradebook_dest'].'?addallcat=&selectcat=0'); + exit; } //move a category $selectcat=isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : ''; if (isset ($_GET['movecat'])) { - $move_cat=Security::remove_XSS($_GET['movecat']); - block_students(); - $cats= Category :: load($move_cat); - if (!isset ($_GET['targetcat'])) { - $move_form= new CatForm(CatForm :: TYPE_MOVE, - $cats[0], - 'move_cat_form', - null, - api_get_self() . '?movecat=' . $move_cat - . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); - if ($move_form->validate()) { - header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) - . '&movecat=' . $move_cat - . '&targetcat=' . $move_form->exportValue('move_cat')); - exit; - } - } else { - $get_target_cat=Security::remove_XSS($_GET['targetcat']); - $targetcat= Category :: load($get_target_cat); - $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); + $move_cat=Security::remove_XSS($_GET['movecat']); + block_students(); + $cats= Category :: load($move_cat); + if (!isset ($_GET['targetcat'])) { + $move_form= new CatForm(CatForm :: TYPE_MOVE, + $cats[0], + 'move_cat_form', + null, + api_get_self() . '?movecat=' . $move_cat + . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); + if ($move_form->validate()) { + header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) + . '&movecat=' . $move_cat + . '&targetcat=' . $move_form->exportValue('move_cat')); + exit; + } + } else { + $get_target_cat=Security::remove_XSS($_GET['targetcat']); + $targetcat= Category :: load($get_target_cat); + $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); - if (!($course_to_crsind && !isset($_GET['confirm']))) { - $cats[0]->move_to_cat($targetcat[0]); - header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); - exit; - } - unset ($targetcat); - } - unset ($cats); + if (!($course_to_crsind && !isset($_GET['confirm']))) { + $cats[0]->move_to_cat($targetcat[0]); + header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); + exit; + } + unset ($targetcat); + } + unset ($cats); } //move an evaluation if (isset ($_GET['moveeval'])) { - block_students(); - $get_move_eval=Security::remove_XSS($_GET['moveeval']); - $evals= Evaluation :: load($get_move_eval); - if (!isset ($_GET['targetcat'])) { + block_students(); + $get_move_eval=Security::remove_XSS($_GET['moveeval']); + $evals= Evaluation :: load($get_move_eval); + if (!isset ($_GET['targetcat'])) { - $move_form= new EvalForm(EvalForm :: TYPE_MOVE, - $evals[0], - null, - 'move_eval_form', - null, - api_get_self() . '?moveeval=' . $get_move_eval - . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); + $move_form= new EvalForm(EvalForm :: TYPE_MOVE, + $evals[0], + null, + 'move_eval_form', + null, + api_get_self() . '?moveeval=' . $get_move_eval + . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); - if ($move_form->validate()) { - header('Location: ' .api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) - . '&moveeval=' . $get_move_eval - . '&targetcat=' . $move_form->exportValue('move_cat')); - exit; - } - } else { - $get_target_cat=Security::remove_XSS($_GET['targetcat']); - $targetcat= Category :: load($get_target_cat); - $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); + if ($move_form->validate()) { + header('Location: ' .api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) + . '&moveeval=' . $get_move_eval + . '&targetcat=' . $move_form->exportValue('move_cat')); + exit; + } + } else { + $get_target_cat=Security::remove_XSS($_GET['targetcat']); + $targetcat= Category :: load($get_target_cat); + $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); - if (!($course_to_crsind && !isset($_GET['confirm']))) { - $evals[0]->move_to_cat($targetcat[0]); - header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); - exit; - } - unset ($targetcat); - } - unset ($evals); + if (!($course_to_crsind && !isset($_GET['confirm']))) { + $evals[0]->move_to_cat($targetcat[0]); + header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); + exit; + } + unset ($targetcat); + } + unset ($evals); } //move a link if (isset ($_GET['movelink'])) { - block_students(); - $get_move_link=Security::remove_XSS($_GET['movelink']); - $link= LinkFactory :: load($get_move_link); - $move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $get_move_link . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); - if ($move_form->validate()) { - $targetcat= Category :: load($move_form->exportValue('move_cat')); - $link[0]->move_to_cat($targetcat[0]); - unset ($link); - header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); - exit; - } + block_students(); + $get_move_link=Security::remove_XSS($_GET['movelink']); + $link= LinkFactory :: load($get_move_link); + $move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $get_move_link . '&selectcat=' . Security::remove_XSS($_GET['selectcat'])); + if ($move_form->validate()) { + $targetcat= Category :: load($move_form->exportValue('move_cat')); + $link[0]->move_to_cat($targetcat[0]); + unset ($link); + header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat'])); + exit; + } } //parameters for categories if (isset ($_GET['visiblecat'])) { - block_students(); - if (isset ($_GET['set_visible'])) { - $visibility_command= 1; - } else { - $visibility_command= 0; - } - $cats= Category :: load($_GET['visiblecat']); - $cats[0]->set_visible($visibility_command); - $cats[0]->save(); - $cats[0]->apply_visibility_to_children(); - unset ($cats); - if ($visibility_command) { - $confirmation_message = get_lang('ViMod'); - $filter_confirm_msg = false; - } else { - $confirmation_message = get_lang('InViMod'); - $filter_confirm_msg = false; - } + block_students(); + if (isset ($_GET['set_visible'])) { + $visibility_command= 1; + } else { + $visibility_command= 0; + } + $cats= Category :: load($_GET['visiblecat']); + $cats[0]->set_visible($visibility_command); + $cats[0]->save(); + $cats[0]->apply_visibility_to_children(); + unset ($cats); + if ($visibility_command) { + $confirmation_message = get_lang('ViMod'); + $filter_confirm_msg = false; + } else { + $confirmation_message = get_lang('InViMod'); + $filter_confirm_msg = false; + } } if (isset ($_GET['deletecat'])) { - block_students(); - $cats= Category :: load($_GET['deletecat']); - //delete all categories,subcategories and results - if ($cats[0] != null) { - if ($cats[0]->get_id() != 0) { - // better don't try to delete the root... - $cats[0]->delete_all(); - } - } - $confirmation_message = get_lang('CategoryDeleted'); - $filter_confirm_msg = false; + block_students(); + $cats= Category :: load($_GET['deletecat']); + //delete all categories,subcategories and results + if ($cats[0] != null) { + if ($cats[0]->get_id() != 0) { + // better don't try to delete the root... + $cats[0]->delete_all(); + } + } + $confirmation_message = get_lang('CategoryDeleted'); + $filter_confirm_msg = false; } //parameters for evaluations if (isset ($_GET['visibleeval'])) { - block_students(); - if (isset ($_GET['set_visible'])) { - $visibility_command= 1; - } else { - $visibility_command= 0; - } + block_students(); + if (isset ($_GET['set_visible'])) { + $visibility_command= 1; + } else { + $visibility_command= 0; + } - $eval= Evaluation :: load($_GET['visibleeval']); - $eval[0]->set_visible($visibility_command); - $eval[0]->save(); - unset ($eval); - if ($visibility_command) { - $confirmation_message = get_lang('ViMod'); - $filter_confirm_msg = false; - } else { - $confirmation_message = get_lang('InViMod'); - $filter_confirm_msg = false; - } + $eval= Evaluation :: load($_GET['visibleeval']); + $eval[0]->set_visible($visibility_command); + $eval[0]->save(); + unset ($eval); + if ($visibility_command) { + $confirmation_message = get_lang('ViMod'); + $filter_confirm_msg = false; + } else { + $confirmation_message = get_lang('InViMod'); + $filter_confirm_msg = false; + } } if (isset ($_GET['deleteeval'])) { - block_students(); - $eval= Evaluation :: load($_GET['deleteeval']); - if ($eval[0] != null) { - $eval[0]->delete_with_results(); - } - $confirmation_message = get_lang('GradebookEvaluationDeleted'); - $filter_confirm_msg = false; + block_students(); + $eval= Evaluation :: load($_GET['deleteeval']); + if ($eval[0] != null) { + $eval[0]->delete_with_results(); + } + $confirmation_message = get_lang('GradebookEvaluationDeleted'); + $filter_confirm_msg = false; } //parameters for links if (isset ($_GET['visiblelink'])) { - block_students(); - if (isset ($_GET['set_visible'])) { - $visibility_command= 1; - }else { - $visibility_command= 0; - } - $link= LinkFactory :: load($_GET['visiblelink']); - $link[0]->set_visible($visibility_command); - $link[0]->save(); - unset ($link); - if ($visibility_command) { - $confirmation_message = get_lang('ViMod'); - $filter_confirm_msg = false; - } else { - $confirmation_message = get_lang('InViMod'); - $filter_confirm_msg = false; - } + block_students(); + if (isset ($_GET['set_visible'])) { + $visibility_command= 1; + }else { + $visibility_command= 0; + } + $link= LinkFactory :: load($_GET['visiblelink']); + $link[0]->set_visible($visibility_command); + $link[0]->save(); + unset ($link); + if ($visibility_command) { + $confirmation_message = get_lang('ViMod'); + $filter_confirm_msg = false; + } else { + $confirmation_message = get_lang('InViMod'); + $filter_confirm_msg = false; + } } if (isset ($_GET['deletelink'])) { - block_students(); - //fixing #5229 - if (!empty($_GET['deletelink'])) { - $link= LinkFactory :: load($_GET['deletelink']); - if ($link[0] != null) { - $link[0]->delete(); - } - unset ($link); - $confirmation_message = get_lang('LinkDeleted'); - $filter_confirm_msg = false; - } + block_students(); + //fixing #5229 + if (!empty($_GET['deletelink'])) { + $link= LinkFactory :: load($_GET['deletelink']); + if ($link[0] != null) { + $link[0]->delete(); + } + unset ($link); + $confirmation_message = get_lang('LinkDeleted'); + $filter_confirm_msg = false; + } } $course_to_crsind = isset ($course_to_crsind) ? $course_to_crsind : ''; if ($course_to_crsind && !isset($_GET['confirm'])) { - block_students(); - if (!isset($_GET['movecat']) && !isset($_GET['moveeval'])) { - die ('Error: movecat or moveeval not defined'); - } - $button = '
+ .(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat']) + : '&moveeval=' . Security::remove_XSS($_GET['moveeval']) ) + .'&selectcat=' . Security::remove_XSS($_GET['selectcat']) + .'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
'; - $warning_message = get_lang('MoveWarning').'

'.$button; - $filter_warning_msg = false; + $warning_message = get_lang('MoveWarning').'

'.$button; + $filter_warning_msg = false; } //actions on the sortabletable if (isset ($_POST['action'])) { - block_students(); - $number_of_selected_items= count($_POST['id']); - if ($number_of_selected_items == '0') { - $warning_message = get_lang('NoItemsSelected'); - $filter_warning_msg = false; - } - else { - switch ($_POST['action']) { - case 'deleted' : - $number_of_deleted_categories= 0; - $number_of_deleted_evaluations= 0; - $number_of_deleted_links= 0; - foreach ($_POST['id'] as $indexstr) { - if (api_substr($indexstr, 0, 4) == 'CATE') { - $cats= Category :: load(api_substr($indexstr, 4)); - if ($cats[0] != null) { - $cats[0]->delete_all(); - } - $number_of_deleted_categories++; - } - if (api_substr($indexstr, 0, 4) == 'EVAL') { - $eval= Evaluation :: load(api_substr($indexstr, 4)); - if ($eval[0] != null) { - $eval[0]->delete_with_results(); - } - $number_of_deleted_evaluations++; - } - if (api_substr($indexstr, 0, 4) == 'LINK') { - $id = api_substr($indexstr, 4); - if (!empty($id)) { - $link= LinkFactory :: load(); - if ($link[0] != null) { - $link[0]->delete(); - } - $number_of_deleted_links++; - } - } - } - $confirmation_message = get_lang('DeletedCategories') . ' : ' . $number_of_deleted_categories . '
' . get_lang('DeletedEvaluations') . ' : ' . $number_of_deleted_evaluations . '
' . get_lang('DeletedLinks') . ' : ' . $number_of_deleted_links . '

' . get_lang('TotalItems') . ' : ' . $number_of_selected_items . ''; - $filter_confirm_msg = false; - break; - case 'setvisible' : - foreach ($_POST['id'] as $indexstr) - { - if (api_substr($indexstr, 0, 4) == 'CATE') - { - $cats= Category :: load(api_substr($indexstr, 4)); - $cats[0]->set_visible(1); - $cats[0]->save(); - $cats[0]->apply_visibility_to_children(); - } - if (api_substr($indexstr, 0, 4) == 'EVAL') - { - $eval= Evaluation :: load(api_substr($indexstr, 4)); - $eval[0]->set_visible(1); - $eval[0]->save(); - } - if (api_substr($indexstr, 0, 4) == 'LINK') - { - $link= LinkFactory :: load(api_substr($indexstr, 4)); - $link[0]->set_visible(1); - $link[0]->save(); - } - } - $confirmation_message = get_lang('ItemsVisible'); - $filter_confirm_msg = false; - break; - case 'setinvisible' : - foreach ($_POST['id'] as $indexstr) - { - if (api_substr($indexstr, 0, 4) == 'CATE') - { - $cats= Category :: load(api_substr($indexstr, 4)); - $cats[0]->set_visible(0); - $cats[0]->save(); - $cats[0]->apply_visibility_to_children(); - } - if (api_substr($indexstr, 0, 4) == 'EVAL') - { - $eval= Evaluation :: load(api_substr($indexstr, 4)); - $eval[0]->set_visible(0); - $eval[0]->save(); - } - if (api_substr($indexstr, 0, 4) == 'LINK') - { - $link= LinkFactory :: load(api_substr($indexstr, 4)); - $link[0]->set_visible(0); - $link[0]->save(); - } - } - $confirmation_message = get_lang('ItemsInVisible'); - $filter_confirm_msg = false; - break; - } - } + block_students(); + $number_of_selected_items= count($_POST['id']); + if ($number_of_selected_items == '0') { + $warning_message = get_lang('NoItemsSelected'); + $filter_warning_msg = false; + } + else { + switch ($_POST['action']) { + case 'deleted' : + $number_of_deleted_categories= 0; + $number_of_deleted_evaluations= 0; + $number_of_deleted_links= 0; + foreach ($_POST['id'] as $indexstr) { + if (api_substr($indexstr, 0, 4) == 'CATE') { + $cats= Category :: load(api_substr($indexstr, 4)); + if ($cats[0] != null) { + $cats[0]->delete_all(); + } + $number_of_deleted_categories++; + } + if (api_substr($indexstr, 0, 4) == 'EVAL') { + $eval= Evaluation :: load(api_substr($indexstr, 4)); + if ($eval[0] != null) { + $eval[0]->delete_with_results(); + } + $number_of_deleted_evaluations++; + } + if (api_substr($indexstr, 0, 4) == 'LINK') { + $id = api_substr($indexstr, 4); + if (!empty($id)) { + $link= LinkFactory :: load(); + if ($link[0] != null) { + $link[0]->delete(); + } + $number_of_deleted_links++; + } + } + } + $confirmation_message = get_lang('DeletedCategories') . ' : ' . $number_of_deleted_categories . '
' . get_lang('DeletedEvaluations') . ' : ' . $number_of_deleted_evaluations . '
' . get_lang('DeletedLinks') . ' : ' . $number_of_deleted_links . '

' . get_lang('TotalItems') . ' : ' . $number_of_selected_items . ''; + $filter_confirm_msg = false; + break; + case 'setvisible' : + foreach ($_POST['id'] as $indexstr) + { + if (api_substr($indexstr, 0, 4) == 'CATE') + { + $cats= Category :: load(api_substr($indexstr, 4)); + $cats[0]->set_visible(1); + $cats[0]->save(); + $cats[0]->apply_visibility_to_children(); + } + if (api_substr($indexstr, 0, 4) == 'EVAL') + { + $eval= Evaluation :: load(api_substr($indexstr, 4)); + $eval[0]->set_visible(1); + $eval[0]->save(); + } + if (api_substr($indexstr, 0, 4) == 'LINK') + { + $link= LinkFactory :: load(api_substr($indexstr, 4)); + $link[0]->set_visible(1); + $link[0]->save(); + } + } + $confirmation_message = get_lang('ItemsVisible'); + $filter_confirm_msg = false; + break; + case 'setinvisible' : + foreach ($_POST['id'] as $indexstr) + { + if (api_substr($indexstr, 0, 4) == 'CATE') + { + $cats= Category :: load(api_substr($indexstr, 4)); + $cats[0]->set_visible(0); + $cats[0]->save(); + $cats[0]->apply_visibility_to_children(); + } + if (api_substr($indexstr, 0, 4) == 'EVAL') + { + $eval= Evaluation :: load(api_substr($indexstr, 4)); + $eval[0]->set_visible(0); + $eval[0]->save(); + } + if (api_substr($indexstr, 0, 4) == 'LINK') + { + $link= LinkFactory :: load(api_substr($indexstr, 4)); + $link[0]->set_visible(0); + $link[0]->save(); + } + } + $confirmation_message = get_lang('ItemsInVisible'); + $filter_confirm_msg = false; + break; + } + } } if (isset ($_POST['submit']) && isset ($_POST['keyword'])) { - header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) - . '&search='.Security::remove_XSS($_POST['keyword'])); - exit; + header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']) + . '&search='.Security::remove_XSS($_POST['keyword'])); + exit; } // DISPLAY HEADERS AND MESSAGES - if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) { - if (isset ($_GET['studentoverview'])) { - $interbreadcrumb[]= array ( - 'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']), - 'name' => get_lang('ToolGradebook') - ); - Display :: display_header(get_lang('FlatView')); - } elseif (isset ($_GET['search'])) { - if ($_SESSION['gradebook_dest'] == 'index.php') { - $gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']).'?cidReq='.Security::remove_XSS($_GET['course']).'&'; - } else { - $gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']); - } - - $interbreadcrumb[]= array ('url' => $gradebook_dest,'name' => get_lang('Gradebook')); + if (isset ($_GET['studentoverview'])) { + $interbreadcrumb[]= array ( + 'url' => $_SESSION['gradebook_dest'].'?selectcat=' . Security::remove_XSS($_GET['selectcat']), + 'name' => get_lang('ToolGradebook') + ); + Display :: display_header(get_lang('FlatView')); + } elseif (isset ($_GET['search'])) { + if ($_SESSION['gradebook_dest'] == 'index.php') { + $gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']).'?cidReq='.Security::remove_XSS($_GET['course']).'&'; + } else { + $gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']); + } - if ((isset($_GET['selectcat']) && $_GET['selectcat']>0)) { - if (!empty($_GET['course'])) { - $interbreadcrumb[]= array ('url' => $gradebook_dest.'selectcat='.Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Details')); - } else { - $interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=0','name' => get_lang('Details')); - } - } - Display :: display_header(''); - } else { - Display :: display_header(''); - } + $interbreadcrumb[]= array ('url' => $gradebook_dest,'name' => get_lang('Gradebook')); + + if ((isset($_GET['selectcat']) && $_GET['selectcat']>0)) { + if (!empty($_GET['course'])) { + $interbreadcrumb[]= array ('url' => $gradebook_dest.'selectcat='.Security::remove_XSS($_GET['selectcat']),'name' => get_lang('Details')); + } else { + $interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=0','name' => get_lang('Details')); + } + } + Display :: display_header(''); + } else { + Display :: display_header(''); + } } if (isset ($_GET['categorymoved'])) { - Display :: display_confirmation_message(get_lang('CategoryMoved'),false); + Display :: display_confirmation_message(get_lang('CategoryMoved'),false); } if (isset ($_GET['evaluationmoved'])) { - Display :: display_confirmation_message(get_lang('EvaluationMoved'),false); + Display :: display_confirmation_message(get_lang('EvaluationMoved'),false); } if (isset ($_GET['linkmoved'])) { - Display :: display_confirmation_message(get_lang('LinkMoved'),false); + Display :: display_confirmation_message(get_lang('LinkMoved'),false); } if (isset ($_GET['addcat'])) { - Display :: display_confirmation_message(get_lang('CategoryAdded'),false); + Display :: display_confirmation_message(get_lang('CategoryAdded'),false); } if (isset ($_GET['linkadded'])) { - Display :: display_confirmation_message(get_lang('LinkAdded'),false); + Display :: display_confirmation_message(get_lang('LinkAdded'),false); } if (isset ($_GET['addresult'])) { - Display :: display_confirmation_message(get_lang('ResultAdded'),false); + Display :: display_confirmation_message(get_lang('ResultAdded'),false); } if (isset ($_GET['editcat'])) { - Display :: display_confirmation_message(get_lang('CategoryEdited'),false); + Display :: display_confirmation_message(get_lang('CategoryEdited'),false); } if (isset ($_GET['editeval'])) { - Display :: display_confirmation_message(get_lang('EvaluationEdited'),false); + Display :: display_confirmation_message(get_lang('EvaluationEdited'),false); } if (isset ($_GET['linkedited'])) { - Display :: display_confirmation_message(get_lang('LinkEdited'),false); + Display :: display_confirmation_message(get_lang('LinkEdited'),false); } if (isset ($_GET['nolinkitems'])) { - Display :: display_warning_message(get_lang('NoLinkItems'),false); + Display :: display_warning_message(get_lang('NoLinkItems'),false); } if (isset ($_GET['addallcat'])) { - Display :: display_normal_message(get_lang('AddAllCat'),false); + Display :: display_normal_message(get_lang('AddAllCat'),false); } if (isset ($confirmation_message)) { - Display :: display_confirmation_message($confirmation_message,$filter_confirm_msg); + Display :: display_confirmation_message($confirmation_message,$filter_confirm_msg); } if (isset ($warning_message)) { - Display :: display_warning_message($warning_message,$filter_warning_msg); + Display :: display_warning_message($warning_message,$filter_warning_msg); } if (isset ($move_form)) { - Display :: display_normal_message($move_form->toHtml(),false); + Display :: display_normal_message($move_form->toHtml(),false); } // LOAD DATA & DISPLAY TABLE - $is_platform_admin= api_is_platform_admin(); $is_course_admin= api_is_allowed_to_edit(); //load data for category, evaluation and links if (!isset ($_GET['selectcat']) || empty ($_GET['selectcat'])) { - $category= 0; - } else { - $category= Security::remove_XSS($_GET['selectcat']); - } + $category= 0; +} else { + $category= Security::remove_XSS($_GET['selectcat']); +} // search form $simple_search_form= new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . $selectcat); $values= $simple_search_form->exportValues(); $keyword = ''; if (isset($_GET['search']) && !empty($_GET['search'])) { - $keyword = Security::remove_XSS($_GET['search']); + $keyword = Security::remove_XSS($_GET['search']); } if ($simple_search_form->validate() && (empty($keyword))) { - $keyword = $values['keyword']; + $keyword = $values['keyword']; } if (!empty($keyword)) { - - $cats= Category :: load($category); - $allcat= array (); - if ((isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search'])) { - $allcat= $cats[0]->get_subcategories(null); - $allcat_info = Category :: find_category($keyword,$allcat); - $alleval=array(); - $alllink=array(); - } else { - $alleval = Evaluation :: find_evaluations($keyword, $cats[0]->get_id()); - $alllink = LinkFactory :: find_links($keyword, $cats[0]->get_id()); - } + + $cats= Category :: load($category); + $allcat= array (); + if ((isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search'])) { + $allcat= $cats[0]->get_subcategories(null); + $allcat_info = Category :: find_category($keyword,$allcat); + $alleval=array(); + $alllink=array(); + } else { + $alleval = Evaluation :: find_evaluations($keyword, $cats[0]->get_id()); + $alllink = LinkFactory :: find_links($keyword, $cats[0]->get_id()); + } } elseif (isset ($_GET['studentoverview'])) { - //@todo this code seems to be deprecated because the gradebook tab is off - $cats= Category :: load($category); - $stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); - $allcat= array (); - $alleval= $cats[0]->get_evaluations($stud_id, true); - $alllink= $cats[0]->get_links($stud_id, true); - if (isset ($_GET['exportpdf'])) { - $datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink); - $header_names = array(get_lang('Name'),get_lang('Description'),get_lang('Weight'),get_lang('Date'),get_lang('Results')); - $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true); - $newarray = array(); - foreach ($data_array as $data) { - $newarray[] = array_slice($data, 1); - } - $pdf= new Cezpdf(); - $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); - $pdf->ezSetMargins(30, 30, 50, 30); - $pdf->ezSetY(810); - $pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT) . ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center')); - $pdf->line(50,790,550,790); - $pdf->line(50,40,550,40); - $pdf->ezSetY(750); - $pdf->ezTable($newarray,$header_names,'',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,'rowGap'=>3,'width'=> 500)); - $pdf->ezStream(); - exit; - } + //@todo this code seems to be deprecated because the gradebook tab is off + $cats= Category :: load($category); + $stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); + $allcat= array (); + $alleval= $cats[0]->get_evaluations($stud_id, true); + $alllink= $cats[0]->get_links($stud_id, true); + if (isset ($_GET['exportpdf'])) { + $datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink); + $header_names = array(get_lang('Name'),get_lang('Description'),get_lang('Weight'),get_lang('Date'),get_lang('Results')); + $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true); + $newarray = array(); + foreach ($data_array as $data) { + $newarray[] = array_slice($data, 1); + } + $pdf= new Cezpdf(); + $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); + $pdf->ezSetMargins(30, 30, 50, 30); + $pdf->ezSetY(810); + $pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT) . ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center')); + $pdf->line(50,790,550,790); + $pdf->line(50,40,550,40); + $pdf->ezSetY(750); + $pdf->ezTable($newarray,$header_names,'',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,'rowGap'=>3,'width'=> 500)); + $pdf->ezStream(); + exit; + } } elseif (!empty($_GET['export_certificate'])){ //@todo this code seems not to be used - $user_id = strval(intval($_GET['user'])); - if (!api_is_allowed_to_edit(true,true)) { - $user_id = api_get_user_id(); - } - $category = Category :: load ($_GET['cat_id']); - if ($category[0]->is_certificate_available($user_id)) { - $user= get_user_info_from_id($user_id); - $scoredisplay = ScoreDisplay :: instance(); - $scorecourse = $category[0]->calc_score($user_id); - $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable')); + $user_id = strval(intval($_GET['user'])); + if (!api_is_allowed_to_edit(true,true)) { + $user_id = api_get_user_id(); + } + $category = Category :: load ($_GET['cat_id']); + if ($category[0]->is_certificate_available($user_id)) { + $user= get_user_info_from_id($user_id); + $scoredisplay = ScoreDisplay :: instance(); + $scorecourse = $category[0]->calc_score($user_id); + $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable')); - $cattotal = Category :: load(0); - $scoretotal= $cattotal[0]->calc_score($user_id); - $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable')); + $cattotal = Category :: load(0); + $scoretotal= $cattotal[0]->calc_score($user_id); + $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable')); - //prepare all necessary variables: - $organization_name = api_get_setting('Institution'); - $portal_name = api_get_setting('siteName'); - $stud_fn = $user['firstname']; - $stud_ln = $user['lastname']; - $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'),$organization_name,$stud_fn.' '.$stud_ln,$category[0]->get_name(),$scorecourse_display); - $certif_text = str_replace("\\n","\n",$certif_text); - $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT); + //prepare all necessary variables: + $organization_name = api_get_setting('Institution'); + $portal_name = api_get_setting('siteName'); + $stud_fn = $user['firstname']; + $stud_ln = $user['lastname']; + $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'),$organization_name,$stud_fn.' '.$stud_ln,$category[0]->get_name(),$scorecourse_display); + $certif_text = str_replace("\\n","\n",$certif_text); + $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT); - $pdf= new Cezpdf('a4','landscape'); - $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); - $pdf->ezSetMargins(30, 30, 50, 50); - //line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom) - $pdf->line(50,50,790,50); - $pdf->line(50,550,790,550); - $pdf->ezSetY(450); + $pdf= new Cezpdf('a4','landscape'); + $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); + $pdf->ezSetMargins(30, 30, 50, 50); + //line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom) + $pdf->line(50,50,790,50); + $pdf->line(50,550,790,550); + $pdf->ezSetY(450); //@todo replace image - //$pdf->ezImage(api_get_path(SYS_CODE_PATH).'img/dokeos_logo_certif.png',1,400,'','center',''); - $pdf->ezSetY(480); - $pdf->ezText($certif_text,28,array('justification'=>'center')); - //$pdf->ezSetY(750); - $pdf->ezSetY(50); - $pdf->ezText($date,18,array('justification'=>'center')); - $pdf->ezSetY(580); - $pdf->ezText($organization_name,22,array('justification'=>'left')); - $pdf->ezSetY(580); - $pdf->ezText($portal_name,22,array('justification'=>'right')); - $pdf->ezStream(); - } - exit; + //$pdf->ezImage(api_get_path(SYS_CODE_PATH).'img/dokeos_logo_certif.png',1,400,'','center',''); + $pdf->ezSetY(480); + $pdf->ezText($certif_text,28,array('justification'=>'center')); + //$pdf->ezSetY(750); + $pdf->ezSetY(50); + $pdf->ezText($date,18,array('justification'=>'center')); + $pdf->ezSetY(580); + $pdf->ezText($organization_name,22,array('justification'=>'left')); + $pdf->ezSetY(580); + $pdf->ezText($portal_name,22,array('justification'=>'right')); + $pdf->ezStream(); + } + exit; } else { - $cats= Category :: load($category); - $stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); - $allcat= $cats[0]->get_subcategories($stud_id); - $alleval= $cats[0]->get_evaluations($stud_id); - $alllink= $cats[0]->get_links($stud_id); + $cats= Category :: load($category); + $stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); + $allcat= $cats[0]->get_subcategories($stud_id); + $alleval= $cats[0]->get_evaluations($stud_id); + $alllink= $cats[0]->get_links($stud_id); } $addparams = array ('selectcat' => $cats[0]->get_id()); if (isset($_GET['search'])) { - $addparams['search'] = $keyword; + $addparams['search'] = $keyword; } if (isset ($_GET['studentoverview'])) { - $addparams['studentoverview'] = ''; + $addparams['studentoverview'] = ''; } if (count($allcat_info)>=0 && (isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search']) && strlen(trim($_GET['search']))>0 ) { - $allcat=$allcat_info; + $allcat=$allcat_info; } else { - $allcat=$allcat; + $allcat=$allcat; } $gradebooktable= new GradebookTable($cats[0], $allcat, $alleval, $alllink, $addparams); if (((empty ($allcat)) && (empty ($alleval)) && (empty ($alllink)) && (!$is_platform_admin) && ($is_course_admin) && (!isset ($_GET['selectcat']))) && api_is_course_tutor()) { - Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '

',false); + Display :: display_normal_message(get_lang('GradebookWelcomeMessage') . '

',false); } //here we are in a sub category if ($category != '0') { - DisplayGradebook :: display_header_gradebook($cats[0], 1, $_GET['selectcat'], $is_course_admin, $is_platform_admin, $simple_search_form); + DisplayGradebook :: display_header_gradebook($cats[0], 1, $_GET['selectcat'], $is_course_admin, $is_platform_admin, $simple_search_form); } else { - //this is the root category - DisplayGradebook :: display_header_gradebook($cats[0], (((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1), 0, $is_course_admin, $is_platform_admin, $simple_search_form); + //this is the root category + DisplayGradebook :: display_header_gradebook($cats[0], (((count($allcat) == '0') && (!isset ($_GET['search']))) ? 0 : 1), 0, $is_course_admin, $is_platform_admin, $simple_search_form); } $gradebooktable->display(); Display :: display_footer(); diff --git a/main/gradebook/gradebook_add_cat.php b/main/gradebook/gradebook_add_cat.php index ccd3615b23..427581c036 100755 --- a/main/gradebook/gradebook_add_cat.php +++ b/main/gradebook/gradebook_add_cat.php @@ -1,18 +1,17 @@ set_parent_id($get_select_cat); $catcourse = Category :: load ($get_select_cat); if ($_in_course) { - $catadd->set_course_code($course_code); + $catadd->set_course_code($course_code); } else { - $catadd->set_course_code($catcourse[0]->get_course_code()); + $catadd->set_course_code($catcourse[0]->get_course_code()); } $catadd->set_course_code(api_get_course_id()); @@ -109,44 +108,44 @@ $form = new CatForm( ); if ($form->validate()) { - $values = $form->exportValues(); - $select_course=isset($values['select_course']) ? $values['select_course'] : array(); - $cat = new Category(); - if ($values['hid_parent_id'] == '0') { - if ($select_course == 'COURSEINDEPENDENT') { - $cat->set_name($values['name']); - $cat->set_course_code(null); - } else { - $cat->set_course_code($select_course); - $cat->set_name($values['name']); - } - } else { - $cat->set_name($values['name']); - $cat->set_course_code($values['course_code']); - } + $values = $form->exportValues(); + $select_course=isset($values['select_course']) ? $values['select_course'] : array(); + $cat = new Category(); + if ($values['hid_parent_id'] == '0') { + if ($select_course == 'COURSEINDEPENDENT') { + $cat->set_name($values['name']); + $cat->set_course_code(null); + } else { + $cat->set_course_code($select_course); + $cat->set_name($values['name']); + } + } else { + $cat->set_name($values['name']); + $cat->set_course_code($values['course_code']); + } $cat->set_session_id(api_get_session_id()); - //Always add the gradebook to the course - $cat->set_course_code(api_get_course_id()); + //Always add the gradebook to the course + $cat->set_course_code(api_get_course_id()); $cat->set_skills($values['skills']); - $cat->set_description($values['description']); - $cat->set_user_id($values['hid_user_id']); - $cat->set_parent_id($values['hid_parent_id']); - $cat->set_weight($values['weight']); - - if (empty ($values['visible'])) { - $visible = 0; - } else { - $visible = 1; - } - $cat->set_visible($visible); - $result = $cat->add(); - header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?addcat=&selectcat=' . $cat->get_parent_id()); - exit; + $cat->set_description($values['description']); + $cat->set_user_id($values['hid_user_id']); + $cat->set_parent_id($values['hid_parent_id']); + $cat->set_weight($values['weight']); + + if (empty ($values['visible'])) { + $visible = 0; + } else { + $visible = 1; + } + $cat->set_visible($visible); + $result = $cat->add(); + header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?addcat=&selectcat=' . $cat->get_parent_id()); + exit; } if ( !$_in_course ) { - $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$get_select_cat,'name' => get_lang('Gradebook')); + $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$get_select_cat,'name' => get_lang('Gradebook')); } $interbreadcrumb[]= array ( 'url' =>'index.php','name' => get_lang('ToolGradebook')); Display :: display_header(get_lang('NewCategory')); diff --git a/main/gradebook/gradebook_add_eval.php b/main/gradebook/gradebook_add_eval.php index 7de17f09fd..e61bd06166 100755 --- a/main/gradebook/gradebook_add_eval.php +++ b/main/gradebook/gradebook_add_eval.php @@ -5,9 +5,7 @@ * Script * @package chamilo.gradebook */ -/** - * Init - */ + $language_file = 'gradebook'; require_once '../inc/global.inc.php'; require_once 'lib/be.inc.php'; @@ -50,7 +48,7 @@ if ($form->validate()) { $parent_cat = Category :: load($values['hid_category_id']); $global_weight = $cat[0]->get_weight(); - //$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight(); + //$values['weight'] = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight(); $values['weight'] = $values['weight_mask']; @@ -88,25 +86,25 @@ if ($form->validate()) { $interbreadcrumb[] = array( 'url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?selectcat=' . $select_cat, 'name' => get_lang('Gradebook' - )); + )); $this_section = SECTION_COURSES; $htmlHeadXtra[] = '"; api_block_anonymous_users(); if (!api_is_allowed_to_edit()) { - api_not_allowed(true); + api_not_allowed(true); } $cat_id = isset($_GET['cat_id']) ? (int)$_GET['cat_id'] : null; @@ -182,25 +179,25 @@ if (count($certificate_list)==0) { foreach ($certificate_list as $index=>$value) { echo ' '.get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].')'; - echo ''; + echo ''; echo ' '; - $list_certificate = get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id); - foreach ($list_certificate as $value_certificate) { - echo ''; - echo ''; - echo ''; - echo ''; + echo ''; + echo ''; + echo ''; - } - echo '
'.get_lang('Score').' : '.$value_certificate['score_certificate'].''.get_lang('Date').' : '.api_convert_and_format_date($value_certificate['created_at']).''; + $list_certificate = get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id); + foreach ($list_certificate as $value_certificate) { + echo '
'.get_lang('Score').' : '.$value_certificate['score_certificate'].''.get_lang('Date').' : '.api_convert_and_format_date($value_certificate['created_at']).''; $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$value_certificate['id']; $certificates = Display::url(get_lang('Certificate'), $url, array('target'=>'_blank', 'class' => 'btn')); echo $certificates; - echo ' + echo ' '.Display::return_icon('delete.png',get_lang('Delete')).' '; - echo '
'; + echo ''; + } + echo ''; echo ''; } echo ''; diff --git a/main/gradebook/gradebook_edit_all.php b/main/gradebook/gradebook_edit_all.php index 0be185a810..29e3d8899b 100755 --- a/main/gradebook/gradebook_edit_all.php +++ b/main/gradebook/gradebook_edit_all.php @@ -1,13 +1,11 @@ Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook')); - Display :: display_header(get_lang('FlatView')); - } elseif (isset ($_GET['search'])) { - $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook')); - Display :: display_header(get_lang('SearchResults')); - } else { - $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=1', 'name' => get_lang('Gradebook')); - $interbreadcrumb[] = array ('url' => '#','name' => get_lang('EditAllWeights')); - Display :: display_header(''); - } + if (isset ($_GET['studentoverview'])) { + $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook')); + Display :: display_header(get_lang('FlatView')); + } elseif (isset ($_GET['search'])) { + $interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook')); + Display :: display_header(get_lang('SearchResults')); + } else { + $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=1', 'name' => get_lang('Gradebook')); + $interbreadcrumb[] = array ('url' => '#','name' => get_lang('EditAllWeights')); + Display :: display_header(''); + } } $course_id = get_course_id_by_link_id($my_selectcat); @@ -74,15 +72,15 @@ $table_evaluated[LINK_SURVEY] = array(TABLE_SURVEY, 'code', 'survey_ $submitted = isset($_POST['submitted'])?$_POST['submitted']:''; if ($submitted==1) { - Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '

'; - if (isset($_POST['evaluation'])) { - require_once 'lib/be/evaluation.class.php'; - $eval_log = new Evaluation(); - } - if(isset($_POST['link'])){ - require_once 'lib/be/abstractlink.class.php'; - //$eval_link_log = new AbstractLink(); - } + Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '

'; + if (isset($_POST['evaluation'])) { + require_once 'lib/be/evaluation.class.php'; + $eval_log = new Evaluation(); + } + if(isset($_POST['link'])){ + require_once 'lib/be/abstractlink.class.php'; + //$eval_link_log = new AbstractLink(); + } } $output=''; @@ -168,30 +166,30 @@ while ($row = Database ::fetch_array($sql)) { //by iflorespaz $my_api_cidreq = api_get_cidreq(); if ($my_api_cidreq=='') { - $my_api_cidreq='cidReq='.$my_category['course_code']; + $my_api_cidreq='cidReq='.$my_category['course_code']; } ?> -
- - - -
+
+ + + +
-
- - - - - - - -
- -
- -
+
+ + + + + + + +
+ +
+ +
'; - $catedit = Category::load($edit_cat); - $form = new CatForm(CatForm::TYPE_EDIT, $catedit[0], 'edit_cat_form'); if ($form->validate()) { - $values = $form->getSubmitValues(); + $values = $form->getSubmitValues(); $cat = new Category(); @@ -97,36 +94,36 @@ if ($form->validate()) { } } - $cat->set_id($values['hid_id']); - $cat->set_name($values['name']); + $cat->set_id($values['hid_id']); + $cat->set_name($values['name']); - if (empty ($values['course_code'])) { - $cat->set_course_code(null); - }else { - $cat->set_course_code($values['course_code']); - } + if (empty ($values['course_code'])) { + $cat->set_course_code(null); + }else { + $cat->set_course_code($values['course_code']); + } $cat->set_grade_model_id($values['grade_model_id']); - $cat->set_description($values['description']); - $cat->set_skills($values['skills']); - $cat->set_user_id($values['hid_user_id']); - $cat->set_parent_id($values['hid_parent_id']); - $cat->set_weight($values['weight']); - - if ($values['hid_parent_id'] == 0 ) { - $cat->set_certificate_min_score($values['certif_min_score']); - } + $cat->set_description($values['description']); + $cat->set_skills($values['skills']); + $cat->set_user_id($values['hid_user_id']); + $cat->set_parent_id($values['hid_parent_id']); + $cat->set_weight($values['weight']); + + if ($values['hid_parent_id'] == 0 ) { + $cat->set_certificate_min_score($values['certif_min_score']); + } if (empty ($values['visible'])) { - $visible = 0; - } else { - $visible = 1; - } + $visible = 0; + } else { + $visible = 1; + } $cat->set_visible($visible); - $cat->save(); - header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id()); - exit; + $cat->save(); + header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id()); + exit; } $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : ''; $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$selectcat,'name' => get_lang('Gradebook')); diff --git a/main/gradebook/gradebook_edit_eval.php b/main/gradebook/gradebook_edit_eval.php index 62e466938a..f269baf91f 100755 --- a/main/gradebook/gradebook_edit_eval.php +++ b/main/gradebook/gradebook_edit_eval.php @@ -1,12 +1,11 @@ -is_locked() && !api_is_platform_admin()) { api_not_allowed(); } -$form = new EvalForm(EvalForm :: TYPE_EDIT, $evaledit[0], null, 'edit_eval_form',null,api_get_self() . '?editeval=' . Security::remove_XSS($_GET['editeval'])); +$form = new EvalForm( + EvalForm :: TYPE_EDIT, + $evaledit[0], + null, + 'edit_eval_form', + null, + api_get_self() . '?editeval=' . Security::remove_XSS($_GET['editeval']) +); if ($form->validate()) { - $values = $form->exportValues(); - $eval = new Evaluation(); - $eval->set_id($values['hid_id']); - $eval->set_name($values['name']); - $eval->set_description($values['description']); - $eval->set_user_id($values['hid_user_id']); - $eval->set_course_code($values['hid_course_code']); - $eval->set_category_id($values['hid_category_id']); - - $parent_cat = Category :: load($values['hid_category_id']); - + $values = $form->exportValues(); + $eval = new Evaluation(); + $eval->set_id($values['hid_id']); + $eval->set_name($values['name']); + $eval->set_description($values['description']); + $eval->set_user_id($values['hid_user_id']); + $eval->set_course_code($values['hid_course_code']); + $eval->set_category_id($values['hid_category_id']); + + $parent_cat = Category :: load($values['hid_category_id']); + /*$final_weight = null; if ($parent_cat[0]->get_parent_id() == 0) { - $final_weight = $values['weight_mask']; + $final_weight = $values['weight_mask']; } else { $cat = Category :: load($parent_cat[0]->get_parent_id()); $global_weight = $cat[0]->get_weight(); - $final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight(); - }*/ + $final_weight = $values['weight_mask']/$global_weight*$parent_cat[0]->get_weight(); + }*/ $final_weight = $values['weight_mask']; - + $eval->set_weight($final_weight); - - $eval->set_max($values['max']); - if (empty ($values['visible'])) { - $visible = 0; - } else { - $visible = 1; - } - $eval->set_visible($visible); - $eval->save(); - header('Location: '.$_SESSION['gradebook_dest'].'?editeval=&selectcat=' . $eval->get_category_id()); - exit; + + $eval->set_max($values['max']); + if (empty ($values['visible'])) { + $visible = 0; + } else { + $visible = 1; + } + $eval->set_visible($visible); + $eval->save(); + header('Location: '.$_SESSION['gradebook_dest'].'?editeval=&selectcat=' . $eval->get_category_id()); + exit; } $selectcat_inter=isset($_GET['selectcat'])?Security::remove_XSS($_GET['selectcat']):''; $interbreadcrumb[] = array ( - 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat_inter, - 'name' => get_lang('Gradebook' -)); + 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat_inter, + 'name' => get_lang('Gradebook' + )); $htmlHeadXtra[] = '