Minor - format code, use ChamiloSession class, fix function name

pull/2487/head
jmontoyaa 8 years ago
parent 9b88719e4b
commit 71693df6e7
  1. 3
      main/inc/lib/api.lib.php
  2. 77
      main/notebook/index.php
  3. 4
      plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php

@ -8221,6 +8221,9 @@ function api_protect_limit_for_session_admin()
} }
} }
/**
* @return bool
*/
function api_is_student_view_active() function api_is_student_view_active()
{ {
$studentView = Session::read('studentview'); $studentView = Session::read('studentview');

@ -1,5 +1,8 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/** /**
* @package chamilo.notebook * @package chamilo.notebook
* @author Christian Fasanando, initial version * @author Christian Fasanando, initial version
@ -39,11 +42,17 @@ $action = isset($_GET['action']) ? $_GET['action'] : '';
// Tool name // Tool name
if ($action === 'addnote') { if ($action === 'addnote') {
$tool = 'NoteAddNew'; $tool = 'NoteAddNew';
$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook')); $interbreadcrumb[] = array(
'url' => 'index.php?'.api_get_cidreq(),
'name' => get_lang('ToolNotebook')
);
} }
if ($action === 'editnote') { if ($action === 'editnote') {
$tool = 'ModifyNote'; $tool = 'ModifyNote';
$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook')); $interbreadcrumb[] = array(
'url' => 'index.php?'.api_get_cidreq(),
'name' => get_lang('ToolNotebook')
);
} }
// Displaying the header // Displaying the header
@ -63,7 +72,7 @@ if ($action === 'addnote') {
exit; exit;
} }
$_SESSION['notebook_view'] = 'creation_date'; Session::write('notebook_view', 'creation_date');
$form = new FormValidator( $form = new FormValidator(
'note', 'note',
@ -99,7 +108,14 @@ if ($action === 'addnote') {
NotebookManager::display_notes(); NotebookManager::display_notes();
} else { } else {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="index.php">'.Display::return_icon('back.png', get_lang('BackToNotesList'), '', ICON_SIZE_MEDIUM).'</a>'; echo '<a href="index.php">'.
Display::return_icon(
'back.png',
get_lang('BackToNotesList'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
echo '</div>'; echo '</div>';
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
@ -124,7 +140,12 @@ if ($action === 'addnote') {
$form->addElement('header', '', get_lang('ModifyNote')); $form->addElement('header', '', get_lang('ModifyNote'));
$form->addElement('hidden', 'notebook_id'); $form->addElement('hidden', 'notebook_id');
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100')); $form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '100'));
$form->addElement('html_editor', 'note_comment', get_lang('NoteComment'), null, api_is_allowed_to_edit() $form->addElement(
'html_editor',
'note_comment',
get_lang('NoteComment'),
null,
api_is_allowed_to_edit()
? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300') ? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300')
: array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student') : array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student')
); );
@ -153,7 +174,13 @@ if ($action === 'addnote') {
} else { } else {
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="index.php">'. echo '<a href="index.php">'.
Display::return_icon('back.png', get_lang('BackToNotesList'), '', ICON_SIZE_MEDIUM).'</a>'; Display::return_icon(
'back.png',
get_lang('BackToNotesList'),
'',
ICON_SIZE_MEDIUM
).
'</a>';
echo '</div>'; echo '</div>';
$token = Security::get_token(); $token = Security::get_token();
$form->addElement('hidden', 'sec_token'); $form->addElement('hidden', 'sec_token');
@ -168,34 +195,52 @@ if ($action === 'addnote') {
} }
NotebookManager::display_notes(); NotebookManager::display_notes();
} elseif ( } elseif ($action === 'changeview' &&
$action === 'changeview' && in_array($_GET['view'], array('creation_date', 'update_date', 'title'))) { in_array($_GET['view'], array('creation_date', 'update_date', 'title'))
) {
// Action handling: changing the view (sorting order) // Action handling: changing the view (sorting order)
switch ($_GET['view']) { switch ($_GET['view']) {
case 'creation_date': case 'creation_date':
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') { if (!$_GET['direction'] || $_GET['direction'] == 'ASC') {
echo Display::return_message(get_lang('NotesSortedByCreationDateAsc'), 'confirmation'); echo Display::return_message(
get_lang('NotesSortedByCreationDateAsc'),
'confirmation'
);
} else { } else {
echo Display::return_message(get_lang('NotesSortedByCreationDateDESC'), 'confirmation'); echo Display::return_message(
get_lang('NotesSortedByCreationDateDESC'),
'confirmation'
);
} }
break; break;
case 'update_date': case 'update_date':
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') { if (!$_GET['direction'] || $_GET['direction'] == 'ASC') {
echo Display::return_message(get_lang('NotesSortedByUpdateDateAsc'), 'confirmation'); echo Display::return_message(
get_lang('NotesSortedByUpdateDateAsc'),
'confirmation'
);
} else { } else {
echo Display::return_message(get_lang('NotesSortedByUpdateDateDESC'), 'confirmation'); echo Display::return_message(
get_lang('NotesSortedByUpdateDateDESC'),
'confirmation'
);
} }
break; break;
case 'title': case 'title':
if (!$_GET['direction'] || $_GET['direction'] == 'ASC') { if (!$_GET['direction'] || $_GET['direction'] == 'ASC') {
echo Display::return_message(get_lang('NotesSortedByTitleAsc'), 'confirmation'); echo Display::return_message(
get_lang('NotesSortedByTitleAsc'),
'confirmation'
);
} else { } else {
echo Display::return_message(get_lang('NotesSortedByTitleDESC'), 'confirmation'); echo Display::return_message(
get_lang('NotesSortedByTitleDESC'),
'confirmation'
);
} }
break; break;
} }
$_SESSION['notebook_view'] = $_GET['view']; Session::write('notebook_view', $_GET['view']);
NotebookManager::display_notes(); NotebookManager::display_notes();
} else { } else {
NotebookManager::display_notes(); NotebookManager::display_notes();

@ -140,7 +140,7 @@ class BlockEvaluationGraph extends Block
$alllinks = $cats[0]->get_links(null, true); $alllinks = $cats[0]->get_links(null, true);
$users = GradebookUtils::get_all_users($alleval, $alllinks); $users = GradebookUtils::get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator($users, $alleval, $alllinks); $datagen = new FlatViewDataGenerator($users, $alleval, $alllinks);
$evaluation_sumary = $datagen->get_evaluation_sumary_results(); $evaluation_sumary = $datagen->getEvaluationSummaryResults();
if (!empty($evaluation_sumary)) { if (!empty($evaluation_sumary)) {
$items = array_keys($evaluation_sumary); $items = array_keys($evaluation_sumary);
$max = $min = $avg = array(); $max = $min = $avg = array();
@ -318,7 +318,7 @@ class BlockEvaluationGraph extends Block
$alllinks = $cats[0]->get_links(null, true); $alllinks = $cats[0]->get_links(null, true);
$users = GradebookUtils::get_all_users($alleval, $alllinks); $users = GradebookUtils::get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator($users, $alleval, $alllinks); $datagen = new FlatViewDataGenerator($users, $alleval, $alllinks);
$evaluation_sumary = $datagen->get_evaluation_sumary_results(); $evaluation_sumary = $datagen->getEvaluationSummaryResults();
if (!empty($evaluation_sumary)) { if (!empty($evaluation_sumary)) {
$items = array_keys($evaluation_sumary); $items = array_keys($evaluation_sumary);
$max = $min = $avg = array(); $max = $min = $avg = array();

Loading…
Cancel
Save