Controller notification
unknown
php
a year ago
2.7 kB
7
Indexable
public function saveNotif() { $token = $this->input->post('token') ? $this->input->post("token") : null; if ($token) { $data['notification_title'] = isset($_POST['notification_title']) && filter_var($_POST['notification_title']) == true ? $this->input->post('notification_title') : null; $data['notification_content'] = preg_replace("/\r|\n/", "", str_replace(" ", ' ', $_POST['notification_content'])); $data['create_by'] = $this->session->userdata('username'); $data['notification_send_time'] = isset($_POST['notification_send_time']) && filter_var($_POST['notification_send_time']) == true ? $this->input->post('notification_send_time') : null; $data['notification_all'] = isset($_POST['notification_all']) && filter_var($_POST['notification_all']) == true ? $this->input->post('notification_all') : null; $data['module'] = isset($_POST['module']) && filter_var($_POST['module']) == true ? $this->input->post('module') : null; $data['id'] = isset($_POST['id']) && filter_var($_POST['id']) == true ? $this->input->post('id') : null; $user = explode(',', $this->input->post('recipient')); $player = []; foreach ($user as $us) { $player_id = getJsonManagement('getUser?type=1&search=' . $us); if ($player_id) { foreach ($player_id->data as $play) { $player[] = $play->player_id; } } } $data['player_id'] = $player; $data['recipient'] = $user; $result = postJsonManagement('sendNotif?type=1', $data); if (empty($result)) { $return['status'] = 'fail'; $return['note'] = 'Failed to push notification'; } else { if ($result->meta->code == 200) { if (empty($result->data)) { $return['status'] = 'fail'; $return['note'] = 'Failed to push notification'; } else { $return['status'] = 'success'; $return['note'] = $result->data->result->id; } } else { $return['status'] = 'fail'; $return['note'] = 'Something went wrong'; } } } else { $return['status'] = 'fail'; $return['note'] = 'Token is not provided'; } $response['payload'] = CryptoJsAes::Encrypt($return, CRYPTOCODE_AES); echo json_encode($response); }
Editor is loading...
Leave a Comment