当前位置: 首页>>代码示例>>PHP>>正文


PHP SessionManager::updateCoaches方法代码示例

本文整理汇总了PHP中SessionManager::updateCoaches方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::updateCoaches方法的具体用法?PHP SessionManager::updateCoaches怎么用?PHP SessionManager::updateCoaches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionManager的用法示例。


在下文中一共展示了SessionManager::updateCoaches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

     if (!empty($sessionCoaches)) {
         foreach ($sessionCoaches as $sessionId => $teacherInfo) {
             $coachesToSubscribe = $teacherInfo['coaches_by_session'];
             SessionManager::updateCoaches($sessionId, $courseId, $coachesToSubscribe, true);
         }
     }
     CourseManager::updateTeachers($courseId, $teachers, true, true, false);
 } else {
     // Normal behaviour
     CourseManager::updateTeachers($courseId, $teachers, true, false);
     // Updating session coaches
     $sessionCoaches = $course['session_coaches'];
     if (!empty($sessionCoaches)) {
         foreach ($sessionCoaches as $sessionId => $coachesToSubscribe) {
             if (!empty($coachesToSubscribe)) {
                 SessionManager::updateCoaches($sessionId, $courseId, $coachesToSubscribe, true);
             }
         }
     }
 }
 if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
     $sql = "UPDATE {$course_table} SET\n                add_teachers_to_sessions_courses = '{$addTeacherToSessionCourses}'\n                WHERE id = " . $courseInfo['real_id'];
     Database::query($sql);
 }
 $course_id = $courseInfo['real_id'];
 Display::addFlash(Display::return_message(get_lang('ItemUpdated')));
 if ($visual_code_is_used) {
     header('Location: course_list.php?action=show_msg&warn=' . urlencode($warn));
 } else {
     header('Location: course_list.php');
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:course_edit.php

示例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);
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:import_csv.php

示例3: importCSV


//.........这里部分代码省略.........
                     if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
                         $addTeachersToSession = $courseInfo['add_teachers_to_sessions_courses'];
                     }
                     // If any user provided for a course, use the users array.
                     if (empty($course_users)) {
                         if (!empty($userList)) {
                             SessionManager::subscribe_users_to_session_course($userList, $session_id, $course_code);
                             if ($debug) {
                                 $msg = "Sessions - Adding student list " . implode(', #', $userList) . " to course: '{$course_code}' and session #{$session_id}";
                                 $logger->addInfo($msg);
                             }
                         }
                     }
                     // Adding coaches to session course user.
                     if (!empty($course_coaches)) {
                         $savedCoaches = array();
                         // only edit if add_teachers_to_sessions_courses is set.
                         if ($addTeachersToSession) {
                             if ($addOriginalCourseTeachersAsCourseSessionCoaches) {
                                 // Adding course teachers as course session teachers.
                                 $alreadyAddedTeachers = CourseManager::get_teacher_list_from_course_code($course_code);
                                 if (!empty($alreadyAddedTeachers)) {
                                     $teachersToAdd = array();
                                     foreach ($alreadyAddedTeachers as $user) {
                                         $teachersToAdd[] = $user['username'];
                                     }
                                     $course_coaches = array_merge($course_coaches, $teachersToAdd);
                                 }
                             }
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     // Just insert new coaches
                                     SessionManager::updateCoaches($session_id, $courseId, array($coach_id), false);
                                     if ($debug) {
                                         $logger->addInfo("Sessions - Adding course coach: user #{$coach_id} ({$course_coach}) to course: '{$course_code}' and session #{$session_id}");
                                     }
                                     $savedCoaches[] = $coach_id;
                                 } else {
                                     $error_message .= get_lang('UserDoesNotExist') . ' : ' . $course_coach . $eol;
                                 }
                             }
                         }
                         // Custom courses/session coaches
                         $teacherToAdd = null;
                         // Only one coach is added.
                         if ($onlyAddFirstCoachOrTeacher == true) {
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     $teacherToAdd = $coach_id;
                                     break;
                                 }
                             }
                             // Un subscribe everyone that's not in the list.
                             $teacherList = CourseManager::get_teacher_list_from_course_code($course_code);
                             if (!empty($teacherList)) {
                                 foreach ($teacherList as $teacher) {
                                     if ($teacherToAdd != $teacher['user_id']) {
                                         CourseManager::unsubscribe_user($teacher['user_id'], $course_code);
                                     }
                                 }
                             }
                             if (!empty($teacherToAdd)) {
                                 SessionManager::updateCoaches($session_id, $courseId, array($teacherToAdd), true);
                                 CourseManager::subscribe_user($teacherToAdd, $course_code, COURSEMANAGER);
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php


注:本文中的SessionManager::updateCoaches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。