/** * @covers \Magento\Framework\App\RequestFactory::__construct * @covers \Magento\Framework\App\RequestFactory::create */ public function testCreate() { $arguments = ['some_key' => 'same_value']; $appRequest = $this->getMock('Magento\\Framework\\App\\RequestInterface'); $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\RequestInterface', $arguments)->will($this->returnValue($appRequest)); $this->assertEquals($appRequest, $this->model->create($arguments)); }
/** * @param $requestName * @param callable $callback * @return mixed */ public function send($requestName, \Closure $callback = null) { $request = $this->requestFactory->create($requestName); if ($callback) { $callback($request); } // validate request $request->validateRequest(); $cacertUrl = __DIR__ . '/../cacert/' . $this->cacertFileName; $apiResponse = $this->sender->send($request, $cacertUrl); return $request->handleResponse($apiResponse); }
public function testRequestObjectArg() { $request = $this->resolver->getRequest([RequestFactory::create('image.jpg', ['w' => 100])]); $this->assertEquals('image.jpg', $request->getPathInfo()); $this->assertEquals(['w' => 100], $request->query->all()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Request', $request); }
/** * @return Response */ private function exec() { $url = $this->url; $options = $this->options; switch ($this->method) { case self::METHOD_GET: break; case self::METHOD_POST: $options[] = [CURLOPT_POST, TRUE]; break; default: $options[] = [CURLOPT_CUSTOMREQUEST, $this->method]; } if ($this->parameters) { if ($this->method === self::METHOD_GET) { $url .= '?' . http_build_query($this->parameters); } else { $isJson = isset($options[self::CURLOPT_JSON]) && $options[self::CURLOPT_JSON]; $data = $isJson ? json_encode($this->parameters) : http_build_query($this->parameters); $options[] = [CURLOPT_POSTFIELDS, $data]; } } if ($this->headers) { $options[] = [CURLOPT_HTTPHEADER, $this->headers]; } $request = $this->requestFactory->create($url, $options); return $this->responseFactory->create($request); }
public function clearUserEventLog() { $req = RequestFactory::createDeleteRequest(get_app_config($this->gameuid)); $req->setKey('gameuid', $this->gameuid); $req->setTable($this->getTableName()); $req->addKeyValue('gameuid', $this->gameuid); return $req->execute(); }
public function testItWillReturnARequestInstanceOnly() { $request1 = RequestFactory::create(); $_SERVER = ['REQUEST_METHOD' => 'GET', 'HTTP_HOST' => 'nilportugues.com', 'REQUEST_TIME' => time()]; $page1 = PageFactory::create($this->request); $page2 = PageFactory::create($this->request); $this->assertTrue($page1 === $page2); }
public function run() { try { $request = $this->requestFactory->createRequest(); $controller = $this->controllerFactory->create($request); $response = $controller->run($request); } catch (AuthorizationException $e) { $response = new Response(['message' => $e->getMessage()], 401); } catch (ApiException $e) { $response = new Response(['message' => $e->getMessage()], $e->getCode() ?: 400); } http_response_code($response->getCode()); header('Content-Type: application/json'); $body = json_encode($response->getData()); header('X-Api-Signature: ' . hash_hmac('sha256', $body, $this->configuration->getPrivateKey())); echo $body; }
/** * Instantiate a client */ public function doSetup($requestNumber) { $handler = new MockHandler([]); for ($i = 0; $i < $requestNumber; $i++) { $handler->append(new Response(200)); } $guzzle = new GuzzleClient(["handler" => $handler]); $this->requestFactory = $this->getMock('Silktide\\SemRushApi\\Model\\Factory\\RequestFactory'); $this->request = $this->getMockBuilder('Silktide\\SemRushApi\\Model\\Request')->disableOriginalConstructor()->getMock(); $this->requestFactory->expects($this->exactly($requestNumber))->method('create')->willReturn($this->request); $this->resultFactory = $this->getMockBuilder('Silktide\\SemRushApi\\Model\\Factory\\ResultFactory')->disableOriginalConstructor()->getMock(); $result = $this->getMockBuilder('Silktide\\SemRushApi\\Model\\Result')->disableOriginalConstructor()->getMock(); $this->resultFactory->expects($this->exactly(1))->method('create')->willReturn($result); $this->responseParser = $this->getMock('Silktide\\SemRushApi\\Helper\\ResponseParser'); $urlBuilder = $this->getMock('Silktide\\SemRushApi\\Helper\\UrlBuilder'); $this->instance = new Client($this->key, $this->requestFactory, $this->resultFactory, $this->responseParser, $urlBuilder, $guzzle); }
/** * _getRequestProxy * * @param string $parameters * @param string $options * @return void */ protected function _getRequestProxy($parameters, $options = array()) { $cakeRequest = new CakeRequest(); $request =& new OauthLibAppController($cakeRequest); $request->request->data = $parameters; $request->request->params['url'] = array('url' => '/', 'ext' => 'html'); $_ENV['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'; $_ENV['Authorization'] = null; return RequestFactory::proxy($request, $options); }
/** * testThatProxyPostAndGetRequestWorks * * @return void */ public function testThatProxyPostAndGetRequestWorks() { $http = null; $request =& new ClientHttp($http, '/test?key=value', array(), 'POST'); $params = array('key2' => 'value2'); $requestProxy = RequestFactory::proxy($request, array('uri' => 'http://example.com/test?key=value', 'parameters' => $params)); $expectedParameters = array('key' => array('value'), 'key2' => array('value2')); $this->assertEqual($expectedParameters, $requestProxy->parameters()); $this->assertEqual('http://example.com/test', $requestProxy->uri()); $this->assertEqual('POST', $requestProxy->method()); }
/** * Factory build method for signature * * @param Request $request * @param array $options */ public function build($request, $options = array()) { $_this = Signature::getInstance(); $request = RequestFactory::proxy($request, $options); $signatureMethod = $request->signatureMethod(); if (isset($_this->availableMethods[$signatureMethod])) { $class = $_this->availableMethods[$signatureMethod]; } else { throw new Exception("UnknownSignatureMethod {$signatureMethod}"); } return new $class($request, $options); }
/** * Wrap request class with proxy * * @param Request $request * @param string $options * @return RequestProxy */ public function proxy(&$request, $options = array()) { $_this = RequestFactory::getInstance(); if (is_object($request) && in_array(get_class($request), $_this->availableProxies)) { return $request; } if (isset($_this->availableProxies[get_class($request)])) { $class = $_this->availableProxies[get_class($request)]; return new $class($request, $options); } foreach ($_this->availableProxies as $requestClass => $proxyClass) { if (is_subclass_of($request, $requestClass)) { return new $proxyClass($request, $options); } } throw new Exception("UnknownRequestType " . get_class($request)); return false; }
static function convertHierarchyLevelMapToSQL($hierarchy_level_map, $object_table = 'a.', $hierarchy_user_table = 'z.', $type_id_column = NULL) { /* ( z.hierarchy_control_id = 469 AND a.authorization_level = 1 ) OR ( z.hierarchy_control_id = 471 AND a.authorization_level = 2 ) OR ( z.hierarchy_control_id = 470 AND a.authorization_level = 3 ) OR ( z.hierarchy_control_id = 469 AND a.authorization_level = 1 AND a.type_id in (10,20,30) ) OR ( z.hierarchy_control_id = 471 AND a.authorization_level = 2 AND a.type_id in (10) ) OR ( z.hierarchy_control_id = 470 AND a.authorization_level = 3 AND a.type_id in (100) ) */ if (is_array($hierarchy_level_map)) { $rf = new RequestFactory(); $clause_arr = array(); foreach ($hierarchy_level_map as $hierarchy_data) { if ($hierarchy_data['last_level'] == TRUE) { $operator = ' >= '; } else { $operator = ' = '; } $object_type_clause = NULL; if ($type_id_column != '' and isset($hierarchy_data['object_type_id']) and count($hierarchy_data['object_type_id']) > 0) { $hierarchy_data['object_type_id'] = $rf->getTypeIdFromHierarchyTypeId($hierarchy_data['object_type_id']); $object_type_clause = ' AND ' . $type_id_column . ' in (' . implode(',', $hierarchy_data['object_type_id']) . ')'; } $clause_arr[] = '( ' . $hierarchy_user_table . 'hierarchy_control_id = ' . (int) $hierarchy_data['hierarchy_control_id'] . ' AND ' . $object_table . 'authorization_level ' . $operator . ' ' . (int) $hierarchy_data['level'] . $object_type_clause . ' )'; } $retval = implode(' OR ', $clause_arr); //Debug::Text(' Hierarchy Filter SQL: '. $retval, __FILE__, __LINE__, __METHOD__,10); return $retval; } return FALSE; }
private function commitToDB_bak($logs = null) { $key = $this->getMemkey(); if ($logs == null) { $logs = $this->getFromCache($key, $this->gameuid); } if (empty($logs)) { return; } if (PLATFORM == "test" || PLATFORM == "facebook_tw") { $contents = ''; $fomat = "g[%d]a[%d]c[%d]m[%d]e[%d]d[%d]it[%d]t[%d] \r\n"; foreach ($logs as $log) { $contents .= sprintf($fomat, $this->gameuid, $log['action_type'], intval($log['coin']), intval($log['money']), intval($log['experience']), intval($log['coupon']), intval($log['content']), $log['create_time']); } if (!empty($contents)) { // $logger = LogFactory::getLogger(array( // 'prefix' => "action_log", // 文件名的前缀 // 'log_dir' => APP_ROOT.'/log/', // 文件所在的目录 // 'archive' => ILogger::ARCHIVE_YEAR_MONTH, // 文件存档的方式 // 'log_level' => 1 // )); $this->logger_self->writeError($contents); } $logs = array(); $this->setToCache($key, $logs, $this->gameuid); } else { // 插入到数据库 $req = RequestFactory::createInsertRequest(get_app_config($this->gameuid)); // 不需要缓存数据 $req->setNoCache(true); $req->setKey("gameuid", $this->gameuid); $req->setTable($this->getTableName()); $req->setColumns("gameuid,action_type,coin,money,experience,create_time,content,coupon"); foreach ($logs as $log) { $req->addValues(array($this->gameuid, $log['action_type'], $log['coin'], $log['money'], $log['experience'], $log['create_time'], intval($log['content']), intval($log['coupon']))); } $affected_rows = $req->execute(); if ($affected_rows > 0) { // 将缓存清空 $logs = array(); $this->setToCache($key, $logs, $this->gameuid); } } }
/** * 从数据库删除一条数据 * @param $gameuid * @param $key_values array,名称做key,数值做value */ protected function deleteFromDb($gameuid, $key_values) { if (empty($key_values)) { return false; } $req = RequestFactory::createDeleteRequest(get_app_config($gameuid)); $req->setKey($this->getKeyName(), $gameuid); $req->setTable($this->getTableName()); foreach ($key_values as $key => $value) { $req->addKeyValue($key, $value); } $req->execute(); return true; }
public function setUp() { $this->factory = RequestFactory::getInstance(); }
function getByUserIdAndFolder($user_id, $folder, $limit = NULL, $page = NULL, $where = NULL, $order = NULL) { if ($user_id == '') { return FALSE; } $strict = TRUE; if ($order == NULL) { $strict = FALSE; $order = array('a.status_id' => '= 10 desc', 'a.created_date' => 'desc'); } //Folder is: INBOX, SENT $key = Option::getByValue($folder, $this->getOptions('folder')); if ($key !== FALSE) { $folder = $key; } $rf = new RequestFactory(); $uf = new UserFactory(); $udf = new UserDateFactory(); $pptsvf = new PayPeriodTimeSheetVerifyFactory(); $ph = array('user_id' => $user_id); $folder_sent_query = NULL; $folder_inbox_query = NULL; $folder_inbox_query_a = NULL; $folder_inbox_query_ab = NULL; $folder_inbox_query_b = NULL; $folder_inbox_query_c = NULL; if ($folder == 10) { $ph['id'] = $user_id; $ph['created_by1'] = $user_id; $ph['created_by2'] = $user_id; $ph['created_by3'] = $user_id; $ph['created_by4'] = $user_id; $folder_inbox_query = ' AND a.created_by != ?'; $folder_inbox_query_a = ' OR d.id = ?'; $folder_inbox_query_ab = ' OR e.user_id = ?'; //$folder_inbox_query_b = ' OR a.parent_id in ( select parent_id FROM '. $this->getTable() .' WHERE created_by = '. $user_id .' ) '; $folder_inbox_query_b = ' OR a.parent_id in ( select parent_id FROM ' . $this->getTable() . ' WHERE created_by = ? AND parent_id != 0 ) '; $folder_inbox_query_c = ' OR a.parent_id in ( select id FROM ' . $this->getTable() . ' WHERE created_by = ? AND parent_id = 0 ) '; } elseif ($folder == 20) { $ph['created_by4'] = $user_id; $folder_sent_query = ' OR a.created_by = ?'; } //Need to include all threads that user has posted to. $query = ' SELECT a.*, CASE WHEN a.object_type_id = 5 THEN d.id WHEN a.object_type_id = 50 THEN c.user_id WHEN a.object_type_id = 90 THEN e.user_id END as sent_to_user_id FROM ' . $this->getTable() . ' as a LEFT JOIN ' . $uf->getTable() . ' as d ON a.object_type_id = 5 AND a.object_id = d.id LEFT JOIN ' . $uf->getTable() . ' as f ON a.created_by = f.id LEFT JOIN ' . $rf->getTable() . ' as b ON a.object_type_id = 50 AND a.object_id = b.id LEFT JOIN ' . $udf->getTable() . ' as c ON b.user_date_id = c.id LEFT JOIN ' . $pptsvf->getTable() . ' as e ON a.object_type_id = 90 AND a.object_id = e.id WHERE a.object_type_id in (5,50,90) AND ( ( ( c.user_id = ? ' . $folder_sent_query . ' ' . $folder_inbox_query_a . ' ' . $folder_inbox_query_ab . ' ' . $folder_inbox_query_b . ' ' . $folder_inbox_query_c . ' ) ' . $folder_inbox_query . ' ) ) AND ( a.deleted = 0 AND f.deleted = 0 AND ( b.id IS NULL OR ( b.id IS NOT NULL AND b.deleted = 0 ) ) AND ( c.id IS NULL OR ( c.id IS NOT NULL AND c.deleted = 0 ) ) AND ( d.id IS NULL OR ( d.id IS NOT NULL AND d.deleted = 0 ) ) AND ( e.id IS NULL OR ( e.id IS NOT NULL AND e.deleted = 0 ) ) AND NOT ( b.id IS NULL AND c.id IS NULL AND d.id IS NULL AND e.id IS NULL ) ) '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict, array('sent_to_user_id')); //Debug::text('Query: '. $query , __FILE__, __LINE__, __METHOD__,9); if ($limit == NULL) { //Run query without limit $this->rs = $this->db->Execute($query, $ph); } else { $this->rs = $this->db->PageExecute($query, $limit, $page, $ph); } return $this; }
function getAPISearchByCompanyIdAndArrayCriteria($company_id, $filter_data, $limit = NULL, $page = NULL, $where = NULL, $order = NULL) { if ($company_id == '') { return FALSE; } if (!is_array($order)) { //Use Filter Data ordering if its set. if (isset($filter_data['sort_column']) and $filter_data['sort_order']) { $order = array(Misc::trimSortPrefix($filter_data['sort_column']) => $filter_data['sort_order']); } } $additional_order_fields = array(); $sort_column_aliases = array(); $order = $this->getColumnsFromAliases($order, $sort_column_aliases); if ($order == NULL) { $order = array('created_date' => 'desc'); $strict = FALSE; } else { //Always try to order by status first so INACTIVE employees go to the bottom. if (!isset($order['created_date'])) { $order = Misc::prependArray(array('created_date' => 'desc'), $order); } $strict = TRUE; } //Debug::Arr($order,'Order Data:', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($filter_data,'Filter Data:', __FILE__, __LINE__, __METHOD__,10); $uf = new UserFactory(); $rf = new RequestFactory(); $udf = new UserDateFactory(); $pptsvf = new PayPeriodTimeSheetVerifyListFactory(); if (getTTProductEdition() >= TT_PRODUCT_ENTERPRISE) { $uef = new UserExpenseFactory(); } $ph = array('company_id' => $company_id); $query = ' select a.*, CASE WHEN a.object_type_id = 90 THEN pptsvf.user_id ELSE ud.user_id END as user_id, y.first_name as created_by_first_name, y.middle_name as created_by_middle_name, y.last_name as created_by_last_name, z.first_name as updated_by_first_name, z.middle_name as updated_by_middle_name, z.last_name as updated_by_last_name from ' . $this->getTable() . ' as a LEFT JOIN ' . $rf->getTable() . ' as rf ON ( a.object_type_id in (1010,1020,1030,1040,1100) AND a.object_id = rf.id ) LEFT JOIN ' . $udf->getTable() . ' as ud ON ( rf.user_date_id = ud.id ) LEFT JOIN ' . $pptsvf->getTable() . ' as pptsvf ON ( a.object_type_id = 90 AND a.object_id = pptsvf.id ) '; if (getTTProductEdition() >= TT_PRODUCT_ENTERPRISE) { $query .= ' LEFT JOIN ' . $uef->getTable() . ' as uef ON ( a.object_type_id = 200 AND a.object_id = uef.id ) '; } $query .= ' LEFT JOIN ' . $uf->getTable() . ' as y ON ( a.created_by = y.id AND y.deleted = 0 ) LEFT JOIN ' . $uf->getTable() . ' as z ON ( a.updated_by = z.id AND z.deleted = 0 ) where y.company_id = ?'; $user_id_column = 'a.created_by'; if (isset($filter_data['object_type_id']) and in_array($filter_data['object_type_id'], array(1010, 1020, 1030, 1040, 1100))) { //Requests $user_id_column = 'ud.user_id'; } elseif (isset($filter_data['object_type_id']) and in_array($filter_data['object_type_id'], array(90))) { //TimeSheet $user_id_column = 'pptsvf.user_id'; } elseif (isset($filter_data['object_type_id']) and in_array($filter_data['object_type_id'], array(200))) { //Expense $user_id_column = 'uef.user_id'; } if (isset($filter_data['permission_children_ids']) and isset($filter_data['permission_children_ids'][0]) and !in_array(-1, (array) $filter_data['permission_children_ids'])) { $query .= ' AND ' . $user_id_column . ' in (' . $this->getListSQL($filter_data['permission_children_ids'], $ph) . ') '; } if (isset($filter_data['id']) and isset($filter_data['id'][0]) and !in_array(-1, (array) $filter_data['id'])) { $query .= ' AND a.id in (' . $this->getListSQL($filter_data['id'], $ph) . ') '; } if (isset($filter_data['exclude_id']) and isset($filter_data['exclude_id'][0]) and !in_array(-1, (array) $filter_data['exclude_id'])) { $query .= ' AND a.id not in (' . $this->getListSQL($filter_data['exclude_id'], $ph) . ') '; } if (isset($filter_data['object_type_id']) and isset($filter_data['object_type_id'][0]) and !in_array(-1, (array) $filter_data['object_type_id'])) { $query .= ' AND a.object_type_id in (' . $this->getListSQL($filter_data['object_type_id'], $ph) . ') '; } if (isset($filter_data['object_id']) and isset($filter_data['object_id'][0]) and !in_array(-1, (array) $filter_data['object_id'])) { $query .= ' AND a.object_id in (' . $this->getListSQL($filter_data['object_id'], $ph) . ') '; } $query .= isset($filter_data['created_by']) ? $this->getWhereClauseSQL(array('a.created_by', 'y.first_name', 'y.last_name'), $filter_data['created_by'], 'user_id_or_name', $ph) : NULL; $query .= isset($filter_data['updated_by']) ? $this->getWhereClauseSQL(array('a.updated_by', 'z.first_name', 'z.last_name'), $filter_data['updated_by'], 'user_id_or_name', $ph) : NULL; $query .= ' AND a.deleted = 0 '; $query .= $this->getWhereSQL($where); $query .= $this->getSortSQL($order, $strict, $additional_order_fields); $this->ExecuteSQL($query, $ph, $limit, $page); return $this; }
/** * Get request parameters * * @return array */ public function parameters() { $proxy = RequestFactory::proxy($this->request); return $proxy->parameters(); }
/** * Oauth request parameters * * @return boolean */ public function oauthParameters() { $proxy = RequestFactory::proxy($this->Controller); return $proxy->parameters(); }
/** * {@inheritdoc} */ public function run() { $request = RequestFactory::createServerFromGlobals(); $response = $this->getContainer()->get('kernel')->process($request); $this->getContainer()->get('server')->send($response); }
/** * 将uid从映射表中删除 * * @param string $uid 用户uid * @return bool 是否删除成功,成功返回true,否则返回false */ public function deleteMapping($uid) { $this->logger->writeInfo("tring to delete uid[{$uid}] from uid_gameuid_mapping."); $req = RequestFactory::createDeleteRequest(get_app_config()); $req->setTable($this->getTableName()); $req->addKeyValue("uid", $uid); $affected_rows = $req->execute(); if (intval($affected_rows) > 0) { return true; } return false; }
/** * Return mocked request object * * @param string $params * @param string $method * @param string $uri * @return Request Object */ public function request($params = array(), $method = 'GET', $uri = "http://photos.example.net/photos") { App::uses('RequestFactory', 'OauthLib.Lib'); return RequestFactory::proxy(new MockObject(array('parameters' => $params, 'method' => $method, 'uri' => $uri))); }
function createRequest($type, $user_id, $date_stamp) { $date_stamp = strtotime($date_stamp); //Make sure date_stamp is always an integer. $rf = new RequestFactory(); $rf->setUserDate($user_id, $date_stamp); switch ($type) { case 10: $rf->setType(30); //Vacation Request $rf->setStatus(30); $rf->setMessage('I would like to request 1 week vacation starting this friday.'); $rf->setCreatedBy($user_id); break; case 20: $rf->setType(40); //Schedule Request $rf->setStatus(30); $rf->setMessage('I would like to leave at 1pm this friday.'); $rf->setCreatedBy($user_id); break; case 30: $rf->setType(10); //Schedule Request $rf->setStatus(30); $rf->setMessage('Sorry, I forgot to punch out today. I left at 5:00PM'); $rf->setCreatedBy($user_id); break; } if ($rf->isValid()) { $insert_id = $rf->Save(); Debug::Text('Request ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10); return $insert_id; } Debug::Text('Failed Creating Request!', __FILE__, __LINE__, __METHOD__, 10); return FALSE; }
function getFlaggedExceptionsByUserIdAndPayPeriodStatus($user_id, $pay_period_status) { if ($user_id == '') { return FALSE; } if ($pay_period_status == '') { return FALSE; } $udf = new UserDateFactory(); $epf = new ExceptionPolicyFactory(); $ppf = new PayPeriodFactory(); $rf = new RequestFactory(); $ph = array('user_id' => $user_id, 'date_stamp1' => $this->db->BindDate(TTDate::getBeginDayEpoch(TTDate::getTime() - 32 * 86400)), 'date_stamp2' => $this->db->BindDate(TTDate::getBeginDayEpoch(TTDate::getTime())), 'status_id' => $pay_period_status); $query = ' select d.severity_id as severity_id, count(*) as total from ' . $this->getTable() . ' as a LEFT JOIN ' . $udf->getTable() . ' as b ON a.user_date_id = b.id LEFT JOIN ' . $epf->getTable() . ' as d ON a.exception_policy_id = d.id LEFT JOIN ' . $ppf->getTable() . ' as e ON b.pay_period_id = e.id where b.user_id = ? AND a.type_id = 50 AND ( b.date_stamp >= ? AND b.date_stamp <= ? ) AND e.status_id = ? AND NOT EXISTS ( select z.id from ' . $rf->getTable() . ' as z where z.user_date_id = a.user_date_id AND z.status_id = 30 ) AND ( a.deleted = 0 AND b.deleted = 0 AND e.deleted=0) GROUP BY d.severity_id ORDER BY d.severity_id desc '; $this->ExecuteSQL($query, $ph); return $this; }
* * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @copyright Copyright 2010, Cake Development Corporation (http://cakedc.com) * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ if (!class_exists('OauthHelper')) { App::uses('OauthHelper', 'OauthLib.Lib'); } if (!class_exists('RequestFactory')) { App::uses('RequestFactory', 'OauthLib.Lib'); } RequestFactory::register('OauthLibAppController', 'RequestProxyController'); RequestFactory::register('OauthAppController', 'RequestProxyController'); RequestFactory::register('AppController', 'RequestProxyController'); /** * Request proxy controller class. Provide access to request coming to the controller * * @package oauth_lib * @subpackage oauth_lib.libs.request_proxy */ class RequestProxyController extends RequestProxyBase { /** * Request Object * * @var Object $request */ public $request; /**
*/ public function __construct($data = array()) { foreach ($data as $k => $v) { $this->{$k} = $v; } $this->data = $data; } } /** * Request proxy mock class. Provide interface to extract info from MockObject * * @package oauth_lib * @subpackage oauth_lib.libs.request_proxy */ RequestFactory::register('MockObject', 'RequestProxyMock'); class RequestProxyMock extends RequestProxyBase { /** * Request Object * * @var Object $request */ public $request; /** * Configuaration options * * @var array $options */ public $options; /**
//Redirect } $smarty->assign('title', TTi18n::gettext($title = 'View Request')); // See index.php /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'id', 'request_id', 'request_queue_ids', 'selected_level'))); if (isset($request_queue_ids)) { $request_queue_ids = unserialize(base64_decode(urldecode($request_queue_ids))); Debug::Arr($request_queue_ids, ' Input Request Queue IDs ' . $action, __FILE__, __LINE__, __METHOD__, 10); } if (isset($data)) { $data['date_stamp'] = TTDate::parseDateTime($data['date_stamp']); } $rf = new RequestFactory(); $action = Misc::findSubmitButton(); switch ($action) { case 'pass': if (count($request_queue_ids) > 1) { //Remove the authorized/declined request from the stack. array_shift($request_queue_ids); Redirect::Page(URLBuilder::getURL(array('id' => $request_queue_ids[0], 'selected_level' => $selected_level, 'request_queue_ids' => base64_encode(serialize($request_queue_ids))), 'ViewRequest.php')); } else { Redirect::Page(URLBuilder::getURL(array('refresh' => TRUE), '../CloseWindow.php')); } case 'decline': case 'authorize': Debug::text(' Authorizing Request: Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10); if (!empty($request_id)) { Debug::text(' Authorizing Request ID: ' . $request_id, __FILE__, __LINE__, __METHOD__, 10);
require_once Environment::getBasePath() . 'includes/Interface.inc.php'; //Debug::setVerbosity(11); if (!$permission->Check('request', 'enabled') or !($permission->Check('request', 'edit') or $permission->Check('request', 'edit_own'))) { $permission->Redirect(FALSE); //Redirect } $smarty->assign('title', TTi18n::gettext($title = 'Edit Request')); // See index.php /* * Get FORM variables */ extract(FormVariables::GetVariables(array('action', 'id', 'data'))); if (isset($data)) { $data['date_stamp'] = TTDate::parseDateTime($data['date_stamp']); } $rf = new RequestFactory(); $action = Misc::findSubmitButton(); $action = strtolower($action); switch ($action) { case 'submit': //Debug::setVerbosity(11); Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10); $rf->StartTransaction(); $rf->setId($data['id']); $rf->setUserDate($data['user_id'], $data['date_stamp']); $rf->setType($data['type_id']); $rf->setStatus(30); if ($rf->isNew()) { Debug::Text('Object is NEW!', __FILE__, __LINE__, __METHOD__, 10); $rf->setMessage($data['message']); } else {
/** * testThatProxyPostRequestWorksWithMixedParamSources * * @return void */ public function testThatProxyPostRequestWorksWithMixedParamSources() { $request = $this->__HttpObject('/test?key=value', 'POST'); $request->setFormData(array('key2' => array('value2'))); $requestProxy = RequestFactory::proxy($request, array('uri' => 'http://example.com/test?key=value', 'parameters' => array('key3' => array('value3')))); $expected = array('key' => array('value'), 'key2' => array('value2'), 'key3' => array('value3')); $this->assertEqual($expected, $requestProxy->parametersForSignature()); $this->assertEqual('http://example.com/test', $requestProxy->normalizedUri()); $this->assertEqual('POST', $requestProxy->method()); }