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


PHP SessionManager::isUserSubscribedAsStudent方法代码示例

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


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

示例1: WSSessionGetDetailsByUser

 /**
  * @param $params
  * @return null|soap_fault
  */
 public static function WSSessionGetDetailsByUser($params)
 {
     global $debug;
     if ($debug) {
         error_log('WSUserSubscribedInCourse');
         error_log('Params ' . print_r($params, 1));
     }
     if (!WSHelperVerifyKey($params)) {
         return return_error(WS_ERROR_SECRET_KEY);
     }
     $result = return_error(WS_ERROR_NOT_FOUND_RESULT);
     // Check params
     if (is_array($params) && !empty($params['session_id']) && !empty($params['user_id'])) {
         $userId = UserManager::get_user_id_from_original_id($params['user_id'], $params['user_field']);
         $sessionId = (int) $params['session_id'];
         // Check if user exists
         if (UserManager::is_user_id_valid($userId) && SessionManager::isValidId($sessionId)) {
             // Check if student is already subscribed
             $plugin = AdvancedSubscriptionPlugin::create();
             $isOpen = $plugin->isSessionOpen($sessionId);
             $status = $plugin->getQueueStatus($userId, $sessionId);
             $vacancy = $plugin->getVacancy($sessionId);
             $data = $plugin->getSessionDetails($sessionId);
             $isUserInTargetGroup = $plugin->isUserInTargetGroup($userId, $sessionId);
             if (!empty($data) && is_array($data)) {
                 $data['status'] = $status;
                 // Vacancy and queue status cases:
                 if ($isOpen) {
                     // Go to Course session
                     $data['action_url'] = self::$plugin->getOpenSessionUrl($userId, $params);
                     if (SessionManager::isUserSubscribedAsStudent($sessionId, $userId)) {
                         $data['status'] = 10;
                     }
                 } else {
                     if (!$isUserInTargetGroup) {
                         $data['status'] = -2;
                     } else {
                         try {
                             $isAllowed = self::$plugin->isAllowedToDoRequest($userId, $params);
                             $data['message'] = self::$plugin->getStatusMessage($status, $isAllowed);
                         } catch (\Exception $e) {
                             $data['message'] = $e->getMessage();
                         }
                         $params['action'] = 'subscribe';
                         $params['sessionId'] = intval($sessionId);
                         $params['currentUserId'] = 0;
                         // No needed
                         $params['studentUserId'] = intval($userId);
                         $params['queueId'] = 0;
                         // No needed
                         $params['newStatus'] = ADVANCED_SUBSCRIPTION_QUEUE_STATUS_START;
                         if ($vacancy > 0) {
                             // Check conditions
                             if ($status == ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE) {
                                 // No in Queue, require queue subscription url action
                                 $data['action_url'] = self::$plugin->getTermsUrl($params);
                             } elseif ($status == ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED) {
                                 // send url action
                                 $data['action_url'] = self::$plugin->getSessionUrl($sessionId);
                             } else {
                                 // In queue, output status message, no more info.
                             }
                         } else {
                             if ($status == ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED) {
                                 $data['action_url'] = self::$plugin->getSessionUrl($sessionId);
                             } elseif ($status == ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE) {
                                 // in Queue or not, cannot be subscribed to session
                                 $data['action_url'] = self::$plugin->getTermsUrl($params);
                             } else {
                                 // In queue, output status message, no more info.
                             }
                         }
                     }
                 }
                 $result = $data;
             } else {
                 // Return soap fault No result was found
                 $result = return_error(WS_ERROR_NOT_FOUND_RESULT);
             }
         } else {
             // Return soap fault No result was found
             $result = return_error(WS_ERROR_NOT_FOUND_RESULT);
         }
     } else {
         // Return soap fault Not valid input params
         $result = return_error(WS_ERROR_INVALID_INPUT);
     }
     return $result;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:93,代码来源:HookAdvancedSubscription.php

示例2: foreach

        }
    }
    $courses[] = ['course' => $sessionCourse, 'description' => $courseDescription, 'tags' => $courseTags, 'objectives' => $courseObjectives, 'topics' => $courseTopics, 'coaches' => $coachesData, 'extra_fields' => $courseValues->getAllValuesForAnItem($sessionCourse->getId())];
}
$sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
$sessionRequirements = $sequenceResourceRepo->getRequirements($session->getId(), SequenceResource::SESSION_TYPE);
$hasRequirements = false;
foreach ($sessionRequirements as $sequence) {
    if (!empty($sequence['requirements'])) {
        $hasRequirements = true;
        break;
    }
}
$courseController = new CoursesController();
/* View */
//$template = new Template($session->getName(), true, true, false, true, false);
$template = \Chamilo\CoreBundle\Framework\Container::getTwig();
$template->addGlobal('show_tutor', api_get_setting('session.show_session_coach') === 'true' ? true : false);
$template->addGlobal('pageUrl', api_get_path(WEB_PATH) . "session/{$session->getId()}/about/");
$template->addGlobal('session', $session);
$template->addGlobal('session_date', $sessionDates);
$template->addGlobal('is_subscribed', SessionManager::isUserSubscribedAsStudent($session->getId(), api_get_user_id()));
$template->addGlobal('subscribe_button', $courseController->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements));
$template->addGlobal('courses', $courses);
$template->addGlobal('essence', \Essence\Essence::instance());
$template->addGlobal('session_extra_fields', $sessionValues->getAllValuesForAnItem($session->getId(), true));
$template->addGlobal('has_requirements', $hasRequirements);
$template->addGlobal('sequences', $sessionRequirements);
//$templateFolder = api_get_configuration_value('default_template');
echo $template->render('@template_style/session/about.html.twig');
//$template->assign('header', $session->getName());
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:about.php

示例3: getFormatedSessionsBlock

 /**
  * Get the formated data for sessions block to be displayed on Session Catalog page
  * @param array $sessions The session list
  * @return array
  */
 private function getFormatedSessionsBlock(array $sessions)
 {
     $extraFieldValue = new ExtraFieldValue('session');
     $userId = api_get_user_id();
     $sessionsBlocks = [];
     $entityManager = Database::getManager();
     $sessionRelCourseRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourse');
     $extraFieldRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraField');
     $extraFieldRelTagRepo = $entityManager->getRepository('ChamiloCoreBundle:ExtraFieldRelTag');
     $tagsField = $extraFieldRepo->findOneBy(['extraFieldType' => Chamilo\CoreBundle\Entity\ExtraField::COURSE_FIELD_TYPE, 'variable' => 'tags']);
     /** @var \Chamilo\CoreBundle\Entity\Session $session */
     foreach ($sessions as $session) {
         $sessionDates = SessionManager::parseSessionDates(['display_start_date' => $session->getDisplayStartDate(), 'display_end_date' => $session->getDisplayEndDate(), 'access_start_date' => $session->getAccessStartDate(), 'access_end_date' => $session->getAccessEndDate(), 'coach_access_start_date' => $session->getCoachAccessStartDate(), 'coach_access_end_date' => $session->getCoachAccessEndDate()]);
         $imageField = $extraFieldValue->get_values_by_handler_and_field_variable($session->getId(), 'image');
         $sessionCourseTags = [];
         if (!is_null($tagsField)) {
             $sessionRelCourses = $sessionRelCourseRepo->findBy(['session' => $session]);
             foreach ($sessionRelCourses as $sessionRelCourse) {
                 $courseTags = $extraFieldRelTagRepo->getTags($tagsField, $sessionRelCourse->getCourse()->getId());
                 foreach ($courseTags as $tag) {
                     $sessionCourseTags[] = $tag->getTag();
                 }
             }
         }
         if (!empty($sessionCourseTags)) {
             $sessionCourseTags = array_unique($sessionCourseTags);
         }
         $repo = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource');
         $sequences = $repo->getRequirementsAndDependenciesWithinSequences($session->getId(), SequenceResource::SESSION_TYPE);
         $hasRequirements = false;
         foreach ($sequences['sequences'] as $sequence) {
             if (count($sequence['requirements']) === 0) {
                 continue;
             }
             $hasRequirements = true;
             break;
         }
         $sessionsBlock = array('id' => $session->getId(), 'name' => $session->getName(), 'image' => isset($imageField['value']) ? $imageField['value'] : null, 'nbr_courses' => $session->getNbrCourses(), 'nbr_users' => $session->getNbrUsers(), 'coach_name' => $session->getGeneralCoach()->getCompleteName(), 'is_subscribed' => SessionManager::isUserSubscribedAsStudent($session->getId(), $userId), 'icon' => $this->getSessionIcon($session->getName()), 'date' => $sessionDates['display'], 'subscribe_button' => $this->getRegisteredInSessionButton($session->getId(), $session->getName(), $hasRequirements), 'show_description' => $session->getShowDescription(), 'tags' => $sessionCourseTags);
         $sessionsBlock = array_merge($sessionsBlock, $sequences);
         $sessionsBlocks[] = $sessionsBlock;
     }
     return $sessionsBlocks;
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:48,代码来源:courses_controller.php

示例4: api_not_allowed

    api_not_allowed(true);
}
$userId = api_get_user_id();
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
$allowAccess = false;
$userManager = UserManager::getManager();
$entityManager = Database::getManager();
$user = $userManager->findUserBy(['id' => $userId]);
if (empty($sessionId)) {
    $trackCourseAccessRepository = $entityManager->getRepository('ChamiloCoreBundle:TrackECourseAccess');
    $lastCourseAccess = $trackCourseAccessRepository->getLastAccessByUser($user);
    $lastSessionId = 0;
    if ($lastCourseAccess) {
        $lastSessionId = $lastCourseAccess->getSessionId();
    }
    $UserIsSubscribedToSession = SessionManager::isUserSubscribedAsStudent($lastSessionId, $user->getId());
    if (!empty($lastSessionId) && $UserIsSubscribedToSession) {
        $urlWithSession = api_get_self() . '?' . http_build_query(['session_id' => $lastCourseAccess->getSessionId()]);
        header("Location: {$urlWithSession}");
        exit;
    }
}
$sessionCourseSubscriptions = $user->getSessionCourseSubscriptions();
$currentSession = $entityManager->find('ChamiloCoreBundle:Session', $sessionId);
$sessionList = [];
foreach ($sessionCourseSubscriptions as $subscription) {
    $session = $subscription->getSession();
    if (array_key_exists($session->getId(), $sessionList)) {
        continue;
    }
    if ($currentSession && $currentSession->getId() === $session->getId()) {
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:my_progress.php

示例5: api_get_session_info

<?php

/* For licensing terms, see /license.txt */
/**
 * Validate requirements for a open session
 * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
 * @package chamilo.plugin.advanced_subscription
 */
require_once __DIR__ . '/../config.php';
$plugin = AdvancedSubscriptionPlugin::create();
if (!isset($_GET['session_id'], $_GET['user_id'], $_GET['profile_completed'])) {
    die;
}
$sessionInfo = api_get_session_info($_GET['session_id']);
$tpl = new Template($plugin->get_lang('plugin_title'), false, false, false, false, false);
$tpl->assign('session', $sessionInfo);
if (SessionManager::isUserSubscribedAsStudent($_GET['session_id'], $_GET['user_id'])) {
    $tpl->assign('is_subscribed', false);
    $tpl->assign('errorMessages', [sprintf($plugin->get_lang('YouAreAlreadySubscribedToSessionX'), $sessionInfo['name'])]);
} else {
    if (!$plugin->isAllowedSubscribeToOpenSession($_GET)) {
        $tpl->assign('is_subscribed', false);
        $tpl->assign('errorMessages', $plugin->getErrorMessages());
    } else {
        SessionManager::suscribe_users_to_session($_GET['session_id'], [$_GET['user_id']], SESSION_VISIBLE_READ_ONLY, false);
        $tpl->assign('is_subscribed', true);
    }
}
$content = $tpl->fetch('/advanced_subscription/views/open_session.tpl');
$tpl->assign('content', $content);
$tpl->display_one_col_template();
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:open_session.php

示例6: getOpenSessionUrl

 /**
  * Get a url for subscribe a user in session
  * @param int $userId The user ID
  * @param array $params Params from WS
  * @return string
  */
 public function getOpenSessionUrl($userId, $params)
 {
     $userIsSubscribed = SessionManager::isUserSubscribedAsStudent($params['session_id'], $userId);
     if ($userIsSubscribed) {
         return api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($params['session_id']);
     }
     $params['secret_key'] = null;
     $params['user_id'] = null;
     $params['user_field'] = null;
     $params['is_connected'] = null;
     $urlParams = array_merge($params, ['user_id' => $userId]);
     $url = api_get_path(WEB_PLUGIN_PATH);
     $url .= 'advanced_subscription/src/open_session.php?';
     $url .= http_build_query($urlParams);
     return 'javascript:void(window.open(\'' . $url . '\',\'AdvancedSubscriptionTerms\', \'toolbar=no,location=no,' . 'status=no,menubar=no,scrollbars=yes,resizable=yes,width=700px,' . 'height=600px\', \'100\' ))';
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:22,代码来源:AdvancedSubscriptionPlugin.php


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