本文整理汇总了PHP中VBX_User::get方法的典型用法代码示例。如果您正苦于以下问题:PHP VBX_User::get方法的具体用法?PHP VBX_User::get怎么用?PHP VBX_User::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VBX_User
的用法示例。
在下文中一共展示了VBX_User::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get a DialList object try
* Pass in a VBX_User or VBX_Group object to begin
*
* @param object users_or_group
* @return object DialList
*/
public static function get($users_or_group)
{
$users = array();
$class = 'DialList';
switch (true) {
case is_array($users_or_group):
if (current($users_or_group) instanceof VBX_User) {
// list of users, set as users list and continue
$users = $users_or_group;
} else {
// list of user ids, populate list
$users = VBX_User::get_users($users_or_group);
}
break;
case $users_or_group instanceof VBX_Group:
if (!empty($users_or_group->users)) {
foreach ($users_or_group->users as $user) {
array_push($users, VBX_User::get($user->user_id));
}
}
break;
case $users_or_group instanceof VBX_User:
$class = 'DialListUser';
// individual user, add to list and continue
array_push($users, $users_or_group);
break;
}
return new $class($users);
}
示例2: 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;
}
示例3: reset
public function reset()
{
$this->template->write('title', 'Reset Password');
$data = array();
$email = $this->input->post('email');
if (empty($email)) {
$data['error'] = $this->session->flashdata('error');
return $this->respond('', 'reset', $data, 'login-wrapper', 'layout/login');
}
$user = VBX_User::get(array('email' => $email, 'is_active' => 1));
if (empty($user)) {
$this->session->set_flashdata('error', 'No active account found.');
redirect('auth/reset');
}
if ($user->auth_type == 'google') {
header('Location: http://www.google.com/support/accounts/bin/answer.py?answer=48598&hl=en&ctx=ch_Login&fpUrl=https%3A%2F%2Fwww.google.com%2Faccounts%2FForgotPasswd%3FfpOnly%3D1%26continue%3Dhttp%253A%252F%252Fwww.google.com%252F%26hl%3Den');
return;
} else {
$emailSent = $user->send_reset_notification();
if ($emailSent) {
$this->session->set_flashdata('error', 'To complete the password reset, check your inbox.');
} else {
$this->session->set_flashdata('error', 'The email was not sent. Contact your admin.');
}
redirect('auth/login');
}
redirect('auth/reset');
}
示例4: 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');
}
示例5: __construct
public function __construct()
{
parent::__construct();
$this->user = VBX_User::get($this->session->userdata('user_id'));
if (!$this->user->is_admin) {
throw new SiteCachesException('Action not allowed to non-administrators');
}
}
示例6: who_called
public function who_called($number)
{
if (preg_match('|^client:|', $number)) {
$user_id = str_replace('client:', '', $number);
$user = VBX_User::get(array('id' => $user_id));
$ret = $user->first_name . ' ' . $user->last_name . ' (client)';
} else {
$ret = format_phone($number);
}
return $ret;
}
示例7: testVoicemailUserSay
public function testVoicemailUserSay()
{
ob_start();
$this->CI->voice(1, 'f274cd');
$out = ob_get_clean();
$xml = simplexml_load_string($out);
$this->assertInstanceOf('SimpleXMLElement', $xml);
$user = VBX_User::get($this->user_id);
// this regex match is cheap, need better reg-fu to match possible
// language and voice attributes that could appear in any order
$this->assertRegExp('|(<Say(.*?)>' . $user->voicemail . '</Say>)|', $out);
$this->assertRegExp('|(<Record transcribeCallback="(.*?)"/>)|', $out);
}
示例8: setUp
public function setUp()
{
parent::setUp();
// set the user's voicemail to be a recording
$this->user = VBX_User::get($this->user_id);
$this->user->voicemail = $this->upload_prefix . $this->filename;
$this->user->save();
$this->setFlow(array('id' => 1, 'user_id' => 1, 'created' => NULL, 'updated' => NULL, 'data' => '{"start":{"name":"Call Start","data":{"next":"start/59c7d7"},"id":"start","type":"standard---start"},"59c7d7":{"name":"Voicemail","data":{"prompt_say":"","prompt_play":"","prompt_mode":"","prompt_tag":"global","number":"","library":"","permissions_id":"' . $this->user_id . '","permissions_type":"user"},"id":"59c7d7","type":"standard---voicemail"}}', 'sms_data' => NULL, 'tenant_id' => 1));
// set up our request
$this->setPath('/twiml/applet/voice/1/59c7d7');
$this->setRequestMethod('POST');
// prepare the header token for request validation
$this->setRequestToken();
}
示例9: 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);
}
示例10: dialDevice
/**
* Add a device to the Dialer
*
* @param VBX_Device $device
* @return bool
*/
public function dialDevice($device)
{
$dialed = false;
if ($device->is_active) {
$user = VBX_User::get($device->user_id);
$call_opts = array('url' => site_url('twiml/whisper?name=' . urlencode($user->first_name)));
$dial = new Dial(NULL, array('action' => current_url(), 'callerId' => $this->callerId));
if (strpos($device->value, 'client:') !== false) {
$dial->addClient(str_replace('client:', '', $device->value), $call_opts);
} else {
$dial->addNumber($device->value, $call_opts);
}
$this->response->append($dial);
$dialed = true;
}
return $dialed;
}
示例11: testUserDialClient
public function testUserDialClient()
{
$this->setFlowVar('data', '{"start":{"name":"Call Start","data":{"next":"start/4a7eed"},"id":"start","type":"standard---start"},"4a7eed":{"name":"Dial","data":{"dial-whom-selector":"user-or-group","dial-whom-user-or-group_id":"' . $this->dial_user_id . '","dial-whom-user-or-group_type":"user","dial-whom-number":"","callerId":"","no-answer-action":"voicemail","no-answer-group-voicemail_say":"","no-answer-group-voicemail_play":"","no-answer-group-voicemail_mode":"","no-answer-group-voicemail_tag":"global","no-answer-group-voicemail_caller_id":"+14158774003","number":"","library":"","no-answer-redirect":"","no-answer-redirect-number":"start/4a7eed/e18b35","version":"3"},"id":"4a7eed","type":"standard---dial"},"e18b35":{"name":"Hangup","data":{},"id":"e18b35","type":"standard---hangup"}}');
$user = VBX_User::get($this->dial_user_id);
$user->online = 1;
$user->save();
ob_start();
$this->CI->voice('1', '4a7eed');
$out = ob_get_clean();
// test valid xml
$xml = simplexml_load_string($out);
$this->assertInstanceOf('SimpleXMLElement', $xml);
// test valid user number item
$user_name = $user->first_name;
$user_phone = $user->devices[0]->value;
$regexp = '|<Number url="(.*?)/twiml/whisper\\?name=' . $user_name . '">\\' . $user_phone . '</Number>|';
$this->assertRegExp($regexp, $out);
// test valid user client item
$regexp2 = '|<Client url="(.*?)/twiml/whisper\\?name=' . $user_name . '">' . $user->id . '</Client>|';
$this->assertRegExp($regexp2, $out);
}
示例12: save_greeting
private function save_greeting()
{
$data['json'] = array('error' => false, 'message' => '');
$user = VBX_User::get($this->user_id);
$user->voicemail = $this->input->post('voicemail');
try {
$user->save();
} catch (VBX_UserException $e) {
$data['json'] = array('error' => true, 'message' => $e->getMessage());
}
return $data;
}
示例13: client_status
public function client_status()
{
$data = array('json' => array('error' => true, 'message' => 'Invalid Request'));
if ($this->input->post('clientstatus')) {
$online = $this->input->post('online') == 1;
$user = VBX_User::get($this->session->userdata('user_id'));
try {
$user->setting_set('online', $online);
$data['json'] = array('error' => false, 'message' => 'status updated', 'client_status' => $online ? 'online' : 'offline');
} catch (VBX_UserException $e) {
$data['json'] = array('error' => true, 'message' => $e->getMessage());
}
}
$this->respond('', null, $data);
}
示例14: getUserGroupPickerValue
public static function getUserGroupPickerValue($name = 'userGroupPicker')
{
$ci =& get_instance();
$ci->load->model('vbx_user');
$ci->load->model('vbx_group');
$owner_id = self::getValue($name . '_id');
$owner_type = self::getValue($name . '_type');
$owner = null;
switch ($owner_type) {
case 'group':
$owner = VBX_Group::get(array('id' => $owner_id));
break;
case 'user':
$owner = VBX_User::get($owner_id);
break;
}
return $owner;
}
示例15: __construct
public function __construct()
{
parent::__construct();
$this->config_check();
$this->config->load('openvbx');
// check for required configuration values
$this->load->database();
$this->load->library('ErrorMessages');
// deprecated in 1.2
$this->load->model('vbx_rest_access');
$this->load->model('vbx_message');
// When we're in testing mode, allow access to set Hiccup configuration
$this->testing_mode = !empty($_REQUEST['vbx_testing_key']) ? $_REQUEST['vbx_testing_key'] == $this->config->item('testing-key') : false;
$this->config->set_item('sess_cookie_name', $this->tenant->id . '-' . $this->config->item('sess_cookie_name'));
$this->load->library('session');
$keys = array('base_url', 'salt');
foreach ($keys as $key) {
$item[$key] = $this->config->item($key);
if (empty($item[$key])) {
redirect('install');
}
}
/* Rest API Authentication - one time pass only */
$singlepass = $this->input->cookie('singlepass');
if (!empty($singlepass)) {
$ra = new VBX_Rest_Access();
$user_id = $ra->auth_key($singlepass);
unset($_COOKIE['singlepass']);
if ($user_id) {
$this->session->set_userdata('user_id', $user_id);
$this->session->set_userdata('loggedin', true);
$this->session->set_userdata('signature', VBX_User::signature($user_id));
}
}
$user_id = $this->session->userdata('user_id');
// Signature check
if (!empty($user_id)) {
$signature = $this->session->userdata('signature');
if (!VBX_User::check_signature($user_id, $signature)) {
$this->session->set_flashdata('error', 'Your session has expired');
$this->session->set_userdata('loggedin', false);
}
}
if ($this->response_type == 'json') {
$this->attempt_digest_auth();
}
if (!$this->session->userdata('loggedin') && $this->response_type != 'json') {
$redirect = site_url($this->uri->uri_string());
if (!empty($_COOKIE['last_known_url'])) {
$redirect = $_COOKIE['last_known_url'];
set_last_known_url('', time() - 3600);
}
return redirect('auth/login?redirect=' . urlencode($redirect));
}
$this->user_id = $this->session->userdata('user_id');
$this->set_request_method();
/* Mark the user as seen */
if (!empty($this->user_id)) {
try {
$user = VBX_User::get($this->user_id);
$user->setting_set('last_seen', new MY_ModelLiteral('UTC_TIMESTAMP()'));
} catch (VBX_UserException $e) {
/* Handle this gracefully, but report the error. */
error_log($e->getMessage());
}
$this->connect_check();
/* Check for first run */
if ($this->session->userdata('is_admin') && $this->uri->segment(1) != 'welcome') {
$this->welcome_check();
}
/* Check for updates if an admin */
if ($this->session->userdata('is_admin') && $this->uri->segment(1) != "upgrade") {
$this->upgrade_check();
}
}
}