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


PHP UserController::apiProfile方法代码示例

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


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

示例1: testUserDataAnotherUser

 public function testUserDataAnotherUser()
 {
     $user = UserFactory::createUser("testuser3");
     $user2 = UserFactory::createUser("testuser4");
     $r = new Request(array("auth_token" => self::login($user), "username" => $user2->getUsername()));
     $response = UserController::apiProfile($r);
     $this->assertArrayNotHasKey("password", $response["userinfo"]);
     $this->assertEquals($user2->getUsername(), $response["userinfo"]["username"]);
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:9,代码来源:UserProfileTest.php

示例2: apiRequests

 public static function apiRequests(Request $r)
 {
     // Authenticate request
     self::authenticateRequest($r);
     Validators::isStringNonEmpty($r["contest_alias"], "contest_alias");
     try {
         $contest = ContestsDAO::getByAlias($r["contest_alias"]);
     } catch (Exception $e) {
         throw new InvalidDatabaseOperationException($e);
     }
     if (!Authorization::IsContestAdmin($r["current_user_id"], $contest)) {
         throw new ForbiddenAccessException();
     }
     try {
         $db_results = ContestUserRequestDAO::getRequestsForContest($contest->getContestId());
     } catch (Exception $e) {
         throw new InvalidDatabaseOperationException($e);
     }
     // @TODO prefetch an alias-user_id map so that we dont need
     // a getbypk (sql select query) on every iteration of the following loop
     // Precalculate all admin profiles.
     $admin_infos = array();
     foreach ($db_results as $result) {
         $admin_id = $result["admin_id"];
         if (!array_key_exists($admin_id, $admin_infos)) {
             $data = UsersDAO::getByPK($admin_id);
             if (!is_null($data)) {
                 $admin_infos[$admin_id]["user_id"] = $data->user_id;
                 $admin_infos[$admin_id]["username"] = $data->username;
                 $admin_infos[$admin_id]["name"] = $data->name;
             }
         }
     }
     $users = array();
     foreach ($db_results as $result) {
         $admin_id = $result["admin_id"];
         $result = new ContestUserRequest($result);
         $user_id = $result->getUserId();
         $user = UsersDAO::getByPK($user_id);
         // Get user profile. Email, school, etc.
         $profile_request = new Request();
         $profile_request["username"] = $user->getUsername();
         $profile_request["omit_rank"] = true;
         $userprofile = UserController::apiProfile($profile_request);
         $adminprofile = array();
         if (array_key_exists($admin_id, $admin_infos)) {
             $adminprofile = $admin_infos[$admin_id];
         }
         $users[] = array_merge($userprofile["userinfo"], array("last_update" => $result->last_update, "accepted" => $result->accepted, "extra_note" => $result->extra_note, "admin" => $adminprofile, "request_time" => $result->request_time));
     }
     $response = array();
     $response["users"] = $users;
     $response["status"] = "ok";
     return $response;
 }
开发者ID:heduenas,项目名称:omegaup,代码行数:55,代码来源:ContestController.php


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