public function testSortableWithRequestParameters()
 {
     $usersTable = $this->user->getTable();
     Input::replace(['sort' => 'name', 'order' => 'asc']);
     $resultArray = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $expected = ['column' => $usersTable . '.name', 'direction' => 'asc'];
     $this->assertEquals($expected, head($resultArray));
     Input::replace(['sort' => 'name', 'order' => 'desc']);
     $resultArray = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $expected = ['column' => $usersTable . '.name', 'direction' => 'desc'];
     $this->assertEquals($expected, head($resultArray));
     Input::replace(['sort' => 'name', 'order' => '']);
     $result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $this->assertNull($result);
     Input::replace(['sort' => '', 'order' => 'asc']);
     $result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $this->assertNull($result);
     Input::replace(['sort' => '', 'order' => '']);
     $result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $this->assertNull($result);
     Input::replace(['sort' => 'name']);
     $result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $this->assertNull($result);
     Input::replace(['sort' => '']);
     $result = $this->user->scopeSortable($this->user->newQuery())->getQuery()->orders;
     $this->assertNull($result);
 }
示例#2
0
 /**
  * Ensures the correct URL value is saved to the model
  */
 protected function modifyPost()
 {
     $new_post_data = post();
     if (post('Menu')['is_external'] == "1") {
         $new_post_data['Menu']['url'] = $new_post_data['Menu']['external_url'];
     } else {
         $new_post_data['Menu']['url'] = $new_post_data['Menu']['internal_url'];
     }
     unset($new_post_data['Menu']['internal_url']);
     unset($new_post_data['Menu']['external_url']);
     Input::replace($new_post_data);
 }
示例#3
0
文件: Api.php 项目: vespakoen/epi
 protected function fastRequest($uri, $method, $input = array())
 {
     $uri = $this->config['prefix'] . $uri;
     $method = strtoupper($method);
     if ($this->config['local']) {
         $oldInput = Input::all();
         Input::replace($input);
         $request = Request::create($uri, $method, array());
         $response = Route::dispatch($request);
         $content = $response->getContent();
         $code = $response->getStatusCode();
         $results = json_decode($content);
         Input::replace($oldInput);
     } else {
         if ($method === 'GET') {
             $uri .= '?' . urldecode(http_build_query($input));
         }
         $client = new Client($this->config['domain']);
         $request = $client->createRequest($method, $uri, array(), $method === 'GET' ? array() : $input)->addHeader('Content-Type', 'application/json');
         try {
             $response = $request->send();
         } catch (ClientErrorResponseException $e) {
             $response = $e->getResponse();
         }
         $code = $response->getStatusCode();
         $results = $response->json();
     }
     if (!Str::startsWith((string) $code, "2")) {
         throw new ApiException($results, $code);
     }
     return $results;
 }
 public function testComplex()
 {
     $engine = new CollectionEngine(new Collection($this->getRealArray()));
     $this->addRealColumns($engine);
     $engine->searchColumns('foo', 'bar');
     $engine->setAliasMapping();
     Input::replace(array('sSearch' => 't'));
     $test = json_decode($engine->make()->getContent());
     $test = $test->aaData;
     $this->assertTrue($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
     $this->assertTrue($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
     //Test2
     $engine = new CollectionEngine(new Collection($this->getRealArray()));
     $this->addRealColumns($engine);
     $engine->searchColumns('foo', 'bar');
     $engine->setAliasMapping();
     Input::replace(array('sSearch' => 'plasch'));
     $test = json_decode($engine->make()->getContent());
     $test = $test->aaData;
     $this->assertTrue($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
     $this->assertFalse($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
     //test3
     $engine = new CollectionEngine(new Collection($this->getRealArray()));
     $this->addRealColumns($engine);
     $engine->searchColumns('foo', 'bar');
     $engine->setAliasMapping();
     Input::replace(array('sSearch' => 'tay'));
     $test = json_decode($engine->make()->getContent());
     $test = $test->aaData;
     $this->assertFalse($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
     $this->assertTrue($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
     //test4
     $engine = new CollectionEngine(new Collection($this->getRealArray()));
     $this->addRealColumns($engine);
     $engine->searchColumns('foo', 'bar');
     $engine->setAliasMapping();
     Input::replace(array('sSearch' => 'O'));
     $test = json_decode($engine->make()->getContent());
     $test = $test->aaData;
     $this->assertFalse($this->arrayHasKeyValue('foo', 'Nils', (array) $test));
     $this->assertTrue($this->arrayHasKeyValue('foo', 'Taylor', (array) $test));
 }
示例#5
0
 /**
  * 
  * @return mixed
  */
 protected function one()
 {
     $this->id = Input::get('id');
     $fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null;
     if ($this->action == "add") {
         // @todo test
         $user = $this->validateAndCreate($fill);
     } else {
         $user = \Veer\Models\User::find($this->id);
     }
     if (!is_object($user)) {
         return event('veer.message.center', trans('veeradmin.error.model.not.found'));
     }
     if (!empty($fill)) {
         $user->fill($fill);
     }
     $user->save();
     $this->id = $user->id;
     $this->user = $user;
     $this->goThroughEverything();
     if ($this->action == "add") {
         app('veer')->skipShow = true;
         Input::replace(['id' => $this->id]);
         return \Redirect::route('admin.show', ['users', 'id' => $this->id]);
     }
 }
示例#6
0
            }
        }
    }
    if ($impure) {
        // report banned input
        //
        $userUid = Session::get('user_uid');
        syslog(LOG_WARNING, "User {$userUid} attempted to send unsanitary input containing HTML tags or script: " . json_encode($bannedInput));
        Input::replace($input);
        // return error
        //
        return Response::make("Can not send unsanitary input containing HTML tags or script.", 400);
    } else {
        // return sanitized input
        //
        Input::replace($input);
    }
});
App::after(function ($request, $response) {
    $response->headers->set('Access-Control-Allow-Origin', Config::get('app.cors_url'));
    $response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
    $response->headers->set('Access-Control-Allow-Headers', '*,x-requested-with,Content-Type,If-Modified-Since,If-None-Match,Auth-User-Token');
    $response->headers->set('Access-Control-Allow-Credentials', 'true');
    $response->headers->remove('Cache-Control');
    return $response;
});
/**
 * Validation of enabled users.
 */
Route::filter('user_enabled_check', function ($route, $request) {
    $user_uid = Session::get('user_uid');
示例#7
0
 public static function prepareRequest()
 {
     $className = \Request::segment(3);
     if (isset($className)) {
         $object = self::makeModelObject($className);
         $inputs = Input::all();
         $inputs = self::prepareRequestBasicFields($inputs, $object);
         $inputs = self::prepareRequestDateFields($inputs);
         $inputs = self::prepareRequestBytesFields($inputs);
         $inputs = self::prepareRequestRelations($inputs, $object);
         Input::replace($inputs);
     }
 }
示例#8
0
 protected function one()
 {
     $this->id = Input::get('id');
     $this->action = Input::get('action');
     $this->order = \Veer\Models\Order::find($this->id);
     if (!is_object($this->order)) {
         $this->order = new \Veer\Models\Order();
     }
     $fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null;
     if ($this->action == "delete") {
         $this->delete();
         app('veer')->skipShow = true;
         return \Redirect::route('admin.show', ['orders']);
     }
     if ($this->order->status_id != $fill['status_id']) {
         $addStatusToHistory = true;
     }
     if ($this->order->userbook_id != $fill['userbook_id']) {
         $this->userbookToOrder($fill['userbook_id'], false);
     }
     $this->order->fill($fill);
     if ($this->action == "add") {
         $result = $this->addOrder($fill, Input::get('userbook.0', []), Input::get('attachContent'), ['_skipObjectCreate' => true, '_skipPrepare' => true, '_allowSkipContent' => false]);
         if ($result === false) {
             return false;
         }
         $addStatusToHistory = true;
         $this->id = $this->order->id;
     }
     $this->goThroughEverything();
     $this->order->save();
     $this->id = $this->order->id;
     if (isset($addStatusToHistory)) {
         $this->status(['status_id' => $this->order->status_id]);
     }
     if ($this->action == "add" && $this->order->userdiscount_id > 0 && !empty($this->discount)) {
         app('veershop')->changeUserDiscountStatus($this->discount);
     }
     if (Input::has('sendMessageToUser')) {
         (new \Veer\Commands\CommunicationSendCommand(Input::get('communication')))->handle();
         event('veer.message.center', trans('veeradmin.user.page.sendmessage'));
     }
     if ($this->action == "add") {
         $this->sendEmail();
         app('veer')->skipShow = true;
         Input::replace(['id' => $this->order->id]);
         return \Redirect::route('admin.show', ['orders', 'id' => $this->order->id]);
     }
 }
示例#9
0
 /**
  * @return mixed
  */
 protected function one()
 {
     $this->id = Input::get('category');
     $category = \Veer\Models\Category::find($this->id);
     if (!is_object($category)) {
         event('veer.message.center', trans('veeradmin.error.model.not.found'));
         return \Redirect::route('admin.show', ['categories']);
     }
     $this->entity = $category;
     $this->goThroughEverything();
     if ($this->action == 'deleteCurrent') {
         Input::replace(['category' => null]);
         app('veer')->skipShow = true;
         event('veer.message.center', trans('veeradmin.category.delete'));
         return \Redirect::route('admin.show', ['categories']);
     }
 }
示例#10
0
 /**
  * @helper Model create|find
  * @return mixed
  */
 protected function one()
 {
     $this->id = Input::get('id');
     $fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null;
     if ($this->action == 'add' || $this->action == 'saveAs') {
         if ($this->type == 'page') {
             $fill['hidden'] = true;
         } elseif ($this->type == 'product') {
             $fill['status'] = 'hide';
         }
         $entity = $this->create($fill);
     } else {
         $className = $this->className;
         $entity = $className::find($this->id);
     }
     if (!is_object($entity)) {
         event('veer.message.center', trans('veeradmin.error.model.not.found'));
         return \Redirect::route('admin.show', [str_plural($this->type)]);
     }
     $this->id = $entity->id;
     $this->entity = $entity;
     $this->goThroughEverything($fill);
     if ($this->action == 'add' || $this->action == 'saveAs') {
         app('veer')->skipShow = true;
         Input::replace(['id' => $this->id]);
         return \Redirect::route('admin.show', [str_plural($this->type), 'id' => $this->id]);
     }
 }
示例#11
0
 protected function addSlugToInput()
 {
     $data = Input::all();
     $data['slug'] = Str::slug(Input::get('name'));
     Input::replace($data);
 }