From eb0fcbef70156abcbf4afa82ffb91e99f32e5917 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 7 Aug 2018 14:50:28 +0200 Subject: [PATCH] Minor - partial merge from 1.11.x --- main/admin/add_sessions_to_usergroup.php | 5 - main/admin/course_list.php | 4 - main/admin/index.php | 1 - main/admin/user_list_consent.php | 44 +- main/admin/usergroups.php | 11 - main/auth/courses_controller.php | 5 +- main/auth/inscription.php | 95 +++- main/auth/my_progress.php | 26 +- main/auth/profile.php | 92 +--- main/auth/unsubscribe_account.php | 6 +- main/auth/user_mail_confirmation.php | 29 +- main/badge/criteria.php | 3 +- main/badge/issued.php | 14 +- main/badge/issued_all.php | 25 +- main/calendar/agenda.php | 8 +- main/calendar/agenda_list.php | 14 +- .../course_description_controller.php | 18 +- main/course_description/resources/js/main.js | 34 +- main/course_home/course_home.php | 2 +- main/course_info/delete_course.php | 2 - main/course_info/infocours.php | 451 ++++++++---------- main/course_progress/index.php | 4 +- main/coursecopy/copy_course.php | 17 +- main/coursecopy/copy_course_session.php | 19 +- .../copy_course_session_selected.php | 23 +- main/coursecopy/create_backup.php | 132 +++-- main/coursecopy/import_backup.php | 66 +-- main/coursecopy/import_moodle.php | 6 +- main/coursecopy/recycle_course.php | 13 +- 29 files changed, 542 insertions(+), 627 deletions(-) diff --git a/main/admin/add_sessions_to_usergroup.php b/main/admin/add_sessions_to_usergroup.php index de9e2c738b..1b0c973b8f 100755 --- a/main/admin/add_sessions_to_usergroup.php +++ b/main/admin/add_sessions_to_usergroup.php @@ -15,16 +15,11 @@ $data = $usergroup->get($id); $usergroup->protectScript($data); $xajax = new xajax(); - -//$xajax->debugOn(); $xajax->registerFunction('search_usergroup_sessions'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; -// setting breadcrumbs -api_protect_admin_script(true); - // setting breadcrumbs $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; diff --git a/main/admin/course_list.php b/main/admin/course_list.php index 4ac1bdfcde..754e76d30a 100755 --- a/main/admin/course_list.php +++ b/main/admin/course_list.php @@ -338,8 +338,6 @@ if (isset($_POST['action'])) { if (count($course_codes) > 0) { foreach ($course_codes as $course_code) { CourseManager::delete_course($course_code); - $obj_cat = new Category(); - $obj_cat->update_category_delete($course_code); } } @@ -409,8 +407,6 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') { $tool_name = get_lang('CourseList'); if (isset($_GET['delete_course'])) { CourseManager::delete_course($_GET['delete_course']); - $obj_cat = new Category(); - $obj_cat->update_category_delete($_GET['delete_course']); Display::addFlash(Display::return_message(get_lang('Deleted'))); } // Create a search-box diff --git a/main/admin/index.php b/main/admin/index.php index c3f82b79af..3d7f6b1d5d 100644 --- a/main/admin/index.php +++ b/main/admin/index.php @@ -305,7 +305,6 @@ if (file_exists($sessionsBlockExtraFile)) { if (api_is_platform_admin()) { $blocks['sessions']['editable'] = true; } - $sessionPath = api_get_path(WEB_CODE_PATH).'session/'; $search_form = '
diff --git a/main/admin/user_list_consent.php b/main/admin/user_list_consent.php index 765ff7a5e2..d4e2833237 100644 --- a/main/admin/user_list_consent.php +++ b/main/admin/user_list_consent.php @@ -54,7 +54,8 @@ function prepare_user_sql_query($getCount) u.registration_date AS col10, u.expiration_date AS exp, u.password, - v.field_id + v.field_id, + v.updated_at FROM $user_table u"; } @@ -246,6 +247,7 @@ function get_user_data($from, $number_of_items, $column, $direction) $user[7], api_get_local_time($user[9]), $user[12], + Display::dateToStringAgoAndLongDate($user[13]), $user[0], ]; } @@ -327,18 +329,18 @@ function modify_filter($user_id, $url_params, $row) $result .= '  '; } - $result .= ' '. - Display::return_icon( - 'anonymous.png', - get_lang('Anonymize'), - [], - ICON_SIZE_SMALL - ). - ''; - if ($user_id != api_get_user_id()) { + $result .= ' '. + Display::return_icon( + 'anonymous.png', + get_lang('Anonymize'), + [], + ICON_SIZE_SMALL + ). + ''; + $result .= ' '. @@ -463,18 +465,7 @@ if (!empty($action)) { if ($check) { switch ($action) { case 'delete_terms': - $extraFieldValue = new ExtraFieldValue('user'); - $value = $extraFieldValue->get_values_by_handler_and_field_variable( - $_GET['user_id'], - 'legal_accept' - ); - $result = $extraFieldValue->delete($value['id']); - - $value = $extraFieldValue->get_values_by_handler_and_field_variable( - $_GET['user_id'], - 'request_for_legal_agreement_consent_removal' - ); - $result = $extraFieldValue->delete($value['id']); + UserManager::cleanUserRequestsOfRemoval($_GET['user_id']); Display::addFlash(Display::return_message(get_lang('Deleted'))); header('Location: '.api_get_self()); @@ -624,14 +615,15 @@ $table->set_header(7, get_lang('Profile')); $table->set_header(8, get_lang('Active'), true, 'width="15px"'); $table->set_header(9, get_lang('RegistrationDate'), true, 'width="90px"'); $table->set_header(10, get_lang('RequestType'), true, 'width="15px"'); -$table->set_header(11, get_lang('Action'), false, 'width="220px"'); +$table->set_header(11, get_lang('RequestDate'), true, 'width="15px"'); +$table->set_header(12, get_lang('Action'), false, 'width="220px"'); $table->set_column_filter(3, 'user_filter'); $table->set_column_filter(4, 'user_filter'); $table->set_column_filter(6, 'email_filter'); $table->set_column_filter(7, 'status_filter'); $table->set_column_filter(8, 'active_filter'); -$table->set_column_filter(11, 'modify_filter'); +$table->set_column_filter(12, 'modify_filter'); $table->set_column_filter(10, 'requestTypeFilter'); // Only show empty actions bar if delete users has been blocked diff --git a/main/admin/usergroups.php b/main/admin/usergroups.php index d8ad129463..d699a0f356 100755 --- a/main/admin/usergroups.php +++ b/main/admin/usergroups.php @@ -16,17 +16,6 @@ $usergroup->protectScript(); // Add the JS needed to use the jqgrid $htmlHeadXtra[] = api_get_jqgrid_js(); -$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')]; -$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null; -if ($action == 'add') { - $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; - $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add')]; -} elseif ($action == 'edit') { - $interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')]; - $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Edit')]; -} else { - $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Classes')]; -} // setting breadcrumbs $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : ''; $userGroupId = isset($_GET['id']) ? (int) $_GET['id'] : 0; diff --git a/main/auth/courses_controller.php b/main/auth/courses_controller.php index f4fb9179c3..b63f281448 100755 --- a/main/auth/courses_controller.php +++ b/main/auth/courses_controller.php @@ -166,7 +166,7 @@ class CoursesController $data['content'] = $content; $data['error'] = $error; $data['catalogShowCoursesSessions'] = 0; - $showCoursesSessions = intval('catalog_show_courses_sessions'); + $showCoursesSessions = (int) api_get_setting('catalog_show_courses_sessions'); if ($showCoursesSessions > 0) { $data['catalogShowCoursesSessions'] = $showCoursesSessions; } @@ -930,7 +930,8 @@ class CoursesController $actions = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session->getId(); } - $isThisSessionOnSale = $session->getBuyCoursePluginPrice(); + $plugin = \BuyCoursesPlugin::create(); + $isThisSessionOnSale = $plugin->getBuyCoursePluginPrice($session); $sessionsBlock = [ 'id' => $session->getId(), diff --git a/main/auth/inscription.php b/main/auth/inscription.php index 53563cd53c..7b0ce68d19 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -37,10 +37,12 @@ if ($gMapsPlugin->get('enable_api') === 'true') { $htmlHeadXtra[] = ''; } +$extraFieldsLoaded = false; $htmlHeadXtra[] = api_get_password_checker_js('#username', '#pass1'); // User is not allowed if Terms and Conditions are disabled and // registration is disabled too. -$isNotAllowedHere = api_get_setting('allow_terms_conditions') === 'false' && api_get_setting('allow_registration') === 'false'; +$isNotAllowedHere = api_get_setting('allow_terms_conditions') === 'false' && + api_get_setting('allow_registration') === 'false'; if ($isNotAllowedHere) { api_not_allowed(true, get_lang('RegistrationDisabled')); @@ -54,9 +56,33 @@ if (!empty($_SESSION['user_language_choice'])) { $user_selected_language = api_get_setting('platformLanguage'); } +$extraConditions = api_get_configuration_value('show_conditions_to_user'); + +if ($extraConditions && isset($extraConditions['conditions'])) { + // Create user extra fields for the conditions + $userExtraField = new ExtraField('user'); + $extraConditions = $extraConditions['conditions']; + foreach ($extraConditions as $condition) { + $exists = $userExtraField->get_handler_field_info_by_field_variable($condition['variable']); + if ($exists == false) { + $params = [ + 'field_type' => ExtraField::FIELD_TYPE_CHECKBOX, + 'variable' => $condition['variable'], + 'display_text' => $condition['display_text'], + 'default_value' => '', + 'visible_to_self' => true, + 'visible_to_others' => false, + 'changeable' => true, + 'filter' => false, + ]; + $userExtraField->save($params); + } + } +} + $form = new FormValidator('registration'); $user_already_registered_show_terms = false; -if (api_get_setting('allow_terms_conditions') == 'true') { +if (api_get_setting('allow_terms_conditions') === 'true') { $user_already_registered_show_terms = isset($_SESSION['term_and_condition']['user_id']); } @@ -83,7 +109,9 @@ if (!empty($course_code_redirect)) { Session::write('exercise_redirect', $exercise_redirect); } -if ($user_already_registered_show_terms === false && api_get_setting('allow_registration') === 'true') { +if ($user_already_registered_show_terms === false && + api_get_setting('allow_registration') !== 'false' +) { // STUDENT/TEACHER if (api_get_setting('allow_registration_as_teacher') != 'false') { if (in_array('status', $allowedFields)) { @@ -310,9 +338,10 @@ if ($user_already_registered_show_terms === false && api_get_setting('allow_regi in_array('extra_fields', $allowedFields) ) { $extraField = new ExtraField('user'); - $extraFieldList = isset($allowedFields['extra_fields']) && is_array( - $allowedFields['extra_fields'] - ) ? $allowedFields['extra_fields'] : []; + $extraFieldList = []; + if (isset($allowedFields['extra_fields']) && is_array($allowedFields['extra_fields'])) { + $extraFieldList = $allowedFields['extra_fields']; + } $returnParams = $extraField->addElements( $form, 0, @@ -321,6 +350,7 @@ if ($user_already_registered_show_terms === false && api_get_setting('allow_regi false, $extraFieldList ); + $extraFieldsLoaded = true; } // CAPTCHA @@ -475,7 +505,7 @@ if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') { $showTerms = false; // Terms and conditions -if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registered_show_terms) { +if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_registered_show_terms) { if (!api_is_platform_admin()) { if (api_get_setting('show_terms_if_profile_completed') === 'true') { $userInfo = api_get_user_info(); @@ -517,7 +547,7 @@ if (api_get_setting('allow_terms_conditions') == 'true' && $user_already_registe 'TermsAndConditions' ).'' ); - $form->addRule('legal_accept', get_lang('ThisFieldIsRequired'), 'required'); + $form->addRule('legal_accept', get_lang('WeNeedYouToAcceptOurTreatmentOfYourData'), 'required'); } else { $preview = LegalManager::show_last_condition($term_preview); $form->addElement('label', null, $preview); @@ -555,7 +585,16 @@ if ($allowDoubleValidation && $showTerms == false) { $form->addHtml(''); $formContainsSendButton = true; } else { - if (api_get_setting('allow_registration') === 'true' || $user_already_registered_show_terms || $showTerms) { + // In normal cases (without double validation), we check if the + // registration is allowed in any way or if the user is already registered + // but needs to confirm terms. If not, send not allowed message + if ( + api_get_setting('allow_registration') === 'approval' || + api_get_setting('allow_registration') === 'true' || + api_get_setting('allow_registration') === 'confirmation' || + $user_already_registered_show_terms || + $showTerms + ) { $form->addButtonNext(get_lang('RegisterUser')); $formContainsSendButton = true; } @@ -569,6 +608,31 @@ if (!$formContainsSendButton) { $course_code_redirect = Session::read('course_redirect'); $sessionToRedirect = Session::read('session_redirect'); +if ($extraConditions && $extraFieldsLoaded) { + // Set conditions as "required" and also change the labels + foreach ($extraConditions as $condition) { + /** @var HTML_QuickForm_group $element */ + $element = $form->getElement('extra_'.$condition['variable']); + if ($element) { + $children = $element->getElements(); + /** @var HTML_QuickForm_checkbox $child */ + foreach ($children as $child) { + $child->setText(get_lang($condition['display_text'])); + } + $form->setRequired($element); + if (!empty($condition['text_area'])) { + $element->setLabel( + [ + '', + //'', + '
'.get_lang($condition['text_area']).'
', + ] + ); + } + } + } +} + if ($form->validate()) { $values = $form->getSubmitValues(1); // Make *sure* the login isn't too long @@ -584,7 +648,7 @@ if ($form->validate()) { $values['official_code'] = api_strtoupper($values['username']); } - if (api_get_setting('login_is_email') == 'true') { + if (api_get_setting('login_is_email') === 'true') { $values['username'] = $values['email']; } @@ -824,11 +888,18 @@ if ($form->validate()) { $cond_array = explode(':', $values['legal_accept_type']); if (!empty($cond_array[0]) && !empty($cond_array[1])) { $time = time(); - $condition_to_save = intval($cond_array[0]).':'.intval($cond_array[1]).':'.$time; + $conditionToSave = (int) $cond_array[0].':'.(int) $cond_array[1].':'.$time; UserManager::update_extra_field_value( $user_id, 'legal_accept', - $condition_to_save + $conditionToSave + ); + + Event::addEvent( + LOG_TERM_CONDITION_ACCEPTED, + LOG_USER_OBJECT, + api_get_user_info($user_id), + api_get_utc_datetime() ); $bossList = UserManager::getStudentBossList($user_id); diff --git a/main/auth/my_progress.php b/main/auth/my_progress.php index e8eea81893..f5085f1292 100755 --- a/main/auth/my_progress.php +++ b/main/auth/my_progress.php @@ -10,7 +10,6 @@ $cidReset = true; require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_TRACKING; - $nameTools = get_lang('MyProgress'); api_block_anonymous_users(); @@ -23,23 +22,29 @@ $(function() { autoPlayPause: 2000 }) }); - "; +$pluginCalendar = api_get_plugin_setting('learning_calendar', 'enabled') === 'true'; + +if ($pluginCalendar) { + $plugin = LearningCalendarPlugin::create(); + $plugin->setJavaScript($htmlHeadXtra); +} + if (api_get_configuration_value('block_my_progress_page')) { api_not_allowed(true); } $user_id = api_get_user_id(); -$course_user_list = CourseManager::get_courses_list_by_user_id($user_id); +$courseUserList = CourseManager::get_courses_list_by_user_id($user_id); $dates = $issues = ''; -$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0; +$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : 0; $courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null; -if (!empty($course_user_list)) { +if (!empty($courseUserList)) { $items = MySpace::get_connections_from_course_list( $user_id, - $course_user_list + $courseUserList ); $first = null; $last = null; @@ -94,6 +99,15 @@ if (!empty($dates)) { $content .= ''; } +if (api_get_configuration_value('private_messages_about_user_visible_to_user') === true) { + $allowMessages = api_get_configuration_value('private_messages_about_user'); + if ($allowMessages === true) { + // Messages + $content .= Display::page_subheader2(get_lang('Messages')); + $content .= MessageManager::getMessagesAboutUserToString(api_get_user_info()); + } +} + $message = null; if (empty($content)) { $message = Display::return_message(get_lang('NoDataAvailable'), 'warning'); diff --git a/main/auth/profile.php b/main/auth/profile.php index 9713695837..d0c3349b45 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -23,9 +23,7 @@ if (api_get_setting('allow_social_tool') == 'true') { $_SESSION['this_section'] = $this_section; -if (!(isset($_user['user_id']) && $_user['user_id']) || - api_is_anonymous($_user['user_id'], true) -) { +if (!(isset($_user['user_id']) && $_user['user_id']) || api_is_anonymous($_user['user_id'], true)) { api_not_allowed(true); } @@ -363,87 +361,20 @@ if (is_profile_editable()) { } else { $form->freeze(); } -$form->setDefaults($user_data); - -/** - * Is user auth_source is platform ? - * - * @return bool if auth_source is platform - */ -function is_platform_authentication() -{ - $tab_user_info = api_get_user_info(); - - return $tab_user_info['auth_source'] == PLATFORM_AUTH_SOURCE; -} - -/** - * Can a user edit his/her profile? - * - * @return bool Editability of the profile - */ -function is_profile_editable() -{ - if (isset($GLOBALS['profileIsEditable'])) { - return (bool) $GLOBALS['profileIsEditable']; - } - - return true; -} - -/* - PRODUCTIONS FUNCTIONS -*/ -/** - * Upload a submitted user production. - * - * @param $user_id User id - * - * @return The filename of the new production or FALSE if the upload has failed - */ -function upload_user_production($user_id) -{ - $production_repository = UserManager::getUserPathById($user_id, 'system'); - if (!file_exists($production_repository)) { - @mkdir($production_repository, api_get_permissions_for_new_directories(), true); - } - $filename = api_replace_dangerous_char($_FILES['production']['name']); - $filename = disable_dangerous_file($filename); - - if (filter_extension($filename)) { - if (@move_uploaded_file($_FILES['production']['tmp_name'], $production_repository.$filename)) { - return $filename; +$extraConditions = api_get_configuration_value('show_conditions_to_user'); +if ($extraConditions && isset($extraConditions['conditions'])) { + $extraConditions = $extraConditions['conditions']; + foreach ($extraConditions as $condition) { + $element = $form->getElement('extra_'.$condition['variable']); + if ($element) { + $element->freeze(); } } - - return false; // this should be returned if anything went wrong with the upload } -/** - * Check current user's current password. - * - * @param char email - * - * @return bool true o false - * - * @uses \Gets user ID from global variable - */ -function check_user_email($email) -{ - $user_id = api_get_user_id(); - if ($user_id != strval(intval($user_id)) || empty($email)) { - return false; - } - $table_user = Database::get_main_table(TABLE_MAIN_USER); - $email = Database::escape_string($email); - $sql = "SELECT * FROM $table_user - WHERE user_id='".$user_id."' AND email='".$email."'"; - $result = Database::query($sql); - - return Database::num_rows($result) != 0; -} +$form->setDefaults($user_data); $filtered_extension = false; @@ -542,7 +473,7 @@ if ($form->validate()) { } } elseif (!empty($user_data['remove_picture'])) { // remove existing picture if asked - UserManager::delete_user_picture(api_get_user_id()); + UserManager::deleteUserPicture(api_get_user_id()); $user_data['picture_uri'] = ''; } @@ -719,6 +650,7 @@ if ($form->validate()) { Session::write('_user', $userInfo); if ($hook) { + $hook->setEventData(['user' => $user]); $hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST); } @@ -782,7 +714,7 @@ if (api_get_setting('allow_social_tool') === 'true') { $normalImage = UserManager::getUserPicture(api_get_user_id(), USER_IMAGE_SIZE_ORIGINAL); $imageToShow = '
'; - $imageToShow .= ''; + $imageToShow .= ''; $imageToShow .= '
'; $content = $imageToShow.$form->returnForm(); diff --git a/main/auth/unsubscribe_account.php b/main/auth/unsubscribe_account.php index 374175c381..f268b2942a 100755 --- a/main/auth/unsubscribe_account.php +++ b/main/auth/unsubscribe_account.php @@ -28,10 +28,8 @@ if ($form->validate()) { if ($result) { $message = Display::return_message( sprintf( - get_lang( - 'UnsubscribeFromPlatformSuccess', - $user_info['username'] - ) + get_lang('UnsubscribeFromPlatformSuccess'), + $user_info['username'] ) ); $content = null; diff --git a/main/auth/user_mail_confirmation.php b/main/auth/user_mail_confirmation.php index 6a7d9370c2..a095e9e5f1 100644 --- a/main/auth/user_mail_confirmation.php +++ b/main/auth/user_mail_confirmation.php @@ -19,8 +19,33 @@ if ($user) { Database::getManager()->persist($user); Database::getManager()->flush(); - Display::addFlash(Display::return_message(get_lang('UserConfirmedNowYouCanLogInThePlatform'), 'success')); - header('Location: '.api_get_path(WEB_PATH)); + // See where to redirect the user to, if any redirection has been set + $url = api_get_path(WEB_PATH); + + if (!empty($_GET['c'])) { + $courseCode = Security::remove_XSS($_GET['c']); + } + if (!empty($_GET['s'])) { + $sessionId = (int) $_GET['s']; + } + + // Get URL to a course, to a session, or an empty string + $courseUrl = api_get_course_url($courseCode, $sessionId); + if (!empty($courseUrl)) { + $url = $courseUrl; + } + + Event::addEvent( + LOG_USER_CONFIRMED_EMAIL, + LOG_USER_OBJECT, + api_get_user_info($user->getId()), + api_get_utc_datetime() + ); + + Display::addFlash( + Display::return_message(get_lang('UserConfirmedNowYouCanLogInThePlatform'), 'success') + ); + header('Location: '.$url); exit; } else { Display::addFlash( diff --git a/main/badge/criteria.php b/main/badge/criteria.php index dda58fe3d2..d89bfe7ba1 100644 --- a/main/badge/criteria.php +++ b/main/badge/criteria.php @@ -11,6 +11,7 @@ require_once __DIR__.'/../inc/global.inc.php'; $entityManager = Database::getManager(); +/** @var \Chamilo\CoreBundle\Entity\Skill $skill */ $skill = $entityManager->find('ChamiloCoreBundle:Skill', $_GET['id']); if (!$skill) { @@ -27,7 +28,7 @@ $skillInfo = [ 'short_code' => $skill->getShortCode(), 'description' => $skill->getDescription(), 'criteria' => $skill->getCriteria(), - 'badge_image' => $skill->getWebIconPath(), + 'badge_image' => Skill::getWebIconPath($skill), ]; $template = new Template(); diff --git a/main/badge/issued.php b/main/badge/issued.php index e4a7037173..df9962150e 100644 --- a/main/badge/issued.php +++ b/main/badge/issued.php @@ -3,6 +3,7 @@ use Chamilo\CoreBundle\Entity\SkillRelUser; use Chamilo\CoreBundle\Entity\SkillRelUserComment; +use SkillRelUser as SkillRelUserManager; /** * Show information about the issued badge. @@ -63,7 +64,7 @@ $skillInfo = [ 'short_code' => $skill->getShortCode(), 'description' => $skill->getDescription(), 'criteria' => $skill->getCriteria(), - 'badge_image' => $skill->getWebIconPath(), + 'badge_image' => Skill::getWebIconPath($skill), 'courses' => [], ]; @@ -102,12 +103,12 @@ $skillIssueInfo = [ 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_id' => $skillIssue->getSkill()->getId(), - 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), + 'skill_badge_image' => Skill::getWebIconPath($skillIssue->getSkill()), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), - 'badge_assertion' => $skillIssue->getAssertionUrl(), + 'badge_assertion' => SkillRelUserManager::getAssertionUrl($skillIssue), 'comments' => [], 'feedback_average' => $skillIssue->getAverage(), ]; @@ -120,7 +121,6 @@ $skillId = $skillIssueInfo['skill_id']; /** @var SkillRelUserComment $comment */ foreach ($skillIssueComments as $comment) { $commentDate = api_get_local_time($comment->getFeedbackDateTime()); - $skillIssueInfo['comments'][] = [ 'text' => $comment->getFeedbackText(), 'value' => $comment->getFeedbackValue(), @@ -157,7 +157,6 @@ if (!$profile) { if ($profile) { $profileId = $profile->getId(); - $levels = $skillLevelRepo->findBy([ 'profile' => $profileId, ]); @@ -168,7 +167,6 @@ if ($profile) { } ksort($profileLevels); // Sort the array by Position. - foreach ($profileLevels as $profileLevel) { $profileId = key($profileLevel); $acquiredLevel[$profileId] = $profileLevel[$profileId]; @@ -193,7 +191,7 @@ if ($showLevels && $allowToEdit) { $entityManager->flush(); Display::addFlash(Display::return_message(get_lang('Saved'))); - header("Location: ".$skillIssue->getIssueUrl()); + header('Location: '.SkillRelUserManager::getIssueUrl($skillIssue)); exit; } } @@ -226,7 +224,7 @@ if ($form->validate() && $allowComment && $allowToEdit) { $entityManager->flush(); Display::addFlash(Display::return_message(get_lang('Added'))); - header("Location: ".$skillIssue->getIssueUrl()); + header('Location: '.SkillRelUserManager::getIssueUrl($skillIssue)); exit; } diff --git a/main/badge/issued_all.php b/main/badge/issued_all.php index 6f4819a0aa..a1e17f0bde 100644 --- a/main/badge/issued_all.php +++ b/main/badge/issued_all.php @@ -4,6 +4,7 @@ use Chamilo\CoreBundle\Entity\SkillRelUser; use Chamilo\CoreBundle\Entity\SkillRelUserComment; use Chamilo\UserBundle\Entity\User; +use SkillRelUser as SkillRelUserManager; /** * Show information about all issued badges with same skill by user. @@ -14,8 +15,8 @@ use Chamilo\UserBundle\Entity\User; */ require_once __DIR__.'/../inc/global.inc.php'; -$userId = isset($_GET['user']) ? intval($_GET['user']) : 0; -$skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0; +$userId = isset($_GET['user']) ? (int) $_GET['user'] : 0; +$skillId = isset($_GET['skill']) ? (int) $_GET['skill'] : 0; if (!$userId || !$skillId) { api_not_allowed(true); @@ -26,7 +27,6 @@ Skill::isAllowed($userId); $em = Database::getManager(); $user = api_get_user_entity($userId); $skill = $em->find('ChamiloCoreBundle:Skill', $skillId); - $currentUserId = api_get_user_id(); if (!$user || !$skill) { @@ -58,7 +58,7 @@ $skillInfo = [ 'short_code' => $skill->getShortCode(), 'description' => $skill->getDescription(), 'criteria' => $skill->getCriteria(), - 'badge_image' => $skill->getWebIconPath(), + 'badge_image' => Skill::getWebIconPath($skill), 'courses' => [], ]; @@ -80,18 +80,21 @@ foreach ($userSkills as $index => $skillIssue) { 'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT), 'acquired_level' => $currentSkillLevel, 'argumentation_author_id' => $skillIssue->getArgumentationAuthorId(), - 'argumentation_author_name' => api_get_person_name($argumentationAuthor['firstname'], $argumentationAuthor['lastname']), + 'argumentation_author_name' => api_get_person_name( + $argumentationAuthor['firstname'], + $argumentationAuthor['lastname'] + ), 'argumentation' => $skillIssue->getArgumentation(), 'source_name' => $skillIssue->getSourceName(), 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_id' => $skillIssue->getSkill()->getId(), - 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), + 'skill_badge_image' => Skill::getWebIconPath($skillIssue->getSkill()), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), - 'badge_assertion' => $skillIssue->getAssertionUrl(), + 'badge_assertion' => SkillRelUserManager::getAssertionUrl($skillIssue), 'comments' => [], 'feedback_average' => $skillIssue->getAverage(), ]; @@ -156,7 +159,7 @@ foreach ($userSkills as $index => $skillIssue) { $formAcquiredLevel = new FormValidator( 'acquired_level'.$skillIssue->getId(), 'post', - $skillIssue->getIssueUrlAll() + SkillRelUserManager::getIssueUrlAll($skillIssue) ); $formAcquiredLevel->addSelect('acquired_level', get_lang('AcquiredLevel'), $acquiredLevel); $formAcquiredLevel->addHidden('user', $skillIssue->getUser()->getId()); @@ -172,14 +175,14 @@ foreach ($userSkills as $index => $skillIssue) { $em->persist($skillIssue); $em->flush(); - header("Location: ".$skillIssue->getIssueUrlAll()); + header('Location: '.SkillRelUserManager::getIssueUrlAll($skillIssue)); exit; } $form = new FormValidator( 'comment'.$skillIssue->getId(), 'post', - $skillIssue->getIssueUrlAll() + SkillRelUserManager::getIssueUrlAll($skillIssue) ); $form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]); $form->applyFilter('comment', 'trim'); @@ -207,7 +210,7 @@ foreach ($userSkills as $index => $skillIssue) { $em->persist($skillUserComment); $em->flush(); - header("Location: ".$skillIssue->getIssueUrlAll()); + header('Location: '.SkillRelUserManager::getIssueUrlAll($skillIssue)); exit; } diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 84776ce7b9..edf5a50432 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -114,13 +114,11 @@ if ($allowToEdit) { $sendEmail = isset($values['add_announcement']) ? true : false; $allDay = isset($values['all_day']) ? 'true' : 'false'; - $sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false; $attachmentList = $sendAttachment ? $_FILES : null; $attachmentCommentList = isset($values['legend']) ? $values['legend'] : null; $comment = isset($values['comment']) ? $values['comment'] : null; $usersToSend = isset($values['users_to_send']) ? $values['users_to_send'] : ''; - $startDate = $values['date_range_start']; $endDate = $values['date_range_end']; @@ -185,12 +183,10 @@ if ($allowToEdit) { $sendAttachment = isset($_FILES) && !empty($_FILES) ? true : false; $attachmentList = $sendAttachment ? $_FILES : null; - $attachmentCommentList = isset($values['legend']) ? $values['legend'] : null; - - $comment = isset($values['comment']) ? $values['comment'] : null; + $attachmentCommentList = isset($values['legend']) ? $values['legend'] : ''; + $comment = isset($values['comment']) ? $values['comment'] : ''; // This is a sub event. Delete the current and create another BT#7803 - if (!empty($event['parent_event_id'])) { $agenda->deleteEvent($eventId); diff --git a/main/calendar/agenda_list.php b/main/calendar/agenda_list.php index 74798a7d99..2693d4459a 100755 --- a/main/calendar/agenda_list.php +++ b/main/calendar/agenda_list.php @@ -6,17 +6,19 @@ */ require_once __DIR__.'/../inc/global.inc.php'; +$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; + $interbreadcrumb[] = [ - 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php', + 'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type='.Security::remove_XSS($type), 'name' => get_lang('Agenda'), ]; $currentCourseId = api_get_course_int_id(); -$currentGroupdId = api_get_group_id(); +$groupId = api_get_group_id(); -if (!empty($currentGroupdId)) { - $groupProperties = GroupManager::get_group_properties($currentGroupdId); - $currentGroupdId = $groupProperties['iid']; +if (!empty($groupId)) { + $groupProperties = GroupManager::get_group_properties($groupId); + $groupId = $groupProperties['iid']; $interbreadcrumb[] = [ "url" => api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(), "name" => get_lang('Groups'), @@ -33,7 +35,7 @@ $events = $agenda->getEvents( null, null, $currentCourseId, - $currentGroupdId, + $groupId, null, 'array' ); diff --git a/main/course_description/course_description_controller.php b/main/course_description/course_description_controller.php index e56d007d1d..1ba3652585 100644 --- a/main/course_description/course_description_controller.php +++ b/main/course_description/course_description_controller.php @@ -52,13 +52,29 @@ class CourseDescriptionController $data['descriptions'] = [$data['descriptions']]; } - foreach ($data['descriptions'] as $description) { + // Prepare confirmation code for item deletion + global $htmlHeadXtra; + $htmlHeadXtra[] = ""; + + foreach ($data['descriptions'] as $id => $description) { if (!empty($description['content']) && strpos($description['content'], 'update_category_delete($_course['sysCode']); // DELETE CONFIRMATION MESSAGE Session::erase('_cid'); diff --git a/main/course_info/infocours.php b/main/course_info/infocours.php index 1a751cc3a1..41c66ed35a 100755 --- a/main/course_info/infocours.php +++ b/main/course_info/infocours.php @@ -7,11 +7,11 @@ * * See ./inc/conf/course_info.conf.php for settings * - * @todo Take those config settings into account in this script + * @todo Take those config settings into account in this script * - * @author Patrick Cool - * @author Roan Embrechts, refactoring and improved course visibility|subscribe|unsubscribe options - * @author Julio Montoya Jquery support + lots of fixes + * @author Patrick Cool + * @author Roan Embrechts, refactoring and improved course visibility|subscribe|unsubscribe options + * @author Julio Montoya Jquery support + lots of fixes * * @package chamilo.course_info */ @@ -28,7 +28,7 @@ define('MODULE_HELP_NAME', 'Settings'); define('COURSE_CHANGE_PROPERTIES', 'COURSE_CHANGE_PROPERTIES'); $currentCourseRepository = $_course['path']; -$is_allowedToEdit = $is_courseAdmin || $is_platformAdmin; +$is_allowedToEdit = api_is_course_admin() || api_is_platform_admin(); $course_code = api_get_course_id(); $courseId = api_get_course_int_id(); @@ -52,9 +52,7 @@ if (api_get_setting('pdf_export_watermark_by_course') == 'true') { } } -$categories = CourseCategory::getCategoriesCanBeAddedInCourse( - $_course['categoryCode'] -); +$categories = CourseCategory::getCategoriesCanBeAddedInCourse($_course['categoryCode']); // Build the form $form = new FormValidator( @@ -119,7 +117,7 @@ $group = [ $form->createElement('radio', 'show_course_in_user_language', null, get_lang('No'), 2), ]; -$form->addGroup($group, '', [get_lang("ShowCourseInUserLanguage")]); +$form->addGroup($group, '', [get_lang('ShowCourseInUserLanguage')]); $form->addText('department_name', get_lang('Department'), false); $form->applyFilter('department_name', 'html_filter'); @@ -128,6 +126,30 @@ $form->applyFilter('department_name', 'trim'); $form->addText('department_url', get_lang('DepartmentUrl'), false); $form->applyFilter('department_url', 'html_filter'); +// Extra fields +$extra_field = new ExtraField('course'); + +$extraFieldAdminPermissions = false; +$showOnlyTheseFields = ['tags', 'video_url', 'course_hours_duration']; +$extra = $extra_field->addElements( + $form, + $courseId, + [], + false, + false, + $showOnlyTheseFields, + [], + false +); + +//Tags ExtraField +$htmlHeadXtra[] = ' +'; + // Picture $form->addFile( 'picture', @@ -171,7 +193,7 @@ if (api_get_setting('allow_course_theme') == 'true') { null, ['id' => 'course_theme_id'] ); - $form->addGroup($group, '', [get_lang("Stylesheets")]); + $form->addGroup($group, '', [get_lang('Stylesheets')]); } $form->addElement('label', get_lang('DocumentQuota'), format_file_size(DocumentManager::get_course_quota())); @@ -193,34 +215,11 @@ $form->addHtml(' $form->addHtml(''); // COURSE ACCESS -$form->addHtml('
'); -$form->addHtml(' - -'); - -$form->addHtml(' -
-
-'); - $group = []; $group[] = $form->createElement( 'radio', 'visibility', - get_lang("CourseAccess"), + get_lang('CourseAccess'), get_lang('OpenToTheWorld'), COURSE_VISIBILITY_OPEN_WORLD ); @@ -239,6 +238,7 @@ $group[] = $form->createElement( get_lang('CourseVisibilityClosed'), COURSE_VISIBILITY_CLOSED ); + // The "hidden" visibility is only available to portal admins if (api_is_platform_admin()) { $group[] = $form->createElement( @@ -249,79 +249,86 @@ if (api_is_platform_admin()) { COURSE_VISIBILITY_HIDDEN ); } -$form->addGroup($group, '', [get_lang("CourseAccess"), get_lang("CourseAccessConfigTip")]); + +$groupElement = $form->addGroup( + $group, + '', + [get_lang('CourseAccess'), get_lang('CourseAccessConfigTip')], + null, + null, + true +); $url = api_get_path(WEB_CODE_PATH)."auth/inscription.php?c=$course_code&e=1"; $url = Display::url($url, $url); -$form->addElement('label', get_lang('DirectLink'), sprintf(get_lang('CourseSettingsRegisterDirectLink'), $url)); +$label = $form->addLabel(get_lang('DirectLink'), sprintf(get_lang('CourseSettingsRegisterDirectLink'), $url), true); -$group = []; -$group[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1); -$group[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0); -$form->addGroup($group, '', [get_lang("Subscription")]); +$group2 = []; +$group2[] = $form->createElement('radio', 'subscribe', get_lang('Subscription'), get_lang('Allowed'), 1); +$group2[] = $form->createElement('radio', 'subscribe', null, get_lang('Denied'), 0); -$group = []; -$group[] = $form->createElement( +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); + +$group3[] = $form->createElement( 'radio', 'unsubscribe', get_lang('Unsubscription'), get_lang('AllowedToUnsubscribe'), 1 ); -$group[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0); -$form->addGroup($group, '', [get_lang("Unsubscription")]); - -$form->addText('course_registration_password', get_lang('CourseRegistrationPassword'), false, ['size' => '60']); +$group3[] = $form->createElement('radio', 'unsubscribe', null, get_lang('NotAllowedToUnsubscribe'), 0); + +$text = $form->createElement( + 'text', + 'course_registration_password', + get_lang('CourseRegistrationPassword'), + false, + ['size' => '60'] +); -$form->addElement( +$checkBoxActiveLegal = $form->createElement( 'checkbox', 'activate_legal', [null, get_lang('ShowALegalNoticeWhenEnteringTheCourse')], get_lang('ActivateLegal') ); -$form->addElement('textarea', 'legal', get_lang('CourseLegalAgreement'), ['rows' => 8]); -$form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); - -$form->addHtml(' -
-
-'); -$form->addHtml('
'); +$textAreaLegal = $form->createElement('textarea', 'legal', get_lang('CourseLegalAgreement'), ['rows' => 8]); + +$elements = [ + $groupElement, + $label, + get_lang('Subscription') => $group2, + get_lang('Unsubscription') => $group3, + $text, + $checkBoxActiveLegal, + $textAreaLegal, + $myButton, +]; -// Documents -$form->addHtml('
'); -$form->addHtml(' - - '); -$form->addHtml(' -
-
-'); +// Documents +$globalGroup = []; if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') { $group = [ $form->createElement('radio', 'documents_default_visibility', null, get_lang('Visible'), 'visible'), $form->createElement('radio', 'documents_default_visibility', null, get_lang('Invisible'), 'invisible'), ]; - $form->addGroup($group, '', [get_lang('DocumentsDefaultVisibility')]); + $globalGroup[get_lang('DocumentsDefaultVisibility')] = $group; } $group = [ $form->createElement('radio', 'show_system_folders', null, get_lang('Yes'), 1), $form->createElement('radio', 'show_system_folders', null, get_lang('No'), 2), ]; -$form->addGroup($group, '', [get_lang('ShowSystemFolders')]); + +$globalGroup[get_lang('ShowSystemFolders')] = $group; + +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); $group = []; $group[] = $form->createElement( @@ -332,14 +339,15 @@ $group[] = $form->createElement( 1 ); $group[] = $form->createElement('radio', 'enable_document_auto_launch', null, get_lang('Deactivate'), 0); -$form->addGroup($group, '', [get_lang('DocumentAutoLaunch')]); +$globalGroup[get_lang('DocumentAutoLaunch')] = $group; -$form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); -$form->addHtml(' -
-
-'); -$form->addHtml('
'); +$globalGroup[] = $myButton; + +$form->addPanelOption( + 'documents', + Display::return_icon('folder.png', get_lang('Documents')).' '.get_lang('Documents'), + $globalGroup +); // EMAIL NOTIFICATIONS $form->addHtml('
'); @@ -498,26 +506,6 @@ $form->addHtml(' '); $form->addHtml('
'); -// USER RIGHTS -$form->addHtml('
'); -$form->addHtml(' - -'); -$form->addHtml(' -
-
-'); $group = []; $group[] = $form->createElement( @@ -528,80 +516,64 @@ $group[] = $form->createElement( 1 ); $group[] = $form->createElement('radio', 'allow_user_edit_agenda', null, get_lang('AllowUserEditAgendaDeactivate'), 0); -$form->addGroup($group, '', [get_lang("AllowUserEditAgenda")]); -$group = []; -$group[] = $form->createElement( +$group2 = []; +$group2[] = $form->createElement( 'radio', 'allow_user_edit_announcement', get_lang('AllowUserEditAnnouncement'), get_lang('AllowUserEditAnnouncementActivate'), 1 ); -$group[] = $form->createElement( +$group2[] = $form->createElement( 'radio', 'allow_user_edit_announcement', null, get_lang('AllowUserEditAnnouncementDeactivate'), 0 ); -$form->addGroup($group, '', [get_lang("AllowUserEditAnnouncement")]); -$group = []; -$group[] = $form->createElement( +$group3 = []; +$group3[] = $form->createElement( 'radio', 'allow_user_image_forum', get_lang('AllowUserImageForum'), get_lang('AllowUserImageForumActivate'), 1 ); -$group[] = $form->createElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0); -$form->addGroup($group, '', [get_lang("AllowUserImageForum")]); +$group3[] = $form->createElement('radio', 'allow_user_image_forum', null, get_lang('AllowUserImageForumDeactivate'), 0); -$group = []; -$group[] = $form->createElement( +$group4 = []; +$group4[] = $form->createElement( 'radio', 'allow_user_view_user_list', get_lang('AllowUserViewUserList'), get_lang('AllowUserViewUserListActivate'), 1 ); -$group[] = $form->createElement( +$group4[] = $form->createElement( 'radio', 'allow_user_view_user_list', null, get_lang('AllowUserViewUserListDeactivate'), 0 ); -$form->addGroup($group, '', [get_lang("AllowUserViewUserList")]); -$form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); -$form->addHtml(' -
-
-'); -$form->addHtml('
'); - +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); + +$globalGroup = [ + get_lang('AllowUserEditAgenda') => $group, + get_lang('AllowUserEditAnnouncement') => $group2, + get_lang('AllowUserImageForum') => $group3, + get_lang('AllowUserViewUserList') => $group4, + '' => $myButton, +]; // CHAT SETTINGS -$form->addHtml('
'); -$form->addHtml(' - -'); -$form->addHtml(' -
-
-'); + $group = []; $group[] = $form->createElement( @@ -612,14 +584,18 @@ $group[] = $form->createElement( 1 ); $group[] = $form->createElement('radio', 'allow_open_chat_window', null, get_lang('AllowOpenChatWindowDeactivate'), 0); -$form->addGroup($group, '', [get_lang("AllowOpenchatWindow")]); -$form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); -$form->addHtml(' -
-
-'); -$form->addHtml('
'); +$globalGroup = [ + get_lang('AllowOpenchatWindow') => $group, + '' => $myButton, +]; + +$form->addPanelOption( + 'chat', + Display::return_icon('chat.png', get_lang('ConfigChat'), '', ICON_SIZE_SMALL).' '.get_lang('ConfigChat'), + $globalGroup +); // LEARNING PATH $form->addHtml('
'); @@ -809,32 +785,6 @@ if (api_get_configuration_value('allow_exercise_auto_launch')) { $form->addHtml('
'); } -// THEMATIC ADVANCE SETTINGS -$form->addHtml('
'); -$form->addHtml(' - -'); -$form->addHtml(' -
-
-'); $group = []; $group[] = $form->createElement( @@ -865,37 +815,26 @@ $group[] = $form->createElement( get_lang('DoNotDisplayAnyAdvance'), 0 ); -$form->addGroup($group, '', [get_lang("InfoAboutAdvanceInsideHomeCourse")]); -$form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); -$form->addHtml(' -
-
-'); -$form->addHtml('
'); +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); +$globalGroup = [ + get_lang('InfoAboutAdvanceInsideHomeCourse') => $group, + '' => $myButton, +]; // Certificate settings -if (api_get_setting('allow_public_certificates') == 'true') { - $form->addHtml('
'); - $form->addHtml(' - - '); - $form->addHtml(' -
-
- '); +$form->addPanelOption( + 'thematic', + Display::return_icon( + 'course_progress.png', + get_lang('ThematicAdvanceConfiguration') + ) + .' ' + .get_lang('ThematicAdvanceConfiguration'), + $globalGroup +); +// Certificate settings +if (api_get_setting('allow_public_certificates') === 'true') { $group = []; $group[] = $form->createElement( 'radio', @@ -905,47 +844,60 @@ if (api_get_setting('allow_public_certificates') == 'true') { 1 ); $group[] = $form->createElement('radio', 'allow_public_certificates', null, get_lang('No'), 0); - $form->addGroup($group, '', [get_lang('AllowPublicCertificates')]); - $form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); - $form->addHtml(' -
-
- '); - $form->addHtml('
'); + $myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); + + $globalGroup = [ + get_lang('AllowPublicCertificates') => $group, + '' => $myButton, + ]; + + $form->addPanelOption( + 'certificate', + Display::return_icon('certificate.png', get_lang('Certificates')).' '.get_lang('Certificates'), + $globalGroup + ); } -// Forum settings -$form->addHtml('
'); -$form->addHtml(' - -'); -$form->addHtml(' -
-
-'); $group = [ $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('RedirectToForumList'), 1), $form->createElement('radio', 'enable_forum_auto_launch', null, get_lang('Disabled'), 2), ]; -$form->addGroup($group, '', [get_lang('EnableForumAutoLaunch')]); -$form->addButtonSave(get_lang('SaveSettings'), 'submit_save'); -$form->addHtml(' -
-
-'); -$form->addHtml('
'); +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); + +$globalGroup = [ + get_lang('EnableForumAutoLaunch') => $group, + '' => $myButton, +]; + +$form->addPanelOption( + 'forum', + Display::return_icon('forum.png', get_lang('Forum')).' '.get_lang('Forum'), + $globalGroup +); + +// Student publication +$group = [ + $form->createElement('radio', 'show_score', null, get_lang('NewVisible'), 0), + $form->createElement('radio', 'show_score', null, get_lang('NewUnvisible'), 1), +]; +$group2 = [ + $form->createElement('radio', 'student_delete_own_publication', null, get_lang('Yes'), 1), + $form->createElement('radio', 'student_delete_own_publication', null, get_lang('No'), 0), +]; +$myButton = $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true); + +$globalGroup = [ + get_lang('DefaultUpload') => $group, + get_lang('StudentAllowedToDeleteOwnPublication') => $group2, + '' => $myButton, +]; + +$form->addPanelOption( + 'student-publication', + Display::return_icon('work.png', get_lang('StudentPublications')).' '.get_lang('StudentPublications'), + $globalGroup +); // Plugin course settings $appPlugin = new AppPlugin(); @@ -969,6 +921,7 @@ $values['unsubscribe'] = $_course['unsubscribe']; $values['course_registration_password'] = $all_course_information['registration_code']; $values['legal'] = $all_course_information['legal']; $values['activate_legal'] = $all_course_information['activate_legal']; +$values['show_score'] = $all_course_information['show_score']; $courseSettings = CourseManager::getCourseSettingVariables($appPlugin); @@ -978,6 +931,10 @@ foreach ($courseSettings as $setting) { $values[$setting] = $result; } } +// make sure new settings have a clear default value +if (!isset($values['student_delete_own_publication'])) { + $values['student_delete_own_publication'] = 0; +} $form->setDefaults($values); // Validate form @@ -1042,22 +999,6 @@ if ($form->validate() && is_settings_editable()) { unset($updateValues['pdf_export_watermark_path']); } - // Variables that will be saved in the TABLE_MAIN_COURSE table - $update_in_course_table = [ - 'title', - 'course_language', - 'category_code', - 'department_name', - 'department_url', - 'visibility', - 'subscribe', - 'unsubscribe', - 'tutor_name', - 'course_registration_password', - 'legal', - 'activate_legal', - ]; - $activeLegal = isset($updateValues['activate_legal']) ? $updateValues['activate_legal'] : 0; $table_course = Database::get_main_table(TABLE_MAIN_COURSE); @@ -1073,6 +1014,7 @@ if ($form->validate() && is_settings_editable()) { 'legal' => $updateValues['legal'], 'activate_legal' => $activeLegal, 'registration_code' => $updateValues['course_registration_password'], + 'show_score' => $updateValues['show_score'], ]; Database::update($table_course, $params, ['id = ?' => $courseId]); @@ -1086,6 +1028,9 @@ if ($form->validate() && is_settings_editable()) { api_get_course_int_id() ); } + // update the extra fields + $courseFieldValue = new ExtraFieldValue('course'); + $courseFieldValue->saveFieldValues($updateValues); $appPlugin->saveCourseSettingsHook($updateValues); $courseParams = api_get_cidreq(); diff --git a/main/course_progress/index.php b/main/course_progress/index.php index 9a13af982f..8233a8187f 100755 --- a/main/course_progress/index.php +++ b/main/course_progress/index.php @@ -116,7 +116,7 @@ $htmlHeadXtra[] = '