Unreachable code: "You need need to setup your mobile phone to send messages"
jpmckinney - August 21, 2009 - 17:22
| Project: | SMS Framework |
| Version: | 6.x-2.x-dev |
| Component: | Send to Phone |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
In sms_sendtophone_page():
<?php
if (user_access('send to any number') || !empty($user->sms_user['0']['number'])) {
$form = drupal_get_form('sms_sendtophone_form', $type);
}
else {
if (empty($user->sms_user['0']['number']) && user_access('send to any number')) {
$register = array(
'#value' => t('You need need to <a href="@setup">setup</a> your mobile phone to send messages.', array('@setup' => url('user/'. $user->uid .'/mobile')))
);
}
else {
$register = array(
'#value' => t('You do not have permission to send messages. You may need to <a href="@signin">sign in</a> or <a href="@register">register</a> for an account to send messages to a mobile phone.', array('@signin' => url('user', array('query' => array('destination' => $_GET['destination']))), '@register' => url('user/register', array('query' => array('destination' => $_GET['destination']))))),
);
}
$form = drupal_render($register);
}
?>The following:
<?php
if (empty($user->sms_user['0']['number']) && user_access('send to any number')) {
?>will always evaluate to FALSE, as user_access('send to any number') cannot be TRUE at this point, because if it were TRUE, the code within the previous if-statement would have been run instead. The quoted line should be replaced with:
<?php
if (empty($user->sms_user['0']['number'])) {
?>which results in the expected behavior.

#1