|
From: Jon O. <jon...@us...> - 2005-10-22 22:42:40
|
Update of /cvsroot/mxbb/mx_dev_startkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv378/modules/mx_dev_startkit Modified Files: db_install.php db_uninstall.php db_upgrade.php mx_dev_startkit.php Added Files: DevelopersStartkit.pak Log Message: adding this dev startkit module --- NEW FILE: DevelopersStartkit.pak --- module=+:60=+:Developers Startkit Module=+:modules/mx_dev_startkit/=+:Developers resource, demonstrating how to develope a mxBB module, by giving examples=+:1 New_function=+:---------------------------=+:0=+:0=+:0=+:0=+:0 function=+:60=+:104=+:DevelopersStartkitFunction=+:Startkit Function=+:mx_dev_startkit.php=+: parameter=+:104=+:349=+:startkit_test_custom=+:startkit_group_select=+:=+: parameter=+:104=+:348=+:startkit_test_number=+:Number=+:0=+: parameter=+:104=+:347=+:startkit_test_string=+:Text=+:enter a string=+: parameter=+:0=+:0=+:0=+:endoflist=+:0=+:0 block=+:=+:Demo - DevelopersStartkitFunction=+:Demo block=+:104=+:0=+:5=+:0=+:0=+:0=+:0=+:1=+:1 function=+:0=+:0=+:0=+:endoflist=+:0=+:0 Index: db_upgrade.php =================================================================== RCS file: /cvsroot/mxbb/mx_dev_startkit/db_upgrade.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_upgrade.php 22 Oct 2005 12:40:33 -0000 1.1 --- db_upgrade.php 22 Oct 2005 22:42:31 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- define( 'IN_PORTAL', true ); + if ( !defined( 'IN_ADMIN' ) ) { *************** *** 42,47 **** } ! $mx_module_version = 'mxBB - phpBB Integration Module 1.0.3'; ! $mx_module_copy = 'Based on <a href="http://www.phpbb.com/" target="_phpbb" >phpBB</a>'; $sql = array(); --- 43,48 ---- } ! $mx_module_version = 'mxBB - Developers Startkit Module 1.0'; ! $mx_module_copy = 'How to write a mxBB module? This module demonstrates by giving examples. Author: Jon'; $sql = array(); *************** *** 50,110 **** // Precheck // ! if ( $result = $db->sql_query( "SELECT config_name from " . $mx_table_prefix . "phpbb_plugin_config" ) ) { // // Upgrade checks // $upgrade_101 = 0; - $upgrade_102 = 0; - $upgrade_103 = 0; - $upgrade_104 = 0; - $upgrade_105 = 0; - $upgrade_106 = 0; - $upgrade_107 = 0; // ! // validate before 1.01 // ! $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "phpbb_plugin_config WHERE config_name = 'override_default_pages'" ); ! if ( $db->sql_numrows( $result ) == 0 ) ! { ! $upgrade_101 = 1; ! } ! ! $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "phpbb_plugin_config WHERE config_name = 'enable_module'" ); if ( $db->sql_numrows( $result ) == 0 ) { ! $upgrade_102 = 1; } - $message = "<b>Upgrading!</b><br/><br/>"; ! if ( $upgrade_101 == 1 ) ! { ! $message .= "<b>Upgrading to v. 1.01...</b><br/><br/>"; ! $sql[] = "CREATE TABLE " . $mx_table_prefix . "phpbb_plugin_config ( ! config_name VARCHAR(255) NOT NULL default '', ! config_value varchar(255) NOT NULL default '', ! PRIMARY KEY (config_name) ! ) TYPE=MyISAM"; ! ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('override_default_pages', 'Block_setup')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('faq', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('groupcp', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('index', '2')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('login', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('memberlist', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('modcp', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('posting', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('privmsg', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('profile', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('search', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewonline', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('other', '0')"; ! } ! else if ( $upgrade_102 == 1 ) { ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('enable_module', '1')"; } else --- 51,85 ---- // Precheck // ! if ( $result = $db->sql_query( "SELECT config_name from " . $mx_table_prefix . "dev_startkit_config" ) ) { // // Upgrade checks // + $upgrade_100 = 0; $upgrade_101 = 0; // ! // validate before 1.0.0 // ! $result = $db->sql_query( "SELECT config_value from " . $mx_table_prefix . "dev_startkit_config WHERE config_name = 'test1'" ); if ( $db->sql_numrows( $result ) == 0 ) { ! $upgrade_100 = 1; } $message = "<b>Upgrading!</b><br/><br/>"; ! if ( $upgrade_100 == 1 ) { ! $message .= "<b>Upgrading to v. 1.00...</b><br/><br/>"; ! ! $sql[] = "CREATE TABLE " . $mx_table_prefix . "dev_startkit_config ( ! config_name VARCHAR(255) NOT NULL default '', ! config_value varchar(255) NOT NULL default '', ! PRIMARY KEY (config_name) ! ) TYPE=MyISAM"; ! ! $sql[] = "INSERT INTO " . $mx_table_prefix . "dev_startkit_config VALUES ('startkit_config1', 'test1')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "dev_startkit_config VALUES ('startkit_config1', 'test2')"; } else Index: db_uninstall.php =================================================================== RCS file: /cvsroot/mxbb/mx_dev_startkit/db_uninstall.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_uninstall.php 22 Oct 2005 12:40:33 -0000 1.1 --- db_uninstall.php 22 Oct 2005 22:42:31 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- define( 'IN_PORTAL', true ); + if ( !defined( 'IN_ADMIN' ) ) { *************** *** 43,47 **** $sql = array( ! "DROP TABLE IF EXISTS " . $mx_table_prefix . "phpbb_plugin_config", ); --- 44,48 ---- $sql = array( ! "DROP TABLE IF EXISTS " . $mx_table_prefix . "dev_startkit_config", ); Index: db_install.php =================================================================== RCS file: /cvsroot/mxbb/mx_dev_startkit/db_install.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** db_install.php 22 Oct 2005 12:40:33 -0000 1.1 --- db_install.php 22 Oct 2005 22:42:31 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- define( 'IN_PORTAL', true ); + if ( !defined( 'IN_ADMIN' ) ) { *************** *** 42,59 **** } ! $mx_module_version = 'mxBB - phpBB Integration Module 1.0.3'; ! $mx_module_copy = 'Based on <a href="http://www.phpbb.com/" target="_phpbb">phpBB</a>'; - // If fresh install ! if ( !$result = $db->sql_query( "SELECT config_name from " . $mx_table_prefix . "phpbb_plugin_config" ) ) { $message = "<b>This is a fresh install!</b><br/><br/>"; $sql = array(); ! $sql[] = "DROP TABLE IF EXISTS " . $mx_table_prefix . "phpbb_plugin_config"; ! $sql[] = "CREATE TABLE " . $mx_table_prefix . "phpbb_plugin_config ( config_name VARCHAR(255) NOT NULL default '', config_value varchar(255) NOT NULL default '', --- 43,62 ---- } ! $mx_module_version = 'mxBB - Developers Startkit Module 1.0'; ! $mx_module_copy = 'How to write a mxBB module? This module demonstrates by giving examples. Author: Jon'; ! if ( !$result = $db->sql_query( "SELECT config_name from " . $mx_table_prefix . "dev_startkit_config" ) ) { + // + // Fresh install + // $message = "<b>This is a fresh install!</b><br/><br/>"; $sql = array(); ! $sql[] = "DROP TABLE IF EXISTS " . $mx_table_prefix . "dev_startkit_config"; ! $sql[] = "CREATE TABLE " . $mx_table_prefix . "dev_startkit_config ( config_name VARCHAR(255) NOT NULL default '', config_value varchar(255) NOT NULL default '', *************** *** 61,83 **** ) TYPE=MyISAM"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('override_default_pages', 'Block_setup')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('enable_module', '1')"; ! ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('faq', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('groupcp', '0')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('index', '2')"; ! //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewforum', '0')"; ! //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewtopic', '0')"; ! //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('modcp', '0')"; ! //$sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('posting', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('login', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('memberlist', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('privmsg', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('profile', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('search', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('viewonline', '0')"; - $sql[] = "INSERT INTO " . $mx_table_prefix . "phpbb_plugin_config VALUES ('other', '0')"; - $sql[] = "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', --- 64,70 ---- ) TYPE=MyISAM"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "dev_startkit_config VALUES ('startkit_config1', 'test1')"; ! $sql[] = "INSERT INTO " . $mx_table_prefix . "dev_startkit_config VALUES ('startkit_config2', 'test2')"; $sql[] = "UPDATE " . $mx_table_prefix . "module" . " SET module_version = '" . $mx_module_version . "', *************** *** 89,94 **** else { ! // If already installed ! $message = "<b>Module is already installed...consider upgrading ;)</b><br/><br/>"; } --- 76,83 ---- else { ! // ! // Updating ! // ! $message = "<b>Nothing to do... ;)</b><br/><br/>"; } Index: mx_dev_startkit.php =================================================================== RCS file: /cvsroot/mxbb/mx_dev_startkit/mx_dev_startkit.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mx_dev_startkit.php 22 Oct 2005 12:40:33 -0000 1.1 --- mx_dev_startkit.php 22 Oct 2005 22:42:31 -0000 1.2 *************** *** 99,102 **** --- 99,108 ---- // + // Load module constants and functions + // + include_once($mx_root_path . $mx_block->module_root_path . "includes/startkit_constants.$phpEx"); // Will load additional module lang keys, definitions, copyrights and theme data + include_once($mx_root_path . $mx_block->module_root_path . "includes/startkit_functions.$phpEx"); // Will load additional module functions (be sure to prefix with 'mx_' to avoid function conflicts) + + // // Load POST/GET vars // - When php.ini is set with Register Globals Off (highly recommended due to security), you need to declare all GET/POST vars *************** *** 111,115 **** if ( !$result = $db->sql_query( $sql ) ) { ! message_die( CRITICAL_ERROR, "Could not query config information in kb_config", "", __LINE__, __FILE__, $sql ); } else --- 117,121 ---- if ( !$result = $db->sql_query( $sql ) ) { ! message_die( CRITICAL_ERROR, "Could not query config information", "", __LINE__, __FILE__, $sql ); } else *************** *** 125,130 **** // ! // Load module block parameters // - be careful not to use too common variable names - to avoid conflicts with other blocks // // If possible, do this instead --- 131,137 ---- // ! // Load (custom) module block parameters // - be careful not to use too common variable names - to avoid conflicts with other blocks + // - additional module parameters are defined in module_root/admin/mx_module_defs.php // // If possible, do this instead *************** *** 132,144 **** // $mx_startkit_pars['test_string'] = $mx_block->get_parameters( 'startkit_test_string' ); // $mx_startkit_pars['test_number'] = $mx_block->get_parameters( 'startkit_test_number' ); // $mx_par_test_string = $mx_block->get_parameters( 'startkit_test_string' ); $mx_par_test_number = $mx_block->get_parameters( 'startkit_test_number' ); ! // ! // Load module constants and functions // ! include_once($mx_root_path . $mx_block->module_root_path . "includes/mx_module_constants.$phpEx"); // Will load additional module lang keys, definitions, copyrights and theme data ! include_once($mx_root_path . $mx_block->module_root_path . "includes/mx_module_functions.$phpEx"); // Will load additional module functions (be sure to prefix with 'mx_' to avoid function conflicts) // --- 139,158 ---- // $mx_startkit_pars['test_string'] = $mx_block->get_parameters( 'startkit_test_string' ); // $mx_startkit_pars['test_number'] = $mx_block->get_parameters( 'startkit_test_number' ); + // $mx_startkit_pars['test_custom'] = $mx_block->get_parameters( 'startkit_test_custom' ); // $mx_par_test_string = $mx_block->get_parameters( 'startkit_test_string' ); $mx_par_test_number = $mx_block->get_parameters( 'startkit_test_number' ); ! $mx_par_test_custom = $mx_block->get_parameters( 'startkit_test_custom' ); ! // ! // Get Module Name from module_id // ! $sql = "SELECT module_name FROM " . MODULE_TABLE . " WHERE module_id = " . $mx_par_test_custom; ! if ( !$result = $db->sql_query( $sql ) ) ! { ! message_die( CRITICAL_ERROR, "Could not query module information", "", __LINE__, __FILE__, $sql ); ! } ! $results = $db->sql_fetchrow( $result ); ! $startkit_module_name = $results['module_name']; // *************** *** 150,154 **** // Start output of Block // ! $template->set_filenames( array( 'body' => 'kb_index_body.tpl' )); // --- 164,168 ---- // Start output of Block // ! $template->set_filenames( array( 'body' => 'startkit_body.tpl' )); // *************** *** 170,189 **** // $template->assign_vars( array( ! 'L_STARTKIT_INFO' => $lang['Startkit_info'], 'L_TEST_STRING' => $lang['Test_string'], 'L_TEST_NUMBER' => $lang['Test_number'], - 'L_TEST_NUMBER' => $lang['Test_config1'], - 'L_TEST_NUMBER' => $lang['Test_config2'], - 'L_TEST_GET_PAR' => $lang['Test_get_par'], 'TEST_STRING' => $mx_par_test_string, 'TEST_NUMBER' => $mx_par_test_number, ! 'MANIPULATED_TEST_NUMBER' => $mx_manipulated_test_number, 'TEST_CONFIG1' => $mx_module_configs['startkit_config1'], 'TEST_CONFIG2' => $mx_module_configs['startkit_config2'], ! 'TEST_GET_PAR' => $par_test_get_par )); --- 184,226 ---- // $template->assign_vars( array( ! // ! // Titles ! // ! 'L_STARTKIT' => $lang['Startkit'], + 'L_STARTKIT_PARAMETER' => $lang['Startkit_parameter'], + 'L_STARTKIT_PARAMETER_EXPLAIN' => $lang['Startkit_parameter_explain'], 'L_TEST_STRING' => $lang['Test_string'], 'L_TEST_NUMBER' => $lang['Test_number'], + 'L_STARTKIT_PARAMETER_MODIFIED' => $lang['Startkit_parameter_modified'], + 'L_STARTKIT_PARAMETER_MODIFIED_EXPLAIN' => $lang['Startkit_parameter_modified_explain'], + 'L_TEST_MODIFIED' => $lang['Test_modified'], + + 'L_STARTKIT_PARAMETER_CUSTOM' => $lang['Startkit_parameter_custom'], + 'L_STARTKIT_PARAMETER_CUSTOM_EXPLAIN' => $lang['Startkit_parameter_custom_explain'], + 'L_TEST_CUSTOM' => $lang['Test_custom'], + + 'L_STARTKIT_CONFIG' => $lang['Startkit_config'], + 'L_STARTKIT_CONFIG_EXPLAIN' => $lang['Startkit_config_explain'], + 'L_TEST_CONFIG1' => $lang['Test_config1'], + 'L_TEST_CONFIG2' => $lang['Test_config2'], + + 'L_STARTKIT_GET' => $lang['Startkit_get'], + 'L_STARTKIT_GET_EXPLAIN' => $lang['Startkit_get_explain'], + 'L_TEST_GET' => $lang['Test_get_par'], + + // + // Values + // 'TEST_STRING' => $mx_par_test_string, 'TEST_NUMBER' => $mx_par_test_number, ! 'TEST_MODIFIED' => $mx_manipulated_test_number, ! 'TEST_CUSTOM' => $startkit_module_name, 'TEST_CONFIG1' => $mx_module_configs['startkit_config1'], 'TEST_CONFIG2' => $mx_module_configs['startkit_config2'], ! 'TEST_GET' => $test_get_var )); |