reworked config file to work with drupal and added extra config fields to the configuration form in the module

This commit is contained in:
Quitta 2013-09-02 16:23:07 +02:00
parent ef61212038
commit ebc2c1c144
2 changed files with 127 additions and 46 deletions

View file

@ -1,5 +1,4 @@
<?php <?php
echo "config";
// This file contains all variables needed by other php scripts // This file contains all variables needed by other php scripts
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// Variables for database access // Variables for database access
@ -7,29 +6,29 @@ echo "config";
// where we can find the mysql database // where we can find the mysql database
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------
$cfg['db']['web']['host'] = 'localhost'; $cfg['db']['web']['host'] = variable_get('ryzommanage_webserverurl', 'localhost');
$cfg['db']['web']['port'] = '3306'; $cfg['db']['web']['port'] = variable_get('ryzommanage_webmysqlport', '3306');
$cfg['db']['web']['name'] = 'ryzom_ams'; $cfg['db']['web']['name'] = variable_get('ryzommanage_webdbname', 'ryzom_ams');
$cfg['db']['web']['user'] = 'shard'; $cfg['db']['web']['user'] = variable_get('ryzommanage_webusername', 'shard');
$cfg['db']['web']['pass'] = ''; $cfg['db']['web']['pass'] = variable_get('ryzommanage_webpassword', '');
$cfg['db']['lib']['host'] = 'localhost'; $cfg['db']['lib']['host'] = variable_get('ryzommanage_libserverurl', 'localhost');
$cfg['db']['lib']['port'] = '3306'; $cfg['db']['lib']['port'] = variable_get('ryzommanage_libmysqlport', '3306');
$cfg['db']['lib']['name'] = 'ryzom_ams_lib'; $cfg['db']['lib']['name'] = variable_get('ryzommanage_libdbname', 'ryzom_ams_lib');
$cfg['db']['lib']['user'] = 'shard'; $cfg['db']['lib']['user'] = variable_get('ryzommanage_libusername', 'shard');
$cfg['db']['lib']['pass'] = ''; $cfg['db']['lib']['pass'] = variable_get('ryzommanage_libpassword', '');
$cfg['db']['shard']['host'] = 'localhost'; $cfg['db']['shard']['host'] = variable_get('ryzommanage_shardserverurl', 'localhost');
$cfg['db']['shard']['port'] = '3306'; $cfg['db']['shard']['port'] = variable_get('ryzommanage_shardmysqlport', '3306');
$cfg['db']['shard']['name'] = 'nel'; $cfg['db']['shard']['name'] = variable_get('ryzommanage_sharddbname', 'nel');
$cfg['db']['shard']['user'] = 'shard'; $cfg['db']['shard']['user'] = variable_get('ryzommanage_shardusername', 'shard');
$cfg['db']['shard']['pass'] = ''; $cfg['db']['shard']['pass'] = variable_get('ryzommanage_shardpassword', '');
$cfg['db']['ring']['host'] = 'localhost'; $cfg['db']['ring']['host'] = variable_get('ryzommanage_ringserverurl', 'localhost');
$cfg['db']['ring']['port'] = '3306'; $cfg['db']['ring']['port'] = variable_get('ryzommanage_ringmysqlport', '3306');
$cfg['db']['ring']['name'] = 'ring_open'; $cfg['db']['ring']['name'] = variable_get('ryzommanage_ringdbname', 'ring_open');
$cfg['db']['ring']['user'] = 'shard'; $cfg['db']['ring']['user'] = variable_get('ryzommanage_ringusername', 'shard');
$cfg['db']['ring']['pass'] = ''; $cfg['db']['ring']['pass'] = variable_get('ryzommanage_ringpassword', '');
// To connect to an IMAP server running on port 143 on the local machine, // To connect to an IMAP server running on port 143 on the local machine,
// do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password"); // do the following: $mbox = imap_open("{localhost:143}INBOX", "user_id", "password");
@ -54,13 +53,14 @@ $TICKET_MAILING_SUPPORT = true;
//You have to create this dir at first! //You have to create this dir at first!
$MAIL_DIR = "/tmp/mail"; $MAIL_DIR = "/tmp/mail";
$TOS_URL ="http://createyourtos.com";
$MAIL_LOG_PATH = "/tmp/mail/cron_mail.log"; $MAIL_LOG_PATH = "/tmp/mail/cron_mail.log";
$cfg['crypt']['key'] = 'Sup3rS3cr3tStuff'; $cfg['crypt']['key'] = 'Sup3rS3cr3tStuff';
$cfg['crypt']['enc_method'] = 'AES-256-CBC'; $cfg['crypt']['enc_method'] = 'AES-256-CBC';
$cfg['crypt']['hash_method'] = "SHA512"; $cfg['crypt']['hash_method'] = "SHA512";
$TOS_URL = variable_get('ryzommanage_TOS', 'www.mytosurlhere.com');
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------
// If true= the server will add automatically unknown user in the database // If true= the server will add automatically unknown user in the database
// (in nel.user= nel.permission= ring.ring_user and ring.characters // (in nel.user= nel.permission= ring.ring_user and ring.characters

View file

@ -10,11 +10,12 @@ menu items that do stuff
*/ */
module_load_include('php', 'ryzommanage', 'config');
module_load_include('php', 'ryzommanage', 'ams_lib/libinclude'); global $TOS_URL;
global $MAIL_DIR; global $cfg;
echo $MAIL_DIR; include 'ams_lib/libinclude.php';
echo "booo"; include 'config.php';
/* /*
Drupal 7 ryzom core module Drupal 7 ryzom core module
@ -53,46 +54,125 @@ function ryzommanage_admin()
{ {
$form = array(); $form = array();
//admin menu items //admin menu items
global $cfg;
$form['ryzommanage_shardserverurl'] = array(
//$path = drupal_get_path('module', 'ryzommanage');
//require($path . '/config.php');
$form['ryzommanage_serverurl'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Server url'), '#title' => t('Shard server url'),
'#default_value' => $cfg['db']['lib']['name'],//variable_get('ryzommanage_serverurl', 'localhost'), '#default_value' => $cfg['db']['shard']['host'],
'#description' => t("The url of the ryzom server to integrate with."), '#description' => t("The url of the ryzom server to integrate with."),
'#required' => TRUE '#required' => TRUE
); );
$form['ryzommanage_mysqlport'] = array( $form['ryzommanage_shardmysqlport'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Port for MySQL'), '#title' => t('Port for MySQL of the Shard'),
'#size' => 5, '#size' => 5,
'#maxlength' => 5, '#maxlength' => 5,
'#default_value' => variable_get('ryzommanage_mysqlport', '3306'), '#default_value' => $cfg['db']['shard']['port'],
'#description' => t("The MySQL port of the ryzom server to integrate with."), '#description' => t("The MySQL port of the ryzom server to integrate with."),
'#required' => TRUE, '#required' => TRUE,
'#element_validate' => array( '#element_validate' => array(
'_check_port_value' '_check_port_value'
) )
); );
$form['ryzommanage_dbname'] = array( $form['ryzommanage_sharddbname'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Database Name'), '#title' => t('Shard Database Name'),
'#default_value' => variable_get('ryzommanage_dbname', 'nel'), '#default_value' => $cfg['db']['shard']['name'],
'#description' => t("The MySQL database name to connect to."), '#description' => t("The MySQL database name to connect to."),
'#required' => TRUE '#required' => TRUE
); );
$form['ryzommanage_username'] = array( $form['ryzommanage_shardusername'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('MySQL Username'), '#title' => t('Shard MySQL Username'),
'#default_value' => variable_get('ryzommanage_username', 'root'), '#default_value' => $cfg['db']['shard']['user'],
'#description' => t("The MySQL username to connect with."), '#description' => t("The MySQL username to connect with."),
'#required' => TRUE '#required' => TRUE
); );
$form['ryzommanage_password'] = array( $form['ryzommanage_shardpassword'] = array(
'#type' => 'password_confirm', '#type' => 'password_confirm',
'#title' => t('MySQL Password'), '#title' => t('Shard MySQL Password'),
'#description' => t("Confirm the MySQL password."),
'#suffix' => '<hr/>'
);
$form['ryzommanage_libserverurl'] = array(
'#type' => 'textfield',
'#title' => t('Lib server url'),
'#default_value' => $cfg['db']['lib']['host'],
'#description' => t("The url of the ryzom's lib db to integrate with."),
'#required' => TRUE
);
$form['ryzommanage_libmysqlport'] = array(
'#type' => 'textfield',
'#title' => t('Port for MySQL of the Lib'),
'#size' => 5,
'#maxlength' => 5,
'#default_value' => $cfg['db']['lib']['port'],
'#description' => t("The MySQL port of the ryzom's lib db to integrate with."),
'#required' => TRUE,
'#element_validate' => array(
'_check_port_value'
)
);
$form['ryzommanage_libdbname'] = array(
'#type' => 'textfield',
'#title' => t('Lib Database Name'),
'#default_value' => $cfg['db']['lib']['name'],
'#description' => t("The MySQL database name to connect to."),
'#required' => TRUE
);
$form['ryzommanage_libusername'] = array(
'#type' => 'textfield',
'#title' => t('Lib MySQL Username'),
'#default_value' => $cfg['db']['lib']['user'],
'#description' => t("The MySQL username to connect with."),
'#required' => TRUE
);
$form['ryzommanage_libpassword'] = array(
'#type' => 'password_confirm',
'#title' => t('Lib MySQL Password'),
'#description' => t("Confirm the MySQL password."),
'#suffix' => '<hr/>'
);
$form['ryzommanage_ringserverurl'] = array(
'#type' => 'textfield',
'#title' => t('Ring server url'),
'#default_value' => $cfg['db']['ring']['host'],
'#description' => t("The url of the ryzom's ring db to integrate with."),
'#required' => TRUE
);
$form['ryzommanage_ringmysqlport'] = array(
'#type' => 'textfield',
'#title' => t('Port for MySQL of the Lib'),
'#size' => 5,
'#maxlength' => 5,
'#default_value' => $cfg['db']['ring']['port'],
'#description' => t("The MySQL port of the ryzom ring db to integrate with."),
'#required' => TRUE,
'#element_validate' => array(
'_check_port_value'
)
);
$form['ryzommanage_ringdbname'] = array(
'#type' => 'textfield',
'#title' => t('Ring Database Name'),
'#default_value' => $cfg['db']['ring']['name'],
'#description' => t("The MySQL database name to connect to."),
'#required' => TRUE
);
$form['ryzommanage_ringusername'] = array(
'#type' => 'textfield',
'#title' => t('Ring MySQL Username'),
'#default_value' => $cfg['db']['ring']['user'],
'#description' => t("The MySQL username to connect with."),
'#required' => TRUE
);
$form['ryzommanage_ringpassword'] = array(
'#type' => 'password_confirm',
'#title' => t('Ring MySQL Password'),
'#description' => t("Confirm the MySQL password.") '#description' => t("Confirm the MySQL password.")
); );
return system_settings_form($form); return system_settings_form($form);
@ -195,6 +275,7 @@ function ryzommanage_menu()
return $items; return $items;
} }
function name_registration_admin_settings() { function name_registration_admin_settings() {
global $TOS_URL;
$form = array(); $form = array();
$form['ryzommanage_game-name'] = array( $form['ryzommanage_game-name'] = array(
'#type' => 'textfield', '#type' => 'textfield',
@ -207,7 +288,7 @@ function name_registration_admin_settings() {
$form['ryzommanage_TOS'] = array( $form['ryzommanage_TOS'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Terms of Service URL'), '#title' => t('Terms of Service URL'),
'#default_value' => variable_get('ryzommanage_TOS', ''), '#default_value' => $TOS_URL,
'#description' => t("The url of the TOS for your server."), '#description' => t("The url of the TOS for your server."),
'#required' => TRUE '#required' => TRUE
); );