protected function ruleToString($perm, $rule) {

    // Some rules only apply to READ.
    if (self::READ & $perm) {

      // Host rule.
      if (!empty($rule['host'])) {
        return '.r:' . $rule['host'];
      }

      // Listing rule.
      if (!empty($rule['rlistings'])) {
        return '.rlistings';
      }
    }

    // READ and WRITE both allow account/user rules.
    if (!empty($rule['account'])) {

      // Just an account name.
      if (empty($rule['user'])) {
        return $rule['account'];
      }

      // Account + multiple users.
      elseif (is_array($rule['user'])) {
        $buffer = array();
        foreach ($rule['user'] as $user) {
          $buffer[] = $rule['account'] . ':' . $user;
        }
        return implode(',', $buffer);

      }

      // Account + one user.
      else {
        return $rule['account'] . ':' . $rule['user'];
      }
    }
  }
protected function ruleToString($perm, $rule) {

    // Some rules only apply to READ.
    if (self::READ & $perm) {

      // Host rule.
      if (!empty($rule['host'])) {
        return '.r:' . $rule['host'];
      }

      // Listing rule.
      if (!empty($rule['rlistings'])) {
        return '.rlistings';
      }
    }

    // READ and WRITE both allow account/user rules.
    if (!empty($rule['account'])) {

      // Just an account name.
      if (empty($rule['user'])) {
        return $rule['account'];
      }

      // Account + multiple users.
      elseif (is_array($rule['user'])) {
        $buffer = array();
        foreach ($rule['user'] as $user) {
          $buffer[] = $rule['account'] . ':' . $user;
        }
        return implode(',', $buffer);

      }

      // Account + one user.
      else {
        return $rule['account'] . ':' . $rule['user'];
      }
    }
  }
protected function ruleToString ( $ perm , $ rule ) { // Some rules only apply to READ. if ( self :: READ & $ perm ) { // Host rule. if ( ! empty ( $ rule [ 'host' ] ) ) { return '.r:' . $ rule [ 'host' ] ; } // Listing rule. if ( ! empty ( $ rule [ 'rlistings' ] ) ) { return '.rlistings' ; } } // READ and WRITE both allow account/user rules. if ( ! empty ( $ rule [ 'account' ] ) ) { // Just an account name. if ( empty ( $ rule [ 'user' ] ) ) { return $ rule [ 'account' ] ; } // Account + multiple users. elseif ( is_array ( $ rule [ 'user' ] ) ) { $ buffer = array ( ) ; foreach ( $ rule [ 'user' ] as $ user ) { $ buffer [ ] = $ rule [ 'account' ] . ':' . $ user ; } return implode ( ',' , $ buffer ) ; } // Account + one user. else { return $ rule [ 'account' ] . ':' . $ rule [ 'user' ] ; } } }
Convert a rule to a string.

@param int $perm
The permission for which to generate the rule.
@param array $rule
A rule array.
Convert a rule to a string .