You are here

function sms_valid_rules_to_text in SMS Framework 7

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

Implodes a rules array into rules text.

Parameters

array $rules: A rules array.

Return value

string A text string containing rules for a ruleset.

2 calls to sms_valid_rules_to_text()
SmsValidWebTest::testSmsValidFunctions in modules/sms_valid/sms_valid.test
Tests the internal sms_valid functions.
sms_valid_admin_ruleset_form in modules/sms_valid/sms_valid.admin.inc
Form constructor for validation ruleset editing.

File

modules/sms_valid/sms_valid.module, line 392
Number validation feature module for Drupal SMS Framework.

Code

function sms_valid_rules_to_text($rules) {
  $lines = array();
  if ($rules && is_array($rules)) {
    foreach ($rules as $rule_prefix => $rule) {
      $allow = $rule['allow'] ? '+' : '-';
      $comment = $rule['comment'] ? '    # ' . $rule['comment'] : '';
      $lines[] = $rule_prefix . $allow . $comment;
    }
  }
  return implode("\n", $lines);
}