Vergleich inc/plugins/hello.php - 1.8.7 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 13Zeile 13
{
die('This file cannot be accessed directly.');
}

{
die('This file cannot be accessed directly.');
}

	



// cache templates - this is important when it comes to performance
// THIS_SCRIPT is defined by some of the MyBB scripts, including index.php
if(defined('THIS_SCRIPT'))

// cache templates - this is important when it comes to performance
// THIS_SCRIPT is defined by some of the MyBB scripts, including index.php
if(defined('THIS_SCRIPT'))

Zeile 74Zeile 74
	return array(
'name' => 'Hello World!',
'description' => $lang->hello_desc,

	return array(
'name' => 'Hello World!',
'description' => $lang->hello_desc,

		'website'		=> 'http://mybb.com',

		'website'		=> 'https://mybb.com',

		'author'		=> 'MyBB Group',

		'author'		=> 'MyBB Group',

		'authorsite'	=> 'http://www.mybb.com',

		'authorsite'	=> 'https://mybb.com',

		'version'		=> '2.0',
'compatibility' => '18*',
'codename' => 'hello'

		'version'		=> '2.0',
'compatibility' => '18*',
'codename' => 'hello'

Zeile 204Zeile 204
			}
}
// Create

			}
}
// Create

		else

		else

		{
$db->insert_query('templates', $template);
}

		{
$db->insert_query('templates', $template);
}

Zeile 215Zeile 215

// Remove no longer used templates.
foreach($templates as $name => $row)


// Remove no longer used templates.
foreach($templates as $name => $row)

	{

	{

		$db->delete_query('templates', "title='{$db->escape_string($name)}'");
}


		$db->delete_query('templates', "title='{$db->escape_string($name)}'");
}


Zeile 245Zeile 245

$gid = (int)$db->insert_query('settinggroups', $group);
}


$gid = (int)$db->insert_query('settinggroups', $group);
}





	// Deprecate all the old entries.
$db->update_query('settings', array('description' => 'HELLODELETEMARKER'), "gid='{$gid}'");

// add settings
$settings = array(
'display1' => array(

	// Deprecate all the old entries.
$db->update_query('settings', array('description' => 'HELLODELETEMARKER'), "gid='{$gid}'");

// add settings
$settings = array(
'display1' => array(

		'optionscode'	=> 'yesno',

		'optionscode'	=> 'yesno',

		'value'			=> 1
),
'display2' => array(

		'value'			=> 1
),
'display2' => array(

Zeile 318Zeile 318

// Delete deprecated entries.
$db->delete_query('settings', "gid='{$gid}' AND description='HELLODELETEMARKER'");


// Delete deprecated entries.
$db->delete_query('settings', "gid='{$gid}' AND description='HELLODELETEMARKER'");

	



	// This is required so it updates the settings.php file as well and not only the database - they must be synchronized!
rebuild_settings();

	// This is required so it updates the settings.php file as well and not only the database - they must be synchronized!
rebuild_settings();





	// Include this file because it is where find_replace_templatesets is defined

	// Include this file because it is where find_replace_templatesets is defined

	require_once MYBB_ROOT.'inc/adminfunctions_templates.php';


	require_once MYBB_ROOT.'inc/adminfunctions_templates.php';


	// Edit the index template and add our variable to above {$forums}
find_replace_templatesets('index', '#'.preg_quote('{$forums}').'#', "{\$hello}\n{\$forums}");
}

	// Edit the index template and add our variable to above {$forums}
find_replace_templatesets('index', '#'.preg_quote('{$forums}').'#', "{\$hello}\n{\$forums}");
}

Zeile 339Zeile 339
function hello_deactivate()
{
require_once MYBB_ROOT.'inc/adminfunctions_templates.php';

function hello_deactivate()
{
require_once MYBB_ROOT.'inc/adminfunctions_templates.php';

	



	// remove template edits
find_replace_templatesets('index', '#'.preg_quote('{$hello}').'#', '');
}

	// remove template edits
find_replace_templatesets('index', '#'.preg_quote('{$hello}').'#', '');
}

Zeile 354Zeile 354
{
global $db;


{
global $db;


	// Create our entries table

	// Create our table collation

	$collation = $db->build_create_table_collation();


	$collation = $db->build_create_table_collation();


	// create table if it doesn't exist already

	// Create table if it doesn't exist already

	if(!$db->table_exists('hello_messages'))
{

	if(!$db->table_exists('hello_messages'))
{

		$db->write_query("CREATE TABLE `".TABLE_PREFIX."hello_messages` (
`mid` int(10) UNSIGNED NOT NULL auto_increment,
`message` varchar(100) NOT NULL default '',
PRIMARY KEY (`mid`)
) ENGINE=MyISAM{$collation}");
}
}




















		switch($db->type)
{
case "pgsql":
$db->write_query("CREATE TABLE ".TABLE_PREFIX."hello_messages (
mid serial,
message varchar(100) NOT NULL default '',
PRIMARY KEY (mid)
);");
break;
case "sqlite":
$db->write_query("CREATE TABLE ".TABLE_PREFIX."hello_messages (
mid INTEGER PRIMARY KEY,
message varchar(100) NOT NULL default ''
);");
break;
default:
$db->write_query("CREATE TABLE ".TABLE_PREFIX."hello_messages (
mid int unsigned NOT NULL auto_increment,
message varchar(100) NOT NULL default '',
PRIMARY KEY (mid)
) ENGINE=MyISAM{$collation};");
break;
}
}
}


/*
* _is_installed():
* Called on the plugin management page to establish if a plugin is already installed or not.

/*
* _is_installed():
* Called on the plugin management page to establish if a plugin is already installed or not.

Zeile 381Zeile 399
	// If the table exists then it means the plugin is installed because we only drop it on uninstallation
return $db->table_exists('hello_messages');
}

	// If the table exists then it means the plugin is installed because we only drop it on uninstallation
return $db->table_exists('hello_messages');
}





/*
* _uninstall():
* Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin

/*
* _uninstall():
* Called whenever a plugin is to be uninstalled. This should remove ALL traces of the plugin

Zeile 390Zeile 408
function hello_uninstall()
{
global $db, $mybb;

function hello_uninstall()
{
global $db, $mybb;





	if($mybb->request_method != 'post')
{
global $page, $lang;
$lang->load('hello');

	if($mybb->request_method != 'post')
{
global $page, $lang;
$lang->load('hello');





		$page->output_confirm_action('index.php?module=config-plugins&action=deactivate&uninstall=1&plugin=hello', $lang->hello_uninstall_message, $lang->hello_uninstall);

		$page->output_confirm_action('index.php?module=config-plugins&action=deactivate&uninstall=1&plugin=hello', $lang->hello_uninstall_message, $lang->hello_uninstall);

	}

// remove our templates group
// Query the template groups
$query = $db->simple_select('templategroups', 'prefix', "prefix='hello'");

// Build where string for templates
$sqlwhere = array();

while($prefix = $db->fetch_field($query, 'prefix'))
{
$tprefix = $db->escape_string($prefix);
$sqlwhere[] = "title='{$tprefix}' OR title LIKE '{$tprefix}=_%' ESCAPE '='";
}

	}

// Delete template groups.
$db->delete_query('templategroups', "prefix='hello'");















	if($sqlwhere) // else there are no groups to delete
{
// Delete template groups.
$db->delete_query('templategroups', "prefix='hello'");

// Delete templates belonging to template groups.
$db->delete_query('templates', implode(' OR ', $sqlwhere));
}

	// Delete templates belonging to template groups.
$db->delete_query('templates', "title='hello' OR title LIKE 'hello_%'");











	// delete settings group

	// Delete settings group

	$db->delete_query('settinggroups', "name='hello'");


	$db->delete_query('settinggroups', "name='hello'");


	// remove settings

	// Remove the settings

	$db->delete_query('settings', "name IN ('hello_display1','hello_display2')");

// This is required so it updates the settings.php file as well and not only the database - they must be synchronized!
rebuild_settings();


	$db->delete_query('settings', "name IN ('hello_display1','hello_display2')");

// This is required so it updates the settings.php file as well and not only the database - they must be synchronized!
rebuild_settings();


	// drop tables if desired

	// Drop tables if desired

	if(!isset($mybb->input['no']))
{
$db->drop_table('hello_messages');

	if(!isset($mybb->input['no']))
{
$db->drop_table('hello_messages');