Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Commit

Permalink
Fixing various notices and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gipetto committed May 21, 2013
1 parent 5122fa9 commit 412510c
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 75 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

- Fix curl error handling on GitHub API calls.
- Adding SIP validation helper.
- No longer including client/account data in encoded json to avoid icky 'recursion detected' warning in JSON encode.
- Fix notice in logs about undefined `status` member on phone number entries.
- Clean up various innocuous log notices.


## OpenVBX 1.2.13
Expand Down
2 changes: 1 addition & 1 deletion OpenVBX/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 1;
$config['log_threshold'] = 4;

/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions OpenVBX/controllers/twiml.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function start_sms($flow_id)
$flow_id = $this->set_flow_id($flow_id);
$flow = $this->get_flow();
$flow_data = array();
if(is_object($flow))
if(is_object($flow) && strlen($flow->sms_data))
{
$flow_data = get_object_vars(json_decode($flow->sms_data));
}
Expand All @@ -110,7 +110,7 @@ function start_voice($flow_id)
$flow_id = $this->set_flow_id($flow_id);
$flow = $this->get_flow();
$flow_data = array();
if(is_object($flow))
if(is_object($flow) && strlen($flow->data))
{
$flow_data = get_object_vars(json_decode($flow->data));
}
Expand Down
32 changes: 16 additions & 16 deletions OpenVBX/helpers/twilio_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,25 @@ function version_url($url) {
*/
function _deprecated_notice($method, $version, $replacement = null) {
if (!is_null($replacement)) {
$message = sprintf('`%s` is deprecated since version %f. Use `%s` instead.');
$message = sprintf('`%s` is deprecated since version %f. Use `%s` instead.', $method, $version, $replacement);
}
else {
$message = sprintf('`%s` is deprecated since version %f.');
$message = sprintf('`%s` is deprecated since version %f.', $method, $version);
}
log_message('error', $message);
trigger_error($message, E_WARNING);
trigger_error($message, E_USER_WARNING);
}
}

if (!function_exists('t_form_dropdown')) {
/**
* An easier to use version of form_dropdown
*
* @param array $params
* @param array $options
* @param string $selected
* @return string HTML
*/
/**
* An easier to use version of form_dropdown
*
* @param array $params
* @param array $options
* @param bool|string $selected
* @return string HTML
*/
function t_form_dropdown($params, $options, $selected = false)
{
$name = '';
Expand All @@ -187,13 +187,13 @@ function t_form_dropdown($params, $options, $selected = false)

if (!function_exists('t_form_input'))
{
function t_form_input($params, $value)
{
function t_form_input($params, $value = '')
{
$data = array();

if (!empty($params['name']))
{
$data = array(
'name' => $params['name']
);
$data['name'] = $params['name'];
}

$extra = '';
Expand Down
2 changes: 1 addition & 1 deletion OpenVBX/libraries/DialList.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static function get($users_or_group)
else
{
// list of user ids, populate list
$users = VBX_User::get_users($user_ids);
$users = VBX_User::get_users($users_or_group);
}
break;
case $users_or_group instanceof VBX_Group:
Expand Down
2 changes: 1 addition & 1 deletion OpenVBX/libraries/MY_Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct($object = null)
{
foreach($this->fields as $property)
{
$this->values[$property] = $object->$property;
$this->values[$property] = isset($object->property) ? $object->$property : null;
}
}

Expand Down
8 changes: 6 additions & 2 deletions OpenVBX/libraries/OpenVBX.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,18 @@ public static function schemaVersion()
$ci =& get_instance();
if ($ci->db)
{
$reenable_cache = false;

$ci->load->model('vbx_settings');
if (!$ci->cache && $ci->cache->enabled())
if (isset($ci->cache) && $ci->cache->enabled())
{
$ci->cache->enabled(false);
$reenable_cache = true;
}

self::$schemaVersion = $ci->vbx_settings->get('schema-version', VBX_PARENT_TENANT);
if ($reenable_cache)

if ($reenable_cache)
{
$ci->cache->enabled(true);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenVBX/models/vbx_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static function search($search_options = array(), $limit = -1, $offset = 0)
$groups[$gu->group_id]->users[$gu->user_id] = $gu;
}

if($limit == 1 && count($groups) == 1)
if($limit == 1 && count($groups) > 0)
{
$groups = current($groups);
}
Expand Down
100 changes: 55 additions & 45 deletions OpenVBX/models/vbx_message.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ function notify_message($message)
}
$message->content_url = $vm_url;

$users = array();
$notify = array();
if($message->owner_type == 'user')
{
Expand All @@ -420,7 +419,6 @@ function notify_message($message)
}
}

$group_users = array();
if($message->owner_type == 'group')
{
$user_ids = $ci->vbx_group->get_user_ids($message->owner_id);
Expand All @@ -441,54 +439,66 @@ function notify_message($message)
$incoming_number = VBX_Incoming_numbers::get(array(
'phone_number' => normalize_phone_to_E164($message->called)
));

$sms_notify = false;

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, // SMS from incoming number
$number->value, // SMS to user
$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)
if (!$email_notify && !$sms_notify)
{
return false;
}

if (!count($user_ids)) {
return false;
}

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';

$_owner = $owner;

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, // SMS from incoming number
$number->value, // SMS to user
$this->tiny_notification_message($message)
);
}
catch(VBX_Sms_messageException $e)
{
log_message('error', 'unable to send sms alert, reason: '.$e->getMessage());
}
}
}
}
}
}

function tiny_notification_message($message)
Expand Down
2 changes: 1 addition & 1 deletion OpenVBX/models/vbx_user.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public function save($force_update = false)
{
throw new VBX_UserException('Email is a required field.');
}

if(!(strpos($this->email, '@') > 0))
{
throw new VBX_UserException('Valid email address is required');
Expand Down
13 changes: 10 additions & 3 deletions plugins/standard/applets/dial/TwimlDial.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,16 @@ public function __construct($settings = array())
$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 (is_object($this->dial_whom_user_or_group))
{
$this->dial_whom_instance = get_class($this->dial_whom_user_or_group);
}
elseif (is_array($this->dial_whom_user_or_group) && count($this->dial_whom_user_or_group))
{
$this->dial_whom_instance = get_class(current($this->dial_whom_user_or_group));
}

if (count($settings)) {
foreach ($settings as $setting => $value)
{
Expand Down
2 changes: 2 additions & 0 deletions plugins/standard/applets/dial/twiml.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
// create a dial list from the input state
$dial_list = DialList::get($dialer->dial_whom_user_or_group);

$dialed = false;

while (count($dial_list))
{
$to_dial = $dial_list->next();
Expand Down

0 comments on commit 412510c

Please sign in to comment.