diff --git a/main/notebook/index.php b/main/notebook/index.php index 00e2a8cfb7..00b14e3d68 100755 --- a/main/notebook/index.php +++ b/main/notebook/index.php @@ -1,283 +1,283 @@ -, Ghent University, Belgium, refactoring and tighter integration in Dokeos - */ - -// name of the language file that needs to be included -$language_file = array('notebook'); - -// including the global dokeos file -require_once('../inc/global.inc.php'); - -// the section (tabs) -$this_section=SECTION_COURSES; - -// notice for unauthorized people. -api_protect_course_script(true); - -// including additional libraries -require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); - -// additional javascript -$htmlHeadXtra[] = javascript_notebook(); - -// setting the tool constants -$tool = TOOL_NOTEBOOK; - -// displaying the header -Display::display_header(get_lang(ucfirst($tool))); - -// tool introduction - -$fck_attribute['Width'] = '100%'; -$fck_attribute['Height'] = '400'; -$fck_attribute['ToolbarSet'] = 'Full'; - -Display::display_introduction_section(TOOL_NOTEBOOK,'left'); - -$fck_attribute = null; // Clearing this global variable immediatelly after it has been used. - -// action links -echo '
'; -//if (api_is_allowed_to_edit()) -//{ - echo ''.Display::return_icon('filenew.gif',get_lang('NoteAddNew')).get_lang('NoteAddNew').''; -//} -echo ''.Display::return_icon('calendar_select.gif',get_lang('OrderByCreationDate')).get_lang('OrderByCreationDate').''; -echo ''.Display::return_icon('calendar_select.gif',get_lang('OrderByModificationDate')).get_lang('OrderByModificationDate').''; -echo ''.Display::return_icon('comment.gif',get_lang('OrderByTitle')).get_lang('OrderByTitle').''; -echo '
'; - -// Action handling: Adding a note -if (isset($_GET['action']) && $_GET['action'] == 'addnote') -{ - // initiate the object - $form = new FormValidator('note','post', api_get_self().'?action='.Security::remove_XSS($_GET['action'])); - // settting the form elements - $form->addElement('header', '', get_lang('NoteAddNew')); - $form->addElement('text', 'note_title', get_lang('NoteTitle')); - $form->addElement('html_editor', 'note_comment', get_lang('NoteComment')); - $form->addElement('style_submit_button', 'SubmitNote', get_lang('Save'), 'class="save"'); - - // 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(); - save_note($values); - } - Security::clear_token(); - } - else - { - $token = Security::get_token(); - $form->addElement('hidden','sec_token'); - $form->setConstants(array('sec_token' => $token)); - $form->display(); - } -} - -// Action handling: Editing a note -if (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_GET['notebook_id'])) -{ - // initiate the object - $form = new FormValidator('note','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'¬ebook_id='.Security::remove_XSS($_GET['notebook_id'])); - // settting the form elements - $form->addElement('header', '', get_lang('NoteEdit')); - $form->addElement('hidden', 'notebook_id'); - $form->addElement('text', 'note_title', get_lang('NoteTitle')); - $form->addElement('html_editor', 'note_comment', get_lang('NoteComment')); - $form->addElement('style_submit_button', 'SubmitNote', get_lang('Save'), 'class="save"'); - - // setting the defaults - $defaults = 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(); - update_note($values); - } - Security::clear_token(); - } - else - { - $token = Security::get_token(); - $form->addElement('hidden','sec_token'); - $form->setConstants(array('sec_token' => $token)); - $form->display(); - } -} - -// Action handling: deleting a note -if (isset($_GET['action']) && $_GET['action'] == 'deletenote' && is_numeric($_GET['notebook_id'])) -{ - delete_note(Security::remove_XSS($_GET['notebook_id'])); -} - -// Action handling: changing the view (sorting order) -if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('creation_date','update_date', 'title'))) -{ - $_SESSION['notebook_view'] = $_GET['view']; -} - -display_notes(); - -// footer -Display::display_footer(); - -/** - * a little bit of javascript to display a prettier warning when deleting a note - * - * @return unknown - * - * @author Patrick Cool , Ghent University, Belgium - * @version januari 2009, dokeos 1.8.6 - */ -function javascript_notebook() -{ - return ""; -} - -/** - * This functions stores the note in the database - * - * @param array $values - * - * @author Christian Fasanando - * @author Patrick Cool , Ghent University, Belgium - * @version januari 2009, dokeos 1.8.6 - */ -function save_note($values) -{ - // Database table definition - $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); - - $sql = "INSERT INTO $t_notebook (user_id, course, session_id, title, description, creation_date, status) - VALUES( - '".Database::escape_string(api_get_user_id())."', - '".Database::escape_string(api_get_course_id())."', - '".Database::escape_string($_SESSION['id_session'])."', - '".Database::escape_string($values['note_title'])."', - '".Database::escape_string($values['note_comment'])."', - '".Database::escape_string(date('Y-m-d H:i:s'))."', - '0')"; - $result = api_sql_query($sql, __FILE__, __LINE__); - // display the feedback message - Display::display_confirmation_message(get_lang('NoteAdded')); -} - -function get_note_information($notebook_id) -{ - // Database table definition - $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); - - $sql = "SELECT notebook_id AS notebook_id, - title AS note_title, - description AS note_comment - FROM $t_notebook - WHERE notebook_id = '".Database::escape_string($notebook_id)."' "; - $result = api_sql_query($sql, __FILE__, __LINE__); - return Database::fetch_array($result); -} - -/** - * This functions updates the note in the database - * - * @param array $values - * - * @author Christian Fasanando - * @author Patrick Cool , Ghent University, Belgium - * @version januari 2009, dokeos 1.8.6 - */ -function update_note($values) -{ - // Database table definition - $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); - - $sql = "UPDATE $t_notebook SET - user_id = '".Database::escape_string(api_get_user_id())."', - course = '".Database::escape_string(api_get_course_id())."', - session_id = '".Database::escape_string($_SESSION['id_session'])."', - title = '".Database::escape_string($values['note_title'])."', - description = '".Database::escape_string($values['note_comment'])."', - update_date = '".Database::escape_string(date('Y-m-d H:i:s'))."' - WHERE notebook_id = '".Database::escape_string($values['notebook_id'])."'"; - $result = api_sql_query($sql, __FILE__, __LINE__); - // display the feedback message - Display::display_confirmation_message(get_lang('NoteUpdated')); -} - -function delete_note($notebook_id) -{ - // Database table definition - $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); - - $sql = "DELETE FROM $t_notebook WHERE notebook_id='".Database::escape_string($notebook_id)."' AND user_id = '".Database::escape_string(api_get_user_id())."'"; - $result = api_sql_query($sql, __FILE__, __LINE__); - Display::display_confirmation_message(get_lang('NoteDeleted')); -} - -function display_notes() -{ - if (!in_array($_SESSION['notebook_view'],array('creation_date','update_date', 'title'))) - { - $_SESSION['notebook_view'] = 'update_date'; - } - - // Database table definition - $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); - $order_by = ""; - if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') { - $order_by = " ORDER BY ".$_SESSION['notebook_view']." DESC "; - } else { - $order_by = " ORDER BY ".$_SESSION['notebook_view']." ASC "; - } - - $sql = "SELECT * FROM $t_notebook WHERE user_id = '".Database::escape_string(api_get_user_id())."' $order_by"; - $result = api_sql_query($sql, __FILE__, __LINE__); - while ($row = Database::fetch_array($result)) - { - echo '
'; - echo ' ('.get_lang('CreationDate').': '.$row['creation_date']; - if ($row['update_date'] <> '0000-00-00 00:00:00') - { - echo ', '.get_lang('UpdateDate').': '.$row['update_date']; - } - echo ')'; - echo $row['title']; - echo '
'; - echo '
'.$row['description'].'
'; - echo ''; - } - return $return; -} -?> +, Ghent University, Belgium, refactoring and tighter integration in Dokeos + */ + +// name of the language file that needs to be included +$language_file = array('notebook'); + +// including the global dokeos file +require_once('../inc/global.inc.php'); + +// the section (tabs) +$this_section=SECTION_COURSES; + +// notice for unauthorized people. +api_protect_course_script(true); + +// including additional libraries +require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); + +// additional javascript +$htmlHeadXtra[] = javascript_notebook(); + +// setting the tool constants +$tool = TOOL_NOTEBOOK; + +// displaying the header +Display::display_header(get_lang(ucfirst($tool))); + +// tool introduction + +$fck_attribute['Width'] = '100%'; +$fck_attribute['Height'] = '400'; +$fck_attribute['ToolbarSet'] = 'Introduction'; + +Display::display_introduction_section(TOOL_NOTEBOOK,'left'); + +$fck_attribute = null; // Clearing this global variable immediatelly after it has been used. + +// action links +echo ''; + +// Action handling: Adding a note +if (isset($_GET['action']) && $_GET['action'] == 'addnote') +{ + // initiate the object + $form = new FormValidator('note','post', api_get_self().'?action='.Security::remove_XSS($_GET['action'])); + // settting the form elements + $form->addElement('header', '', get_lang('NoteAddNew')); + $form->addElement('text', 'note_title', get_lang('NoteTitle')); + $form->addElement('html_editor', 'note_comment', get_lang('NoteComment')); + $form->addElement('style_submit_button', 'SubmitNote', get_lang('Save'), 'class="save"'); + + // 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(); + save_note($values); + } + Security::clear_token(); + } + else + { + $token = Security::get_token(); + $form->addElement('hidden','sec_token'); + $form->setConstants(array('sec_token' => $token)); + $form->display(); + } +} + +// Action handling: Editing a note +if (isset($_GET['action']) && $_GET['action'] == 'editnote' && is_numeric($_GET['notebook_id'])) +{ + // initiate the object + $form = new FormValidator('note','post', api_get_self().'?action='.Security::remove_XSS($_GET['action']).'¬ebook_id='.Security::remove_XSS($_GET['notebook_id'])); + // settting the form elements + $form->addElement('header', '', get_lang('NoteEdit')); + $form->addElement('hidden', 'notebook_id'); + $form->addElement('text', 'note_title', get_lang('NoteTitle')); + $form->addElement('html_editor', 'note_comment', get_lang('NoteComment')); + $form->addElement('style_submit_button', 'SubmitNote', get_lang('Save'), 'class="save"'); + + // setting the defaults + $defaults = 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(); + update_note($values); + } + Security::clear_token(); + } + else + { + $token = Security::get_token(); + $form->addElement('hidden','sec_token'); + $form->setConstants(array('sec_token' => $token)); + $form->display(); + } +} + +// Action handling: deleting a note +if (isset($_GET['action']) && $_GET['action'] == 'deletenote' && is_numeric($_GET['notebook_id'])) +{ + delete_note(Security::remove_XSS($_GET['notebook_id'])); +} + +// Action handling: changing the view (sorting order) +if ($_GET['action'] == 'changeview' AND in_array($_GET['view'],array('creation_date','update_date', 'title'))) +{ + $_SESSION['notebook_view'] = $_GET['view']; +} + +display_notes(); + +// footer +Display::display_footer(); + +/** + * a little bit of javascript to display a prettier warning when deleting a note + * + * @return unknown + * + * @author Patrick Cool , Ghent University, Belgium + * @version januari 2009, dokeos 1.8.6 + */ +function javascript_notebook() +{ + return ""; +} + +/** + * This functions stores the note in the database + * + * @param array $values + * + * @author Christian Fasanando + * @author Patrick Cool , Ghent University, Belgium + * @version januari 2009, dokeos 1.8.6 + */ +function save_note($values) +{ + // Database table definition + $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); + + $sql = "INSERT INTO $t_notebook (user_id, course, session_id, title, description, creation_date, status) + VALUES( + '".Database::escape_string(api_get_user_id())."', + '".Database::escape_string(api_get_course_id())."', + '".Database::escape_string($_SESSION['id_session'])."', + '".Database::escape_string($values['note_title'])."', + '".Database::escape_string($values['note_comment'])."', + '".Database::escape_string(date('Y-m-d H:i:s'))."', + '0')"; + $result = api_sql_query($sql, __FILE__, __LINE__); + // display the feedback message + Display::display_confirmation_message(get_lang('NoteAdded')); +} + +function get_note_information($notebook_id) +{ + // Database table definition + $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); + + $sql = "SELECT notebook_id AS notebook_id, + title AS note_title, + description AS note_comment + FROM $t_notebook + WHERE notebook_id = '".Database::escape_string($notebook_id)."' "; + $result = api_sql_query($sql, __FILE__, __LINE__); + return Database::fetch_array($result); +} + +/** + * This functions updates the note in the database + * + * @param array $values + * + * @author Christian Fasanando + * @author Patrick Cool , Ghent University, Belgium + * @version januari 2009, dokeos 1.8.6 + */ +function update_note($values) +{ + // Database table definition + $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); + + $sql = "UPDATE $t_notebook SET + user_id = '".Database::escape_string(api_get_user_id())."', + course = '".Database::escape_string(api_get_course_id())."', + session_id = '".Database::escape_string($_SESSION['id_session'])."', + title = '".Database::escape_string($values['note_title'])."', + description = '".Database::escape_string($values['note_comment'])."', + update_date = '".Database::escape_string(date('Y-m-d H:i:s'))."' + WHERE notebook_id = '".Database::escape_string($values['notebook_id'])."'"; + $result = api_sql_query($sql, __FILE__, __LINE__); + // display the feedback message + Display::display_confirmation_message(get_lang('NoteUpdated')); +} + +function delete_note($notebook_id) +{ + // Database table definition + $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); + + $sql = "DELETE FROM $t_notebook WHERE notebook_id='".Database::escape_string($notebook_id)."' AND user_id = '".Database::escape_string(api_get_user_id())."'"; + $result = api_sql_query($sql, __FILE__, __LINE__); + Display::display_confirmation_message(get_lang('NoteDeleted')); +} + +function display_notes() +{ + if (!in_array($_SESSION['notebook_view'],array('creation_date','update_date', 'title'))) + { + $_SESSION['notebook_view'] = 'update_date'; + } + + // Database table definition + $t_notebook = Database :: get_course_table(TABLE_NOTEBOOK); + $order_by = ""; + if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') { + $order_by = " ORDER BY ".$_SESSION['notebook_view']." DESC "; + } else { + $order_by = " ORDER BY ".$_SESSION['notebook_view']." ASC "; + } + + $sql = "SELECT * FROM $t_notebook WHERE user_id = '".Database::escape_string(api_get_user_id())."' $order_by"; + $result = api_sql_query($sql, __FILE__, __LINE__); + while ($row = Database::fetch_array($result)) + { + echo '
'; + echo ' ('.get_lang('CreationDate').': '.$row['creation_date']; + if ($row['update_date'] <> '0000-00-00 00:00:00') + { + echo ', '.get_lang('UpdateDate').': '.$row['update_date']; + } + echo ')'; + echo $row['title']; + echo '
'; + echo '
'.$row['description'].'
'; + echo ''; + } + return $return; +} +?> diff --git a/main/survey/survey_list.php b/main/survey/survey_list.php index e18b9296b7..04f26b2abd 100644 --- a/main/survey/survey_list.php +++ b/main/survey/survey_list.php @@ -1,4 +1,4 @@ -, Ghent University: cleanup, refactoring and rewriting large parts of the code * @author Julio Montoya Armas , Dokeos: Personality Test modification and rewriting large parts of the code -* @version $Id: survey_list.php 18113 2009-02-01 11:25:38Z ivantcholakov $ +* @version $Id: survey_list.php 18307 2009-02-06 21:38:07Z herodoto $ * * @todo use quickforms for the forms */ @@ -83,7 +83,7 @@ Display :: display_header($tool_name,'Survey'); $fck_attribute['Width'] = '100%'; $fck_attribute['Height'] = '400'; -$fck_attribute['ToolbarSet'] = 'Full'; +$fck_attribute['ToolbarSet'] = 'Introduction'; Display::display_introduction_section('survey', 'left'); diff --git a/main/user/user.php b/main/user/user.php index 84da65ad0e..e9e6385800 100644 --- a/main/user/user.php +++ b/main/user/user.php @@ -1,4 +1,4 @@ -, Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default. * @author Roan Embrechts, code refactoring and virtual course support * @author Frederic Vauthier, directories management -* @version $Id: work.php 18261 2009-02-05 20:56:30Z cfasanando $ +* @version $Id: work.php 18307 2009-02-06 21:38:07Z herodoto $ * * @todo refactor more code into functions, use quickforms, coding standards, ... */ @@ -373,7 +373,7 @@ if (!empty ($_POST['changeProperties'])) { $fck_attribute['Width'] = '100%'; $fck_attribute['Height'] = '400'; -$fck_attribute['ToolbarSet'] = 'Full'; +$fck_attribute['ToolbarSet'] = 'Introduction'; Display :: display_introduction_section(TOOL_STUDENTPUBLICATION,'left');