You are here

function clientside_validation_testswarm_enable in Clientside Validation 7

Same name and namespace in other branches
  1. 7.2 clientside_validation_testswarm/clientside_validation_testswarm.module \clientside_validation_testswarm_enable()

Implements hook_enable().

2 calls to clientside_validation_testswarm_enable()
clientside_validation_testswarm_update_7101 in clientside_validation_testswarm/clientside_validation_testswarm.install
Import the webform needed to test Clientside Validation Webform.
clientside_validation_testswarm_update_7104 in clientside_validation_testswarm/clientside_validation_testswarm.install
Import the webform needed to test Clientside Validation Webform Validation.

File

clientside_validation_testswarm/clientside_validation_testswarm.module, line 54
Testswarm tests for Clientside Validation.

Code

function clientside_validation_testswarm_enable() {
  module_load_include('inc', 'clientside_validation_testswarm', 'clientside_validation_testswarm.default_content');
  $content = _clientside_validation_testswarm_default_content();
  $nodenames = variable_get('clientside_validation_testswarm_nodenames', array());
  variable_set('node_content_enabled', TRUE);
  foreach ($content as $newnode) {
    if (!array_key_exists($newnode->machine_name, $nodenames)) {
      defaultcontent_import_node($newnode);
      $nid = defaultcontent_get_default($newnode->machine_name);
      $nodenames[$newnode->machine_name] = $nid;
    }
  }
  variable_set('clientside_validation_testswarm_nodenames', $nodenames);
  if (module_exists('path')) {
    foreach (variable_get('clientside_validation_testswarm_nodenames', array()) as $machine_name => $nid) {
      $node = node_load($nid);
      $path = array(
        'source' => 'node/' . $nid,
        'alias' => 'clientsidevalidation/tests/' . $machine_name,
      );
      if (isset($node->language)) {
        $path['language'] = $node->language;
      }
      path_save($path);
    }
  }
  menu_rebuild();
  $pid = db_select('menu_links', 'ml')
    ->fields('ml')
    ->condition('link_path', 'clientsidevalidation/tests')
    ->execute()
    ->fetchObject()->mlid;
  $link = array(
    'menu_name' => 'navigation',
    'link_path' => 'node-name/webform',
    'router_path' => 'node/%',
    'link_title' => 'Clientside Validation Webform Tests',
    'options' => array(
      'attributes' => array(
        'title' => 'Test Clientside Validation on form elements provided by the Webform module',
      ),
    ),
    'module' => 'menu',
    'hidden' => '0',
    'external' => '0',
    'has_children' => '0',
    'expanded' => '0',
    'weight' => '0',
    'parent_path' => 'clientsidevalidation/tests',
    'identifier' => 'navigation:node-name/webform',
    'pid' => $pid,
  );
  defaultcontent_import_menu_link($link['identifier'], $link);
  $link = array(
    'menu_name' => 'navigation',
    'link_path' => 'node-name/webformvalidation',
    'router_path' => 'node/%',
    'link_title' => 'Clientside Validation Webform Validation Tests',
    'options' => array(
      'attributes' => array(
        'title' => 'Test Clientside Validation Webform Validation',
      ),
    ),
    'module' => 'menu',
    'hidden' => '0',
    'external' => '0',
    'has_children' => '0',
    'expanded' => '0',
    'weight' => '0',
    'parent_path' => 'clientsidevalidation/tests',
    'identifier' => 'navigation:node-name/webformvalidation',
    'pid' => $pid,
  );
  defaultcontent_import_menu_link($link['identifier'], $link);
  $link = array(
    'menu_name' => 'navigation',
    'link_path' => 'node/add/cv-test-field-validation',
    'router_path' => 'node/add/cv-test-field-validation',
    'link_title' => 'Clientside Validation Test Field Validation',
    'options' => array(
      'attributes' => array(
        'title' => 'Test Clientside Validation Field Validation',
      ),
    ),
    'module' => 'menu',
    'hidden' => '0',
    'external' => '0',
    'has_children' => '0',
    'expanded' => '0',
    'weight' => '0',
    'parent_path' => 'clientsidevalidation/tests',
    'pid' => $pid,
    'identifier' => 'navigation:node/add/cv-test-field-validation',
  );
  defaultcontent_import_menu_link($link['identifier'], $link);
  _clientside_validation_testswarm_create_webform_validation_rules();
}