本文整理汇总了PHP中SessionManager::edit_session方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::edit_session方法的具体用法?PHP SessionManager::edit_session怎么用?PHP SessionManager::edit_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::edit_session方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WSEditSession
function WSEditSession($params)
{
global $_user;
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sessions_params = $params['sessions'];
$results = array();
$orig_session_id_value = array();
foreach ($sessions_params as $session_param) {
$name = trim($session_param['name']);
$year_start = intval($session_param['year_start']);
$month_start = intval($session_param['month_start']);
$day_start = intval($session_param['day_start']);
$year_end = intval($session_param['year_end']);
$month_end = intval($session_param['month_end']);
$day_end = intval($session_param['day_end']);
$nb_days_access_before = intval($session_param['nb_days_access_before']);
$nb_days_access_after = intval($session_param['nb_days_access_after']);
$original_session_id_value = $session_param['original_session_id_value'];
$original_session_id_name = $session_param['original_session_id_name'];
$orig_session_id_value[] = $original_session_id_value;
$coach_username = $session_param['coach_username'];
$nolimit = $session_param['nolimit'];
$id_coach = $session_param['user_id'];
$extra_list = $session_param['extra'];
$id = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
if (empty($id)) {
$results[] = 0;
continue;
}
if (empty($nolimit)) {
$date_start = "{$year_start}-" . ($month_start < 10 ? "0{$month_start}" : $month_start) . "-" . ($day_start < 10 ? "0{$day_start}" : $day_start);
$date_end = "{$year_end}-" . ($month_end < 10 ? "0{$month_end}" : $month_end) . "-" . ($day_end < 10 ? "0{$day_end}" : $day_end);
} else {
$date_start = "";
$date_end = "";
}
if (empty($name)) {
$results[] = 0;
//SessionNameIsRequired
continue;
} elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
$results[] = 0;
//InvalidStartDate
continue;
} elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end, $day_end, $year_end))) {
$results[] = 0;
//InvalidEndDate
continue;
} elseif (empty($nolimit) && $date_start >= $date_end) {
$results[] = 0;
//StartDateShouldBeBeforeEndDate
continue;
} else {
$startDate = new DateTime($date_start);
$endDate = new DateTime($date_end);
$diffStart = new DateInterval($nb_days_access_before);
$diffEnd = new DateInterval($nb_days_access_after);
$coachStartDate = $startDate->sub($diffStart);
$coachEndDate = $endDate->add($diffEnd);
$sessionInfo = api_get_session_info($id);
SessionManager::edit_session($id, $name, $date_start, $date_end, $date_start, $date_end, $coachStartDate->format('Y-m-d H:i:s'), $coachEndDate->format('Y-m-d H:i:s'), $id_coach, $sessionInfo['session_category_id'], $sessionInfo['visibility'], $sessionInfo['description'], $sessionInfo['show_description'], $sessionInfo['duration'], null, $_user['user_id']);
if (is_array($extra_list) && count($extra_list) > 0) {
foreach ($extra_list as $extra) {
$extra_field_name = $extra['field_name'];
$extra_field_value = $extra['field_value'];
// Save the external system's id into session_field_value table.
$res = SessionManager::update_session_extra_field_value($id, $extra_field_name, $extra_field_value);
}
}
$results[] = 1;
continue;
}
}
// end principal foreach
$count_results = count($results);
$output = array();
for ($i = 0; $i < $count_results; $i++) {
$output[] = array('original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
}
return $output;
}
示例2: importSessionsStatic
/**
* Updates the session synchronize with the csv file.
* @param string $file
*/
private function importSessionsStatic($file)
{
$content = file($file);
$sessions = array();
if (!api_strstr($content[0], ';')) {
$error_message = get_lang('NotCSV');
} else {
$tag_names = array();
foreach ($content as $key => $enreg) {
$enreg = explode(';', trim($enreg));
if ($key) {
foreach ($tag_names as $tag_key => $tag_name) {
$sessions[$key - 1][$tag_name] = $enreg[$tag_key];
}
} else {
foreach ($enreg as $tag_name) {
$tag_names[] = api_preg_replace('/[^a-zA-Z0-9_\\-]/', '', $tag_name);
}
if (!in_array('SessionName', $tag_names) || !in_array('DateStart', $tag_names) || !in_array('DateEnd', $tag_names)) {
$error_message = get_lang('NoNeededData');
break;
}
}
}
}
if (!empty($sessions)) {
// Looping the sessions.
foreach ($sessions as $session) {
if (!empty($session['SessionID'])) {
$sessionId = SessionManager::get_session_id_from_original_id($session['SessionID'], $this->extraFieldIdNameList['session']);
$coachUserName = isset($session['Coach']) ? $session['Coach'] : null;
$categoryId = isset($session['category_id']) ? $session['category_id'] : null;
// 2014-06-30
$dateStart = explode('/', $session['DateStart']);
$dateEnd = explode('/', $session['DateEnd']);
$visibility = $this->defaultSessionVisibility;
$coachId = null;
if (!empty($coachUserName)) {
$coachInfo = api_get_user_info_from_username($coachUserName);
$coachId = $coachInfo['user_id'];
}
if (empty($sessionId)) {
$result = SessionManager::create_session($session['SessionName'], $dateStart[0], $dateStart[1], $dateStart[2], $dateEnd[0], $dateEnd[1], $dateEnd[2], $this->daysCoachAccessBeforeBeginning, $this->daysCoachAccessAfterBeginning, null, $coachUserName, $categoryId, $visibility, 1);
if (is_numeric($result)) {
$sessionId = $result;
SessionManager::update_session_extra_field_value($sessionId, $this->extraFieldIdNameList['session'], $session['SessionID']);
}
} else {
$sessionInfo = api_get_session_info($sessionId);
$accessBefore = null;
$accessAfter = null;
if (empty($sessionInfo['nb_days_access_before_beginning']) || !empty($sessionInfo['nb_days_access_before_beginning']) && $sessionInfo['nb_days_access_before_beginning'] < $this->daysCoachAccessBeforeBeginning) {
$accessBefore = intval($this->daysCoachAccessBeforeBeginning);
}
$accessAfter = null;
if (empty($sessionInfo['nb_days_access_after_end']) || !empty($sessionInfo['nb_days_access_after_end']) && $sessionInfo['nb_days_access_after_end'] < $this->daysCoachAccessAfterBeginning) {
$accessAfter = intval($this->daysCoachAccessAfterBeginning);
}
$showDescription = isset($sessionInfo['show_description']) ? $sessionInfo['show_description'] : 1;
$result = SessionManager::edit_session($sessionId, $session['SessionName'], $dateStart[0], $dateStart[1], $dateStart[2], $dateEnd[0], $dateEnd[1], $dateEnd[2], $accessBefore, $accessAfter, null, $coachId, $categoryId, $visibility, true, true, null, $showDescription);
if (is_numeric($result)) {
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$params = array('description' => $session['SessionDescription']);
Database::update($tbl_session, $params, array('id = ?' => $sessionId));
}
}
// Courses
$courses = explode('|', $session['Courses']);
$courseList = array();
foreach ($courses as $course) {
$courseArray = bracketsToArray($course);
$courseCode = $courseArray[0];
if (CourseManager::course_exists($courseCode)) {
$courseList[] = $courseCode;
}
}
SessionManager::add_courses_to_session($sessionId, $courseList, true);
if (!empty($sessionId)) {
$courses = explode('|', $session['Courses']);
foreach ($courses as $course) {
$courseArray = bracketsToArray($course);
$courseCode = $courseArray[0];
if (CourseManager::course_exists($courseCode)) {
// Coaches
$courseCoaches = isset($courseArray[1]) ? $courseArray[1] : null;
$courseCoaches = explode(',', $courseCoaches);
if (!empty($courseCoaches)) {
$coachList = array();
foreach ($courseCoaches as $courseCoach) {
$courseCoachId = UserManager::get_user_id_from_username($courseCoach);
if ($courseCoachId !== false) {
// Just insert new coaches
$coachList[] = $courseCoachId;
}
}
SessionManager::updateCoaches($sessionId, $courseCode, $coachList, true);
//.........这里部分代码省略.........
示例3: isset
$nb_days_acess_after = $_POST['nb_days_access_after'];
//$nolimit = $_POST['nolimit'];
$id_coach = $_POST['id_coach'];
$id_session_category = $_POST['session_category'];
$id_visibility = $_POST['session_visibility'];
$duration = isset($_POST['duration']) ? $_POST['duration'] : null;
$description = isset($_POST['description']) ? $_POST['description'] : null;
$showDescription = isset($_POST['show_description']) ? 1 : 0;
$end_limit = $_POST['end_limit'];
$start_limit = $_POST['start_limit'];
if (empty($end_limit) && empty($start_limit)) {
$nolimit = 1;
} else {
$nolimit = null;
}
$return = SessionManager::edit_session($id, $name, $year_start, $month_start, $day_start, $year_end, $month_end, $day_end, $nb_days_acess_before, $nb_days_acess_after, $nolimit, $id_coach, $id_session_category, $id_visibility, $start_limit, $end_limit, $description, $showDescription, $duration);
if ($return == strval(intval($return))) {
header('Location: resume_session.php?id_session=' . $return);
exit;
}
}
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY 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)\n\t\t\t WHERE status='1' AND access_url_id = '{$access_url_id}' {$order_clause}";
}
}
$result = Database::query($sql);
示例4: editSessionHelper
/**
* Edits a session (helper method)
*
* @param string Name of the session
* @param string Start date, use the 'YYYY-MM-DD' format
* @param string End date, use the 'YYYY-MM-DD' format
* @param int Access delays of the coach (days before)
* @param int Access delays of the coach (days after)
* @param int Nolimit (0 = no limit of time, 1 = limit of time)
* @param int Visibility
* @param string User id field name for the coach
* @param string User id value for the coach
* @param string Original session id field name (use "chamilo_session_id" to use internal id)
* @param string Original session id value
* @param array Array of extra fields
* @return mixed True on success, WSError otherwise
*/
protected function editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras)
{
$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
if ($session_id instanceof WSError) {
return $session_id;
} else {
// Verify that coach exists and get its id
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if ($user_id instanceof WSError) {
return $user_id;
}
$coachStartDate = null;
if (!empty($nb_days_access_before)) {
$day = intval($nb_days_access_before);
$coachStartDate = date('Y-m-d ', strtotime($start_date . ' + ' . $day . ' days'));
}
$coachEndDate = null;
if (!empty($nb_days_access_after)) {
$day = intval($nb_days_access_after);
$coachEndDate = date('Y-m-d ', strtotime($end_date . ' + ' . $day . ' days'));
}
$result_id = SessionManager::edit_session($session_id, $name, $start_date, $end_date, $start_date, $end_date, $coachStartDate, $coachEndDate, $user_id, 0, (int) $visibility);
if (!is_int($result_id)) {
return new WSError(302, 'Could not edit the session');
} else {
if (!empty($extras)) {
$extras_associative = array();
foreach ($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
// Create the extra fields
foreach ($extras_associative as $fname => $fvalue) {
SessionManager::create_session_extra_field($fname, 1, $fname);
SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
}
}
return true;
}
}
}
示例5: intval
$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;
$description = $params['description'];
$showDescription = isset($params['show_description']) ? 1 : 0;
$sendSubscritionNotification = isset($params['send_subscription_notification']);
$extraFields = array();
foreach ($params as $key => $value) {
if (strpos($key, 'extra_') === 0) {
$extraFields[$key] = $value;
}
}
$return = SessionManager::edit_session($id, $name, $startDate, $endDate, $displayStartDate, $displayEndDate, $coachStartDate, $coachEndDate, $coach_username, $id_session_category, $id_visibility, $description, $showDescription, $duration, $extraFields, null, $sendSubscritionNotification);
if ($return == strval(intval($return))) {
header('Location: resume_session.php?id_session=' . $return);
exit;
}
}
// display the header
Display::display_header($tool_name);
$form->display();
?>
<script>
$(document).ready( function() {
<?php
if (!empty($sessionInfo['duration'])) {
示例6: editSessionHelper
/**
* Edits a session (helper method)
*
* @param string Name of the session
* @param string Start date, use the 'YYYY-MM-DD' format
* @param string End date, use the 'YYYY-MM-DD' format
* @param int Access delays of the coach (days before)
* @param int Access delays of the coach (days after)
* @param int Nolimit (0 = no limit of time, 1 = limit of time)
* @param int Visibility
* @param string User id field name for the coach
* @param string User id value for the coach
* @param string Original session id field name (use "chamilo_session_id" to use internal id)
* @param string Original session id value
* @param array Array of extra fields
* @return mixed True on success, WSError otherwise
*/
protected function editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
if($session_id instanceof WSError) {
return $session_id;
} else {
// Verify that coach exists and get its id
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if($user_id instanceof WSError) {
return $user_id;
}
// Build the date
$start_date_array = explode('-', $start_date);
foreach($start_date_array as &$sd_element) {
$sd_element = intval($sd_element);
}
$end_date_array = explode('-', $end_date);
foreach($end_date_array as &$ed_element) {
$ed_element = intval($ed_element);
}
$result_id = SessionManager::edit_session($session_id, $name, $start_date_array[0], $start_date_array[1], $start_date_array[2], $end_date_array[0], $end_date_array[1], $end_date_array[2], (int)$nb_days_access_before, (int)$nb_days_access_after, (int)$nolimit, $user_id, 0, (int)$visibility);
if(!is_int($result_id)) {
return new WSError(302, 'Could not edit the session');
} else {
if(!empty($extras)) {
$extras_associative = array();
foreach($extras as $extra) {
$extras_associative[$extra['field_name']] = $extra['field_value'];
}
// Create the extra fields
foreach($extras_associative as $fname => $fvalue) {
SessionManager::create_session_extra_field($fname, 1, $fname);
SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
}
}
return true;
}
}
}