Browse Source

Format code + use Display::panel function

Julio Montoya 9 years ago
parent
commit
70e4171cdc

+ 32 - 33
main/course_description/index.php

@@ -8,7 +8,6 @@
 * @package chamilo.course_description
 */
 
-// including files
 require_once '../inc/global.inc.php';
 $current_course_tool  = TOOL_COURSE_DESCRIPTION;
 
@@ -44,42 +43,42 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
 
 // interbreadcrumb
 $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
-if(intval($description_type) == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
-if(intval($description_type) == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
-if(intval($description_type) == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics'));
-if(intval($description_type) == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology'));
-if(intval($description_type) == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial'));
-if(intval($description_type) == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
-if(intval($description_type) == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment'));
-if(intval($description_type) == 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('ThematicAdvance'));
-if(intval($description_type) >= 9) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Others'));
+if ($description_type == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
+if ($description_type == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
+if ($description_type == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics'));
+if ($description_type == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology'));
+if ($description_type == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial'));
+if ($description_type == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
+if ($description_type == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment'));
+if ($description_type == 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('ThematicAdvance'));
+if ($description_type >= 9) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Others'));
 
 // course description controller object
 $course_description_controller = new CourseDescriptionController();
 
 // distpacher actions to controller
 switch ($action) {
-	case 'listing':
-		$course_description_controller->listing();
-		break;
-	case 'history':
-		$course_description_controller->listing(true);
-		break;
-	case 'add'      :
-		if (api_is_allowed_to_edit(null, true)) {
-			$course_description_controller->add();
-		}
-		break;
-	case 'edit'      :
-		if (api_is_allowed_to_edit(null, true)) {
-			$course_description_controller->edit($id, $description_type);
-		}
-		break;
-	case 'delete' :
-		if (api_is_allowed_to_edit(null, true)) {
-			$course_description_controller->destroy($id);
-		}
-		break;
-	default          :
-		$course_description_controller->listing();
+    case 'listing':
+        $course_description_controller->listing();
+        break;
+    case 'history':
+        $course_description_controller->listing(true);
+        break;
+    case 'add':
+        if (api_is_allowed_to_edit(null, true)) {
+            $course_description_controller->add();
+        }
+        break;
+    case 'edit':
+        if (api_is_allowed_to_edit(null, true)) {
+            $course_description_controller->edit($id, $description_type);
+        }
+        break;
+    case 'delete':
+        if (api_is_allowed_to_edit(null, true)) {
+            $course_description_controller->destroy($id);
+        }
+        break;
+    default:
+        $course_description_controller->listing();
 }

+ 14 - 17
main/course_description/listing.php

@@ -51,33 +51,30 @@ $user_info = api_get_user_info();
 if (isset($descriptions) && count($descriptions) > 0) {
 	foreach ($descriptions as $id => $description) {
         if (!empty($description)) {
-            echo '<div class="panel panel-info">';
-            echo '<div class="panel-heading">';
-
+            $actions = '';
             if (api_is_allowed_to_edit(null,true) && !$history) {
                 if (api_get_session_id() == $description['session_id']) {
                     $description['title'] = $description['title'].' '.api_get_session_image(api_get_session_id(), $user_info['status']);
 
                     // delete
-                    echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding())).'\')) return false;">';
-                    echo Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
-                    echo '</a> ';
+                    $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=delete&description_type='.$description['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,api_get_system_encoding())).'\')) return false;">';
+                    $actions .= Display::return_icon('delete.png', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
+                    $actions .= '</a> ';
 
                     // edit
-                    echo '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=edit&description_type='.$description['description_type'].'">';
-                    echo Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),ICON_SIZE_SMALL);
-                    echo '</a> ';
+                    $actions .= '<a href="'.api_get_self().'?id='.$description['id'].'&cidReq='.api_get_course_id().'&id_session='.$description['session_id'].'&action=edit&description_type='.$description['description_type'].'">';
+                    $actions .= Display::return_icon('edit.png', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'),ICON_SIZE_SMALL);
+                    $actions .= '</a> ';
                 } else {
-                    echo Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
+                    $actions .= Display::return_icon('edit_na.png', get_lang('EditionNotAvailableFromSession'), array('style' => 'vertical-align:middle;float:right;'),ICON_SIZE_SMALL);
                 }
             }
-
-            echo $description['title'];
-            echo '</div>';
-            echo '<div class="panel-body">';
-            echo $description['content'];
-            echo '</div></div>';
-            
+            echo Display::panel(
+                $description['content'],
+                $description['title'].$actions,
+                '',
+                'info'
+            );
         }
     }
 } else {

+ 7 - 7
main/inc/lib/display.lib.php

@@ -2026,9 +2026,7 @@ class Display
         $editProfileUrl = api_get_path(WEB_CODE_PATH).'auth/profile.php';
 
         if ($asAdmin) {
-            $editProfileUrl = api_get_path(
-                    WEB_CODE_PATH
-                )."admin/user_edit.php?user_id=".intval($userId);
+            $editProfileUrl = api_get_path(WEB_CODE_PATH)."admin/user_edit.php?user_id=".intval($userId);
         }
 
         if (api_get_setting('sso_authentication') === 'true') {
@@ -2057,18 +2055,20 @@ class Display
      * @param string $content
      * @param string $title
      * @param string $footer
-     * @param string $style
+     * @param string $style primary|success|info|warning|danger
      * @param string $extra
      *
      * @return string
      */
-    public static function panel($content, $title = '', $footer = '', $style = '', $extra='')
+    public static function panel($content, $title = '', $footer = '', $style = '', $extra = '')
     {
         $title = !empty($title) ? '<div class="panel-heading"><h3 class="panel-title">'.$title.'</h3>'.$extra.'</div>' : '';
-        $footer = !empty($footer) ? '<div class="panel-footer">'.$footer.'</div>' : '';
+        $footer = !empty($footer) ? '<div class="panel-footer ">'.$footer.'</div>' : '';
+        $styles = ['primary','success','info','warning','danger'];
+        $style = !in_array($style, $styles) ? 'default' : $style;
 
         return '
-            <div class="panel panel-default">
+            <div class="panel panel-'.$style.'">
                 '.$title.'
                 '.self::contentPanel($content).'
                 '.$footer.'

+ 38 - 21
main/inc/lib/notebook.lib.php

@@ -9,15 +9,17 @@
  */
 class NotebookManager
 {
-
-    private function __construct()
+    /**
+     * Constructor
+     */
+    public function __construct()
     {
     }
 
     /**
      * a little bit of javascript to display a prettier warning when deleting a note
      *
-     * @return unknown
+     * @return string
      *
      * @author Patrick Cool <patrick.cool@ugent.be>, Ghent University, Belgium
      * @version januari 2009, dokeos 1.8.6
@@ -85,6 +87,10 @@ class NotebookManager
         }
     }
 
+    /**
+     * @param int $notebook_id
+     * @return array|mixed
+     */
     static function get_note_information($notebook_id)
     {
         if (empty($notebook_id)) {
@@ -159,7 +165,6 @@ class NotebookManager
         );
 
         return true;
-
     }
 
     static function delete_note($notebook_id)
@@ -196,7 +201,7 @@ class NotebookManager
     /**
      * Display notes
      */
-    static function display_notes()
+    public static function display_notes()
     {
         $_user = api_get_user_info();
         if (!isset($_GET['direction'])) {
@@ -224,9 +229,12 @@ class NotebookManager
             echo '<a href="javascript:void(0)">' . Display::return_icon('new_note.png', get_lang('NoteAddNew'), '', '32') . '</a>';
         }
 
-        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
-        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
-        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' . Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
+        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=creation_date&direction=' . $link_sort_direction . '">' .
+            Display::return_icon('notes_order_by_date_new.png', get_lang('OrderByCreationDate'), '', '32') . '</a>';
+        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=update_date&direction=' . $link_sort_direction . '">' .
+            Display::return_icon('notes_order_by_date_mod.png', get_lang('OrderByModificationDate'), '', '32') . '</a>';
+        echo '<a href="index.php?' . api_get_cidreq() . '&action=changeview&view=title&direction=' . $link_sort_direction . '">' .
+            Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32') . '</a>';
         echo '</div>';
 
         if (!in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))) {
@@ -249,26 +257,35 @@ class NotebookManager
         $cond_extra = ($_SESSION['notebook_view'] == 'update_date') ? " AND update_date <> '0000-00-00 00:00:00'" : " ";
         $course_id = api_get_course_int_id();
 
-        $sql = "SELECT * FROM $t_notebook WHERE c_id = $course_id AND user_id = '" . api_get_user_id() . "' $condition_session $cond_extra $order_by";
+        $sql = "SELECT * FROM $t_notebook
+                WHERE
+                    c_id = $course_id AND
+                    user_id = '" . api_get_user_id() . "'
+                    $condition_session
+                    $cond_extra $order_by
+                ";
         $result = Database::query($sql);
         while ($row = Database::fetch_array($result)) {
-            //validacion when belongs to a session
+            // 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());
-            echo '<div class="sectiontitle">';
-            echo '<span style="float: right;"> (' . get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . '</span>';
+
+            $updateValue = '';
             if ($row['update_date'] <> $row['creation_date']) {
-                echo ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
+                $updateValue = ', ' . get_lang('UpdateDate') . ': ' . date_to_str_ago($update_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $update_date . '</span>';
             }
-            echo ')</span>';
-            echo $row['title'] . $session_img;
-            echo '</div>';
-            echo '<div class="sectioncomment">' . $row['description'] . '</div>';
-            echo '<div>';
-            echo '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
-            echo '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
-            echo '</div>';
+
+            $actions = '<a href="' . api_get_self() . '?action=editnote&notebook_id=' . $row['notebook_id'] . '">' .
+                Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>';
+            $actions .= '<a href="' . api_get_self() . '?action=deletenote&notebook_id=' . $row['notebook_id'] . '" onclick="return confirmation(\'' . $row['title'] . '\');">' .
+                Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>';
+
+            echo Display::panel(
+                $row['description'],
+                $row['title'] . $session_img.' <div class="pull-right">'.$actions.'</div>',
+                get_lang('CreationDate') . ': ' . date_to_str_ago($creation_date) . '&nbsp;&nbsp;<span class="dropbox_date">' . $creation_date . $updateValue."</span>"
+            );
         }
     }
 }

+ 131 - 128
main/notebook/index.php

@@ -3,7 +3,8 @@
 /**
  * @package chamilo.notebook
  * @author Christian Fasanando, initial version
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium, refactoring and tighter integration
+ * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium,
+ * refactoring and tighter integration
  */
 
 // Including the global initialization file
@@ -37,11 +38,11 @@ Event::event_access_tool(TOOL_NOTEBOOK);
 // Tool 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') {
 	$tool = 'ModifyNote';
-	$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('ToolNotebook'));
+	$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('ToolNotebook'));
 }
 
 // Displaying the header
@@ -63,136 +64,138 @@ if (isset($_GET['action']) && $_GET['action'] == 'addnote') {
 
 	$_SESSION['notebook_view'] = 'creation_date';
 
-	// Initiate the object
-	$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']));
-	// Setting the form elements
-	$form->addElement('header', '', get_lang('NoteAddNew'));
-	$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')
-		: array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student')
-	);
-	$form->addButtonCreate(get_lang('AddNote'), 'SubmitNote');
-
-	// Setting the rules
-	$form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
-
-	// The validation or display
-	if ($form->validate()) {
-		$check = Security::check_token('post');
-		if ($check) {
-	   		$values = $form->exportValues();
-	   		$res = NotebookManager::save_note($values);
-	   		if ($res) {
-	   			Display::display_confirmation_message(get_lang('NoteAdded'));
-	   		}
-		}
-		Security::clear_token();
-		NotebookManager::display_notes();
-	} else {
-		echo '<div class="actions">';
-		echo '<a href="index.php">'.Display::return_icon('back.png',get_lang('BackToNotesList'),'',ICON_SIZE_MEDIUM).'</a>';
-		echo '</div>';
-		$token = Security::get_token();
-		$form->addElement('hidden', 'sec_token');
-		$form->setConstants(array('sec_token' => $token));
-		$form->display();
-	}
+    $form = new FormValidator(
+        'note',
+        'post',
+        api_get_self().'?action='.Security::remove_XSS($_GET['action'])
+    );
+    // 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->addButtonCreate(get_lang('AddNote'), 'SubmitNote');
+
+    // Setting the rules
+    $form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
+
+    // The validation or display
+    if ($form->validate()) {
+        $check = Security::check_token('post');
+        if ($check) {
+            $values = $form->exportValues();
+            $res = NotebookManager::save_note($values);
+            if ($res) {
+                Display::display_confirmation_message(get_lang('NoteAdded'));
+            }
+        }
+        Security::clear_token();
+        NotebookManager::display_notes();
+    } else {
+        echo '<div class="actions">';
+        echo '<a href="index.php">'.Display::return_icon('back.png',get_lang('BackToNotesList'),'',ICON_SIZE_MEDIUM).'</a>';
+        echo '</div>';
+        $token = Security::get_token();
+        $form->addElement('hidden', 'sec_token');
+        $form->setConstants(array('sec_token' => $token));
+        $form->display();
+    }
 } elseif (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_GET['notebook_id'])) {
     // Action handling: Editing a note
 
-	if (!empty($_GET['isStudentView'])) {
-		NotebookManager::display_notes();
-		exit;
-	}
-
-	// Initialize the object
-	$form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.Security::remove_XSS($_GET['notebook_id']));
-	// Setting 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->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')
-		: array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student')
-	);
-	$form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote');
-
-	// Setting the defaults
-	$defaults = NotebookManager::get_note_information(Security::remove_XSS($_GET['notebook_id']));
-	$form->setDefaults($defaults);
-
-	// Setting the rules
-	$form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
-
-	// The validation or display
-	if ($form->validate()) {
-		$check = Security::check_token('post');
-		if ($check) {
-	   		$values = $form->exportValues();
-	   		$res = NotebookManager::update_note($values);
-	   		if ($res) {
-	   			Display::display_confirmation_message(get_lang('NoteUpdated'));
-	   		}
-
-		}
-		Security::clear_token();
-		NotebookManager::display_notes();
-	} else {
-		echo '<div class="actions">';
-		echo '<a href="index.php">'.Display::return_icon('back.png',get_lang('BackToNotesList'),'',ICON_SIZE_MEDIUM).'</a>';
-		echo '</div>';
-		$token = Security::get_token();
-		$form->addElement('hidden', 'sec_token');
-		$form->setConstants(array('sec_token' => $token));
-		$form->display();
-	}
-}
-
-// Action handling: deleting a note
-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();
+    if (!empty($_GET['isStudentView'])) {
+        NotebookManager::display_notes();
+        exit;
+    }
+
+    // Initialize the object
+    $form = new FormValidator('note', 'post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&notebook_id='.Security::remove_XSS($_GET['notebook_id']));
+    // Setting 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->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')
+        : array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student')
+    );
+    $form->addButtonUpdate(get_lang('ModifyNote'), 'SubmitNote');
+
+    // Setting the defaults
+    $defaults = NotebookManager::get_note_information(Security::remove_XSS($_GET['notebook_id']));
+    $form->setDefaults($defaults);
+
+    // Setting the rules
+    $form->addRule('note_title', get_lang('ThisFieldIsRequired'), 'required');
+
+    // The validation or display
+    if ($form->validate()) {
+        $check = Security::check_token('post');
+        if ($check) {
+            $values = $form->exportValues();
+            $res = NotebookManager::update_note($values);
+            if ($res) {
+                Display::display_confirmation_message(get_lang('NoteUpdated'));
+            }
+
+        }
+        Security::clear_token();
+        NotebookManager::display_notes();
+    } else {
+        echo '<div class="actions">';
+        echo '<a href="index.php">'.
+            Display::return_icon('back.png',get_lang('BackToNotesList'),'',ICON_SIZE_MEDIUM).'</a>';
+        echo '</div>';
+        $token = Security::get_token();
+        $form->addElement('hidden', 'sec_token');
+        $form->setConstants(array('sec_token' => $token));
+        $form->display();
+    }
+} elseif (isset($_GET['action']) && $_GET['action'] == 'deletenote' && is_numeric($_GET['notebook_id'])) {
+    // Action handling: deleting a note
+
+    $res = NotebookManager::delete_note(Security::remove_XSS($_GET['notebook_id']));
+    if ($res) {
+        Display::display_confirmation_message(get_lang('NoteDeleted'));
+    }
+
+    NotebookManager::display_notes();
 } elseif (
-	isset($_GET['action']) && $_GET['action'] == 'changeview' &&
-	in_array($_GET['view'], array('creation_date', 'update_date', 'title'))
-) {
-
-	// Action handling: changing the view (sorting order)
-	switch ($_GET['view']) {
-		case 'creation_date':
-			if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
-				Display::display_confirmation_message(get_lang('NotesSortedByCreationDateAsc'));
-			} else {
-				Display::display_confirmation_message(get_lang('NotesSortedByCreationDateDESC'));
-			}
-			break;
-		case 'update_date':
-			if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
-				Display::display_confirmation_message(get_lang('NotesSortedByUpdateDateAsc'));
-			} else {
-				Display::display_confirmation_message(get_lang('NotesSortedByUpdateDateDESC'));
-			}
-			break;
-		case 'title':
-			if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
-				Display::display_confirmation_message(get_lang('NotesSortedByTitleAsc'));
-			} else {
-				Display::display_confirmation_message(get_lang('NotesSortedByTitleDESC'));
-			}
-			break;
-	}
-	$_SESSION['notebook_view'] = $_GET['view'];
-	NotebookManager::display_notes();
+    isset($_GET['action']) && $_GET['action'] == 'changeview' &&
+    in_array($_GET['view'], array('creation_date', 'update_date', 'title'))
+    ) {
+
+    // Action handling: changing the view (sorting order)
+    switch ($_GET['view']) {
+        case 'creation_date':
+            if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
+                Display::display_confirmation_message(get_lang('NotesSortedByCreationDateAsc'));
+            } else {
+                Display::display_confirmation_message(get_lang('NotesSortedByCreationDateDESC'));
+            }
+            break;
+        case 'update_date':
+            if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
+                Display::display_confirmation_message(get_lang('NotesSortedByUpdateDateAsc'));
+            } else {
+                Display::display_confirmation_message(get_lang('NotesSortedByUpdateDateDESC'));
+            }
+            break;
+        case 'title':
+            if (!$_GET['direction'] OR $_GET['direction'] == 'ASC') {
+                Display::display_confirmation_message(get_lang('NotesSortedByTitleAsc'));
+            } else {
+                Display::display_confirmation_message(get_lang('NotesSortedByTitleDESC'));
+            }
+            break;
+    }
+    $_SESSION['notebook_view'] = $_GET['view'];
+    NotebookManager::display_notes();
 } else {
-	NotebookManager::display_notes();
+    NotebookManager::display_notes();
 }
 
 // Footer