@ -1,31 +1,30 @@
<?php //$id: $
/* For licensing terms, see /dokeos_license.txt */
<?php
/* For licensing terms, see /license.txt */
/**
* @package dokeos .glossary
* @package chamilo .glossary
* @author Christian Fasanando, initial version
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium, refactoring and tighter integration in Dokeos
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium, refactoring and tighter integration
*/
// n ame of the language file that needs to be included
// N ame of the language file that needs to be included
$language_file = array('notebook');
// including the global dokeos fileç
// Including the global initialization file
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'notebook.lib.php';
// the section (tabs)
$this_section=SECTION_COURSES;
require_once api_get_path(LIBRARY_PATH).'notebook.lib.php';
// The section (tabs)
$this_section = SECTION_COURSES;
// notice for unauthorized people.
// N otice for unauthorized people.
api_protect_course_script(true);
// i ncluding additional libraries
// I ncluding additional libraries
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
// a dditional javascript
// A dditional javascript
$htmlHeadXtra[] = NotebookManager::javascript_notebook();
$htmlHeadXtra[] = '< script src = "'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type = "text/javascript" language = "javascript" > < / script > '; //jQuery
$htmlHeadXtra[] = '< script type = "text/javascript" >
@ -37,33 +36,31 @@ $(document).ready(function () {
});
< / script > ';
// setting the tool constants
// Setting the tool constants
$tool = TOOL_NOTEBOOK;
// t racking
// T racking
event_access_tool(TOOL_NOTEBOOK);
// t ool name
if ( isset($_GET['action']) & & $_GET['action'] == 'addnote') {
// T ool name
if (isset($_GET['action']) & & $_GET['action'] == 'addnote') {
$tool = 'NoteAddNew';
$interbreadcrumb[] = array ("url"=>"index.php", "name" => get_lang('ToolNotebook'));
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('ToolNotebook'));
}
if ( isset($_GET['action']) & & $_GET['action'] == 'editnote') {
if (isset($_GET['action']) & & $_GET['action'] == 'editnote') {
$tool = 'ModifyNote';
$interbreadcrumb[] = array ("url"=>"index.php", "name" => get_lang('ToolNotebook'));
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('ToolNotebook'));
}
// d isplaying the header
// D isplaying the header
Display::display_header(get_lang(ucfirst($tool)));
// Tool introduction
Display::display_introduction_section(TOOL_NOTEBOOK);
// Action handling: Adding a note
if (isset($_GET['action']) & & $_GET['action'] == 'addnote') {
if (api_get_session_id()!=0 & & api_is_allowed_to_session_edit(false,true)==false ) {
if (api_get_session_id() != 0 & & ! api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
@ -74,11 +71,11 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
$_SESSION['notebook_view'] = 'creation_date';
// i nitiate the object
$form = new FormValidator('note','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// s ettting the form elements
// I nitiate the object
$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
// S ettting the form elements
$form->addElement('header', '', get_lang('NoteAddNew'));
$form->addElement('text', 'note_title', get_lang('NoteTitle'),array('size'=>'95', 'id'=> 'note_title'));
$form->addElement('text', 'note_title', get_lang('NoteTitle'), array('size' => '95', 'id' => 'note_title'));
//$form->applyFilter('note_title', 'html_filter');
$form->addElement('html_editor', 'note_comment', get_lang('NoteComment'), null, api_is_allowed_to_edit()
? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300')
@ -86,7 +83,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
);
$form->addElement('style_submit_button', 'SubmitNote', get_lang('AddNote'), 'class="add"');
// s etting the rules
// S etting the rules
$form->addRule('note_title', '< div class = "required" > '.get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
@ -96,7 +93,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
$values = $form->exportValues();
$res = NotebookManager::save_note($values);
if ($res == true){
Display::display_confirmation_message(get_lang('NoteAdded'));
Display::display_confirmation_message(get_lang('NoteAdded'));
}
}
Security::clear_token();
@ -106,26 +103,26 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
echo '< a href = "index.php" > '.Display::return_icon('back.png').' '.get_lang('BackToNotesList').'< / a > ';
echo '< / div > ';
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}
// Action handling: Editing a note
else if (isset($_GET['action']) & & $_GET['action'] == 'editnote' & & is_numeric($_GET['notebook_id']))
{
elseif (isset($_GET['action']) & & $_GET['action'] == 'editnote' & & is_numeric($_GET['notebook_id'])) {
if (!empty($_GET['isStudentView'])) {
NotebookManager::display_notes();
exit;
}
// initiat e the object
$form = new FormValidator('note','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'¬ebook_id='.Security::remove_XSS($_GET['notebook_id']));
// s ettting the form elements
// Initializ e the object
$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'¬ebook_id='.Security::remove_XSS($_GET['notebook_id']));
// S ettting the form elements
$form->addElement('header', '', get_lang('ModifyNote'));
$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->applyFilter('note_title', 'html_filter');
$form->addElement('html_editor', 'note_comment', get_lang('NoteComment'), null, api_is_allowed_to_edit()
? array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300')
@ -133,11 +130,11 @@ else if (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($
);
$form->addElement('style_submit_button', 'SubmitNote', get_lang('ModifyNote'), 'class="save"');
// s etting the defaults
// S etting the defaults
$defaults = NotebookManager::get_note_information(Security::remove_XSS($_GET['notebook_id']));
$form->setDefaults($defaults);
// s etting the rules
// S etting the rules
$form->addRule('note_title', '< div class = "required" > '.get_lang('ThisFieldIsRequired'), 'required');
// The validation or display
@ -145,11 +142,11 @@ else if (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
$res=NotebookManager::update_note($values);
if ($res==true ){
$res = NotebookManager::update_note($values);
if ($res) {
Display::display_confirmation_message(get_lang('NoteUpdated'));
}
}
Security::clear_token();
NotebookManager::display_notes();
@ -158,55 +155,45 @@ else if (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($
echo '< a href = "index.php" > '.Display::return_icon('back.png').' '.get_lang('BackToNotesList').'< / a > ';
echo '< / div > ';
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}
// Action handling: deleting a note
else if (isset($_GET['action']) & & $_GET['action'] == 'deletenote' & & is_numeric($_GET['notebook_id']))
{
$res=NotebookManager::delete_note(Security::remove_XSS($_GET['notebook_id']));
if ($res==true ){
elseif (isset($_GET['action']) & & $_GET['action'] == 'deletenote' & & is_numeric($_GET['notebook_id'])) {
$res = NotebookManager::delete_note(Security::remove_XSS($_GET['notebook_id']));
if ($res) {
Display::display_confirmation_message(get_lang('NoteDeleted'));
}
NotebookManager::display_notes();
}
// Action handling: changing the view (sorting order)
else if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('creation_date','update_date', 'title')))
{
switch ($_GET['view'])
{
elseif ($_GET['action'] == 'changeview' AND in_array($_GET['view'], array('creation_date', 'update_date', 'title'))) {
switch ($_GET['view']) {
case 'creation_date':
if (!$_GET['direction'] OR $_GET['direction'] == 'ASC')
{
if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
Display::display_confirmation_message(get_lang('NotesSortedByCreationDateAsc'));
}
else
{
} else {
Display::display_confirmation_message(get_lang('NotesSortedByCreationDateDESC'));
}
break;
case 'update_date':
if (!$_GET['direction'] OR $_GET['direction'] == 'ASC')
{
if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
Display::display_confirmation_message(get_lang('NotesSortedByUpdateDateAsc'));
}
else
{
} else {
Display::display_confirmation_message(get_lang('NotesSortedByUpdateDateDESC'));
}
break;
case 'title':
if (!$_GET['direction'] OR $_GET['direction'] == 'ASC')
{
if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
Display::display_confirmation_message(get_lang('NotesSortedByTitleAsc'));
}
else
{
} else {
Display::display_confirmation_message(get_lang('NotesSortedByTitleDESC'));
}
break;
@ -217,7 +204,5 @@ else if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('creat
NotebookManager::display_notes();
}
// footer
// Footer
Display::display_footer();
?>