当前位置: 首页>>代码示例>>PHP>>正文


PHP normalize_phone_to_E164函数代码示例

本文整理汇总了PHP中normalize_phone_to_E164函数的典型用法代码示例。如果您正苦于以下问题:PHP normalize_phone_to_E164函数的具体用法?PHP normalize_phone_to_E164怎么用?PHP normalize_phone_to_E164使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了normalize_phone_to_E164函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init_browserphone_data

 protected function init_browserphone_data($callerid_numbers)
 {
     // defaults
     $browserphone = array('call_using' => 'browser', 'caller_id' => '(000) 000-0000', 'number_options' => array(), 'call_using_options' => array('browser' => array('title' => 'Your Computer', 'data' => array())), 'devices' => array());
     $default_caller_id = false;
     if (is_array($callerid_numbers) && !empty($callerid_numbers)) {
         $numbered = $named = array();
         $default_caller_id = current($callerid_numbers)->phone;
         foreach ($callerid_numbers as $number) {
             if (normalize_phone_to_E164($number->phone) != normalize_phone_to_E164($number->name)) {
                 $named[$number->phone] = $number->name;
             } else {
                 $numbered[$number->phone] = $number->phone;
             }
         }
         ksort($numbered);
         asort($named);
         $browserphone['number_options'] = $named + $numbered;
     }
     $user = VBX_User::get(array('id' => $this->session->userdata('user_id')));
     // User preferences
     $browserphone['caller_id'] = $user->setting('browserphone_caller_id', $default_caller_id);
     $browserphone['call_using'] = $user->setting('browserphone_call_using', 'browser');
     // Wether the user has an active device to use
     if (count($user->devices)) {
         foreach ($user->devices as $device) {
             if (strpos($device->value, 'client:') !== false) {
                 continue;
             }
             $browserphone['call_using_options']['device:' . $device->id] = array('title' => 'Device: ' . $device->name, 'data' => (object) array('number' => format_phone($device->value), 'name' => $device->name));
         }
     }
     return $browserphone;
 }
开发者ID:wiserweb,项目名称:OpenVBX,代码行数:34,代码来源:iframe.php

示例2: client

 /**
  * Display the popup for making calls with Twilio Client
  *
  * @return void
  */
 public function client()
 {
     $caller_id = $this->input->get('callerid');
     if (empty($caller_id)) {
         // grab user's default device
         $user = VBX_User::get($this->session->userdata['user_id']);
         $devices = $this->vbx_device->get_by_user($this->user_id);
         if (!empty($devices)) {
             $caller_id = $devices[0]->value;
         }
     }
     $client_params = array('callerid' => normalize_phone_to_E164($caller_id), 'application_id' => 'client');
     if ($this->input->get('outgoing')) {
         // functionality for using the "dial" modal to initiate a call
         $to = normalize_phone_to_E164($this->input->get('to'));
         if (empty($to)) {
             $to = htmlspecialchars($this->input->get('to'));
         }
         $client_params = array_merge($client_params, array('to' => $to));
     } elseif ($this->input->get('incoming')) {
         $client_params = array_merge($client_params, array('incoming' => true));
     }
     $client_data = array('client_params' => json_encode($client_params));
     $javascript = $this->load->view('client_js', $client_data, true);
     $this->template->add_js($javascript, 'embed', true);
     $data = array('title' => 'dialer', 'client_params' => $client_params);
     $this->respond('Dialer', 'call', $data, '', 'layout/dialer');
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:33,代码来源:message_call.php

示例3: limit_exceeded

function limit_exceeded($duration, $enabled, $instance_id, $limit)
{
    if (!$enabled) {
        return false;
    }
    //throttling disabled
    $number = normalize_phone_to_E164($_REQUEST['From']);
    $data = PluginData::get($instance_id . "__" . $number);
    $duration = intval($duration) * 60;
    //convert it into seconds
    if (!$data) {
        PluginData::set($instance_id . "__" . $number, array('limit' => 1, 'added' => time()));
        return false;
    }
    //clean expired time
    if (!empty($data->added) && time() - $data->added > $duration) {
        PluginData::set($instance_id . "__" . $number, array('limit' => 0, 'added' => time()));
        $data = PluginData::get($instance_id . "__" . $number);
    }
    if ($data->limit >= $limit && time() - $data->added <= $duration) {
        PluginData::set($instance_id . "__" . $number, array('limit' => $data->limit + 1, 'added' => $data->added));
        return true;
    } else {
        PluginData::set($instance_id . "__" . $number, array('limit' => $data->limit + 1, 'added' => $data->added));
        return false;
    }
}
开发者ID:mymizan,项目名称:OpenVBX-Plugin-Throttle,代码行数:27,代码来源:functions.php

示例4: render

 public function render($data = array())
 {
     $hasValue = empty($this->mode) ? false : true;
     $this->load =& load_class('Loader');
     $this->load->model('vbx_audio_file');
     $this->load->model('vbx_device');
     // Get a list of all previously recorded items so we can populate the library
     $ci =& get_instance();
     $ci->db->where('url IS NOT NULL');
     $ci->db->where('tag', $this->tag);
     $ci->db->where('tenant_id', $ci->tenant->id);
     $ci->db->from('audio_files');
     $ci->db->order_by('created DESC');
     $results = $ci->db->get()->result();
     foreach ($results as $i => $result) {
         $results[$i] = new VBX_Audio_File($result);
     }
     // Pre-fill the record text field with the the first device phone number we
     // find for the current user that is active.
     $ci =& get_instance();
     $user = VBX_User::get($ci->session->userdata('user_id'));
     $user_phone = '';
     if (count($user->devices)) {
         foreach ($user->devices as $device) {
             if ($device->is_active) {
                 $user_phone = format_phone($device->value);
                 break;
             }
         }
     }
     // set the caller id for recording via the phone
     $caller_id = '';
     $ci->load->model('vbx_incoming_numbers');
     try {
         $numbers = $ci->vbx_incoming_numbers->get_numbers(false);
         foreach ($numbers as $number) {
             // find the first number that has voice enabled
             // yes, this is a rather paranoid check
             if (isset($number->capabilities->voice) && $number->capabilities->voice > 0) {
                 $caller_id = normalize_phone_to_E164($number->phone);
                 break;
             }
         }
     } catch (VBX_IncomingNumberException $e) {
         // fail silently, for better or worse
         error_log($e->getMessage());
     }
     $data = array_merge(array('name' => $this->name, 'hasValue' => $hasValue, 'mode' => $this->mode, 'say' => $this->say_value, 'play' => $this->play_value, 'tag' => $this->tag, 'library' => $results, 'first_device_phone_number' => $user_phone, 'caller_id' => $caller_id), $data);
     return parent::render($data);
 }
开发者ID:ryanlarrabure,项目名称:OpenVBX,代码行数:50,代码来源:AudioSpeechPickerWidget.php

示例5: foreach

						</div>
				</td>
			</tr>
		</table>
	</div>

	<br />
	<h2>Caller ID</h2>
	<div class="vbx-full-pane">
		<fieldset class="vbx-input-container">
			<select class="medium" name="callerId">
				<option value="">Caller's Number</option>
<?php 
if (count($numbers)) {
    foreach ($numbers as $number) {
        $number->phone = normalize_phone_to_E164($number->phone);
        ?>
				<option value="<?php 
        echo $number->phone;
        ?>
"<?php 
        echo $number->phone == $callerId ? ' selected="selected" ' : '';
        ?>
><?php 
        echo $number->name;
        ?>
</option>
<?php 
    }
}
?>
开发者ID:JeffaCubed,项目名称:OpenVBX,代码行数:31,代码来源:ui.php

示例6: notify_message

 function notify_message($message)
 {
     $ci =& get_instance();
     $ci->load->model('vbx_user');
     $ci->load->model('vbx_group');
     $ci->load->model('vbx_incoming_numbers');
     $recording_host = $ci->settings->get('recording_host', VBX_PARENT_TENANT);
     $vm_url = $message->content_url;
     if (!empty($recording_host) && trim($recording_host) != '') {
         $vm_url = str_replace('api.twilio.com', trim($recording_host), $vm_url);
     }
     $message->content_url = $vm_url;
     $users = array();
     $notify = array();
     if ($message->owner_type == 'user') {
         $user = VBX_User::get($message->owner_id);
         if (!empty($user->email)) {
             $notify[] = $user->email;
         }
     }
     $group_users = array();
     if ($message->owner_type == 'group') {
         $user_ids = $ci->vbx_group->get_user_ids($message->owner_id);
         $group = $ci->vbx_group->get_by_id($message->owner_id);
         $owner = $group->name;
     } else {
         if ($message->owner_type == 'user') {
             $user_ids = array($message->owner_id);
             $owner = 'Personal';
         }
     }
     $notification_setting = 'email_notifications_' . $message->type;
     $email_notify = $ci->vbx_settings->get($notification_setting, $ci->tenant->id);
     // check the incoming number's capabilities and don't even try to send
     // an SMS notification if the number is not allowed to send SMS messages
     $incoming_number = VBX_Incoming_numbers::get(array('phone_number' => normalize_phone_to_E164($message->called)));
     if (!empty($incoming_number) && $incoming_number->capabilities->sms == 1) {
         $sms_notify = true;
     }
     if ($email_notify || $sms_notify) {
         foreach ($user_ids as $user_id) {
             $user = VBX_User::get($user_id);
             $ci->load->model('vbx_device');
             $ci->load->model('vbx_sms_message');
             $numbers = VBX_Device::search(array('user_id' => $user_id));
             $message_type = 'Voicemail';
             if ($message->type == 'sms') {
                 $message_type = 'SMS';
                 $owner = '';
             }
             if ($email_notify) {
                 $email_subject = "New {$owner} {$message_type} Notification - {$message->caller}";
                 openvbx_mail($user->email, $email_subject, 'message', compact('message'));
             }
             if ($sms_notify) {
                 foreach ($numbers as $number) {
                     if ($number->value && $number->sms) {
                         try {
                             $ci->vbx_sms_message->send_message($message->called, $number->value, $this->tiny_notification_message($message));
                         } catch (VBX_Sms_messageException $e) {
                             log_message('error', 'unable to send sms alert, reason: ' . $e->getMessage());
                         }
                     }
                 }
             }
             // if ($sms_notify)
         }
     }
     // if ($email_notify || $sms_notify)
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:70,代码来源:vbx_message.php

示例7: get_instance

<?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;
                    }
                }
            }
开发者ID:wiserweb,项目名称:OpenVBX,代码行数:31,代码来源:twiml.php

示例8: get_instance

<?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;
                        }
                    }
                }
        }
开发者ID:rodrigotanco,项目名称:OpenVBX-Plugin-Subscriptions,代码行数:31,代码来源:twiml.php

示例9: get_instance

<?php

$ci =& get_instance();
$poll = AppletInstance::getValue('poll');
$option = AppletInstance::getValue('option');
$number = 'voice' == AppletInstance::getFlowType() ? normalize_phone_to_E164($_REQUEST['Caller']) : normalize_phone_to_E164($_REQUEST['From']);
$ci->db->delete('polls_responses', array('poll' => $poll, 'value' => $number));
$ci->db->insert('polls_responses', array('poll' => $poll, 'value' => $number, 'response' => $option, 'time' => time()));
$response = new Response();
$next = AppletInstance::getDropZoneUrl('next');
if (!empty($next)) {
    $response->addRedirect($next);
}
$response->Respond();
开发者ID:jsoncorwin,项目名称:OpenVBX-Plugin-Polls,代码行数:14,代码来源:twiml.php

示例10: get_instance

<?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();
开发者ID:afreeth,项目名称:OpenVBX-Plugin-Outbound,代码行数:19,代码来源:twiml.php

示例11: get_by_number

 public function get_by_number($number, $user_id)
 {
     $number = normalize_phone_to_E164($number);
     $search_opts = array('user_id' => intval($user_id), 'value' => normalize_phone_to_E164($number));
     $device = parent::search(self::$__CLASS__, $this->table, $search_opts, array(), 1);
     return $device;
 }
开发者ID:hharrysidhu,项目名称:OpenVBX,代码行数:7,代码来源:vbx_device.php

示例12: add_number

 private function add_number()
 {
     $number = array();
     $number = $this->input->post('number');
     $number['value'] = normalize_phone_to_E164($number['value']);
     $number['user_id'] = $this->user_id;
     // sms is always enabled by default
     $number['sms'] = 1;
     try {
         if (empty($number['value']) || empty($number['name'])) {
             $message = 'All fields required';
             throw new VBX_DeviceException($message);
         }
         $number_id = $this->vbx_device->add($number);
         $response = array('error' => false, 'message' => '', 'id' => $number_id, 'name' => htmlspecialchars($number['name']), 'value' => format_phone($number['value']), 'sms' => $number['sms']);
     } catch (VBX_DeviceException $e) {
         $response = array('error' => true, 'message' => $e->getMessage());
     }
     $data['json'] = $response;
     if ($this->response_type == 'html') {
         redirect('account');
     }
     return $this->respond('', 'account', $data);
 }
开发者ID:rhyselsmore,项目名称:OpenVBX,代码行数:24,代码来源:devices.php

示例13: get_instance

<?php

$user = OpenVBX::getCurrentUser();
$tenant_id = $user->values['tenant_id'];
$ci =& get_instance();
if (!empty($_POST['recipient'])) {
    $account = OpenVBX::getAccount();
    $id = intval($_POST['flow']);
    if (($flow = OpenVBX::getFlows(array('id' => $id, 'tenant_id' => $tenant_id))) && $flow[0]->values['data']) {
        $account->calls->create($_POST['number'], normalize_phone_to_E164($_POST['recipient']), site_url('twiml/start/voice/' . $id));
    }
}
$flows = OpenVBX::getFlows(array('tenant_id' => $tenant_id));
?>
<style>
	.vbx-outbound form {
		padding: 20px 5%;
	}
</style>
<div class="vbx-content-main">
	<div class="vbx-content-menu vbx-content-menu-top">
		<h2 class="vbx-content-heading">Start Flow</h2>
	</div>
    <div class="vbx-table-section vbx-outbound">
		<form method="post" action="">
			<fieldset class="vbx-input-container">
<?php 
if (count($callerid_numbers)) {
    ?>
				<p>
					<label class="field-label">Number<br/>
开发者ID:afreeth,项目名称:OpenVBX-Plugin-Outbound,代码行数:31,代码来源:outbound.php

示例14: save_user

 private function save_user()
 {
     $errors = array();
     $user = false;
     $id = intval($this->input->post('id'));
     $auth_type = $this->input->post('auth_type');
     $error = false;
     $message = "Failed to save user for unknown reason.";
     $shouldGenerateNewPassword = false;
     $device_id_str = trim($this->input->post('device_id'));
     $device_number = trim($this->input->post('device_number'));
     $shouldSendWelcome = false;
     try {
         PhoneNumber::validatePhoneNumber($device_number);
     } catch (PhoneNumberException $e) {
         $data['json'] = array('error' => true, 'message' => $e->getMessage());
         return $this->respond('', 'accounts', $data);
     }
     if (!empty($auth_type)) {
         $auth_type = $this->vbx_user->get_auth_type($auth_type);
     }
     if ($id > 0) {
         $user = VBX_User::get($id);
     } else {
         $user = VBX_User::get(array('email' => $this->input->post('email')));
         if (!empty($user) && $user->is_active == 1) {
             $error = true;
             $message = 'Email address is already in use.';
         } elseif (!empty($user) && $user->is_active == 0) {
             // It's an old account that was made inactive.  By re-adding it, we're
             // assuming the user wants to re-instate the old account.
             $shouldSendWelcome = true;
         } else {
             // It's a new user
             $user = new VBX_User();
             $user->online = 9;
             $shouldSendWelcome = true;
         }
     }
     if (!$error) {
         $fields = array('first_name', 'last_name', 'email', 'is_admin');
         foreach ($fields as $field) {
             $user->{$field} = $this->input->post($field);
         }
         $user->is_active = TRUE;
         $user->auth_type = isset($auth_type->id) ? $auth_type->id : 1;
         try {
             $user->save();
             if ($shouldSendWelcome) {
                 $user->send_new_user_notification();
             }
         } catch (VBX_UserException $e) {
             $error = true;
             $message = $e->getMessage();
             log_message('error', 'Unable to send new user notification: ' . $message);
         }
         if (!$error) {
             if (strlen($device_number) > 0) {
                 // We're adding or modifying an existing device
                 if (strlen($device_id_str) > 0) {
                     // We're updating an existing record
                     $device_id = intval($device_id_str);
                     $device = VBX_Device::get($device_id);
                     $device->value = normalize_phone_to_E164($device_number);
                     try {
                         $device->save();
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = 'Failed to update device: ' . $e->getMessage();
                     }
                 } else {
                     // We're creating a new device record
                     $number = array("name" => "Primary Device", "value" => normalize_phone_to_E164($device_number), "user_id" => $user->id, "sms" => 1);
                     try {
                         $new_device_id = $this->vbx_device->add($number);
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = "Failed to add device: " . $e->getMessage();
                     }
                 }
             } else {
                 if (strlen($device_number) == 0 && strlen($device_id_str) > 0) {
                     // We're deleting a device
                     try {
                         $this->vbx_device->delete(intval($device_id_str), $user->id);
                     } catch (VBX_DeviceException $e) {
                         $error = true;
                         $message = "Unable to delete device entry: " . $e->getMessage();
                     }
                 }
             }
         }
     }
     if ($error) {
         $json = array('error' => $error, 'message' => $message);
     } else {
         $json = array('id' => $user->id, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'is_active' => $user->is_active, 'is_admin' => $user->is_admin, 'notification' => $user->notification, 'auth_type' => isset($auth_type->description) ? $auth_type->description : 'openvbx', 'email' => $user->email, 'error' => false, 'message' => '', 'online' => $user->online);
     }
     $data['json'] = $json;
     $this->respond('', 'accounts', $data);
//.........这里部分代码省略.........
开发者ID:ryanlarrabure,项目名称:OpenVBX,代码行数:101,代码来源:accounts.php

示例15: get_instance

<?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();
开发者ID:mymizan,项目名称:OpenVBX-Plugin-Throttle,代码行数:23,代码来源:twiml.php


注:本文中的normalize_phone_to_E164函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。