| 46 |
'#size' => 40, |
'#size' => 40, |
| 47 |
); |
); |
| 48 |
$form['submit'] = array( |
$form['submit'] = array( |
| 49 |
'#type' => 'submit', |
'#type' => 'submit', |
| 50 |
'#value' => t('Import'), |
'#value' => t('Import'), |
| 51 |
); |
); |
| 52 |
return $form; |
return $form; |
| 358 |
// Use temporary files directory with the same prefix as database. |
// Use temporary files directory with the same prefix as database. |
| 359 |
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix); |
variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix); |
| 360 |
file_check_directory(file_directory_path(), TRUE); // Create the files directory. |
file_check_directory(file_directory_path(), TRUE); // Create the files directory. |
| 361 |
|
|
| 362 |
foreach (module_implements('perm', FALSE, TRUE) as $module) { |
foreach (module_implements('perm', FALSE, TRUE) as $module) { |
| 363 |
$form_state['storage']['permissions'][$module] = module_invoke($module, 'perm'); |
$form_state['storage']['permissions'][$module] = module_invoke($module, 'perm'); |
| 364 |
} |
} |
| 429 |
$form[$key]['#type'] = 'textfield'; |
$form[$key]['#type'] = 'textfield'; |
| 430 |
} |
} |
| 431 |
$form['submit'] = array( |
$form['submit'] = array( |
| 432 |
'#type' => 'submit', |
'#type' => 'submit', |
| 433 |
'#value' => t('Save'), |
'#value' => t('Save'), |
| 434 |
); |
); |
| 435 |
drupal_add_js(drupal_get_path('module', 'simpletest_automator') . '/simpletest_automator.admin.js'); |
drupal_add_js(drupal_get_path('module', 'simpletest_automator') . '/simpletest_automator.admin.js'); |
| 466 |
} |
} |
| 467 |
if (count($simpletest_automator->actions) > 1) { |
if (count($simpletest_automator->actions) > 1) { |
| 468 |
$form['submit'] = array( |
$form['submit'] = array( |
| 469 |
'#type' => 'submit', |
'#type' => 'submit', |
| 470 |
'#value' => t('Save'), |
'#value' => t('Save'), |
| 471 |
); |
); |
| 472 |
} |
} |
| 593 |
return confirm_form($form, t('Are you sure you want to delete %action', array('%action' => $info['label'])), 'admin/build/simpletest_automator/'. $simpletest_automator->said .'/actions'); |
return confirm_form($form, t('Are you sure you want to delete %action', array('%action' => $info['label'])), 'admin/build/simpletest_automator/'. $simpletest_automator->said .'/actions'); |
| 594 |
} |
} |
| 595 |
|
|
| 596 |
function simpletest_automator_admin_record($simpletest_automator, $sure = FALSE) { |
function simpletest_automator_admin_record($form_state, $simpletest_automator) { |
| 597 |
if ($sure == '1') { |
$form = array(); |
| 598 |
$_COOKIE['simpletest_automator'] = $simpletest_automator->db_prefix; |
|
| 599 |
drupal_goto('<front>'); |
$form['said'] = array( |
| 600 |
|
'#type' => 'value', |
| 601 |
|
'#value' => $simpletest_automator->said, |
| 602 |
|
); |
| 603 |
|
|
| 604 |
|
return confirm_form($form, t('Are you sure you want to enter record mode?'), 'admin/build/simpletest_automator', t('Once in record mode, you can exit by clicking the "Stop recording" button at the top of the page.'), t('Record'), t('Cancel')); |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
function simpletest_automator_admin_record_submit($form, &$form_state) { |
| 608 |
|
global $db_prefix; |
| 609 |
|
$simpletest_automator = simpletest_automator_load($form_state['values']['said'], TRUE); |
| 610 |
|
$db_prefix = $simpletest_automator->db_prefix; |
| 611 |
|
setcookie('simpletest_automator', $simpletest_automator->db_prefix, 0, base_path()); |
| 612 |
|
// Create new role. |
| 613 |
|
db_query("INSERT INTO {role} (name) VALUES ('%s')", _simpletest_automator_random_name()); |
| 614 |
|
$rid = db_last_insert_id('role', 'rid'); |
| 615 |
|
foreach ($simpletest_automator->permissions as $permission) { |
| 616 |
|
db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", $rid, $permission); |
| 617 |
} |
} |
| 618 |
else { |
$edit = array(); |
| 619 |
// TODO: Better text |
$edit['name'] = _simpletest_automator_random_name(); |
| 620 |
return t('To record, please click <a href="!url">here</a>.', array('!url' => url('admin/build/simpletest_automator/'. $simpletest_automator->said .'/record/1'))); |
$edit['mail'] = $edit['name'] . '@example.com'; |
| 621 |
|
$edit['roles'] = array($rid => $rid); |
| 622 |
|
$edit['pass'] = user_password(); |
| 623 |
|
$edit['status'] = 1; |
| 624 |
|
$account = user_save('', $edit); |
| 625 |
|
drupal_function_exists('user_logout'); |
| 626 |
|
$GLOBALS['user'] = $account; |
| 627 |
|
|
| 628 |
|
drupal_goto('<front>'); |
| 629 |
|
} |
| 630 |
|
|
| 631 |
|
/** |
| 632 |
|
* Helper function for simpletest_automator_admin_record_submit(). |
| 633 |
|
*/ |
| 634 |
|
function _simpletest_automator_random_name($number = 4, $prefix = 'simpletest_') { |
| 635 |
|
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; |
| 636 |
|
for ($x = 0; $x < $number; $x++) { |
| 637 |
|
$prefix .= $chars{mt_rand(0, strlen($chars) - 1)}; |
| 638 |
|
if ($x == 0) { |
| 639 |
|
$chars .= '0123456789'; |
| 640 |
|
} |
| 641 |
} |
} |
| 642 |
|
return $prefix; |
| 643 |
} |
} |
| 644 |
|
|
| 645 |
function simpletest_automator_admin_export($simpletest_automator, $type = NULL) { |
function simpletest_automator_admin_export($simpletest_automator, $type = NULL) { |
| 654 |
switch ($type) { |
switch ($type) { |
| 655 |
case 'file': |
case 'file': |
| 656 |
return '<iframe src="'. url('simpletest_automator/export/' . $simpletest_automator->said) . '" width="1" height="1" style="border:0"></iframe>'. t('Your download should begin immediately. If it doesn\'t, click <a href="!url">here</a>.', array('!url' => url('simpletest_automator/export/' . $simpletest_automator->said))); |
return '<iframe src="'. url('simpletest_automator/export/' . $simpletest_automator->said) . '" width="1" height="1" style="border:0"></iframe>'. t('Your download should begin immediately. If it doesn\'t, click <a href="!url">here</a>.', array('!url' => url('simpletest_automator/export/' . $simpletest_automator->said))); |
| 657 |
|
|
| 658 |
case 'import': |
case 'import': |
| 659 |
return drupal_get_form('simpletest_automator_export_php', $simpletest_automator); |
return drupal_get_form('simpletest_automator_export_php', $simpletest_automator); |
| 660 |
|
|
| 661 |
default: |
default: |
| 662 |
return drupal_not_found(); |
return drupal_not_found(); |
| 663 |
|
|
| 664 |
} |
} |
| 665 |
} |
} |
| 666 |
return $form; |
return $form; |
| 729 |
// Add the description, along with any dependencies. |
// Add the description, along with any dependencies. |
| 730 |
$description .= drupal_render($module['description']); |
$description .= drupal_render($module['description']); |
| 731 |
if ($module['#dependencies']) { |
if ($module['#dependencies']) { |
| 732 |
$description .= '<div class="admin-dependencies">' . t('Depends on: ') . implode(', ', $module['#dependencies']) . '</div>'; |
$description .= '<div class="admin-dependencies">' . t('Depends on: ') . implode(', ', $module['#dependencies']) . '</div>'; |
| 733 |
} |
} |
| 734 |
if ($module['#dependents']) { |
if ($module['#dependents']) { |
| 735 |
$description .= '<div class="admin-dependencies">' . t('Required by: ') . implode(', ', $module['#dependents']) . '</div>'; |
$description .= '<div class="admin-dependencies">' . t('Required by: ') . implode(', ', $module['#dependents']) . '</div>'; |
| 736 |
} |
} |
| 737 |
$row[] = array('data' => $description, 'class' => 'description'); |
$row[] = array('data' => $description, 'class' => 'description'); |
| 738 |
$rows[] = $row; |
$rows[] = $row; |