public function __construct($settings = array()) { $this->response = new TwimlResponse(); $this->cookie_name = 'state-' . AppletInstance::getInstanceId(); $this->version = AppletInstance::getValue('version', null); $this->callerId = AppletInstance::getValue('callerId', null); if (empty($this->callerId) && !empty($_REQUEST['From'])) { $this->callerId = $_REQUEST['From']; } /* Get current instance */ $this->dial_whom_selector = AppletInstance::getValue('dial-whom-selector'); $this->dial_whom_user_or_group = AppletInstance::getUserGroupPickerValue('dial-whom-user-or-group'); $this->dial_whom_number = AppletInstance::getValue('dial-whom-number'); $this->no_answer_action = AppletInstance::getValue('no-answer-action', 'hangup'); $this->no_answer_group_voicemail = AppletInstance::getAudioSpeechPickerValue('no-answer-group-voicemail'); $this->no_answer_redirect = AppletInstance::getDropZoneUrl('no-answer-redirect'); $this->no_answer_redirect_number = AppletInstance::getDropZoneUrl('no-answer-redirect-number'); $this->dial_whom_instance = get_class($this->dial_whom_user_or_group); if (count($settings)) { foreach ($settings as $setting => $value) { if (isset($this->{$setting})) { $this->{$setting} = $value; } } } }
public function __construct() { $this->response = new Response(); $this->cookie_name = 'state-' . AppletInstance::getInstanceId(); $this->version = AppletInstance::getValue('version', null); $this->callerId = AppletInstance::getValue('callerId', null); if (empty($this->callerId)) { $this->callerId = $_REQUEST['From']; } /* Get current instance */ $this->dial_whom_selector = AppletInstance::getValue('dial-whom-selector'); $this->dial_whom_user_or_group = AppletInstance::getUserGroupPickerValue('dial-whom-user-or-group'); $this->dial_whom_number = AppletInstance::getValue('dial-whom-number'); $this->no_answer_action = AppletInstance::getValue('no-answer-action', 'hangup'); $this->no_answer_group_voicemail = AppletInstance::getAudioSpeechPickerValue('no-answer-group-voicemail'); $this->no_answer_redirect = AppletInstance::getDropZoneUrl('no-answer-redirect'); $this->no_answer_redirect_number = AppletInstance::getDropZoneUrl('no-answer-redirect-number'); }
<?php include_once 'TwimlDial.php'; define('DIAL_COOKIE', 'state-' . AppletInstance::getInstanceId()); $CI =& get_instance(); $CI->load->library('DialList'); $dialer = new TwimlDial(); $dialer->set_state(); // Respond based on state switch ($dialer->state) { case 'hangup': $dialer->hangup(); break; case 'new': if ($dialer->dial_whom_selector === 'user-or-group') { // create a dial list from the input state $dial_list = DialList::get($dialer->dial_whom_user_or_group); $dialed = false; do { $to_dial = $dial_list->next(); if ($to_dial instanceof VBX_User || $to_dial instanceof VBX_Device) { $dialed = $dialer->dial($to_dial); if ($dialed) { $dialer->state = $dial_list->get_state(); } } } while (!$dialed && ($to_dial instanceof VBX_User || $to_dial instanceof VBX_Device)); if (!$dialed) { // nobody to call, push directly to voicemail $dialer->noanswer(); }
<?php $CI =& get_instance(); $status = @$_REQUEST['status']; $flow = @AppletInstance::getFlow(); $flow_id = $flow->id; $instance_id = AppletInstance::getInstanceId(); function zendesk_client($path, $method = 'GET', $xml = '') { // {{{ $ch = curl_init(); curl_setopt_array($ch, array(CURLOPT_URL => ZENDESK_URL . $path, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_HEADER => FALSE, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_USERPWD => ZENDESK_EMAIL . ':' . ZENDESK_PASSWORD, CURLOPT_RETURNTRANSFER => TRUE)); switch ($method) { case 'GET': curl_setopt($ch, CURLOPT_HTTPGET, TRUE); break; case 'POST': curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); break; case 'PUT': curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); break; case 'DELETE': curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); break; default: return FALSE;
<?php $ci =& get_instance(); $moderator = AppletInstance::getUserGroupPickerValue('moderator'); $confId = AppletInstance::getValue('conf-id'); $confName = AppletInstance::getInstanceId() . $confId; $caller = normalize_phone_to_E164(isset($_REQUEST['From']) ? $ci->input->get_post('From') : ''); $isModerator = false; $defaultWaitUrl = 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'; $waitUrl = AppletInstance::getValue('wait-url', $defaultWaitUrl); $record = AppletInstance::getValue('record', 'do-not-record'); $hasModerator = false; if (!is_null($moderator)) { $hasModerator = true; switch (get_class($moderator)) { case 'VBX_User': foreach ($moderator->devices as $device) { if ($device->value == $caller) { $isModerator = true; } } break; case 'VBX_Group': foreach ($moderator->users as $user) { $user = VBX_User::get($user->user_id); foreach ($user->devices as $device) { if ($device->value == $caller) { $isModerator = true; } } }
<?php $const = array(); $const['STRIPE_ACTION'] = 'stripeAction'; $const['STRIPE_COOKIE'] = 'payment-' . AppletInstance::getInstanceId(); $const['GATHER_CARD'] = 'GatherCard'; $const['GATHER_MONTH'] = 'GatherMonth'; $const['GATHER_YEAR'] = 'GatherYear'; $const['GATHER_CVC'] = 'GatherCvc'; $const['SEND_PAYMENT'] = 'SendPayment'; foreach ($const as $k => $v) { define($k, $v); } $response = new TwimlResponse(); $state = array(STRIPE_ACTION => GATHER_CARD, 'card' => array()); $ci =& get_instance(); $settings = PluginData::get('settings'); $amount = AppletInstance::getValue('amount'); $description = AppletInstance::getValue('description'); $digits = clean_digits($ci->input->get_post('Digits')); $finishOnKey = '#'; $timeout = 15; $card_errors = array('invalid_number' => GATHER_CARD, 'incorrect_number' => GATHER_CARD, 'invalid_expiry_month' => GATHER_MONTH, 'invalid_expiry_year' => GATHER_YEAR, 'expired_card' => GATHER_CARD, 'invalid_cvc' => GATHER_CVC, 'incorrect_cvc' => GATHER_CVC); if (is_object($settings)) { $settings = get_object_vars($settings); } if (isset($_COOKIE[STRIPE_COOKIE])) { $state = json_decode(str_replace(', $Version=0', '', $_COOKIE[STRIPE_COOKIE]), true); if (is_object($state)) { $state = get_object_vars($state); }
<?php define('PAYMENT_ACTION', 'paymentAction'); define('PAYMENT_COOKIE', 'payment-' . AppletInstance::getInstanceId()); define('STATE_GATHER_CARD', 'stateGatherCard'); define('STATE_GATHER_MONTH', 'stateGatherMonth'); define('STATE_GATHER_YEAR', 'stateGatherYear'); define('STATE_GATHER_CVC', 'stateGatherCvc'); define('STATE_SEND_PAYMENT', 'stateSendPayment'); $response = new TwimlResponse(); $state = array(PAYMENT_ACTION => STATE_GATHER_CARD, 'card' => array()); $ci =& get_instance(); $settings = PluginData::get('settings'); $amount = AppletInstance::getValue('amount'); $description = AppletInstance::getValue('description'); $digits = clean_digits($ci->input->get_post('Digits')); $finishOnKey = '#'; $timeout = 15; $card_errors = array('invalid_number' => STATE_GATHER_CARD, 'incorrect_number' => STATE_GATHER_CARD, 'invalid_expiry_month' => STATE_GATHER_MONTH, 'invalid_expiry_year' => STATE_GATHER_YEAR, 'expired_card' => STATE_GATHER_CARD, 'invalid_cvc' => STATE_GATHER_CVC, 'incorrect_cvc' => STATE_GATHER_CVC); if (is_object($settings)) { $settings = get_object_vars($settings); } if (isset($_COOKIE[PAYMENT_COOKIE])) { $state = json_decode(str_replace(', $Version=0', '', $_COOKIE[PAYMENT_COOKIE]), true); if (is_object($state)) { $state = get_object_vars($state); } } if ($digits !== false) { switch ($state[PAYMENT_ACTION]) { case STATE_GATHER_CARD: