本文整理汇总了PHP中SessionManager::add方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::add方法的具体用法?PHP SessionManager::add怎么用?PHP SessionManager::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createSessionHelper
/**
* Creates 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 Generated id in case of success, WSError otherwise
*/
protected function createSessionHelper($name, $start_date, $end_date, $coach_access_start_date, $coach_access_end_date, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras)
{
// 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);
}
// Try to create the session
$params = array('name' => $name, 'access_start_date' => $start_date, 'access_end_date' => $end_date, 'coach_access_start_date' => $coach_access_start_date, 'coach_access_end_date' => $coach_access_end_date, 'visibility' => $visibility);
$session_id = SessionManager::add($params);
if (!is_int($session_id)) {
return new WSError(301, 'Could not create the session');
} else {
// Add the Original session id to the extra fields
$extras_associative = array();
if ($session_id_field_name != "chamilo_session_id") {
$extras_associative[$session_id_field_name] = $session_id_value;
}
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 $session_id;
}
}
示例2: importCSV
//.........这里部分代码省略.........
$coach_id = $defaultUserId;
}
if (!$updatesession) {
// Always create a session.
$unique_name = false;
// This MUST be initializead.
$i = 0;
// Change session name, verify that session doesn't exist.
$suffix = null;
while (!$unique_name) {
if ($i > 1) {
$suffix = ' - ' . $i;
}
$sql = 'SELECT 1 FROM ' . $tbl_session . ' WHERE name="' . $session_name . $suffix . '"';
$rs = Database::query($sql);
if (Database::result($rs, 0, 0)) {
$i++;
} else {
$unique_name = true;
$session_name .= $suffix;
}
}
// Creating the session.
/*$sql_session = "INSERT IGNORE INTO $tbl_session SET
name = '".$session_name."',
id_coach = '$coach_id',
date_start = '$date_start',
date_end = '$date_end',
visibility = '$visibility',
session_category_id = '$session_category_id',
session_admin_id=".intval($defaultUserId).$extraParameters;
Database::query($sql_session);*/
$params = array('id_coach' => $coach_id, 'visibility' => $visibility, 'name' => $session_name, 'access_start_date' => $date_start, 'access_end_date' => $date_end, 'session_category_id' => $session_category_id, 'session_admin_id' => $defaultUserId);
$session_id = SessionManager::add($params);
if ($debug) {
if ($session_id) {
foreach ($enreg as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
self::update_session_extra_field_value($session_id, substr($key, 6), $value);
}
}
$logger->addInfo("Sessions - Session created: #{$session_id} - {$session_name}");
} else {
$logger->addError("Sessions - Session NOT created: {$session_name}");
}
}
$session_counter++;
} else {
$sessionId = null;
if (isset($extraFields) && !empty($extraFields)) {
$sessionId = self::get_session_id_from_original_id($enreg['extra_' . $extraFieldId], $extraFieldId);
if (empty($sessionId)) {
$my_session_result = false;
} else {
$my_session_result = true;
}
} else {
$my_session_result = self::get_session_by_name($enreg['SessionName']);
}
if ($my_session_result === false) {
// Creating a session.
/*$sql_session = "INSERT IGNORE INTO $tbl_session SET
name = '$session_name',
id_coach = '$coach_id',
date_start = '$date_start',
示例3: api_get_local_time
$session_info['display_start_date'] = api_get_local_time($session_info['display_start_date'], null, null, true);
$session_info['display_end_date'] = api_get_local_time($session_info['display_end_date'], null, null, true);
$session_info['access_start_date'] = api_get_local_time($session_info['access_start_date'], null, null, true);
$session_info['access_end_date'] = api_get_local_time($session_info['access_end_date'], null, null, true);
$session_info['coach_access_start_date'] = api_get_local_time($session_info['coach_access_start_date'], null, null, true);
$session_info['coach_access_end_date'] = api_get_local_time($session_info['coach_access_end_date'], null, null, true);
$form->setDefaults($session_info);
}
if ($form->validate()) {
$params = $form->getSubmitValues();
if (isset($params['id'])) {
SessionManager::update($params);
header('Location: resume_session.php?id_session=' . $params['id']);
exit;
} else {
$session_id = SessionManager::add($params);
if ($session_id) {
// integer => no error on session creation
header('Location: add_courses_to_session.php?id_session=' . $session_id . '&add=true&msg=');
exit;
}
}
}
function check_session_name($name)
{
$session = SessionManager::get_session_by_name($name);
return empty($session) ? true : false;
}
Display::display_header($tool_name);
echo '<div class="actions">';
echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'session/session_list.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>';
示例4: transaction_8
static function transaction_8($data, $web_service_details)
{
global $data_list;
$session_info = Migration::soap_call($web_service_details, 'programaDetalles', array('intIdSede' => $data['branch_id'], 'uididprograma' => $data['item_id']));
if ($session_info['error'] == false) {
unset($session_info['error']);
// check dates (only do this at session creation)
self::fix_access_dates($session_info);
$session_id = SessionManager::add($session_info);
$session_info = api_get_session_info($session_id, true);
if ($session_id) {
$data_list['sessions'][$data['item_id']] = $session_id;
return array('entity' => 'session', 'before' => null, 'after' => $session_info, 'message' => "Session was created. Id: {$session_id} session data: " . print_r($session_info, 1), 'status_id' => self::TRANSACTION_STATUS_SUCCESSFUL);
} else {
return array('message' => "Session was NOT created: {$data['item_id']} session data: " . print_r($session_info, 1), 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
} else {
//Return error
return $session_info;
}
}
示例5: WSCreateSession
function WSCreateSession($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);
$t_sf = Database::get_main_table(TABLE_MAIN_SESSION_FIELD);
$t_sfv = Database::get_main_table(TABLE_MAIN_SESSION_FIELD_VALUES);
$sessions_params = $params['sessions'];
$results = array();
$orig_session_id_value = array();
foreach ($sessions_params as $session_param) {
$name = trim($session_param['name']);
$access_start_date = $session_param['access_start_date'];
$access_end_date = $session_param['access_end_date'];
/*
$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_acess_before = intval($session_param['nb_days_access_before']);
//$nb_days_acess_after = intval($session_param['nb_days_access_after']);
$id_coach = $session_param['user_id'];
$nolimit = $session_param['nolimit'];
$original_session_id_name = $session_param['original_session_id_name'];
$original_session_id_value = $session_param['original_session_id_value'];
$orig_session_id_value[] = $session_param['original_session_id_value'];
$extra_list = $session_param['extra'];
// Check if exits remote system's session id into session_field_values table.
$sql = "SELECT field_value\tFROM {$t_sf} sf,{$t_sfv} sfv WHERE sfv.field_id=sf.id AND field_variable='{$original_session_id_name}' AND field_value='{$original_session_id_value}'";
$res = Database::query($sql);
$row = Database::fetch_row($res);
if (Database::num_rows($res) > 0) {
$results[] = 0;
continue;
}
if (empty($name)) {
$results[] = 0;
continue;
/*} elseif (empty($nolimit) && (!$month_start || !$day_start || !$year_start || !checkdate($month_start, $day_start, $year_start))) {
$results[] = 0;
continue;
} elseif (empty($nolimit) && (!$month_end || !$day_end || !$year_end || !checkdate($month_end,$day_end,$year_end))) {
$results[] = 0;
continue;
} elseif (empty($nolimit) && $date_start >= $date_end) {
$results[] = 0;
continue;*/
} else {
$rs = Database::query("SELECT 1 FROM {$tbl_session} WHERE name='" . Datanbase::escape_string($name) . "'");
if (Database::num_rows($rs)) {
$results[] = 0;
continue;
} else {
$params = array('name' => $name, 'id_coach' => $id_coach, 'session_admin_id' => $_user['user_id'], 'access_start_date' => $access_start_date, 'access_end_date' => $access_end_date);
$id_session = SessionManager::add($params);
//Database::query("INSERT INTO $tbl_session(name,date_start,date_end,id_coach,session_admin_id, VALUES('".addslashes($name)."','$date_start','$date_end','$id_coach',".intval($_user['user_id']).",".$nb_days_acess_before.", ".$nb_days_acess_after.")");
//$id_session = Database::insert_id();
// Save new fieldlabel into course_field table.
$field_id = SessionManager::create_session_extra_field($original_session_id_name, 1, $original_session_id_name);
// Save the external system's id into user_field_value table.
$res = SessionManager::update_session_extra_field_value($id_session, $original_session_id_name, $original_session_id_value);
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 new fieldlabel into course_field table.
$field_id = SessionManager::create_session_extra_field($extra_field_name, 1, $extra_field_name);
// Save the external system's id into course_field_value table.
$res = SessionManager::update_session_extra_field_value($id_session, $extra_field_name, $extra_field_value);
}
}
$results[] = $id_session;
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;
}