Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * $Id: list.php 535 2017-05-08 12:29:53Z denis $
  5. */
  6.  
  7. require_once __DIR__ . '/../../../../include/Service.php';
  8.  
  9. header('Content-type: application/json');
  10. main();
  11.  
  12. /******************************************************************************/
  13. function main()
  14. {
  15. $api = Service::API();
  16.  
  17. $filter = array();
  18.  
  19. if (isset($_REQUEST['ids']))
  20. {
  21. $filter['id'] = array(
  22. '$in' => array_map('intval', explode(',', $_REQUEST['ids']))
  23. );
  24. }
  25.  
  26. if (strlen($_REQUEST['search']['value']))
  27. {
  28. $filter['name'] = array(
  29. '$regex' => $_REQUEST['search']['value'],
  30. '$options' => 'i'
  31. );
  32. }
  33.  
  34. $sort = array(
  35. 'team_id' => -1
  36. );
  37.  
  38. foreach ((array) $_REQUEST['order'] as $order)
  39. {
  40. $column = $_REQUEST['columns'][$order['column']]['data'];
  41. $dir = $order['dir'] == 'desc' ? -1 : 1;
  42. $sort[$column] = $dir;
  43. }
  44.  
  45. if ($_REQUEST['type'] == 'public')
  46. {
  47. $method_count = 'public_count';
  48. $method_list = 'public_list';
  49. }
  50. else
  51. else
  52. {
  53. $method_count = 'count';
  54. $method_list = 'list';
  55. }
  56.  
  57. $count = $api->network()->$method_count($filter);
  58. $data = $api->network()->$method_list($filter, array(
  59. 'sort' => $sort,
  60. 'skip' => intval($_REQUEST['start']),
  61. 'limit' => intval($_REQUEST['length'])
  62. ));
  63.  
  64. $api->ok(array(
  65. 'draw' => $_REQUEST['draw'],
  66. 'data' => $data,
  67. 'total' => $count
  68. ));
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement