mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Cleaned up plugin installation class. May fix issues with some v1 plugin installations. $tp->Glyph() now accepts a 'style' option.
This commit is contained in:
@@ -765,163 +765,34 @@ class pluginManager{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME - move it to plugin handler, similar to install_plugin() routine
|
|
||||||
function pluginUninstall()
|
function pluginUninstall()
|
||||||
{
|
{
|
||||||
$pref = e107::getPref();
|
|
||||||
$admin_log = e107::getAdminLog();
|
|
||||||
$plugin = e107::getPlugin();
|
|
||||||
$tp = e107::getParser();
|
|
||||||
$sql = e107::getDb();
|
|
||||||
$eplug_folder = '';
|
|
||||||
if(!isset($_POST['uninstall_confirm']))
|
|
||||||
{ // $id is already an integer
|
|
||||||
$this->pluginConfirmUninstall();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$plug = $plugin->getinfo($this->id);
|
if(!isset($_POST['uninstall_confirm']))
|
||||||
|
{ // $id is already an integer
|
||||||
|
|
||||||
// Check if plugin is being used by another plugin before uninstalling it.
|
$this->pluginConfirmUninstall();
|
||||||
if(isset($plug['plugin_path']))
|
return;
|
||||||
{
|
|
||||||
if ($plugin->isUsedByAnotherPlugin($plug['plugin_path']))
|
|
||||||
{
|
|
||||||
$this->action = 'installed'; // Render plugin list.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = '';
|
$post = e107::getParser()->filter($_POST);
|
||||||
//Uninstall Plugin
|
$text = e107::getPlugin()->uninstall($this->id, $post);
|
||||||
if ($plug['plugin_installflag'] == TRUE )
|
$this->show_message($text, E_MESSAGE_SUCCESS);
|
||||||
{
|
|
||||||
$eplug_folder = $plug['plugin_path'];
|
|
||||||
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
|
||||||
|
|
||||||
if(file_exists($_path.'plugin.xml'))
|
$this->action = 'installed';
|
||||||
{
|
|
||||||
unset($_POST['uninstall_confirm']);
|
|
||||||
$plugin->install_plugin_xml($this->id, 'uninstall', $tp->filter($_POST)); //$_POST must be used.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Deprecated - plugin uses plugin.php
|
|
||||||
$eplug_table_names = null;
|
|
||||||
$eplug_prefs = null;
|
|
||||||
$eplug_comment_ids= null;
|
|
||||||
$eplug_array_pref= null;
|
|
||||||
$eplug_menu_name = null;
|
|
||||||
$eplug_link = null;
|
|
||||||
$eplug_link_url = null;
|
|
||||||
$eplug_link_name = null;
|
|
||||||
$eplug_userclass = null;
|
|
||||||
$eplug_version = null;
|
|
||||||
|
|
||||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
$log = e107::getPlugin()->getLog();
|
||||||
|
e107::getDebug()->log($log);
|
||||||
|
|
||||||
$func = $eplug_folder.'_uninstall';
|
return;
|
||||||
if (function_exists($func))
|
|
||||||
{
|
|
||||||
$text .= call_user_func($func);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($_POST['delete_tables'])
|
|
||||||
{
|
|
||||||
if (is_array($eplug_table_names))
|
|
||||||
{
|
|
||||||
$result = $plugin->manage_tables('remove', $eplug_table_names);
|
|
||||||
if ($result !== TRUE)
|
|
||||||
{
|
|
||||||
$text .= EPL_ADLAN_27.' <b>'.MPREFIX.$result.'</b> - '.EPL_ADLAN_30.'<br />';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$text .= EPL_ADLAN_28."<br />";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$text .= EPL_ADLAN_49."<br />";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($eplug_prefs))
|
|
||||||
{
|
|
||||||
$plugin->manage_prefs('remove', $eplug_prefs);
|
|
||||||
$text .= EPL_ADLAN_29."<br />";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($eplug_comment_ids))
|
|
||||||
{
|
|
||||||
$text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_array($eplug_array_pref))
|
|
||||||
{
|
|
||||||
foreach($eplug_array_pref as $key => $val)
|
|
||||||
{
|
|
||||||
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($eplug_menu_name)
|
|
||||||
{
|
|
||||||
$sql->delete('menus', "menu_name='{$eplug_menu_name}' ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($eplug_link)
|
|
||||||
{
|
|
||||||
$plugin->manage_link('remove', $eplug_link_url, $eplug_link_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($eplug_userclass)
|
|
||||||
{
|
|
||||||
$plugin->manage_userclass('remove', $eplug_userclass);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql->update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$this->id}' ");
|
|
||||||
$plugin->manage_search('remove', $eplug_folder);
|
|
||||||
|
|
||||||
$plugin->manage_notify('remove', $eplug_folder);
|
|
||||||
|
|
||||||
// it's done inside install_plugin_xml(), required only here
|
|
||||||
if (isset($pref['plug_installed'][$plug['plugin_path']]))
|
|
||||||
{
|
|
||||||
unset($pref['plug_installed'][$plug['plugin_path']]);
|
|
||||||
}
|
|
||||||
e107::getConfig('core')->setPref($pref);
|
|
||||||
$plugin->rebuildUrlConfig();
|
|
||||||
e107::getConfig('core')->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$logInfo = deftrue($plug['plugin_name'],$plug['plugin_name']). " v".$plug['plugin_version']." ({e_PLUGIN}".$plug['plugin_path'].")";
|
|
||||||
e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($_POST['delete_files']) && ($plug['plugin_installflag'] == true))
|
|
||||||
{
|
|
||||||
if(!empty($eplug_folder))
|
|
||||||
{
|
|
||||||
$result = e107::getFile()->rmtree(e_PLUGIN.$eplug_folder);
|
|
||||||
$text .= ($result ? '<br />'.EPL_ADLAN_86.e_PLUGIN.$eplug_folder : '<br />'.EPL_ADLAN_87.'<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
|
|
||||||
}
|
|
||||||
|
|
||||||
$plugin->save_addon_prefs('update');
|
|
||||||
|
|
||||||
$this->show_message($text, E_MESSAGE_SUCCESS);
|
|
||||||
// $ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($plug['plugin_name'], "", "defs,emotes_off,no_make_clickable"), $text);
|
|
||||||
|
|
||||||
$this->action = 'installed';
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function pluginProcessUpload()
|
function pluginProcessUpload()
|
||||||
{
|
{
|
||||||
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
|
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
|
||||||
|
@@ -3617,8 +3617,9 @@ class e_parser
|
|||||||
}
|
}
|
||||||
|
|
||||||
$idAtt = (!empty($parm['id'])) ? "id='".$parm['id']."' " : '';
|
$idAtt = (!empty($parm['id'])) ? "id='".$parm['id']."' " : '';
|
||||||
|
$style = (!empty($parm['style'])) ? "style='".$parm['style']."' " : '';
|
||||||
|
|
||||||
$text = "<".$tag." {$idAtt}class='".$prefix.$id.$size.$spin.$rotate.$fixedW."'></".$tag.">" ;
|
$text = "<".$tag." {$idAtt}class='".$prefix.$id.$size.$spin.$rotate.$fixedW."' {$style}></".$tag.">" ;
|
||||||
$text .= ($space !== false) ? $space : "";
|
$text .= ($space !== false) ? $space : "";
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
|
@@ -212,7 +212,64 @@ class e_menu
|
|||||||
return e107::getDb()->update('menus', $qry);
|
return e107::getDb()->update('menus', $qry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Menu to the Menu Table.
|
||||||
|
* @param string $plugin folder name
|
||||||
|
* @param string $menufile name without the .php
|
||||||
|
* @return bool|int
|
||||||
|
*/
|
||||||
|
public function add($plugin, $menufile)
|
||||||
|
{
|
||||||
|
$sql = e107::getDb();
|
||||||
|
|
||||||
|
if(empty($plugin) || empty($menufile))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($sql->select('menus', 'menu_id' , 'menu_path="'.$plugin.'/" AND menu_name="'.$menufile.'" LIMIT 1'))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$insert = array(
|
||||||
|
'menu_id' => 0,
|
||||||
|
'menu_name' => $menufile,
|
||||||
|
'menu_location' => 0,
|
||||||
|
'menu_order' => 0,
|
||||||
|
'menu_class' => 0,
|
||||||
|
'menu_pages' => 0,
|
||||||
|
'menu_path' => $plugin."/",
|
||||||
|
'menu_layout' => '',
|
||||||
|
'menu_parms' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
return $sql->insert('menus', $insert);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a menu from the Menu table.
|
||||||
|
* @param string $plugin folder name
|
||||||
|
* @param string $menufile
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function remove($plugin, $menufile=null)
|
||||||
|
{
|
||||||
|
$qry = 'menu_path="'.$plugin.'/" ';
|
||||||
|
|
||||||
|
if(!empty($menufile))
|
||||||
|
{
|
||||||
|
$qry .= ' AND menu_name="'.$menufile.'" ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return e107::getDb()->delete('menus', $qry);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to retrieve Menu data from tables.
|
* Function to retrieve Menu data from tables.
|
||||||
*/
|
*/
|
||||||
|
@@ -183,6 +183,7 @@ class e107plugin
|
|||||||
var $unInstallOpts;
|
var $unInstallOpts;
|
||||||
var $module = array();
|
var $module = array();
|
||||||
private $options = array();
|
private $options = array();
|
||||||
|
private $log = array();
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@@ -552,6 +553,7 @@ class e107plugin
|
|||||||
|
|
||||||
function manage_category($cat)
|
function manage_category($cat)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
if (vartrue($cat) && in_array($cat, $this->accepted_categories))
|
if (vartrue($cat) && in_array($cat, $this->accepted_categories))
|
||||||
{
|
{
|
||||||
return $cat;
|
return $cat;
|
||||||
@@ -564,7 +566,7 @@ class e107plugin
|
|||||||
|
|
||||||
function manage_icons($plugin = '', $function = '')
|
function manage_icons($plugin = '', $function = '')
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
if ($plugin == '')
|
if ($plugin == '')
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -587,6 +589,7 @@ class e107plugin
|
|||||||
{
|
{
|
||||||
$status = ($med->removePath(e_PLUGIN.$plugin, 'icon')) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
$status = ($med->removePath(e_PLUGIN.$plugin, 'icon')) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
|
||||||
$mes->add(IMALAN_164, $status);
|
$mes->add(IMALAN_164, $status);
|
||||||
|
$this->log("Deleted Icons from Media-Manager "); // No LANS
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -710,6 +713,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function manage_extended_field($action, $field_name, $field_attrib, $field_source = '')
|
function manage_extended_field($action, $field_name, $field_attrib, $field_source = '')
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$this->setUe();
|
$this->setUe();
|
||||||
|
|
||||||
@@ -854,6 +858,7 @@ class e107plugin
|
|||||||
|
|
||||||
function manage_extended_field_sql($action, $field_name)
|
function manage_extended_field_sql($action, $field_name)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$f = e_CORE.'sql/extended_'.preg_replace('/[^\w]/', '', $field_name).'.php'; // quick security, always good idea
|
$f = e_CORE.'sql/extended_'.preg_replace('/[^\w]/', '', $field_name).'.php'; // quick security, always good idea
|
||||||
|
|
||||||
if(!is_readable($f)) return false;
|
if(!is_readable($f)) return false;
|
||||||
@@ -910,6 +915,7 @@ class e107plugin
|
|||||||
|
|
||||||
function manage_userclass($action, $class_name, $class_description='')
|
function manage_userclass($action, $class_name, $class_description='')
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
global $e107;
|
global $e107;
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
@@ -1037,6 +1043,7 @@ class e107plugin
|
|||||||
// $prefType specifies the storage type - may be 'pref', 'listPref' or 'arrayPref'
|
// $prefType specifies the storage type - may be 'pref', 'listPref' or 'arrayPref'
|
||||||
function manage_prefs($action, $var, $prefType = 'pref', $path = '', $unEscape = FALSE)
|
function manage_prefs($action, $var, $prefType = 'pref', $path = '', $unEscape = FALSE)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
global $pref;
|
global $pref;
|
||||||
if (!is_array($var))
|
if (!is_array($var))
|
||||||
return;
|
return;
|
||||||
@@ -1125,6 +1132,7 @@ class e107plugin
|
|||||||
|
|
||||||
function manage_comments($action, $comment_id)
|
function manage_comments($action, $comment_id)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
@@ -1149,6 +1157,7 @@ class e107plugin
|
|||||||
// 'upgrade' and 'remove' operate on all language variants of the same table
|
// 'upgrade' and 'remove' operate on all language variants of the same table
|
||||||
function manage_tables($action, $var)
|
function manage_tables($action, $var)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$sql = e107::getDB();
|
$sql = e107::getDB();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
@@ -1322,6 +1331,7 @@ class e107plugin
|
|||||||
|
|
||||||
function manage_notify($action, $eplug_folder)
|
function manage_notify($action, $eplug_folder)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
// $notify_prefs = $sysprefs -> get('notify_prefs');
|
// $notify_prefs = $sysprefs -> get('notify_prefs');
|
||||||
// $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
|
// $notify_prefs = $eArrayStorage -> ReadArray($notify_prefs);
|
||||||
@@ -1386,7 +1396,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
public function rebuildUrlConfig()
|
public function rebuildUrlConfig()
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$modules = eRouter::adminReadModules(); // get all available locations, non installed plugins will be ignored
|
$modules = eRouter::adminReadModules(); // get all available locations, non installed plugins will be ignored
|
||||||
$config = eRouter::adminBuildConfig(e107::getPref('url_config'), $modules); // merge with current config
|
$config = eRouter::adminBuildConfig(e107::getPref('url_config'), $modules); // merge with current config
|
||||||
$locations = eRouter::adminBuildLocations($modules); // rebuild locations pref
|
$locations = eRouter::adminBuildLocations($modules); // rebuild locations pref
|
||||||
@@ -1413,6 +1423,22 @@ class e107plugin
|
|||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function log($message)
|
||||||
|
{
|
||||||
|
$this->log[] = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLog()
|
||||||
|
{
|
||||||
|
$text = $this->log;
|
||||||
|
|
||||||
|
$this->log = array();
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install routine for XML file
|
* Install routine for XML file
|
||||||
* @param mixed $id (the number of the plugin in the DB) or the path to the plugin folder. eg. 'forum'
|
* @param mixed $id (the number of the plugin in the DB) or the path to the plugin folder. eg. 'forum'
|
||||||
@@ -1423,7 +1449,7 @@ class e107plugin
|
|||||||
* 'delete_xfields' - to delete extended fields
|
* 'delete_xfields' - to delete extended fields
|
||||||
* 'delete_ipool' - to delete icon pool entry
|
* 'delete_ipool' - to delete icon pool entry
|
||||||
* + any defined in <pluginname>_setup.php in the uninstall_options() method.
|
* + any defined in <pluginname>_setup.php in the uninstall_options() method.
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function install_plugin_xml($id, $function = '', $options = null)
|
function install_plugin_xml($id, $function = '', $options = null)
|
||||||
{
|
{
|
||||||
@@ -1433,7 +1459,7 @@ class e107plugin
|
|||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$event = e107::getEvent();
|
$event = e107::getEvent();
|
||||||
|
|
||||||
$mes->addDebug("Running ".$function);
|
$this->log("Running Plugin: ".$function);
|
||||||
|
|
||||||
$error = array(); // Array of error messages
|
$error = array(); // Array of error messages
|
||||||
$canContinue = TRUE; // Clear flag if must abort part way through
|
$canContinue = TRUE; // Clear flag if must abort part way through
|
||||||
@@ -1478,16 +1504,19 @@ class e107plugin
|
|||||||
if (!file_exists($path.'plugin.xml') || $function == '')
|
if (!file_exists($path.'plugin.xml') || $function == '')
|
||||||
{
|
{
|
||||||
$error[] = EPL_ADLAN_77;
|
$error[] = EPL_ADLAN_77;
|
||||||
|
$this->log("Cannot find plugin.xml"); // Do NOT LAN. Debug Only.
|
||||||
$canContinue = false;
|
$canContinue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($canContinue && $this->parse_plugin_xml($plug['plugin_path']))
|
if ($canContinue && $this->parse_plugin_xml($plug['plugin_path']))
|
||||||
{
|
{
|
||||||
$plug_vars = $this->plug_vars;
|
$plug_vars = $this->plug_vars;
|
||||||
|
$this->log("Vars: ".print_r($plug_vars,true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error[] = EPL_ADLAN_76;
|
$error[] = EPL_ADLAN_76;
|
||||||
|
$this->log("Error in plugin.xml");
|
||||||
$canContinue = FALSE;
|
$canContinue = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1502,6 +1531,7 @@ class e107plugin
|
|||||||
|
|
||||||
if ($canContinue === false)
|
if ($canContinue === false)
|
||||||
{
|
{
|
||||||
|
$this->log("Cannot Continue. Line:".__LINE__); // Do NOT LAN. Debug Only.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1615,6 +1645,9 @@ class e107plugin
|
|||||||
$this->XmlMediaCategories($function, $plug_vars);
|
$this->XmlMediaCategories($function, $plug_vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->XmlMenus($this->plugFolder, $function, $plug_vars['files']);
|
||||||
|
|
||||||
|
|
||||||
$this->manage_icons($this->plugFolder, $function);
|
$this->manage_icons($this->plugFolder, $function);
|
||||||
|
|
||||||
//FIXME
|
//FIXME
|
||||||
@@ -1653,11 +1686,13 @@ class e107plugin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e107::getMessage()->addDebug("updated Installed plugins pref: ".print_a($p_installed,true));
|
|
||||||
|
|
||||||
|
|
||||||
$this->rebuildUrlConfig();
|
$this->rebuildUrlConfig();
|
||||||
|
|
||||||
|
$this->log("Updated 'plug_installed' core pref. ");
|
||||||
|
|
||||||
e107::getConfig('core')->save(true, false, false);
|
e107::getConfig('core')->save(true, false, false);
|
||||||
|
|
||||||
/* if($function == 'install')
|
/* if($function == 'install')
|
||||||
@@ -1706,11 +1741,14 @@ class e107plugin
|
|||||||
$event->trigger('admin_plugin_refresh', $plug);
|
$event->trigger('admin_plugin_refresh', $plug);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function removeCrons($plug_vars)
|
private function removeCrons($plug_vars)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__METHOD__);
|
||||||
|
|
||||||
if(!file_exists(e_PLUGIN. $plug_vars['folder']."/e_cron.php"))
|
if(!file_exists(e_PLUGIN. $plug_vars['folder']."/e_cron.php"))
|
||||||
{
|
{
|
||||||
@@ -1719,6 +1757,7 @@ class e107plugin
|
|||||||
|
|
||||||
if(e107::getDb()->delete('cron', 'cron_function LIKE "'. $plug_vars['folder'] . '::%"'))
|
if(e107::getDb()->delete('cron', 'cron_function LIKE "'. $plug_vars['folder'] . '::%"'))
|
||||||
{
|
{
|
||||||
|
$this->log($plug_vars['folder']." crons removed successfully."); // no LANs.
|
||||||
e107::getMessage()->addDebug($plug_vars['folder']." crons removed successfully."); // No LAN necessary
|
e107::getMessage()->addDebug($plug_vars['folder']." crons removed successfully."); // No LAN necessary
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1726,7 +1765,70 @@ class e107plugin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function XmlMenus($plug, $function, $files)
|
||||||
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
|
|
||||||
|
$menuFiles = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach($files as $file)
|
||||||
|
{
|
||||||
|
if($file === 'e_menu.php')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(substr($file,-9) === '_menu.php')
|
||||||
|
{
|
||||||
|
$menuFiles[] = basename($file, '.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->log("Scanning for _menu.php files - ". count($menuFiles)." found."); // Debug info, no LAN
|
||||||
|
|
||||||
|
|
||||||
|
if(empty($menuFiles))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch($function)
|
||||||
|
{
|
||||||
|
case "install":
|
||||||
|
case "refresh":
|
||||||
|
|
||||||
|
$this->log("Adding menus to menus table."); // NO LANS - debug info!
|
||||||
|
|
||||||
|
foreach($menuFiles as $menu)
|
||||||
|
{
|
||||||
|
if(!e107::getMenu()->add($plug, $menu))
|
||||||
|
{
|
||||||
|
$this->log("Couldn't add ".$menu." to menus table."); // NO LAN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "uninstall":
|
||||||
|
|
||||||
|
$this->log("Removing menus from menus table."); // No Lan
|
||||||
|
|
||||||
|
if(!e107::getMenu()->remove($plug))
|
||||||
|
{
|
||||||
|
$this->log("Couldn't remove menus for plugin: ".$plug); // NO LAN
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse {plugin}_sql.php file and install/upgrade/uninstall tables.
|
* Parse {plugin}_sql.php file and install/upgrade/uninstall tables.
|
||||||
@@ -1736,18 +1838,20 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlTables($function, $plug, $options = array())
|
function XmlTables($function, $plug, $options = array())
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__METHOD__);
|
||||||
|
|
||||||
$sqlFile = e_PLUGIN.$plug['plugin_path'].'/'.str_replace("_menu","", $plug['plugin_path'])."_sql.php";
|
$sqlFile = e_PLUGIN.$plug['plugin_path'].'/'.str_replace("_menu","", $plug['plugin_path'])."_sql.php";
|
||||||
|
|
||||||
if(!file_exists($sqlFile)) // No File, so return;
|
if(!file_exists($sqlFile)) // No File, so return;
|
||||||
{
|
{
|
||||||
e107::getMessage()->addDebug("No SQL File Found at: ".$sqlFile);
|
$this->log("No SQL File Found at: ".$sqlFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_readable($sqlFile)) // File Can't be read.
|
if(!is_readable($sqlFile)) // File Can't be read.
|
||||||
{
|
{
|
||||||
e107::getMessage()->addError("Can't read SQL definition: ".$sqlFile);
|
e107::getMessage()->addError("Can't read SQL definition: ".$sqlFile);
|
||||||
|
$this->log("Can't read SQL definition: ".$sqlFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1763,6 +1867,7 @@ class e107plugin
|
|||||||
if(empty($contents))
|
if(empty($contents))
|
||||||
{
|
{
|
||||||
e107::getMessage()->addError("Can't read SQL definition: ".$sqlFile);
|
e107::getMessage()->addError("Can't read SQL definition: ".$sqlFile);
|
||||||
|
$this->log("Can't read SQL definition: ".$sqlFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1834,6 +1939,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function isUsedByAnotherPlugin($plugin)
|
function isUsedByAnotherPlugin($plugin)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$db = e107::getDb();
|
$db = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
@@ -1915,6 +2021,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlDependencies($tags)
|
function XmlDependencies($tags)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__METHOD__);
|
||||||
$db = e107::getDb();
|
$db = e107::getDb();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
@@ -2080,6 +2187,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlLanguageFiles($function, $tag='', $when = '')
|
function XmlLanguageFiles($function, $tag='', $when = '')
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$core = e107::getConfig('core');
|
$core = e107::getConfig('core');
|
||||||
|
|
||||||
$updated = false;
|
$updated = false;
|
||||||
@@ -2138,6 +2246,7 @@ class e107plugin
|
|||||||
|
|
||||||
if($updated === true)
|
if($updated === true)
|
||||||
{
|
{
|
||||||
|
$this->log("Prefs saved");
|
||||||
$core->save(true,false,false); //FIXME do this quietly without an s-message
|
$core->save(true,false,false); //FIXME do this quietly without an s-message
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2151,6 +2260,8 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlSiteLinks($function, $plug_vars)
|
function XmlSiteLinks($function, $plug_vars)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
|
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
if(vartrue($this->options['nolinks']))
|
if(vartrue($this->options['nolinks']))
|
||||||
@@ -2230,6 +2341,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlAdminLinks($function, $tag)
|
function XmlAdminLinks($function, $tag)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
foreach ($tag['link'] as $link)
|
foreach ($tag['link'] as $link)
|
||||||
{
|
{
|
||||||
$attrib = $link['@attributes'];
|
$attrib = $link['@attributes'];
|
||||||
@@ -2273,6 +2385,7 @@ class e107plugin
|
|||||||
// Only 1 category per file-type allowed. ie. 1 for images, 1 for files.
|
// Only 1 category per file-type allowed. ie. 1 for images, 1 for files.
|
||||||
function XmlMediaCategories($function, $tag)
|
function XmlMediaCategories($function, $tag)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
// print_a($tag);
|
// print_a($tag);
|
||||||
|
|
||||||
@@ -2349,15 +2462,15 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlBBcodes($function, $tag)
|
function XmlBBcodes($function, $tag)
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$this->log("Running ".__FUNCTION__);
|
||||||
//print_a($tag);
|
|
||||||
switch ($function)
|
switch ($function)
|
||||||
{
|
{
|
||||||
case 'install': // Probably best to leave well alone
|
case 'install': // Probably best to leave well alone
|
||||||
if(vartrue($tag['bbcodes']['@attributes']['imgResize']))
|
if(vartrue($tag['bbcodes']['@attributes']['imgResize']))
|
||||||
{
|
{
|
||||||
e107::getConfig('core')->setPref('resize_dimensions/'.$this->plugFolder."-bbcode", array('w'=>300,'h'=>300));
|
e107::getConfig('core')->setPref('resize_dimensions/'.$this->plugFolder."-bbcode", array('w'=>300,'h'=>300));
|
||||||
$mes->debug('Adding imageResize for: '.$this->plugFolder);
|
$this->log('Adding imageResize for: '.$this->plugFolder);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2367,7 +2480,7 @@ class e107plugin
|
|||||||
//e107::getConfig('core')->removePref('resize_dimensions/'.$this->plugFolder);
|
//e107::getConfig('core')->removePref('resize_dimensions/'.$this->plugFolder);
|
||||||
//e107::getConfig('core')->removePref('e_imageresize/'.$this->plugFolder);
|
//e107::getConfig('core')->removePref('e_imageresize/'.$this->plugFolder);
|
||||||
e107::getConfig('core')->removePref('resize_dimensions/'.$this->plugFolder."-bbcode");
|
e107::getConfig('core')->removePref('resize_dimensions/'.$this->plugFolder."-bbcode");
|
||||||
$mes->debug('Removing imageResize for: '.$this->plugFolder."-bbcode");
|
$this->log('Removing imageResize for: '.$this->plugFolder."-bbcode");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -2387,6 +2500,7 @@ class e107plugin
|
|||||||
function XmlUserClasses($function, $array)
|
function XmlUserClasses($function, $array)
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
|
|
||||||
foreach ($array['class'] as $uclass)
|
foreach ($array['class'] as $uclass)
|
||||||
{
|
{
|
||||||
@@ -2446,6 +2560,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlExtendedFields($function, $array)
|
function XmlExtendedFields($function, $array)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$this->setUe();
|
$this->setUe();
|
||||||
|
|
||||||
@@ -2511,7 +2626,7 @@ class e107plugin
|
|||||||
*/
|
*/
|
||||||
function XmlPrefs($mode = 'core', $function, $prefArray)
|
function XmlPrefs($mode = 'core', $function, $prefArray)
|
||||||
{
|
{
|
||||||
|
$this->log("Running ".__FUNCTION__);
|
||||||
//XXX Could also be used for theme prefs.. perhaps this function should be moved elsewhere?
|
//XXX Could also be used for theme prefs.. perhaps this function should be moved elsewhere?
|
||||||
//TODO array support for prefs. <key>? or array() as used in xml site export?
|
//TODO array support for prefs. <key>? or array() as used in xml site export?
|
||||||
|
|
||||||
@@ -2571,6 +2686,7 @@ class e107plugin
|
|||||||
case 'uninstall':
|
case 'uninstall':
|
||||||
$config->remove($key, $value);
|
$config->remove($key, $value);
|
||||||
$mes->addSuccess(EPL_ADLAN_242, $key);
|
$mes->addSuccess(EPL_ADLAN_242, $key);
|
||||||
|
$this->log("Removing Pref: ".$key);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2674,7 +2790,8 @@ class e107plugin
|
|||||||
return FALSE; // IMPORTANT.
|
return FALSE; // IMPORTANT.
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEPRECATED - See XMLPrefs();
|
/* @deprecated
|
||||||
|
// @deprecated - See XMLPrefs();
|
||||||
function parse_prefs($pref_array, $mode = 'simple')
|
function parse_prefs($pref_array, $mode = 'simple')
|
||||||
{
|
{
|
||||||
$ret = array();
|
$ret = array();
|
||||||
@@ -2712,6 +2829,8 @@ class e107plugin
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
function install_plugin_php($id)
|
function install_plugin_php($id)
|
||||||
{
|
{
|
||||||
$function = 'install';
|
$function = 'install';
|
||||||
@@ -2719,6 +2838,8 @@ class e107plugin
|
|||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$mySQLprefix = MPREFIX; // Fix for some plugin.php files.
|
$mySQLprefix = MPREFIX; // Fix for some plugin.php files.
|
||||||
|
|
||||||
|
$this->log("Running Legacy Plugin: ".$function);
|
||||||
|
|
||||||
if(is_array($id))
|
if(is_array($id))
|
||||||
{
|
{
|
||||||
$plug = $id;
|
$plug = $id;
|
||||||
@@ -2736,6 +2857,9 @@ class e107plugin
|
|||||||
$this->parse_plugin_php($plug['plugin_path']);
|
$this->parse_plugin_php($plug['plugin_path']);
|
||||||
$plug_vars = $this->plug_vars;
|
$plug_vars = $this->plug_vars;
|
||||||
|
|
||||||
|
$eplug_folder = '';
|
||||||
|
$text = '';
|
||||||
|
|
||||||
include($_path.'plugin.php');
|
include($_path.'plugin.php');
|
||||||
|
|
||||||
$func = $eplug_folder.'_install';
|
$func = $eplug_folder.'_install';
|
||||||
@@ -2744,16 +2868,18 @@ class e107plugin
|
|||||||
$text .= call_user_func($func);
|
$text .= call_user_func($func);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($eplug_tables))
|
if(!empty($eplug_tables) && is_array($eplug_tables))
|
||||||
{
|
{
|
||||||
$result = $this->manage_tables('add', $eplug_tables);
|
$result = $this->manage_tables('add', $eplug_tables);
|
||||||
if ($result === TRUE)
|
if ($result === true)
|
||||||
{
|
{
|
||||||
$text .= EPL_ADLAN_19.'<br />';
|
$text .= EPL_ADLAN_19.'<br />';
|
||||||
|
$this->log("Tables added");
|
||||||
$mes->addSuccess(EPL_ADLAN_19);
|
$mes->addSuccess(EPL_ADLAN_19);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->log("Unable to create tables for this plugin."); // NO LANS - debug info!
|
||||||
$mes->addError(EPL_ADLAN_18);
|
$mes->addError(EPL_ADLAN_18);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2766,18 +2892,19 @@ class e107plugin
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (varset($plug_vars['mainPrefs'])) //Core pref items <mainPrefs>
|
if (varset($plug_vars['mainPrefs'])) //Core pref items <mainPrefs>
|
||||||
|
|
||||||
{
|
{
|
||||||
$this->XmlPrefs('core', $function, $plug_vars['mainPrefs']);
|
$this->XmlPrefs('core', $function, $plug_vars['mainPrefs']);
|
||||||
$text .= EPL_ADLAN_8.'<br />';
|
$this->log("Prefs added");
|
||||||
|
//$text .= EPL_ADLAN_8.'<br />';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($eplug_array_pref))
|
if (!empty($eplug_array_pref) && is_array($eplug_array_pref))
|
||||||
{
|
{
|
||||||
foreach ($eplug_array_pref as $key => $val)
|
foreach ($eplug_array_pref as $key => $val)
|
||||||
{
|
{
|
||||||
$this->manage_plugin_prefs('add', $key, $eplug_folder, $val);
|
$this->manage_plugin_prefs('add', $key, $eplug_folder, $val);
|
||||||
}
|
}
|
||||||
|
$this->log("Adding Prefs: ". print_r($eplug_array_pref, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varset($plug_vars['siteLinks']))
|
if (varset($plug_vars['siteLinks']))
|
||||||
@@ -2794,6 +2921,8 @@ class e107plugin
|
|||||||
|
|
||||||
$this->manage_notify('add', $eplug_folder);
|
$this->manage_notify('add', $eplug_folder);
|
||||||
|
|
||||||
|
$this->XmlMenus($plug_vars['folder'], $function, $plug_vars['files']);
|
||||||
|
|
||||||
$eplug_addons = $this->getAddons($eplug_folder);
|
$eplug_addons = $this->getAddons($eplug_folder);
|
||||||
|
|
||||||
$sql->update('plugin', "plugin_installflag = 1, plugin_addons = '{$eplug_addons}' WHERE plugin_id = ".(int) $id);
|
$sql->update('plugin', "plugin_installflag = 1, plugin_addons = '{$eplug_addons}' WHERE plugin_id = ".(int) $id);
|
||||||
@@ -2807,8 +2936,11 @@ class e107plugin
|
|||||||
|
|
||||||
e107::getConfig('core')->save();
|
e107::getConfig('core')->save();
|
||||||
|
|
||||||
|
$this->save_addon_prefs('update');
|
||||||
|
|
||||||
$text .= (isset($eplug_done) ? "<br />{$eplug_done}" : "<br />".LAN_INSTALL_SUCCESSFUL);
|
$text .= (isset($eplug_done) ? "<br />{$eplug_done}" : "<br />".LAN_INSTALL_SUCCESSFUL);
|
||||||
if ($eplug_conffile)
|
|
||||||
|
if (!empty($eplug_conffile))
|
||||||
{
|
{
|
||||||
$text .= "<br /><a class='btn btn-primary' href='".e_PLUGIN.$eplug_folder."/".$eplug_conffile."'>".LAN_CONFIGURE."</a>";
|
$text .= "<br /><a class='btn btn-primary' href='".e_PLUGIN.$eplug_folder."/".$eplug_conffile."'>".LAN_CONFIGURE."</a>";
|
||||||
}
|
}
|
||||||
@@ -2887,6 +3019,8 @@ class e107plugin
|
|||||||
function install($id, $options = array())
|
function install($id, $options = array())
|
||||||
{
|
{
|
||||||
global $sysprefs, $mySQLprefix;
|
global $sysprefs, $mySQLprefix;
|
||||||
|
$this->log("Running ".__METHOD__);
|
||||||
|
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -2904,12 +3038,13 @@ class e107plugin
|
|||||||
return "'{$id}' is missing from the plugin db table";
|
return "'{$id}' is missing from the plugin db table";
|
||||||
}
|
}
|
||||||
|
|
||||||
$plug['plug_action'] = 'install';
|
$plug['plug_action'] = !empty($options['function']) ? $options['function'] : 'install';
|
||||||
|
|
||||||
if (!vartrue($plug['plugin_installflag']))
|
if (!vartrue($plug['plugin_installflag']))
|
||||||
{
|
{
|
||||||
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
||||||
|
|
||||||
|
$this->log("Installing: ".$plug['plugin_path']);
|
||||||
|
|
||||||
if (file_exists($_path.'plugin.xml'))
|
if (file_exists($_path.'plugin.xml'))
|
||||||
{
|
{
|
||||||
@@ -2926,10 +3061,171 @@ class e107plugin
|
|||||||
$text = EPL_ADLAN_21;
|
$text = EPL_ADLAN_21;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->log("Installation completed"); // no LANs
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function uninstall($id, $options = array())
|
||||||
|
{
|
||||||
|
$pref = e107::getPref();
|
||||||
|
$admin_log = e107::getAdminLog();
|
||||||
|
$plugin = e107::getPlugin();
|
||||||
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
$sql = e107::getDb();
|
||||||
|
$plug = $this->getinfo($id);
|
||||||
|
|
||||||
|
$this->log("Uninstalling :".$plug['plugin_path']." with options: ".print_r($options, true));
|
||||||
|
|
||||||
|
// Check if plugin is being used by another plugin before uninstalling it.
|
||||||
|
if(isset($plug['plugin_path']))
|
||||||
|
{
|
||||||
|
if ($this->isUsedByAnotherPlugin($plug['plugin_path']))
|
||||||
|
{
|
||||||
|
$this->action = 'installed'; // Render plugin list.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = '';
|
||||||
|
//Uninstall Plugin
|
||||||
|
if ($plug['plugin_installflag'] == true )
|
||||||
|
{
|
||||||
|
$eplug_folder = $plug['plugin_path'];
|
||||||
|
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
||||||
|
|
||||||
|
if(file_exists($_path.'plugin.xml'))
|
||||||
|
{
|
||||||
|
unset($_POST['uninstall_confirm']);
|
||||||
|
$this->install_plugin_xml($plug, 'uninstall', $options); //$_POST must be used.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Deprecated - plugin uses plugin.php
|
||||||
|
$eplug_table_names = null;
|
||||||
|
$eplug_prefs = null;
|
||||||
|
$eplug_comment_ids= null;
|
||||||
|
$eplug_array_pref= null;
|
||||||
|
$eplug_menu_name = null;
|
||||||
|
$eplug_link = null;
|
||||||
|
$eplug_link_url = null;
|
||||||
|
$eplug_link_name = null;
|
||||||
|
$eplug_userclass = null;
|
||||||
|
$eplug_version = null;
|
||||||
|
|
||||||
|
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||||
|
|
||||||
|
$func = $eplug_folder.'_uninstall';
|
||||||
|
if (function_exists($func))
|
||||||
|
{
|
||||||
|
$text .= call_user_func($func);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($options['delete_tables']))
|
||||||
|
{
|
||||||
|
|
||||||
|
if (is_array($eplug_table_names))
|
||||||
|
{
|
||||||
|
$result = $this->manage_tables('remove', $eplug_table_names);
|
||||||
|
if ($result !== TRUE)
|
||||||
|
{
|
||||||
|
$text .= EPL_ADLAN_27.' <b>'.MPREFIX.$result.'</b> - '.EPL_ADLAN_30.'<br />';
|
||||||
|
$this->log("Unable to delete table."); // No LANS
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= EPL_ADLAN_28."<br />";
|
||||||
|
$this->log("Deleting tables."); // NO LANS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= EPL_ADLAN_49."<br />";
|
||||||
|
$this->log("Tables left intact by request."); // No LANS
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($eplug_prefs))
|
||||||
|
{
|
||||||
|
$this->manage_prefs('remove', $eplug_prefs);
|
||||||
|
$text .= EPL_ADLAN_29."<br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($eplug_comment_ids))
|
||||||
|
{
|
||||||
|
$text .= ($this->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($eplug_array_pref))
|
||||||
|
{
|
||||||
|
foreach($eplug_array_pref as $key => $val)
|
||||||
|
{
|
||||||
|
$this->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if ($eplug_menu_name)
|
||||||
|
{
|
||||||
|
$sql->delete('menus', "menu_name='{$eplug_menu_name}' ");
|
||||||
|
}*/
|
||||||
|
$folderFiles = scandir(e_PLUGIN.$plug['plugin_path']);
|
||||||
|
$this->XmlMenus($eplug_folder,'uninstall',$folderFiles);
|
||||||
|
|
||||||
|
if ($eplug_link)
|
||||||
|
{
|
||||||
|
$this->manage_link('remove', $eplug_link_url, $eplug_link_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($eplug_userclass)
|
||||||
|
{
|
||||||
|
$this->manage_userclass('remove', $eplug_userclass);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql->update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_path='{$eplug_folder}' ");
|
||||||
|
$this->manage_search('remove', $eplug_folder);
|
||||||
|
|
||||||
|
$this->manage_notify('remove', $eplug_folder);
|
||||||
|
|
||||||
|
// it's done inside install_plugin_xml(), required only here
|
||||||
|
if (isset($pref['plug_installed'][$plug['plugin_path']]))
|
||||||
|
{
|
||||||
|
unset($pref['plug_installed'][$plug['plugin_path']]);
|
||||||
|
}
|
||||||
|
e107::getConfig('core')->setPref($pref);
|
||||||
|
$this->rebuildUrlConfig();
|
||||||
|
e107::getConfig('core')->save(false,true,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
$logInfo = deftrue($plug['plugin_name'],$plug['plugin_name']). " v".$plug['plugin_version']." ({e_PLUGIN}".$plug['plugin_path'].")";
|
||||||
|
e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($_POST['delete_files']) && ($plug['plugin_installflag'] == true))
|
||||||
|
{
|
||||||
|
if(!empty($eplug_folder))
|
||||||
|
{
|
||||||
|
$result = e107::getFile()->rmtree(e_PLUGIN.$eplug_folder);
|
||||||
|
$text .= ($result ? '<br />'.EPL_ADLAN_86.e_PLUGIN.$eplug_folder : '<br />'.EPL_ADLAN_87.'<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->save_addon_prefs('update');
|
||||||
|
|
||||||
|
$this->log("Uninstall completed");
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* scan the plugin table and create path-array-prefs for each addon.
|
* scan the plugin table and create path-array-prefs for each addon.
|
||||||
*
|
*
|
||||||
@@ -3379,7 +3675,7 @@ class e107plugin
|
|||||||
$ret['administration']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small);
|
$ret['administration']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small);
|
||||||
$ret['administration']['configFile'] = varset($eplug_conffile);
|
$ret['administration']['configFile'] = varset($eplug_conffile);
|
||||||
|
|
||||||
if (varset($eplug_conffile))
|
if(varset($eplug_conffile))
|
||||||
{
|
{
|
||||||
$ret['adminLinks']['link'][0]['@attributes']['url'] = varset($eplug_conffile);
|
$ret['adminLinks']['link'][0]['@attributes']['url'] = varset($eplug_conffile);
|
||||||
$ret['adminLinks']['link'][0]['@attributes']['description'] = LAN_CONFIGURE;
|
$ret['adminLinks']['link'][0]['@attributes']['description'] = LAN_CONFIGURE;
|
||||||
@@ -3387,23 +3683,27 @@ class e107plugin
|
|||||||
$ret['adminLinks']['link'][0]['@attributes']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small);
|
$ret['adminLinks']['link'][0]['@attributes']['iconSmall'] = str_replace($plugName."/","",$eplug_icon_small);
|
||||||
$ret['adminLinks']['link'][0]['@attributes']['primary'] = 'true';
|
$ret['adminLinks']['link'][0]['@attributes']['primary'] = 'true';
|
||||||
}
|
}
|
||||||
if (vartrue($eplug_link) && varset($eplug_link_name) && varset($eplug_link_url))
|
if(vartrue($eplug_link) && varset($eplug_link_name) && varset($eplug_link_url))
|
||||||
{
|
{
|
||||||
$ret['siteLinks']['link'][0]['@attributes']['url'] = $tp->createConstants($eplug_link_url, 1);
|
$ret['siteLinks']['link'][0]['@attributes']['url'] = $tp->createConstants($eplug_link_url, 1);
|
||||||
$ret['siteLinks']['link'][0]['@attributes']['perm'] = varset($eplug_link_perms);
|
$ret['siteLinks']['link'][0]['@attributes']['perm'] = varset($eplug_link_perms);
|
||||||
$ret['siteLinks']['link'][0]['@value'] = varset($eplug_link_name);
|
$ret['siteLinks']['link'][0]['@value'] = varset($eplug_link_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vartrue($eplug_userclass) && vartrue($eplug_userclass_description))
|
if(vartrue($eplug_userclass) && vartrue($eplug_userclass_description))
|
||||||
{
|
{
|
||||||
$ret['userClasses']['class'][0]['@attributes']['name'] = $eplug_userclass;
|
$ret['userClasses']['class'][0]['@attributes']['name'] = $eplug_userclass;
|
||||||
$ret['userClasses']['class'][0]['@attributes']['description'] = $eplug_userclass_description;
|
$ret['userClasses']['class'][0]['@attributes']['description'] = $eplug_userclass_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ret['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING));
|
||||||
|
|
||||||
|
|
||||||
// Set this key so we know the vars came from a plugin.php file
|
// Set this key so we know the vars came from a plugin.php file
|
||||||
// $ret['plugin_php'] = true; // Should no longer be needed.
|
// $ret['plugin_php'] = true; // Should no longer be needed.
|
||||||
$this->plug_vars = $ret;
|
$this->plug_vars = $ret;
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3428,8 +3728,10 @@ class e107plugin
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->plug_vars['category'] = (isset($this->plug_vars['category'])) ? $this->manage_category($this->plug_vars['category']) : "misc";
|
|
||||||
$this->plug_vars['folder'] = $plugName; // remove the need for <folder> tag in plugin.xml.
|
$this->plug_vars['folder'] = $plugName; // remove the need for <folder> tag in plugin.xml.
|
||||||
|
$this->plug_vars['category'] = (isset($this->plug_vars['category'])) ? $this->manage_category($this->plug_vars['category']) : "misc";
|
||||||
|
$this->plug_vars['files'] = preg_grep('/^([^.])/', scandir(e_PLUGIN.$plugName,SCANDIR_SORT_ASCENDING));
|
||||||
|
|
||||||
|
|
||||||
if(varset($this->plug_vars['description']))
|
if(varset($this->plug_vars['description']))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user