[svn r17441] logic changes - Implemented new notebook tool (see FS#3387)

skala
Cristian Fasanando 17 years ago
parent 3658bead74
commit 1da6d0f819
  1. 1
      documentation/changelog.html
  2. 19
      main/inc/lib/add_course.lib.inc.php
  3. 5
      main/inc/lib/database.lib.php
  4. 41
      main/inc/lib/main_api.lib.php
  5. 8
      main/install/dokeos_main.sql
  6. 3
      main/install/migrate-db-1.8.5-1.8.6-pre.sql
  7. 145
      main/notebook/index.php
  8. 146
      main/notebook/notebookfunction.inc.php

@ -61,6 +61,7 @@
<li>Improved chat (open in new window option, smileys, teacher/learner difference and time indication for each message, user picture showing directly, possibility to hold several conversations in several courses at the same time)</li> <li>Improved chat (open in new window option, smileys, teacher/learner difference and time indication for each message, user picture showing directly, possibility to hold several conversations in several courses at the same time)</li>
<li>Option to hide/show e-mail addresses to all users (SVN#16965, SVN#16968)</li> <li>Option to hide/show e-mail addresses to all users (SVN#16965, SVN#16968)</li>
<li>Added an introduction section for each group area (SVN#17424)</li> <li>Added an introduction section for each group area (SVN#17424)</li>
<li>New notebook tool</li>
</ul> </ul>
<br /> <br />
<h3>Debugging</h3> <h3>Debugging</h3>

@ -402,6 +402,8 @@ function update_Db_course($courseDbName)
// Glossary // Glossary
$TBL_GLOSSARY = $courseDbName . 'glossary'; $TBL_GLOSSARY = $courseDbName . 'glossary';
// Notebook
$TBL_NOTEBOOK = $courseDbName . 'notebook';
/* /*
----------------------------------------------------------- -----------------------------------------------------------
Announcement tool Announcement tool
@ -1641,6 +1643,20 @@ function update_Db_course($courseDbName)
)"; )";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql)); $result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
// table notebook
$sql = "CREATE TABLE `".$TBL_NOTEBOOK."` (
notebook_id int unsigned NOT NULL auto_increment,
user_id int unsigned NOT NULL,
course varchar(40) not null,
session_id int NOT NULL default 0,
description varchar(255) NOT NULL,
start_date datetime NOT NULL default '0000-00-00 00:00:00',
end_date datetime NOT NULL default '0000-00-00 00:00:00',
status int,
PRIMARY KEY (notebook_id)
)";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
return 0; return 0;
} }
@ -1970,7 +1986,8 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','".string2binary(api_get_setting('course_create_active_tools', 'survey')) . "','0','squaregrey.gif','NO','_self','interaction')", __FILE__, __LINE__); api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','".string2binary(api_get_setting('course_create_active_tools', 'survey')) . "','0','squaregrey.gif','NO','_self','interaction')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_WIKI ."','wiki/index.php','wiki.gif','".string2binary(api_get_setting('course_create_active_tools', 'wiki')) . "','0','squaregrey.gif','NO','_self','interaction')", __FILE__, __LINE__); api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_WIKI ."','wiki/index.php','wiki.gif','".string2binary(api_get_setting('course_create_active_tools', 'wiki')) . "','0','squaregrey.gif','NO','_self','interaction')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring')", __FILE__, __LINE__); api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook')). "','0','squaregrey.gif','NO','_self','authoring')", __FILE__, __LINE__); api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','glossary.gif','".string2binary(api_get_setting('course_create_active_tools', 'glossary')). "','0','squaregrey.gif','NO','_self','authoring')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_NOTEBOOK."','notebook/index.php','notebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'notebook'))."','0','squaregrey.gif','NO','_self','interaction')", __FILE__, __LINE__);
if(api_get_setting('service_visio','active')=='true') if(api_get_setting('service_visio','active')=='true')
{ {
$mycheck = api_get_setting('service_visio','visio_host'); $mycheck = api_get_setting('service_visio','visio_host');

@ -1,4 +1,4 @@
<?php // $Id: database.lib.php 17238 2008-12-11 20:41:05Z iflorespaz $ <?php // $Id: database.lib.php 17441 2008-12-23 21:19:58Z cfasanando $
/* See license terms in /dokeos_license.txt */ /* See license terms in /dokeos_license.txt */
/** /**
============================================================================== ==============================================================================
@ -187,6 +187,9 @@ define('TABLE_WIKI_MAILCUE', 'wiki_mailcue');
// GLOSSARY // GLOSSARY
define('TABLE_GLOSSARY', 'glossary'); define('TABLE_GLOSSARY', 'glossary');
// GLOSSARY
define('TABLE_NOTEBOOK', 'notebook');
/* /*
============================================================================== ==============================================================================
DATABASE CLASS DATABASE CLASS

@ -139,6 +139,7 @@ define('TOOL_SURVEY','survey');
define('TOOL_WIKI','wiki'); define('TOOL_WIKI','wiki');
define('TOOL_GLOSSARY','glossary'); define('TOOL_GLOSSARY','glossary');
define('TOOL_GRADEBOOK','gradebook'); define('TOOL_GRADEBOOK','gradebook');
define('TOOL_NOTEBOOK','notebook');
// CONSTANTS defining dokeos sections // CONSTANTS defining dokeos sections
define('SECTION_CAMPUS', 'mycampus'); define('SECTION_CAMPUS', 'mycampus');
@ -1387,12 +1388,12 @@ function is_allowed_to_edit() {
* @version 1.1, February 2004 * @version 1.1, February 2004
* @return boolean, true: the user has the rights to edit, false: he does not * @return boolean, true: the user has the rights to edit, false: he does not
*/ */
function api_is_allowed_to_edit($tutor=false,$coach=false) { function api_is_allowed_to_edit($tutor=false,$coach=false) {
$is_courseAdmin = api_is_course_admin() || api_is_platform_admin(); $is_courseAdmin = api_is_course_admin() || api_is_platform_admin() || api_is_coach();
if(!$is_courseAdmin && $tutor == true) { //if we also want to check if the user is a tutor... if(!$is_courseAdmin && $tutor == true) { //if we also want to check if the user is a tutor...
$is_courseAdmin = $is_courseAdmin || api_is_course_tutor(); $is_courseAdmin = $is_courseAdmin || api_is_course_tutor();
} }
if(!$is_courseAdmin && $coach == true) { //if we also want to check if the user is a coach... if(!$is_courseAdmin && $coach == true) { //if we also want to check if the user is a coach...';
$is_courseAdmin = $is_courseAdmin || api_is_course_coach(); $is_courseAdmin = $is_courseAdmin || api_is_course_coach();
} }
if(api_get_setting('student_view_enabled') == 'true') { //check if the student_view is enabled, and if so, if it is activated if(api_get_setting('student_view_enabled') == 'true') { //check if the student_view is enabled, and if so, if it is activated
@ -1652,27 +1653,32 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
$to_user_id = Database::escape_string($to_user_id); $to_user_id = Database::escape_string($to_user_id);
$start_visible = Database::escape_string($start_visible); $start_visible = Database::escape_string($start_visible);
$end_visible = Database::escape_string($end_visible); $end_visible = Database::escape_string($end_visible);
$to_filter = "";
$time = time(); $time = time();
$time = date("Y-m-d H:i:s", $time); $time = date("Y-m-d H:i:s", $time);
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY,$_course['dbName']); $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY,$_course['dbName']);
if ($to_user_id <= 0) if ($to_user_id <= 0) {
$to_user_id = NULL; //no to_user_id set $to_user_id = NULL;//no to_user_id set
}
$start_visible = ($start_visible == 0) ? "0000-00-00 00:00:00" : $start_visible; $start_visible = ($start_visible == 0) ? "0000-00-00 00:00:00" : $start_visible;
$end_visible = ($end_visible == 0) ? "0000-00-00 00:00:00" : $end_visible; $end_visible = ($end_visible == 0) ? "0000-00-00 00:00:00" : $end_visible;
// set filters for $to_user_id and $to_group_id, with priority for $to_user_id // set filters for $to_user_id and $to_group_id, with priority for $to_user_id
$filter = "tool='$tool' AND ref='$item_id'"; $filter = "tool='$tool' AND ref='$item_id'";
if ($item_id == "*") if ($item_id == "*") {
$filter = "tool='$tool' AND visibility<>'2'"; // for all (not deleted) items of the tool $filter = "tool='$tool' AND visibility<>'2'"; // for all (not deleted) items of the tool
}
// check if $to_user_id and $to_group_id are passed in the function call // check if $to_user_id and $to_group_id are passed in the function call
// if both are not passed (both are null) then it is a message for everybody and $to_group_id should be 0 ! // if both are not passed (both are null) then it is a message for everybody and $to_group_id should be 0 !
if (is_null($to_user_id) && is_null($to_group_id)) if (is_null($to_user_id) && is_null($to_group_id)) {
$to_group_id = 0; $to_group_id = 0;
if (!is_null($to_user_id)) }
if (!is_null($to_user_id)) {
$to_filter = " AND to_user_id='$to_user_id'"; // set filter to intended user $to_filter = " AND to_user_id='$to_user_id'"; // set filter to intended user
else } else {
if (!is_null($to_group_id) and $to_group_id == strval(intval($to_group_id))) if (!is_null($to_group_id) and $to_group_id == strval(intval($to_group_id))) {
$to_filter = " AND to_group_id='$to_group_id'"; // set filter to intended group $to_filter = " AND to_group_id='$to_group_id'"; // set filter to intended group
}
}
// update if possible // update if possible
$set_type = ""; $set_type = "";
switch ($lastedit_type) { switch ($lastedit_type) {
@ -1706,12 +1712,12 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
$res = mysql_query($sql); $res = mysql_query($sql);
// insert if no entries are found (can only happen in case of $lastedit_type switch is 'default') // insert if no entries are found (can only happen in case of $lastedit_type switch is 'default')
if (mysql_affected_rows() == 0) { if (mysql_affected_rows() == 0) {
if (!is_null($to_user_id)) // $to_user_id has more priority than $to_group_id if (!is_null($to_user_id)) {
{ // $to_user_id has more priority than $to_group_id
$to_field = "to_user_id"; $to_field = "to_user_id";
$to_value = $to_user_id; $to_value = $to_user_id;
} else // $to_user_id is not set } else {
{ // $to_user_id is not set
$to_field = "to_group_id"; $to_field = "to_group_id";
$to_value = $to_group_id; $to_value = $to_group_id;
} }
@ -1719,8 +1725,9 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
(tool, ref, insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible) (tool, ref, insert_date,insert_user_id,lastedit_date,lastedit_type, lastedit_user_id,$to_field, visibility, start_visible, end_visible)
VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value','$visibility','$start_visible','$end_visible')"; VALUES ('$tool','$item_id','$time', '$user_id', '$time', '$lastedit_type','$user_id', '$to_value','$visibility','$start_visible','$end_visible')";
$res = mysql_query($sql); $res = mysql_query($sql);
if (!$res) if (!$res) {
return FALSE; return FALSE;
}
} }
return TRUE; return TRUE;
} }

@ -249,8 +249,9 @@ INSERT INTO course_module VALUES
(23,'course_maintenance','course_info/maintenance.php','backup.gif',2,3,'courseadmin'), (23,'course_maintenance','course_info/maintenance.php','backup.gif',2,3,'courseadmin'),
(24,'survey','survey/survey_list.php','survey.gif',2,1,'basic'), (24,'survey','survey/survey_list.php','survey.gif',2,1,'basic'),
(25,'wiki','wiki/index.php','wiki.gif',2,3,'basic'), (25,'wiki','wiki/index.php','wiki.gif',2,3,'basic'),
(26,'gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'); (26,'gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'),
(27,'glossary','glossary/index.php','file_txt.gif',2,1,'basic'); (27,'glossary','glossary/index.php','glossary.gif',2,1,'basic'),
(28,'notebook','notebook/index.php','notebook.gif',2,1,'basic');
UNLOCK TABLES; UNLOCK TABLES;
/*!40000 ALTER TABLE course_module ENABLE KEYS */; /*!40000 ALTER TABLE course_module ENABLE KEYS */;
@ -627,7 +628,8 @@ VALUES
('course_create_active_tools','gradebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Gradebook'), ('course_create_active_tools','gradebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Gradebook'),
('allow_users_to_create_courses',NULL,'radio','Platform','true','AllowUsersToCreateCoursesTitle','AllowUsersToCreateCoursesComment',NULL,NULL), ('allow_users_to_create_courses',NULL,'radio','Platform','true','AllowUsersToCreateCoursesTitle','AllowUsersToCreateCoursesComment',NULL,NULL),
('course_create_active_tools','survey','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Survey'), ('course_create_active_tools','survey','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Survey'),
('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary'); ('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary'),
('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook');
UNLOCK TABLES; UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */; /*!40000 ALTER TABLE settings_current ENABLE KEYS */;

@ -38,7 +38,9 @@ ALTER TABLE gradebook_category ADD session_id int DEFAULT NULL;
CREATE TABLE gradebook_result_log (id int NOT NULL auto_increment,id_result int NOT NULL,user_id int NOT NULL,evaluation_id int NOT NULL,date_log datetime default '0000-00-00 00:00:00',score float unsigned default NULL,PRIMARY KEY(id)); CREATE TABLE gradebook_result_log (id int NOT NULL auto_increment,id_result int NOT NULL,user_id int NOT NULL,evaluation_id int NOT NULL,date_log datetime default '0000-00-00 00:00:00',score float unsigned default NULL,PRIMARY KEY(id));
CREATE TABLE gradebook_linkeval_log (id int NOT NULL auto_increment,id_linkeval_log int NOT NULL,name text,description text,date_log int,weight smallint default NULL,visible tinyint default NULL,type varchar(20) NOT NULL,user_id_log int NOT NULL,PRIMARY KEY (id)); CREATE TABLE gradebook_linkeval_log (id int NOT NULL auto_increment,id_linkeval_log int NOT NULL,name text,description text,date_log int,weight smallint default NULL,visible tinyint default NULL,type varchar(20) NOT NULL,user_id_log int NOT NULL,PRIMARY KEY (id));
INSERT INTO course_module (name, link, image, `row`, `column`, position) VALUES ('glossary','glossary/index.php','glossary.gif',2,1,'basic'); INSERT INTO course_module (name, link, image, `row`, `column`, position) VALUES ('glossary','glossary/index.php','glossary.gif',2,1,'basic');
INSERT INTO course_module (name, link, image, `row`, `column`, position) VALUES ('notebook','notebook/index.php','notebook.gif',2,1,'basic');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary',1,0); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary',1,0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook',1,0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('allow_users_to_create_courses',NULL,'radio','Course','true','AllowUsersToCreateCoursesTitle','AllowUsersToCreateCoursesComment',NULL,NULL,1,0); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('allow_users_to_create_courses',NULL,'radio','Course','true','AllowUsersToCreateCoursesTitle','AllowUsersToCreateCoursesComment',NULL,NULL,1,0);
INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_users_to_create_courses','true','Yes'),('allow_users_to_create_courses','false','No'); INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_users_to_create_courses','true','Yes'),('allow_users_to_create_courses','false','No');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','survey','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Survey',1,0), INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','survey','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Survey',1,0),
@ -135,4 +137,5 @@ ALTER TABLE group_info ADD forum_state TINYINT NULL AFTER announcements_state;
CREATE TABLE calendar_event_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, agenda_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) ); CREATE TABLE calendar_event_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, agenda_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) );
ALTER TABLE glossary ADD display_order int; ALTER TABLE glossary ADD display_order int;
CREATE TABLE calendar_event_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, agenda_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) ); CREATE TABLE calendar_event_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, agenda_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) );
CREATE TABLE notebook (notebook_id int unsigned NOT NULL auto_increment,user_id int unsigned NOT NULL,course varchar(40) not null,session_id int NOT NULL default 0,description varchar(255) NOT NULL,start_date datetime NOT NULL default '0000-00-00 00:00:00',end_date datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY (notebook_id));
INSERT INTO course_setting(variable,value,category) VALUES ('allow_open_chat_window',0,'chat');>>>>>>> .r17111 INSERT INTO course_setting(variable,value,category) VALUES ('allow_open_chat_window',0,'chat');>>>>>>> .r17111

@ -0,0 +1,145 @@
<?php //$id: $
/* For licensing terms, see /dokeos_license.txt */
/**
* @package dokeos.notebook
* @author Christian Fasanando
* Notebook tool's user interface
*/
$language_file = array ('notebook');
require_once('../inc/global.inc.php');
api_protect_course_script(true);
require_once('notebookfunction.inc.php');
/*
* Header
*/
$htmlHeadXtra[] = to_javascript_notebook();
$tool = TOOL_NOTEBOOK;
Display::display_header(get_lang(ucfirst($tool)));
$user_id = api_get_user_id();
$course_id = api_get_course_id();
$session_id = $_SESSION['id_session'];
$ctok = $_SESSION['sec_token'];
$stok = Security::get_token();
$date = date('Y/m/d H:i:s');
$icon_add = 'kwrite.gif';
$icon_edit ='edit.gif';
$icon_delete ='delete.gif';
//---------------------------------------------------------
echo '<a href="index.php?action=addnotebook">'.Display::return_icon($icon_add,get_lang(' $tool = TOOL_NOTEBOOK;
Display::display_header(get_lang(ucfirst($tool)));')).get_lang('NewNotebook').'</a>';
if (isset($_REQUEST['action']) && $_REQUEST['action']=='addnotebook') {
echo '<div class="notebook-add-form" id="notebook-add">';
echo '<form name="frm_add_notebook" method="post">';
echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
echo '<input type="hidden" name="action" value="addnotebook">';
echo '<div class="add-desc-notebook"><textarea class="style-add-textarea" rows="4" cols="95" name="description" maxlength="255" onfocus="this.value=\'\';document.getElementById(\'msg_add_error\').style.display=\'none\';"><<'.get_lang("WriteHereYourNote").'>></textarea></div>';
echo '<div class="action_notebook"><input type="button" value="Grabar" onclick="return add_notebook()"><input type="button" value="Cancelar" onclick="document.getElementById(\'notebook-add\').style.display = \'none\';document.getElementById(\'msg_add_error\').style.display=\'none\';"></div>';
echo '<span class="msg_error" id="msg_add_error"></span>';
echo '</form>';
echo '</div>';
}
/*======================================
Add Notebook Details
======================================*/
if ($ctok==$_POST['sec_token']) {
if ((isset($_REQUEST['action']) && $_REQUEST['action']=='addnotebook') && isset($_REQUEST['description'])) {
$description = Security::remove_XSS($_REQUEST['description']);
$add_notebook= add_notebook_details($user_id,$course_id,$session_id,$description,$date);
if($add_notebook) {
Display::display_confirmation_message(get_lang('NotebookAdded'));
}
}
}
/*======================================
Edit Notebook Details
======================================*/
if ($ctok==$_POST['sec_token']) {
if (isset($_REQUEST['upd_notebook_id']) && isset($_REQUEST['upd_description'])) {
$notebook_id = Security::remove_XSS($_REQUEST['upd_notebook_id']);
$description = Security::remove_XSS($_REQUEST['upd_description']);
$edit_notebook= edit_notebook_details($notebook_id,$user_id,$course_id,$session_id,$description,$date);
if($edit_notebook) {
Display::display_confirmation_message(get_lang('NotebookUpdated'));
}
}
}
/*======================================
Delete Notebook Details
======================================*/
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete_notebook'){
$notebook_id = Security::remove_XSS($_REQUEST['notebook_id']);
$delete_notebook = delete_notebook_details($notebook_id);
if($delete_notebook) {
Display::display_confirmation_message(get_lang('NotebookDeleted'));
}
}
/*======================================
Display Notebook Details
======================================*/
$notebook_list=get_notebook_details($user_id);
echo '<div>';
$counter = 1;
while ($row_notebook_list=Database::fetch_array($notebook_list)){
$title= get_lang("Note").'&nbsp;'.$counter;
$notebook_id = $_REQUEST['notebook_id'];
echo '<div class="notebook-list">';
echo '<div class="note-number">';
echo '<span>'.$title.'</span>&nbsp;|&nbsp;';
echo '<span class="date_information" >'.$row_notebook_list['start_date'].'</span>';
echo '</div>';
if ((isset($_REQUEST['action']) && $_REQUEST['action']=='edit_notebook') && ($row_notebook_list['notebook_id'] == $notebook_id)){
echo '<div class="notebook-edit-form"><a name="note-'.$row_notebook_list['notebook_id'].'"></a>';
echo '<form name="frm_edit_notebook" action="index.php" method="post"><input type="hidden" name="upd_notebook_id" value="'.$notebook_id.'"';
echo '<input type="hidden" name="sec_token" value="'.$stok.'" />';
echo '<div class="upd-desc-notebook"><textarea class="style-edit-textarea" rows="4" cols="120" name="upd_description" maxlength="255" onfocus="this.select()">'.$row_notebook_list['description'].'</textarea></div>';
echo '<div class="action_notebook"><input type="button" value="Grabar" onclick="edit_notebook()"><input type="button" value="Cancelar" onclick="edit_cancel_notebook()"></div>';
echo '<span class="msg_error" id="msg_edit_error"></span>';
echo '</form></div>';
} else {
echo '<div class="desc-notebook">'.$row_notebook_list['description'].'</div>';
echo '<div class="notebook-term-action-links">';
echo '<span><a href="index.php?action=edit_notebook&notebook_id='.$row_notebook_list['notebook_id'].'#note-'.$row_notebook_list['notebook_id'].'" >'.Display::return_icon($icon_edit,get_lang('Edit')).'</a>&nbsp;';
echo '<a href="index.php?action=delete_notebook&notebook_id='.$row_notebook_list['notebook_id'].'" onclick="return confirmation(\''.$title.'\');">'.Display::return_icon($icon_delete,get_lang('Edit')).'</a></span>';
if ( $row_notebook_list['status']==1 ) {
echo '&nbsp;&nbsp;<span class="date_information">'.get_lang('EndDate').'&nbsp;:&nbsp;'.$row_notebook_list['end_date'].'</span>';
}
echo '</div>';
}
echo '</div>';
$counter++;
}
echo '</div>';
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();

@ -0,0 +1,146 @@
<?php //$id: $
/* For licensing terms, see /dokeos_license.txt */
/**
* @package dokeos.notebook
* @author Christian Fasanando
* This library enables maintenance of the notebook tool
*/
/**
* This function retrieves notebook details by users
* @return array Array of type ([notebook_id=>a,user_id=>b,course=>c,session_id=>d,description=>e,start_date=>f,end_date=>g,status=>h],[])
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version octubre 2008, dokeos 1.8.6
*/
function get_notebook_details($user_id) {
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$safe_user_id = Database::escape_string($user_id);
$sql = "SELECT note.notebook_id,note.user_id,note.course,note.session_id,
note.description,DATE_FORMAT(note.start_date,'%d/%m/%Y %H:%i:%s') as start_date,DATE_FORMAT(note.end_date,'%d/%m/%Y %H:%i:%s') as end_date,note.status
FROM $t_notebook note where note.user_id='$safe_user_id' ORDER BY note.start_date";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* This function add notebook details by users
* @param user_id type int
* @param course type String
* @param session_id type int
* @param description type String
* @param start_date type Date
* @return boolean
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version octubre 2008, dokeos 1.8
*/
function add_notebook_details($user_id,$course,$session_id,$description,$start_date) {
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$safe_user_id = (int)$user_id;
$safe_course = Database::escape_string($course);
$safe_session_id = (int)$session_id;
$safe_description = Database::escape_string($description);
if (empty($description) || empty($start_date)) {
return false;
}
$sql = "INSERT INTO $t_notebook(user_id,course,session_id,description,start_date,status)
VALUES('$safe_user_id' , '$safe_course','$safe_session_id','$safe_description','$start_date',0)";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* This function modify notebook details by users
* @param notebook_id type int
* @param user_id type int
* @param course type String
* @param session_id type int
* @param description type String
* @param end_date type Date
* @return boolean
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version octubre 2008, dokeos 1.8
*/
function edit_notebook_details($notebook_id,$user_id,$course,$session_id,$description,$end_date) {
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$safe_notebook_id = (int)$notebook_id;
$safe_user_id = (int)$user_id;
$safe_course = Database::escape_string($course);
$safe_session_id = (int)$session_id;
$safe_description = Database::escape_string($description);
if (empty($description) || empty($end_date)) {
return false;
}
$sql = "UPDATE $t_notebook SET user_id='$safe_user_id' , course='$safe_course',session_id='$safe_session_id',description='$safe_description',end_date='$end_date',status='1' WHERE notebook_id='$notebook_id'";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* This function delete notebook details by users
* @param notebook_id type int
* @return boolean
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version octubre 2008, dokeos 1.8
*/
function delete_notebook_details($notebook_id) {
$t_notebook = Database :: get_course_table(TABLE_NOTEBOOK);
$safe_notebook_id = (int)$notebook_id;
$sql = "DELETE FROM $t_notebook WHERE notebook_id=$safe_notebook_id";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* returns all the javascript that is required in notebook/index.php
* this goes into the $htmlHeadXtra[] array
*/
function to_javascript_notebook() {
return "<script type=\"text/javascript\">
function confirmation (name)
{
if (confirm(\" ". get_lang("AreYouSureToDeleteThis") ." \"+ name + \" ?\"))
{return true;}
else
{return false;}
}
function add_notebook() {
msg_error='".get_lang("YouMustWriteANote")."';
msg='<<".get_lang("WriteHereYourNote").">>';
if(document.frm_add_notebook.description.value=='' || document.frm_add_notebook.description.value==msg) {
document.getElementById('msg_add_error').style.display='block';
document.getElementById('msg_add_error').innerHTML=msg_error;
} else {
document.frm_add_notebook.submit();
}
}
function edit_cancel_notebook() {
document.frm_edit_notebook.upd_notebook_id.value = '';
document.frm_edit_notebook.upd_description.value = '';
document.frm_edit_notebook.submit();
}
function edit_notebook() {
msg_error='".get_lang("YouMustWriteANote")."';
if(document.frm_edit_notebook.upd_description.value=='') {
document.getElementById('msg_edit_error').style.display='block';
document.getElementById('msg_edit_error').innerHTML=msg_error;
} else {
document.frm_edit_notebook.submit();
}
}
</script>";
}
Loading…
Cancel
Save