addition of resetbopassword module
This commit is contained in:
parent
b9c24cbdbb
commit
a76dd668fe
@ -206,6 +206,9 @@ class HelperFormBootstrap{
|
||||
case 'simpleText':
|
||||
$this->inputSimpleText($input);
|
||||
break;
|
||||
case 'textAddon':
|
||||
$this->inputTextAddon($input);
|
||||
break;
|
||||
case 'tag':
|
||||
$this->inputTag($input);
|
||||
break;
|
||||
@ -309,9 +312,10 @@ class HelperFormBootstrap{
|
||||
'.(isset($p['label']) && $p['label'] ?'<label class="control-label '.$p['label-class'].'" for="'.(isset($p['id']) ? $p['id'] : $p['name']).'">'.$p['label'].'</label>':'').'
|
||||
<div class="input-group input-group-sm">
|
||||
'.(isset($p['before']) && $p['before'] ?'<div class="input-group-addon">'.$p['before'].'</div>':'').'
|
||||
<input type="text" class="form-control" name="'.$p['name'].'" id="'.(isset($p['id']) ? $p['id'] : $p['name']).'" placeholder="'.((isset($p['placeholder']) && $p['placeholder'])?$p['placeholder']:'').'">
|
||||
<input type="text" class="form-control" '.(isset($p['default']) && $p['default'] ? 'value="'.$p['default'].'"':'').' name="'.$p['name'].'" id="'.(isset($p['id']) ? $p['id'] : $p['name']).'" placeholder="'.((isset($p['placeholder']) && $p['placeholder'])?$p['placeholder']:'').'">
|
||||
'.(isset($p['after']) && $p['after'] ?'<div class="input-group-addon">'.$p['after'].'</div>':'').'
|
||||
</div>
|
||||
' . ((isset($p['help']) && $p['help']) ? '<span class="help-block">'.$p['help'].'</span>' : '') . '
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
@ -392,6 +392,12 @@ table.table tr th {
|
||||
.table tr td {
|
||||
color: #000;
|
||||
}
|
||||
.table th a{
|
||||
color:#fff;
|
||||
}
|
||||
.table tbody tr th:first-child span{
|
||||
color: #E36EA2!important;
|
||||
}
|
||||
|
||||
/* Select2 */
|
||||
.select2-results ul li{
|
||||
|
124
modules/ant_resetbopassword/ant_resetbopassword.php
Normal file
124
modules/ant_resetbopassword/ant_resetbopassword.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
require_once(PS_ADMIN_DIR . '/helpers/HelperFormBootstrap.php');
|
||||
|
||||
class Ant_Resetbopassword extends Module
|
||||
{
|
||||
public $_html = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'ant_resetbopassword';
|
||||
$this->tab = 'administration';
|
||||
$this->author = 'Antadis';
|
||||
$this->version = '1.0';
|
||||
$this->need_instance = 0;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('Sécurité BO');
|
||||
$this->description = $this->l('Envoi, tous les X mois, une demande de changement de mot de passe aux employés');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
if(!(parent::install())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
# Set default configuration values
|
||||
Configuration::updateValue('ANT_RESETBOPASSWORD_FREQ', 3); // month
|
||||
Configuration::updateValue('ANT_RESETBOPASSWORD_LIMIT', 7); // day
|
||||
Configuration::updateValue('ANT_RESETBOPASSWORD_DATE', date('Y-m-d H:i:s')); // last date of updating
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
|
||||
if(parent::uninstall() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Db::getInstance()->execute('ALTER TABLE `'._DB_PREFIX_.'employee` ADD `date_passwd_upd` DATETIME DEFAULT "'.pSQL(date("Y-m-d H:i:s")).'"');
|
||||
Configuration::deleteByName('ANT_RESETBOPASSWORD_FREQ');
|
||||
Configuration::deleteByName('ANT_RESETBOPASSWORD_LIMIT');
|
||||
Configuration::deleteByName('ANT_RESETBOPASSWORD_DATE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
global $cookie, $currentIndex;
|
||||
|
||||
if(Tools::isSubmit('submitUpdate')) {
|
||||
Configuration::updateValue('ANT_RESETBOPASSWORD_FREQ', Tools::getValue('frequency'));
|
||||
Configuration::updateValue('ANT_RESETBOPASSWORD_LIMIT', Tools::getValue('limit'));
|
||||
}
|
||||
|
||||
$helper = new HelperFormBootstrap();
|
||||
$this->_html .= $helper->renderStyle();
|
||||
$this->_html .= '
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel">
|
||||
<div class="panel-title">
|
||||
<h2 style="font-size:24px;"><span class="anticon anticon-cog text-rose" style="font-size:24px;"></span> '.$this->l('Reset Bo Password - Configurations').'</h2>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
<div class="panel-content">
|
||||
<form method="POST" action="">
|
||||
<div class="col-sm-3 col-sm-offset-4">';
|
||||
$input = array(
|
||||
'type' => 'textAddon',
|
||||
'label' => $this->l('Frequency :'),
|
||||
'lang' => true,
|
||||
'name' => 'frequency',
|
||||
'id' => 'frequency',
|
||||
'required' => true,
|
||||
'after' => $this->l('Months'),
|
||||
'help' => $this->l('Mail sending frequency'),
|
||||
'default' => Configuration::get('ANT_RESETBOPASSWORD_FREQ')
|
||||
);
|
||||
$this->_html .= $helper->generateInput($input);
|
||||
$this->_html .= '<div class="clearfix"></div>';
|
||||
|
||||
$input = array(
|
||||
'type' => 'textAddon',
|
||||
'label' => $this->l('Limit :'),
|
||||
'lang' => true,
|
||||
'name' => 'limit',
|
||||
'id' => 'limit',
|
||||
'required' => true,
|
||||
'after' => $this->l('Days'),
|
||||
'help' => $this->l('Nb of day limited to change the password'),
|
||||
'default' => Configuration::get('ANT_RESETBOPASSWORD_LIMIT')
|
||||
);
|
||||
$this->_html .= $helper->generateInput($input);
|
||||
$this->_html .= '<div class="clearfix"></div>';
|
||||
|
||||
$this->_html .='
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<div class="ln_solid-small"></div>
|
||||
<div class="text-right">
|
||||
<input type="submit" class="btn btn-primary" name="submitUpdate" value="'.$this->l('Save').'" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
$this->_html .= $helper->renderScript();
|
||||
return $this->_html;
|
||||
}
|
||||
|
||||
public function hookObjectEmployeeUpdateAfter($params)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
47
modules/ant_resetbopassword/cron.php
Normal file
47
modules/ant_resetbopassword/cron.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
if(isset($_SERVER['REMOTE_ADDR'])) exit;
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
|
||||
include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
include dirname(__FILE__).'/../../init.php';
|
||||
|
||||
$sending_date = Configuration::get('ANT_RESETBOPASSWORD_DATE');
|
||||
$frequency = Configuration::get('ANT_RESETBOPASSWORD_FREQ');
|
||||
$limit = Configuration::get('ANT_RESETBOPASSWORD_LIMIT');
|
||||
|
||||
$now = new Datetime();
|
||||
$last_sent = new Datetime($sending_date);
|
||||
$diff = $now->diff($last_sent);
|
||||
|
||||
if($diff->format("")>=(int)$frequency){
|
||||
|
||||
$employees = Db::getInstance()->ExecuteS('
|
||||
SELECT `id_employee`, CONCAT(`firstname`, \' \', `lastname`) AS "name", email
|
||||
FROM `'._DB_PREFIX_.'employee`
|
||||
WHERE `active` = 1
|
||||
ORDER BY `email`
|
||||
');
|
||||
foreach ($employees as $key => $employee) {
|
||||
// sending email
|
||||
}
|
||||
|
||||
Configuration::updateValue('ANT_RESETBOPASSWORD_DATE', date('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
$employees = Db::getInstance()->ExecuteS('
|
||||
SELECT `id_employee`, CONCAT(`firstname`, \' \', `lastname`) AS "name", `email`, `date_passwd_upd`
|
||||
FROM `'._DB_PREFIX_.'employee`
|
||||
WHERE `active` = 1 AND
|
||||
ORDER BY `email`
|
||||
');
|
||||
|
||||
foreach ($employees as $key => $employee) {
|
||||
$date_passwd_upd = new Datetime($employee['date_passwd_upd']);
|
||||
$diff_limit = $now->diff($date_passwd_upd);
|
||||
if($diff->format("%D")>=(int)$limit){
|
||||
// resending a mail
|
||||
}
|
||||
}
|
||||
|
||||
exit;
|
@ -12,4 +12,18 @@ class Employee extends EmployeeCore {
|
||||
ORDER BY `email`');
|
||||
}
|
||||
|
||||
public function update($nullValues = false)
|
||||
{
|
||||
$result = parent::update();
|
||||
|
||||
if($_POST('passwd')!==null && $result){
|
||||
Db::getInstance()->ExecuteS('
|
||||
UPDATE `'._DB_PREFIX_.'employee`
|
||||
SET `date_passwd_upd` = "'.pSQL(date('Y-m-d H:i:s')).'"
|
||||
WHERE `id_employee` = '.(int)$this->id.'
|
||||
');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user