- md5
- 20addd34abf586f4e1e0cb6a3c0fa0dc
- sha1
- 4b3e667bc83d34ff126533167be11d8ae5bc93a4
- sha256
- 578f86d32057f6a4bb532ce959e19d6ee93944beab2ef20619f629ee312882d4
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
<?php
/**
* @package Joomla.Plugin
* @subpackage Twofactorauth.totp
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* This file contains the functions used by the com_postinstall code to deliver
* the necessary post-installation messages concerning the activation of the
* two-factor authentication code.
*/
/**
* Checks if the plugin is enabled. If not it returns true, meaning that the
* message concerning two factor authentication should be displayed.
*
* @return integer
*
* @since 3.2
*/
function twofactorauth_postinstall_condition()
{
$db = JFactory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__extensions'))
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('enabled') . ' = ' . $db->quote('1'))
->where($db->quoteName('folder') . ' = ' . $db->quote('twofactorauth'));
$db->setQuery($query);
$enabled_plugins = $db->loadObjectList();
return count($enabled_plugins) === 0;
}
/**
* Enables the two factor authentication plugin and redirects the user to their
* user profile page so that they can enable two factor authentication on their
* account.
*
* @return void
*
* @since 3.2
*/
function twofactorauth_postinstall_action()
{
// Enable the plugin
$db = JFactory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = ' . $db->quote(1))
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('twofactorauth'));
$db->setQuery($query);
$db->execute();
// Redirect the user to their profile editor page
$url = 'index.php?option=com_users&task=user.edit&id=' . JFactory::getUser()->id;
JFactory::getApplication()->redirect($url);
}
No other release has this exact content. See every version of this file.