/** * Delete sessions categories * @author Jhon Hinojosa <*****@*****.**>, from existing code * @param array id_checked * @param bool include delete session * @param bool optional, true if the function is called by a webservice, false otherwise. * @return void Nothing, or false on error * The parameters is a array to delete sessions * */ public static function delete_session_category($id_checked, $delete_session = false, $from_ws = false) { $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); if (is_array($id_checked)) { $id_checked = Database::escape_string(implode(',', $id_checked)); } else { $id_checked = intval($id_checked); } //Setting session_category_id to 0 $sql = "UPDATE {$tbl_session} SET session_category_id = 0\n WHERE session_category_id IN (" . $id_checked . ")"; Database::query($sql); $sql = "SELECT id FROM {$tbl_session} WHERE session_category_id IN (" . $id_checked . ")"; $result = Database::query($sql); while ($rows = Database::fetch_array($result)) { $session_id = $rows['id']; if ($delete_session) { if ($from_ws) { SessionManager::delete($session_id, true); } else { SessionManager::delete($session_id); } } } $sql = "DELETE FROM {$tbl_session_category} WHERE id IN (" . $id_checked . ")"; Database::query($sql); // Add event to system log $user_id = api_get_user_id(); Event::addEvent(LOG_SESSION_CATEGORY_DELETE, LOG_SESSION_CATEGORY_ID, $id_checked, api_get_utc_datetime(), $user_id); return true; }
/* For licensing terms, see /license.txt */ /** * List sessions in an efficient and usable way * @package chamilo.admin */ $cidReset = true; require_once '../inc/global.inc.php'; $this_section = SECTION_PLATFORM_ADMIN; SessionManager::protectSession(null, false); //Add the JS needed to use the jqgrid $htmlHeadXtra[] = api_get_jqgrid_js(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null; $list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple'; if ($action == 'delete') { SessionManager::delete($idChecked); Display::addFlash(Display::return_message(get_lang('Deleted'))); header('Location: session_list.php'); exit; } elseif ($action == 'copy') { $result = SessionManager::copy($idChecked); if ($result) { Display::addFlash(Display::return_message(get_lang('ItemCopied'))); } else { Display::addFlash(Display::return_message(get_lang('ThereWasAnError'), 'error')); } header('Location: session_list.php'); exit; } $tool_name = get_lang('SessionList'); Display::display_header($tool_name);
/** * Deletes a session (helper method) * * @param string Session id field name * @param string Session id value * @return mixed True in case of success, WSError otherwise */ protected function deleteSessionHelper($session_id_field_name, $session_id_value) { $session_id = $this->getSessionId($session_id_field_name, $session_id_value); if ($session_id instanceof WSError) { return $session_id; } else { SessionManager::delete($session_id, true); return true; } }