コード例 #1
0
ファイル: numbers.php プロジェクト: JeffaCubed/OpenVBX
 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);
 }
コード例 #2
0
ファイル: flows.php プロジェクト: joshgomez/OpenVBX
 private function save($flow_id)
 {
     $error = false;
     $message = '';
     $flow = new VBX_Flow();
     if ($flow_id > 0) {
         $flow = VBX_Flow::get($flow_id);
         if (empty($flow)) {
             $error = true;
             $message = 'Flow does not exist.';
         }
     }
     $flow->name = trim($this->input->post('name'));
     $voice_data = $this->input->post('data');
     $sms_data = $this->input->post('sms_data');
     if (!empty($voice_data)) {
         $flow->data = $voice_data;
     }
     if (!empty($sms_data)) {
         $flow->sms_data = $sms_data;
     }
     try {
         $flow->save();
         $this->session->set_flashdata('flow-first-save', $flow->id);
     } catch (VBX_FlowException $e) {
         $error = true;
         $message = 'Failed to save flow.';
     }
     $flow_url = site_url('flows/edit/' . $flow->id);
     if ($this->response_type != 'json') {
         return redirect($flow_url);
     }
     $data['json'] = array('error' => $error, 'message' => $message, 'flow_id' => $flow->id, 'flow_url' => $flow_url);
     $this->respond('Call Flows', 'flows', $data);
 }
コード例 #3
0
ファイル: twiml.php プロジェクト: ryanlarrabure/OpenVBX
 private function get_flow($flow_id = 0)
 {
     if ($flow_id < 1) {
         $flow_id = $this->flow_id;
     }
     if (is_null($this->flow)) {
         $this->flow = VBX_Flow::get(array('id' => $flow_id, 'numbers' => false));
     }
     if ($flow_id > 0) {
         if (!empty($this->flow)) {
             if ($this->flow_type == 'sms') {
                 // make flow data visible to all applets
                 Applet::$flow_data = $this->flow->sms_data;
             } else {
                 // make flow data visible to all applets
                 Applet::$flow_data = $this->flow->data;
             }
         }
     }
     return $this->flow;
 }
コード例 #4
0
ファイル: OpenVBX.php プロジェクト: AsaadQ/OpenVBX
 public static function getFlows($options = array(), $limit = -1, $offset = 0)
 {
     return VBX_Flow::search($options, $limit, $offset);
 }
コード例 #5
0
ファイル: numbers.php プロジェクト: wiserweb/OpenVBX
 /**
  * Key an ID keyed list of flows
  *
  * @return array
  */
 protected function get_flows_list()
 {
     $flows = array();
     $_flows = VBX_Flow::search();
     if (count($_flows)) {
         foreach ($_flows as $flow) {
             $flows[$flow->id] = $flow;
         }
     }
     unset($_flows);
     return $flows;
 }
コード例 #6
0
ファイル: twiml.php プロジェクト: howethomas/OpenVBX
 private function get_flow($flow_id = 0)
 {
     if ($flow_id < 1) {
         $flow_id = $this->flow_id;
     }
     if (is_null($this->flow)) {
         $this->flow = VBX_Flow::get($flow_id);
     }
     if ($flow_id > 0) {
         if (!empty($flow)) {
             if ($this->flow_type == 'sms') {
                 Applet::$flow_data = $flow->sms_data;
                 // make flow data visible to all applets
             } else {
                 Applet::$flow_data = $flow->data;
                 // make flow data visible to all applets
             }
         }
     }
     return $this->flow;
 }
コード例 #7
0
ファイル: numbers.php プロジェクト: ryanlarrabure/OpenVBX
 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);
 }