สำหรับ นักพัฒนา ต้องสมัครสมาชิกก่อนเข้าระบบเพื่อ clone โค้ด

Commit 5f275d4e authored by Nahm's avatar Nahm

1.0.0

- เพิ่มแสดงปุ่มสำหรับเข้าสู่ระบบด้วย Gmail
parents
; @package Module M Gmail Login
; @subpackage mod_mgmail_login
; @author Mindphp Developer Teams
; @copyright Copyright (C) 2021 Mindphp. All rights reserved..
; @license GNU General Public License version 2 or later;
MOD_MGMAIL_LOGIN = "M Gmail Login"
MOD_MGMAIL_LOGIN_DESC = "This module for login with gmail"
MOD_MGMAIL_LOGIN_BTN = "Login With Gmail"
\ No newline at end of file
; @package Module M Gmail Login
; @subpackage mod_mgmail_login
; @author Mindphp Developer Teams
; @copyright Copyright (C) 2021 Mindphp. All rights reserved..
; @license GNU General Public License version 2 or later;
MOD_MGMAIL_LOGIN = "M Gmail Login"
MOD_MGMAIL_LOGIN_DESC = "This module for login with gmail"
\ No newline at end of file
; @package Module M Gmail Login
; @subpackage mod_mgmail_login
; @author Mindphp Developer Teams
; @copyright Copyright (C) 2021 Mindphp. All rights reserved..
; @license GNU General Public License version 2 or later;
MOD_MGMAIL_LOGIN = "เอ็ม เข้าสู่ระบบด้วยจีเมล"
MOD_MGMAIL_LOGIN_DESC = "โมดูลนี้สำหรับเข้าสู่ระบบด้วยจีเมล"
MOD_MGMAIL_LOGIN_BTN = "เข้าสู่ระบบด้วย Gmail"
\ No newline at end of file
; @package Module M Gmail Login
; @subpackage mod_mgmail_login
; @author Mindphp Developer Teams
; @copyright Copyright (C) 2021 Mindphp. All rights reserved..
; @license GNU General Public License version 2 or later;
MOD_MGMAIL_LOGIN = "เอ็ม เข้าสู่ระบบด้วยจีเมล"
MOD_MGMAIL_LOGIN_DESC = "โมดูลนี้สำหรับเข้าสู่ระบบด้วยจีเมล"
\ No newline at end of file
<?php
/**
* @package Module M Gmail Login
* @subpackage mod_mgmail_login
* @author Mindphp Developer Teams
* @copyright Copyright (C) 2021 Mindphp. All rights reserved..
* @license GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Component\ComponentHelper;
if (ComponentHelper::isInstalled('com_mgmail'))
{
$component_params = ComponentHelper::getParams('com_mgmail');
$client_id = $component_params->get('client_id');
if ($client_id)
{
require_once JPATH_ADMINISTRATOR . '/components/com_mgmail/global.php';
$doc = Factory::getDocument();
$doc->setMetaData('google-signin-client_id', $client_id);
$attribs = array (
'async' => 'async',
'defer' => 'defer'
);
$doc->addScript('https://apis.google.com/js/platform.js?onload=renderButton', array (), $attribs);
$doc->addStyleDeclaration("
#mgmail_login img {
display: inline;
}
");
$doc->addScriptDeclaration("
function onSuccess(googleUser) {
let profile = googleUser.getBasicProfile();
let data = {
'id': profile.getId(),
'name': profile.getName(),
'email': profile.getEmail(),
'" . Factory::getSession()->getFormToken() . "': 1
};
jQuery.post('index.php?option=com_mgmail&task=check', data, function(result) {
if (typeof result === 'object' && result !== null) {
if (result.status == 'success') {
window.location.reload();
} else {
alert(result.error);
}
} else {
alert(result);
}
});
}
function onFailure(error) {
console.log(error);
}
function renderButton() {
gapi.signin2.render('mgmail_login', {
'scope': 'profile email',
'width': 240,
'height': 50,
'longtitle': true,
'theme': 'dark',
'onsuccess': onSuccess,
'onfailure': onFailure
});
}
");
require JModuleHelper::getLayoutPath('mod_mgmail_login');
}
else
{
echo JText::_('MOD_MGMAIL_LOGIN_APPID_NOT_FOUND');
}
}
else
{
echo JText::_('MOD_MGMAIL_LOGIN_COMPONENT_NOT_FOUND');
}
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1" client="site" method="upgrade">
<name>mod_mgmail_login</name>
<author>Mindphp Developer Teams</author>
<creationDate>May 2021</creationDate>
<copyright>(C) 2021 Mindphp. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later</license>
<authorEmail>shop.mindphp@gmail.com</authorEmail>
<authorUrl>https://www.mindphp.com</authorUrl>
<version>1.0.0</version>
<description>MOD_MGMAIL_LOGIN_DESC</description>
<files>
<folder>language</folder>
<folder>tmpl</folder>
<filename module="mod_mgmail_login">mod_mgmail_login.php</filename>
</files>
<config>
<fields name="params">
</fields>
</config>
<updateservers>
<server type="extension" priority="1" name="mod_mgmail_login">https://www.mindphp.com/update_server.php?element=mod_mgmail_login&amp;type=module</server>
</updateservers>
</extension>
<?php
/**
* @package Module M Gmail Login
* @subpackage mod_mgmail_login
* @author Mindphp Developer Teams
* @copyright Copyright (C) 2021 Mindphp. All rights reserved..
* @license GNU General Public License version 2 or later;
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
if (Factory::getUser()->guest)
{
echo '<div id="mgmail_login"></div>';
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment