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


PHP CourseManager::course_exists方法代码示例

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


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

示例1: event_login

 /**
  * @author Sebastien Piraux <piraux_seb@hotmail.com> old code
  * @author Julio Montoya 2013
  * @desc Record information for login event when an user identifies himself with username & password
  */
 function event_login(User $user)
 {
     $userId = $user->getUserId();
     $TABLETRACK_LOGIN = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
     $reallyNow = api_get_utc_datetime();
     $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, login_ip, login_date, logout_date) VALUES\n                    ('" . $userId . "',\n                    '" . Database::escape_string(api_get_real_ip()) . "',\n                    '" . $reallyNow . "',\n                    '" . $reallyNow . "'\n                    )";
     Database::query($sql);
     $roles = $user->getRoles();
     // auto subscribe
     foreach ($roles as $role) {
         $userStatusParsed = 'student';
         switch ($role) {
             case 'ROLE_SESSION_MANAGER':
                 $userStatusParsed = 'sessionadmin';
                 break;
             case 'ROLE_TEACHER':
                 $userStatusParsed = 'teacher';
                 break;
             case 'ROLE_RRHH':
                 $userStatusParsed = 'DRH';
                 break;
         }
         $autoSubscribe = api_get_setting($userStatusParsed . '_autosubscribe');
         if ($autoSubscribe) {
             $autoSubscribe = explode('|', $autoSubscribe);
             foreach ($autoSubscribe as $code) {
                 if (CourseManager::course_exists($code)) {
                     CourseManager::subscribe_user($userId, $code);
                 }
             }
         }
     }
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:38,代码来源:events.lib.inc.php

示例2: event_login

/**
 * @author Sebastien Piraux <piraux_seb@hotmail.com>
 * @desc Record information for login event
 * (when an user identifies himself with username & password)
 */
function event_login()
{
    global $TABLETRACK_LOGIN;
    global $_user;
    // @todo use api_get_user_info();
    //$userInfo = api_get_user_info();
    $userInfo = $_user;
    if (empty($userInfo)) {
        return false;
    }
    $userId = api_get_user_id();
    $reallyNow = api_get_utc_datetime();
    $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, login_ip, login_date, logout_date) VALUES\n            ('" . $userId . "',\n            '" . Database::escape_string(api_get_real_ip()) . "',\n            '" . $reallyNow . "',\n            '" . $reallyNow . "'\n            )";
    Database::query($sql);
    // Auto subscribe
    $user_status = $userInfo['status'] == SESSIONADMIN ? 'sessionadmin' : $userInfo['status'] == COURSEMANAGER ? 'teacher' : $userInfo['status'] == DRH ? 'DRH' : 'student';
    $autoSubscribe = api_get_setting($user_status . '_autosubscribe');
    if ($autoSubscribe) {
        $autoSubscribe = explode('|', $autoSubscribe);
        foreach ($autoSubscribe as $code) {
            if (CourseManager::course_exists($code)) {
                CourseManager::subscribe_user($userId, $code);
            }
        }
    }
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:events.lib.inc.php

示例3: updateUsers

/**
 * Update users from the imported data
 * @param   array   $users List of users
 * @return  void
 * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
 */
function updateUsers($users)
{
    global $insertedIn_course;
    // Not all scripts declare the $inserted_in_course array (although they should).
    if (!isset($inserted_in_course)) {
        $inserted_in_course = array();
    }
    $usergroup = new UserGroup();
    $send_mail = $_POST['sendMail'] ? true : false;
    if (is_array($users)) {
        foreach ($users as $user) {
            $user = complete_missing_data($user);
            $user['Status'] = api_status_key($user['Status']);
            $userName = $user['UserName'];
            $userInfo = api_get_user_info_from_username($userName);
            $user_id = $userInfo['user_id'];
            if ($user_id == 0) {
                return false;
            }
            $firstName = isset($user['FirstName']) ? $user['FirstName'] : $userInfo['firstname'];
            $lastName = isset($user['LastName']) ? $user['LastName'] : $userInfo['lastname'];
            $userName = isset($user['NewUserName']) ? $user['NewUserName'] : $userInfo['username'];
            $password = isset($user['Password']) ? $user['Password'] : $userInfo['password'];
            $authSource = isset($user['AuthSource']) ? $user['AuthSource'] : $userInfo['auth_source'];
            $email = isset($user['Email']) ? $user['Email'] : $userInfo['email'];
            $status = isset($user['Status']) ? $user['Status'] : $userInfo['status'];
            $officialCode = isset($user['OfficialCode']) ? $user['OfficialCode'] : $userInfo['official_code'];
            $phone = isset($user['PhoneNumber']) ? $user['PhoneNumber'] : $userInfo['phone'];
            $pictureUrl = isset($user['PictureUri']) ? $user['PictureUri'] : $userInfo['picture_uri'];
            $expirationDate = isset($user['ExpiryDate']) ? $user['ExpiryDate'] : $userInfo['expiration_date'];
            $active = isset($user['Active']) ? $user['Active'] : $userInfo['active'];
            $creatorId = $userInfo['creator_id'];
            $hrDeptId = $userInfo['hr_dept_id'];
            $language = isset($user['Language']) ? $user['Language'] : $userInfo['language'];
            $sendEmail = isset($user['SendEmail']) ? $user['SendEmail'] : $userInfo['language'];
            $userUpdated = UserManager::update_user($user_id, $firstName, $lastName, $userName, $password, $authSource, $email, $status, $officialCode, $phone, $pictureUrl, $expirationDate, $active, $creatorId, $hrDeptId, null, $language, '', '', '');
            if (!is_array($user['Courses']) && !empty($user['Courses'])) {
                $user['Courses'] = array($user['Courses']);
            }
            if (is_array($user['Courses'])) {
                foreach ($user['Courses'] as $course) {
                    if (CourseManager::course_exists($course)) {
                        CourseManager::subscribe_user($user_id, $course, $user['Status']);
                        $course_info = CourseManager::get_course_information($course);
                        $inserted_in_course[$course] = $course_info['title'];
                    }
                }
            }
            if (!empty($user['ClassId'])) {
                $classId = explode('|', trim($user['ClassId']));
                foreach ($classId as $id) {
                    $usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
                }
            }
            // Saving extra fields.
            global $extra_fields;
            // We are sure that the extra field exists.
            foreach ($extra_fields as $extras) {
                if (isset($user[$extras[1]])) {
                    $key = $extras[1];
                    $value = $user[$extras[1]];
                    UserManager::update_extra_field_value($user_id, $key, $value);
                }
            }
        }
    }
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:73,代码来源:user_update_import.php

示例4: 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

示例5: importCSV


//.........这里部分代码省略.........
                         Database::update($tbl_session, $params, array('id = ?' => $sessionId));
                         $session_id = $sessionId;
                     } else {
                         Database::update($tbl_session, $params, array("name = '?' " => $enreg['SessionName']));
                         $row = Database::query("SELECT id FROM {$tbl_session} WHERE name = '{$session_name}'");
                         list($session_id) = Database::fetch_array($row);
                     }
                     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);
                         }
                     }
                     Database::query("DELETE FROM {$tbl_session_user} WHERE id_session='{$session_id}'");
                     Database::query("DELETE FROM {$tbl_session_course} WHERE id_session='{$session_id}'");
                     Database::query("DELETE FROM {$tbl_session_course_user} WHERE id_session='{$session_id}'");
                 }
                 $session_counter++;
             }
             $users = explode('|', $enreg['Users']);
             // Adding the relationship "Session - User".
             if (is_array($users)) {
                 foreach ($users as $user) {
                     $user_id = UserManager::get_user_id_from_username($user);
                     if ($user_id !== false) {
                         // Insert new users.
                         $sql = "INSERT IGNORE INTO {$tbl_session_user} SET\n                                    id_user = '{$user_id}',\n                                    id_session = '{$session_id}'";
                         Database::query($sql);
                         if ($debug) {
                             $logger->addInfo("Sessions - Adding User #{$user_id} ({$user}) to session #{$session_id}");
                         }
                         $user_counter++;
                     }
                 }
             }
             $courses = explode('|', $enreg['Courses']);
             foreach ($courses as $course) {
                 $course_code = api_strtoupper(api_substr($course, 0, api_strpos($course, '[')));
                 if (CourseManager::course_exists($course_code)) {
                     $courseInfo = api_get_course_info($course_code);
                     $courseId = $courseInfo['real_id'];
                     // Adding the course to a session.
                     $sql_course = "INSERT IGNORE INTO {$tbl_session_course}\n                                       SET c_id = '" . $courseId . "', id_session = '{$session_id}'";
                     Database::query($sql_course);
                     if ($debug) {
                         $logger->addInfo("Sessions - Adding course '{$course_code}' to session #{$session_id}");
                     }
                     $course_counter++;
                     $pattern = "/\\[(.*?)\\]/";
                     preg_match_all($pattern, $course, $matches);
                     if (isset($matches[1])) {
                         $course_coaches = $matches[1][0];
                         $course_users = $matches[1][1];
                     }
                     $course_users = explode(',', $course_users);
                     $course_coaches = explode(',', $course_coaches);
                     // Adding coaches to session course user
                     if (!empty($course_coaches)) {
                         foreach ($course_coaches as $course_coach) {
                             $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                                            c_id ='{$courseId}',\n                                            id_session = '{$session_id}',\n                                            status = 2 ";
                                 Database::query($sql);
                                 if ($debug) {
                                     $logger->addInfo("Sessions - Adding course coach: user #{$coach_id} ({$course_coach}) to course: '{$course_code}' and session #{$session_id}");
                                 }
                             } else {
                                 $error_message .= get_lang('UserDoesNotExist') . ' : ' . $course_coach . $eol;
                             }
                         }
                     }
                     $users_in_course_counter = 0;
                     // Adding the relationship "Session - Course - User".
                     foreach ($course_users as $user) {
                         $user_id = UserManager::get_user_id_from_username($user);
                         if ($user_id !== false) {
                             $sql = "INSERT IGNORE INTO {$tbl_session_course_user} SET\n                                        id_user='{$user_id}',\n                                        c_id = '{$courseId}',\n                                        id_session = '{$session_id}'";
                             Database::query($sql);
                             if ($debug) {
                                 $logger->addInfo("Sessions - Adding student: user #{$user_id} ({$user}) to course: '{$course_code}' and session #{$session_id}");
                             }
                             $users_in_course_counter++;
                         } else {
                             $error_message .= get_lang('UserDoesNotExist') . ': ' . $user . $eol;
                         }
                     }
                     $sql = "UPDATE {$tbl_session_course} SET nbr_users='{$users_in_course_counter}' WHERE c_id ='{$courseId}'";
                     Database::query($sql);
                     $course_info = CourseManager::get_course_information($course_code);
                     $inserted_in_course[$course_code] = $course_info['title'];
                 }
             }
             $access_url_id = api_get_current_access_url_id();
             UrlManager::add_session_to_url($session_id, $access_url_id);
             $sql_update_users = "UPDATE {$tbl_session} SET nbr_users ='{$user_counter}', nbr_courses='{$course_counter}' WHERE id='{$session_id}'";
             Database::query($sql_update_users);
         }
     }
     return array('error_message' => $error_message, 'session_counter' => $session_counter);
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:sessionmanager.lib.php

示例6: get_lang

             $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 to session_rel_user_rel_course table.
             $sql = "INSERT IGNORE INTO {$tbl_session_course_user} SET\n                                                id_user='{$user_id}',\n                                                course_code='{$course_code}',\n                                                id_session = '{$session_id}'";
             $rs_users = Database::query($sql);
             $users_in_course_counter++;
         } else {
             $error_message .= get_lang('UserDoesNotExist') . ' : ' . $username . '<br />';
         }
     }
     $update_session_course = "UPDATE {$tbl_session_course} SET nbr_users='{$users_in_course_counter}' WHERE course_code='{$course_code}'";
     Database::query($update_session_course);
     $inserted_in_course[$course_code] = $course_info['title'];
 }
 if (CourseManager::course_exists($course_code, true)) {
     // If the course exists we continue.
     // Also subscribe to virtual courses through check on visual code.
     $list = CourseManager::get_courses_info_from_visual_code($course_code);
     foreach ($list as $vcourse) {
         if ($vcourse['code'] == $course_code) {
             // Ignore, this has already been inserted.
         } else {
             $sql_course = "INSERT INTO {$tbl_session_course} SET\n                                                course_code = '" . $vcourse['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);
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:session_import.php

示例7: save_data

/**
 * Saves imported data.
 */
function save_data($users_courses)
{
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
    $csv_data = array();
    $inserted_in_course = array();
    foreach ($users_courses as $user_course) {
        $csv_data[$user_course['Email']][$user_course['CourseCode']] = $user_course['Status'];
    }
    foreach ($csv_data as $email => $csv_subscriptions) {
        $sql = "SELECT * FROM {$user_table} u\n                WHERE u.email = '" . Database::escape_string($email) . "' LIMIT 1";
        $res = Database::query($sql);
        $obj = Database::fetch_object($res);
        $user_id = $obj->user_id;
        $sql = "SELECT * FROM {$course_user_table} cu\n                WHERE cu.user_id = {$user_id} AND cu.relation_type <> " . COURSE_RELATION_TYPE_RRHH . " ";
        $res = Database::query($sql);
        $db_subscriptions = array();
        while ($obj = Database::fetch_object($res)) {
            $db_subscriptions[$obj->c_id] = $obj->status;
        }
        $to_subscribe = array_diff(array_keys($csv_subscriptions), array_keys($db_subscriptions));
        $to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csv_subscriptions));
        if ($_POST['subscribe']) {
            foreach ($to_subscribe as $courseId) {
                $courseInfo = api_get_course_info_by_id($courseId);
                $course_code = $courseInfo['code'];
                if (CourseManager::course_exists($course_code)) {
                    $course_info = CourseManager::get_course_information($course_code);
                    $inserted_in_course[$course_code] = $course_info['title'];
                    CourseManager::subscribe_user($user_id, $course_code, $csv_subscriptions[$course_code]);
                    $inserted_in_course[$course_info['code']] = $course_info['title'];
                }
            }
        }
        if ($_POST['unsubscribe']) {
            foreach ($to_unsubscribe as $courseId) {
                $courseInfo = api_get_course_info_by_id($courseId);
                $course_code = $courseInfo['code'];
                if (CourseManager::course_exists($course_code)) {
                    CourseManager::unsubscribe_user($user_id, $course_code);
                    $course_info = CourseManager::get_course_information($course_code);
                    CourseManager::unsubscribe_user($user_id, $course_code);
                    $inserted_in_course[$course_info['code']] = $course_info['title'];
                }
            }
        }
    }
    return $inserted_in_course;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:52,代码来源:course_user_import_by_email.php

示例8: save_data

/**
 * Save the imported data
 * @param   array   $users List of users
 * @return  void
 * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
 */
function save_data($users)
{
    global $inserted_in_course;
    // Not all scripts declare the $inserted_in_course array (although they should).
    if (!isset($inserted_in_course)) {
        $inserted_in_course = array();
    }
    $usergroup = new UserGroup();
    $send_mail = $_POST['sendMail'] ? true : false;
    if (is_array($users)) {
        foreach ($users as $user) {
            $user = complete_missing_data($user);
            $user['Status'] = api_status_key($user['Status']);
            $user_id = UserManager::create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], $user['language'], $user['PhoneNumber'], '', $user['AuthSource'], $user['ExpiryDate'], 1, 0, null, null, $send_mail);
            if (!is_array($user['Courses']) && !empty($user['Courses'])) {
                $user['Courses'] = array($user['Courses']);
            }
            if (is_array($user['Courses'])) {
                foreach ($user['Courses'] as $course) {
                    if (CourseManager::course_exists($course)) {
                        CourseManager::subscribe_user($user_id, $course, $user['Status']);
                        $course_info = CourseManager::get_course_information($course);
                        $inserted_in_course[$course] = $course_info['title'];
                    }
                }
            }
            if (!empty($user['ClassId'])) {
                $classId = explode('|', trim($user['ClassId']));
                foreach ($classId as $id) {
                    $usergroup->subscribe_users_to_usergroup($id, array($user_id), false);
                }
            }
            // Saving extra fields.
            global $extra_fields;
            // We are sure that the extra field exists.
            foreach ($extra_fields as $extras) {
                if (isset($user[$extras[1]])) {
                    $key = $extras[1];
                    $value = $user[$extras[1]];
                    UserManager::update_extra_field_value($user_id, $key, $value);
                }
            }
        }
    }
}
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:51,代码来源:user_import.php

示例9: importCSV


//.........这里部分代码省略.........
                 }
             }
             if ($deleteUsersNotInList) {
                 // Getting user in DB in order to compare to the new list.
                 $usersListInDatabase = self::get_users_by_session($session_id, 0);
                 if (!empty($usersListInDatabase)) {
                     if (empty($userList)) {
                         foreach ($usersListInDatabase as $userInfo) {
                             self::unsubscribe_user_from_session($session_id, $userInfo['user_id']);
                         }
                     } else {
                         foreach ($usersListInDatabase as $userInfo) {
                             if (!in_array($userInfo['user_id'], $userList)) {
                                 self::unsubscribe_user_from_session($session_id, $userInfo['user_id']);
                             }
                         }
                     }
                 }
             }
             $courses = explode('|', $enreg['Courses']);
             // See BT#6449
             $onlyAddFirstCoachOrTeacher = false;
             if ($sessionWithCoursesModifier) {
                 if (count($courses) >= 2) {
                     // Only first teacher in course session;
                     $onlyAddFirstCoachOrTeacher = true;
                     // Remove all teachers from course.
                     $removeAllTeachersFromCourse = false;
                 }
             }
             foreach ($courses as $course) {
                 $courseArray = bracketsToArray($course);
                 $course_code = $courseArray[0];
                 if (CourseManager::course_exists($course_code)) {
                     $courseInfo = api_get_course_info($course_code);
                     $courseId = $courseInfo['real_id'];
                     // Adding the course to a session.
                     $sql = "INSERT IGNORE INTO {$tbl_session_course}\n                                SET c_id = '{$courseId}', session_id='{$session_id}'";
                     Database::query($sql);
                     SessionManager::installCourse($session_id, $courseInfo['real_id']);
                     if ($debug) {
                         $logger->addInfo("Sessions - Adding course '{$course_code}' to session #{$session_id}");
                     }
                     $course_counter++;
                     $course_coaches = isset($courseArray[1]) ? $courseArray[1] : null;
                     $course_users = isset($courseArray[2]) ? $courseArray[2] : null;
                     $course_users = explode(',', $course_users);
                     $course_coaches = explode(',', $course_coaches);
                     // Checking if the flag is set TeachersWillBeAddedAsCoachInAllCourseSessions (course_edit.php)
                     $addTeachersToSession = true;
                     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();
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php

示例10: ob_start

if ($export_csv) {
    ob_start();
}
$csv_content = array();
$user_id = intval($_GET['student_id']);
if (isset($_GET['course'])) {
    $cidReq = Security::remove_XSS($_GET['course']);
}
$user_infos = UserManager::get_user_info_by_id($user_id);
$name = $user_infos['firstname'] . ' ' . $user_infos['lastname'];
if (!api_is_platform_admin(true) && !CourseManager::is_course_teacher($_user['user_id'], $cidReq) && !Tracking::is_allowed_to_coach_student($_user['user_id'], $_GET['student_id']) && $user_infos['hr_dept_id'] !== $_user['user_id']) {
    Display::display_header('');
    api_not_allowed();
    Display::display_footer();
}
$course_exits = CourseManager::course_exists($cidReq);
if (!empty($course_exits)) {
    $_course = CourseManager::get_course_information($cidReq);
} else {
    api_not_allowed();
}
$_course['dbNameGlu'] = $_configuration['table_prefix'] . $_course['db_name'] . $_configuration['db_glue'];
$lp_id = intval($_GET['lp_id']);
$lp_view_id = cloud_getLpViewId($cidReq, $lp_id, $user_id);
$regid = cloud_getRegId($cidReq, $lp_view_id);
$interbreadcrumb[] = array("url" => api_get_path(WEB_COURSE_PATH) . $_course['directory'], 'name' => $_course['title']);
$interbreadcrumb[] = array("url" => "../tracking/courseLog.php?cidReq=" . $cidReq . '&studentlist=true&id_session=' . $_SESSION['id_session'], "name" => get_lang("Tracking"));
$interbreadcrumb[] = array("url" => "../mySpace/myStudents.php?student=" . Security::remove_XSS($_GET['student_id']) . "&course=" . $cidReq . "&details=true&origin=" . Security::remove_XSS($_GET['origin']), "name" => get_lang("DetailsStudentInCourse"));
$interbreadcrumb[] = array("url" => "cloudCourseDetails.php?regid=" . $regid . "&course=" . $cidReq . "&lp_id=" . $lp_id . "&student_id=" . $user_id, "name" => "Course Activity Report");
$nameTools = get_lang('launchHistoryReport');
$htmlHeadXtra[] = '
开发者ID:RusticiSoftware,项目名称:SCORMCloud_DokeosMod,代码行数:31,代码来源:cloudLaunchHistory.php

示例11: save_data

/**
 * Save the imported data
 */
function save_data($users)
{
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    if (is_array($users)) {
        foreach ($users as $index => $user) {
            $user = complete_missing_data($user);
            $user['Status'] = api_status_key($user['Status']);
            $user_id = UserManager::create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('PlatformLanguage'), $user['PhoneNumber'], '', $user['AuthSource']);
            foreach ($user['Courses'] as $index => $course) {
                if (CourseManager::course_exists($course)) {
                    CourseManager::subscribe_user($user_id, $course, $user['Status']);
                }
            }
            if (strlen($user['ClassName']) > 0) {
                $class_id = ClassManager::get_class_id($user['ClassName']);
                ClassManager::add_user($user_id, $class_id);
            }
            // TODO: Hard-coded French texts.
            // Qualite
            if (!empty($user['Qualite'])) {
                UserManager::update_extra_field_value($user_id, 'qualite', $user['Qualite']);
            }
            // Categorie
            if (!empty($user['Categorie'])) {
                UserManager::update_extra_field_value($user_id, 'categorie', $user['Categorie']);
            }
            // Etat
            if (!empty($user['Etat'])) {
                UserManager::update_extra_field_value($user_id, 'etat', $user['Etat']);
            }
            // Niveau
            if (!empty($user['Niveau'])) {
                UserManager::update_extra_field_value($user_id, 'niveau', $user['Niveau']);
            }
        }
    }
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:40,代码来源:import.lib.php

示例12: external_update_user

/**
 * Update the user in chamilo database. It upgrade only info that is present in the
 * new_user array
 *
 * @param $new_user associative array with the value to upgrade
 *    WARNING user_id key is MANDATORY
 *    Possible keys are :
 *      - firstname
 *      - lastname
 *      - username
 *      - auth_source
 *      - email
 *      - status
 *      - official_code
 *      - phone
 *      - picture_uri
 *      - expiration_date
 *      - active
 *      - creator_id
 *      - hr_dept_id
 *      - extra : array of custom fields
 *      - language
 *      - courses : string of all courses code separated by '|'
 *      - admin : boolean
 * @return boolean
 * @author ndiechburg <noel@cblue.be>
 * */
function external_update_user($new_user)
{
    $old_user = api_get_user_info($new_user['user_id']);
    $u = array_merge($old_user, $new_user);
    $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], null, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'], '');
    if (isset($u['courses']) && !empty($u['courses'])) {
        $autoSubscribe = explode('|', $u['courses']);
        foreach ($autoSubscribe as $code) {
            if (CourseManager::course_exists($code)) {
                CourseManager::subscribe_user($u['user_id'], $code);
            }
        }
    }
    // Is User Admin ?
    //TODO decomments and check that user_is is not already in admin table
    /*
          if (isset($u['admin']) && $u['admin']){
    
          $table = Database::get_main_table(TABLE_MAIN_ADMIN);
          $res = Database::query("SELECT * from $table WHERE user_id = ".$u['user_id']);
          } */
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:49,代码来源:functions.inc.php

示例13: external_get_user_info

    $user = false;
} else {
    $user = external_get_user_info($login, $password);
}
if ($user !== false && ($chamilo_uid = external_add_user($user)) !== false) {
    //log in the user
    $loginFailed = false;
    $_user['user_id'] = $chamilo_uid;
    $_user['uidReset'] = true;
    Session::write('_user', $_user);
    $uidReset = true;
    //Autosubscribe to courses
    if (!empty($user['courses'])) {
        $autoSubscribe = explode('|', $user['courses']);
        foreach ($autoSubscribe as $code) {
            if (CourseManager::course_exists($code)) {
                CourseManager::subscribe_user($_user['user_id'], $code);
            }
        }
    }
    // Is User Admin ?
    if ($user['admin']) {
        $is_platformAdmin = true;
        Database::query("INSERT INTO admin values ('{$chamilo_uid}')");
    }
    // Can user create course
    $is_allowedCreateCourse = (bool) ($user['status'] == COURSEMANAGER or api_get_setting('drhCourseManagerRights') and $user['status'] == SESSIONADMIN);
    event_login();
} else {
    $loginFailed = true;
    unset($_user['user_id']);
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:newUser.php

示例14: save_data

/**
 * Save the imported data
 * @param   array   List of users
 * @return  void
 * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
 */
function save_data($users)
{
    global $inserted_in_course;
    // Not all scripts declare the $inserted_in_course array (although they should).
    if (!isset($inserted_in_course)) {
        $inserted_in_course = array();
    }
    $send_mail = $_POST['sendMail'] ? 1 : 0;
    if (is_array($users)) {
        foreach ($users as $index => $user) {
            $user = complete_missing_data($user);
            $user['Status'] = api_status_key($user['Status']);
            $user_id = UserManager::create_user($user['FirstName'], $user['LastName'], $user['Status'], $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], $user['language'], $user['PhoneNumber'], '', $user['AuthSource'], null, 1, 0, null, null, $send_mail);
            if (!is_array($user['Courses']) && !empty($user['Courses'])) {
                $user['Courses'] = array($user['Courses']);
            }
            if (is_array($user['Courses'])) {
                foreach ($user['Courses'] as $index => $course) {
                    if (CourseManager::course_exists($course)) {
                        CourseManager::subscribe_user($user_id, $course, $user['Status']);
                        $course_info = CourseManager::get_course_information($course);
                        $inserted_in_course[$course] = $course_info['title'];
                    }
                    if (CourseManager::course_exists($course, true)) {
                        // Also subscribe to virtual courses through check on visual code.
                        $list = CourseManager::get_courses_info_from_visual_code($course);
                        foreach ($list as $vcourse) {
                            if ($vcourse['code'] == $course) {
                                // Ignore, this has already been inserted.
                            } else {
                                CourseManager::subscribe_user($user_id, $vcourse['code'], $user['Status']);
                                $inserted_in_course[$vcourse['code']] = $vcourse['title'];
                            }
                        }
                    }
                }
            }
            if (!empty($user['ClassName'])) {
                $class_id = ClassManager::get_class_id($user['ClassName']);
                ClassManager::add_user($user_id, $class_id);
            }
            // Saving extra fields.
            global $extra_fields;
            // We are sure that the extra field exists.
            foreach ($extra_fields as $extras) {
                if (isset($user[$extras[1]])) {
                    $key = $extras[1];
                    $value = $user[$extras[1]];
                    UserManager::update_extra_field_value($user_id, $key, $value);
                }
            }
        }
    }
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:60,代码来源:user_import.php


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