registerFunction ('search_courses'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions api_protect_admin_script(true); // setting breadcrumbs $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList')); // Database Table Definitions $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); // setting the name of the tool $tool_name= get_lang('SubscribeSessionsToCategory'); $id_session=intval($_GET['id_session']); $add_type = 'multiple'; if (isset($_GET['add_type']) && $_GET['add_type']!=''){ $add_type = Security::remove_XSS($_REQUEST['add_type']); } if (!api_is_platform_admin() && !api_is_session_admin()) { $sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session; $rs = Database::query($sql); if (Database::result($rs,0,0)!=$_user['user_id']) { api_not_allowed(true); } } $xajax -> processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ''; $formSent=0; $errorMsg = $firstLetterCourse = $firstLetterSession=''; $CourseList=$SessionList=array(); $courses=$sessions=array(); $Categoryid = intval($_POST['CategorySessionId']); if ($_POST['formSent']) { $formSent=$_POST['formSent']; $SessionCategoryList = $_POST['SessionCategoryList']; if($Categoryid != 0 && count($SessionCategoryList)>0 ){ $session_id = join(',', $SessionCategoryList); $sql = "UPDATE $tbl_session SET session_category_id = $Categoryid WHERE id in ($session_id) "; Database::query($sql); header('Location: add_many_session_to_category.php?id_category='.$Categoryid.'&msg=ok'); exit; } else { header('Location: add_many_session_to_category.php?msg=error'); exit; } } if (isset($_GET['id_category'])) { $Categoryid = intval($_GET['id_category']); } if (isset($_GET['msg']) && $_GET['msg']=='error'){ $errorMsg = get_lang('MsgErrorSessionCategory'); } if (isset($_GET['msg']) && $_GET['msg']=='ok'){ $OkMsg = get_lang('SessionCategoryUpdate'); } // display the dokeos header Display::display_header($tool_name); $where =''; $rows_category_session = array(); if ((isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0) || isset($_GET['id_category']) ) { $where = 'WHERE session_category_id !='.$Categoryid; $sql = 'SELECT id, name FROM '.$tbl_session .' WHERE session_category_id ='.$Categoryid.' ORDER BY name'; $result=Database::query($sql); $rows_category_session = Database::store_result($result); } $rows_session_category = SessionManager::get_all_session_category(); if (empty($rows_session_category)) { Display::display_warning_message(get_lang('YouNeedToAddASessionCategoryFirst')); Display::display_footer(); exit; } $sql = "SELECT id, name FROM $tbl_session $where ORDER BY name"; $result=Database::query($sql); $rows_session = Database::store_result($result); ?>