本文整理汇总了PHP中SessionManager::getSessionIdFromOriginalId方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::getSessionIdFromOriginalId方法的具体用法?PHP SessionManager::getSessionIdFromOriginalId怎么用?PHP SessionManager::getSessionIdFromOriginalId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::getSessionIdFromOriginalId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WSUnsuscribeCoursesFromSession
function WSUnsuscribeCoursesFromSession($params)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
// Initialisation
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$coursessessions_params = $params['coursessessions'];
$results = array();
$orig_course_id_value = array();
$orig_session_id_value = array();
foreach ($coursessessions_params as $coursesession_param) {
$original_session_id_value = $coursesession_param['original_session_id_value'];
$original_session_id_name = $coursesession_param['original_session_id_name'];
$original_course_id_name = $coursesession_param['original_course_id_name'];
$original_course_id_values = $coursesession_param['original_course_id_values'];
$orig_session_id_value[] = $original_session_id_value;
$id_session = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
if (empty($id_session)) {
$results[] = 0;
continue;
}
// Get courses list from row_original_course_id_values
$course_list = array();
$courseIdList = [];
foreach ($original_course_id_values as $row_original_course_list) {
$course_code = Database::escape_string($row_original_course_list['course_code']);
// Check whether exits $x_course_code into user_field_values table.
$courseInfo = CourseManager::getCourseInfoFromOriginalId($row_original_course_list['course_code'], $original_course_id_name);
if (empty($courseInfo) || isset($courseInfo) && $courseInfo['visibility'] == 0) {
continue;
// Course_code doesn't exist'
}
$course_list[] = $courseInfo['code'];
$courseIdList[] = $courseInfo['real_id'];
}
if (empty($course_list)) {
$results[] = 0;
continue;
}
$orig_course_id_value[] = implode(',', $course_list);
foreach ($courseIdList as $courseId) {
$courseId = intval($courseId);
Database::query("DELETE FROM {$tbl_session_rel_course}\n WHERE c_id ='{$courseId}' AND session_id='{$id_session}'");
$result = Database::query("DELETE FROM {$tbl_session_rel_course_rel_user} WHERE c_id='{$courseId}' AND session_id = '{$id_session}'");
Event::addEvent(LOG_SESSION_DELETE_COURSE, LOG_COURSE_ID, $courseId, api_get_utc_datetime(), api_get_user_id(), $courseId, $id_session);
$return = Database::affected_rows($result);
}
$nbr_courses = 0;
$sql = "SELECT nbr_courses FROM {$tbl_session} WHERE id = '{$id_session}'";
$res_nbr_courses = Database::query($sql);
$row_nbr_courses = Database::fetch_row($res_nbr_courses);
if (Database::num_rows($res_nbr_courses) > 0) {
$nbr_users = $row_nbr_courses[0] - $return;
}
// Update number of users in the session.
$update_sql = "UPDATE {$tbl_session} SET nbr_courses= {$nbr_courses} WHERE id='{$id_session}' ";
Database::query($update_sql);
$results[] = 1;
continue;
}
$count_results = count($results);
$output = array();
for ($i = 0; $i < $count_results; $i++) {
$output[] = array('original_course_id_values' => $orig_course_id_value[$i], '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::getSessionIdFromOriginalId($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 = str_replace('/', '-', $session['DateStart']);
$dateEnd = str_replace('/', '-', $session['DateEnd']);
$visibility = $this->defaultSessionVisibility;
$coachId = null;
if (!empty($coachUserName)) {
$coachInfo = api_get_user_info_from_username($coachUserName);
$coachId = $coachInfo['user_id'];
}
$coachStartDate = null;
if (!empty($this->daysCoachAccessBeforeBeginning)) {
$day = intval($this->daysCoachAccessBeforeBeginning);
$coachStartDate = date('Y-m-d ', strtotime($dateStart . ' + ' . $day . ' days'));
}
$coachEndDate = null;
if (!empty($this->daysCoachAccessAfterBeginning)) {
$day = intval($this->daysCoachAccessAfterBeginning);
$coachEndDate = date('Y-m-d ', strtotime($dateEnd . ' + ' . $day . ' days'));
}
if (empty($sessionId)) {
$result = SessionManager::create_session($session['SessionName'], $dateStart, $dateEnd, $dateStart, $dateEnd, $coachStartDate, $coachEndDate, $coachId, $categoryId, $visibility);
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);
$showDescription = isset($sessionInfo['show_description']) ? $sessionInfo['show_description'] : 1;
$result = SessionManager::edit_session($sessionId, $session['SessionName'], $dateStart, $dateEnd, $dateStart, $dateEnd, $sessionInfo['coach_access_start_date'], $sessionInfo['coach_access_end_date'], $coachId, $categoryId, $visibility, 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];
$courseInfo = api_get_course_info($courseCode);
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;
}
//.........这里部分代码省略.........
示例3: getSessionId
/**
* Gets the real session id based on the session id field name and value.
* Note that if the session id field name is "chamilo_session_id", it will use the session id
* in the system database
*
* @param string Session id field name
* @param string Session id value
* @return mixed System session id if the session was found, WSError otherwise
*/
protected function getSessionId($session_id_field_name, $session_id_value)
{
if ($session_id_field_name == "chamilo_session_id") {
$session = SessionManager::fetch((int) $session_id_value);
if (!empty($session)) {
return intval($session_id_value);
} else {
return new WSError(300, "Session not found");
}
} else {
$session_id = SessionManager::getSessionIdFromOriginalId($session_id_value, $session_id_field_name);
if ($session_id == 0) {
return new WSError(300, "Session not found");
} else {
return $session_id;
}
}
}
示例4: WSImportLP
/**
* @param array $params
* @return int|string
*/
function WSImportLP($params)
{
global $debug;
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
if ($debug) {
error_log('WSImportLP');
}
$courseIdName = $params['course_id_name'];
$courseIdValue = $params['course_id_value'];
$sessionIdName = isset($params['session_id_name']) ? $params['session_id_name'] : null;
$sessionIdValue = isset($params['session_id_value']) ? $params['session_id_value'] : null;
$lpName = $params['lp_name'];
$courseInfo = CourseManager::getCourseInfoFromOriginalId($courseIdValue, $courseIdName);
$courseId = $courseInfo['real_id'];
if (empty($courseInfo)) {
if ($debug) {
error_log('Course not found');
}
return 'Course not found';
}
$sessionId = 0;
if (!empty($sessionIdName) && !empty($sessionIdValue)) {
$sessionId = SessionManager::getSessionIdFromOriginalId($sessionIdValue, $sessionIdName);
if (empty($sessionId)) {
if ($debug) {
error_log('Session not found');
}
return 'Session not found';
}
}
$proximity = 'local';
$maker = 'Scorm';
$maxScore = '';
//$_REQUEST['use_max_score']
$oScorm = new scorm($courseInfo['code']);
$fileData = base64_decode($params['file_data']);
$uniqueFile = uniqid();
$userId = 1;
// admin
$filePath = api_get_path(SYS_ARCHIVE_PATH) . $uniqueFile;
file_put_contents($filePath, $fileData);
$fileName = $params['filename'];
$fileInfo = array('tmp_name' => $filePath, 'name' => $fileName);
$manifest = $oScorm->import_package($fileInfo, '', $courseInfo);
if (!$manifest) {
if ($debug) {
error_log('manifest.xml file not found');
}
//if api_set_failure
return 'manifest.xml file not found';
}
$manifestData = $oScorm->parse_manifest($manifest);
if (!empty($manifestData)) {
$oScorm->import_manifest($courseInfo['code'], $maxScore, $sessionId, $userId);
$oScorm->set_name($lpName);
$oScorm->set_proximity($proximity, $courseId);
$oScorm->set_maker($maker, $courseId);
//$oScorm->set_jslib('scorm_api.php');
if ($debug) {
error_log('scorm was added');
}
return 1;
} else {
if ($debug) {
error_log('manifest data empty');
}
return 'manifest data empty';
}
}