| 1 |
<?php
|
| 2 |
|
| 3 |
// $Id: bugbits.admin.inc,v 1.1.2.9 2009/04/24 02:20:00 daften Exp $
|
| 4 |
|
| 5 |
|
| 6 |
/**
|
| 7 |
* @file
|
| 8 |
* Administration page callbacks for the bugbits module
|
| 9 |
*/
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Form builder. Configure bugbits
|
| 13 |
*
|
| 14 |
* @ingroup forms
|
| 15 |
* @see system_settings_form()
|
| 16 |
*/
|
| 17 |
function bugbits_admin_settings() {
|
| 18 |
global $base_url;
|
| 19 |
|
| 20 |
$form['bugbits_mantis_url'] = array(
|
| 21 |
'#type' => 'textfield',
|
| 22 |
'#size' => 50,
|
| 23 |
'#title' => t('Public mantis URL'),
|
| 24 |
'#required' => TRUE,
|
| 25 |
'#default_value' => variable_get('bugbits_mantis_url', $base_url . '/' . drupal_get_path('module', 'bugbits') . '/mantis'),
|
| 26 |
'#description' => t('The url where your mantis installation can be found, this should be the root path without a trailing slash and this url should be publicly accessible.')
|
| 27 |
);
|
| 28 |
|
| 29 |
$form['database'] = array(
|
| 30 |
'#type' => 'fieldset',
|
| 31 |
'#collapsible' => TRUE,
|
| 32 |
'#title' => t('Database settings for mantis'),
|
| 33 |
'#required' => TRUE,
|
| 34 |
'#description' => t('Here you can enter the database settings for mantis.')
|
| 35 |
);
|
| 36 |
$form['database']['bugbits_db_host'] = array(
|
| 37 |
'#type' => 'textfield',
|
| 38 |
'#size' => 15,
|
| 39 |
'#required' => TRUE,
|
| 40 |
'#title' => t('Database host for the mantis database'),
|
| 41 |
'#default_value' => variable_get('bugbits_db_host', 'localhost'),
|
| 42 |
'#description' => t('Give the host for the mantis database.')
|
| 43 |
);
|
| 44 |
$form['database']['bugbits_db_port'] = array(
|
| 45 |
'#type' => 'textfield',
|
| 46 |
'#size' => 5,
|
| 47 |
'#required' => TRUE,
|
| 48 |
'#title' => t('Database port for the mantis database'),
|
| 49 |
'#default_value' => variable_get('bugbits_db_port', '3306'),
|
| 50 |
'#description' => t('Give the port for the mantis database.')
|
| 51 |
);
|
| 52 |
$form['database']['bugbits_db_type'] = array(
|
| 53 |
'#type' => 'select',
|
| 54 |
'#title' => t('Database type for mantis database'),
|
| 55 |
'#required' => TRUE,
|
| 56 |
'#default_value' => variable_get('bugbits_db_type', ''),
|
| 57 |
'#options' => array(
|
| 58 |
'mysql' => t('MySql'),
|
| 59 |
'pgsql' => t('Postgresql'),
|
| 60 |
),
|
| 61 |
'#description' => t('Give the type of database in which the mantis tables are stored here.')
|
| 62 |
);
|
| 63 |
$form['database']['bugbits_table_prefix'] = array(
|
| 64 |
'#type' => 'textfield',
|
| 65 |
'#size' => 15,
|
| 66 |
'#required' => FALSE,
|
| 67 |
'#title' => t('Table prefix for mantis tables'),
|
| 68 |
'#default_value' => variable_get('bugbits_table_prefix', 'mantis_'),
|
| 69 |
'#description' => t('Give the prefix for mantis tables (commonly nothing - an empty string - or "mantis_"). If there is an underscore (or any other seperating character), it should be added here.')
|
| 70 |
);
|
| 71 |
$form['database']['bugbits_db_username'] = array(
|
| 72 |
'#type' => 'textfield',
|
| 73 |
'#size' => 15,
|
| 74 |
'#required' => TRUE,
|
| 75 |
'#title' => t('Database username for mantis database'),
|
| 76 |
'#default_value' => variable_get('bugbits_db_username', ''),
|
| 77 |
'#description' => t('Give the username for the database in which the mantis tables are stored here.')
|
| 78 |
);
|
| 79 |
$form['database']['bugbits_db_password'] = array(
|
| 80 |
'#type' => 'textfield',
|
| 81 |
'#size' => 15,
|
| 82 |
'#required' => TRUE,
|
| 83 |
'#title' => t('Database password for mantis database'),
|
| 84 |
'#default_value' => variable_get('bugbits_db_password', ''),
|
| 85 |
'#description' => t('Give the password for the database in which the mantis tables are stored here.')
|
| 86 |
);
|
| 87 |
$form['database']['bugbits_db_name'] = array(
|
| 88 |
'#type' => 'textfield',
|
| 89 |
'#size' => 15,
|
| 90 |
'#required' => TRUE,
|
| 91 |
'#title' => t('Database name for mantis database'),
|
| 92 |
'#default_value' => variable_get('bugbits_db_name', ''),
|
| 93 |
'#description' => t('Give the name for the database in which the mantis tables are stored here.')
|
| 94 |
);
|
| 95 |
|
| 96 |
return system_settings_form($form);
|
| 97 |
} // function bugbits_admin_settings
|
| 98 |
|
| 99 |
function bugbits_admin_test() {
|
| 100 |
$output = '';
|
| 101 |
|
| 102 |
// Test the database settings
|
| 103 |
$output .= '<h1>' . t('Bugbits database settings') . '</h1>';
|
| 104 |
if(!in_array(variable_get("bugbits_db_type", ''), array("mysql", "pgsql"))) {
|
| 105 |
$output .= '<p>' . t('You\'re database type is not set correctly.') . '</p>';
|
| 106 |
} else {
|
| 107 |
$output .= '<p>' . t('You\'re database type: OK.') . '</p>';
|
| 108 |
require_once 'database-common.inc';
|
| 109 |
_bugbits_db_set_active();
|
| 110 |
if(!_bugbits_db_connect(variable_get("bugbits_db_username", ''), variable_get("bugbits_db_password", ''), variable_get("bugbits_db_name", ''), variable_get('bugbits_db_host', ''), variable_get('bugbits_db_port', ''))) {
|
| 111 |
$output .= '<p>' . t('You\'re database connection settings (username, password, database name, database host, database port) are not set correctly.') . '</p>';
|
| 112 |
} else {
|
| 113 |
$output .= '<p>' . t('You\'re database connection settings (username, password, database name, database host, database port): OK.') . '</p>';
|
| 114 |
$num_users = _bugbits_db_result(_bugbits_db_query('SELECT COUNT(*) FROM {user_table}'));
|
| 115 |
if(!is_numeric($num_users) || $num_users<0) {
|
| 116 |
$output .= '<p>' . t('You\'re database prefix is not set correctly. Or you\'re using the wrong database.') . '</p>';
|
| 117 |
} else {
|
| 118 |
$output .= '<p>' . t('You\'re database prefix: OK.') . '</p>';
|
| 119 |
}
|
| 120 |
}
|
| 121 |
}
|
| 122 |
|
| 123 |
// Test the soap settings
|
| 124 |
// TODO
|
| 125 |
$output .= '<h1>' . t('Bugbits SOAP settings') . '</h1>';
|
| 126 |
$output .= '<p>' . 'To do' . '</p>';
|
| 127 |
|
| 128 |
return $output;
|
| 129 |
}
|