コード例 #1
0
 public function video_logs_json($param = array())
 {
     $response = array();
     $fields = array('id' => '`video_log`.`id` as `id`', 'video_id' => '`video_log`.`video_id` as `video_id`', 'login' => '`administrators`.`login` as `login`', 'actiontime' => '`actiontime`', '`video`.`name`' => 'IF(ISNULL(`video`.`name`), `video_log`.`video_name`, `video`.`name`) as `video_name`', 'action' => '`action`');
     if ($this->isAjax) {
         if ($no_auth = $this->checkAuth()) {
             return $no_auth;
         }
     }
     $param = !empty($this->data) ? $this->data : array();
     $query_param = $this->prepareDataTableParams($param);
     if (!\Admin::isPageActionAllowed('myvideolog')) {
         $query_param['where']["moderator_id"] = $_SESSION['uid'];
     }
     if (!empty($this->data['video_id'])) {
         $query_param['where']['video_id'] = $this->data['video_id'];
     }
     $query_param['select'] = array_merge($query_param['select'], array_diff($fields, $query_param['select']));
     if (empty($query_param['order'])) {
         $query_param['order']['actiontime'] = 'desc';
     }
     $this->cleanQueryParams($query_param, array_keys($fields), $fields);
     $response['recordsTotal'] = $this->db->getTotalRowsVideoLog($query_param['where']);
     $response["recordsFiltered"] = $this->db->getTotalRowsVideoLog($query_param['where'], $query_param['like']);
     if (empty($query_param['limit']['limit'])) {
         $query_param['limit']['limit'] = 50;
     }
     $response['data'] = $this->db->getVideoLog($query_param);
     $response['data'] = array_map(function ($row) {
         $row['actiontime'] = (int) strtotime($row['actiontime']);
         return $row;
     }, $response['data']);
     $response['data'] = $this->setLocalization($response['data'], 'action');
     $this->setLinksForVideoLog($response['data']);
     $response["draw"] = !empty($this->data['draw']) ? $this->data['draw'] : 1;
     if ($this->isAjax) {
         $response = $this->generateAjaxResponse($response);
         return new Response(json_encode($response), empty($error) ? 200 : 500);
     } else {
         return $response;
     }
 }