Exemple #1
0
 /**
  * Get list of messages
  */
 public static function getPage($page = 0)
 {
     $app = \Slim\Slim::getInstance();
     $app->expires(time());
     $userDAO = new UserDAO();
     $groupDAO = new GroupDAO();
     $groupsQuery = array();
     if (!$userDAO->hasRole('ADMIN')) {
         $strong = \Strong\Strong::getInstance();
         $user = $strong->getUser();
         $groupsQuery['user_id'] = $user['id'];
     }
     $groups = $groupDAO->getList($groupsQuery);
     if (0 == $groups['total']) {
         return $app->redirect(MAINURL . '/groups');
     }
     $chatDAO = new ChatDAO();
     $query = $_GET;
     $query['from'] = preg_replace('![^0-9]*!', '', $query['search']);
     if (!$userDAO->hasRole('ADMIN')) {
         $strong = \Strong\Strong::getInstance();
         $user = $strong->getUser();
         $query['user_id'] = $user['id'];
     }
     $pager = new Pager(MAINURL . '/inbox/', 25);
     $pager->setPage($page);
     $query = $pager->getQueryArray($query);
     $list = $chatDAO->getList($query);
     $pager->setCount(count($list['list']));
     if (isset($list['total'])) {
         $pager->setTotal($list['total']);
     }
     $app->view->set('menu', 'inbox');
     $app->view->set('query', $query);
     $app->view->set('result', $list);
     $app->view->set('pager', $pager);
     $app->render('inbox/list.twig.html');
 }
Exemple #2
0
 public static function getInboxPage($page = 0)
 {
     $app = \Slim\Slim::getInstance();
     $limit = 25;
     if ($_GET['format'] == 'csv') {
         $page = 0;
         $limit = 10000;
     }
     $userDAO = new UserDAO();
     $chatDAO = new ChatDAO();
     $formUtils = new FormUtils();
     $startTime = $formUtils->toTimestamp($_GET['start_date'] . ' 00:00');
     $endTime = $formUtils->toTimestamp($_GET['end_date'] . ' 23:59');
     if ($endTime <= 0) {
         $endTime = time();
     }
     if ($startTime <= 0) {
         $startTime = $endTime - 7 * 24 * 3600;
     }
     $app->view->set('start_date', $startTime);
     $app->view->set('end_date', $endTime);
     $query = $_GET;
     $query['start_date'] = $startTime;
     $query['end_date'] = $endTime;
     if (!$userDAO->hasRole('ADMIN')) {
         $strong = \Strong\Strong::getInstance();
         $user = $strong->getUser();
         $query['user_id'] = $user['id'];
     }
     $pager = new Pager(MAINURL . '/reports/inbox/?' . http_build_query($_GET), $limit);
     $pager->setPage($page);
     $query = $pager->getQueryArray($query);
     $list = $chatDAO->getList($query);
     $pager->setCount(count($list['list']));
     if (isset($list['total'])) {
         $pager->setTotal($list['total']);
     }
     $reportTable = array();
     foreach ($list['list'] as $message) {
         $reportTable[] = $message;
     }
     $app->view->set('menu', 'reports');
     $app->view->set('reportTable', array_values($reportTable));
     $app->view->set('query', $query);
     $app->view->set('pager', $pager);
     if ($_GET['format'] == 'csv') {
         header("Content-type: text/csv");
         header("Content-disposition: attachment; filename=inbox.csv");
         $app->render('reports/inbox.twig.csv');
     } else {
         $app->render('reports/inbox.twig.html');
     }
 }