"session_list.php", "name" => get_lang('SessionList')]; $interbreadcrumb[] = ['url' => "resume_session.php?id_session=".$id, "name" => get_lang('SessionOverview')]; if (isset($_POST['formSent']) && $_POST['formSent']) { $formSent = 1; } $order_clause = 'ORDER BY '; $order_clause .= api_sort_by_first_name() ? 'firstname, lastname, username' : 'lastname, firstname, username'; $sql = "SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause; if (api_is_multiple_url_enabled()) { $table_access_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $sql = "SELECT DISTINCT u.user_id,lastname,firstname,username FROM $tbl_user u INNER JOIN $table_access_url_rel_user url_rel_user ON (url_rel_user.user_id = u.user_id) WHERE status='1' AND access_url_id = '$access_url_id' $order_clause"; } } $result = Database::query($sql); $coaches = Database::store_result($result); $thisYear = date('Y'); $coachesOption = [ '' => '----- '.get_lang('None').' -----', ]; foreach ($coaches as $coach) { $personName = api_get_person_name($coach['firstname'], $coach['lastname']); $coachesOption[$coach['user_id']] = "$personName ({$coach['username']})"; } $categoriesList = SessionManager::get_all_session_category(); $categoriesOption = [ '0' => get_lang('None'), ]; if ($categoriesList != false) { foreach ($categoriesList as $categoryItem) { $categoriesOption[$categoryItem['id']] = $categoryItem['name']; } } $formAction = api_get_self().'?'; $formAction .= http_build_query([ 'page' => Security::remove_XSS($_GET['page']), 'id' => $id, ]); $form = new FormValidator('edit_session', 'post', $formAction); $form->addElement('header', $tool_name); $result = SessionManager::setForm($form, $sessionInfo); $htmlHeadXtra[] = ' '; $form->addButtonUpdate(get_lang('ModifyThisSession')); $formDefaults = $sessionInfo; $formDefaults['coach_username'] = $sessionInfo['id_coach']; $formDefaults['session_category'] = $sessionInfo['session_category_id']; $formDefaults['session_visibility'] = $sessionInfo['visibility']; if ($formSent) { $formDefaults['name'] = api_htmlentities($name, ENT_QUOTES, $charset); } else { $formDefaults['name'] = Security::remove_XSS($sessionInfo['name']); } $form->setDefaults($formDefaults); if ($form->validate()) { $params = $form->getSubmitValues(); $name = $params['name']; $startDate = $params['access_start_date']; $endDate = $params['access_end_date']; $displayStartDate = $params['display_start_date']; $displayEndDate = $params['display_end_date']; $coachStartDate = $params['coach_access_start_date']; $coachEndDate = $params['coach_access_end_date']; $coach_username = intval($params['coach_username']); $id_session_category = $params['session_category']; $id_visibility = $params['session_visibility']; $duration = isset($params['duration']) ? $params['duration'] : null; if ($params['access'] == 1) { $duration = null; } $description = $params['description']; $showDescription = isset($params['show_description']) ? 1 : 0; $sendSubscriptionNotification = isset($params['send_subscription_notification']); $isThisImageCropped = isset($params['picture_crop_result']); $extraFields = []; foreach ($params as $key => $value) { if (strpos($key, 'extra_') === 0) { $extraFields[$key] = $value; } } if (isset($extraFields['extra_image']) && $isThisImageCropped) { $extraFields['extra_image']['crop_parameters'] = $params['picture_crop_result']; } $return = SessionManager::edit_session( $id, $name, $startDate, $endDate, $displayStartDate, $displayEndDate, $coachStartDate, $coachEndDate, $coach_username, $id_session_category, $id_visibility, $description, $showDescription, $duration, $extraFields, null, $sendSubscriptionNotification ); if ($return) { Display::addFlash(Display::return_message(get_lang('Updated'))); header('Location: resume_session.php?id_session='.$return); exit(); } } // display the header Display::display_header($tool_name); $form->display(); ?>