From d09858945607133dafeab3f933b6eb6f8d548324 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 30 Apr 2016 12:02:02 -0700 Subject: [PATCH] Fix for plugin repair (in debug mode) Fix for Login page signup link when registration is disabled. --- e107_admin/plugin.php | 35 +++++++++++++------ .../shortcodes/batch/login_shortcodes.php | 9 +++-- e107_handlers/plugin_class.php | 30 ++++++++++++---- e107_handlers/shortcode_handler.php | 9 +++-- e107_themes/bootstrap3/theme_shortcodes.php | 11 ++++++ 5 files changed, 69 insertions(+), 25 deletions(-) diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 242d57b69..52c276590 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -164,7 +164,7 @@ class pluginmanager_form extends e_form if ($this->plug['plugin_installflag'] && e_DEBUG == true) { - $text .= " ".ADMIN_REPAIRPLUGIN_ICON.""; + $text .= " ".ADMIN_REPAIRPLUGIN_ICON.""; } @@ -344,6 +344,12 @@ class pluginManager{ $this -> pluginUninstall(); $this -> pluginCheck(true); // forced } + + if($this->action == "repair") + { + $this -> pluginRepair(); + $this->action = 'refresh'; + } if($this->action == "refresh") { @@ -376,10 +382,8 @@ class pluginManager{ $this -> action = "installed"; } - if($this->action == "refresh") - { - $this -> pluginRefresh(); - } + + if($this->action == "upload") { $this -> pluginUpload(); @@ -1084,9 +1088,9 @@ class pluginManager{ // ----------------------------------------------------------------------------- - function pluginRefresh() + function pluginRepair() { - global $plug; + // global $plug; $plug = e107::getSingleton('e107plugin')->getinfo($this->id); @@ -2345,7 +2349,10 @@ class pluginBuilder { $createData = str_replace("`".MPREFIX, '`', $data[1]); $createData .= ";"; - file_put_contents($file,$createData); + if(!file_exists($file)) + { + file_put_contents($file,$createData); + } } } @@ -2567,9 +2574,17 @@ class pluginBuilder if($content = file_get_contents($source)) { $content = str_replace($srch, $this->pluginName, $content); - if(file_put_contents($destination,$content)) + + if(!file_exists($destination)) { - $result[] = LAN_CREATED." : ".$addon; + if(file_put_contents($destination,$content)) + { + $result[] = LAN_CREATED." : ".$addon; + } + } + else + { + $result[] = "Skipped (already exists) : ".$addon; } } else diff --git a/e107_core/shortcodes/batch/login_shortcodes.php b/e107_core/shortcodes/batch/login_shortcodes.php index a5328d506..e207959e8 100644 --- a/e107_core/shortcodes/batch/login_shortcodes.php +++ b/e107_core/shortcodes/batch/login_shortcodes.php @@ -180,16 +180,15 @@ class login_shortcodes extends e_shortcode function sc_login_table_signup_link($parm='') { - if(empty($this->userReg)) + if($this->userReg === 1) { - return null; + return "".LAN_LOGIN_11.""; } - return "".LAN_LOGIN_11.""; - - + return null; } + function sc_login_table_fpw_link($parm='') { if(empty($this->userReg)) diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 417e557db..90096a2d9 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -1423,6 +1423,8 @@ class e107plugin $mes = e107::getMessage(); $event = e107::getEvent(); + $mes->addDebug("Running ".$function); + $error = array(); // Array of error messages $canContinue = TRUE; // Clear flag if must abort part way through @@ -1563,7 +1565,7 @@ class e107plugin $this->XmlAdminLinks($function, $plug_vars['adminLinks']); } - if (varset($plug_vars['siteLinks'])) + if (!empty($plug_vars['siteLinks'])) { $this->XmlSiteLinks($function, $plug_vars); } @@ -2024,8 +2026,13 @@ class e107plugin { return; } - - // print_a($plug_vars); + + if($function == 'refresh') + { + $mes->addDebug("Checking Plugin Site-links"); + $mes->addDebug(print_a($plug_vars['siteLinks'],true)); + } + $array = $plug_vars['siteLinks']; @@ -2050,9 +2057,17 @@ class e107plugin { case 'upgrade': case 'install': + case 'refresh': if (!$remove) // Add any non-deprecated link { + + if($function == 'refresh') + { + $perm = 'nobody'; + + } + $result = $this->manage_link('add', $url, $linkName, $perm, $options); if($result !== NULL) { @@ -2068,8 +2083,6 @@ class e107plugin } break; - case 'refresh': // Probably best to leave well alone - break; case 'uninstall': //remove all links @@ -2705,14 +2718,17 @@ class e107plugin if (file_exists($_path.'plugin.xml')) { - $text = $this->install_plugin_xml($plug, 'refresh'); + $this->install_plugin_xml($plug, 'refresh'); } else { + e107::getMessage()->addDebug("Missing xml file at : ".$_path."plugin.xml"); $text = EPL_ADLAN_21; } - + + e107::getMessage()->addDebug("Running Refresh of ".$_path); + $this->save_addon_prefs(); return $text; diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 197996ffa..588727396 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -838,14 +838,16 @@ class e_parse_shortcode // XXX remove all globals, $sc_style removed global $pref, $e107cache, $menu_pref, $parm, $sql; - $parmArray = false; - $fullShortcodeKey = null; + $parmArray = false; + $fullShortcodeKey = null; + $noDebugLog = false; if ($this->eVars) { if ($this->eVars->isVar($matches[1])) { $match1 = $matches[1]; // php7 fix. + // e107::getDebug()->log("Using eVars ".$match1); return $this->eVars->$match1; } } @@ -923,6 +925,7 @@ class e_parse_shortcode { $debugArr = array('class_original'=>get_class($this->addedCodes), 'class_override'=>$this->addonOverride[$_method], 'function'=>$_method); e107::getDebug()->logCode(4, $code, null, print_a($debugArr,true)); + $noDebugLog = true; } @@ -1201,7 +1204,7 @@ class e_parse_shortcode $sql->db_Mark_Time("(After SC {$code})"); } - if (E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS) + if (($noDebugLog != true) && (E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS)) { global $db_debug; diff --git a/e107_themes/bootstrap3/theme_shortcodes.php b/e107_themes/bootstrap3/theme_shortcodes.php index a584aa8ae..bcf5121cf 100644 --- a/e107_themes/bootstrap3/theme_shortcodes.php +++ b/e107_themes/bootstrap3/theme_shortcodes.php @@ -13,12 +13,23 @@ class theme_shortcodes extends e_shortcode { + public $override = true; + function __construct() { } + function sc_news_summary() + { + $sc = e107::getScBatch('news'); + $data = $sc->getScVar('news_item'); + + return "".e107::getParser()->toHTML($data['news_summary'],'BODY').""; + } + + function sc_bootstrap_branding() { $pref = e107::pref('theme', 'branding');