From 8d13c27638ad97f363297bb6e7909c5f97a4e322 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 13 Mar 2016 17:57:51 -0700 Subject: [PATCH] Fix for login/signup message on comment form. Allow login page to load if social signup is active. --- .../shortcodes/batch/login_shortcodes.php | 80 +++++++++++++++---- e107_core/templates/login_template.php | 3 +- e107_handlers/comment_class.php | 40 +++++++++- e107_languages/English/lan_comment.php | 7 ++ e107_plugins/social/e_shortcode.php | 9 ++- e107_themes/bootstrap3/theme_shortcodes.php | 2 +- login.php | 3 +- 7 files changed, 125 insertions(+), 19 deletions(-) diff --git a/e107_core/shortcodes/batch/login_shortcodes.php b/e107_core/shortcodes/batch/login_shortcodes.php index 6566ab24e..64b72b5c6 100644 --- a/e107_core/shortcodes/batch/login_shortcodes.php +++ b/e107_core/shortcodes/batch/login_shortcodes.php @@ -14,10 +14,13 @@ if (!defined('e107_INIT')) { exit; } class login_shortcodes extends e_shortcode { var $secImg = false; - + protected $userReg = false; // user registration pref. + + function __construct() { $pref = e107::getPref(); + $this->userReg = intval($pref['user_reg']); $this->secImg = ($pref['logcode'] && extension_loaded("gd")) ? true : false; } @@ -31,11 +34,22 @@ class login_shortcodes extends e_shortcode function sc_login_table_loginmessage($parm='') { - return LOGINMESSAGE; + if(empty($this->userReg)) + { + return null; + } + + return LOGINMESSAGE; } function sc_login_table_username($parm='') //FIXME use $frm { + + if(empty($this->userReg)) + { + return null; + } + $pref = e107::getPref(); $allowEmailLogin = varset($pref['allowEmailLogin'],0); $ulabel = array(LAN_LOGIN_1,LAN_LOGIN_28,LAN_LOGIN_29); @@ -47,6 +61,11 @@ class login_shortcodes extends e_shortcode function sc_login_table_password($parm='') //FIXME use $frm { + if(empty($this->userReg)) + { + return null; + } + $pref = e107::getPref(); $text = ""; @@ -59,6 +78,11 @@ class login_shortcodes extends e_shortcode function sc_login_table_secimg_lan($parm='') { + if(empty($this->userReg)) + { + return null; + } + if(!$this->secImg){ return; } return e107::getSecureImg()->renderLabel(); // return LAN_LOGIN_13; @@ -73,6 +97,11 @@ class login_shortcodes extends e_shortcode function sc_login_table_secimg_secimg($parm='') { + if(empty($this->userReg)) + { + return null; + } + if(!$this->secImg){ return; } return e107::getSecureImg()->renderImage(); // return e107::getSecureImg()->r_image(); @@ -80,6 +109,11 @@ class login_shortcodes extends e_shortcode function sc_login_table_secimg_textboc($parm='') { + if(empty($this->userReg)) + { + return null; + } + if(!$this->secImg){ return; } return e107::getSecureImg()->renderInput(); // return ""; @@ -87,24 +121,43 @@ class login_shortcodes extends e_shortcode function sc_login_table_autologin($parm='')//FIXME use $frm { + if(empty($this->userReg)) + { + return null; + } + return ""; } function sc_login_table_autologin_lan($parm='') { + if(empty($this->userReg)) + { + return null; + } + return LAN_LOGIN_8; } function sc_login_table_rememberme($parm=null) { + if(empty($this->userReg)) + { + return null; + } + return e107::getForm()->checkbox('autologin',1,false,LAN_LOGIN_8); } function sc_login_table_submit($parm="") //FIXME use $frm { - + if(empty($this->userReg)) + { + return null; + } + $class = ($parm == 'large') ? "btn-large btn-lg" : ""; return ""; } @@ -112,18 +165,17 @@ class login_shortcodes extends e_shortcode function sc_login_table_footer_userreg($parm='') { - $pref = e107::getPref(); + //$pref = e107::getPref(); + + if(empty($this->userReg)) + { + return null; + } - if ($pref['user_reg']) - { - $text = "".LAN_LOGIN_11.""; - $text .= "   ".LAN_LOGIN_12.""; - return $text; - } - else - { - return ' '; // In case no registration system enabled - } + $text = "".LAN_LOGIN_11.""; + $text .= "   ".LAN_LOGIN_12.""; + return $text; + } diff --git a/e107_core/templates/login_template.php b/e107_core/templates/login_template.php index 75c3e1aa7..4fb716984 100644 --- a/e107_core/templates/login_template.php +++ b/e107_core/templates/login_template.php @@ -112,8 +112,9 @@ $LOGIN_WRAPPER['page']['LOGIN_TABLE_SUBMIT'] = "
{---}".COMLAN_6." ".COMLAN_321." ".COMLAN_322."
"; + $userReg = intval(e107::pref('core','user_reg')); + $socialLogin = e107::pref('core','social_login_active'); + + $text = "
"; + + $srch = array("[","]"); + + if(!empty($userReg) || !empty($socialLogin)) + { + + $COMLAN_500 = COMLAN_500; // Please [sign in] to leave a comment. + + $repl = array("",""); + + $text .= "
".str_replace($srch,$repl,$COMLAN_500)."
"; + + + if(!empty($socialLogin)) + { + $text .= $tp->parseTemplate("{SOCIAL_LOGIN}",true); + // $text .= "
"; + } + } + + if($userReg === 1) + { + $COMLAN_501 = COMLAN_501; // If you are not yet registered, you may [click here to register]. + + $repl = array("",""); + + $text .= "
".str_replace($srch,$repl,$COMLAN_501)."
"; + } + + $text .= "
"; + + + // $text = "
".COMLAN_6." ".COMLAN_321." ".COMLAN_322."
"; } + + if ($return) { return $text; diff --git a/e107_languages/English/lan_comment.php b/e107_languages/English/lan_comment.php index 17182be0c..2999d6f09 100644 --- a/e107_languages/English/lan_comment.php +++ b/e107_languages/English/lan_comment.php @@ -79,4 +79,11 @@ define("COMLAN_TYPE_6", "bugtrack"); define("COMLAN_TYPE_7", "ideas"); define("COMLAN_TYPE_8", "userprofile"); define("COMLAN_TYPE_PAGE", "Content"); // Really custom page, but use a 'non-technical' description + +define("COMLAN_500", "Please [sign in] to leave a comment."); +define("COMLAN_501", "If you are not yet registered, you may [click here to register]."); + + + + ?> \ No newline at end of file diff --git a/e107_plugins/social/e_shortcode.php b/e107_plugins/social/e_shortcode.php index 39061143e..1d220c94e 100644 --- a/e107_plugins/social/e_shortcode.php +++ b/e107_plugins/social/e_shortcode.php @@ -130,7 +130,14 @@ class social_shortcodes extends e_shortcode } $sc = e107::getScBatch('signup'); - $text = "

Sign in with:

"; + + $text = ''; + + if(!empty($parm['label'])) + { + $text .= "

Sign in with:

"; + } + $text .= $sc->sc_signup_xup_login($parm); $text .= "

"; diff --git a/e107_themes/bootstrap3/theme_shortcodes.php b/e107_themes/bootstrap3/theme_shortcodes.php index 7f736fe93..992b2f07c 100644 --- a/e107_themes/bootstrap3/theme_shortcodes.php +++ b/e107_themes/bootstrap3/theme_shortcodes.php @@ -108,7 +108,7 @@ class theme_shortcodes extends e_shortcode '.LAN_LOGINMENU_51.'