From c1e910447fc5e28d8728da96fa1c0f1db8cb8b6c Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 2 Jun 2016 15:53:53 +0200 Subject: [PATCH] Format code + add api_get_cidreq --- main/newscorm/lp_edit.php | 75 ++++++++++--------- main/newscorm/lp_edit_item.php | 4 - main/newscorm/lp_edit_item_prereq.php | 1 - main/newscorm/lp_final_item.php | 6 +- main/newscorm/lp_save.php | 3 - main/newscorm/lp_subscribe_users.php | 13 +++- .../lp_subscribe_users_to_category.php | 5 +- 7 files changed, 56 insertions(+), 51 deletions(-) diff --git a/main/newscorm/lp_edit.php b/main/newscorm/lp_edit.php index 96eef89838..30b343ab52 100755 --- a/main/newscorm/lp_edit.php +++ b/main/newscorm/lp_edit.php @@ -51,7 +51,7 @@ function activate_end_date() { $gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null; -$defaults=array(); +$defaults = array(); $form = new FormValidator('form1', 'post', 'lp_controller.php'); // Form title @@ -67,32 +67,14 @@ $form->addElement('hidden', 'lp_encoding'); $items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true); $form->addElement('select', 'category_id', get_lang('Category'), $items); -// Origin -/* -$origin_select = $form->addElement('select', 'lp_maker', get_lang('Origin')); -$lp_orig = $_SESSION['oLP']->get_maker(); - -include 'content_makers.inc.php'; -foreach ($content_origins as $origin) { - if ($lp_orig == $origin) { - $s_selected_origin = $origin; - } - $origin_select->addOption($origin, $origin); -} - -// Content proximity -$content_proximity_select = $form->addElement('select', 'lp_proximity', get_lang('ContentProximity')); -$lp_prox = $_SESSION['oLP']->get_proximity(); -if ($lp_prox != 'local') { - $s_selected_proximity = 'remote'; -} else { - $s_selected_proximity = 'local'; -} -$content_proximity_select->addOption(get_lang('Local'), 'local'); -$content_proximity_select->addOption(get_lang('Remote'), 'remote'); -*/ -//Hide toc frame -$hide_toc_frame = $form->addElement('checkbox', 'hide_toc_frame', null, get_lang('HideTocFrame'),array('onclick' => '$("#lp_layout_column").toggle()' )); +// Hide toc frame +$hide_toc_frame = $form->addElement( + 'checkbox', + 'hide_toc_frame', + null, + get_lang('HideTocFrame'), + array('onclick' => '$("#lp_layout_column").toggle()') +); if (api_get_setting('allow_course_theme') == 'true') { $mycourselptheme = api_get_course_setting('allow_learning_path_theme'); if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1) { @@ -106,13 +88,19 @@ if (api_get_setting('allow_course_theme') == 'true') { } // Author -$form->addElement('html_editor', 'lp_author', get_lang('Author'), array('size' => 80), array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px') ); +$form->addElement( + 'html_editor', + 'lp_author', + get_lang('Author'), + array('size' => 80), + array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px') +); $form->applyFilter('lp_author', 'html_filter'); // LP image $form->add_progress_bar(); if (strlen($_SESSION['oLP']->get_preview_image()) > 0) { - $show_preview_image='get_preview_image().'>'; + $show_preview_image = 'get_preview_image().'>'; $form->addElement('label', get_lang('ImagePreview'), $show_preview_image); $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); } @@ -126,7 +114,12 @@ if (api_get_setting('search_enabled') === 'true') { $specific_fields = get_specific_field_list(); foreach ($specific_fields as $specific_field) { $form -> addElement ('text', $specific_field['code'], $specific_field['name']); - $filter = array('c_id'=> "'". api_get_course_int_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $_SESSION['oLP']->lp_id, 'tool_id' => '\''. TOOL_LEARNPATH .'\''); + $filter = array( + 'c_id' => "'".api_get_course_int_id()."'", + 'field_id' => $specific_field['id'], + 'ref_id' => $_SESSION['oLP']->lp_id, + 'tool_id' => '\''.TOOL_LEARNPATH.'\'', + ); $values = get_specific_field_values_list($filter, array('value')); if (!empty($values)) { $arr_str_values = array(); @@ -156,7 +149,14 @@ $form->addElement('html',$items); $form->addElement('html', '
'.get_lang('LpPrerequisiteDescription').'
'); //Start date -$form->addElement('checkbox', 'activate_start_date_check', null,get_lang('EnableStartTime'), array('onclick' => 'activate_start_date()')); +$form->addElement( + 'checkbox', + 'activate_start_date_check', + null, + get_lang('EnableStartTime'), + array('onclick' => 'activate_start_date()') +); + $display_date = 'none'; if (!empty($publicated_on)) { $display_date = 'block'; @@ -168,7 +168,13 @@ $form->addDatePicker('publicated_on', get_lang('PublicationDate')); $form->addElement('html',''); //End date -$form->addElement('checkbox', 'activate_end_date_check', null, get_lang('EnableEndTime'), array('onclick' => 'activate_end_date()')); +$form->addElement( + 'checkbox', + 'activate_end_date_check', + null, + get_lang('EnableEndTime'), + array('onclick' => 'activate_end_date()') +); $display_date = 'none'; if (!empty($expired_on)) { $display_date = 'block'; @@ -210,8 +216,7 @@ if ($enableLpExtraFields) { $defaults['publicated_on'] = (!empty($publicated_on))? api_get_local_time($publicated_on) : date('Y-m-d 12:00:00'); -$defaults['expired_on'] = (!empty($expired_on) )? api_get_local_time($expired_on): date('Y-m-d 12:00:00',time()+84600); -//$defaults['max_attempts'] = $_SESSION['oLP']->get_max_attempts(); +$defaults['expired_on'] = (!empty($expired_on) )? api_get_local_time($expired_on): date('Y-m-d 12:00:00', time()+84600); $defaults['subscribe_users'] = $_SESSION['oLP']->getSubscribeUsers(); $form->setDefaults($defaults); @@ -225,7 +230,7 @@ if ($_SESSION['oLP']->get_hide_toc_frame() == 1) { echo '
'; $form -> display(); echo '
'; -} else{ +} else { echo '
'; $form -> display(); echo '
'; diff --git a/main/newscorm/lp_edit_item.php b/main/newscorm/lp_edit_item.php index 2506471c5d..861b7a40db 100755 --- a/main/newscorm/lp_edit_item.php +++ b/main/newscorm/lp_edit_item.php @@ -19,7 +19,6 @@ api_protect_course_script(); /* Libraries */ include 'learnpath_functions.inc.php'; -//include '../resourcelinker/resourcelinker.inc.php'; include 'resourcelinker.inc.php'; /* Header and action code */ @@ -160,9 +159,6 @@ $(document).ready(function() { build_action_menu(); echo '
'; diff --git a/main/newscorm/lp_edit_item_prereq.php b/main/newscorm/lp_edit_item_prereq.php index 2990854c1b..e501821e9b 100755 --- a/main/newscorm/lp_edit_item_prereq.php +++ b/main/newscorm/lp_edit_item_prereq.php @@ -16,7 +16,6 @@ api_protect_course_script(); /* Libraries */ include 'learnpath_functions.inc.php'; -//include '../resourcelinker/resourcelinker.inc.php'; include 'resourcelinker.inc.php'; /* Constants and variables */ diff --git a/main/newscorm/lp_final_item.php b/main/newscorm/lp_final_item.php index f85f4267f8..ba63d0612c 100644 --- a/main/newscorm/lp_final_item.php +++ b/main/newscorm/lp_final_item.php @@ -1,11 +1,11 @@ * @package chamilo.learnpath */ -// Initialize context $_in_course = true; require_once __DIR__ . '/../inc/global.inc.php'; @@ -44,8 +44,8 @@ $currentItemStatus = $currentItem->get_status(); $accessGranted = false; if ( - ($count - $completed == 0) or - ($count - $completed == 1 && ($currentItemStatus == 'incomplete') or ($currentItemStatus == 'not attempted')) + ($count - $completed == 0) || + ($count - $completed == 1 && ($currentItemStatus == 'incomplete') || ($currentItemStatus == 'not attempted')) ) { if ($lp->prerequisites_match($currentItemId)) { $accessGranted = true; diff --git a/main/newscorm/lp_save.php b/main/newscorm/lp_save.php index 72e9ac862b..d939b78c3e 100755 --- a/main/newscorm/lp_save.php +++ b/main/newscorm/lp_save.php @@ -9,9 +9,6 @@ /** * Initialization is to be done by lp_controller.php. - */ - -/** * Switching within the field to update */ diff --git a/main/newscorm/lp_subscribe_users.php b/main/newscorm/lp_subscribe_users.php index a5567b0f14..82f24f27f5 100644 --- a/main/newscorm/lp_subscribe_users.php +++ b/main/newscorm/lp_subscribe_users.php @@ -23,16 +23,21 @@ if (empty($lpId)) { $oLP = new learnpath(api_get_course_id(), $lpId, api_get_user_id()); -$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); -$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=".$oLP->get_id(), 'name' => $oLP->get_name()); +$interbreadcrumb[] = array( + 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(), + 'name' => get_lang('LearningPaths') +); + +$interbreadcrumb[] = array( + 'url' => api_get_self()."?action=build&lp_id=".$oLP->get_id().'&'.api_get_cidreq(), + 'name' => $oLP->get_name() +); $courseId = api_get_course_int_id(); $courseCode = api_get_course_id(); $url = api_get_self().'?'.api_get_cidreq().'&lp_id='.$lpId; - $lp = new \learnpath($courseCode, $lpId, api_get_user_id()); - $em = Database::getManager(); $session = null; diff --git a/main/newscorm/lp_subscribe_users_to_category.php b/main/newscorm/lp_subscribe_users_to_category.php index 1e0025c13d..8837d7b554 100644 --- a/main/newscorm/lp_subscribe_users_to_category.php +++ b/main/newscorm/lp_subscribe_users_to_category.php @@ -32,7 +32,10 @@ if (!$category) { api_not_allowed(true); } -$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); +$interbreadcrumb[] = array( + 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(), + 'name' => get_lang('LearningPaths') +); $interbreadcrumb[] = array('url' => '#', 'name' => $category->getName()); // Find course.