Seite 1 von 1

MOD Install-Datei

Verfasst: 14.11.2013 20:35
von waldkatze
Ich bastele gerade an einer Install-Datei für einen kleinen MOD.
Das ist der derzeitige Stand:

Code: Alles auswählen

<?php
$versions = array(
    '0.1.0' => array(
        // Tabelle TEST_CONFIG 
        'table_add' => array(
            array('phpbb_test_config', array(
                'COLUMNS'    => array(
                    'name'    => array('UINT:2', 0),   
                    'value'    => array('VCHAR', ),    
                    'aktiv'    => array('UINT:1', 0),   
                ),
            )),
          ),
        //  Bis hier OK, Tabelle wird richtig angelegt
            
        'table_row_insert' => array(
            array('phpbb_test_config', array(
                // Hier komme ich nicht weiter !
            ),
        ),
    ),
    
 // ACP-Modul erstellen (OK)            
        'module_add' => array(
            array('acp', 'ACP_CAT_DOT_MODS', 'ACP_TEST'),
            array('acp', 'ACP_TEST', array(
                'module_basename'  => 'test',
                'modes'   => array('settings'),
            )),
            array('acp', 'ACP_TEST', array(
                'module_basename'  => 'test',
                'modes'   => array('cats'),
            )),
        ),
        
        // Cache leeren (OK)
        'cache_purge' => array(
            'template',
            'theme',
            'cache',
        ),
    ),    
);

include($phpbb_root_path . 'umil/umil_auto.' . $phpEx);

?>
Dieser Befehl müsste jetzt noch in die Tabelle TEST_CONFIG rein.

Code: Alles auswählen

INSERT INTO `phpbb_test_config` (`name`, `value`, `aktiv`) VALUES
	    (1, '', 1),
	    (2, '', 1),
	    (3, '', 1),
	    (4, '', 1),
	    (5, '', 1),
	    (6, '', 1),
	    (7, '', 1),
	    (8, '', 1),
	    (9, '', 1),
	    (10, '', 1);
Kann hier jemand bitte weiterhelfen ?

Re: MOD Install-Datei

Verfasst: 14.11.2013 22:19
von Helmut
Hallo waldkatze,

ich würde es so machen

Code: Alles auswählen

<?php
$versions = array(
    '0.1.0' => array(
        // Tabelle TEST_CONFIG 
        'table_add' => array(
            array('phpbb_test_config', array(
                'COLUMNS'    => array(
                    'name'    => array('UINT:2', 0),   
                    'value'    => array('VCHAR', ),    
                    'aktiv'    => array('UINT:1', 0),   
                ),
            )),
          ),
        //  Bis hier OK, Tabelle wird richtig angelegt
            
    'table_row_insert' => array(
        array('phpbb_test_config', 
             array('config_name' => '1', 'config_value' => '', 'config_aktiv' => '1'),
             array('config_name' => '2', 'config_value' => '', 'config_aktiv' => '1'),
             array('config_name' => '3', 'config_value' => '', 'config_aktiv' => '1'),
             array('config_name' => '3', 'config_value' => '', 'config_aktiv' => '1'),
             //usw.        
        ),
    ), 
),
    
 // ACP-Modul erstellen (OK)            
        'module_add' => array(
            array('acp', 'ACP_CAT_DOT_MODS', 'ACP_TEST'),
            array('acp', 'ACP_TEST', array(
                'module_basename'  => 'test',
                'modes'   => array('settings'),
            )),
            array('acp', 'ACP_TEST', array(
                'module_basename'  => 'test',
                'modes'   => array('cats'),
            )),
        ),
        
        // Cache leeren (OK)
        'cache_purge' => array(
            'template',
            'theme',
            'cache',
        ),
    ),    
);

include($phpbb_root_path . 'umil/umil_auto.' . $phpEx);

?>

Gruß Helmut

Re: MOD Install-Datei

Verfasst: 14.11.2013 22:49
von Crizzo
Hi,

kennst du schon UMIL: https://www.phpbb.com/mods/umil/ ?

Grüße

Re: MOD Install-Datei

Verfasst: 14.11.2013 23:31
von waldkatze
Erst mal vielen Dank für eure Hilfe.
Allerdings fügt er bis jetzt nur die erste Zeile ein, keine weiteren.

Code: Alles auswählen

'table_row_insert' => array(
        array('phpbb_test_config', 
            array('config_name' => '1', 'config_value' => '', 'config_aktiv' => '1'), // SQL ERROR Unknown column 'config_name' in 'field list'
            
            // Wenn ich so schreibe
            array('name' => '1', 'value' => '', 'aktiv' => '1'), // OK wird eingefügt
            array('name' => '2', 'value' => '', 'aktiv' => '1'), // wird nicht eingefügt
            array('name' => '3', 'value' => '', 'aktiv' => '1'), // wird nicht eingefügt
            // usw.
                
            ),
        ),
//    ),  Diese Klammer muss weg, sonst Fehler  

Re: MOD Install-Datei

Verfasst: 15.11.2013 18:00
von waldkatze
Ich habe das jetzt selbst lösen können. Jetzt geht das.
Da fehlte 1x array( damit weitere Zeilen eingefügt werden.
Hier mal der gesamte Install-Code für alle die das interessiert oder weiterhilft.

Code: Alles auswählen

<?php
/**
*
* @package phpBB3 TEST-MOD [INSTALL]
* @author waldkatze
* @package download mod installation package based on umil (c) 2008 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
define('UMIL_AUTO', true);
define('IN_PHPBB', true);

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx);

$user->session_begin();
$auth->acl($user->data);
$user->setup();
$user->add_lang('mods/info_acp_test');

if (!file_exists($phpbb_root_path . 'umil/umil_auto.' . $phpEx))
{
    trigger_error('Please download the latest UMIL (Unified MOD Install Library) from: <a href="http://www.phpbb.com/mods/umil/">phpBB.com/mods/umil</a>', E_USER_ERROR);
}

// The name of the mod to be displayed during installation.
$mod_name = 'Test_MOD';

/*
* The name of the config variable which will hold the currently installed version
* You do not need to set this yourself, UMIL will handle setting and updating the version itself.
*/
$version_config_name = 'test_version';

/*
* The language file which will be included when installing
* Language entries that should exist in the language file for UMIL (replace $mod_name with the mod's name you set to $mod_name above)
* $mod_name
* 'INSTALL_' . $mod_name
* 'INSTALL_' . $mod_name . '_CONFIRM'
* 'UPDATE_' . $mod_name
* 'UPDATE_' . $mod_name . '_CONFIRM'
* 'UNINSTALL_' . $mod_name
* 'UNINSTALL_' . $mod_name . '_CONFIRM'
*/

/*
* The array of versions and actions within each.
* You do not need to order it a specific way (it will be sorted automatically), however, you must enter every version, even if no actions are done for it.
*
* You must use correct version numbering.  Unless you know exactly what you can use, only use X.X.X (replacing X with an integer).
* The version numbering must otherwise be compatible with the version_compare function - http://php.net/manual/en/function.version-compare.php
*/
$versions = array(
    '0.1.0' => array(
        // Tabelle TEST (OK)
        'table_add' => array(
            array('phpbb_test', array(  
                'COLUMNS'            => array(
                    'test_id'            => array('UINT:11', NULL, 'auto_increment'), 
                    'test_name'            => array('VCHAR', ),  
                    'test_homepage'        => array('VCHAR', ),  
                    'test_maps_l'        => array('VCHAR', ),  
                    'test_maps_b'        => array('VCHAR', ),   
                    'message'            => array('TEXT', ''), 
                    'bbcode_uid'        => array('VCHAR:8', ''),                    
                    'bbcode_bitfield'    => array('VCHAR', ''),    
                    'bbcode_options'    => array('VCHAR', ''),    
                    'enable_magic_url'  => array('TINT:1', NULL),
                    'enable_smilies'    => array('TINT:1', NULL),    
                    'enable_bbcode'        => array('TINT:1', NULL),  
                    'test_user'            => array('UINT', 0),         
                ),
                'PRIMARY_KEY' => array('test_id'),
                'KEYS'          => array('test_user' => array('INDEX', 'test_user'), 
                ),
            ),
        ),
        
        //  Tabelle TEST_CONFIG (OK) 
            array('phpbb_test_config', array(
                'COLUMNS'    => array(
                    'name'    => array('UINT:2', 0),   
                    'value'    => array('VCHAR', ),    
                    'aktiv'    => array('UINT:1', 0),      
                ),
            )),
          ),
        
        //  Einfügen in Tabelle TEST_CONFIG (OK)
        'table_row_insert' => array(
            array('phpbb_test_config', array(
            array('name' => '1', 'value' => '', 'aktiv' => '1'), 
            array('name' => '2', 'value' => '', 'aktiv' => '1'), 
            array('name' => '3', 'value' => '', 'aktiv' => '1'), 
            array('name' => '4', 'value' => '', 'aktiv' => '1'), 
            // usw.
            ),
        ),    
    ),
        
        // ACP-Modul erstellen (OK)            
        'module_add' => array(
            array('acp', 'ACP_CAT_DOT_MODS', 'ACP_TEST'),
            array('acp', 'ACP_TEST', array(
                'module_basename'  => 'test',
                'modes'   => array('settings'),
            )),
            array('acp', 'ACP_TEST', array(
                'module_basename'  => 'test',
                'modes'   => array('cats'),
            )),
        ),
        
        // Cache leeren (OK)
        'cache_purge' => array(
            'template',
            'theme',
            'cache',
        ),
    ),    
);

// Include the UMIF Auto file and everything else will be handled automatically.
include($phpbb_root_path . 'umil/umil_auto.' . $phpEx);

?>
Noch mal besonderen Dank an Helmut. Das war der entscheidende Tipp :grin: