- md5
- c377c42b8d8a7098a0801fc5d5ebc8a7
- sha1
- a303f70c9a76e04749897f20739c0ed27da214e4
- sha256
- 3deffca988566086961bcb999d678ba03fc0e1dabd7353f1c33994c7e23c935b
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
<?php
/**
* @package Joomla.Plugin
* @subpackage Twofactorauth.totp
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @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.
*/
use Joomla\CMS\Factory;
/**
* 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 = Factory::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') . ' = ' . 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 = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
$query = $db->getQuery(true)
->update($db->quoteName('#__extensions'))
->set($db->quoteName('enabled') . ' = ' . 1)
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
->where($db->quoteName('folder') . ' = ' . $db->quote('twofactorauth'));
$db->setQuery($query);
$db->execute();
// Clean cache.
Factory::getCache()->clean('com_plugins');
// Redirect the user to their profile editor page
$url = 'index.php?option=com_users&task=user.edit&id=' . Factory::getUser()->id;
Factory::getApplication()->redirect($url);
}
The same content is in 49 releases, Joomla 4.0.0-beta6 to 4.2.0-alpha3. See them all, or every version of this file.