當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。