diff --git a/custompages/index-unlogged.php b/custompages/index-unlogged.php index b3a3c00073..5a0875be3a 100755 --- a/custompages/index-unlogged.php +++ b/custompages/index-unlogged.php @@ -1,4 +1,4 @@ - - '; // Set bredcrumb -switch ($current_page) -{ +switch ($current_page) { case 'new_post' : $nameTools = get_lang('NewPost'); $interbreadcrumb[] = array ('url' => "blog.php?blog_id=$blog_id", "name" => Blog :: get_blog_title($blog_id)); @@ -240,14 +236,11 @@ switch ($current_page) } // feedback messages -if (!empty($return_message)) -{ - if ($return_message['type'] == 'confirmation') - { +if (!empty($return_message)) { + if ($return_message['type'] == 'confirmation') { Display::display_confirmation_message($return_message['message']); } - if ($return_message['type'] == 'error') - { + if ($return_message['type'] == 'error') { Display::display_error_message($return_message['message']); } } @@ -276,12 +269,12 @@ Display::display_introduction_section(TOOL_BLOG);
-
@@ -312,11 +305,11 @@ Blog :: display_minimonthcalendar($month, $year, $blog_id); ".""."\n". diff --git a/main/course_info/delete_course.php b/main/course_info/delete_course.php index 9a89fa7857..35d5c758a7 100755 --- a/main/course_info/delete_course.php +++ b/main/course_info/delete_course.php @@ -23,7 +23,6 @@ $current_course_tool = TOOL_COURSE_MAINTENANCE; api_protect_course_script(true); $_course = api_get_course_info(); - $current_course_code = $_course['official_code']; $current_course_name = $_course['name']; diff --git a/main/course_info/download.php b/main/course_info/download.php index ce66e2c063..c444e16240 100755 --- a/main/course_info/download.php +++ b/main/course_info/download.php @@ -48,11 +48,11 @@ if (Security::check_abs_path($archive_path.$archive_file, $archive_path)) { header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Cache-Control: public'); header('Pragma: no-cache'); - header('Content-Type: '.$content_type); header('Content-Length: '.filesize($archive_path.$archive_file)); header('Content-Disposition: attachment; filename='.$archive_file); readfile($archive_path.$archive_file); + exit; } else { api_not_allowed(true); } diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php index edbdd94e8b..56aa305c91 100755 --- a/main/course_info/infocours.php +++ b/main/course_info/infocours.php @@ -92,7 +92,7 @@ while ($a_titulars = Database::fetch_array($q_result_titulars)) { $s_selected_tutor = api_get_person_name($s_firstname, $s_lastname); } $s_disabled_select_titular = ''; - if (!$is_courseAdmin) { + if (!api_is_course_admin()) { $s_disabled_select_titular = 'disabled=disabled'; } $a_profs[api_get_person_name($s_firstname, $s_lastname)] = api_get_person_name($s_lastname, $s_firstname).' ('.$s_username.')'; @@ -103,7 +103,7 @@ $categories = getCategoriesCanBeAddedInCourse($_course['categoryCode']); $linebreak = '
'; // Build the form -$form = new FormValidator('update_course'); +$form = new FormValidator('update_course', 'post', api_get_self().'?'.api_get_cidreq()); // COURSE SETTINGS $form->addElement('html', '

'.Display::return_icon('settings.png', Security::remove_XSS(get_lang('CourseSettings')),'',ICON_SIZE_SMALL).' '.Security::remove_XSS(get_lang('CourseSettings')).'

'); @@ -305,13 +305,6 @@ if (api_get_setting('allow_course_theme') == 'true') { $group[]=$form->createElement('radio', 'allow_learning_path_theme', null, get_lang('AllowLearningPathThemeDisallow'), 0); $form->addGroup($group, '', array(get_lang("AllowLearningPathTheme")), ''); } -/* -$group = array( - $form->createElement('radio', 'lp_return_link', get_lang('LpReturnLink'), get_lang('RedirectToTheLearningPathList'), 1), - $form->createElement('radio', 'lp_return_link', null, get_lang('RedirectToCourseHome'), 0) -); -$form->addGroup($group, '', array(get_lang("LpReturnLink")), ''); -*/ if (is_settings_editable()) { $form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"'); @@ -374,9 +367,7 @@ $all_course_information = CourseManager::get_course_information($_course['sysCod $values = array(); $values['title'] = $_course['name']; -//$values['visual_code'] = $_course['official_code']; $values['category_code'] = $_course['categoryCode']; -//$values['tutor_name'] = $_course['titular']; $values['course_language'] = $_course['language']; $values['department_name'] = $_course['extLink']['name']; $values['department_url'] = $_course['extLink']['url']; diff --git a/main/course_progress/index.php b/main/course_progress/index.php index 0f687bec8e..a6accbdb46 100755 --- a/main/course_progress/index.php +++ b/main/course_progress/index.php @@ -322,7 +322,7 @@ switch ($action) { } case 'thematic_plan_list': $thematic_controller->thematic_plan($action); - break; + break; case 'thematic_advance_add': case 'thematic_advance_edit': case 'thematic_advance_delete': @@ -331,5 +331,5 @@ switch ($action) { } case 'thematic_advance_list': $thematic_controller->thematic_advance($action); - break; + break; } diff --git a/main/course_progress/thematic.php b/main/course_progress/thematic.php index 102965763b..b826212c96 100755 --- a/main/course_progress/thematic.php +++ b/main/course_progress/thematic.php @@ -53,8 +53,8 @@ if ($action == 'thematic_list') { $table->display(); } elseif ($action == 'thematic_details') { - - if ($last_id) { + + if (isset($last_id) && $last_id) { $link_to_thematic_plan = ''.Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).''; $link_to_thematic_advance = ''.Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).''; Display::display_confirmation_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull').'
'.sprintf(get_lang('NowYouShouldAddThematicPlanXAndThematicAdvanceX'),$link_to_thematic_plan, $link_to_thematic_advance), false); diff --git a/main/course_progress/thematic_controller.php b/main/course_progress/thematic_controller.php index ebad1e156c..cca782f116 100755 --- a/main/course_progress/thematic_controller.php +++ b/main/course_progress/thematic_controller.php @@ -17,12 +17,14 @@ * the requested action * @package chamilo.course_progress */ -class ThematicController { +class ThematicController +{ /** * Constructor */ - public function __construct() { + public function __construct() + { $this->toolname = 'course_progress'; $this->view = new View($this->toolname); } @@ -30,9 +32,10 @@ class ThematicController { /** * This method is used for thematic control (update, insert or listing) * @param string Action - * render to thematic.php + * render to thematic.php */ - public function thematic($action) { + public function thematic($action) + { $thematic = new Thematic(); $data = array(); $error = false; @@ -180,7 +183,7 @@ class ThematicController { $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); $advance_html = null; if (!empty($data)) { - foreach ($data as $advance) { + foreach ($data as $advance) { $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_LONG) . ' ('.$advance['duration'].' '.get_lang('HourShort').')
'.$advance['content'].'
'; } } @@ -192,7 +195,7 @@ class ThematicController { 'add_signatures' => true, 'format' => 'A4-L', 'orientation' => 'L' - ); + ); Export::export_table_pdf($table, $params); break; case 'moveup': @@ -237,10 +240,7 @@ class ThematicController { $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true); $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data); - $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data); - - $data['thematic_plan_data'] = $thematic_plan_data; $data['thematic_advance_data'] = $thematic_advance_data; $data['thematic_data'] = $thematic_data; @@ -261,9 +261,10 @@ class ThematicController { /** * This method is used for thematic plan control (update, insert or listing) * @param string Action - * render to thematic_plan.php + * render to thematic_plan.php */ - public function thematic_plan($action) { + public function thematic_plan($action) + { $thematic = new Thematic(); $data = array(); @@ -310,11 +311,12 @@ class ThematicController { } } + $thematic_id = intval($_GET['thematic_id']); if ($action == 'thematic_plan_list') { $data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id); } - $thematic_id = intval($_GET['thematic_id']); + $description_type = intval($_GET['description_type']); if (!empty($thematic_id) && !empty($description_type)) { @@ -353,10 +355,10 @@ class ThematicController { /** * This method is used for thematic advance control (update, insert or listing) * @param string Action - * render to thematic_advance.php + * render to thematic_advance.php */ - public function thematic_advance($action) { - + public function thematic_advance($action) + { $thematic = new Thematic(); $attendance = new Attendance(); $data = array(); diff --git a/main/coursecopy/classes/Announcement.class.php b/main/coursecopy/classes/Announcement.class.php index f4c5dbc3ef..cb51922c9a 100755 --- a/main/coursecopy/classes/Announcement.class.php +++ b/main/coursecopy/classes/Announcement.class.php @@ -47,8 +47,8 @@ class Announcement extends Resource * @param string $date * @param int display_order */ - function Announcement($id, $title, $content, $date, $display_order, $email_sent, $path, $filename, $size, $comment) -{ + function Announcement($id, $title, $content, $date, $display_order, $email_sent, $path, $filename, $size, $comment) + { parent::Resource($id,RESOURCE_ANNOUNCEMENT); $this->content = $content; diff --git a/main/coursecopy/classes/CourseBuilder.class.php b/main/coursecopy/classes/CourseBuilder.class.php index a23e2039fc..38110612a3 100755 --- a/main/coursecopy/classes/CourseBuilder.class.php +++ b/main/coursecopy/classes/CourseBuilder.class.php @@ -82,7 +82,7 @@ class CourseBuilder $this->course->path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/'; $this->course->backup_path = api_get_path(SYS_COURSE_PATH).$_course['path']; $this->course->encoding = api_get_system_encoding(); //current platform encoding - // db_name is deprecated (only one database now) + $this->course->db_name = $_course['dbName']; $this->course->info = $_course; } @@ -783,7 +783,8 @@ class CourseBuilder /** * Build the announcements */ - public function build_announcements($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) { + public function build_announcements($session_id = 0, $course_code = '', $with_base_content = false, $id_list = array()) + { $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); $course_id = api_get_course_int_id(); @@ -1128,8 +1129,7 @@ class CourseBuilder //$thematic_plan_complete_list[$item['ref']] = $item; } } - //$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id']; - if (count($thematic_plan_id_list) > 0) { + if (count($thematic_plan_id_list) > 0) { $sql = "SELECT tp.* FROM $table_thematic_plan tp INNER JOIN $table_thematic t ON (t.id=tp.thematic_id) diff --git a/main/coursecopy/classes/CourseRestorer.class.php b/main/coursecopy/classes/CourseRestorer.class.php index 2f5518cbac..37e03edea8 100755 --- a/main/coursecopy/classes/CourseRestorer.class.php +++ b/main/coursecopy/classes/CourseRestorer.class.php @@ -279,6 +279,7 @@ class CourseRestorer $course_info = api_get_course_info($destination_course_code); if ($this->course->has_resources(RESOURCE_DOCUMENT)) { + $table = Database :: get_course_table(TABLE_DOCUMENT); $resources = $this->course->resources; $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; @@ -549,7 +550,9 @@ class CourseRestorer $x = $x + 1; $new_base_foldername = $document_path[1].'_'.$x; $new_base_path = $orig_base_path.'_'.$x; - if ($_SESSION['new_base_foldername'] == $new_base_foldername) break; + if ($_SESSION['new_base_foldername'] == $new_base_foldername) { + break; + } $folder_exists = file_exists($new_base_path); } $_SESSION['new_base_foldername'] = $new_base_foldername; @@ -586,7 +589,9 @@ class CourseRestorer $file_info = pathinfo($dest_document_path); if (in_array($file_info['extension'], array('html','htm'))) { $content = file_get_contents($dest_document_path); - if (UTF8_CONVERT) $content = utf8_encode($content); + if (UTF8_CONVERT) { + $content = utf8_encode($content); + } $content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content, $this->course->code, @@ -594,7 +599,7 @@ class CourseRestorer $this->course->backup_path, $this->course->info['path'] ); - file_put_contents($dest_document_path,$content); + file_put_contents($dest_document_path, $content); } } @@ -634,7 +639,9 @@ class CourseRestorer $file_info = pathinfo($path.$new_file_name); if (in_array($file_info['extension'], array('html','htm'))) { $content = file_get_contents($path.$new_file_name); - if (UTF8_CONVERT) $content = utf8_encode($content); + if (UTF8_CONVERT) { + $content = utf8_encode($content); + } $content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content, $this->course->code, @@ -680,7 +687,9 @@ class CourseRestorer $file_info = pathinfo($path.$new_file_name); if (in_array($file_info['extension'], array('html','htm'))) { $content = file_get_contents($path.$new_file_name); - if (UTF8_CONVERT) $content = utf8_encode($content); + if (UTF8_CONVERT) { + $content = utf8_encode($content); + } $content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content, $this->course->code, @@ -735,7 +744,9 @@ class CourseRestorer $file_info = pathinfo($path.$document->path); if (in_array($file_info['extension'], array('html','htm'))) { $content = file_get_contents($path.$document->path); - if (UTF8_CONVERT) $content = utf8_encode($content); + if (UTF8_CONVERT) { + $content = utf8_encode($content); + } $content = DocumentManager::replace_urls_inside_content_html_from_copy_course( $content, $this->course->code, @@ -874,7 +885,13 @@ class CourseRestorer $params['forum_category'] = $cat_id; unset($params['forum_id']); - $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($params['forum_comment'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']); + $params['forum_comment'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( + $params['forum_comment'], + $this->course->code, + $this->course->destination_path, + $this->course->backup_path, + $this->course->info['path'] + ); if (!empty($params['forum_image'])) { $original_forum_image = $this->course->path.'upload/forum/images/'.$params['forum_image']; @@ -1301,7 +1318,7 @@ class CourseRestorer 'c_id' => $this->destination_course_id, 'title' => self::DBUTF8($quiz->title), 'description' => self::DBUTF8($quiz->description), - 'type' => $quiz->quiz_type, + 'type' => isset($quiz->quiz_type) ? $quiz->quiz_type : $quiz->type, 'random' => $quiz->random, 'active' => $quiz->active, 'sound' => self::DBUTF8($doc), @@ -2320,8 +2337,14 @@ class CourseRestorer $condition_session "; Database::query($sql); - $my_id = Database::get_last_insert_id(); - api_item_property_update($this->destination_course_info, TOOL_GLOSSARY, $my_id,"GlossaryAdded", api_get_user_id()); + $my_id = Database::insert_id(); + api_item_property_update( + $this->destination_course_info, + TOOL_GLOSSARY, + $my_id, + "GlossaryAdded", + api_get_user_id() + ); $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = Database::insert_id(); } diff --git a/main/coursecopy/classes/CourseSelectForm.class.php b/main/coursecopy/classes/CourseSelectForm.class.php index 97b9f07384..bd5e4e45e5 100755 --- a/main/coursecopy/classes/CourseSelectForm.class.php +++ b/main/coursecopy/classes/CourseSelectForm.class.php @@ -556,7 +556,7 @@ class CourseSelectForm * @param array $hidden_fiels Hidden fields to add to the form. * @param boolean the document array will be serialize. This is used in the course_copy.php file */ - function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize=false) + function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) { ?> '; - - // Lib for event log, stats & tracking & record of the access event_access_tool(TOOL_DOCUMENT); @@ -849,6 +847,7 @@ if ($is_allowed_to_edit || false, $session_id ); + $move_path = $document_to_move['path']; if (!empty($document_to_move)) { $folders = DocumentManager::get_all_document_folders( @@ -857,7 +856,7 @@ if ($is_allowed_to_edit || $is_allowed_to_edit || $group_member_with_upload_rights ); - //filter if is my shared folder. TODO: move this code to build_move_to_selector function + // filter if is my shared folder. TODO: move this code to build_move_to_selector function if (is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id) && !$is_allowed_to_edit) { //only main user shared folder $main_user_shared_folder_main = '/shared_folder/sf_user_'.api_get_user_id(); @@ -869,6 +868,7 @@ if ($is_allowed_to_edit || $user_shared_folders[] = $fold; } } + $moveForm .= ''.get_lang('Move').''; $moveForm .= build_move_to_selector( $user_shared_folders, @@ -1534,6 +1534,7 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) { } else { $document_name = basename($document_data['path']); } + $row['name'] = $document_name; // Data for checkbox if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) { @@ -1577,6 +1578,7 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) { // Comments => display comment under the document name $display_size = format_file_size($size); + $row[] = ''.$size.''. $invisibility_span_open. $display_size. @@ -1587,9 +1589,10 @@ if (isset($documentAndFolders) && is_array($documentAndFolders)) { $last_edit_date = api_get_local_time($document_data['lastedit_date']); $display_date = date_to_str_ago($last_edit_date). '
'.$last_edit_date."
"; + $row[] = $invisibility_span_open.$display_date.$invisibility_span_close; - // Admins get an edit column + // Admins get an edit column if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_folder(api_get_user_id(), $curdirpath, $session_id)) { $is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false; // If readonly, check if it the owner of the file or if the user is an admin diff --git a/main/document/upload.php b/main/document/upload.php index ef587ec1a7..5bac92f04e 100755 --- a/main/document/upload.php +++ b/main/document/upload.php @@ -107,7 +107,6 @@ $courseDir = $_course['path'].'/document'; $sys_course_path = api_get_path(SYS_COURSE_PATH); $base_work_dir = $sys_course_path.$courseDir; $sessionId = api_get_session_id(); - $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : null; $document_data = DocumentManager::get_document_data_by_id($_REQUEST['id'], api_get_course_id(), true, $sessionId); diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index 5ca5ef558f..20100fe36f 100755 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -80,7 +80,6 @@ function handle_multiple_actions() } // STEP 3C: moving - if (strstr($_POST['action'], 'move_')) { // check move_received_n or move_sent_n command if (strstr($_POST['action'], 'received')) { diff --git a/main/dropbox/dropbox_init.inc.php b/main/dropbox/dropbox_init.inc.php index e233631c2b..6ec456a4a4 100755 --- a/main/dropbox/dropbox_init.inc.php +++ b/main/dropbox/dropbox_init.inc.php @@ -128,6 +128,7 @@ require_once '../inc/global.inc.php'; $is_allowed_in_course = api_is_allowed_in_course(); $is_courseTutor = api_is_course_tutor(); $is_courseAdmin = api_is_course_admin(); + $current_course_tool = TOOL_DROPBOX; // the dropbox configuration parameters diff --git a/main/dropbox/index.php b/main/dropbox/index.php index 81351e1cc1..68aef7f876 100755 --- a/main/dropbox/index.php +++ b/main/dropbox/index.php @@ -567,7 +567,6 @@ if ($action != 'add') { if ($category['sent'] == '1') { $moveList[$category['cat_id']] = $category['cat_name']; - $dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear. $link_open = ''; $dropbox_category_data[] = $link_open.build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).''; diff --git a/main/exercice/admin.php b/main/exercice/admin.php index 6c0f6d7864..a0dbfbed06 100755 --- a/main/exercice/admin.php +++ b/main/exercice/admin.php @@ -44,9 +44,6 @@ * @author Olivier Brouckaert * Modified by Hubert Borderiou 21-10-2011 Question by category */ -/** - * Code - */ use \ChamiloSession as Session; @@ -91,7 +88,6 @@ if($_SERVER['REQUEST_METHOD'] == 'POST') { if (empty($exerciseId)) { $exerciseId = isset($_GET['exerciseId']) ? intval($_GET['exerciseId']):'0'; } - if (empty($newQuestion)) { $newQuestion = isset($_GET['newQuestion']) ? $_GET['newQuestion'] : 0; } @@ -121,7 +117,8 @@ $cancelAnswers = isset($cancelAnswers) ? $cancelAnswers : null; $modifyIn = isset($modifyIn) ? $modifyIn : null; $cancelQuestion = isset($cancelQuestion) ? $cancelQuestion : null; -// Cleaning all incomplete attempts of the admin/teacher to avoid weird problems when changing the exercise settings, number of questions, etc +/* Cleaning all incomplete attempts of the admin/teacher to avoid weird problems + when changing the exercise settings, number of questions, etc */ delete_all_incomplete_attempts(api_get_user_id(), $exerciseId, api_get_course_id(), api_get_session_id()); @@ -140,31 +137,39 @@ $picturePath = $documentPath.'/images'; $audioPath = $documentPath.'/audio'; // the 5 types of answers -$aType = array(get_lang('UniqueSelect'),get_lang('MultipleSelect'),get_lang('FillBlanks'),get_lang('Matching'),get_lang('FreeAnswer')); +$aType = array( + get_lang('UniqueSelect'), + get_lang('MultipleSelect'), + get_lang('FillBlanks'), + get_lang('Matching'), + get_lang('FreeAnswer') +); // tables used in the exercise tool if (!empty($_GET['action']) && $_GET['action'] == 'exportqti2' && !empty($_GET['questionId'])) { - require_once 'export/qti2/qti2_export.php'; - $export = export_question($_GET['questionId'],true); - $qid = (int)$_GET['questionId']; - $archive_path = api_get_path(SYS_ARCHIVE_PATH); - $temp_dir_short = uniqid(); - $temp_zip_dir = $archive_path."/".$temp_dir_short; - if(!is_dir($temp_zip_dir)) mkdir($temp_zip_dir, api_get_permissions_for_new_directories()); - $temp_zip_file = $temp_zip_dir."/".api_get_unique_id().".zip"; - $temp_xml_file = $temp_zip_dir."/qti2export_".$qid.'.xml'; - file_put_contents($temp_xml_file,$export); - $zip_folder=new PclZip($temp_zip_file); - $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH); - $name = 'qti2_export_'.$qid.'.zip'; - - DocumentManager::file_send_for_download($temp_zip_file,true,$name); - unlink($temp_zip_file); - unlink($temp_xml_file); - rmdir($temp_zip_dir); - //DocumentManager::string_send_for_download($export,true,'qti2export_q'.$_GET['questionId'].'.xml'); - exit; //otherwise following clicks may become buggy + require_once 'export/qti2/qti2_export.php'; + $export = export_question($_GET['questionId'], true); + $qid = (int)$_GET['questionId']; + $archive_path = api_get_path(SYS_ARCHIVE_PATH); + $temp_dir_short = uniqid(); + $temp_zip_dir = $archive_path."/".$temp_dir_short; + if (!is_dir($temp_zip_dir)) { + mkdir($temp_zip_dir, api_get_permissions_for_new_directories()); + } + $temp_zip_file = $temp_zip_dir."/".api_get_unique_id().".zip"; + $temp_xml_file = $temp_zip_dir."/qti2export_".$qid.'.xml'; + file_put_contents($temp_xml_file, $export); + $zip_folder = new PclZip($temp_zip_file); + $zip_folder->add($temp_xml_file, PCLZIP_OPT_REMOVE_ALL_PATH); + $name = 'qti2_export_'.$qid.'.zip'; + + DocumentManager::file_send_for_download($temp_zip_file, true, $name); + unlink($temp_zip_file); + unlink($temp_xml_file); + rmdir($temp_zip_dir); + //DocumentManager::string_send_for_download($export,true,'qti2export_q'.$_GET['questionId'].'.xml'); + exit; //otherwise following clicks may become buggy } // Exercise object creation. diff --git a/main/exercice/export/aiken/aiken_import.inc.php b/main/exercice/export/aiken/aiken_import.inc.php index 407d04b9fd..5d740b51cc 100755 --- a/main/exercice/export/aiken/aiken_import.inc.php +++ b/main/exercice/export/aiken/aiken_import.inc.php @@ -288,13 +288,10 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile) $answers_array = array(); $new_question = true; } else { - if (empty($exercise_info['question'][$question_index]['title'])) - { - if (strlen($info) < 40) - { + if (empty($exercise_info['question'][$question_index]['title'])) { + if (strlen($info) < 40) { $exercise_info['question'][$question_index]['title'] = $info; - } else - { + } else { //Question itself (use a 40-chars long title and a larger description) $exercise_info['question'][$question_index]['title'] = trim(substr($info,0,40)).'...'; $exercise_info['question'][$question_index]['description'] = $info; diff --git a/main/exercice/export/exercise_import.inc.php b/main/exercice/export/exercise_import.inc.php index 0c460b596e..5ee82c5f0b 100755 --- a/main/exercice/export/exercise_import.inc.php +++ b/main/exercice/export/exercise_import.inc.php @@ -9,11 +9,6 @@ * @author claro team * @author Guillaume Lederer */ -/** - * Security check - */ -if (count(get_included_files()) == 1) - die('---'); /** * function to create a temporary directory (SAME AS IN MODULE ADMIN) diff --git a/main/exercice/export/exercise_import.php b/main/exercice/export/exercise_import.php index c7eafab801..ca705c73ff 100755 --- a/main/exercice/export/exercise_import.php +++ b/main/exercice/export/exercise_import.php @@ -13,7 +13,9 @@ require '../../inc/global.inc.php'; //SECURITY CHECK -if ( api_is_platform_admin() ) api_not_allowed(); +if (api_is_platform_admin()) { + api_not_allowed(); +} //DECLARE NEEDED LIBRARIES @@ -27,8 +29,8 @@ include_once 'qti/qti_classes.php'; //SQL table name -$tbl_exercise = Database::get_course_table(TABLE_QUIZ_TEST); -$tbl_question = Database::get_course_table(TABLE_QUIZ_QUESTION); +$tbl_exercise = Database::get_course_table(TABLE_QUIZ_TEST); +$tbl_question = Database::get_course_table(TABLE_QUIZ_QUESTION); $tbl_rel_exercise_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION); // tool libraries @@ -41,7 +43,7 @@ $nameTools = get_lang('ImportExercise'); //bredcrump -$interbredcrump[]= array ('url' => '../exercice.php','name' => get_lang('Exercises')); +$interbredcrump[] = array('url' => '../exercice.php', 'name' => get_lang('Exercises')); //---------------------------------- // EXECUTE COMMAND @@ -49,8 +51,7 @@ $interbredcrump[]= array ('url' => '../exercice.php','name' => get_lang('Exercis $cmd = (isset($_REQUEST['cmd'])? $_REQUEST['cmd'] : 'show_import'); -switch ( $cmd ) -{ +switch ($cmd) { case 'show_import' : { $display = '

' @@ -68,23 +69,20 @@ switch ( $cmd ) } break; - case 'import' : - { + case 'import': { //include needed librabries for treatment $result_log = import_exercise($_FILES['uploadedExercise']['name']); //display the result message (fail or success) - $dialogBox = ''; - foreach ($result_log as $log) - { - $dialogBox .= $log . '
'; + foreach ($result_log as $log) { + $dialogBox .= $log.'
'; } } - break; + break; } //---------------------------------- @@ -114,11 +112,15 @@ Display::display_introduction_section(TOOL_QUIZ, array( //Display Forms or dialog box(if needed) -if ( isset($dialogBox) ) echo Display::display_normal_message($dialogBox,false); +if (isset($dialogBox)) { + echo Display::display_normal_message($dialogBox, false); +} //display content -if (isset($display) ) echo $display; +if (isset($display)) { + echo $display; +} //footer display diff --git a/main/exercice/export/qti2/qti2_export.php b/main/exercice/export/qti2/qti2_export.php index 576bdd7bc8..7dcd8d9d43 100755 --- a/main/exercice/export/qti2/qti2_export.php +++ b/main/exercice/export/qti2/qti2_export.php @@ -205,7 +205,6 @@ class ImsSection */ function export_ordering() { - $out = ''; if ($n = $this->exercise->getShuffle()) { $out.= "" diff --git a/main/exercice/export/scorm/scorm_export.php b/main/exercice/export/scorm/scorm_export.php index c4133753b9..90ee4e77c5 100755 --- a/main/exercice/export/scorm/scorm_export.php +++ b/main/exercice/export/scorm/scorm_export.php @@ -35,8 +35,7 @@ class ScormAssessmentItem { $this->question = $question; //$this->answer = new Answer($question->id); - $this->question->setAnswer(); - + $this->question->setAnswer(); $this->questionIdent = "QST_" . $question->id ; $this->standalone = $standalone; //echo "

".print_r($this,1)."
"; @@ -85,14 +84,12 @@ class ScormAssessmentItem if ($this->standalone) { $css = ''."\n"; $css .= ''."\n"; + $css .= ''."\n"; } return $css; } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 454aa55626..e8a64537d8 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -21,9 +21,6 @@ * @todo complete the missing phpdoc the correct order should be */ -/** - * code - */ use \ChamiloSession as Session; require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; @@ -376,6 +373,7 @@ function delete_forum_image($forum_id) $row = Database::fetch_array($result); if ($row['forum_image'] != '') { $del_file = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/forum/images/'.$row['forum_image']; + return @unlink($del_file); } else { return false; @@ -406,7 +404,13 @@ function show_edit_forumcategory_form($inputvalues = array()) $form->addElement('text', 'forum_category_title', get_lang('Title'), 'class="input_titles"'); //$form->applyFilter('forum_category_title', 'html_filter'); - $form->addElement('html_editor', 'forum_category_comment', get_lang('Comment'), null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200')); + $form->addElement( + 'html_editor', + 'forum_category_comment', + get_lang('Comment'), + null, + array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200') + ); //$form->applyFilter('forum_category_comment', 'html_filter'); $form->addElement('style_submit_button', 'SubmitEditForumCategory', get_lang('ModifyCategory'), 'class="save"'); @@ -594,7 +598,15 @@ function store_forum($values) WHERE c_id = $course_id AND forum_id='".Database::escape_string($values['forum_id'])."'"; Database::query($sql); - api_item_property_update($_course, TOOL_FORUM, Database::escape_string($values['forum_id']), 'ForumUpdated', api_get_user_id(), $group_id); + + api_item_property_update( + $_course, + TOOL_FORUM, + Database::escape_string($values['forum_id']), + 'ForumUpdated', + api_get_user_id(), + $group_id + ); $return_message = get_lang('ForumEdited'); } else { @@ -603,7 +615,7 @@ function store_forum($values) $new_file_name = isset($new_file_name) ? $new_file_name : ''; $sql_image = "'".$new_file_name."', "; } - $b = $values['forum_comment']; + $b = isset($values['forum_comment']) ? $values['forum_comment'] : null; $sql = "INSERT INTO ".$table_forums." (c_id, forum_title, forum_image, forum_comment, forum_category, allow_anonymous, allow_edit, approval_direct_post, allow_attachments, allow_new_threads, default_view, forum_of_group, forum_group_public_private, forum_order, session_id) VALUES ( @@ -630,6 +642,7 @@ function store_forum($values) } $return_message = get_lang('ForumAdded'); } + return $return_message; } @@ -781,6 +794,7 @@ function check_if_last_post_of_thread($thread_id) $result = Database::query($sql); if (Database::num_rows($result) > 0) { $row = Database::fetch_array($result); + return $row; } else { return false; @@ -839,6 +853,7 @@ function display_lock_unlock_icon($content, $id, $current_lock_status, $addition if ($content == 'thread') { if (api_resource_is_locked_by_gradebook($id, LINK_FORUM_THREAD)) { echo Display::return_icon('lock_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL); + return; } } @@ -868,7 +883,7 @@ function display_lock_unlock_icon($content, $id, $current_lock_status, $addition * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post * @param $id is the id of the item we want to display the icons for * @param $list is an array of all the items. All items in this list should have an up and down icon except for the first (no up icon) and the last (no down icon) - * The key of this $list array is the id of the item. + * The key of this $list array is the id of the item. * * @return void HTML * @@ -1089,6 +1104,7 @@ function move_up_down($content, $direction, $id) Database::query($sql_update1); Database::query($sql_update2); } + return get_lang(ucfirst($content).'Moved'); } @@ -1171,6 +1187,7 @@ function get_forum_categories($id = '') $forum_categories_list = $row; } } + return $forum_categories_list; } @@ -1215,6 +1232,7 @@ function get_forums_in_category($cat_id) while ($row = Database::fetch_array($result)) { $forum_list[$row['forum_id']] = $row; } + return $forum_list; } @@ -1242,10 +1260,12 @@ function get_forums($id = '', $course_code = '', $includeGroupsForum = true) $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); // GETTING ALL THE FORUMS + // Condition for the session $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id, true, true); $course_id = $course_info['real_id']; + $forum_list = array(); $includeGroupsForumSelect = ""; if (!$includeGroupsForum) { @@ -1407,7 +1427,7 @@ function get_forums($id = '', $course_code = '', $includeGroupsForum = true) $forum_list['number_of_posts'] = $row3['number_of_posts']; } } - + /* Finding the last post information (last_post_id, last_poster_id, last_post_date, last_poster_name, last_poster_lastname, last_poster_firstname)*/ if ($id == '') { @@ -1433,6 +1453,7 @@ function get_forums($id = '', $course_code = '', $includeGroupsForum = true) $forum_list['last_poster_lastname'] = $last_post_info_of_forum['last_poster_lastname']; $forum_list['last_poster_firstname'] = $last_post_info_of_forum['last_poster_firstname']; } + return $forum_list; } @@ -1516,6 +1537,7 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_ $return_array['last_poster_name'] = $row['poster_name']; $return_array['last_poster_lastname'] = $row['lastname']; $return_array['last_poster_firstname'] = $row['firstname']; + return $return_array; } else { // We have to loop through the results to find the first one that is actually visible to students (forum_category, forum, thread AND post are visible). @@ -1527,6 +1549,7 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_ $return_array['last_poster_name'] = $row['poster_name']; $return_array['last_poster_lastname'] = $row['lastname']; $return_array['last_poster_firstname'] = $row['firstname']; + return $return_array; } } @@ -1611,6 +1634,7 @@ function get_threads($forum_id, $course_code = null) while ($row = Database::fetch_array($result, 'ASSOC')) { $thread_list[] = $row; } + return $thread_list; } @@ -1626,7 +1650,6 @@ function get_posts($thread_id) { $table_users = Database :: get_main_table(TABLE_MAIN_USER); $table_posts = Database :: get_course_table(TABLE_FORUM_POST); - //$tableItemProperty = Database :: get_course_table(TABLE_ITEM_PROPERTY); $course_id = api_get_course_int_id(); $sessionId = api_get_session_id(); @@ -1661,6 +1684,7 @@ function get_posts($thread_id) while ($row = Database::fetch_array($result)) { $post_list[] = $row; } + return $post_list; } @@ -1686,6 +1710,7 @@ function get_post_information($post_id) posts.post_id='".Database::escape_string($post_id)."'"; $result = Database::query($sql); $row = Database::fetch_array($result); + return $row; } @@ -1714,6 +1739,7 @@ function get_thread_information($thread_id) "; $result = Database::query($sql); $row = Database::fetch_array($result); + return $row; } @@ -1771,6 +1797,7 @@ function get_thread_users_details($thread_id) course_code = '".$course_code."' $orderby"; } $result = Database::query($sql); + return $result; } @@ -1840,6 +1867,7 @@ function get_thread_users_qualify($thread_id) $orderby "; } $result = Database::query($sql); + return $result; } @@ -1907,6 +1935,7 @@ function get_thread_users_not_qualify($thread_id) AND course_code = '".$course_code."' AND post.c_id = $course_id $orderby"; } $result = Database::query($sql); + return $result; } @@ -1966,6 +1995,7 @@ function get_forumcategory_information($cat_id) forumcategories.cat_id='".Database::escape_string($cat_id)."'"; $result = Database::query($sql); $row = Database::fetch_array($result); + return $row; } @@ -1989,6 +2019,7 @@ function count_number_of_forums_in_category($cat_id) WHERE c_id = $course_id AND forum_category='".Database::escape_string($cat_id)."'"; $result = Database::query($sql); $row = Database::fetch_array($result); + return $row['number_of_forums']; } @@ -2007,6 +2038,7 @@ function store_thread($current_forum, $values) { $_course = api_get_course_info(); $_user = api_get_user_info(); + $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); $table_posts = Database :: get_course_table(TABLE_FORUM_POST); @@ -2287,6 +2319,7 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id = if (($action == 'quote' || $action == 'replymessage') && isset($my_post)) { // We also need to put the parent_id of the post in a hidden form when we are quoting or replying to a message (<> reply to a thread !!!) $form->addElement('hidden', 'post_parent_id', intval($my_post)); + // If we are replying or are quoting then we display a default title. $values = get_post_information($my_post); $defaults['post_title'] = get_lang('ReplyShort').api_html_entity_decode($values['post_title'], ENT_QUOTES); @@ -2311,9 +2344,11 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id = $values = $form->exportValues(); if ($values['thread_qualify_gradebook'] == '1' && empty($values['weight_calification'])) { Display::display_error_message(get_lang('YouMustAssignWeightOfQualification').' '.get_lang('Back').'', false); + return false; } Security::clear_token(); + return $values; } } else { @@ -2366,12 +2401,14 @@ function store_theme_qualify($user_id, $thread_id, $thread_qualify = 0, $qualify $sql = "INSERT INTO $table_threads_qualify (c_id, user_id, thread_id,qualify,qualify_user_id,qualify_time,session_id) VALUES (".$course_id.", '".$user_id."','".$thread_id."',".(float) $thread_qualify.", '".$qualify_user_id."','".$qualify_time."','".$session_id."')"; $res = Database::query($sql); + return $res; } else { $sql1 = "SELECT qualify FROM ".$table_threads_qualify." WHERE c_id = $course_id AND user_id=".$user_id." and thread_id=".$thread_id.";"; $rs = Database::query($sql1); $row = Database::fetch_array($rs); $row[1] = "update"; + return $row; } } else { @@ -2415,6 +2452,7 @@ function show_qualify($option, $user_id, $thread_id) } $rs = Database::query($sql); $row = Database::fetch_array($rs); + return $row[0]; } @@ -2447,6 +2485,7 @@ function get_historical_qualify($user_id, $thread_id, $opt) while ($row = Database::fetch_array($rs, 'ASSOC')) { $my_qualify_log[] = $row; } + return $my_qualify_log; } @@ -2463,8 +2502,15 @@ function get_historical_qualify($user_id, $thread_id, $opt) * @author Isaac Flores , U.N.A.S University * @version October 2008, dokeos 1.8.6 */ -function store_qualify_historical($option, $couser_id, $forum_id, $user_id, $thread_id, $current_qualify, $qualify_user_id) -{ +function store_qualify_historical( + $option, + $couser_id, + $forum_id, + $user_id, + $thread_id, + $current_qualify, + $qualify_user_id +) { $table_threads_qualify = Database::get_course_table(TABLE_FORUM_THREAD_QUALIFY); $table_threads = Database::get_course_table(TABLE_FORUM_THREAD); @@ -2511,6 +2557,7 @@ function current_qualify_of_thread($thread_id, $session_id) $res = Database::query("SELECT qualify FROM $table_threads_qualify WHERE c_id = $course_id AND thread_id = $thread_id AND session_id = $session_id"); $row = Database::fetch_array($res, 'ASSOC'); + return $row['qualify']; } @@ -2527,6 +2574,7 @@ function store_reply($current_forum, $values) $_course = api_get_course_info(); $forum_table_attachment = Database :: get_course_table(TABLE_FORUM_ATTACHMENT); $table_posts = Database :: get_course_table(TABLE_FORUM_POST); + $post_date = api_get_utc_datetime(); if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) { @@ -2605,6 +2653,7 @@ function store_reply($current_forum, $values) } //$message .= '
'.get_lang('ReturnTo').' '.get_lang('Forum').'
'; //$message .= get_lang('ReturnTo').' '.get_lang('Message').''; + // Setting the notification correctly. $my_post_notification = isset($values['post_notification']) ? $values['post_notification'] : null; if ($my_post_notification == 1) { @@ -2620,10 +2669,12 @@ function store_reply($current_forum, $values) Session::erase('addedresourceid'); $return['msg'] = $message; $return['type'] = 'confirmation'; + } else { $return['msg'] = get_lang('UplNoFileUploaded').' '.get_lang('UplSelectFileFirst'); $return['type'] = 'error'; } + return $return; } @@ -2897,6 +2948,7 @@ function display_user_image($user_id, $name, $origin = '') if ($user_id != 0) { $image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true); $friends_profile = UserManager::get_picture_user($user_id, $image_path['file'], 0, USER_IMAGE_SIZE_MEDIUM, 'width="96" height="96" '); + return $link.''.$name.''; } else { return $link.''.$name.''; @@ -2950,6 +3002,7 @@ function forum_not_allowed_here() { Display :: display_error_message(get_lang('NotAllowedHere')); Display :: display_footer(); + return false; } @@ -3024,6 +3077,7 @@ function get_post_topics_of_forum($forum_id) $table_posts = Database :: get_course_table(TABLE_FORUM_POST); $table_threads = Database :: get_course_table(TABLE_FORUM_THREAD); $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); + $course_id = api_get_course_int_id(); if (api_is_allowed_to_edit(null, true)) { @@ -3088,6 +3142,7 @@ function get_post_topics_of_forum($forum_id) } $return = array('number_of_topics' => $number_of_topics, 'number_of_posts' => $number_of_posts); + return $return; } @@ -3144,6 +3199,7 @@ function get_unaproved_messages($forum_id) while ($row = Database::fetch_array($result)) { $return_array[] = $row['thread_id']; } + return $return_array; } @@ -3248,10 +3304,6 @@ function handle_mail_cue($content, $id) while ($row = Database::fetch_array($result)) { send_mail($row, get_thread_information($post_info['thread_id'])); } - - // Deleting the relevant entries from the mailcue. - //$sql_delete_mailcue = "DELETE FROM $table_mailcue WHERE c_id = $course_id AND post_id='".Database::escape_string($id)."' AND thread_id='".Database::escape_string($post_info['thread_id'])."'"; - //$result = Database::query($sql_delete_mailcue); } elseif ($content == 'thread') { // Sending the mail to all the users that wanted to be informed for replies on this thread. $sql = "SELECT users.firstname, users.lastname, users.user_id, users.email @@ -3319,7 +3371,6 @@ function send_mail($user_info = array(), $thread_information = array()) if ($user_info['user_id'] <> $user_id) { MessageManager::send_message($user_info['user_id'], $subject, $email_body, null, null, null, null, null, null, $user_id); - //@api_mail_html(api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $user_info['email'], $email_subject, $email_body, api_get_person_name($_SESSION['_user']['firstName'], $_SESSION['_user']['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_SESSION['_user']['mail']); } } @@ -3395,6 +3446,7 @@ function move_post_form() // Invisible form: the post_id $form->addElement('hidden', 'post_id', intval($_GET['post'])); + // Dropdown list: Threads of this forum $threads = get_threads($_GET['forum']); //my_print_r($threads); @@ -3522,6 +3574,7 @@ function store_move_post($values) $sql = "UPDATE $table_threads SET thread_replies=thread_replies+1 WHERE c_id = $course_id AND thread_id='".intval($_POST['thread'])."'"; Database::query($sql); } + return get_lang('ThreadMoved'); } @@ -3642,7 +3695,6 @@ function display_forum_search_results($search_term) $table_posts = Database :: get_course_table(TABLE_FORUM_POST); $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY); $session_id = api_get_session_id(); - $gradebook = Security::remove_XSS($_GET['gradebook']); $course_id = api_get_course_int_id(); @@ -3753,6 +3805,7 @@ function search_link() $return .= ''.Display::return_icon('delete.gif', get_lang('RemoveSearchResults')).''; } } + return $return; } @@ -3875,6 +3928,7 @@ function get_attachment($post_id) if (Database::num_rows($result) != 0) { $row = Database::fetch_array($result); } + return $row; } @@ -4000,13 +4054,13 @@ function get_forums_of_group($group_id) $sql3 = "SELECT count(post_id) AS number_of_posts, forum_id FROM $table_posts WHERE c_id = $course_id GROUP BY forum_id"; + } // Handling all the forum information. $result = Database::query($sql); $forum_list = array(); - while ($row = Database::fetch_array($result, 'ASSOC')) { $forum_list[$row['forum_id']] = $row; } @@ -4085,6 +4139,7 @@ function set_notification($content, $id, $add_only = false) $result = Database::query($sql); Session::erase('forum_notification'); get_notifications_of_user(0, true); + return get_lang('YouWillBeNotifiedOfNewPosts'); } else { if (!$add_only) { @@ -4093,6 +4148,7 @@ function set_notification($content, $id, $add_only = false) Database::query($sql); Session::erase('forum_notification'); get_notifications_of_user(0, true); + return get_lang('YouWillNoLongerBeNotifiedOfNewPosts'); } } @@ -4136,6 +4192,7 @@ function get_notifications($content, $id) while ($row = Database::fetch_array($result)) { $return['user'.$row['user_id']] = array('email' => $row['email'], 'user_id' => $row['user_id']); } + return $return; } @@ -4154,7 +4211,6 @@ function get_notifications($content, $id) */ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0) { - //$_user = api_get_user_info(); $_course = api_get_course_info(); // The content of the mail @@ -4180,22 +4236,19 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0) $users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread); $sender_id = api_get_user_id(); - if (is_array($users_to_be_notified)) { foreach ($users_to_be_notified as $value) { - //if ($value['email'] != $_user['email']) { - - $user_info = api_get_user_info($value['user_id']); - $email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).",
\n\r"; - $email_body .= get_lang('NewForumPost').": ".$current_forum['forum_title'].' - '.$current_thread['thread_title']."
\n"; - $email_body .= get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."]
\n"; - $email_body .= get_lang('YouWantedToStayInformed')."
\n"; - $email_body .= get_lang('ThreadCanBeFoundHere').':
'.$thread_link."\n"; - - MessageManager::send_message_simple( - $value['user_id'], $subject, $email_body, $sender_id - ); - //} + + $user_info = api_get_user_info($value['user_id']); + $email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).",
\n\r"; + $email_body .= get_lang('NewForumPost').": ".$current_forum['forum_title'].' - '.$current_thread['thread_title']."
\n"; + $email_body .= get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."]
\n"; + $email_body .= get_lang('YouWantedToStayInformed')."
\n"; + $email_body .= get_lang('ThreadCanBeFoundHere').':
'.$thread_link."\n"; + + MessageManager::send_message_simple( + $value['user_id'], $subject, $email_body, $sender_id + ); } } } @@ -4256,6 +4309,7 @@ function count_number_of_post_in_thread($thread_id) } $sql = "SELECT * FROM $table_posts WHERE c_id = $course_id AND thread_id='".Database::escape_string($thread_id)."' "; $result = Database::query($sql); + return count(Database::store_result($result)); } @@ -4279,6 +4333,7 @@ function count_number_of_post_for_user_thread($thread_id, $user_id) $count = Database::fetch_array($result); $count = $count['count']; } + return $count; } @@ -4295,6 +4350,7 @@ function count_number_of_user_in_course($course_id) $sql = "SELECT * FROM $table_course_rel_user WHERE course_code ='".Database::escape_string($course_id)."' "; $result = Database::query($sql); + return count(Database::store_result($result)); } @@ -4367,6 +4423,7 @@ function get_thread_user_post($course_code, $thread_id, $user_id) $post_list[] = $row2; } } + return $post_list; } @@ -4384,6 +4441,7 @@ function get_name_thread_by_id($thread_id) $sql = "SELECT thread_title FROM ".$t_forum_thread." WHERE c_id = $course_id AND thread_id = '".intval($thread_id)."' "; $result = Database::query($sql); $row = Database::fetch_array($result); + return $row[0]; } @@ -4452,6 +4510,7 @@ function get_all_post_from_user($user_id, $course_code) }$j++; } } + return $forum_results; } @@ -4484,6 +4543,7 @@ function get_thread_user_post_limit($course_code, $thread_id, $user_id, $limit = $row['status'] = '1'; $post_list[] = $row; } + return $post_list; } @@ -4506,6 +4566,7 @@ function calculate_children($rows) _phorum_recursive_sort($rows, $sorted_rows); unset($sorted_rows[0]); } + return $sorted_rows; } diff --git a/main/forum/forumqualify.php b/main/forum/forumqualify.php index a1e01685da..1d457d7552 100755 --- a/main/forum/forumqualify.php +++ b/main/forum/forumqualify.php @@ -27,9 +27,7 @@ if (isset($_GET['origin'])) { } $user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : null; - api_block_course_item_locked_by_gradebook($_GET['thread'], LINK_FORUM_THREAD); - $nameTools = get_lang('ToolForum'); /* Including necessary files */ diff --git a/main/forum/index.php b/main/forum/index.php index 5d67411952..22fad06095 100755 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -196,6 +196,7 @@ if (api_is_allowed_to_edit(false, true)) { Display::return_icon('new_forum.png', get_lang('AddForum'),'',ICON_SIZE_MEDIUM).''; } } + echo '
'; // Fixes error if there forums with no category. @@ -293,6 +294,7 @@ if (is_array($forumCategories)) { if (api_is_allowed_to_edit(false, true)) { $show_forum = true; } else { + // you are not a teacher // it is not a group forum => show forum (invisible forums are already left out see get_forums function) if ($forum['forum_of_group'] == '0') { $show_forum = true; diff --git a/main/forum/reply.php b/main/forum/reply.php index 13ec03cf4b..6ff92a4d86 100755 --- a/main/forum/reply.php +++ b/main/forum/reply.php @@ -92,6 +92,7 @@ if ($current_forum['forum_of_group'] != 0) { } /* Breadcrumbs */ + $gradebook = null; if (isset($_SESSION['gradebook'])){ $gradebook = Security::remove_XSS($_SESSION['gradebook']); diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index ecb5fdc1a3..b2ce5c4715 100755 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -70,10 +70,8 @@ $is_group_tutor = false; if (!empty($groupId)) { //Group info & group category info $group_properties = GroupManager::get_group_properties($groupId); - //User has access in the group? - $user_has_access_in_group = GroupManager::user_has_access($userid, $groupId, GroupManager::GROUP_TOOL_FORUM); - + $user_has_access_in_group = GroupManager::user_has_access($userid, $groupId, GroupManager::GROUP_TOOL_FORUM); $is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $groupId); //Course @@ -98,6 +96,7 @@ if (!empty($groupId)) { $my_search = isset($_GET['search']) ? $_GET['search'] : ''; $my_action = isset($_GET['action']) ? $_GET['action'] : ''; + $gradebook = null; if (isset($_SESSION['gradebook'])){ $gradebook = $_SESSION['gradebook']; @@ -277,7 +276,6 @@ if (!empty($message)) { echo '
'; if ($origin != 'learnpath') { - if ($origin=='group') { echo ''.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'',ICON_SIZE_MEDIUM).''; } else { @@ -416,7 +414,6 @@ if (is_array($threads)) { echo '
'; echo '

'; Blog :: display_form_user_unsubscribe($blog_id); - } - else + } else { api_not_allowed(); + } break; case 'manage_rights' : Blog :: display_form_user_rights($blog_id); break; case 'manage_tasks' : - if (api_is_allowed('BLOG_'.$blog_id, 'task_management')) - { + if (api_is_allowed('BLOG_'.$blog_id, 'task_management')) { if (isset($_GET['do']) && $_GET['do'] == 'add') { Blog :: display_new_task_form($blog_id); @@ -468,12 +442,9 @@ switch ($current_page) { break; case '' : default : - if (isset ($_GET['filter']) && !empty ($_GET['filter'])) - { + if (isset ($_GET['filter']) && !empty ($_GET['filter'])) { Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); - } - else - { + } else { Blog :: display_blog_posts($blog_id); } } diff --git a/main/blog/blog_admin.php b/main/blog/blog_admin.php index 02696dfc95..3f62731f81 100755 --- a/main/blog/blog_admin.php +++ b/main/blog/blog_admin.php @@ -49,8 +49,8 @@ if (api_is_allowed_to_edit()) { 'name' => $current_section ); Display::display_header(''); - } else { - } + } else { + } echo ''; @@ -83,7 +83,7 @@ if (api_is_allowed_to_edit()) { Display::display_confirmation_message(get_lang('BlogDeleted')); } - /* + /* DISPLAY */ //api_display_tool_title($nameTools); diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 4da2337462..04fc03d7ee 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -795,9 +795,6 @@ function selectAll(cbList,bSelect,showwarning) { } document.new_calendar_item.submit(); } - - - } function reverseAll(cbList) @@ -847,15 +844,12 @@ function plus_ical() { */ function user_group_filter_javascript() { - return " - "; + "; } /** @@ -911,7 +905,6 @@ function get_course_users() */ function get_course_groups() { - $group_list = array(); $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id()); return $group_list; } @@ -1405,7 +1398,11 @@ function show_user_group_filter_form() $option = ""; foreach ($group_list as $this_group) { // echo ""; - $has_access = GroupManager::user_has_access(api_get_user_id(), $this_group['id'], GroupManager::GROUP_TOOL_CALENDAR); + $has_access = GroupManager::user_has_access( + api_get_user_id(), + $this_group['id'], + GroupManager::GROUP_TOOL_CALENDAR + ); $result = GroupManager::get_group_properties($this_group['id']); if ($result['calendar_state'] != '0') { diff --git a/main/calendar/allagendas.php b/main/calendar/allagendas.php index bc1e9dd98d..fc88db328c 100755 --- a/main/calendar/allagendas.php +++ b/main/calendar/allagendas.php @@ -158,17 +158,13 @@ function get_agenda_items_by_course_list($course_list, $month, $year, $session_i ORDER BY start_date "; $result = Database::query($sqlquery); while ($item = Database::fetch_array($result,'ASSOC')) { - //var_dump($item); //taking the day $agendaday = date("j",strtotime($item['start_date'])); if(!isset($items[$agendaday])){$items[$agendaday]=array();} //taking the time $time = date("H:i",strtotime($item['start_date'])); - //var_dump($time ); $end_time= date("H:i",strtotime($item['end_date'])); $URL = api_get_path(WEB_PATH)."main/calendar/allagendas.php?cidReq=".urlencode($code)."&sort=asc&view=list&day=$agendaday&month=$month&year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item - //var_dump($URL); - if ($setting_agenda_link == 'coursecode') { //$title=$array_course_info['title']; $agenda_link = api_substr($title, 0, 14); @@ -260,14 +256,8 @@ if(!empty($my_session_id)) { $_SESSION['my_course_list'] = array(); $my_course_list = array(); } else { - //echo 'here'; - $my_course_list = $_SESSION['my_course_list']; - - //var_dump($_SESSION['my_course_list'], $my_course_list); - + $my_course_list = $_SESSION['my_course_list']; $my_course_list_keys = array_keys($my_course_list); - - //var_dump($my_course_list, $my_course_list_keys); if (!in_array($my_course_id, $my_course_list_keys)) { $course_info = api_get_course_info_by_id($my_course_id); $_SESSION['my_course_list'][$my_course_id] = $course_info; diff --git a/main/calendar/ical_export.php b/main/calendar/ical_export.php index ba54dae50e..f651815813 100755 --- a/main/calendar/ical_export.php +++ b/main/calendar/ical_export.php @@ -74,14 +74,12 @@ if (!empty($event)) { $vevent->setClass('PRIVATE'); break; } - + $event['start_date'] = api_get_local_time($event['start_date']); $event['end_date'] = api_get_local_time($event['end_date']); - - - + switch($type) { - case 'personal': + case 'personal': case 'platform': $vevent->setProperty( 'summary', api_convert_encoding($event['title'],'UTF-8', $charset)); if(empty($event['start_date'])){header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));} @@ -105,7 +103,7 @@ if (!empty($event)) { $ical->setComponent ($vevent); // add event to calendar $ical->returnCalendar(); break; - case 'course': + case 'course': $vevent->setProperty( 'summary', api_convert_encoding($event['title'],'UTF-8',$charset)); if(empty($event['start_date'])){header('location:'.Security::remove_XSS($_SERVER['HTTP_REFERER']));} list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$event['start_date']); diff --git a/main/calendar/myagenda.inc.php b/main/calendar/myagenda.inc.php index 03dc96b688..f06aea569e 100755 --- a/main/calendar/myagenda.inc.php +++ b/main/calendar/myagenda.inc.php @@ -869,27 +869,15 @@ function show_simple_personal_agenda($user_id) { $style = "datanow"; $text_style = "text"; } - /*-------------------------------------------------- - display: date and time - --------------------------------------------------*/ + // adding an internal anchor $content.= date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))." "; $content.= strftime(get_lang("timeNoSecFormat"), strtotime($myrow["date"])); - /*-------------------------------------------------- - display: the title - --------------------------------------------------*/ $content.= '
'; $content.= $myrow['title']; $content.= '
'; - /*-------------------------------------------------- - display: the content - --------------------------------------------------*/ - /* - $content = $myrow['title']; - $content = make_clickable($content); - */ return $content; } } else { @@ -941,8 +929,7 @@ function get_personal_agenda_items_between_dates($user_id, $date_start='', $date // get agenda-items for every course $courses = api_get_user_courses($user_id,false); require_once(api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); - foreach ($courses as $id => $course) - { + foreach ($courses as $id => $course) { $c = api_get_course_info($course['code']); //databases of the courses $t_a = Database :: get_course_table(TABLE_AGENDA, $course['db']); diff --git a/main/chat/chat_chat.php b/main/chat/chat_chat.php index b874073816..c6a7b4e039 100755 --- a/main/chat/chat_chat.php +++ b/main/chat/chat_chat.php @@ -33,7 +33,7 @@ if (!empty($course)) { list($pseudo_user) = Database::fetch_row($result); $isAllowed = !(empty($pseudo_user) || !$_cid); - $isMaster = (bool)$is_courseAdmin; + $isMaster = (bool)api_is_course_admin(); $date_now = date('Y-m-d'); $basepath_chat = ''; diff --git a/main/chat/chat_hidden.php b/main/chat/chat_hidden.php index a61e89e1d4..8e036c5f95 100755 --- a/main/chat/chat_hidden.php +++ b/main/chat/chat_hidden.php @@ -30,7 +30,7 @@ $result = Database::query($query); list($pseudo_user) = Database::fetch_row($result); $isAllowed = !(empty($pseudo_user) || !$_cid); -$isMaster = (bool)$is_courseAdmin; +$isMaster = (bool)api_is_course_admin(); $date_now = date('Y-m-d'); diff --git a/main/chat/chat_message.php b/main/chat/chat_message.php index 86355b274a..8a852ca8ac 100755 --- a/main/chat/chat_message.php +++ b/main/chat/chat_message.php @@ -79,7 +79,7 @@ if (!empty($course) && !empty($_user['user_id'])) { list($pseudo_user) = Database::fetch_row($result); $isAllowed = !(empty($pseudo_user) || !$_cid); - $isMaster = (bool)$is_courseAdmin; + $isMaster = (bool)api_is_course_admin(); $user_id = Database::result($result, 0, 'user_id'); $firstname = Database::result($result, 0, 'firstname'); diff --git a/main/chat/chat_whoisonline.php b/main/chat/chat_whoisonline.php index 9603dd5102..f35cb4e6ee 100755 --- a/main/chat/chat_whoisonline.php +++ b/main/chat/chat_whoisonline.php @@ -43,8 +43,8 @@ if (!empty($course)) { list($pseudo_user) = Database::fetch_array($result); - $isAllowed = !(empty($pseudo_user) || !$_cid); - $isMaster = (bool)$is_courseAdmin; + $isAllowed = !(empty($pseudo_user) || !$_cid); + $isMaster = api_is_course_admin(); $date_inter = date('Y-m-d H:i:s', time() - 120); diff --git a/main/course_description/add.php b/main/course_description/add.php index 92e6166508..98b5b2c03f 100755 --- a/main/course_description/add.php +++ b/main/course_description/add.php @@ -9,6 +9,7 @@ // protect a course script api_protect_course_script(true); + // display categories $categories = array (); foreach ($default_description_titles as $id => $title) { diff --git a/main/course_home/3column.php b/main/course_home/3column.php index 67282226d4..6b711f025e 100755 --- a/main/course_home/3column.php +++ b/main/course_home/3column.php @@ -113,7 +113,7 @@ elseif ($restore) { // visibility 0,2 -> 1 elseif (isset($update) && $update) { $result = Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id"); $tool = Database::fetch_array($result); - $racine = $_configuration['root_sys'].'/'.$currentCourseID.'/images/'; + $racine = api_get_path(SYS_PATH).'/'.$currentCourseID.'/images/'; $chemin = $racine; $name = $tool[1]; $image = $tool[3]; @@ -165,7 +165,7 @@ elseif (isset($update) && $update) { // Work with data post askable by admin of course -if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach()) { +if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) { // Show message to confirm that a tools must be hide from aivailable tools // visibility 0,1->2 if ($askDelete) { @@ -219,7 +219,7 @@ if (api_is_allowed_to_edit(null, true) && !api_is_coach()) { /* TOOLS FOR PLATFORM ADMIN ONLY */ -if ($is_platformAdmin && api_is_allowed_to_edit(null, true) && !api_is_coach()) { +if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) { $content .= "
". "
". "
'.$last_post.''; - // Get attachment id. if (isset($row['post_id'])) { $attachment_list = get_attachment($row['post_id']); diff --git a/main/forum/viewpost.php b/main/forum/viewpost.php index 6194d69cf1..d267a6f561 100755 --- a/main/forum/viewpost.php +++ b/main/forum/viewpost.php @@ -45,6 +45,7 @@ $current_thread = get_thread_information($_GET['thread']); // Note: This has to $current_forum = get_forum_information($current_thread['forum_id']); // Note: This has to be validated that it is an existing forum. $current_forum_category = get_forumcategory_information($current_forum['forum_category']); $whatsnew_post_info = $_SESSION['whatsnew_post_info']; + /* Header and Breadcrumbs */ if (isset($_SESSION['gradebook'])){ diff --git a/main/glossary/index.php b/main/glossary/index.php index 31e2103aa9..e61ca3c9b7 100755 --- a/main/glossary/index.php +++ b/main/glossary/index.php @@ -25,7 +25,7 @@ api_protect_course_script(true); // Additional javascripts. $htmlHeadXtra[] = GlossaryManager::javascript_glossary(); -$htmlHeadXtra[] = '