Merge branch '1.11.x' into scrutinizer-patch-2

pull/2487/head
Julio Montoya 9 years ago committed by GitHub
commit 3f9839b86c
  1. 39
      main/course_progress/thematic.php
  2. 2
      main/course_progress/thematic_controller.php
  3. 39
      main/course_progress/thematic_plan.php
  4. 4
      main/inc/lib/agenda.lib.php

@ -20,16 +20,16 @@ if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">'; echo '<div class="actions">';
switch ($action) { switch ($action) {
case 'thematic_add' : case 'thematic_add':
case 'thematic_import_select' : case 'thematic_import_select':
echo '<a href="index.php?'.api_get_cidreq().'">'. echo '<a href="index.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ThematicDetails'),'',ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ThematicDetails'),'',ICON_SIZE_MEDIUM).'</a>';
break; break;
case 'thematic_list' : case 'thematic_list':
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'. echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
break; break;
case 'thematic_details' : case 'thematic_details':
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'. echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'. echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'.
@ -39,7 +39,7 @@ if (api_is_allowed_to_edit(null, true)) {
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export_pdf'.$url_token.'">'. echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export_pdf'.$url_token.'">'.
Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>';
break; break;
default : default:
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'. echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>'; Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
} }
@ -47,7 +47,6 @@ if (api_is_allowed_to_edit(null, true)) {
} }
if ($action == 'thematic_list') { if ($action == 'thematic_list') {
$table = new SortableTable( $table = new SortableTable(
'thematic_list', 'thematic_list',
array('Thematic', 'get_number_of_thematics'), array('Thematic', 'get_number_of_thematics'),
@ -57,15 +56,19 @@ if ($action == 'thematic_list') {
$parameters['action'] = $action; $parameters['action'] = $action;
$table->set_additional_parameters($parameters); $table->set_additional_parameters($parameters);
$table->set_header(0, '', false, array('style'=>'width:20px;')); $table->set_header(0, '', false, array('style'=>'width:20px;'));
$table->set_header(1, get_lang('Title'), false ); $table->set_header(1, get_lang('Title'), false);
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$table->set_header(2, get_lang('Actions'), false,array('style'=>'text-align:center;width:40%;')); $table->set_header(
2,
get_lang('Actions'),
false,
array('style' => 'text-align:center;width:40%;')
);
$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics'))); $table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));
} }
$table->display(); $table->display();
} elseif ($action == 'thematic_details') { } elseif ($action == 'thematic_details') {
if (isset($_GET['thematic_plan_save_message']) && $_GET['thematic_plan_save_message'] == 'ok') { if (isset($_GET['thematic_plan_save_message']) && $_GET['thematic_plan_save_message'] == 'ok') {
Display::display_confirmation_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull')); Display::display_confirmation_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
} }
@ -93,7 +96,6 @@ if ($action == 'thematic_list') {
// Display thematic data // Display thematic data
if (!empty($thematic_data)) { if (!empty($thematic_data)) {
// display progress // display progress
echo '<div style="text-align:right;"><h2>'.get_lang('Progress').': <span id="div_result">'.$total_average_of_advances.'</span> %</h2></div>'; echo '<div style="text-align:right;"><h2>'.get_lang('Progress').': <span id="div_result">'.$total_average_of_advances.'</span> %</h2></div>';
echo '<table width="100%" class="data_table">'; echo '<table width="100%" class="data_table">';
@ -113,12 +115,11 @@ if ($action == 'thematic_list') {
$actions_first_col = ''; $actions_first_col = '';
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
// Thematic title // Thematic title
$actions_first_col = Display::url( $actions_first_col = Display::url(
Display::return_icon('cd.gif', get_lang('Copy')), Display::return_icon('cd.gif', get_lang('Copy')),
'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$params.$url_token 'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$params.$url_token
); );
if (api_get_session_id() == 0 ) { if (api_get_session_id() == 0 ) {
if ($thematic['display_order'] > 1) { if ($thematic['display_order'] > 1) {
$actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>'; $actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>';
} else { } else {
@ -129,7 +130,6 @@ if ($action == 'thematic_list') {
} else { } else {
$actions_first_col .= ' '.Display::return_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL); $actions_first_col .= ' '.Display::return_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
} }
} }
if (api_get_session_id() == $thematic['session_id']) { if (api_get_session_id() == $thematic['session_id']) {
$actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'; $actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
@ -143,9 +143,7 @@ if ($action == 'thematic_list') {
echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content')); echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content'));
// Display 2nd column - thematic plan data // Display 2nd column - thematic plan data
echo '<td>'; echo '<td>';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) { //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'&width=700&height=500">'. echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'&width=700&height=500">'.
@ -172,7 +170,6 @@ if ($action == 'thematic_list') {
if (!empty($thematic_advance_data[$thematic['id']])) { if (!empty($thematic_advance_data[$thematic['id']])) {
echo '<table width="100%">'; echo '<table width="100%">';
foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) { foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
$thematic_advance['start_date'] = api_get_local_time($thematic_advance['start_date']); $thematic_advance['start_date'] = api_get_local_time($thematic_advance['start_date']);
$thematic_advance['start_date'] = api_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG); $thematic_advance['start_date'] = api_format_date($thematic_advance['start_date'], DATE_TIME_FORMAT_LONG);
echo '<tr>'; echo '<tr>';
@ -193,17 +190,17 @@ if ($action == 'thematic_list') {
'thematic_advance_id' => $thematic_advance['id'] 'thematic_advance_id' => $thematic_advance['id']
]) ])
); );
$edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'. $edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>'; Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
//Links // Links
$edit_link = Display::div( $edit_link = Display::div(
Display::div($edit_link , array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')), Display::div($edit_link, array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')),
array('style'=>'height:20px;') array('style'=>'height:20px;')
); );
} }
$thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null; $thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id'])); echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
echo $edit_link; echo $edit_link;
echo '</td>'; echo '</td>';
@ -246,10 +243,8 @@ if ($action == 'thematic_list') {
echo '<div><em>'.get_lang('ThereIsNoAThematicSection').'</em></div>'; echo '<div><em>'.get_lang('ThereIsNoAThematicSection').'</em></div>';
} }
} elseif ($action == 'thematic_add' || $action == 'thematic_edit') { } elseif ($action == 'thematic_add' || $action == 'thematic_edit') {
// Display form // Display form
$form = new FormValidator('thematic_add','POST','index.php?action=thematic_add&'.api_get_cidreq()); $form = new FormValidator('thematic_add','POST','index.php?action=thematic_add&'.api_get_cidreq());
if ($action == 'thematic_edit') { if ($action == 'thematic_edit') {
$form->addElement('header', '', get_lang('EditThematicSection')); $form->addElement('header', '', get_lang('EditThematicSection'));
} }

@ -49,7 +49,6 @@ class ThematicController
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (trim($_POST['title']) !== '') { if (trim($_POST['title']) !== '') {
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
$id = isset($_POST['thematic_id']) ? $_POST['thematic_id'] : null; $id = isset($_POST['thematic_id']) ? $_POST['thematic_id'] : null;
$title = trim($_POST['title']); $title = trim($_POST['title']);
$content = trim($_POST['content']); $content = trim($_POST['content']);
@ -121,7 +120,6 @@ class ThematicController
// Import the progress. // Import the progress.
$current_thematic = null; $current_thematic = null;
foreach ($csv_import_array as $key => $item) { foreach ($csv_import_array as $key => $item) {
if (!$key) { if (!$key) {
continue; continue;

@ -10,9 +10,9 @@
// actions menu // actions menu
$new_thematic_plan_data = array(); $new_thematic_plan_data = array();
if (!empty($thematic_plan_data)) { if (!empty($thematic_plan_data)) {
foreach($thematic_plan_data as $thematic_item) { foreach ($thematic_plan_data as $thematic_item) {
$thematic_simple_list[] = $thematic_item['description_type']; $thematic_simple_list[] = $thematic_item['description_type'];
$new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item; $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
} }
} }
@ -57,21 +57,21 @@ if ($action === 'thematic_plan_list') {
$form->addElement('hidden', 'description_type['.$id.']', $id); $form->addElement('hidden', 'description_type['.$id.']', $id);
$form->addText("title[$id]", [get_lang('Title'), null, $btnDelete], false); $form->addText("title[$id]", [get_lang('Title'), null, $btnDelete], false);
$form->addHtmlEditor( $form->addHtmlEditor(
'description['.$id.']', 'description['.$id.']',
get_lang('Description'), get_lang('Description'),
false, false,
false, false,
array( array(
'ToolbarStartExpanded' => 'false', 'ToolbarStartExpanded' => 'false',
'ToolbarSet' => 'TrainingDescription', 'ToolbarSet' => 'TrainingDescription',
'Height' => '150' 'Height' => '150'
) )
); );
if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) { if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
$thematic_plan = $new_thematic_plan_data[$id]; $thematic_plan = $new_thematic_plan_data[$id];
// set default values // set default values
$default['title['.$id.']'] = $thematic_plan['title']; $default['title['.$id.']'] = $thematic_plan['title'];
$default['description['.$id.']'] = $thematic_plan['description']; $default['description['.$id.']'] = $thematic_plan['description'];
$thematic_plan = null; $thematic_plan = null;
} else { } else {
@ -82,7 +82,16 @@ if ($action === 'thematic_plan_list') {
$form->setDefaults($default); $form->setDefaults($default);
} }
$form->addGroup([ $form->addGroup([
$form->addButton('add_item', get_lang('SaveAndAddNewItem'), 'plus', 'info', 'default', null, [], true), $form->addButton(
'add_item',
get_lang('SaveAndAddNewItem'),
'plus',
'info',
'default',
null,
[],
true
),
$form->addButtonSave(get_lang('Save'), 'submit', true) $form->addButtonSave(get_lang('Save'), 'submit', true)
]); ]);
$form->display(); $form->display();
@ -125,7 +134,7 @@ if ($action === 'thematic_plan_list') {
'ToolbarStartExpanded' => 'false', 'ToolbarStartExpanded' => 'false',
'ToolbarSet' => 'TrainingDescription', 'ToolbarSet' => 'TrainingDescription',
'Width' => '80%', 'Width' => '80%',
'Height' => '150', 'Height' => '150'
) )
); );
$form->addButtonSave(get_lang('Save')); $form->addButtonSave(get_lang('Save'));

@ -677,7 +677,7 @@ class Agenda
* @param bool $updateContent * @param bool $updateContent
* @param int $authorId * @param int $authorId
* *
* @return null|false * @return bool
*/ */
public function editEvent( public function editEvent(
$id, $id,
@ -1379,7 +1379,7 @@ class Agenda
/** /**
* Gets a single event * Gets a single event
* *
* @param int event id * @param int $id event id
* @return array * @return array
*/ */
public function get_event($id) public function get_event($id)

Loading…
Cancel
Save