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


PHP SessionController::getCurrentSession方法代码示例

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


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

示例1: apiCurrentSession

 /**
  * Returns associative array with information about current session.
  *
  * */
 public static function apiCurrentSession(Request $r = null)
 {
     if (defined('OMEGAUP_SESSION_CACHE_ENABLED') && OMEGAUP_SESSION_CACHE_ENABLED === true && !is_null(self::$current_session)) {
         return self::$current_session;
     }
     if (is_null($r)) {
         $r = new Request();
     }
     if (is_null($r['auth_token'])) {
         $r['auth_token'] = SessionController::getAuthToken($r);
     }
     $authToken = $r['auth_token'];
     if ($authToken != null && defined('OMEGAUP_SESSION_CACHE_ENABLED') && OMEGAUP_SESSION_CACHE_ENABLED === true) {
         Cache::getFromCacheOrSet(Cache::SESSION_PREFIX, $authToken, $r, array('SessionController', 'getCurrentSession'), $session, APC_USER_CACHE_SESSION_TIMEOUT);
         self::$current_session = $session;
     } else {
         self::$current_session = SessionController::getCurrentSession($r);
     }
     return self::$current_session;
 }
开发者ID:andreasantillana,项目名称:omegaup,代码行数:24,代码来源:SessionController.php

示例2: apiArbitrateRequest

 public static function apiArbitrateRequest(Request $r)
 {
     $result = array("status" => "ok");
     if (is_null($r["resolution"])) {
         throw new InvalidParameterException("invalidParameters");
     }
     // user must be admin of contest to arbitrate security
     $current_ses = SessionController::getCurrentSession($r);
     try {
         $r["contest"] = ContestsDAO::getByAlias($r["contest_alias"]);
     } catch (Exception $e) {
         throw new NotFoundException($e);
     }
     if (is_null($r["contest"])) {
         throw new NotFoundException("contestNotFound");
     }
     $r["target_user"] = UsersDAO::FindByUsername($r["username"]);
     $request = ContestUserRequestDAO::getByPK($r["target_user"]->user_id, $r["contest"]->contest_id);
     if (is_null($request)) {
         throw new InvalidParameterException("userNotInListOfRequests");
     }
     if ($r["resolution"] === "false") {
         // "false" casts to true.
         $resolution = false;
     } else {
         $resolution = (bool) $r["resolution"];
     }
     $request->setAccepted($resolution);
     $request->setExtraNote($r["note"]);
     $request->setLastUpdate(gmdate('Y-m-d H:i:s'));
     ContestUserRequestDAO::save($request);
     // Save this action in the history
     $history = new ContestUserRequestHistory();
     $history->user_id = $request->user_id;
     $history->contest_id = $request->user_id;
     $history->time = $request->last_update;
     $history->admin_id = $current_ses["id"];
     $history->accepted = $request->accepted;
     ContestUserRequestHistoryDAO::save($history);
     self::$log->info("Arbitrated contest for user, new accepted user_id=" . $r["target_user"]->user_id . ", state=" . $resolution);
     return $result;
 }
开发者ID:heduenas,项目名称:omegaup,代码行数:42,代码来源:ContestController.php


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