mirror of
https://github.com/e107inc/e107.git
synced 2025-05-02 10:19:16 +02:00
Sigin plugin/shortcode added.
This commit is contained in:
parent
ffc605f936
commit
515d81ebb7
@ -4521,7 +4521,7 @@ class e_parser
|
||||
}
|
||||
|
||||
$title = (ADMIN) ? $image : $tp->toAttribute($userData['user_name']);
|
||||
$shape = (!empty($options['shape'])) ? 'img-' .$options['shape'] : 'img-rounded rounded ';
|
||||
$shape = (!empty($options['shape'])) ? 'img-' .$options['shape'] : 'img-rounded rounded';
|
||||
|
||||
if($shape === 'img-circle')
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ class pm_shortcodes extends e_shortcode
|
||||
$urlOutbox = e107::url('pm','index','', array('query'=>array('mode'=>'outbox')));
|
||||
$urlCompose = e107::url('pm','index','', array('query'=>array('mode'=>'send')));
|
||||
|
||||
return '<a class="dropdown-toggle" data-toggle="dropdown" data-bs-toggle="dropdown" href="#">'.$icon.$count.'</a>
|
||||
return '<a class="nav-link dropdown-toggle" data-toggle="dropdown" data-bs-toggle="dropdown" href="#">'.$icon.$count.'</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
|
||||
|
76
e107_plugins/signin/e_shortcode.php
Normal file
76
e107_plugins/signin/e_shortcode.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
|
||||
* $Id: e_shortcode.php 12438 2011-12-05 15:12:56Z secretr $
|
||||
*
|
||||
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
|
||||
*/
|
||||
|
||||
if(!defined('e107_INIT'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class signin_shortcodes extends e_shortcode
|
||||
{
|
||||
public $override = false; // when set to true, existing core/plugin shortcodes matching methods below will be overridden.
|
||||
private $lsc;
|
||||
|
||||
|
||||
/**
|
||||
* @example {SIGNIN} shortcode - available site-wide.
|
||||
* @param null $parm
|
||||
* @return string
|
||||
*/
|
||||
function sc_signin($parm = null) // Naming: "sc_" + [plugin-directory] + '_uniquename'
|
||||
{
|
||||
e107::includeLan(e_PLUGIN."login_menu/languages/".e_LANGUAGE.".php");
|
||||
|
||||
$this->lsc = e107::getScBatch('signin', 'signin');
|
||||
|
||||
if(USERID) // Logged Out.
|
||||
{
|
||||
return $this->signOut($parm);
|
||||
}
|
||||
|
||||
return $this->signIn($parm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form to show to GUESTS.
|
||||
*
|
||||
* @param null $parm
|
||||
* @return string
|
||||
*/
|
||||
private function signIn($parm=null)
|
||||
{
|
||||
$template = e107::getTemplate('signin', 'signin', 'signin');
|
||||
|
||||
$this->lsc->wrapper('signin/signin');
|
||||
|
||||
return e107::getParser()->parseTemplate($template, true, $this->lsc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Form to show to MEMBERS.
|
||||
* @param null $parm
|
||||
* @return string
|
||||
*/
|
||||
private function signOut($parm=null)
|
||||
{
|
||||
// Logged in.
|
||||
$this->lsc->wrapper('signin/signout');
|
||||
|
||||
$template = e107::getTemplate('signin', 'signin', 'signout'); // todo
|
||||
|
||||
return e107::getParser()->parseTemplate($template, true, $this->lsc);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
4
e107_plugins/signin/plugin.xml
Normal file
4
e107_plugins/signin/plugin.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<e107Plugin name="Signin" version="1.0" date="2020-12-29" compatibility="2.0" installRequired="false" >
|
||||
<category>menu</category>
|
||||
</e107Plugin>
|
274
e107_plugins/signin/signin_shortcodes.php
Normal file
274
e107_plugins/signin/signin_shortcodes.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| Copyright (C) 2008-2009 e107 Inc
|
||||
| http://e107.org
|
||||
|
|
||||
|
|
||||
| Released under the terms and conditions of the
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('e107_INIT'))
|
||||
{
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
class plugin_signin_signin_shortcodes extends e_shortcode
|
||||
{
|
||||
|
||||
private $use_imagecode = 0;
|
||||
private $sec;
|
||||
private $usernamePlaceholder = LAN_LOGINMENU_1;
|
||||
private $allowEmailLogin;
|
||||
private $authMethod;
|
||||
private $regMode;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
$this->use_imagecode = e107::getConfig()->get('logcode');
|
||||
$this->sec = e107::getSecureImg();
|
||||
$this->usernamePlaceholder = '';
|
||||
$this->allowEmailLogin = $pref['allowEmailLogin'];
|
||||
|
||||
if ($pref['allowEmailLogin'] == 1)
|
||||
{
|
||||
$this->usernamePlaceholder = LAN_LOGINMENU_49;
|
||||
}
|
||||
|
||||
if ($pref['allowEmailLogin'] == 2)
|
||||
{
|
||||
$this->usernamePlaceholder = LAN_LOGINMENU_50;
|
||||
}
|
||||
|
||||
$this->regMode = (int) defset('USER_REGISTRATION');
|
||||
|
||||
$this->authMethod = varset($pref['auth_method'], 'e107');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $parm
|
||||
* @return null|string
|
||||
*/
|
||||
function sc_signin_active($parm = array())
|
||||
{
|
||||
|
||||
// $request = e_REQUEST_URI;
|
||||
|
||||
$ret = null;
|
||||
|
||||
$mode = varset($parm['mode']);
|
||||
|
||||
if ($mode === 'settings' && defset('e_PAGE') === 'usersettings.php')
|
||||
{
|
||||
return 'active';
|
||||
}
|
||||
elseif ($mode === 'profile' && defset('e_PAGE') === 'user.php')
|
||||
{
|
||||
return 'active';
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_input_username($parm = null)
|
||||
{
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
// If logging in with email address - ignore pref and increase to 100 chars.
|
||||
$maxLength = ($this->allowEmailLogin == 1 || $this->allowEmailLogin) ? 100 : varset($pref['loginname_maxlength'], 30);
|
||||
|
||||
return "
|
||||
<label class='sr-only' for='" . vartrue($parm['idprefix']) . "username'>" . $this->usernamePlaceholder . "</label>
|
||||
<input class='form-control tbox login user' type='text' name='username' placeholder='" . $this->usernamePlaceholder . "' required='required' id='" . vartrue($parm['idprefix']) . "username' size='15' value='' maxlength='" . $maxLength . "' />\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_signin_username($parm=null)
|
||||
{
|
||||
return !empty($parm['username']) ? USERNAME : '';
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_input_password($parm = null)
|
||||
{
|
||||
|
||||
$pref = e107::getPref();
|
||||
$t_password = "
|
||||
<label class='sr-only' for='" . vartrue($parm['idprefix']) . "userpass'>" . LAN_PASSWORD . "</label>
|
||||
<input class='form-control tbox login pass' type='password' placeholder='" . LAN_PASSWORD . "' required='required' name='userpass' id='" . vartrue($parm['idprefix']) . "userpass' size='15' value='' maxlength='30' />\n";
|
||||
|
||||
if (!USER && e107::getSession()->is('challenge') && varset($pref['password_CHAP'], 0))
|
||||
{
|
||||
$t_password .= "<input type='hidden' name='hashchallenge' id='hashchallenge' value='" . e107::getSession()->get('challenge') . "' />\n\n";
|
||||
}
|
||||
|
||||
return $t_password;
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_password_label($parm = '')
|
||||
{
|
||||
return LAN_LOGINMENU_2;
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_imagecode_number($parm = '')
|
||||
{
|
||||
|
||||
if ($this->use_imagecode)
|
||||
{
|
||||
return e107::getSecureImg()->renderImage();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function sc_signin_form($parm=null)
|
||||
{
|
||||
return ($parm === 'start') ? '<form method="post" onsubmit="hashLoginPassword(this);return true" action="'.e_REQUEST_HTTP.'" accept-charset="UTF-8">' : '</form>';
|
||||
}
|
||||
|
||||
function sc_signin_imagecode_box($parm = '')
|
||||
{
|
||||
|
||||
if ($this->use_imagecode)
|
||||
{
|
||||
return e107::getSecureImg()->renderInput();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_signin_rememberme($parm = '')
|
||||
{
|
||||
|
||||
$pref = e107::getPref();
|
||||
if ($parm == "hidden")
|
||||
{
|
||||
return "<input type='hidden' name='autologin' id='autologin' value='1' />";
|
||||
}
|
||||
if ($pref['user_tracking'] !== "session")
|
||||
{
|
||||
return "<label for='autologin'><input type='checkbox' name='autologin' id='autologin' value='1' checked='checked' />" . ($parm ? $parm : "" . LAN_LOGINMENU_6 . "</label>");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function sc_signin_signup_href($parm = '')
|
||||
{
|
||||
|
||||
if ($this->regMode !== 1 || $this->authMethod !== 'e107')
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return e_SIGNUP;
|
||||
|
||||
}
|
||||
|
||||
function sc_signin_resend_href($parm=null)
|
||||
{
|
||||
if ($this->regMode !== 1 || $this->authMethod !== 'e107')
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return e_SIGNUP . '?resend';
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_signin_fpw_href($parm=null)
|
||||
{
|
||||
return SITEURL . 'fpw.php';
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_maintenance($parm = '')
|
||||
{
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
if (ADMIN && !empty($pref['maintainance_flag']))
|
||||
{
|
||||
return LAN_LOGINMENU_10;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_pm_nav($parm=null)
|
||||
{
|
||||
if(!e107::isInstalled('pm') )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$sc = e107::getScBatch('pm', true);
|
||||
|
||||
return $sc->sc_pm_nav($parm);;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function sc_signin_admin_href($parm = '')
|
||||
{
|
||||
// '<li><a href="'.e_ADMIN_ABS.'"><span class="fa fa-cogs"></span> '.LAN_LOGINMENU_11.'</a></li>';
|
||||
if (ADMIN == true)
|
||||
{
|
||||
return e_ADMIN_ABS; // . 'admin.php' : '<a class="signin-sc admin" id="signin-sc-admin" href="' . e_ADMIN_ABS . 'admin.php">' . LAN_LOGINMENU_11 . '</a>';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
function sc_signin_usersettings_href($parm = null)
|
||||
{
|
||||
return e107::getUrl()->create('user/myprofile/edit', array('id' => USERID));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo- to be merged with sc_signin_profile() ?
|
||||
* @param string $parm
|
||||
* @return string
|
||||
*/
|
||||
function sc_signin_profile_href($parm = '')
|
||||
{
|
||||
return e107::getUrl()->create('user/profile/view', array('user_id' => USERID, 'user_name' => USERNAME));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function sc_signin_logout_href($parm = '')
|
||||
{
|
||||
return e_HTTP . 'index.php?logout';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
69
e107_plugins/signin/templates/signin_template.php
Normal file
69
e107_plugins/signin/templates/signin_template.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
// Do not use constants.. use {LAN=xxx} instead.
|
||||
// Template compatible with Bootstrap 5 only.
|
||||
|
||||
$SIGNIN_TEMPLATE = [];
|
||||
|
||||
|
||||
$SIGNIN_WRAPPER['signin']['SIGNIN_SIGNUP_HREF'] = '<li class="nav-item"><a class="nav-link" href="{---}">{LAN=LAN_LOGINMENU_3}</a></li>';
|
||||
|
||||
$SIGNIN_TEMPLATE['signin'] = '
|
||||
<ul class="nav navbar-nav navbar-right nav-right">
|
||||
{SIGNIN_SIGNUP_HREF}
|
||||
<li class="divider-vertical"></li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#" data-toggle="dropdown">{LAN=LAN_LOGINMENU_51} <strong class="caret"></strong></a>
|
||||
<div class="dropdown-menu col-sm-12" style="min-width:250px; padding: 15px; padding-bottom: 0px;">
|
||||
|
||||
{SIGNIN_FORM=start}
|
||||
<p>{SIGNIN_INPUT_USERNAME}</p>
|
||||
<p>{SIGNIN_INPUT_PASSWORD}</p>
|
||||
|
||||
<div class="form-group"></div>
|
||||
{SIGNIN_IMAGECODE_NUMBER}
|
||||
{SIGNIN_IMAGECODE_BOX}
|
||||
|
||||
<div class="checkbox">
|
||||
<label class="string optional" for="bs3-autologin"><input style="margin-right: 10px;" type="checkbox" name="autologin" id="bs3-autologin" value="1">
|
||||
{LAN=LAN_LOGINMENU_6}</label>
|
||||
</div>
|
||||
<div class="d-grid gap-2" style="padding-bottom:15px">
|
||||
<input class="btn btn-primary btn-block" type="submit" name="userlogin" id="bs3-userlogin" value="{LAN=LAN_LOGINMENU_51}">
|
||||
<a href="{SIGNIN_FPW_HREF}" class="btn btn-default btn-secondary btn-sm btn-block">{LAN=LAN_LOGINMENU_4}</a>
|
||||
<a href="{SIGNIN_RESEND_LINK=href}" class="btn btn-default btn-secondary btn-sm btn-block">{LAN=LAN_LOGINMENU_40}</a>
|
||||
</div>
|
||||
{SIGNIN_FORM=end}
|
||||
</div>
|
||||
|
||||
</li>
|
||||
|
||||
</ul>';
|
||||
|
||||
|
||||
|
||||
$SIGNIN_WRAPPER['signout']['SIGNIN_ADMIN_HREF'] = '<li class="list-group-item"><a class="signin-sc admin" id="signin-sc-admin" href="{---}"><span class="fa fa-cogs"></span> {LAN=LAN_LOGINMENU_11}</a></li>';
|
||||
$SIGNIN_WRAPPER['signout']['SIGNIN_PM_NAV'] = '<li class="dropdown">{---}</li>';
|
||||
|
||||
|
||||
$SIGNIN_TEMPLATE['signout'] = '
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{SIGNIN_PM_NAV}
|
||||
<li class="dropdown dropdown-avatar"><a href="#" class="nav-link dropdown-toggle" data-bs-toggle="dropdown">{USER_AVATAR: w=30&h=30&crop=1&shape=circle} {SIGNIN_USERNAME} <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu ">
|
||||
<li class="list-group-item">
|
||||
<a href="{SIGNIN_USERSETTINGS_HREF}"><span class="fa fa-cog"></span> {LAN=LAN_SETTINGS}</a>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<a role="button" href="{SIGNIN_PROFILE_HREF}"><span class="fa fa-user"></span> {LAN=LAN_LOGINMENU_13}</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
{SIGNIN_ADMIN_HREF}
|
||||
<li class="list-group-item"><a href="{SIGNIN_LOGOUT_HREF}"><span class="fa fa-power-off"></span> {LAN=LAN_LOGOUT}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
';
|
||||
|
File diff suppressed because one or more lines are too long
@ -947,7 +947,7 @@ while($row = $sql->fetch())
|
||||
'parms' => array('w'=>30, 'h'=>30, 'shape'=>'circle', 'alt'=>'mytitle'),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_AVATAR%7Ddefault%2Favatartest.png&w=30&h=30",
|
||||
"class='img-circle user-avatar'",
|
||||
"class='img-circle rounded-circle user-avatar'",
|
||||
'alt="mytitle"',
|
||||
)
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user