'.get_lang('ThisFieldIsRequired'), 'required');
- $form->addRule('template_text', '
'.get_lang('ThisFieldIsRequired'), 'required');
-
- // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed)
- if( $form->validate() )
- {
-
- $check = Security::check_token('post');
- if ($check) {
- // exporting the values
- $values = $form->exportValues();
- // upload the file
- if (!empty($_FILES['template_image']['name']))
- {
- include_once (api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
- $upload_ok = process_uploaded_file($_FILES['template_image']);
-
- if ($upload_ok)
- {
- // Try to add an extension to the file if it hasn't one
- $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']);
-
- // upload dir
- $upload_dir = api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/';
-
- // create dir if not exists
- if (!is_dir($upload_dir)) {
- mkdir($upload_dir, api_get_permissions_for_new_directories());
- }
-
- // resize image to max default and upload
- require_once (api_get_path(LIBRARY_PATH).'image.lib.php');
- $temp = new image($_FILES['template_image']['tmp_name']);
- $picture_infos=@getimagesize($_FILES['template_image']['tmp_name']);
-
- $max_width_for_picture = 100;
-
- if ($picture_infos[0]>$max_width_for_picture)
- {
- $thumbwidth = $max_width_for_picture;
- if (empty($thumbwidth) or $thumbwidth==0) {
- $thumbwidth=$max_width_for_picture;
- }
- $new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
-
- $temp->resize($thumbwidth,$new_height,0);
- }
-
- $type=$picture_infos[2];
-
- switch (!empty($type))
- {
- case 2 : $temp->send_image('JPG',$upload_dir.$new_file_name);
- break;
- case 3 : $temp->send_image('PNG',$upload_dir.$new_file_name);
- break;
- case 1 : $temp->send_image('GIF',$upload_dir.$new_file_name);
- break;
- }
- }
- }
-
- // store the information in the database (as insert or as update)
- $table_system_template = Database :: get_main_table('system_template');
- if ($_GET['action'] == 'add') {
- $content_template = '{CSS}'.Database::escape_string($values['template_text']).'';
- $sql = "INSERT INTO $table_system_template (title, content, image) VALUES ('".Database::escape_string($values['title'])."','".$content_template."','".Database::escape_string($new_file_name)."')";
- $result = Database::query($sql);
-
- // display a feedback message
- Display::display_confirmation_message(get_lang('TemplateAdded'));
- echo '
'.Display::return_icon('template_add.gif', get_lang('AddTemplate')).get_lang('AddTemplate').'';
- } else {
- $content_template = '{CSS}'.Database::escape_string($values['template_text']).'';
- $sql = "UPDATE $table_system_template set title = '".Database::escape_string($values['title'])."',
- content = '".$content_template."'";
- if (!empty($new_file_name))
- {
- $sql .= ", image = '".Database::escape_string($new_file_name)."'";
- }
- $sql .= " WHERE id='".Database::escape_string($_GET['id'])."'";
- $result = Database::query($sql);
-
- // display a feedback message
- Display::display_confirmation_message(get_lang('TemplateEdited'));
- }
-
- }
- Security::clear_token();
- display_templates();
- }
- else
- {
- $token = Security::get_token();
- $form->addElement('hidden','sec_token');
- $form->setConstants(array('sec_token' => $token));
- // display the form
- $form->display();
- }
-}
-
-/**
- * Delete a template
- *
- * @param integer $id the id of the template that has to be deleted
- *
- * @author Patrick Cool
, Ghent University, Belgium
- * @version August 2008
- * @since Dokeos 1.8.6
- */
-function delete_template($id)
-{
- // first we remove the image
- $table_system_template = Database :: get_main_table('system_template');
- $sql = "SELECT * FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
- $result = Database::query($sql);
- $row = Database::fetch_array($result);
- if (!empty($row['image']))
- {
- @unlink(api_get_path(SYS_PATH).'home/default_platform_document/template_thumb/'.$row['image']);
- }
-
- // now we remove it from the database
- $sql = "DELETE FROM $table_system_template WHERE id = '".Database::escape_string($id)."'";
- $result = Database::query($sql);
-
- // display a feedback message
- Display::display_confirmation_message(get_lang('TemplateDeleted'));
-}
-?>
diff --git a/main/install/dokeos_main.sql b/main/install/dokeos_main.sql
index 42efdf09f9..703b026f6f 100755
--- a/main/install/dokeos_main.sql
+++ b/main/install/dokeos_main.sql
@@ -217,7 +217,7 @@ CREATE TABLE course_field (
field_visible tinyint default 0,
field_changeable tinyint default 0,
field_filter tinyint default 0,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY(id)
);
@@ -231,7 +231,7 @@ CREATE TABLE course_field_values(
course_code varchar(40) NOT NULL,
field_id int NOT NULL,
field_value text,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY(id)
);
@@ -517,7 +517,7 @@ CREATE TABLE session_field (
field_visible tinyint default 0,
field_changeable tinyint default 0,
field_filter tinyint default 0,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY(id)
);
@@ -527,7 +527,7 @@ CREATE TABLE session_field_values(
session_id int NOT NULL,
field_id int NOT NULL,
field_value text,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY(id)
);
@@ -1162,7 +1162,7 @@ CREATE TABLE user_field (
field_visible tinyint default 0,
field_changeable tinyint default 0,
field_filter tinyint default 0,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY(id)
);
DROP TABLE IF EXISTS user_field_options;
@@ -1172,7 +1172,7 @@ CREATE TABLE user_field_options (
option_value text,
option_display_text varchar(64),
option_order int,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id)
);
DROP TABLE IF EXISTS user_field_values;
@@ -1181,7 +1181,7 @@ CREATE TABLE user_field_values(
user_id int unsigned NOT NULL,
field_id int NOT NULL,
field_value text,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY(id)
);
@@ -1226,7 +1226,7 @@ CREATE TABLE access_url(
description text,
active int unsigned not null default 0,
created_by int not null,
- tms TIMESTAMP,
+ tms DATETIME NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id)
);
@@ -2393,4 +2393,4 @@ PRIMARY KEY(id)
);
ALTER TABLE block ADD UNIQUE(path);
-INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(1, 'dashboard', 'dashboard', 0, 0);
\ No newline at end of file
+INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(1, 'dashboard', 'dashboard', 0, 0);
diff --git a/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql b/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql
index e766e75aad..fcf3f3c98f 100755
--- a/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql
+++ b/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql
@@ -20,7 +20,6 @@ ALTER TABLE course_rel_user ADD COLUMN relation_type int NOT NULL default 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 course_module (name, link, image, `row`, `column`, position) VALUES ('notebook','notebook/index.php','notebook.gif',2,1,'basic');
-UPDATE settings_current SET selected_value = '1.8.7.10308' WHERE variable = 'dokeos_database_version';
ALTER TABLE course DROP PRIMARY KEY , ADD UNIQUE KEY code (code);
ALTER TABLE course ADD id int NOT NULL auto_increment PRIMARY KEY FIRST;
CREATE TABLE block (id INT NOT NULL auto_increment, name VARCHAR(255) NULL, description TEXT NULL, path VARCHAR(255) NOT NULL, controller VARCHAR(100) NOT NULL, active TINYINT NOT NULL default 1, PRIMARY KEY(id));
@@ -28,6 +27,20 @@ ALTER TABLE block ADD UNIQUE(path);
INSERT INTO user_field(field_type, field_variable, field_display_text, field_visible, field_changeable) VALUES(1, 'dashboard', 'dashboard', 0, 0);
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'dashboard', 'checkbox', 'Platform', 'true', 'ShowTabsTitle','ShowTabsComment',NULL,'TabsDashboard', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('users_can_change_timezone', 'timezones', 'radio', 'Timezones', 'true', 'AllowUsersTimezoneTitle','AllowUsersTimezoneComment',NULL,'Timezones', 1);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('users_can_change_timezone', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('users_can_change_timezone', 'false', 'No');
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('timezone_value', 'timezones', 'select', 'Timezones', 'UTC', 'TimezoneValueTitle','TimezoneValueComment',NULL,'Timezones', 1);
+
+ALTER TABLE user_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE course_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE course_field_values CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE session_field CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE session_field_values CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE user_field_options CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE user_field_values CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+ALTER TABLE access_url CHANGE tms tms DATETIME NOT NULL default '0000-00-00 00:00:00';
+UPDATE settings_current SET selected_value = '1.8.7.10365' WHERE variable = 'dokeos_database_version';
-- xxSTATSxx
CREATE TABLE track_e_item_property(id int NOT NULL auto_increment PRIMARY KEY, course_id int NOT NULL, item_property_id int NOT NULL, title varchar(255), content text, progress int NOT NULL default 0, lastedit_date datetime NOT NULL default '0000-00-00 00:00:00', lastedit_user_id int NOT NULL, session_id int NOT NULL default 0);
@@ -50,4 +63,4 @@ ALTER TABLE attendance_result ADD INDEX(attendance_id);
ALTER TABLE attendance_result ADD INDEX(user_id);
CREATE TABLE attendance (id int NOT NULL auto_increment PRIMARY KEY, name text NOT NULL, description TEXT NULL, active tinyint(3) NOT NULL default 1, attendance_qualify_title varchar(255) NULL, attendance_qualify_max int NOT NULL default 0, attendance_weight float(6,2) NOT NULL default '0.0', session_id int NOT NULL default 0);
ALTER TABLE attendance ADD INDEX(session_id);
-ALTER TABLE attendance ADD INDEX(active);
\ No newline at end of file
+ALTER TABLE attendance ADD INDEX(active);