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


PHP GroupManager::subscribe_tutors方法代码示例

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


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

示例1: api_get_person_name

        if ($orderUserListByOfficialCode === 'true') {
            $officialCode = !empty($user['official_code']) ? $user['official_code'] . " - " : '? - ';
            $name = $officialCode . " " . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')';
        }
        $possible_users[$user['user_id']] = $name . $groupNameListToString;
    }
}
$group_tutors_element = $form->addElement('advmultiselect', 'group_tutors', get_lang('GroupTutors'), $possible_users, 'style="width: 280px;"');
// submit button
$form->addButtonSave(get_lang('SaveSettings'));
if ($form->validate()) {
    $values = $form->exportValues();
    // Storing the tutors (we first remove all the tutors and then add only those who were selected)
    GroupManager::unsubscribe_all_tutors($current_group['id']);
    if (isset($_POST['group_tutors']) && count($_POST['group_tutors']) > 0) {
        GroupManager::subscribe_tutors($values['group_tutors'], $current_group['id']);
    }
    // Returning to the group area (note: this is inconsistent with the rest of chamilo)
    $cat = GroupManager::get_category_from_group($current_group['id']);
    if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) {
        Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning'));
        header('Location: group.php?' . api_get_cidreq(true, false));
    } else {
        Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success'));
        header('Location: group.php?' . api_get_cidreq(true, false) . '&category=' . $cat['id']);
    }
    exit;
}
$defaults = $current_group;
$defaults['group_tutors'] = $selected_tutors;
$action = isset($_GET['action']) ? $_GET['action'] : '';
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:tutor_settings.php

示例2: importCourses

 /**
  * @param string $file
  * @param bool $moveFile
  * @param array $teacherBackup
  * @param array $groupBackup
  */
 private function importCourses($file, $moveFile = true, &$teacherBackup = array(), &$groupBackup = array())
 {
     $data = Import::csv_to_array($file);
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         foreach ($data as $row) {
             $row = $this->cleanCourseRow($row);
             $courseCode = CourseManager::get_course_id_from_original_id($row['extra_' . $this->extraFieldIdNameList['course']], $this->extraFieldIdNameList['course']);
             $courseInfo = api_get_course_info($courseCode);
             if (empty($courseInfo)) {
                 // Create
                 $params = array();
                 $params['title'] = $row['title'];
                 $params['exemplary_content'] = false;
                 $params['wanted_code'] = $row['course_code'];
                 $params['course_category'] = $row['course_category'];
                 $params['course_language'] = $row['language'];
                 $params['teachers'] = $row['teachers'];
                 $courseInfo = CourseManager::create_course($params);
                 if (!empty($courseInfo)) {
                     CourseManager::update_course_extra_field_value($courseInfo['code'], 'external_course_id', $row['extra_' . $this->extraFieldIdNameList['course']]);
                     $this->logger->addInfo("Courses - Course created " . $courseInfo['code']);
                 } else {
                     $this->logger->addError("Courses - Can't create course:" . $row['title']);
                 }
             } else {
                 // Update
                 $params = array('title' => $row['title'], 'category_code' => $row['course_category']);
                 $result = CourseManager::update_attributes($courseInfo['real_id'], $params);
                 $addTeacherToSession = isset($courseInfo['add_teachers_to_sessions_courses']) && !empty($courseInfo['add_teachers_to_sessions_courses']) ? true : false;
                 $teachers = $row['teachers'];
                 if (!is_array($teachers)) {
                     $teachers = array($teachers);
                 }
                 if ($addTeacherToSession) {
                     CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, true, false, $teacherBackup);
                 } else {
                     CourseManager::updateTeachers($courseInfo['id'], $row['teachers'], false, false, false, $teacherBackup);
                 }
                 foreach ($teachers as $teacherId) {
                     if (isset($groupBackup['tutor'][$teacherId]) && isset($groupBackup['tutor'][$teacherId][$courseInfo['code']])) {
                         foreach ($groupBackup['tutor'][$teacherId][$courseInfo['code']] as $data) {
                             GroupManager::subscribe_tutors(array($teacherId), $data['group_id'], $data['c_id']);
                         }
                     }
                     if (isset($groupBackup['user'][$teacherId]) && isset($groupBackup['user'][$teacherId][$courseInfo['code']]) && !empty($groupBackup['user'][$teacherId][$courseInfo['code']])) {
                         foreach ($groupBackup['user'][$teacherId][$courseInfo['code']] as $data) {
                             GroupManager::subscribe_users(array($teacherId), $data['group_id'], $data['c_id']);
                         }
                     }
                 }
                 if ($result) {
                     $this->logger->addInfo("Courses - Course updated " . $courseInfo['code']);
                 } else {
                     $this->logger->addError("Courses - Course NOT updated " . $courseInfo['code']);
                 }
             }
         }
     }
     if ($moveFile) {
         $this->moveFile($file);
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:69,代码来源:import_csv.php

示例3: importCSV


//.........这里部分代码省略.........
                                         $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "\n                                                    WHERE\n                                                        user_id = " . $teacher['user_id'] . " AND\n                                                        course_code = '" . $course_code . "'\n                                                    ";
                                         $result = Database::query($sql);
                                         $userCourseData = Database::fetch_array($result, 'ASSOC');
                                         $teacherBackupList[$teacher['user_id']][$course_code] = $userCourseData;
                                         $sql = "SELECT * FROM " . Database::get_course_table(TABLE_GROUP_USER) . "\n                                                    WHERE\n                                                        user_id = " . $teacher['user_id'] . " AND\n                                                        c_id = '" . $courseInfo['real_id'] . "'\n                                                    ";
                                         $result = Database::query($sql);
                                         while ($groupData = Database::fetch_array($result, 'ASSOC')) {
                                             $groupBackup['user'][$teacher['user_id']][$course_code][$groupData['group_id']] = $groupData;
                                         }
                                         $sql = "SELECT * FROM " . Database::get_course_table(TABLE_GROUP_TUTOR) . "\n                                                    WHERE\n                                                        user_id = " . $teacher['user_id'] . " AND\n                                                        c_id = '" . $courseInfo['real_id'] . "'\n                                                    ";
                                         $result = Database::query($sql);
                                         while ($groupData = Database::fetch_array($result, 'ASSOC')) {
                                             $groupBackup['tutor'][$teacher['user_id']][$course_code][$groupData['group_id']] = $groupData;
                                         }
                                         CourseManager::unsubscribe_user($teacher['user_id'], $course_code);
                                     }
                                 }
                             }
                             if (!empty($teacherToAdd)) {
                                 SessionManager::updateCoaches($session_id, $courseId, array($teacherToAdd), true);
                                 $userCourseCategory = '';
                                 if (isset($teacherBackupList[$teacherToAdd]) && isset($teacherBackupList[$teacherToAdd][$course_code])) {
                                     $courseUserData = $teacherBackupList[$teacherToAdd][$course_code];
                                     $userCourseCategory = $courseUserData['user_course_cat'];
                                 }
                                 CourseManager::subscribe_user($teacherToAdd, $course_code, COURSEMANAGER, 0, $userCourseCategory);
                                 if (isset($groupBackup['user'][$teacherToAdd]) && isset($groupBackup['user'][$teacherToAdd][$course_code]) && !empty($groupBackup['user'][$teacherToAdd][$course_code])) {
                                     foreach ($groupBackup['user'][$teacherToAdd][$course_code] as $data) {
                                         GroupManager::subscribe_users($teacherToAdd, $data['group_id'], $data['c_id']);
                                     }
                                 }
                                 if (isset($groupBackup['tutor'][$teacherToAdd]) && isset($groupBackup['tutor'][$teacherToAdd][$course_code]) && !empty($groupBackup['tutor'][$teacherToAdd][$course_code])) {
                                     foreach ($groupBackup['tutor'][$teacherToAdd][$course_code] as $data) {
                                         GroupManager::subscribe_tutors($teacherToAdd, $data['group_id'], $data['c_id']);
                                     }
                                 }
                             }
                         }
                         // See BT#6449#note-195
                         // All coaches are added.
                         if ($removeAllTeachersFromCourse) {
                             $teacherToAdd = null;
                             foreach ($course_coaches as $course_coach) {
                                 $coach_id = UserManager::get_user_id_from_username($course_coach);
                                 if ($coach_id !== false) {
                                     $teacherToAdd[] = $coach_id;
                                 }
                             }
                             if (!empty($teacherToAdd)) {
                                 // Deleting all course teachers and adding the only coach as teacher.
                                 $teacherList = CourseManager::getTeacherListFromCourse($courseId);
                                 if (!empty($teacherList)) {
                                     foreach ($teacherList as $teacher) {
                                         if (!in_array($teacher['user_id'], $teacherToAdd)) {
                                             $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "\n                                                        WHERE\n                                                            user_id = " . $teacher['user_id'] . " AND\n                                                            course_code = '" . $course_code . "'\n                                                        ";
                                             $result = Database::query($sql);
                                             $userCourseData = Database::fetch_array($result, 'ASSOC');
                                             $teacherBackupList[$teacher['user_id']][$course_code] = $userCourseData;
                                             $sql = "SELECT * FROM " . Database::get_course_table(TABLE_GROUP_USER) . "\n                                                    WHERE\n                                                        user_id = " . $teacher['user_id'] . " AND\n                                                        c_id = '" . $courseInfo['real_id'] . "'\n                                                    ";
                                             $result = Database::query($sql);
                                             while ($groupData = Database::fetch_array($result, 'ASSOC')) {
                                                 $groupBackup['user'][$teacher['user_id']][$course_code][$groupData['group_id']] = $groupData;
                                             }
                                             $sql = "SELECT * FROM " . Database::get_course_table(TABLE_GROUP_TUTOR) . "\n                                                        WHERE\n                                                            user_id = " . $teacher['user_id'] . " AND\n                                                            c_id = '" . $courseInfo['real_id'] . "'\n                                                        ";
                                             $result = Database::query($sql);
                                             while ($groupData = Database::fetch_array($result, 'ASSOC')) {
开发者ID:daffef,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php


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