private function flows() { $max = $this->input->get_post('max'); $offset = $this->input->get_post('offset'); if (empty($max)) { $max = $this->flows_per_page; } $this->template->add_js('assets/j/flows.js'); $data = $this->init_view_data(); $flows = VBX_Flow::search(array(), $max, $offset); if (empty($flows)) { set_banner('flows', $this->load->view('banners/flows-start', array(), true)); } $flows_with_numbers = array(); foreach ($flows as $flow) { $flows_with_numbers[] = array('id' => $flow->id, 'name' => trim($flow->name), 'numbers' => $flow->numbers, 'voice_data' => $flow->data, 'sms_data' => $flow->sms_data); } $data['items'] = $flows_with_numbers; $data['highlighted_flows'] = array($this->session->flashdata('flow-first-save', 0)); // pagination $total_items = VBX_Flow::count(); $page_config = array('base_url' => site_url('flows/'), 'total_rows' => $total_items, 'per_page' => $max); $this->pagination->initialize($page_config); $data['pagination'] = CI_Template::literal($this->pagination->create_links()); $this->respond('Call Flows', 'flows', $data); }
function index() { $this->admin_only($this->section); $this->template->add_js('assets/j/numbers.js'); $data = $this->init_view_data(); $numbers = array(); try { $numbers = $this->vbx_incoming_numbers->get_numbers(); } catch (VBX_IncomingNumberException $e) { $this->error_message = ErrorMessages::message('twilio_api', $e->getCode()); } $incoming_numbers = array(); // now generate table if (count($numbers) > 0) { $flows = VBX_Flow::search(); foreach ($numbers as $item) { $item_msg = ''; if (is_object($this->new_number) && $this->new_number->id == $item->id) { $item_msg = 'New'; } $flow_name = '(Not Set)'; foreach ($flows as $flow) { if ($flow->id == $item->flow_id) { $flow_name = ''; } } $incoming_numbers[] = array('id' => $item->id, 'name' => $item->name, 'trial' => isset($item->trial) && $item->trial == 1 ? 1 : 0, 'phone' => format_phone($item->phone), 'pin' => $item->pin, 'status' => $item_msg, 'flow_id' => $item->flow_id, 'flow_name' => $flow_name, 'flows' => $flows); } } $data['highlighted_numbers'] = array($this->session->flashdata('new-number')); $data['items'] = $incoming_numbers; $data['twilio_sid'] = $this->twilio_sid; if (empty($this->error_message)) { $error_message = $this->session->flashdata('error'); if (!empty($error_message)) { $this->error_message = $this->session->flashdata('error'); } } if (!empty($this->error_message)) { $data['error'] = CI_Template::literal($this->error_message); } $data['counts'] = $this->message_counts(); $this->respond('', 'numbers', $data); }
function __construct() { parent::__construct('public', 'default'); //$this->CI->load->model(); //$this->CI->lang->load('admin'); //$config=array('session_name','tmpl_site','copyright','sitename','_x','_y','_h','_spath','_sStart','_sItem','_sStop','_ipath','_ifiles','server','linkget','linksave','linksavetime','_bg'); //$this->config=$this->CI->config_model->get($config); $this->set_master_template(); //if($this->CI->router->class!='home' && $this->CI->router->class!='authorize'){ // $this->SetSession('current_controll',$this->CI->router->class); //} $lang = $this->GetSession('lang'); if (empty($lang)) { $lang = $this->CI->uri->getLang(); } $this->lang = $lang; $this->add_region('copyright'); $this->add_region('lang'); $this->write('copyright', $this->config['copyright'], true); $this->write('title_page', $this->config['sitename'], true); $this->write('lang', $lang, true); }
public function index() { $redirect = $this->input_redirect(); if ($this->session->userdata('loggedin')) { if (VBX_User::signature($this->user_id) == $this->session->userdata('signature')) { return $this->redirect($redirect); } } $this->template->write('title', 'Log In'); $data = array(); $data['redirect'] = $redirect; if ($this->input->post('login')) { $this->login($redirect); } // admin check sets flashdata error message if (!isset($data['error'])) { $error = $this->session->flashdata('error'); if (!empty($error)) { $data['error'] = CI_Template::literal($error); } } return $this->respond('', 'login', $data, 'login-wrapper', 'layout/login'); }
private function inbox($group = false) { $max = $this->input->get_post('max'); $offset = $this->input->get_post('offset'); $do_transcriptions = $this->vbx_settings->get('transcriptions', $this->tenant->id); if (!$max) { $max = self::PAGE_SIZE; } $this->template->add_css(asset_url('assets/c/messages.css'), 'link'); $data = $this->init_view_data(); $inbox_counts = $data['counts']; if ($group && !array_key_exists($group, $inbox_counts)) { redirect('messages/inbox'); return; } $this->template->add_js('messages/scripts' . ($group ? '/' . $group : '') . '?' . http_build_query(compact('max', 'offset')), 'dynamic'); $data['group'] = $group; $total_items = 0; $folders = array(); if (!$group) { $data['group_name'] = 'Inbox'; $groups = array_keys($inbox_counts); } else { $data['group_name'] = $inbox_counts[$group]->name; $groups = array($group); $folders[$group] = $inbox_counts[$group]; } $users = $group == 0 ? array($this->user_id) : array(); $message_options = array('group' => $groups, 'user' => $users); $messages = $this->vbx_message->get_messages($message_options, $offset, $max); $total_items = $messages['total']; $items = array(); $this->load->library('pagination'); $group_name = ''; $data['active_users'] = $this->vbx_user->get_active_users(); if ($messages['total'] < 1) { $group_name = $inbox_counts[$group]->name; } else { uasort($messages['messages'], 'sort_by_date'); foreach ($messages['messages'] as $item) { $group_name = ''; $group_id = 0; if ($item->owner_type == 'group' && isset($inbox_counts[$item->owner_id])) { $group_name = $inbox_counts[$item->owner_id]->name; $group_id = $item->owner_id; } if ($item->owner_type == 'user' && isset($inbox_counts[$item->owner_id])) { $group_name = 'Inbox'; $group_id = $item->owner_id; } $this->session->set_flashdata('selected-folder', $group_name); $this->session->set_flashdata('selected-folder-id', $group_id); $short_summary = null; if (is_null($item->content_text)) { $short_summary = ' '; if ($do_transcriptions) { $short_summary = "(no transcription)"; } } else { $short_summary = substr($item->content_text, 0, 125) . (strlen($item->content_text) > 125 ? '...' : ''); } $date_recorded = date('c', strtotime($item->created)); $date_updated = date('c', strtotime($item->updated)); $assigned_user = null; foreach ($data['active_users'] as $u) { if ($u->id == $item->assigned_to) { $assigned_user = clone $u; } } $items[] = array('id' => $item->id, 'folder' => $group_name, 'folder_id' => $group_id, 'short_summary' => $short_summary, 'assigned' => $item->assigned_to, 'type' => $item->type, 'assigned_user' => $assigned_user, 'ticket_status' => $item->ticket_status, 'archived' => $item->status == 'archived' ? true : false, 'unread' => $item->status == 'new' ? true : false, 'recording_url' => $item->content_url, 'recording_length' => format_player_time($item->size), 'received_time' => $date_recorded, 'last_updated' => $date_updated, 'called' => format_phone($item->called), 'caller' => format_phone($item->caller), 'original_called' => $item->called, 'original_caller' => $item->caller, 'owner_type' => $item->owner_type); } $group_name = 'Inbox'; } // set up pagination $group_id = $group === false ? 0 : $group; $page_config = array('base_url' => site_url('messages/inbox/' . $group_id), 'total_rows' => $total_items, 'per_page' => $max, 'uri_segment' => 4); $this->pagination->initialize($page_config); $data['items'] = $json['messages']['items'] = $items; // render to output array $data['pagination'] = CI_Template::literal($this->pagination->create_links()); $data['transcribe'] = $do_transcriptions; /* Return current group */ if ($group !== false && $group >= 0) { // $json = $messages; $json['id'] = $group; $json['name'] = $inbox_counts[$group]->name; $json['read'] = $inbox_counts[$group]->read; $json['new'] = $inbox_counts[$group]->new; $json['messages']['total'] = $total_items; $json['messages']['offset'] = $offset; $json['messages']['max'] = $max; } else { /* Return folder summary */ foreach ($inbox_counts as $folder_count) { $folders[] = $folder_count; } $json = array('max' => $max, 'offset' => $offset, 'total' => $total_items, 'folders' => $folders); } $data['json'] = $json; $this->respond(' - ' . $group_name, 'messages/inbox', $data); }
function index() { $this->admin_only($this->section); $this->template->add_js('assets/j/numbers.js'); $max = $this->input->get_post('max'); $offset = $this->input->get_post('offset'); if (empty($offset)) { $offset = 0; } if (empty($max)) { $max = $this->numbers_per_page; } $data = $this->init_view_data(); $data['selected_country'] = $this->vbx_settings->get('numbers_country', $this->tenant->id); $numbers = array(); $total_numbers = 0; $data['countries'] = array(); $data['openvbx_js']['countries'] = array(); try { $numbers = $this->vbx_incoming_numbers->get_numbers(); $countries = $this->vbx_incoming_numbers->get_available_countries(); // lighten the payload as we don't need the url data in the view foreach ($countries as &$country) { $data['countries'][$country->country_code] = $country->country; $country->available = array_keys(get_object_vars($country->subresource_uris)); unset($country->uri, $country->subresource_uris); } $data['openvbx_js']['countries'] = json_encode($countries); } catch (VBX_IncomingNumberException $e) { $this->error_message = $e->getMessage(); } $data['incoming_numbers'] = array(); $data['available_numbers'] = array(); $data['other_numbers'] = array(); $data['count_real_numbers'] = 0; // now generate table if (count($numbers) > 0) { $this->flows = $this->get_flows_list(); $data['flow_options'] = $this->get_flow_options($this->flows); foreach ($numbers as $item) { $item_msg = ''; if (is_object($this->new_number) && $this->new_number->id == $item->id) { $item_msg = 'New'; } $item->phone_formatted = format_phone($item->phone); $capabilities = array(); if (!empty($item->capabilities)) { foreach ($item->capabilities as $cap => $enabled) { if ($enabled) { array_push($capabilities, ucfirst($cap)); } } } $item->capabilities = $capabilities; $item->status = null; if ($item->installed) { // Number is installed in this instance of OpenVBX $item->trial = isset($item->trial) && $item->trial == 1 ? 1 : 0; $item->status = $item_msg; array_push($data['incoming_numbers'], $item); } elseif ((!empty($item->url) || !empty($item->smsUrl)) && $offset == 0) { // Number is in use elsewhere array_push($data['other_numbers'], $item); } elseif ($offset == 0) { // Number is open for use array_push($data['available_numbers'], $item); } if ($item->id !== 'Sandbox') { $data['count_real_numbers']++; } } } $data['highlighted_numbers'] = array($this->session->flashdata('new-number')); $data['twilio_sid'] = $this->twilio_sid; if (empty($this->error_message)) { $error_message = $this->session->flashdata('error'); if (!empty($error_message)) { $this->error_message = $this->session->flashdata('error'); } } if (!empty($this->error_message)) { $data['error'] = CI_Template::literal($this->error_message); } $data['counts'] = $this->message_counts(); /** * $numbers is a list of phone numbers straight from the Twilio API, * there's no fancy query logic here, just slicing up the array. */ $total_numbers = count($data['incoming_numbers']); $data['incoming_numbers'] = array_slice($data['incoming_numbers'], $offset, $max, true); // pagination $page_config = array('base_url' => site_url('numbers'), 'total_rows' => $total_numbers, 'per_page' => $max); $this->pagination->initialize($page_config); $data['pagination'] = CI_Template::literal($this->pagination->create_links()); $this->respond('', 'numbers/numbers', $data); }
function index() { $this->admin_only($this->section); $this->template->add_js('assets/j/numbers.js'); $data = $this->init_view_data(); $data['selected_country'] = $this->vbx_settings->get('numbers_country', $this->tenant->id); $numbers = array(); $data['countries'] = array(); $data['openvbx_js']['countries'] = array(); try { $numbers = $this->vbx_incoming_numbers->get_numbers(); $countries = $this->vbx_incoming_numbers->get_available_countries(); // lighten the payload as we don't need the url data in the view foreach ($countries as &$country) { $data['countries'][$country->country_code] = $country->country; $country->available = array_keys(get_object_vars($country->subresource_uris)); unset($country->uri, $country->subresource_uris, $country->client); } $data['openvbx_js']['countries'] = json_encode($countries); } catch (VBX_IncomingNumberException $e) { $this->error_message = $e->getMessage(); } $data['incoming_numbers'] = array(); $data['available_numbers'] = array(); $data['other_numbers'] = array(); $data['count_real_numbers'] = 0; // now generate table if (count($numbers) > 0) { $this->flows = $this->get_flows_list(); $data['flow_options'] = $this->get_flow_options($this->flows); foreach ($numbers as $item) { $item_msg = ''; if (is_object($this->new_number) && $this->new_number->id == $item->id) { $item_msg = 'New'; } $item->phone_formatted = format_phone($item->phone); if (!empty($item->pin)) { $item->pin = implode('-', str_split($item->pin, 4)); } $capabilities = array(); if (!empty($item->capabilities)) { foreach ($item->capabilities as $cap => $enabled) { if ($enabled) { array_push($capabilities, ucfirst($cap)); } } } $item->capabilities = $capabilities; $item->status = null; if ($item->installed) { // Number is installed in this instance of OpenVBX $item->trial = isset($item->trial) && $item->trial == 1 ? 1 : 0; $item->status = $item_msg; array_push($data['incoming_numbers'], $item); } elseif (!empty($item->url) || !empty($item->smsUrl)) { // Number is in use elsewhere array_push($data['other_numbers'], $item); } else { // Number is open for use array_push($data['available_numbers'], $item); } if ($item->id !== 'Sandbox') { $data['count_real_numbers']++; } } } $data['highlighted_numbers'] = array($this->session->flashdata('new-number')); $data['twilio_sid'] = $this->twilio_sid; if (empty($this->error_message)) { $error_message = $this->session->flashdata('error'); if (!empty($error_message)) { $this->error_message = $this->session->flashdata('error'); } } if (!empty($this->error_message)) { $data['error'] = CI_Template::literal($this->error_message); } $data['counts'] = $this->message_counts(); $this->respond('', 'numbers/numbers', $data); }
function index() { $this->admin_only($this->section); $this->template->add_js('assets/j/numbers.js'); $data = $this->init_view_data(); $data['selected_country'] = $this->vbx_settings->get('numbers_country', $this->tenant->id); $numbers = array(); $data['countries'] = array(); try { $numbers = $this->vbx_incoming_numbers->get_numbers(); $countries = $this->vbx_incoming_numbers->get_available_countries(); // lighten the payload as we don't need the url data in the view foreach ($countries as &$country) { $data['countries'][$country->country_code] = $country->country; $country->available = array_keys(get_object_vars($country->subresource_uris)); unset($country->uri, $country->subresource_uris); } $data['openvbx_js']['countries'] = json_encode($countries); } catch (VBX_IncomingNumberException $e) { $this->error_message = ErrorMessages::message('twilio_api', $e->getCode()); } $incoming_numbers = array(); // now generate table if (count($numbers) > 0) { $flows = VBX_Flow::search(); foreach ($numbers as $item) { $item_msg = ''; if (is_object($this->new_number) && $this->new_number->id == $item->id) { $item_msg = 'New'; } $flow_name = '(Not Set)'; foreach ($flows as $flow) { if ($flow->id == $item->flow_id) { $flow_name = ''; } } $capabilities = array(); if (!empty($item->capabilities)) { foreach ($item->capabilities as $cap => $enabled) { if ($enabled) { array_push($capabilities, ucfirst($cap)); } } } $incoming_numbers[] = array('id' => $item->id, 'name' => $item->name, 'trial' => isset($item->trial) && $item->trial == 1 ? 1 : 0, 'phone' => format_phone($item->phone), 'pin' => $item->pin, 'status' => $item_msg, 'flow_id' => $item->flow_id, 'flow_name' => $flow_name, 'flows' => $flows, 'capabilities' => $capabilities); } } $data['highlighted_numbers'] = array($this->session->flashdata('new-number')); $data['items'] = $incoming_numbers; $data['twilio_sid'] = $this->twilio_sid; if (empty($this->error_message)) { $error_message = $this->session->flashdata('error'); if (!empty($error_message)) { $this->error_message = $this->session->flashdata('error'); } } if (!empty($this->error_message)) { $data['error'] = CI_Template::literal($this->error_message); } $data['counts'] = $this->message_counts(); $this->respond('', 'numbers', $data); }