From 0855bd9cebfc4f3376ea7178b8953556ee71fb4b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 24 Feb 2011 14:40:21 +0100 Subject: [PATCH] Session category are now filtered by access_url_id (Multiple URLs) see BT#1220 --- main/admin/add_many_session_to_category.php | 15 ++-------- main/admin/session_add.php | 14 ++-------- main/admin/session_category_add.php | 31 ++++----------------- main/admin/session_category_edit.php | 20 +------------ main/admin/session_category_list.php | 14 ++++++---- main/admin/session_edit.php | 17 ++--------- main/inc/lib/sessionmanager.lib.php | 25 +++++++++++++++-- main/install/db_main.sql | 3 +- main/install/migrate-db-1.8.7-1.8.8-pre.sql | 9 +++--- 9 files changed, 51 insertions(+), 97 deletions(-) diff --git a/main/admin/add_many_session_to_category.php b/main/admin/add_many_session_to_category.php index 7546520c40..5886df7639 100755 --- a/main/admin/add_many_session_to_category.php +++ b/main/admin/add_many_session_to_category.php @@ -91,9 +91,6 @@ $formSent=0; $errorMsg = $firstLetterCourse = $firstLetterSession=''; $CourseList=$SessionList=array(); $courses=$sessions=array(); -$noPHP_SELF=true; - - $Categoryid = intval($_POST['CategorySessionId']); if ($_POST['formSent']) { @@ -131,7 +128,6 @@ Display::display_header($tool_name); echo '
'.$tool_name.'

'; -// ******************* $where =''; $rows_category_session = array(); if((isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0) || isset($_GET['id_category']) ) { @@ -142,9 +138,7 @@ if((isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0) || isset($_GE $rows_category_session = Database::store_result($result); } -$sql = "SELECT id, name FROM $tbl_session_category ORDER BY name"; -$result=Database::query($sql); -$rows_session_category = Database::store_result($result); +$rows_session_category = SessionManager::get_all_session_category(); $sql = "SELECT id, name FROM $tbl_session $where ORDER BY name"; $result=Database::query($sql); @@ -298,8 +292,5 @@ function valide(){ \ No newline at end of file +/* FOOTER */ +Display::display_footer(); \ No newline at end of file diff --git a/main/admin/session_add.php b/main/admin/session_add.php index c2408c9f66..2d66c12621 100755 --- a/main/admin/session_add.php +++ b/main/admin/session_add.php @@ -204,7 +204,6 @@ if (intval($count_users)<50) { WHERE access_url_id = '.$access_url_id.' AND status=1'.$order_clause; } } - $result=Database::query($sql); $Coaches=Database::store_result($result); ?> @@ -214,7 +213,6 @@ if (intval($count_users)<50) { -
- - +$Categories = SessionManager::get_all_session_category(); +?> - diff --git a/main/admin/session_category_add.php b/main/admin/session_category_add.php index fd56461c6e..096af16b45 100755 --- a/main/admin/session_category_add.php +++ b/main/admin/session_category_add.php @@ -1,29 +1,8 @@ registerFunction ('search_coachs'); diff --git a/main/admin/session_category_edit.php b/main/admin/session_category_edit.php index 30311cbbdc..46b0bd314a 100755 --- a/main/admin/session_category_edit.php +++ b/main/admin/session_category_edit.php @@ -1,23 +1,5 @@
- - +
@@ -117,7 +116,6 @@ if (!empty($return)) { - - -
     
@@ -146,8 +138,6 @@ unset($Coaches);
  @@ -395,5 +385,4 @@ function disable_starttime(select) { +Display::display_footer(); \ No newline at end of file diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 7e7ab2fc33..36c2eea396 100755 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -891,8 +891,9 @@ class SessionManager { $msg=get_lang('StartDateShouldBeBeforeEndDate'); return $msg; } - $sql = "INSERT INTO $tbl_session_category(name, date_start, date_end) - VALUES('".Database::escape_string($name)."','$date_start','$date_end')"; + $access_url_id = api_get_current_access_url_id(); + $sql = "INSERT INTO $tbl_session_category (name, date_start, date_end, access_url_id) + VALUES('".Database::escape_string($name)."','$date_start','$date_end', '$access_url_id')"; Database::query($sql); $id_session=Database::insert_id(); // add event to system log @@ -900,7 +901,6 @@ class SessionManager { $user_id = api_get_user_id(); event_system(LOG_SESSION_CATEGORY_CREATE, LOG_SESSION_CATEGORY_ID, $id_session, $time, $user_id); return $id_session; - } /** @@ -1062,6 +1062,7 @@ class SessionManager { } return $return_array; } + /** * Get the session category information by id * @param string session category ID @@ -1079,6 +1080,24 @@ class SessionManager { return false; } } + + /** + * Get all session categories (filter by access_url_id) + * @return mixed false if the session category does not exist, array if the session category exists + */ + public static function get_all_session_category() { + $id = intval($id); + $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); + $id = api_get_current_access_url_id(); + $sql = 'SELECT * FROM '.$tbl_session_category.' WHERE access_url_id ="'.$id.'" ORDER BY name ASC'; + $result = Database::query($sql); + if (Database::num_rows($result) > 0 ){ + $data = Database::store_result($result,'ASSOC'); + return $data; + } else { + return false; + } + } /** * Assign a coach to course in session with status = 2 diff --git a/main/install/db_main.sql b/main/install/db_main.sql index 5d4e4769f8..794ca2c9a9 100755 --- a/main/install/db_main.sql +++ b/main/install/db_main.sql @@ -820,7 +820,7 @@ VALUES ('show_groups_to_users',NULL,'radio','Platform','true','ShowGroupsToUsersTitle','ShowGroupsToUsersComment',NULL,NULL, 0), ('accessibility_font_resize',NULL,'radio','Platform','false','EnableAccessibilityFontResizeTitle','EnableAccessibilityFontResizeComment',NULL,NULL, 1), ('hide_courses_in_sessions',NULL,'radio', 'Platform','false','HideCoursesInSessionsTitle', 'HideCoursesInSessionsComment','platform',NULL, 1), -('chamilo_database_version',NULL,'textfield',NULL, '1.8.8.13860','DokeosDatabaseVersion','', NULL, NULL, 0); +('chamilo_database_version',NULL,'textfield',NULL, '1.8.8.13997','DokeosDatabaseVersion','', NULL, NULL, 0); UNLOCK TABLES; /*!40000 ALTER TABLE settings_current ENABLE KEYS */; @@ -2429,6 +2429,7 @@ CREATE TABLE session_category ( name varchar(100) default NULL, date_start date default NULL, date_end date default NULL, + access_url_id INT NOT NULL default 1, PRIMARY KEY (id) ); diff --git a/main/install/migrate-db-1.8.7-1.8.8-pre.sql b/main/install/migrate-db-1.8.7-1.8.8-pre.sql index 2b07254a53..94e32b2169 100755 --- a/main/install/migrate-db-1.8.7-1.8.8-pre.sql +++ b/main/install/migrate-db-1.8.7-1.8.8-pre.sql @@ -88,9 +88,6 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value, INSERT INTO settings_options (variable, value, display_text) VALUES ('hide_courses_in_sessions','true','Yes'); INSERT INTO settings_options (variable, value, display_text) VALUES ('hide_courses_in_sessions','false','No'); - - - INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('pdf_export_watermark_text', NULL,'textfield', 'Platform', '', 'PDFExportWatermarkTextTitle','PDFExportWatermarkTextComment','platform',NULL, 1); ALTER TABLE personal_agenda ADD PRIMARY KEY (id); @@ -159,7 +156,7 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('show_group INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('हिन्दी', 'hindi', 'hi', 'hindi', 0); -ALTER TABLE session ADD promotion_id INT NOT NULL; +ALTER TABLE session ADD COLUMN promotion_id INT NOT NULL; CREATE TABLE career (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, status INT NOT NULL default '0', created_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id)); CREATE TABLE promotion (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, description TEXT NOT NULL, status INT NOT NULL default '0', career_id INT NOT NULL, created_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', updated_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY(id)); @@ -178,7 +175,9 @@ CREATE TABLE notification (id BIGINT PRIMARY KEY NOT NULL AUTO_INCREMENT,dest_us ALTER TABLE notification ADD index mail_notify_sent_index (sent_at); ALTER TABLE notification ADD index mail_notify_freq_index (sent_at, send_freq, created_at); -UPDATE settings_current SET selected_value = '1.8.8.13860' WHERE variable = 'chamilo_database_version'; +ALTER TABLE session_category ADD COLUMN access_url_id INT NOT NULL default 1; + +UPDATE settings_current SET selected_value = '1.8.8.13997' WHERE variable = 'chamilo_database_version'; -- xxSTATSxx ALTER TABLE track_e_exercices ADD COLUMN orig_lp_item_view_id INT NOT NULL DEFAULT 0;