Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * $Id: list.php 535 2017-05-08 12:29:53Z denis $
- */
- require_once __DIR__ . '/../../../../include/Service.php';
- header('Content-type: application/json');
- main();
- /******************************************************************************/
- function main()
- {
- $api = Service::API();
- $filter = array();
- if (isset($_REQUEST['ids']))
- {
- $filter['id'] = array(
- '$in' => array_map('intval', explode(',', $_REQUEST['ids']))
- );
- }
- if (strlen($_REQUEST['search']['value']))
- {
- $filter['name'] = array(
- '$regex' => $_REQUEST['search']['value'],
- '$options' => 'i'
- );
- }
- $sort = array(
- 'team_id' => -1
- );
- foreach ((array) $_REQUEST['order'] as $order)
- {
- $column = $_REQUEST['columns'][$order['column']]['data'];
- $dir = $order['dir'] == 'desc' ? -1 : 1;
- $sort[$column] = $dir;
- }
- if ($_REQUEST['type'] == 'public')
- {
- $method_count = 'public_count';
- $method_list = 'public_list';
- }
- else
- else
- {
- $method_count = 'count';
- $method_list = 'list';
- }
- $count = $api->network()->$method_count($filter);
- $data = $api->network()->$method_list($filter, array(
- 'sort' => $sort,
- 'skip' => intval($_REQUEST['start']),
- 'limit' => intval($_REQUEST['length'])
- ));
- $api->ok(array(
- 'draw' => $_REQUEST['draw'],
- 'data' => $data,
- 'total' => $count
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement