bludit/bl-kernel/admin/views/edit-user.php

258 lines
7.6 KiB
PHP
Raw Normal View History

2018-11-02 00:34:42 +01:00
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
2015-10-19 00:45:58 +02:00
<?php echo Bootstrap::formOpen(array('id'=>'jsform', 'class'=>'tab-content')); ?>
2015-11-15 22:37:34 +01:00
<div class="align-middle">
<div class="float-right mt-1">
<button type="submit" class="btn btn-primary btn-sm" name="save"><?php $L->p('Save') ?></button>
<a class="btn btn-secondary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" role="button"><?php $L->p('Cancel') ?></a>
</div>
<?php echo Bootstrap::pageTitle(array('title'=>$L->g('Edit user'), 'icon'=>'person')); ?>
2018-11-02 00:34:42 +01:00
</div>
<!-- TABS -->
<nav class="mb-3">
<div class="nav nav-tabs" id="nav-tab" role="tablist">
2018-11-09 00:59:06 +01:00
<a class="nav-item nav-link active" id="nav-profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="nav-profile" aria-selected="false"><?php $L->p('Profile') ?></a>
<a class="nav-item nav-link" id="nav-picture-tab" data-toggle="tab" href="#picture" role="tab" aria-controls="nav-picture" aria-selected="false"><?php $L->p('Profile picture') ?></a>
<a class="nav-item nav-link" id="nav-security-tab" data-toggle="tab" href="#security" role="tab" aria-controls="nav-security" aria-selected="false"><?php $L->p('Security') ?></a>
<a class="nav-item nav-link" id="nav-social-tab" data-toggle="tab" href="#social" role="tab" aria-controls="nav-social" aria-selected="false"><?php $L->p('Social Networks') ?></a>
</div>
2018-11-02 00:34:42 +01:00
</nav>
2018-07-28 18:33:37 +02:00
2018-11-02 00:34:42 +01:00
<?php
// Token CSRF
2018-05-14 00:00:10 +02:00
echo Bootstrap::formInputHidden(array(
2015-10-20 05:14:28 +02:00
'name'=>'tokenCSRF',
'value'=>$security->getTokenCSRF()
2015-10-19 00:45:58 +02:00
));
2018-11-02 00:34:42 +01:00
// Username
2018-05-14 00:00:10 +02:00
echo Bootstrap::formInputHidden(array(
2015-10-19 00:45:58 +02:00
'name'=>'username',
2018-05-14 00:00:10 +02:00
'value'=>$user->username()
2015-10-19 00:45:58 +02:00
));
2018-11-02 00:34:42 +01:00
?>
2015-10-19 00:45:58 +02:00
2018-11-02 00:34:42 +01:00
<div class="tab-content" id="nav-tabContent">
<!-- Profile tab -->
<div class="tab-pane fade show active" id="profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<?php
// Display username but disable the field
echo Bootstrap::formInputText(array(
'name'=>'usernameDisabled',
'label'=>$L->g('Username'),
'value'=>$user->username(),
2018-05-14 00:00:10 +02:00
'class'=>'',
2018-11-02 00:34:42 +01:00
'placeholder'=>'',
'disabled'=>true,
2018-05-14 00:00:10 +02:00
'tip'=>''
));
2018-11-02 00:34:42 +01:00
if ($login->role()==='admin') {
echo Bootstrap::formSelect(array(
'name'=>'role',
'label'=>$L->g('Role'),
'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
'selected'=>$user->role(),
'class'=>'',
'tip'=>''
));
}
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'email',
'label'=>$L->g('Email'),
'value'=>$user->email(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
2018-07-28 18:33:37 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'nickname',
'label'=>$L->g('Nickname'),
'value'=>$user->nickname(),
'class'=>'',
'placeholder'=>'',
'tip'=>$L->g('The nickname is almost used in the themes to display the author of the content')
));
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'firstName',
'label'=>$L->g('First Name'),
'value'=>$user->firstName(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
2015-10-19 00:45:58 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'lastName',
'label'=>$L->g('Last Name'),
'value'=>$user->lastName(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
?>
2018-05-15 20:12:15 +02:00
</div>
2018-11-02 00:34:42 +01:00
<!-- Profile picture tab -->
<div class="tab-pane fade" id="picture" role="tabpanel" aria-labelledby="nav-picture-tab">
<div class="custom-file mb-2">
<input type="file" class="custom-file-input" id="jsprofilePictureInputFile" name="profilePictureInputFile">
<label class="custom-file-label" for="jsprofilePictureInputFile"><?php $L->p('Choose images to upload'); ?></label>
2018-11-02 00:34:42 +01:00
</div>
<div>
2018-11-12 17:55:38 +01:00
<img id="jsprofilePicturePreview" class="img-fluid img-thumbnail" alt="Profile picture preview" src="<?php echo (Sanitize::pathFile(PATH_UPLOADS_PROFILES.$user->username().'.png')?DOMAIN_UPLOADS_PROFILES.$user->username().'.png?version='.time():HTML_PATH_ADMIN_THEME_IMG.'default.svg') ?>" />
2018-11-02 00:34:42 +01:00
</div>
<script>
$("#jsprofilePictureInputFile").on("change", function() {
var formData = new FormData();
formData.append('tokenCSRF', tokenCSRF);
formData.append('profilePictureInputFile', $(this)[0].files[0]);
formData.append('username', $("#jsusername").val());
$.ajax({
url: HTML_PATH_ADMIN_ROOT+"ajax/profile-picture",
type: "POST",
data: formData,
cache: false,
contentType: false,
processData: false
}).done(function(json) {
console.log(json);
$("#jsprofilePicturePreview").attr('src',json.absoluteURL+"?time="+Math.random());
2018-11-02 00:34:42 +01:00
});
});
2018-11-02 00:34:42 +01:00
</script>
</div>
2015-10-19 00:45:58 +02:00
2018-11-02 00:34:42 +01:00
<!-- Security tab -->
<div class="tab-pane fade" id="security" role="tabpanel" aria-labelledby="nav-security-tab">
<?php
echo Bootstrap::formTitle(array('title'=>$L->g('Password')));
2016-09-07 02:14:57 +02:00
2018-05-14 00:00:10 +02:00
echo '
2018-11-02 00:34:42 +01:00
<div class="form-group">
<a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$user->username().'" class="btn btn-primary mr-2">'.$L->g('Change password').'</a>
2018-05-14 00:00:10 +02:00
</div>
';
2018-11-02 00:34:42 +01:00
echo Bootstrap::formTitle(array('title'=>$L->g('Authentication Token')));
2016-01-01 00:31:51 +01:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'tokenAuth',
'label'=>$L->g('Token'),
'value'=>$user->tokenAuth(),
'class'=>'',
'tip'=>$L->g('this-token-is-similar-to-a-password-it-should-not-be-shared')
));
2016-01-01 00:31:51 +01:00
2018-11-09 00:59:06 +01:00
if (checkRole(array('admin'),false)) {
echo Bootstrap::formTitle(array('title'=>$L->g('Status')));
2018-07-25 23:42:00 +02:00
2018-11-09 00:59:06 +01:00
echo Bootstrap::formInputText(array(
'name'=>'status',
'label'=>$L->g('Current status'),
'value'=>$user->enabled()?$L->g('Enabled'):$L->g('Disabled'),
'class'=>'',
'disabled'=>true,
'tip'=>$user->enabled()?'':$L->g('To enable the user you must set a new password')
));
2018-11-09 00:59:06 +01:00
if ($user->enabled()) {
echo '
<div class="form-group row">
<div class="col-sm-2"></div>
<div class="col-sm-10">
<button type="submit" class="btn btn-warning mr-2" id="jsdisableUser" name="disableUser">'.$L->g('Disable user').'</button>
<button type="submit" class="btn btn-danger mr-2" id="jsdeleteUserAndKeepContent" name="deleteUserAndKeepContent">'.$L->g('Delete user and keep content').'</button>
<button type="submit" class="btn btn-danger mr-2" id="jsdeleteUserAndDeleteContent" name="deleteUserAndDeleteContent">'.$L->g('Delete user and delete content').'</button>
</div>
</div>
';
}
2018-11-02 00:34:42 +01:00
}
?>
2018-05-14 00:00:10 +02:00
</div>
2018-07-30 23:43:12 +02:00
2018-11-02 00:34:42 +01:00
<!-- Social Networks tab -->
<div class="tab-pane fade" id="social" role="tabpanel" aria-labelledby="nav-social-tab">
<?php
echo Bootstrap::formInputText(array(
'name'=>'twitter',
'label'=>'Twitter',
'value'=>$user->twitter(),
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2015-10-19 00:45:58 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'facebook',
'label'=>'Facebook',
'value'=>$user->facebook(),
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2015-10-19 00:45:58 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'codepen',
'label'=>'CodePen',
'value'=>$user->codepen(),
2018-11-02 00:34:42 +01:00
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2015-10-19 00:45:58 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'instagram',
'label'=>'Instagram',
'value'=>$user->instagram(),
2018-11-02 00:34:42 +01:00
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2018-07-30 23:43:12 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'gitlab',
'label'=>'GitLab',
'value'=>$user->gitlab(),
2018-11-02 00:34:42 +01:00
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2018-10-29 18:21:42 +01:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'github',
'label'=>'GitHub',
2018-11-02 00:34:42 +01:00
'value'=>$user->github(),
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2018-07-30 23:43:12 +02:00
2018-11-02 00:34:42 +01:00
echo Bootstrap::formInputText(array(
'name'=>'linkedin',
'label'=>'LinkedIn',
'value'=>$user->linkedin(),
2018-11-02 00:34:42 +01:00
'class'=>'',
'placeholder'=>'',
2018-11-02 00:34:42 +01:00
'tip'=>''
));
2018-07-30 23:43:12 +02:00
echo Bootstrap::formInputText(array(
'name'=>'mastodon',
'label'=>'Mastodon',
'value'=>$user->mastodon(),
'class'=>'',
'placeholder'=>'',
'tip'=>''
));
2018-11-02 00:34:42 +01:00
?>
</div>
</div>
<?php echo Bootstrap::formClose(); ?>