Fix time display + adding api_get_cidreq

pull/2487/head
jmontoyaa 9 years ago
parent 2223d36b25
commit 6d851da2ef
  1. 23
      main/inc/lib/notebook.lib.php
  2. 37
      main/notebook/index.php

@ -124,7 +124,7 @@ class NotebookManager
* @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
* @version januari 2009, dokeos 1.8.6
*/
static function update_note($values)
public static function update_note($values)
{
if (!is_array($values) or empty($values['note_title'])) {
return false;
@ -141,7 +141,7 @@ class NotebookManager
'session_id' => $sessionId,
'title' => $values['note_title'],
'description' => $values['note_comment'],
'update_date' => api_get_utc_datetime(),
'update_date' => api_get_utc_datetime()
];
Database::update(
@ -150,7 +150,7 @@ class NotebookManager
[
'c_id = ? AND notebook_id = ?' => [
$course_id,
$values['notebook_id'],
$values['notebook_id']
],
]
);
@ -167,9 +167,13 @@ class NotebookManager
return true;
}
static function delete_note($notebook_id)
/**
* @param int $notebook_id
* @return bool
*/
public static function delete_note($notebook_id)
{
if (empty($notebook_id) or $notebook_id != strval(intval($notebook_id))) {
if (empty($notebook_id) || $notebook_id != strval(intval($notebook_id))) {
return false;
}
// Database table definition
@ -242,7 +246,7 @@ class NotebookManager
}
// Database table definition
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') {
$order_by = " ORDER BY " . $_SESSION['notebook_view'] . " $sort_direction ";
} else {
@ -267,12 +271,9 @@ class NotebookManager
while ($row = Database::fetch_array($result)) {
// Validation when belongs to a session
$session_img = api_get_session_image($row['session_id'], $_user['status']);
$creation_date = api_get_local_time($row['creation_date'], null, date_default_timezone_get());
$update_date = api_get_local_time($row['update_date'], null, date_default_timezone_get());
$updateValue = '';
if ($row['update_date'] <> $row['creation_date']) {
$updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($row['update_date']) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
$updateValue = ', ' . get_lang('UpdateDate') . ': ' . Display::dateToStringAgoAndLongDate($row['update_date']);
}
$actions = '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' .
@ -283,7 +284,7 @@ class NotebookManager
echo Display::panel(
$row['description'],
$row['title'] . $session_img.' <div class="pull-right">'.$actions.'</div>',
get_lang('CreationDate') . ': ' . date_to_str_ago($row['creation_date']) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue."</span>"
get_lang('CreationDate') . ': ' . Display::dateToStringAgoAndLongDate($row['creation_date']). $updateValue
);
}
}

@ -39,11 +39,11 @@ $action = isset($_GET['action']) ? $_GET['action'] : '';
// Tool name
if ($action === 'addnote') {
$tool = 'NoteAddNew';
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('ToolNotebook'));
$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook'));
}
if ($action === 'editnote') {
$tool = 'ModifyNote';
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('ToolNotebook'));
$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook'));
}
// Displaying the header
@ -54,29 +54,31 @@ Display::display_introduction_section(TOOL_NOTEBOOK);
// Action handling: Adding a note
if ($action === 'addnote') {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
if (!empty($_GET['isStudentView'])) {
NotebookManager::display_notes();
exit;
}
if (!empty($_GET['isStudentView'])) {
NotebookManager::display_notes();
exit;
}
$_SESSION['notebook_view'] = 'creation_date';
$form = new FormValidator(
'note',
'post',
api_get_self().'?action='.Security::remove_XSS($_GET['action'])
api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq()
);
// Setting the form elements
$form->addElement('header', '', get_lang('NoteAddNew'));
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('id' => 'note_title'));
$form->addElement('html_editor', 'note_comment', get_lang('NoteComment'), null, api_is_allowed_to_edit()
? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300')
: array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student')
$form->addElement(
'html_editor',
'note_comment',
get_lang('NoteComment'),
null,
api_is_allowed_to_edit() ? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300') : array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student')
);
$form->addButtonCreate(get_lang('AddNote'), 'SubmitNote');
@ -116,7 +118,7 @@ if ($action === 'addnote') {
$form = new FormValidator(
'note',
'post',
api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.intval($_GET['notebook_id'])
api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.intval($_GET['notebook_id']).'&'.api_get_cidreq()
);
// Setting the form elements
$form->addElement('header', '', get_lang('ModifyNote'));
@ -160,15 +162,14 @@ if ($action === 'addnote') {
}
} elseif ($action === 'deletenote' && is_numeric($_GET['notebook_id'])) {
// Action handling: deleting a note
$res = NotebookManager::delete_note(Security::remove_XSS($_GET['notebook_id']));
$res = NotebookManager::delete_note($_GET['notebook_id']);
if ($res) {
Display::display_confirmation_message(get_lang('NoteDeleted'));
}
NotebookManager::display_notes();
} elseif (
$action === 'changeview' && in_array($_GET['view'], array('creation_date', 'update_date', 'title')) ) {
$action === 'changeview' && in_array($_GET['view'], array('creation_date', 'update_date', 'title'))) {
// Action handling: changing the view (sorting order)
switch ($_GET['view']) {

Loading…
Cancel
Save