-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_registerlogin.php
68 lines (67 loc) · 1.97 KB
/
mod_registerlogin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* @package Register Login Joomla Module
* @author JoomDev
* @copyright Copyright (C) 2018 Joomdev, Inc. All rights reserved.
* @license GNU/GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die;
// Include the login functions only once
$language = JFactory::getLanguage();
$language->load('com_users');
require_once __DIR__ . '/helper.php';
$params->def('greeting', 1);
$user = JFactory::getUser();
$layout = $params->get('layout', 'default');
$app = JFactory::getApplication();
$type = modRegisterLoginHelper::getType();
$return = modRegisterLoginHelper::getReturnURL($params, $type);
$jinput = JFactory::getApplication()->input;
// user register
$mName = 'module'.$module->id;
$errorMessage = '';
if($jinput->get($mName) == 'register'){
$registerResponse = modRegisterLoginHelper::getUserRegister($params);
if($registerResponse['error']){
$errorMessage = $registerResponse['error_message'];
if($errorMessage == 'Username in use.'){
$errorMessage = JText::_('COM_USERS_REGISTER_USERNAME_MESSAGE');
}
}else{
$useractivation = $params->def('useractivation');
if ($useractivation == 0)
{
$messge = JText::_('COM_USERS_REGISTRATION_SAVE_SUCCESS');
}
elseif ($useractivation == 1)
{
$messge = JText::_('COM_USERS_REGISTRATION_COMPLETE_ACTIVATE');
}else{
$messge = JText::_('COM_USERS_REGISTRATION_COMPLETE_VERIFY');
}
$app->enqueueMessage($messge, 'Success');
if($params->get('login')){
$app->redirect(base64_decode($return));
}else{
$app->redirect(JURI::current());
}
}
}
//user login
$loginResponse = '';
$mName = 'module'.$module->id;
if($jinput->get($mName) == 'login'){
$loginResponse = modRegisterLoginHelper::getUserlogin($params);
if(!$loginResponse['error']){
if($params->get('login')){
$app->redirect(base64_decode($return));
}else{
$app->redirect(JURI::current());
}
}
}
if (!$user->guest)
{
$layout .= '_logout';
}
require JModuleHelper::getLayoutPath('mod_registerlogin', $layout);