You are here

function sms_valid_create_example_ruleset in SMS Framework 7

Same name and namespace in other branches
  1. 6.2 modules/sms_valid/sms_valid.install \sms_valid_create_example_ruleset()
  2. 6 modules/sms_valid/sms_valid.install \sms_valid_create_example_ruleset()

Create an example number validation ruleset.

Parameters

array $ret: Array of query results.

1 call to sms_valid_create_example_ruleset()
sms_valid_install in modules/sms_valid/sms_valid.install
Implements hook_install().

File

modules/sms_valid/sms_valid.install, line 74
SMS Framework Number Validation feature module: Install file.

Code

function sms_valid_create_example_ruleset(&$ret = array()) {
  $prefix = 64;
  $name = 'New Zealand';
  $dirs_enabled = 4;
  $iso2 = 'NZ';
  $rules = array(
    '21' => array(
      'allow' => TRUE,
      'comment' => 'Vodafone',
    ),
    '22' => array(
      'allow' => TRUE,
      'comment' => 'Two Degrees Mobile',
    ),
    '25' => array(
      'allow' => FALSE,
      'comment' => 'Telecom AMPS+TDMA (old)',
    ),
    '26' => array(
      'allow' => FALSE,
      'comment' => 'Telecom pager network',
    ),
    '27' => array(
      'allow' => TRUE,
      'comment' => 'Telecom CDMA',
    ),
    '28' => array(
      'allow' => TRUE,
      'comment' => 'Slingshot',
    ),
    '29' => array(
      'allow' => TRUE,
      'comment' => 'TelstraClear',
    ),
  );
  $rules_z = serialize($rules);
  $sql = "INSERT INTO {sms_valid_rules} (prefix,name,rules,dirs_enabled,iso2)" . "VALUES (%d, '%s', '%s', %d, '%s')";

  // @TODO Please convert this statement to the D7 database API syntax.
  //  $result = db_query($sql, $prefix, $name, $rules_z, $dirs_enabled, $iso2);
  $result = db_insert('sms_valid_rules')
    ->fields(array(
    'prefix' => $prefix,
    'name' => $name,
    'rules' => $rules_z,
    'dirs_enabled' => $dirs_enabled,
    'iso2' => $iso2,
  ))
    ->execute();
  $ret[] = array(
    'success' => $result !== FALSE,
    'query' => check_plain($sql),
  );
}