function sms_valid_save_ruleset in SMS Framework 6
Same name and namespace in other branches
- 6.2 modules/sms_valid/sms_valid.module \sms_valid_save_ruleset()
- 7 modules/sms_valid/sms_valid.module \sms_valid_save_ruleset()
Create or update a ruleset
Parameters
$ruleset: A ruleset array.
Return value
Boolean. Result of the DB query.
1 call to sms_valid_save_ruleset()
- sms_valid_admin_ruleset_form_submit in modules/
sms_valid/ sms_valid.admin.inc
File
- modules/
sms_valid/ sms_valid.module, line 285 - Number validation feature module for Drupal SMS Framework.
Code
function sms_valid_save_ruleset($ruleset) {
$prefix = $ruleset['prefix'];
$name = $ruleset['name'];
$iso2 = $ruleset['iso2'];
$rules_z = serialize($ruleset['rules']);
$dirs_enabled = $ruleset['dirs_enabled'];
if (sms_valid_get_ruleset($prefix)) {
// The ruleset exists so we should update
return db_query("UPDATE {sms_valid_rules} SET\n name = '%s', rules = '%s', dirs_enabled = %d,\n iso2 = '%s' WHERE prefix = %d", $name, $rules_z, $dirs_enabled, $iso2, $prefix);
}
else {
// The ruleset does not exist so we should create
return db_query("INSERT INTO {sms_valid_rules}\n (prefix, name, rules, dirs_enabled, iso2)\n VALUES\n (%d, '%s', '%s', %d, '%s')", $prefix, $name, $rules_z, $dirs_enabled, $iso2);
}
}