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


PHP SessionManager::relation_session_course_exist方法代码示例

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


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

示例1: foreach

     $username = UserManager::purify_username(api_utf8_decode($node_user), $purification_option_for_usernames);
     $user_id = UserManager::get_user_id_from_username($username);
     if ($user_id !== false) {
         $sql = "INSERT IGNORE INTO {$tbl_session_user} SET\n                                        id_user='{$user_id}',\n                                        id_session = '{$session_id}'";
         $rs_user = Database::query($sql);
         $user_counter++;
     }
 }
 // Adding courses to a session.
 foreach ($node_session->Course as $node_course) {
     $course_code = Database::escape_string(trim(api_utf8_decode($node_course->CourseCode)));
     // Verify that the course pointed by the course code node exists.
     if (CourseManager::course_exists($course_code)) {
         // If the course exists we continue.
         $course_info = CourseManager::get_course_information($course_code);
         $session_course_relation = SessionManager::relation_session_course_exist($session_id, $course_code);
         if (!$session_course_relation) {
             $sql_course = "INSERT INTO {$tbl_session_course} SET\n                                            course_code = '{$course_code}',\n                                            id_session='{$session_id}'";
             $rs_course = Database::query($sql_course);
             $course_info = api_get_course_info($course['code']);
             SessionManager::installCourse($id_session, $course_info['real_id']);
         }
         $course_coaches = explode(',', $node_course->Coach);
         // Adding coachs to session course user
         foreach ($course_coaches as $course_coach) {
             $coach_id = UserManager::purify_username(api_utf8_decode($course_coach), $purification_option_for_usernames);
             $coach_id = UserManager::get_user_id_from_username($course_coach);
             if ($coach_id !== false) {
                 $sql = "INSERT IGNORE INTO {$tbl_session_course_user} SET\n                                                id_user='{$coach_id}',\n                                                course_code='{$course_code}',\n                                                id_session = '{$session_id}',\n                                                status = 2 ";
                 $rs_coachs = Database::query($sql);
             } else {
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:session_import.php

示例2: importCalendarStatic

 /**
  * @param string $file
  * @param bool   $moveFile
  *
  * @return int
  */
 private function importCalendarStatic($file, $moveFile = true)
 {
     $data = Import::csv_to_array($file);
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         $eventsToCreate = array();
         $errorFound = false;
         foreach ($data as $row) {
             $sessionId = null;
             $externalSessionId = null;
             if (isset($row['external_sessionID'])) {
                 $externalSessionId = $row['external_sessionID'];
                 $sessionId = SessionManager::get_session_id_from_original_id($externalSessionId, $this->extraFieldIdNameList['session']);
             }
             $courseCode = null;
             if (isset($row['coursecode'])) {
                 $courseCode = $row['coursecode'];
             }
             $courseInfo = api_get_course_info($courseCode);
             if (empty($courseInfo)) {
                 $this->logger->addInfo("Course '{$courseCode}' does not exists");
             }
             if (empty($sessionId)) {
                 $this->logger->addInfo("external_sessionID: " . $externalSessionId . " does not exists.");
             }
             $teacherId = null;
             if (!empty($sessionId) && !empty($courseInfo)) {
                 $courseIncluded = SessionManager::relation_session_course_exist($sessionId, $courseInfo['code']);
                 if ($courseIncluded == false) {
                     $this->logger->addInfo("Course '{$courseCode}' is not included in session: {$sessionId}");
                     $errorFound = true;
                 } else {
                     $teachers = CourseManager::get_coach_list_from_course_code($courseInfo['code'], $sessionId);
                     // Getting first teacher.
                     if (!empty($teachers)) {
                         $teacher = current($teachers);
                         $teacherId = $teacher['user_id'];
                     } else {
                         $sessionInfo = api_get_session_info($sessionId);
                         $teacherId = $sessionInfo['id_coach'];
                     }
                 }
             } else {
                 $errorFound = true;
             }
             if (empty($teacherId)) {
                 $errorFound = true;
                 $this->logger->addInfo("No teacher found in course code : '{$courseCode}' and session: '{$sessionId}'");
             }
             $date = $row['date'];
             $startTime = $row['time_start'];
             $endTime = $row['time_end'];
             $title = $row['title'];
             $comment = $row['comment'];
             $color = isset($row['color']) ? $row['color'] : '';
             $startDateYear = substr($date, 0, 4);
             $startDateMonth = substr($date, 4, 2);
             $startDateDay = substr($date, 6, 8);
             $startDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $startTime . ":00";
             $endDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $endTime . ":00";
             if (!api_is_valid_date($startDate) || !api_is_valid_date($endDate)) {
                 $this->logger->addInfo("Verify your dates:  '{$startDate}' : '{$endDate}' ");
                 $errorFound = true;
             }
             // If old events do nothing.
             /*if (api_strtotime($startDate) < time()) {
                   continue;
               }*/
             if ($errorFound == false) {
                 $eventsToCreate[] = array('start' => $startDate, 'end' => $endDate, 'title' => $title, 'sender_id' => $teacherId, 'course_id' => $courseInfo['real_id'], 'session_id' => $sessionId, 'comment' => $comment, 'color' => $color, $this->extraFieldIdNameList['calendar_event'] => $row['external_calendar_itemID']);
             }
         }
         if (empty($eventsToCreate)) {
             $this->logger->addInfo("No events to add");
             return 0;
         }
         $this->logger->addInfo("Ready to insert events");
         $agenda = new Agenda();
         $extraFieldValue = new ExtraFieldValue('calendar_event');
         $extraFieldName = $this->extraFieldIdNameList['calendar_event'];
         $externalEventId = null;
         $extraField = new ExtraField('calendar_event');
         $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
         if (empty($extraFieldInfo)) {
             $this->logger->addInfo("No calendar event extra field created: {$extraFieldName}");
             return 0;
         }
         foreach ($eventsToCreate as $event) {
             $update = false;
             $item = null;
             if (!isset($event[$extraFieldName])) {
                 $this->logger->addInfo("No external_calendar_itemID found. Skipping ...");
                 continue;
             } else {
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:import_csv.php

示例3: importCalendarStatic

 /**
  * @param string $file
  * @param bool   $moveFile
  *
  * @return int
  */
 private function importCalendarStatic($file, $moveFile = true)
 {
     $data = Import::csvToArray($file);
     if ($this->getDumpValues()) {
         // Remove all calendar items
         $truncateTables = array(Database::get_course_table(TABLE_AGENDA), Database::get_course_table(TABLE_AGENDA_ATTACHMENT), Database::get_course_table(TABLE_AGENDA_REPEAT), Database::get_course_table(TABLE_AGENDA_REPEAT_NOT), Database::get_main_table(TABLE_PERSONAL_AGENDA), Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT_NOT), Database::get_main_table(TABLE_PERSONAL_AGENDA_REPEAT));
         foreach ($truncateTables as $table) {
             $sql = "TRUNCATE {$table}";
             Database::query($sql);
         }
         $table = Database::get_course_table(TABLE_ITEM_PROPERTY);
         $sql = "DELETE FROM {$table} WHERE tool = 'calendar_event'";
         Database::query($sql);
     }
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         $eventsToCreate = array();
         $errorFound = false;
         foreach ($data as $row) {
             $sessionId = null;
             $externalSessionId = null;
             if (isset($row['external_sessionID'])) {
                 $externalSessionId = $row['external_sessionID'];
                 $sessionId = SessionManager::getSessionIdFromOriginalId($externalSessionId, $this->extraFieldIdNameList['session']);
             }
             $courseCode = null;
             if (isset($row['coursecode'])) {
                 $courseCode = $row['coursecode'];
             }
             $courseInfo = api_get_course_info($courseCode);
             if (empty($courseInfo)) {
                 $this->logger->addInfo("Course '{$courseCode}' does not exists");
             }
             if (empty($sessionId)) {
                 $this->logger->addInfo("external_sessionID: " . $externalSessionId . " does not exists.");
             }
             $teacherId = null;
             if (!empty($sessionId) && !empty($courseInfo)) {
                 $courseIncluded = SessionManager::relation_session_course_exist($sessionId, $courseInfo['real_id']);
                 if ($courseIncluded == false) {
                     $this->logger->addInfo("Course '{$courseCode}' is not included in session: {$sessionId}");
                     $errorFound = true;
                 } else {
                     $teachers = CourseManager::get_coach_list_from_course_code($courseInfo['code'], $sessionId);
                     // Getting first teacher.
                     if (!empty($teachers)) {
                         $teacher = current($teachers);
                         $teacherId = $teacher['user_id'];
                     } else {
                         $sessionInfo = api_get_session_info($sessionId);
                         $teacherId = $sessionInfo['id_coach'];
                     }
                 }
             } else {
                 $errorFound = true;
             }
             if (empty($teacherId)) {
                 $errorFound = true;
                 $this->logger->addInfo("No teacher found in course code : '{$courseCode}' and session: '{$sessionId}'");
             }
             $date = $row['date'];
             $startTime = $row['time_start'];
             $endTime = $row['time_end'];
             $title = $row['title'];
             $startDateYear = substr($date, 0, 4);
             $startDateMonth = substr($date, 4, 2);
             $startDateDay = substr($date, 6, 8);
             $startDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $startTime . ":00";
             $endDate = $startDateYear . '-' . $startDateMonth . '-' . $startDateDay . ' ' . $endTime . ":00";
             if (!api_is_valid_date($startDate) or !api_is_valid_date($endDate)) {
                 $this->logger->addInfo("Verify your dates:  '{$startDate}' : '{$endDate}' ");
                 $errorFound = true;
             }
             if ($errorFound == false) {
                 $eventsToCreate[] = array('start' => $startDate, 'end' => $endDate, 'title' => $title, 'sender_id' => $teacherId, 'course_id' => $courseInfo['real_id'], 'session_id' => $sessionId, $this->extraFieldIdNameList['calendar_event'] => $row['external_calendar_itemID']);
             }
         }
         if (empty($eventsToCreate)) {
             $this->logger->addInfo("No events to add");
             return 0;
         }
         $this->logger->addInfo("Ready to insert events");
         $content = null;
         $agenda = new Agenda();
         $extraFieldValue = new ExtraFieldValue('calendar_event');
         $extraFieldName = $this->extraFieldIdNameList['calendar_event'];
         $externalEventId = null;
         $extraField = new ExtraField('calendar_event');
         $extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
         if (empty($extraFieldInfo)) {
             $this->logger->addInfo("No calendar event extra field created: {$extraFieldName}");
             return 0;
         }
         foreach ($eventsToCreate as $event) {
//.........这里部分代码省略.........
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:import_csv.php


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