function sms_valid_ruleset_is_enabled in SMS Framework 7
Same name and namespace in other branches
- 6.2 modules/sms_valid/sms_valid.module \sms_valid_ruleset_is_enabled()
- 6 modules/sms_valid/sms_valid.module \sms_valid_ruleset_is_enabled()
Checks what directions are enabled for a ruleset.
Parameters
int $prefix: A prefix number.
int $dir: The direction code that you want to check. See SMS_DIR_* constants.
Return value
bool true if the ruleset is enabled for this direction, false otherwise.
3 calls to sms_valid_ruleset_is_enabled()
- sms_valid_admin_rulesets_form in modules/
sms_valid/ sms_valid.admin.inc - Form constructor for validation rulesets list form.
- sms_valid_admin_ruleset_form in modules/
sms_valid/ sms_valid.admin.inc - Form constructor for validation ruleset editing.
- sms_valid_validate in modules/
sms_valid/ sms_valid.module - Validates a number.
File
- modules/
sms_valid/ sms_valid.module, line 228 - Number validation feature module for Drupal SMS Framework.
Code
function sms_valid_ruleset_is_enabled($prefix, $dir = SMS_DIR_OUT) {
$result = db_query_range("SELECT dirs_enabled FROM {sms_valid_rules} WHERE prefix = :prefix", 0, 1, array(
':prefix' => $prefix,
));
$dirs_enabled = $result
->fetchField();
// There must be a better way of doing this, but this works ok
if ($dirs_enabled == SMS_DIR_ALL) {
return TRUE;
}
if ($dirs_enabled == SMS_DIR_OUT && $dir == SMS_DIR_OUT) {
return TRUE;
}
if ($dirs_enabled == SMS_DIR_IN && $dir == SMS_DIR_IN) {
return TRUE;
}
return FALSE;
}