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


PHP SessionManager::unsubscribe_user_from_session方法代码示例

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


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

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

示例2: isset

        $idChecked = isset($_GET['idChecked']) ? $_GET['idChecked'] : null;
        if (is_array($idChecked)) {
            $usersToDelete = array();
            foreach ($idChecked as $courseCode) {
                // forcing the escape_string
                $courseInfo = api_get_course_info($courseCode);
                SessionManager::unsubscribe_course_from_session($sessionId, $courseInfo['real_id']);
            }
        }
        if (!empty($_GET['class'])) {
            $result = Database::query("DELETE FROM {$tbl_session_rel_class}\n                             WHERE session_id='{$sessionId}' AND class_id=" . intval($_GET['class']));
            $nbr_affected_rows = Database::affected_rows($result);
            Database::query("UPDATE {$tbl_session} SET nbr_classes=nbr_classes-{$nbr_affected_rows} WHERE id='{$sessionId}'");
        }
        if (!empty($_GET['user'])) {
            SessionManager::unsubscribe_user_from_session($sessionId, $_GET['user']);
        }
        break;
}
$sessionHeader = Display::page_header(Display::return_icon('session.png', get_lang('Session')) . ' ' . $sessionInfo['name'], null, 'h3');
$url = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), "session_edit.php?page=resume_session.php&id={$sessionId}");
$sessionTitle = Display::page_subheader(get_lang('GeneralProperties') . $url);
$generalCoach = api_get_user_info($sessionInfo['id_coach']);
$sessionField = new ExtraField('session');
$extraFieldData = $sessionField->getDataAndFormattedValues($sessionId);
$multiple_url_is_on = api_get_multiple_access_url();
$urlList = [];
if ($multiple_url_is_on) {
    $urlList = UrlManager::get_access_url_from_session($sessionId);
}
$url = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), "add_courses_to_session.php?page=resume_session.php&id_session={$sessionId}");
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:31,代码来源:resume_session.php

示例3: transaction_4

 static function transaction_4($data)
 {
     $uidIdPersona = $data['item_id'];
     $uidIdPrograma = $data['orig_id'];
     $uidIdProgramaDestination = $data['dest_id'];
     $status = !empty($data['info']) ? $data['info'] : null;
     global $data_list;
     $user_id = self::get_user_id_by_persona_id($uidIdPersona, $data_list);
     if (empty($user_id)) {
         return array('message' => "User does not exists in DB: {$uidIdPersona}", 'status_id' => self::TRANSACTION_STATUS_FAILED);
     }
     //Move A to B
     if (!empty($uidIdPrograma) && !empty($uidIdProgramaDestination)) {
         $session_id = self::get_session_id_by_programa_id($uidIdPrograma, $data_list);
         $destination_session_id = self::get_session_id_by_programa_id($uidIdProgramaDestination, $data_list);
         if (!empty($session_id) && !empty($destination_session_id)) {
             $before1 = SessionManager::get_user_status_in_session($session_id, $user_id);
             $before2 = SessionManager::get_user_status_in_session($destination_session_id, $user_id);
             /*
               These constants are defined in sessionmanager but are not
               usable directly from here
               SESSION_CHANGE_USER_REASON_SCHEDULE = 1;
               SESSION_CHANGE_USER_REASON_CLASSROOM = 2;
               SESSION_CHANGE_USER_REASON_LOCATION = 3;
               SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION = 4;
             */
             $reason_id = 1;
             SessionManager::change_user_session($user_id, $session_id, $destination_session_id, $reason_id);
             $befores = array($before1, $before2);
             $message = "Move Session A to Session B";
             return self::check_if_user_is_subscribe_to_session($user_id, $destination_session_id, $message, $befores);
         } else {
             return array('message' => "Session ids were not correctly setup session_id 1: {$session_id} Session id 2 {$uidIdProgramaDestination} - Move Session A to Session B", 'status_id' => self::TRANSACTION_STATUS_FAILED);
         }
     }
     //Move A to empty
     if (!empty($uidIdPrograma) && empty($uidIdProgramaDestination)) {
         $session_id = self::get_session_id_by_programa_id($uidIdPrograma, $data_list);
         if (!empty($session_id)) {
             $before = SessionManager::get_user_status_in_session($session_id, $user_id);
             //SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
             SessionManager::unsubscribe_user_from_session($session_id, $user_id);
             $message = "Move Session to empty";
             return self::check_if_user_is_subscribe_to_session($user_id, $session_id, $message, $before);
         } else {
             return array('message' => "Session does not exists in DB {$uidIdPrograma}  - Move Session to empty", 'status_id' => self::TRANSACTION_STATUS_FAILED);
         }
     }
     //Move empty to A
     if (empty($uidIdPrograma) && !empty($uidIdProgramaDestination)) {
         $session_id = self::get_session_id_by_programa_id($uidIdProgramaDestination, $data_list);
         if (!empty($session_id)) {
             $before = SessionManager::get_user_status_in_session($session_id, $user_id);
             if (isset($status) && $status == 1) {
                 $course_list = SessionManager::get_course_list_by_session_id($session_id);
                 if (!empty($course_list)) {
                     $course_data = current($course_list);
                     SessionManager::set_coach_to_course_session($user_id, $session_id, $course_data['code']);
                 } else {
                     return array('message' => 'Could not subscribe to course: no course in session ' . $uidIdProgramaDestination, 'status_id' => self::TRANSACTION_STATUS_FAILED);
                 }
             } else {
                 SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false);
             }
             $message = 'Move empty to Session';
             return self::check_if_user_is_subscribe_to_session($user_id, $session_id, $message, $before);
         } else {
             return array('message' => "Session does not exists in DB {$uidIdProgramaDestination} - Move empty to Session", 'status_id' => self::TRANSACTION_STATUS_FAILED);
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:71,代码来源:migration.custom.class.php

示例4: changeUserSubscription

 /**
  * Change user subscription (helper method)
  *
  * @param string User id field name
  * @param string User id value
  * @param string Session id field name
  * @param string Session id value
  * @param int State (1 to subscribe, 0 to unsubscribe)
  * @return mixed True on success, WSError otherwise
  */
 protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state)
 {
     $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
     if ($session_id instanceof WSError) {
         return $session_id;
     } else {
         $user_id = $this->getUserId($user_id_field_name, $user_id_value);
         if ($user_id instanceof WSError) {
             return $user_id;
         } else {
             if ($state == 1) {
                 SessionManager::suscribe_users_to_session($session_id, array($user_id));
             } else {
                 $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
                 if (!$result) {
                     return new WSError(303, 'There was an error unsubscribing this user from the session');
                 }
             }
             return true;
         }
     }
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:32,代码来源:webservice_session.php

示例5: WSUnsuscribeUsersFromSession

function WSUnsuscribeUsersFromSession($params)
{
    if (!WSHelperVerifyKey($params)) {
        return returnError(WS_ERROR_SECRET_KEY);
    }
    global $debug;
    if ($debug) {
        error_log('WSUnsuscribeUsersFromSession with params=[' . serialize($params) . ']');
    }
    $user_table = Database::get_main_table(TABLE_MAIN_USER);
    $userssessions_params = $params['userssessions'];
    $results = array();
    $orig_user_id_value = array();
    $orig_session_id_value = array();
    foreach ($userssessions_params as $usersession_params) {
        $original_session_id_value = $usersession_params['original_session_id_value'];
        $original_session_id_name = $usersession_params['original_session_id_name'];
        $original_user_id_name = $usersession_params['original_user_id_name'];
        $original_user_id_values = $usersession_params['original_user_id_values'];
        $orig_session_id_value[] = $original_session_id_value;
        $id_session = SessionManager::getSessionIdFromOriginalId($original_session_id_value, $original_session_id_name);
        if (empty($id_session)) {
            $results[] = 0;
            continue;
        }
        foreach ($original_user_id_values as $key => $row_original_user_list) {
            $user_id = UserManager::get_user_id_from_original_id($row_original_user_list['original_user_id_value'], $original_user_id_name);
            if ($user_id == 0) {
                continue;
                // user_id doesn't exist.
            } else {
                $sql = "SELECT user_id FROM {$user_table}\n                        WHERE user_id ='" . $user_id . "' AND active= '0'";
                $resu = Database::query($sql);
                $r_check_user = Database::fetch_row($resu);
                if (!empty($r_check_user[0])) {
                    continue;
                    // user_id is not active.
                }
                SessionManager::unsubscribe_user_from_session($id_session, $user_id);
                $orig_user_id_value[] = $row_original_user_list['original_user_id_value'];
                $orig_session_id_value[] = $original_session_id_value;
                $results[] = 1;
                if ($debug) {
                    error_log("Unsubscribe user:{$user_id} to session:{$id_session}");
                }
            }
        }
    }
    // end principal foreach
    $count_results = count($results);
    $output = array();
    for ($i = 0; $i < $count_results; $i++) {
        $output[] = array('original_user_id_values' => $orig_user_id_value[$i], 'original_session_id_value' => $orig_session_id_value[$i], 'result' => $results[$i]);
    }
    return $output;
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:56,代码来源:registration.soap.php


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