New feature, disable user account
This commit is contained in:
parent
e040d96d4c
commit
832e47e94a
|
@ -4,6 +4,25 @@
|
|||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function disableUser($username) {
|
||||
|
||||
global $dbUsers;
|
||||
global $Language;
|
||||
global $Login;
|
||||
|
||||
// The editors can't disable users
|
||||
if($Login->role()!=='admin') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $dbUsers->disableUser($username) ) {
|
||||
Alert::set($Language->g('The changes have been saved'));
|
||||
}
|
||||
else {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the user.');
|
||||
}
|
||||
}
|
||||
|
||||
function editUser($args)
|
||||
{
|
||||
global $dbUsers;
|
||||
|
@ -72,6 +91,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
elseif(isset($_POST['delete-user-associate'])) {
|
||||
deleteUser($_POST, false);
|
||||
}
|
||||
elseif(isset($_POST['disable-user'])) {
|
||||
disableUser($_POST['username']);
|
||||
}
|
||||
else {
|
||||
editUser($_POST);
|
||||
}
|
||||
|
|
|
@ -59,17 +59,6 @@
|
|||
}
|
||||
|
||||
|
||||
/* UIKIT HACKs forms
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
.uk-form input:not([type]), .uk-form input[type="text"], .uk-form input[type="password"], .uk-form input[type="email"], .uk-form input[type="url"], .uk-form input[type="search"], .uk-form input[type="tel"], .uk-form input[type="number"], .uk-form input[type="datetime"], .uk-form input[type="datetime-local"], .uk-form input[type="date"], .uk-form input[type="month"], .uk-form input[type="time"], .uk-form input[type="week"], .uk-form input[type="color"], .uk-form select, .uk-form textarea {
|
||||
border-radius: 2px !important;
|
||||
}
|
||||
|
||||
.uk-form-help-block {
|
||||
color: #777 !important;
|
||||
font-size: 0.9em !important;
|
||||
}
|
||||
|
||||
/* CSS defaults
|
||||
---------------------------------------------------------------- */
|
||||
|
@ -167,11 +156,48 @@ div.dashboard-links h4 {
|
|||
margin-bottom: -8px !important;
|
||||
}
|
||||
|
||||
/* NEW POST */
|
||||
h3.titleOptions {
|
||||
font-size: 1em;
|
||||
|
||||
/* FORM
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
.uk-form input:not([type]), .uk-form input[type="text"], .uk-form input[type="password"], .uk-form input[type="email"], .uk-form input[type="url"], .uk-form input[type="search"], .uk-form input[type="tel"], .uk-form input[type="number"], .uk-form input[type="datetime"], .uk-form input[type="datetime-local"], .uk-form input[type="date"], .uk-form input[type="month"], .uk-form input[type="time"], .uk-form input[type="week"], .uk-form input[type="color"], .uk-form select, .uk-form textarea {
|
||||
border-radius: 2px !important;
|
||||
}
|
||||
|
||||
.uk-form-help-block {
|
||||
color: #777 !important;
|
||||
font-size: 0.9em !important;
|
||||
}
|
||||
|
||||
.sidebar-meta .uk-form-label {
|
||||
font-size: 0.9em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.uk-form legend {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.uk-form legend.first-child {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
button.aslink {
|
||||
background: rgba(0, 0, 0, 0) none repeat scroll 0 0;
|
||||
border: 0 none;
|
||||
color: #07d;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
font-size: 1em;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
button.aslink:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
/* OLD
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
|
@ -236,10 +262,6 @@ table.statistics tr:last-child td {
|
|||
|
||||
/* ----------- FORM ----------- */
|
||||
|
||||
.sidebar .uk-form-label {
|
||||
font-size: 0.9em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#bludit-tags {
|
||||
margin-top: 15px;
|
||||
|
|
|
@ -18,7 +18,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
|||
|
||||
// ---- LEFT SIDE ----
|
||||
echo '<div class="uk-grid">';
|
||||
echo '<div class="uk-width-large-8-10">';
|
||||
echo '<div class="uk-width-8-10">';
|
||||
|
||||
// Title input
|
||||
HTML::formInputText(array(
|
||||
|
@ -52,7 +52,7 @@ if(count($_Page->children())===0)
|
|||
echo '</div>';
|
||||
|
||||
// ---- RIGHT SIDE ----
|
||||
echo '<div class="sidebar uk-width-large-2-10">';
|
||||
echo '<div class="sidebar-meta uk-width-2-10">';
|
||||
|
||||
// Tabs, general and advanced mode
|
||||
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
|
||||
|
|
|
@ -18,7 +18,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
|||
|
||||
// ---- LEFT SIDE ----
|
||||
echo '<div class="uk-grid">';
|
||||
echo '<div class="uk-width-large-8-10">';
|
||||
echo '<div class="uk-width-8-10">';
|
||||
|
||||
// Title input
|
||||
HTML::formInputText(array(
|
||||
|
@ -46,7 +46,7 @@ echo '<div class="uk-width-large-8-10">';
|
|||
echo '</div>';
|
||||
|
||||
// ---- RIGHT SIDE ----
|
||||
echo '<div class="sidebar uk-width-large-2-10">';
|
||||
echo '<div class="sidebar-meta uk-width-2-10">';
|
||||
|
||||
// Tabs, general and advanced mode
|
||||
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
|
||||
|
|
|
@ -64,6 +64,7 @@ if($Login->role()==='admin') {
|
|||
));
|
||||
|
||||
}
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'email',
|
||||
'label'=>$L->g('Email'),
|
||||
|
@ -113,6 +114,25 @@ if($Login->role()==='admin') {
|
|||
</div>
|
||||
</div>';
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Status')));
|
||||
|
||||
HTML::formInputText(array(
|
||||
'name'=>'status',
|
||||
'label'=>$L->g('Current status'),
|
||||
'value'=>$_User->enabled()?$L->g('Enabled'):$L->g('Disabled'),
|
||||
'class'=>'uk-width-1-2 uk-form-medium',
|
||||
'disabled'=>true,
|
||||
'tip'=>$_User->enabled()?'':$L->g('To enable the user you have to set a new password')
|
||||
));
|
||||
|
||||
if( $_User->enabled() ) {
|
||||
echo '<div class="uk-form-row">
|
||||
<div class="uk-form-controls">
|
||||
<button type="submit" id="jsdisable-user" class="delete-button" name="disable-user"><i class="uk-icon-ban"></i> '.$L->g('Disable the user').'</button>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if( ($Login->role()==='admin') && ($_User->username()!='admin') ) {
|
||||
|
||||
HTML::legend(array('value'=>$L->g('Delete')));
|
||||
|
@ -155,6 +175,12 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
$("#jsdisable-user").click(function() {
|
||||
if(confirm("<?php $Language->p('do-you-want-to-disable-the-user') ?>")==false) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
|
@ -12,7 +12,7 @@ HTML::formOpen(array('class'=>'uk-form-stacked'));
|
|||
|
||||
// ---- LEFT SIDE ----
|
||||
echo '<div class="uk-grid">';
|
||||
echo '<div class="uk-width-large-8-10">';
|
||||
echo '<div class="uk-width-8-10">';
|
||||
|
||||
// Title input
|
||||
HTML::formInputText(array(
|
||||
|
@ -39,7 +39,7 @@ echo '<div class="uk-width-large-8-10">';
|
|||
echo '</div>';
|
||||
|
||||
// ---- RIGHT SIDE ----
|
||||
echo '<div class="sidebar uk-width-large-2-10">';
|
||||
echo '<div class="sidebar-meta uk-width-2-10">';
|
||||
|
||||
// Tabs, general and advanced mode
|
||||
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
|
||||
|
|
|
@ -39,7 +39,7 @@ echo '<div class="uk-width-8-10">';
|
|||
echo '</div>';
|
||||
|
||||
// ---- RIGHT SIDE ----
|
||||
echo '<div class="uk-width-2-10">';
|
||||
echo '<div class="sidebar-meta uk-width-2-10">';
|
||||
|
||||
// Tabs, general and advanced mode
|
||||
echo '<ul class="uk-tab" data-uk-tab="{connect:\'#tab-options\'}">';
|
||||
|
|
|
@ -108,6 +108,15 @@ class dbUsers extends dbJSON
|
|||
return $this->set($args);
|
||||
}
|
||||
|
||||
// Disable the user
|
||||
public function disableUser($username)
|
||||
{
|
||||
$args['username'] = $username;
|
||||
$args['password'] = '!';
|
||||
|
||||
return $this->set($args);
|
||||
}
|
||||
|
||||
public function set($args)
|
||||
{
|
||||
$dataForDb = array();
|
||||
|
|
|
@ -46,6 +46,13 @@ class User
|
|||
return $this->getField('password');
|
||||
}
|
||||
|
||||
public function enabled()
|
||||
{
|
||||
$password = $this->getField('password');
|
||||
|
||||
return $password != '!';
|
||||
}
|
||||
|
||||
public function salt()
|
||||
{
|
||||
return $this->getField('salt');
|
||||
|
|
|
@ -240,5 +240,8 @@
|
|||
"email-access-code": "Email access code",
|
||||
"current-format": "Current format",
|
||||
|
||||
"welcome": "Welcome"
|
||||
"welcome": "Welcome",
|
||||
|
||||
"to-enable-the-user-you-have-to-set-a-new-password": "To enable the user you have to set a new password.",
|
||||
"do-you-want-to-disable-the-user": "Do you want to disable the user ?"
|
||||
}
|
Loading…
Reference in New Issue