1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-04 20:27:40 +02:00

Users Plugin: Improvements

This commit is contained in:
Awilum
2014-01-15 00:39:00 +02:00
parent fa00499d93
commit 5e06c10ef9
5 changed files with 56 additions and 64 deletions

View File

@@ -1,14 +1,5 @@
<?php <?php
// Check if is user is logged in then set variables for welcome button
if (Session::exists('user_id')) {
$user_id = Session::get('user_id');
$user_login = Session::get('user_login');
} else {
$user_id = '';
$user_login = '';
}
// Add plugin navigation link // Add plugin navigation link
Navigation::add(__('Users', 'users'), 'system', 'users', 2); Navigation::add(__('Users', 'users'), 'system', 'users', 2);

View File

@@ -21,8 +21,12 @@ Plugin::register( __FILE__,
'users', 'users',
'box'); 'box');
// Include Users Admin if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
Plugin::Admin('users', 'box');
// Include Users Admin
Plugin::Admin('users', 'box');
}
// Add Plugin Javascript // Add Plugin Javascript
Javascript::add('plugins/box/users/js/users.js', 'backend'); Javascript::add('plugins/box/users/js/users.js', 'backend');

View File

@@ -1,64 +1,62 @@
<!-- Users_add --> <!-- Users_add -->
<h2><?php echo __('New User Registration', 'users'); ?></h2> <h2><?php echo __('New User Registration', 'users'); ?></h2>
<?php <?php
echo ( echo (
Html::br(). Html::br().
Form::open(). Form::open().
Form::hidden('csrf', Security::token()) Form::hidden('csrf', Security::token())
); );
?> ?>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="form-group"> <div class="form-group">
<?php <?php
echo ( echo (
Form::label('login', __('Username', 'users')). Form::label('login', __('Username', 'users')).
Form::input('login', null, array('class' => (isset($errors['users_this_user_alredy_exists']) || isset($errors['users_empty_login'])) ? 'form-control error-field' : 'form-control')) Form::input('login', null, array('class' => (isset($errors['users_this_user_alredy_exists']) || isset($errors['users_empty_login'])) ? 'form-control error-field' : 'form-control'))
); );
if (isset($errors['users_this_user_alredy_exists'])) echo '<span class="error-message">'.$errors['users_this_user_alredy_exists'].'</span>'; if (isset($errors['users_this_user_alredy_exists'])) echo '<span class="error-message">'.$errors['users_this_user_alredy_exists'].'</span>';
if (isset($errors['users_empty_login'])) echo '<span class="error-message">'.$errors['users_empty_login'].'</span>'; if (isset($errors['users_empty_login'])) echo '<span class="error-message">'.$errors['users_empty_login'].'</span>';
?> ?>
</div> </div>
<div class="form-group"> <div class="form-group">
<?php <?php
echo ( echo (
Form::label('password', __('Password', 'users')). Form::label('password', __('Password', 'users')).
Form::password('password', null, array('class' => (isset($errors['users_empty_password'])) ? 'form-control error-field' : 'form-control')) Form::password('password', null, array('class' => (isset($errors['users_empty_password'])) ? 'form-control error-field' : 'form-control'))
); );
if (isset($errors['users_empty_password'])) echo '<span class="error-message">'.$errors['users_empty_password'].'</span>'; if (isset($errors['users_empty_password'])) echo '<span class="error-message">'.$errors['users_empty_password'].'</span>';
?> ?>
</div> </div>
<div class="form-group"> <div class="form-group">
<?php <?php
echo ( echo (
Form::label('email', __('Email', 'users')). Form::label('email', __('Email', 'users')).
Form::input('email', null, array('class' => (isset($errors['users_this_email_alredy_exists']) || isset($errors['users_empty_email'])) ? 'form-control error-field' : 'form-control')) Form::input('email', null, array('class' => (isset($errors['users_this_email_alredy_exists']) || isset($errors['users_empty_email'])) ? 'form-control error-field' : 'form-control'))
); );
if (isset($errors['users_this_email_alredy_exists'])) echo '<span class="error-message">'.$errors['users_this_email_alredy_exists'].'</span>'; if (isset($errors['users_this_email_alredy_exists'])) echo '<span class="error-message">'.$errors['users_this_email_alredy_exists'].'</span>';
if (isset($errors['users_empty_email'])) echo '<span class="error-message">'.$errors['users_empty_email'].'</span>'; if (isset($errors['users_empty_email'])) echo '<span class="error-message">'.$errors['users_empty_email'].'</span>';
?> ?>
</div> </div>
<div class="form-group"> <div class="form-group">
<?php <?php
echo ( echo (
Form::label('role', __('Role', 'users')). Form::label('role', __('Role', 'users')).
Form::select('role', array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')), null, array('class' => 'form-control')) Form::select('role', array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')), null, array('class' => 'form-control'))
); );
?> ?>
</div> </div>
<?php <?php
echo ( echo (
Form::submit('register', __('Register', 'users'), array('class' => 'btn btn-primary')).Html::nbsp(2). Form::submit('register', __('Register', 'users'), array('class' => 'btn btn-primary')).Html::nbsp(2).
Html::anchor(__('Cancel', 'users'), 'index.php?id=users', array('title' => __('Cancel', 'users'), 'class' => 'btn btn-default')). Html::anchor(__('Cancel', 'users'), 'index.php?id=users', array('title' => __('Cancel', 'users'), 'class' => 'btn btn-default')).
Form::close() Form::close()
); );
?> ?>
</div>
</div> </div>
</div> </div>

View File

@@ -16,7 +16,7 @@
Form::hidden('user_id', Request::get('user_id')) Form::hidden('user_id', Request::get('user_id'))
); );
if (isset($_SESSION['user_role']) && in_array($_SESSION['user_role'], array('admin'))) { if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
?> ?>
<div class="form-group"> <div class="form-group">
<?php <?php
@@ -78,7 +78,7 @@
?> ?>
</div> </div>
<?php <?php
if (isset($_SESSION['user_role']) && in_array($_SESSION['user_role'], array('admin'))) { if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
?> ?>
<div class="form-group"> <div class="form-group">
<?php <?php
@@ -88,7 +88,7 @@
</div> </div>
<?php <?php
} else { } else {
echo Form::hidden('role', $_SESSION['user_role']); echo Form::hidden('role', Session::get('user_role'));
} }
echo ( echo (
@@ -127,7 +127,6 @@
</div> </div>
<div style="clear:both;"></div>
<?php <?php
} else { } else {

View File

@@ -47,7 +47,7 @@
<div class="pull-right"> <div class="pull-right">
<?php echo Html::anchor(__('Edit', 'users'), 'index.php?id=users&action=edit&user_id='.$user['id'], array('class' => 'btn btn-primary')); ?> <?php echo Html::anchor(__('Edit', 'users'), 'index.php?id=users&action=edit&user_id='.$user['id'], array('class' => 'btn btn-primary')); ?>
<?php <?php
if ((int)$user['id'] != (int)$_SESSION['user_id']) { if ((int)$user['id'] != (int)Session::get('user_id')) {
echo Html::anchor(__('Delete', 'users'), echo Html::anchor(__('Delete', 'users'),
'index.php?id=users&action=delete&user_id='.$user['id'].'&token='.Security::token(), 'index.php?id=users&action=delete&user_id='.$user['id'].'&token='.Security::token(),
array('class' => 'btn btn-danger', 'onclick' => "return confirmDelete('".__('Delete user: :user', 'users', array(':user' => Html::toText($user['login'])))."')")); array('class' => 'btn btn-danger', 'onclick' => "return confirmDelete('".__('Delete user: :user', 'users', array(':user' => Html::toText($user['login'])))."')"));