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


PHP CourseManager::unsubscribe_user方法代码示例

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


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

示例1: api_get_user_id

            $result = Database::query($sql);
            $row = Database::fetch_array($result, 'ASSOC');
            if ($row['user_id'] == $user_id || $row['user_id'] == "") {
                CourseManager::unsubscribe_user($_GET['user_id'], $courseCode);
                Display::addFlash(Display::return_message(get_lang('UserUnsubscribed')));
            } else {
                Display::addFlash(Display::return_message(get_lang('ThisStudentIsSubscribeThroughASession')));
            }
        }
    }
} else {
    // If student can unsubscribe
    if (isset($_REQUEST['unregister']) && $_REQUEST['unregister'] == 'yes') {
        if ($course_info['unsubscribe'] == 1) {
            $user_id = api_get_user_id();
            CourseManager::unsubscribe_user($user_id, $course_info['code']);
            header('Location: ' . api_get_path(WEB_PATH) . 'user_portal.php');
            exit;
        }
    }
}
if (!$is_allowed_in_course) {
    api_not_allowed(true);
}
// Statistics
Event::event_access_tool(TOOL_USER);
/**
 * Get the users to display on the current page.
 */
function get_number_of_users()
{
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:user.php

示例2: 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);
         }
     }
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:68,代码来源:usergroup.lib.php

示例3: array_map

            $row[] = Display::url($url['url'], $url['url']);
            $csvContent[] = array_map('strip_tags', $row);
            $data[] = $row;
        }
        $urlInformation = Display::page_subheader(get_lang('URLList'));
        $urlInformation .= Display::return_sortable_table($header, $data, array(), array(), array('user_id' => intval($_GET['user_id'])));
    } else {
        $urlInformation = '<p>' . get_lang('NoUrlForThisUser') . '</p>';
    }
}
$message = null;
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'unsubscribe':
            if (CourseManager::get_user_in_course_status($_GET['user_id'], $_GET['course_code']) == STUDENT) {
                CourseManager::unsubscribe_user($_GET['user_id'], $_GET['course_code'], $_GET['id_session']);
                $message = Display::return_message(get_lang('UserUnsubscribed'));
            } else {
                $message = Display::return_message(get_lang('CannotUnsubscribeUserFromCourse'), 'error');
            }
            break;
        case 'unsubscribeSessionCourse':
            SessionManager::removeUsersFromCourseSession(array($_GET['user_id']), $_GET['id_session'], api_get_course_info($_GET['course_code']));
            $message = Display::return_message(get_lang('UserUnsubscribed'));
            break;
        case 'export':
            Export::arrayToCsv($csvContent, 'user_information_' . $user);
            exit;
            break;
    }
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:31,代码来源:user_information.php

示例4: importUnsubscribeStatic

 /**
  * @param string $file
  */
 private function importUnsubscribeStatic($file, $moveFile = false, &$teacherBackup = array(), &$groupBackup = array())
 {
     $data = Import::csv_reader($file);
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         foreach ($data as $row) {
             $chamiloUserName = $row['UserName'];
             $chamiloCourseCode = $row['CourseCode'];
             $chamiloSessionId = $row['SessionID'];
             $sessionInfo = api_get_session_info($chamiloSessionId);
             if (empty($sessionInfo)) {
                 $this->logger->addError('Session does not exists: ' . $chamiloSessionId);
                 continue;
             }
             $courseInfo = api_get_course_info($chamiloCourseCode);
             if (empty($courseInfo)) {
                 $this->logger->addError('Course does not exists: ' . $courseInfo);
                 continue;
             }
             $userId = Usermanager::get_user_id_from_username($chamiloUserName);
             if (empty($userId)) {
                 $this->logger->addError('User does not exists: ' . $chamiloUserName);
                 continue;
             }
             $sql = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "\n                        WHERE\n                            user_id = " . $userId . " AND\n                            course_code = '" . $courseInfo['code'] . "'\n                        ";
             $result = Database::query($sql);
             $userCourseData = Database::fetch_array($result, 'ASSOC');
             $teacherBackup[$userId][$courseInfo['code']] = $userCourseData;
             $sql = "SELECT * FROM " . Database::get_course_table(TABLE_GROUP_USER) . "\n                        WHERE\n                            user_id = " . $userId . " AND\n                            c_id = '" . $courseInfo['real_id'] . "'\n                        ";
             $result = Database::query($sql);
             while ($groupData = Database::fetch_array($result, 'ASSOC')) {
                 $groupBackup['user'][$userId][$courseInfo['code']][$groupData['group_id']] = $groupData;
             }
             $sql = "SELECT * FROM " . Database::get_course_table(TABLE_GROUP_TUTOR) . "\n                        WHERE\n                            user_id = " . $userId . " AND\n                            c_id = '" . $courseInfo['real_id'] . "'\n                        ";
             $result = Database::query($sql);
             while ($groupData = Database::fetch_array($result, 'ASSOC')) {
                 $groupBackup['tutor'][$userId][$courseInfo['code']][$groupData['group_id']] = $groupData;
             }
             CourseManager::unsubscribe_user($userId, $courseInfo['code'], $chamiloSessionId);
             $this->logger->addError("User '{$chamiloUserName}' was removed from session: #{$chamiloSessionId}, Course: " . $courseInfo['code']);
         }
     }
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:46,代码来源:import_csv.php

示例5: get_lang

         $clean_users[] = $user_id;
     } else {
         $invalid_users[] = $user_data;
     }
 }
 if (empty($invalid_users)) {
     $type = 'confirmation';
     $message = get_lang('ListOfUsersSubscribedToCourse');
     if ($unsubscribe_users) {
         $current_user_list = CourseManager::get_user_list_from_course_code($course_code, $session_id);
         if (!empty($current_user_list)) {
             $user_ids = array();
             foreach ($current_user_list as $user) {
                 $user_ids[] = $user['user_id'];
             }
             CourseManager::unsubscribe_user($user_ids, $course_code, $session_id);
         }
     }
     foreach ($clean_users as $userId) {
         $userInfo = api_get_user_info($userId);
         CourseManager::subscribe_user($userId, $course_code, STUDENT, $session_id);
         if (empty($session_id)) {
             //just to make sure
             if (CourseManager::is_user_subscribed_in_course($userId, $course_code)) {
                 $user_to_show[] = $userInfo['complete_name'];
             }
         } else {
             //just to make sure
             if (CourseManager::is_user_subscribed_in_course($userId, $course_code, true, $session_id)) {
                 $user_to_show[] = $userInfo['complete_name'];
             }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:user_import.php

示例6: get_lang

            $result = Database::query($sql);
            $row = Database::fetch_array($result, 'ASSOC');
            if ($row['user_id'] == $user_id || $row['user_id'] == "") {
                CourseManager::unsubscribe_user($_GET['user_id'], $courseId);
                $message = get_lang('UserUnsubscribed');
            } else {
                $message = get_lang('ThisStudentIsSubscribeThroughASession');
            }
        }
    }
} else {
    //if student can unsubsribe
    if (isset($_REQUEST['unregister']) && $_REQUEST['unregister'] == 'yes') {
        if ($course_info['unsubscribe'] == 1) {
            $user_id = api_get_user_id();
            CourseManager::unsubscribe_user($user_id, $courseId);
            header('Location: ' . api_get_path(WEB_PATH) . 'user_portal.php');
            exit;
        }
    }
}
/*		FUNCTIONS	*/
function display_user_search_form()
{
    echo '<form method="get" action="user.php">';
    echo get_lang("SearchForUser") . "&nbsp;&nbsp;";
    echo '<input type="text" name="keyword" value="' . Security::remove_XSS($_GET['keyword']) . '"/>';
    echo '<input type="submit" value="' . get_lang('SearchButton') . '"/>';
    echo '</form>';
}
/*	Header */
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:user.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: remove_user_from_course

 /**
  * unsubscribe the user from a given course
  * @param   string  Course code
  * @return  bool    True if it success
  */
 public function remove_user_from_course($course_code)
 {
     $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
     // protect variables
     $current_user_id = api_get_user_id();
     $course_code = Database::escape_string($course_code);
     $result = true;
     $courseInfo = api_get_course_info($course_code);
     $courseId = $courseInfo['real_id'];
     // we check (once again) if the user is not course administrator
     // because the course administrator cannot unsubscribe himself
     // (s)he can only delete the course
     $sql = "SELECT * FROM {$tbl_course_user}\n                WHERE\n                    user_id='" . $current_user_id . "' AND\n                    c_id ='" . $courseId . "' AND\n                    status='1' ";
     $result_check = Database::query($sql);
     $number_of_rows = Database::num_rows($result_check);
     if ($number_of_rows > 0) {
         $result = false;
     }
     CourseManager::unsubscribe_user($current_user_id, $course_code);
     return $result;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:26,代码来源:auth.lib.php

示例9: importUnsubscribeStatic

 /**
  * @param string $file
  */
 private function importUnsubscribeStatic($file)
 {
     $data = Import::csv_reader($file);
     if (!empty($data)) {
         $this->logger->addInfo(count($data) . " records found.");
         foreach ($data as $row) {
             $chamiloUserName = $row['UserName'];
             $chamiloCourseCode = $row['CourseCode'];
             $chamiloSessionId = $row['SessionID'];
             $sessionInfo = api_get_session_info($chamiloSessionId);
             if (empty($sessionInfo)) {
                 $this->logger->addError('Session does not exists: ' . $chamiloSessionId);
                 continue;
             }
             $courseInfo = api_get_course_info($chamiloCourseCode);
             if (empty($courseInfo)) {
                 $this->logger->addError('Course does not exists: ' . $courseInfo);
                 continue;
             }
             $userId = Usermanager::get_user_id_from_username($chamiloUserName);
             if (empty($userId)) {
                 $this->logger->addError('User does not exists: ' . $chamiloUserName);
                 continue;
             }
             CourseManager::unsubscribe_user($userId, $courseInfo['code'], $chamiloSessionId);
             $this->logger->addError("User '{$chamiloUserName}' was removed from session: #{$chamiloSessionId}, Course: " . $courseInfo['code']);
         }
     }
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:32,代码来源:import_csv.php

示例10: importCSV


//.........这里部分代码省略.........
                     } else {
                         if ($debug) {
                             $logger->addError("Sessions - Session not found");
                         }
                     }
                 }
                 $session_counter++;
             }
             $sessionList[] = $session_id;
             $users = explode('|', $enreg['Users']);
             // Adding the relationship "Session - User" for students
             $userList = array();
             if (is_array($users)) {
                 foreach ($users as $user) {
                     $user_id = UserManager::get_user_id_from_username($user);
                     if ($user_id !== false) {
                         $userList[] = $user_id;
                         // Insert new users.
                         $sql = "INSERT IGNORE INTO {$tbl_session_user} SET\n                                    user_id = '{$user_id}',\n                                    session_id = '{$session_id}',\n                                    registered_at = '" . api_get_utc_datetime() . "'";
                         Database::query($sql);
                         if ($debug) {
                             $logger->addInfo("Sessions - Adding User #{$user_id} ({$user}) to session #{$session_id}");
                         }
                         $user_counter++;
                     }
                 }
             }
             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) {
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:67,代码来源:sessionmanager.lib.php

示例11: changeUserSubscription

	/**
	 * Subscribe or unsubscribe user to a course (helper method)
	 *
	 * @param string Course id field name. Use "chamilo_course_id" to use internal id
	 * @param string Course id value.
	 * @param string User id field name. Use "chamilo_user_id" to use internal id
	 * @param string User id value
	 * @param int Set to 1 to subscribe, 0 to unsubscribe
	 * @param int Status (STUDENT or TEACHER) Used for subscription only
	 * @return mixed True if subscription or unsubscription was successful, false otherwise
	 */
	protected function changeUserSubscription($course_id_field_name, $course_id_value, $user_id_field_name, $user_id_value, $state, $status = STUDENT) {
		$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
		if($course_id instanceof WSError) {
			return $course_id;
		} else {
			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
			if($user_id instanceof WSError) {
				return $user_id;
			} else {
				$course_code = CourseManager::get_course_code_from_course_id($course_id);
				if($state == 0) {
					// Unsubscribe user
					CourseManager::unsubscribe_user($user_id, $course_code);
					return true;
				} else {
					// Subscribe user
					if(CourseManager::subscribe_user($user_id, $course_code, $status)) {
						return true;
					} else {
						return new WSError(203, 'An error occured subscribing to this course');
					}
				}
			}
		}
	}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:36,代码来源:webservice_course.php

示例12: WSUnSubscribeUserFromCourseSimple

/**
 * @param array $params
 * @return array|null|soap_fault
 */
function WSUnSubscribeUserFromCourseSimple($params)
{
    global $debug;
    error_log('WSUnSubscribeUserFromCourseSimple');
    if (!WSHelperVerifyKey($params)) {
        return return_error(WS_ERROR_SECRET_KEY);
    }
    $original_user_id_value = $params['original_user_id_value'];
    $original_user_id_name = $params['original_user_id_name'];
    $original_course_id_value = $params['original_course_id_value'];
    $original_course_id_name = $params['original_course_id_name'];
    $result = array();
    $result['original_user_id_value'] = $original_user_id_value;
    $result['result'] = 0;
    $user_id = UserManager::get_user_id_from_original_id($original_user_id_value, $original_user_id_name);
    if ($user_id) {
        if ($debug) {
            error_log("User {$original_user_id_value}, {$original_user_id_name} found");
            error_log("Course {$original_course_id_value}, {$original_course_id_name} found");
        }
        $courseCode = CourseManager::get_course_id_from_original_id($original_course_id_value, $original_course_id_name);
        if (empty($courseCode)) {
            // Course was not found
            if ($debug) {
                error_log("course not found");
            }
        } else {
            if ($debug) {
                error_log("Course {$courseCode} found");
            }
            CourseManager::unsubscribe_user($user_id, $courseCode, 0);
            $result['result'] = 1;
        }
    } else {
        if ($debug) {
            error_log("User not found");
        }
    }
    return $result;
}
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:44,代码来源:registration.soap.php

示例13: 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();
    foreach ($users_courses as $user_course) {
        $csv_data[$user_course['UserName']][$user_course['CourseCode']] = $user_course['Status'];
    }
    foreach ($csv_data as $username => $csv_subscriptions) {
        $sql = "SELECT * FROM {$user_table} u WHERE u.username = '" . Database::escape_string($username) . "'";
        $res = Database::query($sql);
        $obj = Database::fetch_object($res);
        $user_id = $obj->user_id;
        $sql = "SELECT * FROM {$course_user_table} cu\n\t\t        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;
        }
        $csvCourseList = array();
        foreach ($csv_subscriptions as $courseCode => $status) {
            $courseInfo = api_get_course_info($courseCode);
            if ($courseInfo) {
                $csvCourseList[$courseInfo['real_id']] = $status;
            }
        }
        $to_subscribe = array_diff(array_keys($csvCourseList), array_keys($db_subscriptions));
        $to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csvCourseList));
        global $inserted_in_course;
        if (!isset($inserted_in_course)) {
            $inserted_in_course = array();
        }
        if (isset($_POST['subscribe']) && $_POST['subscribe']) {
            foreach ($to_subscribe as $courseId) {
                CourseManager::add_user_to_course($user_id, $courseId, $csvCourseList[$courseId]);
                $course_info = api_get_course_info_by_id($courseId);
                $inserted_in_course[$courseId] = $course_info['title'];
            }
        }
        if (isset($_POST['unsubscribe']) && $_POST['unsubscribe']) {
            foreach ($to_unsubscribe as $courseId) {
                CourseManager::unsubscribe_user($user_id, $courseId);
                $course_info = api_get_course_info_by_id($courseId);
                $inserted_in_course[$courseId] = $course_info['title'];
            }
        }
    }
}
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:51,代码来源:course_user_import.php

示例14: unsubscribe_from_course

 /**
  * Unsubscribe a class from a course.
  * Only students are unsubscribed. If a user is member of 2 classes which
  * are both subscribed to the course, the user stays in the course.
  * @param int $class_id The class id
  * @param string $course_code The course code
  */
 public static function unsubscribe_from_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);
     $sql = "SELECT cu.user_id,COUNT(cc.class_id) FROM {$tbl_course_class} cc, {$tbl_class_user} cu WHERE  cc.class_id = cu.class_id AND cc.course_code = '" . Database::escape_string($course_code) . "' GROUP BY cu.user_id HAVING COUNT(cc.class_id) = 1";
     $single_class_users = Database::query($sql);
     while ($single_class_user = Database::fetch_object($single_class_users)) {
         $sql = "SELECT * FROM {$tbl_class_user} WHERE class_id = '" . intval($class_id) . "' AND user_id = '" . Database::escape_string($single_class_user->user_id) . "'";
         $res = Database::query($sql);
         if (Database::num_rows($res) > 0) {
             if (CourseManager::get_user_in_course_status($single_class_user->user_id, $course_code) == STUDENT) {
                 CourseManager::unsubscribe_user($single_class_user->user_id, $course_code);
             }
         }
     }
     $sql = "DELETE FROM {$tbl_course_class} WHERE course_code = '" . Database::escape_string($course_code) . "' AND class_id = '" . Database::escape_string($class_id) . "'";
     Database::query($sql);
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:25,代码来源:classmanager.lib.php

示例15: api_protect_admin_script

api_protect_admin_script();
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array("url" => 'user_list.php', "name" => get_lang('UserList'));
if (!isset($_GET['user_id'])) {
    api_not_allowed();
}
$user = api_get_user_info($_GET['user_id']);
$tool_name = $user['complete_name'] . (empty($user['official_code']) ? '' : ' (' . $user['official_code'] . ')');
Display::display_header($tool_name);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'unsubscribe':
            if (CourseManager::get_user_in_course_status($_GET['user_id'], $_GET['courseId']) == STUDENT) {
                CourseManager::unsubscribe_user($_GET['user_id'], $_GET['courseId']);
                Display::display_normal_message(get_lang('UserUnsubscribed'));
            } else {
                Display::display_error_message(get_lang('CannotUnsubscribeUserFromCourse'));
            }
            break;
    }
}
//only allow platform admins to login_as, or session admins only for students
// (not teachers nor other admins), and only if all options confirm it
// $_configuration['login_as_forbidden_globally'], defined in configuration.php,
// is the master key to these conditions
$statusname = api_get_status_langvars();
$login_as_icon = '';
if (empty($_configuration['login_as_forbidden_globally']) && (api_is_global_platform_admin() || api_get_setting('login_as_allowed') === 'true' && (api_is_platform_admin() || api_is_session_admin() && (api_is_session_admin() && $row['6'] == $statusname[STUDENT])))) {
    $login_as_icon = '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?action=login_as&amp;user_id=' . $user['user_id'] . '&amp;sec_token=' . $_SESSION['sec_token'] . '">' . Display::return_icon('login_as.gif', get_lang('LoginAs')) . '</a>';
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:user_information.php


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