<?php
/**
* @package Force Password Change
* @copyright (C) 2010 by Source Coast - All rights reserved
* http://www.sourcecoast.com
* http://www.cmsmarket.com
* http://www.covertapps.com
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.plugin.plugin');
class plgSystemForcePasswordChange extends JPlugin
{
function plgSystemForcePasswordChange(&$subject, $config)
{
parent::__construct($subject, $config);
}
function onAfterRoute()
{
global $mainframe;
// Don't do anything if this is the administrator backend or debugging is on
if($mainframe->isAdmin() || JDEBUG) {
return;
}
$user = &JFactory::getUser();
$option = JRequest::getVar('option');
$view = JRequest::getVar('view');
$task = JRequest::getVar('task');
$savetask = JRequest::getVar('action');
// no_html is sent by Mighty Registration for ajax checks, so we need to ignore them
$noHtml = JRequest::getVar('no_html');
$editProfileOption = "com_community";
$editProfileSaveTask = "save";
$editProfileView = "profile";
$editProfileTask = "edit";
if(!$user->guest && $user->lastvisitDate == "0000-00-00 00:00:00" && $noHtml != "1")
{
// The user is not a guest and their lastvisitDate is zeros
if($option == $editProfileOption && $savetask == $editProfileSaveTask)
{
// The user is saving their profile
// Set the last visit date to a real value so we won't continue forcing them to update their profile
$user->setLastVisit();
$date = JFactory::getDate();
$user->lastvisitDate = $date->toMySQL();
}
else if(!($option == $editProfileOption && $view == $editProfileView && $task == $editProfileTask))
{
// The user is not on the edit profile form
// Update lastvisitDate back to zero
$dbo = &JFactory::getDBO();
$query = "UPDATE #__users ".
"SET lastvisitDate = ".$dbo->quote("0000-00-00 00:00:00")." ".
"WHERE id = ".$dbo->quote($user->id);
$dbo->setQuery($query);
$dbo->query();
// Redirect to edit profile
$app = &JFactory::getApplication();
$app->redirect(
"index.php?option=".$editProfileOption."&view=".$editProfileView."&task=".$editProfileTask,
$this->params->get("message", "You must update your password before continuing to use the site.")
);
}
}
}
}
Join our newsletter to get alerts for Joomla releases, tips and tricks and extension updates.