本文整理汇总了PHP中SessionManager::set_coach_to_course_session方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::set_coach_to_course_session方法的具体用法?PHP SessionManager::set_coach_to_course_session怎么用?PHP SessionManager::set_coach_to_course_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionManager
的用法示例。
在下文中一共展示了SessionManager::set_coach_to_course_session方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$coaches_course_session = array();
if (Database::num_rows($rs_coaches) > 0) {
while ($row_coaches = Database::fetch_row($rs_coaches)) {
$coaches_course_session[] = $row_coaches[0];
}
}
$id_coaches = $_POST['id_coach'];
if (is_array($id_coaches) && count($id_coaches) > 0) {
foreach ($id_coaches as $id_coach) {
$id_coach = intval($id_coach);
$rs1 = SessionManager::set_coach_to_course_session($id_coach, $id_session, $courseId);
}
// set status to 0 other tutors from multiple list
$array_intersect = array_diff($coaches_course_session, $id_coaches);
foreach ($array_intersect as $no_coach_user_id) {
$rs2 = SessionManager::set_coach_to_course_session($no_coach_user_id, $id_session, $courseId, true);
}
header('Location: ' . Security::remove_XSS($_GET['page']) . '?id_session=' . $id_session);
exit;
}
} else {
$sql = "SELECT user_id\n\t FROM {$tbl_session_rel_course_rel_user}\n\t WHERE\n session_id = '{$id_session}' AND\n c_id = '" . $courseId . "' AND\n status = 2 ";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
while ($infos = Database::fetch_array($rs)) {
$arr_infos[] = $infos['user_id'];
}
}
}
$order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
if (api_is_multiple_url_enabled()) {
示例2: unset
}
}
}
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
}
}
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'subscribe':
if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id) {
$user_id = intval($user_id);
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'teacher') {
if (!empty($current_session_id)) {
$is_suscribe[] = SessionManager::set_coach_to_course_session($user_id, $current_session_id, $_course['sysCode']);
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $_course['sysCode'], COURSEMANAGER);
}
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $_course['sysCode']);
}
$is_suscribe_user_id[] = $user_id;
}
}
$user_id_temp = $_SESSION['session_user_id'];
$user_name_temp = $_SESSION['session_user_name'];
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
$counter = 0;
$is_suscribe_counter = count($is_suscribe_user_id);
示例3: importSubscribeStatic
/**
* @param string $file
*/
private function importSubscribeStatic($file)
{
$data = Import::csv_reader($file);
if (!empty($data)) {
$this->logger->addInfo(count($data) . " records found.");
foreach ($data as $row) {
$chamiloUserName = $row['UserName'];
$chamiloCourseCode = $row['CourseCode'];
$chamiloSessionId = $row['SessionID'];
$type = $row['Type'];
$sessionInfo = api_get_session_info($chamiloSessionId);
if (empty($sessionInfo)) {
$this->logger->addError('Session does not exists: ' . $chamiloSessionId);
continue;
}
$courseInfo = api_get_course_info($chamiloCourseCode);
if (empty($courseInfo)) {
$this->logger->addError('Course does not exists: ' . $courseInfo);
continue;
}
$userId = Usermanager::get_user_id_from_username($chamiloUserName);
if (empty($userId)) {
$this->logger->addError('User does not exists: ' . $chamiloUserName);
continue;
}
$status = null;
switch ($type) {
case 'student':
SessionManager::subscribe_users_to_session_course(array($userId), $chamiloSessionId, $courseInfo['code'], null, false);
break;
case 'teacher':
SessionManager::set_coach_to_course_session($userId, $chamiloSessionId, $courseInfo['real_id']);
break;
}
$this->logger->addError("User '{$chamiloUserName}' with status {$type} was added to session: #{$chamiloSessionId} - Course: " . $courseInfo['code']);
}
}
}
示例4: updateTeachers
/**
* @param int $courseId
* @param array $teachers
* @param bool $deleteTeachersNotInList
* @param bool $editTeacherInSessions
* @param bool $deleteSessionTeacherNotInList
* @return bool
*/
public static function updateTeachers($courseId, $teachers, $deleteTeachersNotInList = true, $editTeacherInSessions = false, $deleteSessionTeacherNotInList = false, $teacherBackup = array())
{
if (empty($teachers)) {
return false;
}
if (!is_array($teachers)) {
$teachers = array($teachers);
}
$courseId = intval($courseId);
$courseInfo = api_get_course_info_by_id($courseId);
$course_code = $courseInfo['code'];
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$alreadyAddedTeachers = CourseManager::getTeacherListFromCourse($course_code);
if ($deleteTeachersNotInList) {
// Delete only teacher relations that doesn't match the selected teachers
$cond = null;
if (count($teachers) > 0) {
foreach ($teachers as $key) {
$key = Database::escape_string($key);
$cond .= " AND user_id <> '" . $key . "'";
}
}
$sql = 'DELETE FROM ' . $course_user_table . '
WHERE c_id ="' . $courseId . '" AND status="1" AND relation_type = 0 ' . $cond;
Database::query($sql);
}
if (count($teachers) > 0) {
foreach ($teachers as $userId) {
$userId = intval($userId);
// We check if the teacher is already subscribed in this course
$sql = 'SELECT 1 FROM ' . $course_user_table . '
WHERE user_id = "' . $userId . '" AND c_id = "' . $courseId . '" ';
$result = Database::query($sql);
if (Database::num_rows($result)) {
$sql = 'UPDATE ' . $course_user_table . ' SET status = "1"
WHERE c_id = "' . $courseId . '" AND user_id = "' . $userId . '" ';
} else {
$userCourseCategory = '0';
if (isset($teacherBackup[$userId]) && isset($teacherBackup[$userId][$course_code])) {
$courseUserData = $teacherBackup[$userId][$course_code];
$userCourseCategory = $courseUserData['user_course_cat'];
}
$sql = "INSERT INTO " . $course_user_table . " SET\n c_id = " . $courseId . ",\n user_id = " . $userId . ",\n status = '1',\n is_tutor = '0',\n sort = '0',\n relation_type = '0',\n user_course_cat = '{$userCourseCategory}'\n ";
}
Database::query($sql);
}
}
if ($editTeacherInSessions) {
$sessions = SessionManager::get_session_by_course($courseId);
if (!empty($sessions)) {
foreach ($sessions as $session) {
// Remove old and add new
if ($deleteSessionTeacherNotInList) {
foreach ($teachers as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId);
}
$teachersToDelete = array();
if (!empty($alreadyAddedTeachers)) {
$teachersToDelete = array_diff(array_keys($alreadyAddedTeachers), $teachers);
}
if (!empty($teachersToDelete)) {
foreach ($teachersToDelete as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId, true);
}
}
} else {
// Add new teachers only
foreach ($teachers as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $courseId);
}
}
}
}
}
}
示例5: unset
}
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
}
header('Location:' . api_get_path(WEB_CODE_PATH) . 'user/user.php?' . api_get_cidreq() . '&type=' . $type);
exit;
}
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'subscribe':
if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id) {
$user_id = intval($user_id);
if ($type == COURSEMANAGER) {
if (!empty($current_session_id)) {
$is_suscribe[] = SessionManager::set_coach_to_course_session($user_id, $current_session_id, $courseInfo['code']);
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $courseInfo['code'], COURSEMANAGER);
}
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $courseInfo['code']);
}
$is_suscribe_user_id[] = $user_id;
}
}
$user_id_temp = $_SESSION['session_user_id'];
$user_name_temp = $_SESSION['session_user_name'];
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
$counter = 0;
$is_suscribe_counter = count($is_suscribe_user_id);
示例6: WSSubscribeTeacherToSessionCourse
/**
* Subscribe teacher to a session course
*
* @param array $params - WSFunction parameters (include VerifyKey)
* @return bool|null|soap_fault A simple boolean (true if teacher successful subscribed, false otherwise)
*/
function WSSubscribeTeacherToSessionCourse($params)
{
global $debug;
if ($debug) {
error_log('WSSubscribeTeacherToSessionCourse');
}
if ($debug) {
error_log('Params ' . print_r($params, 1));
}
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$userId = $params['userId'];
// Chamilo user Id
$sessionId = $params['sessionId'];
// Current Session course ID
$courseId = $params['courseId'];
// Course Real Id
return SessionManager::set_coach_to_course_session($userId, $sessionId, $courseId);
}
示例7: transaction_4
static function transaction_4($data)
{
$uidIdPersona = $data['item_id'];
$uidIdPrograma = $data['orig_id'];
$uidIdProgramaDestination = $data['dest_id'];
$status = !empty($data['info']) ? $data['info'] : null;
global $data_list;
$user_id = self::get_user_id_by_persona_id($uidIdPersona, $data_list);
if (empty($user_id)) {
return array('message' => "User does not exists in DB: {$uidIdPersona}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
//Move A to B
if (!empty($uidIdPrograma) && !empty($uidIdProgramaDestination)) {
$session_id = self::get_session_id_by_programa_id($uidIdPrograma, $data_list);
$destination_session_id = self::get_session_id_by_programa_id($uidIdProgramaDestination, $data_list);
if (!empty($session_id) && !empty($destination_session_id)) {
$before1 = SessionManager::get_user_status_in_session($session_id, $user_id);
$before2 = SessionManager::get_user_status_in_session($destination_session_id, $user_id);
/*
These constants are defined in sessionmanager but are not
usable directly from here
SESSION_CHANGE_USER_REASON_SCHEDULE = 1;
SESSION_CHANGE_USER_REASON_CLASSROOM = 2;
SESSION_CHANGE_USER_REASON_LOCATION = 3;
SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION = 4;
*/
$reason_id = 1;
SessionManager::change_user_session($user_id, $session_id, $destination_session_id, $reason_id);
$befores = array($before1, $before2);
$message = "Move Session A to Session B";
return self::check_if_user_is_subscribe_to_session($user_id, $destination_session_id, $message, $befores);
} else {
return array('message' => "Session ids were not correctly setup session_id 1: {$session_id} Session id 2 {$uidIdProgramaDestination} - Move Session A to Session B", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
}
//Move A to empty
if (!empty($uidIdPrograma) && empty($uidIdProgramaDestination)) {
$session_id = self::get_session_id_by_programa_id($uidIdPrograma, $data_list);
if (!empty($session_id)) {
$before = SessionManager::get_user_status_in_session($session_id, $user_id);
//SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
SessionManager::unsubscribe_user_from_session($session_id, $user_id);
$message = "Move Session to empty";
return self::check_if_user_is_subscribe_to_session($user_id, $session_id, $message, $before);
} else {
return array('message' => "Session does not exists in DB {$uidIdPrograma} - Move Session to empty", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
}
//Move empty to A
if (empty($uidIdPrograma) && !empty($uidIdProgramaDestination)) {
$session_id = self::get_session_id_by_programa_id($uidIdProgramaDestination, $data_list);
if (!empty($session_id)) {
$before = SessionManager::get_user_status_in_session($session_id, $user_id);
if (isset($status) && $status == 1) {
$course_list = SessionManager::get_course_list_by_session_id($session_id);
if (!empty($course_list)) {
$course_data = current($course_list);
SessionManager::set_coach_to_course_session($user_id, $session_id, $course_data['code']);
} else {
return array('message' => 'Could not subscribe to course: no course in session ' . $uidIdProgramaDestination, 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
} else {
SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
}
$message = 'Move empty to Session';
return self::check_if_user_is_subscribe_to_session($user_id, $session_id, $message, $before);
} else {
return array('message' => "Session does not exists in DB {$uidIdProgramaDestination} - Move empty to Session", 'status_id' => self::TRANSACTION_STATUS_FAILED);
}
}
}
示例8: WSSubscribeTeacherToSessionCourse
/**
* Subscribe teacher to a session course
*
* @param array $params - WSFunction parameters (include VerifyKey)
* @return bool|null|soap_fault A simple boolean (true if teacher successful subscribed, false otherwise)
*/
function WSSubscribeTeacherToSessionCourse($params)
{
global $debug;
if ($debug) {
error_log('WSSubscribeTeacherToSessionCourse');
}
if (!WSHelperVerifyKey($params)) {
return returnError(WS_ERROR_SECRET_KEY);
}
if ($debug) {
error_log('Params ' . print_r($params, 1));
}
$params = parseCourseSessionUserParams($params);
$userId = $params['user_id'];
$courseId = $params['course_id'];
$sessionId = $params['session_id'];
SessionManager::set_coach_to_course_session($userId, $sessionId, $courseId);
$coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseId);
$result = 0;
if (!empty($coaches)) {
if ($debug) {
error_log('Coaches: ' . print_r($coaches, 1));
}
if (in_array($userId, $coaches)) {
$result = 1;
}
}
if ($debug) {
error_log('Result: ' . $result);
}
return $result;
}
示例9: WSSubscribeTeacherToSessionCourse
/**
* Subscribe teacher to a session course
*
* @param array $params - WSFunction parameters (include VerifyKey)
* @return bool|null|soap_fault A simple boolean (true if teacher successful subscribed, false otherwise)
*/
function WSSubscribeTeacherToSessionCourse($params)
{
global $debug;
if ($debug) {
error_log('WSSubscribeTeacherToSessionCourse');
}
if ($debug) {
error_log('Params ' . print_r($params, 1));
}
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$params = parseCourseSessionUserParams($params);
$userId = $params['user_id'];
$courseId = $params['course_id'];
$sessionId = $params['session_id'];
return intval(SessionManager::set_coach_to_course_session($userId, $sessionId, $courseId));
}
示例10: updateTeachers
/**
* @param string $course_code
* @param array $teachers
* @param bool $deleteTeachersNotInList
* @param bool $editTeacherInSessions
* @param bool $deleteSessionTeacherNotInList
* @return bool
*/
public static function updateTeachers($course_code, $teachers, $deleteTeachersNotInList = true, $editTeacherInSessions = false, $deleteSessionTeacherNotInList = false)
{
if (empty($teachers)) {
return false;
}
if (!is_array($teachers)) {
$teachers = array($teachers);
}
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code);
if ($deleteTeachersNotInList) {
// Delete only teacher relations that doesn't match the selected teachers
$cond = null;
if (count($teachers) > 0) {
foreach ($teachers as $key) {
$key = Database::escape_string($key);
$cond .= " AND user_id <> '" . $key . "'";
}
}
$sql = 'DELETE FROM ' . $course_user_table . '
WHERE course_code="' . Database::escape_string($course_code) . '" AND status="1"' . $cond;
Database::query($sql);
}
if (count($teachers) > 0) {
foreach ($teachers as $userId) {
$userId = intval($userId);
// We check if the teacher is already subscribed in this course
$sql = 'SELECT 1 FROM ' . $course_user_table . '
HERE user_id = "' . $userId . '" AND course_code = "' . $course_code . '" ';
$result = Database::query($sql);
if (Database::num_rows($result)) {
$sql = 'UPDATE ' . $course_user_table . ' SET status = "1"
WHERE course_code = "' . $course_code . '" AND user_id = "' . $userId . '" ';
} else {
$sql = "INSERT INTO " . $course_user_table . " SET\n course_code = '" . Database::escape_string($course_code) . "',\n user_id = '" . $userId . "',\n status = '1',\n role = '',\n tutor_id = '0',\n sort = '0',\n user_course_cat='0'";
}
Database::query($sql);
}
}
if ($editTeacherInSessions) {
$sessions = SessionManager::get_session_by_course($course_code);
if (!empty($sessions)) {
foreach ($sessions as $session) {
// Remove old and add new
if ($deleteSessionTeacherNotInList) {
foreach ($teachers as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code);
}
$teachersToDelete = array();
if (!empty($alreadyAddedTeachers)) {
$teachersToDelete = array_diff(array_keys($alreadyAddedTeachers), $teachers);
}
if (!empty($teachersToDelete)) {
foreach ($teachersToDelete as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code, true);
}
}
} else {
// Add new teachers only
foreach ($teachers as $userId) {
SessionManager::set_coach_to_course_session($userId, $session['id'], $course_code);
}
}
}
}
}
}
示例11: changeTeacherSubscription
/**
* Change Teacher subscription (helper method)
*
* @param string User id field name
* @param string User id value
* @param string Session id field name
* @param string Session id value
* @param string Course id field name
* @param string Course id value
* @param int State (1 to subscribe, 0 to unsubscribe)
* @return mixed True on success, WSError otherwise
*/
protected function changeTeacherSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $course_id_field_name, $course_id_value, $state)
{
$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
if ($session_id instanceof WSError) {
return $session_id;
} else {
$user_id = $this->getUserId($user_id_field_name, $user_id_value);
if ($user_id instanceof WSError) {
return $user_id;
} else {
$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
if ($course_id instanceof WSError) {
return $course_id;
} else {
if ($state == 1) {
SessionManager::set_coach_to_course_session($user_id, $session_id, $course_id);
} else {
$user_id = array(0 => $user_id);
$result = SessionManager::removeUsersFromCourseSession($user_id, $session_id, $course_id);
if (!$result) {
return new WSError(303, 'There was an error unsubscribing this Teacher from the session');
}
}
return true;
}
}
}
}
示例12: isset
// role is a string
if (isset ($_REQUEST['role']))
{
$role=$_REQUEST['role'];
$userProperties['role'] = $role;
}
*/
//get information about one user - task #3009
if ($current_session_id) {
$nocoach = isset($_POST['promoteTutor'])?false:true;
$res = SessionManager::set_coach_to_course_session($userIdViewed, $current_session_id, $courseCode, $nocoach);
} else {
if (!empty($_POST['promoteCourseAdmin']) && $_POST['promoteCourseAdmin']){
$userProperties['status'] = 1;
} else{
$userProperties['status'] = 5;
}
if (!empty($_POST['promoteTutor']) && $_POST['promoteTutor']){
$userProperties['tutor'] = 1;
} else{
$userProperties['tutor'] = 0;
}
$userProperties['role'] = $_POST['role'];
update_user_course_properties($userIdViewed, $courseCode, $userProperties);