protected function loadPage()
 {
     $table = new PhabricatorOAuthClientAuthorization();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT * FROM %T auth %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     return $table->loadAllFromArray($data);
 }
 /**
  * @task auth
  */
 public function authorizeClient(array $scope)
 {
     $authorization = new PhabricatorOAuthClientAuthorization();
     $authorization->setUserPHID($this->getUser()->getPHID());
     $authorization->setClientPHID($this->getClient()->getPHID());
     $authorization->setScope($scope);
     $authorization->save();
     return $authorization;
 }
 public function execute()
 {
     $table = new PhabricatorOAuthClientAuthorization();
     $conn_r = $table->establishConnection('r');
     $where_clause = $this->buildWhereClause($conn_r);
     $limit_clause = $this->buildLimitClause($conn_r);
     $data = queryfx_all($conn_r, 'SELECT * FROM %T auth %Q %Q', $table->getTableName(), $where_clause, $limit_clause);
     return $table->loadAllFromArray($data);
 }
 private function authorizeOAuthMethodAccess(PhabricatorOAuthClientAuthorization $authorization, $method_name)
 {
     $method = ConduitAPIMethod::getConduitMethod($method_name);
     if (!$method) {
         return false;
     }
     $required_scope = $method->getRequiredScope();
     switch ($required_scope) {
         case ConduitAPIMethod::SCOPE_ALWAYS:
             return true;
         case ConduitAPIMethod::SCOPE_NEVER:
             return false;
     }
     $authorization_scope = $authorization->getScope();
     if (!empty($authorization_scope[$required_scope])) {
         return true;
     }
     return false;
 }