コード例 #1
0
 public function queryChildren($resource, $id, $childresource, $request, $response)
 {
     if ($resource == 'roles') {
         // new role rest service
         $roleRestSvc = new RoleRestService();
         return $roleRestSvc->queryChildren($resource, $id, $childresource, $request, $response);
     }
     return parent::queryChildren($resource, $id, $childresource, $request, $response);
 }
コード例 #2
0
ファイル: TrackService.php プロジェクト: EQ4/smafe
 public function __construct()
 {
     parent::__construct("get");
 }
コード例 #3
0
 protected function setResponse($dataArray, $response, $format)
 {
     if ($this->extraDataReturn) {
         foreach ($this->extraDataReturn as $k => $v) {
             $dataArray[$k] = $v;
         }
     }
     return parent::setResponse($dataArray, $response, $format);
 }
コード例 #4
0
ファイル: process.php プロジェクト: NetWielder/mantis-rest
<?php

require_once 'init.php';
$request = new Request();
$request->populate_from_server();
$service = new RestService();
try {
    $resp = $service->handle($request);
    $resp->send();
} catch (HTTPException $e) {
    $e->resp->send();
}
コード例 #5
0
ファイル: HelpApi.php プロジェクト: jglaine/sugar761-ent
 /**
  * Gets the exceptions list for the exceptions help endpoint
  * 
  * @param RestService $api The service object
  * @param array $args The request arguments
  * @return string The HTML output for this help endpoint
  */
 public function getExceptionsHelp($api, $args)
 {
     $exceptions = $this->getExceptions();
     $this->ensureClientFiles();
     $jsfiles = $this->clientFiles;
     ob_start();
     require 'include/api/help/extras/exceptionList.php';
     $endpointHtml = ob_get_clean();
     $api->setHeader('Content-Type', 'text/html');
     return $endpointHtml;
 }
コード例 #6
0
<?php

/**
 * This is the entry point for the RESTful services.
 * You should place this file to the proper place of your server.
 *
 */
define('APP_ROOT', realpath(dirname(__FILE__)));
define('ACTION_ROOT', APP_ROOT . '/actions/');
define('FRAMEWORK', APP_ROOT . '/framework');
define('API_SIG_KEY', '03feddaa3434c48cd4b6a6238f002e77');
require_once FRAMEWORK . '/elex.php';
import('elex.rest.RestService');
$service = new RestService();
// set the action root
$service->setActionPath(ACTION_ROOT);
// set the app conmunicate secret key
$service->setAppkey(API_SIG_KEY);
// if you want to run at debug mode
//$service->setDebug(true);
$service->service();
コード例 #7
0
 protected function login($args, $params)
 {
     //Login
     if ($this->method == "POST") {
         //return "hello";
         //return var_dump($params);
         if (isset($params['Access'])) {
             //access hash was passed to us, check if user is logged in already
             $result = $this->checkIfLoggedIn($params['Access']);
             //$result=$params['Access'];
             if ($result != 0 && $result != -1) {
                 //user already logged in
                 return parent::_response("Already logged in", 202);
             } elseif ($result != -1) {
                 //user is not logged in, continue logging in
             } else {
                 //failed to get info from DB
                 return parent::_response("Failed to session info", 500);
             }
         }
         if (isset($this->request['username']) && isset($this->request['password'])) {
             //return {Something:"hello"};
             $conn = new DB();
             if ($conn->connect("localhost", "finalProject", "root", "final")) {
                 //var_dump($this->request);
                 $fields = array("user_id", "username", "password");
                 $username = $this->request['username'];
                 $data = $conn->getData("users", $fields, null, "username='******'");
                 if ($data[0]["password"] == $this->request['password']) {
                     $access = $this->random_str(50);
                     $columns = array("access", "uid");
                     $values = array($access, $data[0]["user_id"]);
                     if ($conn->insertData("sessions", $columns, $values)) {
                         return array("status" => "logged in", "uid" => $data[0]["user_id"], "accesshash" => $access);
                     } else {
                         return parent::_response("Failed to add user session", 500);
                     }
                 } else {
                     return parent::_response("Invalid Login", 403);
                 }
             } else {
                 return parent::_response("Failed to connect to DB", 500);
             }
         } else {
             return parent::_response("User or password not supplied", 400);
         }
     } else {
         return parent::_response("Incorrect login format or nothing sent", 400);
     }
 }
コード例 #8
0
 public function query($resource, $request, $response)
 {
     $profile = BizSystem::getUserProfile();
     $userId = $profile['Id'];
     return parent::get('users', $userId, $request, $response);
 }
コード例 #9
0
ファイル: grest.php プロジェクト: remyguillaume/GRest
<?php

require_once 'RestService.php';
require_once 'Parameters.php';
Parameters::Initialize();
$service = new RestService();
$service->processRequest($_SERVER, $_GET, $_POST);
コード例 #10
0
 public function queryChildren($resource, $id, $childresource, $request, $response)
 {
     // handle aclroleactions in special logic
     if ($childresource != "aclroleactions") {
         return parent::queryChildren($resource, $id, $childresource, $request, $response);
     }
     $roleId = $id;
     // get page and sort parameters
     $allGetVars = $request->get();
     $queryParams = array();
     foreach ($allGetVars as $key => $value) {
         if ($key == 'page' || $key == 'rows' || $key == 'sort' || $key == 'sorder' || $key == 'format') {
             continue;
         }
         //if ($value !== null && $value !== '') {
         $queryParams[$key] = $value;
         //}
     }
     $page = $request->params('page');
     if (!$page) {
         $page = 0;
     }
     if ($page >= 1) {
         $page--;
     }
     $rows = $request->params('rows');
     if (!$rows) {
         $rows = 10;
     }
     $sort = $request->params('sort');
     $sorder = $request->params('sorder');
     // fetch acl_action records
     $aclActionDo = BizSystem::getObject("system.do.AclActionDO");
     $aclActionDo->resetRules();
     $aclActionDo->setQueryParameters($queryParams);
     $aclActionDo->setLimit($rows, $page * $rows);
     if ($sort && $sorder) {
         $aclActionDo->setSortRule("[{$sort}] {$sorder}");
     }
     $dataSet = $aclActionDo->fetch();
     $total = $aclActionDo->count();
     $totalPage = ceil($total / $rows);
     // fetch role and access records
     $dataObj = BizSystem::getObject("system.do.AclRoleActionDO");
     $dataObj->setSearchRule("[role_id]={$roleId}");
     $dataObj->setQueryParameters($queryParams);
     if ($sort && $sorder) {
         $dataObj->setSortRule("[{$sort}] {$sorder}");
     }
     $dataSet1 = $dataObj->fetch();
     foreach ($dataSet1 as $rec) {
         $actionRoleAccess[$rec['action_id']] = $rec;
     }
     $dataArr = $dataSet->toArray();
     // merge 2 datasets
     for ($i = 0; $i < count($dataArr); $i++) {
         $actionId = $dataArr[$i]['Id'];
         $dataArr[$i]['access_level'] = "0";
         if (isset($actionRoleAccess[$actionId])) {
             $dataArr[$i]['role_id'] = $roleId;
             $dataArr[$i]['access_level'] = $actionRoleAccess[$actionId]['access_level'];
         }
     }
     $format = strtolower($request->params('format'));
     return $this->setResponse(array('totalPage' => $totalPage, 'data' => $dataArr), $response, $format);
 }
コード例 #11
0
ファイル: TrackServiceDelete.php プロジェクト: EQ4/smafe
 public function __construct()
 {
     parent::__construct("delete");
 }
コード例 #12
0
ファイル: TrackServiceAdd.php プロジェクト: EQ4/smafe
 public function __construct()
 {
     parent::__construct("put, post");
 }
コード例 #13
0
 public function __construct($parent)
 {
     $this->parent = $parent;
     parent::__construct();
 }