Esempio n. 1
0
 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;
             }
         }
     }
 }
Esempio n. 2
0
function verify_day($key, $today)
{
    $sunday = AppletInstance::getValue('sunday[]');
    $monday = AppletInstance::getValue('monday[]');
    $tuesday = AppletInstance::getValue('tuesday[]');
    $wednesday = AppletInstance::getValue('wednesday[]');
    $thursday = AppletInstance::getValue('thursday[]');
    $friday = AppletInstance::getValue('friday[]');
    $saturday = AppletInstance::getValue('saturday[]');
    $days = array(0 => is_array($sunday) && array_key_exists($key, $sunday) ? $sunday[$key] : $sunday, 1 => is_array($monday) && array_key_exists($key, $monday) ? $monday[$key] : $monday, 2 => is_array($tuesday) && array_key_exists($key, $tuesday) ? $tuesday[$key] : $tuesday, 3 => is_array($wednesday) && array_key_exists($key, $wednesday) ? $wednesday[$key] : $wednesday, 4 => is_array($thursday) && array_key_exists($key, $thursday) ? $thursday[$key] : $thursday, 5 => is_array($friday) && array_key_exists($key, $friday) ? $friday[$key] : $friday, 6 => is_array($saturday) && array_key_exists($key, $saturday) ? $saturday[$key] : $saturday);
    return $days[$today];
}
function day_check($day, $key)
{
    $value = AppletInstance::getValue($day);
    if (count($value) > 1) {
        if ($value[$key] == "true") {
            return "selected";
        }
    } elseif (count($value) == "true") {
        if ($value == 1) {
            return "selected";
        }
    } else {
        return "failed";
    }
}
Esempio n. 4
0
 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');
 }
Esempio n. 5
0
<?php

$user = OpenVBX::getCurrentUser();
$tenant_id = $user->values['tenant_id'];
$ci =& get_instance();
$queries = explode(';', file_get_contents(dirname(dirname(dirname(__FILE__))) . '/db.sql'));
foreach ($queries as $query) {
    if (trim($query)) {
        $ci->db->query($query);
    }
}
$polls = $ci->db->query(sprintf('SELECT id, name FROM polls WHERE tenant=%d', $tenant_id))->result();
$poll = AppletInstance::getValue('poll');
$poll = $poll ? $poll : count($polls) ? $polls[0]->id : null;
$options = json_decode($ci->db->query(sprintf('SELECT data FROM polls WHERE tenant=%d AND id=%d', $tenant_id, $poll))->row()->data);
$option = AppletInstance::getValue('option');
?>
<div class="vbx-applet vbx-polls">
<?php 
if (count($polls)) {
    ?>
	<div class="vbx-full-pane">
		<h3>Poll</h3>
		<fieldset class="vbx-input-container">
				<select class="medium" name="poll">
<?php 
    foreach ($polls as $p) {
        ?>
					<option value="<?php 
        echo $p->id;
        ?>
Esempio n. 6
0
<?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;
                    }
                }
            }
Esempio n. 7
0
if (!empty($orderid)) {
    $settings = PluginData::get('orders', array('keys' => array(), 'status' => array()));
    $statusArray = array('shipped' => 'Shipped', 'fullfillment' => 'Sent to Fullfillment', 'processing' => 'Processing');
    $s = '';
    $keys = $settings->keys;
    $status = $settings->status;
    foreach ($keys as $i => $key) {
        if ($key == $orderid) {
            $s = $statusArray[$status[$i]];
            break;
        }
    }
    if ($s != '') {
        $response->say("Your order is marked as {$s}.", $prefs);
        if (AppletInstance::getFlowType() == 'voice') {
            $next = AppletInstance::getDropZoneUrl('next');
            if (!empty($next)) {
                $response->redirect($next);
            }
        }
    } else {
        $response->say("We could not find your order.", $prefs);
    }
} elseif ($flow_type == 'voice') {
    $gather = $response->gather(array('numDigits' => 5));
    $gather->say(AppletInstance::getValue('prompt-text'), $prefs);
    $response->redirect();
} elseif ($flow_type != 'voice') {
    $response->say(AppletInstance::getValue('prompt-text'));
}
$response->respond();
Esempio n. 8
0
		</fieldset>
		<h3>Message</h3>
<?php 
    if (AppletInstance::getFlowType() == 'voice') {
        ?>
		<p>Use %caller% to substitute the caller's number or %number% for the number called.</p>
<?php 
    } else {
        ?>
		<p>Use %sender% to substitute the sender's number, %number% for the number texted or %body% for the message body.</p>
<?php 
    }
    ?>
		<fieldset class="vbx-input-container">
			<textarea name="sms" class="medium"><?php 
    echo AppletInstance::getValue('sms');
    ?>
</textarea>
		</fieldset>
	</div>
	<h2>Next</h2>
	<p>After sending the message, continue to the next applet</p>
	<div class="vbx-full-pane">
		<?php 
    echo AppletUI::DropZone('next');
    ?>
	</div>
<?php 
} else {
    ?>
	<div class="vbx-full-pane">
Esempio n. 9
0
    ?>
</em></p>

	<div class="vbx-full-pane">
<?php 
    foreach ($days as $index => $day) {
        ?>
		<div class="timing-timerange-wrap">
			<label><?php 
        print $day;
        ?>
</label>
<?php 
        $state = AppletInstance::getValue("range_{$index}_from", '') ? 'remove' : 'add';
        $default = $index < 5 ? '09:00AM' : '';
        echo AppletUI::timeRange("range_{$index}", AppletInstance::getValue("range_{$index}_from", $default), AppletInstance::getValue("range_{$index}_to", '05:00PM'), $day);
        ?>
			<a href="#" class="timing-<?php 
        echo $state;
        ?>
"><?php 
        echo $state;
        ?>
</a>
			<br class="clear"/>
		</div>
<?php 
    }
    ?>
	</div>
Esempio n. 10
0
<?php

$defaultNumberOfChoices = 4;
$venues = AppletInstance::getValue('venues[]', array('1', '2', '3', '4'));
if (count($venues) == 0) {
    $venues = array('1', '2', '3', '4');
}
$venue_options = AppletInstance::getValue('venue-options[]');
?>

<div class="vbx-applet 4sq-venue-applet">

		<h2>FourSquare Options</h2>
		<p>To get the Venue ID for your favorite checkins, log in to foursquare.com, click on History
			and then click on the venue.  You should see the URL your browser is pointed at looks like 
			http://foursquare.com/venue/100281 and that 100281 is the Venue ID to use</p>

		<p>Click <a href="http://foursquare.com/history" target="_new">Here </a>to see your History</p>
		<h3>User Selection</h3>
		<p>Choose which VBX user to use for controlling this Applet with their 4sq checkins</p>
		<?php 
echo AppletUI::UserGroupPicker('4sq-venue-controller');
?>
		

		<table class="vbx-menu-grid options-table">
			<thead>
				<tr>
					<td>Venue ID</td>
					<td>&nbsp;</td>
					<td>Applet</td>
Esempio n. 11
0

<div class="vbx-applet openvbx-zendesk-applet">
    <h2>This applet creates a ticket in ZenDesk for calls</h2>
    <p>Enter in the URL subdomain you use for Desk</p>
    <textarea class="small" name="subdomain"><?php 
echo AppletInstance::getValue('subdomain');
?>
</textarea>
    <p>Enter in the ZenDesk API Token</p>
    <textarea class="small" name="apitoken"><?php 
echo AppletInstance::getValue('apitoken');
?>
</textarea>
   <p>Enter in the email address</p>
    <textarea class="small" name="email"><?php 
echo AppletInstance::getValue('email');
?>
</textarea>

 <br />
    <h2> Select An Action for The Caller</h2>
    <?php 
echo AppletUI::DropZone('primary');
?>
</div>

Esempio n. 12
0
<?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);
$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;
                    }
                }
            }
            break;
Esempio n. 13
0
<?php

$defaultNumberOfChoices = 2;
$keys = (array) AppletInstance::getValue('keys[]', array('1' => '', '2' => ''));
$responses = (array) AppletInstance::getValue('responses[]');
?>

<div class="vbx-applet regex-applet">

		<h2>RegEx Options</h2>
		<table class="vbx-menu-grid options-table">
			<thead>
				<tr>
					<td>RegEx</td>
					<td>&nbsp;</td>
					<td>Applet</td>
					<td>Add &amp; Remove</td>
				</tr>
			</thead>
			<tfoot>
				<tr class="hide">
					<td>
						<fieldset class="vbx-input-container">
							<input class="keypress small" type="text" name="new-keys[]" value="" autocomplete="off" />
						</fieldset>
					</td>
					<td>then</td>
					<td>
						<?php 
echo AppletUI::dropZone('new-responses[]', 'Drop applet here');
?>
Esempio n. 14
0
					<td>
						<a href="" class="add action"><span class="replace">Add</span></a> <a href="" class="remove action"><span class="replace">Remove</span></a>
					</td>
				</tr>
				<?php 
}
?>
			</tbody>
		</table><!-- .vbx-menu-grid -->

		<h3>Do you want to repeat the menu back?</h3>
		<div class="vbx-full-pane">
			<p>Repeat the menu back to the caller.  Enter zero if you do not want the menu to repeat.</p>
			<fieldset class="vbx-input-complex vbx-input-container">
				<input type="text" name="repeat-count" class="left tiny" value="<?php 
echo AppletInstance::getValue('repeat-count', 3);
?>
" />
				<label class="field-label-left">time(s)</label>
			</fieldset>
		</div>

		<h3>When the caller didn't enter anything after the menu...</h3>
		<div class="vbx-full-pane">
			<fieldset class="vbx-input-complex vbx-input-container">
				<p>Redirect the caller to another applet.</p>
				<?php 
echo AppletUI::DropZone('next');
?>
			</fieldset>
		</div><!-- .vbx-split-pane -->
<?php

$user = OpenVBX::getCurrentUser();
$tenant_id = $user->values['tenant_id'];
$ci =& get_instance();
$selected = AppletInstance::getValue('list');
$action = AppletInstance::getValue('action');
$queries = explode(';', file_get_contents(dirname(dirname(dirname(__FILE__))) . '/db.sql'));
foreach ($queries as $query) {
    if (trim($query)) {
        $ci->db->query($query);
    }
}
$lists = $ci->db->query(sprintf('SELECT id, name FROM subscribers_lists WHERE tenant = %d', $tenant_id))->result();
?>
<div class="vbx-applet">
<?php 
if (count($lists)) {
    ?>
	<div class="vbx-full-pane">
		<h3>Subscription</h3>
		<fieldset class="vbx-input-container">
				<select class="medium" name="list">
<?php 
    foreach ($lists as $list) {
        ?>
					<option value="<?php 
        echo $list->id;
        ?>
"<?php 
        echo $list->id == $selected ? ' selected="selected" ' : '';
Esempio n. 16
0
<?php

$ci =& get_instance();
$number = AppletInstance::getValue('number');
$recipient = normalize_phone_to_E164(AppletInstance::getValue('recipient'));
$message = AppletInstance::getValue('sms');
if (!empty($_REQUEST['From'])) {
    $from = normalize_phone_to_E164($_REQUEST['From']);
    $to = normalize_phone_to_E164($_REQUEST['To']);
    if (AppletInstance::getFlowType() == 'voice') {
        $message = str_replace(array('%caller%', '%number%'), array($from, $to), $message);
    } else {
        $message = str_replace(array('%sender%', '%number%', '%body%'), array($from, $to, $_REQUEST['Body']), $message);
    }
    require_once APPPATH . 'libraries/Services/Twilio.php';
    $service = new Services_Twilio($ci->twilio_sid, $ci->twilio_token);
    $service->account->sms_messages->create($number, $recipient, $message);
}
$response = new TwimlResponse();
$next = AppletInstance::getDropZoneUrl('next');
if (!empty($next)) {
    $response->redirect($next);
}
$response->respond();
Esempio n. 17
0
<?php

$defaultNumberOfChoices = 4;
$keys = AppletInstance::getValue('keys[]', array('1' => '', '2' => '', '3' => '', '4' => ''));
$responses = AppletInstance::getValue('responses[]');
?>

<div class="vbx-applet query-applet">

		<h2>Menu Prompt</h2>
		<fieldset class="vbx-input-container">
			<p>When the texter reaches this menu, they will read:</p>
			<textarea class="medium" name="prompt" placeholder="Tell the users your options"><?php 
echo AppletInstance::getValue('prompt');
?>
</textarea>
		</fieldset>

		<h2>Menu Options</h2>
		<table class="vbx-menu-grid options-table">
			<thead>
				<tr>
					<td>Keyword</td>
					<td>&nbsp;</td>
					<td>Reply</td>
					<td>Add &amp; Remove</td>
				</tr>
			</thead>
			<tfoot>
				<tr class="hide">
					<td>
Esempio n. 18
0
<?php 
if (!empty($settings) && !empty($settings['api_key'])) {
    ?>
	<div class="vbx-full-pane">
		<h3>Amount</h3>
		<p>A positive integer in cents representing much to charge the card.</p>
		<fieldset class="vbx-input-container">
			<input type="text" name="amount" class="medium" value="<?php 
    echo AppletInstance::getValue('amount', 50);
    ?>
" />
		</fieldset>
		<h3>Description</h3>
		<fieldset class="vbx-input-container">
			<input type="text" name="description" class="medium" value="<?php 
    echo AppletInstance::getValue('description');
    ?>
" />
		</fieldset>
	</div>
	<h2>After the payment</h2>
	<div class="vbx-full-pane">
		<?php 
    echo AppletUI::DropZone('success');
    ?>
	</div>
	<h2>If the payment fails</h2>
	<div class="vbx-full-pane">
		<?php 
    echo AppletUI::DropZone('fail');
    ?>
Esempio n. 19
0
<div class="vbx-applet">
	<h2>Add Call to queue</h2>
	<p>Put this call into the hold queue uniquely identified by the string below</p>
	
	<input name="queue_name" value="<?php 
echo AppletInstance::getValue("queue_name");
?>
"/>
</div>
Esempio n. 20
0
<?php

$ci =& get_instance();
$ci->load->helper('format');
$flow_type = AppletInstance::getFlowType();
$next = AppletInstance::getDropZoneUrl('next');
$from = normalize_phone_to_E164($_POST['From']);
$blacklist = explode("\n", trim(AppletInstance::getValue('blacklist')));
foreach ($blacklist as $key => $value) {
    $blacklist[$key] = normalize_phone_to_E164($value);
}
$response = new TwimlResponse();
if (in_array($from, $blacklist)) {
    //reject calls
    if ($flow_type == 'voice') {
        $response->reject();
    } else {
        //empty response for sms
    }
} else {
    $response->redirect($next);
}
$response->respond();
<?php

$ci =& get_instance();
$dispatcher = AppletInstance::getUserGroupPickerValue('dispatcher');
$list = AppletInstance::getValue('list');
$dispatch = false;
if (!empty($_REQUEST['From'])) {
    $sender = normalize_phone_to_E164($_REQUEST['From']);
    $number = normalize_phone_to_E164($_REQUEST['To']);
    $body = $_REQUEST['Body'];
    if (is_null($dispatcher)) {
        $dispatch = true;
    } else {
        switch (get_class($dispatcher)) {
            case 'VBX_User':
                foreach ($dispatcher->devices as $device) {
                    if ($sender == $device->value) {
                        $dispatch = true;
                    }
                }
                break;
            case 'VBX_Group':
                foreach ($dispatcher->users as $user) {
                    $user = VBX_User::get($user->user_id);
                    foreach ($user->devices as $device) {
                        if ($sender == $device->value) {
                            $dispatch = true;
                        }
                    }
                }
        }
Esempio n. 22
0
<?php

$response = new Response();
/* Fetch all the data to operate the menu */
$digits = isset($_REQUEST['Digits']) ? $_REQUEST['Digits'] : false;
$prompt = AppletInstance::getAudioSpeechPickerValue('prompt');
$invalid_option = AppletInstance::getAudioSpeechPickerValue('invalid-option');
$repeat_count = AppletInstance::getValue('repeat-count', 3);
$next = AppletInstance::getDropZoneUrl('next');
$selected_item = false;
/* Build Menu Items */
$choices = (array) AppletInstance::getDropZoneUrl('choices[]');
$keys = (array) AppletInstance::getDropZoneValue('keys[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $choices);
$numDigits = 1;
foreach ($keys as $key) {
    if (strlen($key) > $numDigits) {
        $numDigits = strlen($key);
    }
}
if ($digits !== false) {
    if (!empty($menu_items[$digits])) {
        $selected_item = $menu_items[$digits];
    } else {
        if ($invalid_option) {
            $verb = AudioSpeechPickerWidget::getVerbForValue($invalid_option, null);
            $response->append($verb);
            $response->addRedirect();
        } else {
            $response->addSay('You selected an incorrect option.');
            $response->addRedirect();
Esempio n. 23
0
<div class="vbx-applet">

		<h2>Build your own TwiML</h2>
		<p><a href="http://www.twilio.com/docs/api/2010-04-01/twiml/" target="_blank">Learn more about TwiML</a></p>
		<fieldset class="vbx-input-container">
			<textarea name="twiml" class="large" placeholder="&lt;Say&gt;:)&lt;/Say&gt;"><?php 
echo AppletInstance::getValue('twiml');
?>
</textarea>
		</fieldset>


		<h2 class="settings-title">Next</h2>
		<p>After the message is sent, continue to the next applet</p>
		<div class="vbx-full-pane">
			<?php 
echo AppletUI::DropZone('next');
?>
		</div>

</div><!-- .vbx-applet -->
Esempio n. 24
0
<?php

$response = new TwimlResponse();
$now = date_create('now');
$today = date_format($now, 'N') - 1;
/**
 * The names of the applet instance variables for "from" and "to" times
 * are of the form: "range_n_from" and "range_n_to" where "n"
 * is a value between 0 and 6 (inclusive). 0 represents Monday
 * and 6 represents Sunday. In PHP, the value of date_format($now, 'w')
 * for Sunday is 0 - for Monday the value is 1 - and so on.
 * Here, we need to compensate for this by checking to see if the value
 * of date_format($now, 'w') - 1 is -1, and, if so, bring Sunday
 * back into the valid range of values by setting $today to 6.
 */
if ($today == -1) {
    $today = 6;
}
$response->redirect(AppletInstance::getDropZoneUrl(($from = AppletInstance::getValue("range_{$today}_from")) && ($to = AppletInstance::getValue("range_{$today}_to")) && date_create($from) <= $now && $now < date_create($to) ? 'open' : 'closed'));
$response->respond();
Esempio n. 25
0
/* States */
define('DIAL_STATE_DIAL', 'dialStateDial');
define('DIAL_STATE_NO_ANSWER', 'dialStateNoAnswer');
define('DIAL_STATE_RECORDING', 'dialStateRecording');
define('DIAL_STATE_HANGUP', 'dialStateHangup');
$response = new Response();
// Default State
$state = array();
$state[DIAL_ACTION] = DIAL_STATE_DIAL;
$state[DIAL_NUMBER_INDEX] = 0;
$version = AppletInstance::getValue('version', null);
/* Get current instance	 */
$dial_whom_selector = AppletInstance::getValue('dial-whom-selector');
$dial_whom_user_or_group = AppletInstance::getUserGroupPickerValue('dial-whom-user-or-group');
$dial_whom_number = AppletInstance::getValue('dial-whom-number');
$no_answer_action = AppletInstance::getValue('no-answer-action', 'hangup');
$no_answer_group_voicemail = AppletInstance::getAudioSpeechPickerValue('no-answer-group-voicemail');
$no_answer_redirect = AppletInstance::getDropZoneUrl('no-answer-redirect');
$no_answer_redirect_number = AppletInstance::getDropZoneUrl('no-answer-redirect-number');
$numbers = array();
$voicemail = null;
if ($dial_whom_selector === 'user-or-group') {
    $dial_whom_instance = null;
    if (is_object($dial_whom_user_or_group)) {
        $dial_whom_instance = get_class($dial_whom_user_or_group);
    }
    switch ($dial_whom_instance) {
        case 'VBX_User':
            foreach ($dial_whom_user_or_group->devices as $device) {
                if ($device->is_active == 1) {
                    $numbers[] = $device->value;
Esempio n. 26
0
<?php

$ci =& get_instance();
/* Get the body of the SMS message */
$body = isset($_REQUEST['Body']) ? trim($ci->input->get_post('Body')) : null;
$body = strtolower($body);
$prompt = AppletInstance::getValue('prompt');
$keys = AppletInstance::getValue('keys[]');
$responses = AppletInstance::getValue('responses[]');
$menu_items = AppletInstance::assocKeyValueCombine($keys, $responses, 'strtolower');
$response = new TwimlResponse();
/* Display the menu item if we found a match - case insensitive */
if (array_key_exists($body, $menu_items) && !empty($menu_items[$body])) {
    $response_text = $menu_items[$body];
} else {
    /* Display the prompt if incorrect */
    $response_text = $prompt;
}
$response->sms($response_text);
$response->Respond();
<?php

$user = OpenVBX::getCurrentUser();
$tenant_id = $user->values['tenant_id'];
$ci =& get_instance();
$selected = AppletInstance::getValue('list');
$queries = explode(';', file_get_contents(dirname(dirname(dirname(__FILE__))) . '/db.sql'));
foreach ($queries as $query) {
    if (trim($query)) {
        $ci->db->query($query);
    }
}
$lists = $ci->db->query(sprintf('SELECT id, name FROM subscribers_lists WHERE tenant=%d', $tenant_id))->result();
?>
<div class="vbx-applet">
<?php 
if (count($lists)) {
    ?>
	<div class="vbx-full-pane">
		<h3>List</h3>
		<fieldset class="vbx-input-container">
				<select class="medium" name="list">
<?php 
    foreach ($lists as $list) {
        ?>
					<option value="<?php 
        echo $list->id;
        ?>
"<?php 
        echo $list->id == $selected ? ' selected="selected" ' : '';
        ?>
Esempio n. 28
0
<?php

$flow_type = AppletInstance::getFlowType();
$vp = AppletInstance::getValue('prompt-text');
?>
<div class="vbx-applet monkey-applet">
    <h2>Order Tracking</h2>
    <p>Enter  a custom message that your callers will be greeted by.</p>
    <textarea class="medium" name="prompt-text"><?php 
echo !empty($vp) ? AppletInstance::getValue('prompt-text') : 'Please enter your order id';
?>
</textarea>
<?php 
if ($flow_type == 'voice') {
    ?>
	<br/>
	<h2>Next</h2>
	<p>After retrieving the order id, continue to the next applet</p>
	<div class="vbx-full-pane">
		<?php 
    echo AppletUI::DropZone('next');
    ?>
	</div>
<?php 
}
?>
</div>
Esempio n. 29
0
<?php

header("Content-type: text/xml\n");
error_reporting(E_NONE);
include "chirbit.php";
$user = AppletInstance::getUserGroupPickerValue('chirbit-controller');
$user_id = $user->values["id"];
$chirbit_username = PluginStore::get("chirbit_username_{$user_id}", "");
$chirbit_password = PluginStore::get("chirbit_password_{$user_id}", "");
$prompt = AppletInstance::getAudioSpeechPickerValue('prompt');
$after = AppletInstance::getAudioSpeechPickerValue('after');
$title = AppletInstance::getValue("title", "");
$response = new Response();
if (isset($_REQUEST['RecordingUrl'])) {
    chirbit_post($chirbit_username, $chirbit_password, $_REQUEST['RecordingUrl'], $title);
    $verb = AudioSpeechPickerWidget::getVerbForValue($after, null);
    $response->append($verb);
    $response->addHangup();
} else {
    $verb = AudioSpeechPickerWidget::getVerbForValue($prompt, null);
    $response->append($verb);
    $response->addRecord();
}
$response->Respond();
Esempio n. 30
0
<?php

$ci =& get_instance();
$number = AppletInstance::getValue('number');
$id = AppletInstance::getValue('flow');
if (!empty($_REQUEST['From'])) {
    $recipient = normalize_phone_to_E164(str_replace('%sender%', $_REQUEST['From'], AppletInstance::getValue('recipient')));
    require_once APPPATH . 'libraries/Services/Twilio.php';
    $service = new Services_Twilio($ci->twilio_sid, $ci->twilio_token);
    if (($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $ci->tenant->id))) && $flow[0]->values['data']) {
        $service->account->calls->create($number, $recipient, site_url('twiml/start/voice/' . $id));
    }
}
$response = new TwimlResponse();
$next = AppletInstance::getDropZoneUrl('next');
if (!empty($next)) {
    $response->redirect($next);
}
$response->respond();