本文整理汇总了PHP中CourseManager::subscribe_user方法的典型用法代码示例。如果您正苦于以下问题:PHP CourseManager::subscribe_user方法的具体用法?PHP CourseManager::subscribe_user怎么用?PHP CourseManager::subscribe_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CourseManager
的用法示例。
在下文中一共展示了CourseManager::subscribe_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
}
示例2: 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);
}
}
}
}
}
示例3: indexAction
/**
* @Route("/courses/{cidReq}/{sessionId}")
* @Method({"GET"})
*
* @param string $cidReq
* @param int $id_session
* @return Response
*/
public function indexAction($cidReq, $id_session = null)
{
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$userId = $this->getUser()->getUserId();
$coursesAlreadyVisited = $this->getRequest()->getSession()->get('coursesAlreadyVisited');
$result = $this->autolaunch();
$showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning'];
$showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning'];
if ($showAutoLaunchLpWarning) {
$this->getTemplate()->assign('lp_warning', Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'), 'warning'));
}
if ($showAutoLaunchExerciseWarning) {
$this->getTemplate()->assign('exercise_warning', Display::return_message(get_lang('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'), 'warning'));
}
if ($this->isCourseTeacher()) {
$editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('course_home.controller:iconListAction', array('course' => api_get_course_id())));
$this->getTemplate()->assign('edit_icons', $editIcons);
}
if (!isset($coursesAlreadyVisited[$courseCode])) {
event_access_course();
$coursesAlreadyVisited[$courseCode] = 1;
$this->getRequest()->getSession()->set('coursesAlreadyVisited', $coursesAlreadyVisited);
}
$this->getRequest()->getSession()->remove('toolgroup');
$this->getRequest()->getSession()->remove('_gid');
$isSpecialCourse = \CourseManager::is_special_course($courseCode);
if ($isSpecialCourse) {
$autoreg = $this->getRequest()->get('autoreg');
if ($autoreg == 1) {
\CourseManager::subscribe_user($userId, $courseCode, STUDENT);
}
}
$script = 'activity.php';
if (api_get_setting('homepage_view') == 'activity' || api_get_setting('homepage_view') == 'activity_big') {
$script = 'activity.php';
} elseif (api_get_setting('homepage_view') == '2column') {
$script = '2column.php';
} elseif (api_get_setting('homepage_view') == '3column') {
$script = '3column.php';
} elseif (api_get_setting('homepage_view') == 'vertical_activity') {
$script = 'vertical_activity.php';
}
$result = (require_once api_get_path(SYS_CODE_PATH) . 'course_home/' . $script);
$toolList = $result['tool_list'];
$this->getTemplate()->assign('icons', $result['content']);
$introduction = Display::return_introduction_section($this->get('url_generator'), TOOL_COURSE_HOMEPAGE, $toolList);
$this->getTemplate()->assign('introduction_text', $introduction);
if (api_get_setting('show_session_data') == 'true' && $sessionId) {
$sessionInfo = \CourseHome::show_session_data($sessionId);
$this->getTemplate()->assign('session_info', $sessionInfo);
}
$response = $this->get('template')->render_template($this->getTemplatePath() . 'index.tpl');
return new Response($response, 200, array());
}
示例4: indexAction
/**
* @Route("/", name="course_home")
* @Route("/index.php")
* @Method({"GET"})
*
* @param Request $request
* @return Response
*/
public function indexAction(Request $request)
{
$sessionId = api_get_session_id();
$course = $this->getCourse();
$courseCode = $course->getId();
$result = $this->autoLaunch();
$showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning'];
$showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning'];
if ($showAutoLaunchLpWarning) {
$this->addFlash('warning', $this->trans('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'));
}
if ($showAutoLaunchExerciseWarning) {
$this->addFlash('warning', $this->trans('TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise'));
}
if (true) {
$editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('chamilo_course_home_home_iconlist', array('course' => api_get_course_id())));
}
$isSpecialCourse = \CourseManager::isSpecialCourse($courseCode);
if ($isSpecialCourse) {
$user = $this->getUser();
if (!empty($user)) {
$userId = $this->getUser()->getId();
$autoreg = $request->get('autoreg');
if ($autoreg == 1) {
\CourseManager::subscribe_user($userId, $courseCode, STUDENT);
}
}
}
$homeView = api_get_setting('course.homepage_view');
if ($homeView == 'activity' || $homeView == 'activity_big') {
$result = $this->renderActivityView();
} elseif ($homeView == '2column') {
$result = $this->render2ColumnView();
} elseif ($homeView == '3column') {
$result = $this->render3ColumnView();
} elseif ($homeView == 'vertical_activity') {
$result = $this->renderVerticalActivityView();
}
$toolList = $result['tool_list'];
$introduction = Display::return_introduction_section(TOOL_COURSE_HOMEPAGE, $toolList);
$sessionInfo = null;
if (api_get_setting('session.show_session_data') == 'true' && $sessionId) {
$sessionInfo = CourseHome::show_session_data($sessionId);
}
return $this->render('ChamiloCourseBundle:Home:index.html.twig', array('course' => $course, 'session_info' => $sessionInfo, 'icons' => $result['content'], 'edit_icons' => $editIcons, 'introduction_text' => $introduction, 'exercise_warning' => null, 'lp_warning' => null));
}
示例5: switch
}
}
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);
$list_register_user = '';
//if ($$is_suscribe_counter!=1) {
for ($i = 0; $i < $is_suscribe_counter; $i++) {
for ($j = 0; $j < count($user_id_temp); $j++) {
if ($is_suscribe_user_id[$i] == $user_id_temp[$j]) {
示例6: switch
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);
$list_register_user = '';
for ($i = 0; $i < $is_suscribe_counter; $i++) {
for ($j = 0; $j < count($user_id_temp); $j++) {
if ($is_suscribe_user_id[$i] == $user_id_temp[$j]) {
if ($is_suscribe[$i]) {
示例7: api_not_allowed
if (api_is_invitee()) {
$isInASession = $sessionId > 0;
$isSubscribed = CourseManager::is_user_subscribed_in_course($user_id, $course_code, $isInASession, $sessionId);
if (!$isSubscribed) {
api_not_allowed(true);
}
}
//Deleting group session
Session::erase('toolgroup');
Session::erase('_gid');
$isSpecialCourse = CourseManager::isSpecialCourse($courseId);
if ($isSpecialCourse) {
if (isset($_GET['autoreg'])) {
$autoRegistration = Security::remove_XSS($_GET['autoreg']);
if ($autoRegistration == 1) {
if (CourseManager::subscribe_user($user_id, $course_code, STUDENT)) {
Session::write('is_allowed_in_course', true);
}
}
}
}
if (isset($_GET['action']) && $_GET['action'] == 'subscribe') {
if (Security::check_token('get')) {
Security::clear_token();
$auth = new Auth();
$msg = $auth->subscribe_user($course_code);
if (CourseManager::is_user_subscribed_in_course($user_id, $course_code)) {
Session::write('is_allowed_in_course', true);
}
if (!empty($msg)) {
$show_message .= Display::return_message(get_lang($msg['message']), 'info', false);
示例8: subscribe_users_to_usergroup
/**
* Subscribe users to a group
* @param int $usergroup_id usergroup id
* @param array $list list of user ids *
* @param bool $delete_users_not_present_in_list
* @param array $relationType
*/
public function subscribe_users_to_usergroup($usergroup_id, $list, $delete_users_not_present_in_list = true, $relationType = '')
{
$current_list = self::get_users_by_usergroup($usergroup_id);
$course_list = self::get_courses_by_usergroup($usergroup_id);
$session_list = self::get_sessions_by_usergroup($usergroup_id);
$delete_items = array();
$new_items = array();
if (!empty($list)) {
foreach ($list as $user_id) {
if (!in_array($user_id, $current_list)) {
$new_items[] = $user_id;
}
}
}
if (!empty($current_list)) {
foreach ($current_list as $user_id) {
if (!in_array($user_id, $list)) {
$delete_items[] = $user_id;
}
}
}
// Deleting items
if (!empty($delete_items) && $delete_users_not_present_in_list) {
foreach ($delete_items as $user_id) {
// Removing courses
if (!empty($course_list)) {
foreach ($course_list as $course_id) {
$course_info = api_get_course_info_by_id($course_id);
CourseManager::unsubscribe_user($user_id, $course_info['code']);
}
}
// Removing sessions
if (!empty($session_list)) {
foreach ($session_list as $session_id) {
SessionManager::unsubscribe_user_from_session($session_id, $user_id);
}
}
Database::delete($this->usergroup_rel_user_table, array('usergroup_id = ? AND user_id = ? AND relation_type = ?' => array($usergroup_id, $user_id, $relationType)));
}
}
// Adding new relationships
if (!empty($new_items)) {
// Adding sessions
if (!empty($session_list)) {
foreach ($session_list as $session_id) {
SessionManager::suscribe_users_to_session($session_id, $new_items, null, false);
}
}
foreach ($new_items as $user_id) {
// Adding courses
if (!empty($course_list)) {
foreach ($course_list as $course_id) {
$course_info = api_get_course_info_by_id($course_id);
CourseManager::subscribe_user($user_id, $course_info['code']);
}
}
$params = array('user_id' => $user_id, 'usergroup_id' => $usergroup_id, 'relation_type' => $relationType);
Database::insert($this->usergroup_rel_user_table, $params);
}
}
}
示例9: 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;
}
示例10: 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']);
}
}
}
}
示例11: subscribe_to_course
/**
* Subscribe all members of a class to a course
* @param int $class_id The class id
* @param string $course_code The course code
*/
public static function subscribe_to_course($class_id, $course_code)
{
$tbl_course_class = Database::get_main_table(TABLE_MAIN_COURSE_CLASS);
$tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$sql = "INSERT IGNORE INTO {$tbl_course_class} SET course_code = '" . Database::escape_string($course_code) . "', class_id = '" . Database::escape_string($class_id) . "'";
Database::query($sql);
$sql = "SELECT user_id FROM {$tbl_class_user} WHERE class_id = '" . intval($class_id) . "'";
$res = Database::query($sql);
while ($user = Database::fetch_object($res)) {
CourseManager::subscribe_user($user->user_id, $course_code);
}
}
示例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']);
} */
}
示例13: indexAction
/**
* @Route("/", name="course_home")
* @Route("/index.php")
* @Method({"GET"})
* @return Response
*/
public function indexAction(Request $request)
{
$course = $this->getCourse();
$session = $this->getSession();
// Already added in the listener.
/*if (false === $this->isGranted('view', $course)) {
throw new AccessDeniedException('Unauthorised access!');
}*/
$courseCode = $course->getId();
$sessionId = api_get_session_id();
$sessionHandler = $request->getSession();
$coursesAlreadyVisited = $sessionHandler->get('coursesAlreadyVisited');
$result = $this->autolaunch();
$showAutoLaunchLpWarning = $result['show_autolaunch_lp_warning'];
$showAutoLaunchExerciseWarning = $result['show_autolaunch_exercise_warning'];
if ($showAutoLaunchLpWarning) {
$this->addFlash('warning', 'TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP');
}
if ($showAutoLaunchExerciseWarning) {
$this->addFlash('warning', 'TheExerciseAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificExercise');
}
if (true) {
$editIcons = Display::url(Display::return_icon('edit.png'), $this->generateUrl('chamilo_course_home_home_iconlist', array('course' => api_get_course_id())));
}
// Course access events
$dispatcher = $this->container->get('event_dispatcher');
$dispatcher->dispatch('chamilo_course.course.access', new CourseAccess($this->getUser(), $course));
if (!isset($coursesAlreadyVisited[$courseCode])) {
$dispatcher = $this->container->get('event_dispatcher');
if (empty($sessionId)) {
$dispatcher->dispatch('chamilo_course.course.access', new CourseAccess($this->getUser(), $course));
} else {
$dispatcher->dispatch('chamilo_course.course.access', new SessionAccess($this->getUser(), $course, $session));
}
$coursesAlreadyVisited[$courseCode] = 1;
$sessionHandler->set('coursesAlreadyVisited', $coursesAlreadyVisited);
}
$sessionHandler->remove('toolgroup');
$sessionHandler->remove('_gid');
$isSpecialCourse = \CourseManager::is_special_course($courseCode);
if ($isSpecialCourse) {
$user = $this->getUser();
if (!empty($user)) {
$userId = $this->getUser()->getId();
$autoreg = $this->getRequest()->get('autoreg');
if ($autoreg == 1) {
\CourseManager::subscribe_user($userId, $courseCode, STUDENT);
}
}
}
$homeView = api_get_setting('course.homepage_view');
$homeView = 'activity_big';
if ($homeView == 'activity' || $homeView == 'activity_big') {
$result = $this->renderActivityView();
} elseif ($homeView == '2column') {
$result = $this->render2ColumnView();
} elseif ($homeView == '3column') {
$result = $this->render3ColumnView();
} elseif ($homeView == 'vertical_activity') {
$result = $this->renderVerticalActivityView();
}
$toolList = $result['tool_list'];
$introduction = Display::return_introduction_section($this->get('router'), TOOL_COURSE_HOMEPAGE, $toolList);
$sessionInfo = null;
if (api_get_setting('session.show_session_data') == 'true' && $sessionId) {
$sessionInfo = CourseHome::show_session_data($sessionId);
}
/*$response = $this->render(
'ChamiloCoreBundle:Tool:Home/index.html.twig',
array(
'session_info' => $sessionInfo,
'icons' => $result['content'],
'edit_icons' => $editIcons,
'introduction_text' => $introduction,
'exercise_warning' => null,
'lp_warning' => null
)
);
return new Response($response, 200, array());*/
return $this->render('ChamiloCourseBundle:Home:index.html.twig', array('course' => $course, 'session_info' => $sessionInfo, 'icons' => $result['content'], 'edit_icons' => $editIcons, 'introduction_text' => $introduction, 'exercise_warning' => null, 'lp_warning' => null));
}
示例14: external_get_user_info
} 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']);
$uidReset = false;
示例15: 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);
}
}
}
}
}