/[drupal]/contributions/modules/simpletest_automator/simpletest_automator_proctor/simpletest_automator_proctor.module
ViewVC logotype

Diff of /contributions/modules/simpletest_automator/simpletest_automator_proctor/simpletest_automator_proctor.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Fri Aug 1 04:13:20 2008 UTC revision 1.3, Thu Aug 28 06:41:42 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: simpletest_automator_proctor.module,v 1.1 2008/08/01 03:37:53 cwgordon7 Exp $  // $Id: simpletest_automator_proctor.module,v 1.2 2008/08/01 04:13:20 cwgordon7 Exp $
3    
4  /**  /**
5   * Implementation of hook_init().   * Implementation of hook_init().
6   */   */
7  function simpletest_automator_proctor_init() {  function simpletest_automator_proctor_init() {
8    if (!function_exists('custom_url_rewrite_outbound')) {    global $db_prefix;
9      if ($db_prefix != $_COOKIE['simpletest_automator']) {
10      $code = <<<EOT      $code = <<<EOT
11  if (isset(\$_GET['simpletest_automator']) && preg_match('/simpletest\d+/', \$_GET['simpletest_automator'])) {  if (isset(\$_COOKIE['simpletest_automator']) && preg_match('/st_automator\d+/', \$_COOKIE['simpletest_automator'])) {
12    \$GLOBALS['db_prefix'] = \$_GET['simpletest_automator'];    \$db_prefix_original = \$db_prefix;
13    \$GLOBALS['db_prefix_original'] = \$GLOBALS['db_prefix'];    \$db_prefix = \$_COOKIE['simpletest_automator'];
   function custom_url_rewrite_outbound(&\$path, &\$options, \$original_path) {  
     \$options['query'] += array('simpletest_automator' => \$_GET['simpletest_automator']);  
   }  
14  }  }
15  EOT;  EOT;
16      drupal_set_message(t('Please add the following code to settings.php: <code><pre>@code</pre></code>', array('@code' => $code)), 'warning');      drupal_set_message(t('Please add the following code to settings.php: <code><pre>@code</pre></code>', array('@code' => $code)), 'warning');
17    }    }
18    drupal_add_js(drupal_get_path('module', 'simpletest_automator_proctor') .'/simpletest_automator_proctor.js');    drupal_add_js(drupal_get_path('module', 'simpletest_automator_proctor') .'/simpletest_automator_proctor.js');
19      drupal_set_message(t('Operating in record mode.'));
20      if ((!isset($_GET['record']) || $_GET['record'] != 'false') && empty($_POST)) {
21        simpletest_automator_record(array(
22          'type' => 'drupal_get',
23          'url' => $_GET['q'],
24        ));
25      }
26      elseif (!empty($_POST) && (!isset($_GET['record']) || $_GET['record'] != 'false')) {
27        $post = $_POST;
28        unset($post['form_build_id']);
29        unset($post['form_id']);
30        $op = $post['op'];
31        unset($post['op']);
32        simpletest_automator_record(array(
33          'type' => 'drupal_post',
34          'url' => $_GET['q'],
35          'post' => $post,
36          'operation' => $op,
37        ));
38      }
39  }  }
40    
41  /**  /**
# Line 33  function simpletest_automator_proctor_me Line 51  function simpletest_automator_proctor_me
51    );    );
52    
53    return $items;    return $items;
54    }
55    
56    function simpletest_automator_record($data) {
57      global $db_prefix, $db_prefix_original;
58      $simpletest_prefix = $db_prefix;
59      $db_prefix = $db_prefix_original;
60      drupal_load('module', 'simpletest_automator');
61      $simpletest_automator_action = new StdClass();
62      $simpletest_automator_action->said = db_query("SELECT said FROM {simpletest_automator} WHERE db_prefix = '%s'", $simpletest_prefix)->fetchField();
63      $simpletest_automator_action->type = $data['type'];
64      unset($data['type']);
65      $simpletest_automator_action->parameters = $data;
66      simpletest_automator_action_save($simpletest_automator_action);
67  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2