1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

More updates, getting closer

This commit is contained in:
mcfly
2008-02-02 03:23:47 +00:00
parent f3c8d31b55
commit 39f7ced05a
3 changed files with 58 additions and 22 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.25 $ | $Revision: 1.26 $
| $Date: 2008-02-02 00:48:57 $ | $Date: 2008-02-02 03:23:47 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -67,8 +67,9 @@ class e107plugin
); );
var $plug_vars; var $plug_vars;
var $current_plug;
var $parsed_plugin; var $parsed_plugin;
function e107plugin() function e107plugin()
{ {
$parsed_plugin = array(); $parsed_plugin = array();
@@ -602,7 +603,13 @@ class e107plugin
global $sql; global $sql;
$id = (int)$id; $id = (int)$id;
$plug = $this->getinfo($id); $plug = $this->getinfo($id);
$this->current_plug = $plug;
$path = e_PLUGIN.$plug['plugin_path'].'/'; $path = e_PLUGIN.$plug['plugin_path'].'/';
//We'll just install using plugin.php file for now.
return $this->install_plugin_php($path);
//New code to install using plugin.xml below.
$addons = explode(',', $plug['plugin_addons']); $addons = explode(',', $plug['plugin_addons']);
$sql_list = array(); $sql_list = array();
foreach($addons as $addon) foreach($addons as $addon)
@@ -613,10 +620,6 @@ class e107plugin
} }
} }
//Will just install using plugin.php file for now.
//return $this->install_plugin_php($path);
//New code to install using plugin.xml below.
if(!file_exists($path.'plugin.xml') || $function == '') if(!file_exists($path.'plugin.xml') || $function == '')
{ {
return false; return false;
@@ -652,13 +655,13 @@ class e107plugin
preg_match("/CREATE TABLE(.*?)\(/si", $sql_table, $match); preg_match("/CREATE TABLE(.*?)\(/si", $sql_table, $match);
$tablename = trim($match[1]); $tablename = trim($match[1]);
echo "Removing table $tablename <br />"; echo "Removing table $tablename <br />";
// $this->manage_tables('remove', array($tablename)); $this->manage_tables('remove', array($tablename));
} }
if($function == 'install') if($function == 'install')
{ {
$sql_table = preg_replace("/create table\s+/si", "CREATE TABLE #", $sql_table); $sql_table = preg_replace("/create table\s+/si", "CREATE TABLE #", $sql_table);
echo "Adding table: <pre>{$sql_table}</pre><br />"; echo "Adding table: <pre>{$sql_table}</pre><br />";
// $this->manage_tables('add', array($sql_table)); $this->manage_tables('add', array($sql_table));
} }
} }
} }
@@ -685,20 +688,20 @@ class e107plugin
{ {
$perm = (isset($attrib['perm']) ? $attrib['perm'] : 0); $perm = (isset($attrib['perm']) ? $attrib['perm'] : 0);
echo "Adding link {$attrib['name']} with url [{$attrib['url']}] and perm {$perm} <br />"; echo "Adding link {$attrib['name']} with url [{$attrib['url']}] and perm {$perm} <br />";
// manage_link('add', $attrib['url'], $attrib['name'], $perm); $this->manage_link('add', $attrib['url'], $attrib['name'], $perm);
} }
//remove inactive links on upgrade //remove inactive links on upgrade
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false') if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{ {
echo "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />"; echo "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />";
// manage_link('remove', $attrib['url'], $attrib['name']); $this->manage_link('remove', $attrib['url'], $attrib['name']);
} }
break; break;
case 'uninstall': case 'uninstall':
//remove all links //remove all links
echo "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />"; echo "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />";
// manage_link('remove', $attrib['url'], $attrib['name']); $this->manage_link('remove', $attrib['url'], $attrib['name']);
break; break;
} }
} }
@@ -717,14 +720,14 @@ class e107plugin
if(is_array($list['active'])) if(is_array($list['active']))
{ {
echo "Adding prefs ".print_a($list['active'], true)."<br />"; echo "Adding prefs ".print_a($list['active'], true)."<br />";
// manage_prefs('add', $list['active']); $this->manage_prefs('add', $list['active']);
} }
//If upgrading, removing any inactive pref //If upgrading, removing any inactive pref
if($function == 'upgrade' && is_array($list['inactive'])) if($function == 'upgrade' && is_array($list['inactive']))
{ {
echo "Removing prefs ".print_a($list['inactive'], true)."<br />"; echo "Removing prefs ".print_a($list['inactive'], true)."<br />";
// manage_prefs('remove', $list['inactive']); $this->manage_prefs('remove', $list['inactive']);
} }
break; break;
@@ -733,7 +736,7 @@ class e107plugin
if(is_array($list['all'])) if(is_array($list['all']))
{ {
echo "Removing prefs ".print_a($list['all'], true)."<br />"; echo "Removing prefs ".print_a($list['all'], true)."<br />";
// manage_prefs('remove', $list['all']); $this->manage_prefs('remove', $list['all']);
} }
break; break;
} }
@@ -765,21 +768,21 @@ class e107plugin
if(!isset($attrib['active']) || $attrib['active'] == 'true') if(!isset($attrib['active']) || $attrib['active'] == 'true')
{ {
echo "Adding userclass ".$attrib['name']."<br />"; echo "Adding userclass ".$attrib['name']."<br />";
// manage_userclass('add', $attrib['name'], $attrib['description']); $this->manage_userclass('add', $attrib['name'], $attrib['description']);
} }
//If upgrading, removing any inactive userclass //If upgrading, removing any inactive userclass
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false') if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{ {
echo "Removing userclass ".$attrib['name']."<br />"; echo "Removing userclass ".$attrib['name']."<br />";
// manage_userclass('remove', $attrib['name'], $attrib['description']); $this->manage_userclass('remove', $attrib['name'], $attrib['description']);
} }
break; break;
//If uninstalling, remove all userclasses (active or inactive) //If uninstalling, remove all userclasses (active or inactive)
case 'uninstall': case 'uninstall':
echo "Removing prefs ".$attrib['name']."<br />"; echo "Removing prefs ".$attrib['name']."<br />";
// manage_userclass('remove', $attrib['name'], $attrib['description']); $this->manage_userclass('remove', $attrib['name'], $attrib['description']);
break; break;
} }
} }
@@ -792,10 +795,10 @@ class e107plugin
// Let's call any custom post functions defined in <management> section // Let's call any custom post functions defined in <management> section
$this->execute_function($path, $function, 'post'); $this->execute_function($path, $function, 'post');
if($function == 'install' || $functon = 'upgrade') if($function == 'install' || $functon = 'upgrade')
{ {
$eplug_addons = $this->getAddons($plug_vars['folder']); $eplug_addons = $this->getAddons($plug_vars['folder']);
$sql->db_Update('plugin', "plugin_installflag = 1, plugin_addons = '{$eplug_addons}', plugin_version = '{$plug_vars['version']}' WHERE plugin_id = ".$id); $sql->db_Update('plugin', "plugin_installflag = 1, plugin_addons = '{$eplug_addons}', plugin_version = '{$plug_vars['version']}' WHERE plugin_id = ".$id);
$pref['plug_installed'][$plug['plugin_path']] = $plug_vars['version']; $pref['plug_installed'][$plug['plugin_path']] = $plug_vars['version'];
save_prefs(); save_prefs();
@@ -827,13 +830,13 @@ class e107plugin
include_once($path.$attrib['file']); include_once($path.$attrib['file']);
if($attrib['type'] == 'fileFunction') if($attrib['type'] == 'fileFunction')
{ {
$result = call_user_func($attrib['function'], $plug_vars); $result = call_user_func($attrib['function'], $this);
return $result; return $result;
} }
elseif($attrib['type'] == 'classFunction') elseif($attrib['type'] == 'classFunction')
{ {
$_tmp = new $attrib['class']; $_tmp = new $attrib['class'];
$result = call_user_func(array($_tmp, $attrib['function']), $plug_vars); $result = call_user_func(array($_tmp, $attrib['function']), $this);
return $result; return $result;
} }
} }

View File

@@ -0,0 +1,34 @@
<?php
class forum_management
{
function forum_install_pre(&$var)
{
print_a($var);
echo "custom install 'pre' function<br /><br />";
}
function forum_install_post(&$var)
{
global $sql;
echo "Setting all user_forums to 0 <br />";
$sql -> db_Update("user", "user_forums='0'");
}
function forum_uninstatll(&$var)
{
global $sql;
$sql -> db_Update("user", "user_forums='0'");
}
function forum_upgrade(&$var)
{
global $sql;
if(version_compare($var['current_plug']['plugin_version'], "1.2", "<"))
{
$qry = "ALTER TABLE #forum ADD forum_postclass TINYINT( 3 ) UNSIGNED DEFAULT '0' NOT NULL ;"
$sql->db_Select_gen($qry);
}
}
}

View File

@@ -39,7 +39,6 @@
<userclass name="forum_moderator" description="Moderator of all forums" /> <userclass name="forum_moderator" description="Moderator of all forums" />
</userclasses> </userclasses>
<management> <management>
<install when="pre" type="classFunction" file="forum_management.php" class="forum_management" function="forum_install_pre" />
<install when="post" type="classFunction" file="forum_management.php" class="forum_management" function="forum_install_post" /> <install when="post" type="classFunction" file="forum_management.php" class="forum_management" function="forum_install_post" />
<uninstall type="classFunction" file="forum_management.php" class="forum_management" function="forum_uninstall" /> <uninstall type="classFunction" file="forum_management.php" class="forum_management" function="forum_uninstall" />
<upgrade type="classFunction" file="forum_management.php" class="forum_management" function="forum_upgrade" /> <upgrade type="classFunction" file="forum_management.php" class="forum_management" function="forum_upgrade" />