mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-13 00:24:27 +02:00
Add Monstra from HG Commit 683dcb70c4cc
This commit is contained in:
11
plugins/box/users/install/users.manifest.xml
Normal file
11
plugins/box/users/install/users.manifest.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<plugin_location>plugins/box/users/users.plugin.php</plugin_location>
|
||||
<plugin_status>active</plugin_status>
|
||||
<plugin_priority>7</plugin_priority>
|
||||
<plugin_name>Users</plugin_name>
|
||||
<plugin_description>Users plugin</plugin_description>
|
||||
<plugin_version>1.0.0</plugin_version>
|
||||
<plugin_author>Awilum</plugin_author>
|
||||
<plugin_author_uri>http://monstra.org/</plugin_author_uri>
|
||||
</root>
|
60
plugins/box/users/languages/en.lang.php
Normal file
60
plugins/box/users/languages/en.lang.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'users' => array(
|
||||
'Users' => 'Users',
|
||||
'Login' => 'Login',
|
||||
'Username' => 'Username',
|
||||
'Password' => 'Password',
|
||||
'Registered' => 'Registered',
|
||||
'Email' => 'Email',
|
||||
'Role' => 'Role',
|
||||
'Roles' => 'Roles',
|
||||
'Edit' => 'Edit',
|
||||
'Actions' => 'Actions',
|
||||
'Delete' => 'Delete',
|
||||
'Enter' => 'Enter',
|
||||
'Logout' => 'Logout',
|
||||
'Register new user' => 'Register new user',
|
||||
'New User Registration' => 'New User Registration',
|
||||
'Delete user: :user' => 'Delete user: :user',
|
||||
'User <i>:user</i> have been deleted.' => 'User <i>:user</i> have been deleted.',
|
||||
'This field should not be empty' => 'This field should not be empty',
|
||||
'This user alredy exist' => 'This user alredy exist',
|
||||
'Changes saved' => 'Changes saved',
|
||||
'Wrong old password' => 'Wrong old password',
|
||||
'Admin' => 'Admin',
|
||||
'User' => 'User',
|
||||
'Editor' => 'Editor',
|
||||
'Register' => 'Register',
|
||||
'Edit profile' => 'Edit profile',
|
||||
'Save' => 'Save',
|
||||
'Firstname' => 'Firstname',
|
||||
'Lastname' => 'Lastname',
|
||||
'Old password' => 'Old password',
|
||||
'New password' => 'New password',
|
||||
'Welcome' => 'Welcome',
|
||||
'Wrong <b>username</b> or <b>password</b>' => 'Wrong <b>username</b> or <b>password</b>',
|
||||
'Your changes have been saved.' => 'Your changes have been saved.',
|
||||
'New user have been registered.' => 'New user have been registered.',
|
||||
'Captcha' => 'Captcha',
|
||||
'Registration' => 'Registration',
|
||||
'Username' => 'Username',
|
||||
'User email is invalid' => 'User email is invalid',
|
||||
'Reset Password' => 'Reset Password',
|
||||
'Send New Password' => 'Send New Password',
|
||||
'This user doesnt alredy exist' => 'This user doesnt alredy exist',
|
||||
'Users - Profile' => 'Users - Profile',
|
||||
'Users - Edit Profile' => 'Users - Edit Profile',
|
||||
'Users - Login' => 'Users - Login',
|
||||
'Users - Registration' => 'Users - Registration',
|
||||
'Users - Password Recover' => 'Users - Password Recover',
|
||||
'New Password' => 'New Password',
|
||||
'Forgot your password?' => 'Forgot your password?',
|
||||
'New password has been sent' => 'New password has been sent',
|
||||
'Monstra says: This is not your profile...' => 'Monstra says: This is not your profile...',
|
||||
'User registration is closed.' => 'User registration is closed.',
|
||||
'Allow user registration' => 'Allow user registration',
|
||||
'Required field' => 'Required field',
|
||||
)
|
||||
);
|
59
plugins/box/users/languages/ru.lang.php
Normal file
59
plugins/box/users/languages/ru.lang.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'users' => array(
|
||||
'Users' => 'Пользователи',
|
||||
'Login' => 'Вход',
|
||||
'Password' => 'Пароль',
|
||||
'Email' => 'Емейл',
|
||||
'Registered' => 'Зарегистрирован',
|
||||
'Role' => 'Роль',
|
||||
'Roles' => 'Роли',
|
||||
'Actions' => 'Действия',
|
||||
'Edit' => 'Редактировать',
|
||||
'Delete' => 'Удалить',
|
||||
'Enter' => 'Вход',
|
||||
'Logout' => 'Выход',
|
||||
'New User Registration' => 'Регистрация нового пользователя',
|
||||
'Register new user' => 'Регистрация нового пользователя',
|
||||
'Delete user: :user' => 'Удалить пользователя: :user',
|
||||
'User <i>:user</i> have been deleted.' => 'Пользователь <i>:user</i> удален.',
|
||||
'This field should not be empty' => 'Это поле не должно быть пустым',
|
||||
'This user alredy exist' => 'Такой пользователь уже существует',
|
||||
'Changes saved' => 'Изменения сохранены',
|
||||
'Wrong old password' => 'Неправильный старый пароль',
|
||||
'Admin' => 'Администратор',
|
||||
'User' => 'Пользователь',
|
||||
'Editor' => 'Редактор',
|
||||
'Register' => 'Регистрация',
|
||||
'Edit profile' => 'Редактирование профиля пользователя',
|
||||
'Save' => 'Сохранить',
|
||||
'Firstname' => 'Имя',
|
||||
'Lastname' => 'Фамилия',
|
||||
'Old password' => 'Старый пароль',
|
||||
'New password' => 'Новый пароль',
|
||||
'Welcome' => 'Добро пожаловать',
|
||||
'Wrong <b>login</b> or <b>password</b>' => 'Неправильный <b>логин</b> или <b>пароль</b>',
|
||||
'Your changes have been saved.' => 'Ваши изменения были сохранены.',
|
||||
'New user have been registered.' => 'Новый пользователь был зарегистрирован.',
|
||||
'Captcha' => 'Капча',
|
||||
'Registration' => 'Регистрация',
|
||||
'Username' => 'Имя пользователя',
|
||||
'User email is invalid' => 'Электронная почта является недействительной',
|
||||
'Reset Password' => 'Сбросить пароль',
|
||||
'Send New Password' => 'Отослать пароль',
|
||||
'This user doesnt alredy exist' => 'Такого пользователя не существует',
|
||||
'Users - Profile' => 'Пользователи - Профиль',
|
||||
'Users - Edit Profile' => 'Пользователи - Редактирование профиля',
|
||||
'Users - Login' => 'Пользователи - Вход',
|
||||
'Users - Registration' => 'Пользователи - Регистрация',
|
||||
'Users - Password Recover' => 'Пользователи - Восстановление пароля',
|
||||
'New Password' => 'Новый пароль',
|
||||
'Forgot your password?' => 'Забыли пароль ?',
|
||||
'New password has been sent' => 'Новый пароль был отправлен',
|
||||
'Monstra says: This is not your profile...' => 'Монстра говорит: Это не твой профиль.',
|
||||
'User registration is closed.' => 'Регистрация пользователей закрыта.',
|
||||
'Allow user registration' => 'Разрешить регистрацию пользователей.',
|
||||
'Required field' => 'Обязательное поле',
|
||||
)
|
||||
);
|
214
plugins/box/users/users.admin.php
Normal file
214
plugins/box/users/users.admin.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?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 = '';
|
||||
}
|
||||
|
||||
Navigation::add(__('Users', 'users'), 'system', 'users', 2);
|
||||
|
||||
Action::add('admin_header', 'UsersAdmin::headers');
|
||||
|
||||
class UsersAdmin extends Backend {
|
||||
|
||||
|
||||
public static function headers() {
|
||||
echo ('
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("[name=users_frontend_registration] , [name=users_frontend_authorization]").click(function() {
|
||||
$("[name=users_frontend]").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* Users admin
|
||||
*/
|
||||
public static function main() {
|
||||
|
||||
// Users roles
|
||||
$roles = array('admin' => __('Admin', 'users'),
|
||||
'editor' => __('Editor', 'users'),
|
||||
'user' => __('User', 'users'));
|
||||
|
||||
// Get uses table
|
||||
$users = new Table('users');
|
||||
|
||||
if (Option::get('users_frontend_registration') == 'true') {
|
||||
$users_frontend_registration = true;
|
||||
} else {
|
||||
$users_frontend_registration = false;
|
||||
}
|
||||
|
||||
if (Request::post('users_frontend_submit')) {
|
||||
if (Request::post('users_frontend_registration')) $users_frontend_registration = 'true'; else $users_frontend_registration = 'false';
|
||||
Option::update('users_frontend_registration', $users_frontend_registration);
|
||||
Request::redirect('index.php?id=users');
|
||||
}
|
||||
|
||||
// Check for get actions
|
||||
// ---------------------------------------------
|
||||
if (Request::get('action')) {
|
||||
|
||||
// Switch actions
|
||||
// -----------------------------------------
|
||||
switch (Request::get('action')) {
|
||||
|
||||
// Add
|
||||
// -------------------------------------
|
||||
case "add":
|
||||
|
||||
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
|
||||
|
||||
$errors = array();
|
||||
if (Request::post('register')) {
|
||||
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
$user_login = trim(Request::post('login'));
|
||||
$user_password = trim(Request::post('password'));
|
||||
if ($user_login == '') $errors['users_empty_login'] = __('This field should not be empty', 'users');
|
||||
if ($user_password == '') $errors['users_empty_password'] = __('This field should not be empty', 'users');
|
||||
$user = $users->select("[login='".$user_login."']");
|
||||
if ($user != null) $errors['users_this_user_alredy_exists'] = __('This user alredy exist', 'users');
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$users->insert(array('login' => Security::safeName($user_login),
|
||||
'password' => Security::encryptPassword(Request::post('password')),
|
||||
'email' => Request::post('email'),
|
||||
'date_registered' => time(),
|
||||
'role' => Request::post('role')));
|
||||
|
||||
Notification::set('success', __('New user have been registered.', 'users'));
|
||||
Request::redirect('index.php?id=users');
|
||||
}
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
}
|
||||
|
||||
// Display view
|
||||
View::factory('box/users/views/backend/add')
|
||||
->assign('roles', $roles)
|
||||
->assign('errors', $errors)
|
||||
->display();
|
||||
|
||||
} else {
|
||||
Request::redirect('index.php?id=users&action=edit&user_id='.Session::get('user_id'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Edit
|
||||
// -------------------------------------
|
||||
case "edit":
|
||||
|
||||
// Get current user record
|
||||
$user = $users->select("[id='".(int)Request::get('user_id')."']", null);
|
||||
|
||||
if (isset($user['firstname'])) $user_firstname = $user['firstname']; else $user_firstname = '';
|
||||
if (isset($user['lastname'])) $user_lastname = $user['lastname']; else $user_lastname = '';
|
||||
if (isset($user['email'])) $user_email = $user['email']; else $user_email = '';
|
||||
if (isset($user['twitter'])) $user_twitter = $user['twitter']; else $user_twitter = '';
|
||||
if (isset($user['skype'])) $user_skype = $user['skype']; else $user_skype = '';
|
||||
|
||||
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) {
|
||||
|
||||
if ((Request::post('edit_profile')) and
|
||||
(((int)Session::get('user_id') == (int)Request::get('user_id')) or
|
||||
(in_array(Session::get('user_role'), array('admin'))))){
|
||||
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
if (Security::safeName(Request::post('login')) != '') {
|
||||
if ($users->update(Request::post('user_id'), array('login' => Security::safeName(Request::post('login')),
|
||||
'firstname' => Request::post('firstname'),
|
||||
'lastname' => Request::post('lastname'),
|
||||
'email' => Request::post('email'),
|
||||
'skype' => Request::post('skype'),
|
||||
'twitter' => Request::post('twitter'),
|
||||
'role' => Request::post('role')))) {
|
||||
|
||||
Notification::set('success', __('Your changes have been saved.', 'users'));
|
||||
Request::redirect('index.php?id=users&action=edit&user_id='.Request::post('user_id'));
|
||||
}
|
||||
} else { }
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
|
||||
}
|
||||
|
||||
if (Request::post('edit_profile_password')) {
|
||||
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
if (trim(Request::post('new_password')) != '') {
|
||||
$users->update(Request::post('user_id'), array('password' => Security::encryptPassword(trim(Request::post('new_password')))));
|
||||
Notification::set('success', __('Your changes have been saved.', 'users'));
|
||||
Request::redirect('index.php?id=users&action=edit&user_id='.Request::post('user_id'));
|
||||
}
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
}
|
||||
|
||||
if ( ((int)Session::get('user_id') == (int)Request::get('user_id')) or (in_array(Session::get('user_role'), array('admin')) && count($user) != 0) ) {
|
||||
|
||||
// Display view
|
||||
View::factory('box/users/views/backend/edit')
|
||||
->assign('user', $user)
|
||||
->assign('user_firstname', $user_firstname)
|
||||
->assign('user_lastname', $user_lastname)
|
||||
->assign('user_email', $user_email)
|
||||
->assign('user_twitter', $user_twitter)
|
||||
->assign('user_skype', $user_skype)
|
||||
->assign('roles', $roles)
|
||||
->display();
|
||||
|
||||
} else {
|
||||
echo __('Monstra says: This is not your profile...', 'users');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
// Delete
|
||||
// -------------------------------------
|
||||
case "delete":
|
||||
|
||||
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
|
||||
$user = $users->select('[id="'.Request::get('user_id').'"]', null);
|
||||
$users->delete(Request::get('user_id'));
|
||||
Notification::set('success', __('User <i>:user</i> have been deleted.', 'users', array(':user' => $user['login'])));
|
||||
Request::redirect('index.php?id=users');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
|
||||
|
||||
// Get all records from users table
|
||||
$users_list = $users->select();
|
||||
|
||||
// Dislay view
|
||||
View::factory('box/users/views/backend/index')
|
||||
->assign('roles', $roles)
|
||||
->assign('users_list', $users_list)
|
||||
->assign('users_frontend_registration', $users_frontend_registration)
|
||||
->display();
|
||||
|
||||
} else {
|
||||
Request::redirect('index.php?id=users&action=edit&user_id='.Session::get('user_id'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
399
plugins/box/users/users.plugin.php
Normal file
399
plugins/box/users/users.plugin.php
Normal file
@@ -0,0 +1,399 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Users plugin
|
||||
*
|
||||
* @package Monstra
|
||||
* @subpackage Plugins
|
||||
* @author Romanenko Sergey / Awilum
|
||||
* @copyright 2012 Romanenko Sergey / Awilum
|
||||
* @version 1.0.0
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Register plugin
|
||||
Plugin::register( __FILE__,
|
||||
__('Users', 'users'),
|
||||
__('Users manager', 'users'),
|
||||
'1.0.0',
|
||||
'Awilum',
|
||||
'http://monstra.org/',
|
||||
'users',
|
||||
'box');
|
||||
|
||||
// Include Users Admin
|
||||
Plugin::Admin('users', 'box');
|
||||
|
||||
|
||||
/**
|
||||
* Users class
|
||||
*/
|
||||
class Users extends Frontend {
|
||||
|
||||
/**
|
||||
* Users table
|
||||
*/
|
||||
public static $users = null;
|
||||
|
||||
|
||||
/**
|
||||
* Sandbox main function
|
||||
*/
|
||||
public static function main(){
|
||||
|
||||
// Get users table
|
||||
Users::$users = new Table('users');
|
||||
|
||||
// Logout
|
||||
if (Uri::segment(1) == 'logout') { Users::logout(); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Route
|
||||
*/
|
||||
protected static function route() {
|
||||
/* /users */
|
||||
if (Uri::segment(0) == 'users' && !Uri::segment(1)) return 'list';
|
||||
/* /users/(int) */
|
||||
if (Uri::segment(1) && (Uri::segment(1) !== 'login' && Uri::segment(1) !== 'registration' && Uri::segment(1) !== 'password-reset' && Uri::segment(2) !== 'edit')) return 'profile';
|
||||
/* /users/login */
|
||||
if (Uri::segment(1) == 'login') return 'login';
|
||||
/* /users/registration */
|
||||
if (Uri::segment(1) == 'registration') return 'registration';
|
||||
/* /pusers/password-reset */
|
||||
if (Uri::segment(1) == 'password-reset') return 'password-reset';
|
||||
/* /users/(int)/edit */
|
||||
if ( ( Uri::segment(1) and (Uri::segment(1) !== 'login' && Uri::segment(1) !== 'registration' && Uri::segment(1) !== 'password-reset') ) and Uri::segment(2) == 'edit') return 'edit';
|
||||
/* /users/logout */
|
||||
if (Uri::segment(1) == 'logout') return 'logout';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get users list
|
||||
*/
|
||||
public static function getList() {
|
||||
View::factory('box/users/views/frontend/index')
|
||||
->assign('users', Users::$users->select(null, 'all'))
|
||||
->display();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user profile
|
||||
*/
|
||||
public static function getProfile($id) {
|
||||
View::factory('box/users/views/frontend/profile')
|
||||
->assign('user', Users::$users->select("[id=".(int)$id."]", null))
|
||||
->display();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get New User Registration
|
||||
*/
|
||||
public static function getRegistration() {
|
||||
|
||||
if (Option::get('users_frontend_registration') == 'true') {
|
||||
|
||||
// Is User Loged in ?
|
||||
if ( ! Session::get('user_id')) {
|
||||
|
||||
$errors = array();
|
||||
|
||||
$user_email = Request::post('email');
|
||||
$user_login = Request::post('login');
|
||||
$user_password = Request::post('password');
|
||||
|
||||
// Register form submit
|
||||
if (Request::post('register')) {
|
||||
|
||||
// Check csrf
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
$user_email = trim($user_email);
|
||||
$user_login = trim($user_login);
|
||||
$user_password = trim($user_password);
|
||||
|
||||
if (Option::get('captcha_installed') == 'true' && ! CryptCaptcha::check(Request::post('answer'))) $errors['users_captcha_wrong'] = __('Captcha code is wrong', 'captcha');
|
||||
if ($user_login == '') $errors['users_empty_login'] = __('Required field', 'users');
|
||||
if ($user_password == '') $errors['users_empty_password'] = __('Required field', 'users');
|
||||
if ($user_email == '') $errors['users_empty_email'] = __('Required field', 'users');
|
||||
if ($user_email != '' && ! Valid::email($user_email)) $errors['users_invalid_email'] = __('User email is invalid', 'users');
|
||||
if (Users::$users->select("[login='".$user_login."']")) $errors['users_this_user_alredy_exists'] = __('This user alredy exist', 'users');
|
||||
if (Users::$users->select("[email='".$user_email."']")) $errors['users_this_email_alredy_exists'] = __('This email alredy exist', 'users');
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
Users::$users->insert(array('login' => Security::safeName($user_login),
|
||||
'password' => Security::encryptPassword(Request::post('password')),
|
||||
'email' => Request::post('email'),
|
||||
'date_registered' => time(),
|
||||
'role' => 'user'));
|
||||
|
||||
// Log in
|
||||
$user = Users::$users->select("[id='".Users::$users->lastId()."']", null);
|
||||
Session::set('user_id', (int)$user['id']);
|
||||
Session::set('user_login', (string)$user['login']);
|
||||
Session::set('user_role', (string)$user['role']);
|
||||
|
||||
// Redirect to user profile
|
||||
Request::redirect(Option::get('siteurl').'users/'.Users::$users->lastId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
}
|
||||
|
||||
// Display view
|
||||
View::factory('box/users/views/frontend/registration')
|
||||
->assign('errors', $errors)
|
||||
->assign('user_email', $user_email)
|
||||
->assign('user_login', $user_login)
|
||||
->assign('user_password', $user_password)
|
||||
->display();
|
||||
|
||||
} else {
|
||||
Request::redirect(Site::url().'users/'.Session::get('user_id'));
|
||||
}
|
||||
|
||||
} else {
|
||||
echo __('User registration is closed.', 'users');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get user panel
|
||||
*/
|
||||
public static function getPanel() {
|
||||
View::factory('box/users/views/frontend/userspanel')->display();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is User Loged
|
||||
*/
|
||||
public static function isLoged() {
|
||||
if ((Session::get('user_id')) and (((int)Session::get('user_id') == Uri::segment(1)) or (in_array(Session::get('user_role'), array('admin'))))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logout
|
||||
*/
|
||||
public static function logout() {
|
||||
Session::destroy(); Request::redirect(Site::url().'users/login');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Edit user profile
|
||||
*/
|
||||
public static function getProfileEdit($id) {
|
||||
|
||||
// Is Current User Loged in ?
|
||||
if (Users::isLoged()) {
|
||||
|
||||
$user = Users::$users->select("[id='".(int)$id."']", null);
|
||||
|
||||
// Edit Profile Submit
|
||||
if (Request::post('edit_profile')) {
|
||||
|
||||
// Check csrf
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
|
||||
if (Security::safeName(Request::post('login')) != '') {
|
||||
if (Users::$users->update(Request::post('user_id'),
|
||||
array('login' => Security::safeName(Request::post('login')),
|
||||
'firstname' => Request::post('firstname'),
|
||||
'lastname' => Request::post('lastname'),
|
||||
'email' => Request::post('email'),
|
||||
'skype' => Request::post('skype'),
|
||||
'twitter' => Request::post('twitter')))) {
|
||||
|
||||
// Change password
|
||||
if (trim(Request::post('new_password')) != '') {
|
||||
Users::$users->update(Request::post('user_id'), array('password' => Security::encryptPassword(trim(Request::post('new_password')))));
|
||||
}
|
||||
|
||||
Notification::set('success', __('Your changes have been saved.', 'users'));
|
||||
Request::redirect(Site::url().'users/'.$user['id'].'/edit');
|
||||
}
|
||||
} else { }
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
|
||||
}
|
||||
|
||||
View::factory('box/users/views/frontend/edit')
|
||||
->assign('user', $user)
|
||||
->display();
|
||||
|
||||
} else {
|
||||
Request::redirect(Site::url().'users/login');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Password Reset
|
||||
*/
|
||||
public static function getPasswordReset() {
|
||||
|
||||
// Is User Loged in ?
|
||||
if ( ! Session::get('user_id')) {
|
||||
|
||||
$errors = array();
|
||||
|
||||
$user_login = Request::post('login');
|
||||
|
||||
// Reset Password Form Submit
|
||||
if (Request::post('reset_password_submit')) {
|
||||
|
||||
$user_login = trim($user_login);
|
||||
|
||||
// Check csrf
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
if (Option::get('captcha_installed') == 'true' && ! CryptCaptcha::check(Request::post('answer'))) $errors['users_captcha_wrong'] = __('Captcha code is wrong', 'users');
|
||||
if ($user_login == '') $errors['users_empty_field'] = __('Required field', 'users');
|
||||
if ($user_login != '' && ! Users::$users->select("[login='".$user_login."']")) $errors['users_user_doesnt_exists'] = __('This user doesnt alredy exist', 'users');
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
$user = Users::$users->select("[login='" . $user_login . "']", null);
|
||||
|
||||
// Generate new password
|
||||
$new_password = Text::random('alnum', 6);
|
||||
|
||||
// Update user profile
|
||||
Users::$users->updateWhere("[login='" . $user_login . "']", array('password' => Security::encryptPassword($new_password)));
|
||||
|
||||
// Message
|
||||
$message = "Login: {$user['login']}\nNew Password: {$new_password}";
|
||||
|
||||
// Send
|
||||
@mail($user['email'], 'MonstraPasswordReset', $message);
|
||||
|
||||
// Set notification
|
||||
Notification::set('success', __('New password has been sent', 'users'));
|
||||
|
||||
// Redirect to password-reset page
|
||||
Request::redirect(Site::url().'users/password-reset');
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
|
||||
}
|
||||
|
||||
View::factory('box/users/views/frontend/password_reset')
|
||||
->assign('errors', $errors)
|
||||
->assign('user_login', $user_login)
|
||||
->display();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User login
|
||||
*/
|
||||
public static function getLogin() {
|
||||
|
||||
// Is User Loged in ?
|
||||
if ( ! Session::get('user_id')) {
|
||||
|
||||
// Login Form Submit
|
||||
if (Request::post('login_submit')) {
|
||||
|
||||
// Check csrf
|
||||
if (Security::check(Request::post('csrf'))) {
|
||||
|
||||
$user = Users::$users->select("[login='" . trim(Request::post('username')) . "']", null);
|
||||
|
||||
if (count($user) !== 0) {
|
||||
if ($user['login'] == Request::post('username')) {
|
||||
if (trim($user['password']) == Security::encryptPassword(Request::post('password'))) {
|
||||
if ($user['role'] == 'admin' || $user['role'] == 'editor') {
|
||||
Session::set('admin', true);
|
||||
}
|
||||
Session::set('user_id', (int)$user['id']);
|
||||
Session::set('user_login', (string)$user['login']);
|
||||
Session::set('user_role', (string)$user['role']);
|
||||
Request::redirect(Site::url().'users/'.Session::get('user_id'));
|
||||
} else {
|
||||
Notification::setNow('error', __('Wrong <b>login</b> or <b>password</b>', 'users'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Notification::setNow('error', __('Wrong <b>login</b> or <b>password</b>', 'users'));
|
||||
}
|
||||
|
||||
} else { die('csrf detected!'); }
|
||||
|
||||
}
|
||||
|
||||
View::factory('box/users/views/frontend/login')->display();
|
||||
} else {
|
||||
Request::redirect(Site::url().'users/'.Session::get('user_id'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set title
|
||||
*/
|
||||
public static function title(){
|
||||
switch (Users::route()) {
|
||||
case 'list': return __('Users'); break;
|
||||
case 'profile': return __('Users - Profile'); break;
|
||||
case 'edit': return __('Users - Edit Profile'); break;
|
||||
case 'login': return __('Users - Login'); break;
|
||||
case 'registration': return __('Users - Registration'); break;
|
||||
case 'password-reset': return __('Users - Password Recover'); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set content
|
||||
*/
|
||||
public static function content(){
|
||||
switch (Users::route()) {
|
||||
case 'list': Users::getList(); break;
|
||||
case 'profile': Users::getProfile(Uri::segment(1)); break;
|
||||
case 'edit': Users::getProfileEdit(Uri::segment(1)); break;
|
||||
case 'login': Users::getLogin(); break;
|
||||
case 'registration': Users::getRegistration(); break;
|
||||
case 'password-reset': Users::getPasswordReset(); break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set template
|
||||
*/
|
||||
public static function template() {
|
||||
return 'index';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Gravatar
|
||||
*/
|
||||
public static function getGravatarURL($email, $size) {
|
||||
return 'http://www.gravatar.com/avatar.php?gravatar_id='.md5($email).'&rating=PG'.'&size='.$size;
|
||||
}
|
||||
|
||||
}
|
32
plugins/box/users/views/backend/add.view.php
Normal file
32
plugins/box/users/views/backend/add.view.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<!-- Users_add -->
|
||||
<?php
|
||||
echo ( '<h2>'.__('New User Registration', 'users').'</h2>' );
|
||||
|
||||
echo (
|
||||
Html::br().
|
||||
Form::open().
|
||||
Form::hidden('csrf', Security::token()).
|
||||
Form::label('login', __('Username', 'users')).
|
||||
Form::input('login', null, array('class' => 'span3'))
|
||||
);
|
||||
|
||||
if (isset($errors['users_this_user_alredy_exists'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_this_user_alredy_exists'].'</span>';
|
||||
if (isset($errors['users_empty_login'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_empty_login'].'</span>';
|
||||
|
||||
echo (
|
||||
Form::label('password', __('Password', 'users')).
|
||||
Form::password('password', null, array('class' => 'span3'))
|
||||
);
|
||||
|
||||
if (isset($errors['users_empty_password'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_empty_password'].'</span>';
|
||||
|
||||
echo (
|
||||
Form::label('email', __('Email', 'users')).
|
||||
Form::input('email', null, array('class' => 'span3')). Html::br().
|
||||
Form::label('role', __('Role', 'users')).
|
||||
Form::select('role', array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')), null, array('class' => 'span3')). Html::br(2).
|
||||
Form::submit('register', __('Register', 'users'), array('class' => 'btn default')).
|
||||
Form::close()
|
||||
);
|
||||
?>
|
||||
<!-- /Users_add -->
|
89
plugins/box/users/views/backend/edit.view.php
Normal file
89
plugins/box/users/views/backend/edit.view.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<!-- Users_edit -->
|
||||
<?php
|
||||
|
||||
// Show template for exist user else show error
|
||||
if ($user !== null) {
|
||||
|
||||
echo ( '<h2>'.__('Edit profile', 'users').'</h2>' );
|
||||
|
||||
?>
|
||||
|
||||
<br />
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
<?php if (Notification::get('error')) Alert::error(Notification::get('error')); ?>
|
||||
|
||||
<div>
|
||||
|
||||
<div class="span7">
|
||||
<?php
|
||||
|
||||
echo (
|
||||
Form::open().
|
||||
Form::hidden('csrf', Security::token()).
|
||||
Form::hidden('user_id', Request::get('user_id'))
|
||||
);
|
||||
|
||||
if (isset($_SESSION['user_role']) && in_array($_SESSION['user_role'], array('admin'))) {
|
||||
echo Form::label('login', __('Username', 'users'));
|
||||
echo Form::input('login', $user['login'], array('class' => 'span6'));
|
||||
} else {
|
||||
echo Form::hidden('login', $user['login']);
|
||||
}
|
||||
|
||||
echo (
|
||||
Html::br().
|
||||
Form::label('firstname', __('Firstname', 'users')).
|
||||
Form::input('firstname', $user_firstname, array('class' => 'span6')).Html::br().
|
||||
Form::label('lastname', __('Lastname', 'users')).
|
||||
Form::input('lastname', $user_lastname, array('class' => 'span6')).Html::br().
|
||||
Form::label('email', __('Email', 'users')).
|
||||
Form::input('email', $user_email, array('class' => 'span6')).Html::br().
|
||||
Form::label('twitter', __('Twitter', 'users')).
|
||||
Form::input('twitter', $user_twitter, array('class' => 'span6')).Html::br().
|
||||
Form::label('skype', __('Skype', 'users')).
|
||||
Form::input('skype', $user_skype, array('class' => 'span6')).Html::br()
|
||||
);
|
||||
|
||||
if (isset($_SESSION['user_role']) && in_array($_SESSION['user_role'], array('admin'))) {
|
||||
echo Form::label('role', __('Role', 'users'));
|
||||
echo Form::select('role', array('admin' => __('Admin', 'users'), 'editor' => __('Editor', 'users'), 'user' => __('User', 'users')), $user['role'], array('class' => 'span3')). Html::br();
|
||||
} else {
|
||||
echo Form::hidden('role', $_SESSION['user_role']);
|
||||
}
|
||||
|
||||
|
||||
echo (
|
||||
Html::br().
|
||||
Form::submit('edit_profile', __('Save', 'users'), array('class' => 'btn')).
|
||||
Form::close()
|
||||
);
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="span5">
|
||||
<?php
|
||||
|
||||
echo (
|
||||
Form::open().
|
||||
Form::hidden('csrf', Security::token()).
|
||||
Form::hidden('user_id', Request::get('user_id')).
|
||||
Form::label('new_password', __('New password', 'users')).
|
||||
Form::password('new_password', null, array('class' => 'span6')).Html::br().Html::br().
|
||||
Form::submit('edit_profile_password', __('Save', 'users'), array('class' => 'btn')).
|
||||
Form::close()
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style="clear:both"></div>
|
||||
|
||||
<?php
|
||||
} else {
|
||||
echo '<div class="message-error">'.__('This user does not exist', 'users').'</div>';
|
||||
}
|
||||
?>
|
||||
<!-- /Users_edit -->
|
55
plugins/box/users/views/backend/index.view.php
Normal file
55
plugins/box/users/views/backend/index.view.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<h2><?php echo __('Users', 'users'); ?></h2>
|
||||
<br />
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
|
||||
<?php echo Html::anchor(__('Register new user', 'users'), 'index.php?id=users&action=add', array('title' => __('Create new page', 'users'), 'class' => 'btn default btn-small')); ?>
|
||||
|
||||
<div class="pull-right">
|
||||
<?php echo Form::open(null, array('name' => 'users_frontend')); ?>
|
||||
<?php echo Form::hidden('csrf', Security::token()); ?>
|
||||
<?php echo Form::checkbox('users_frontend_registration', null, $users_frontend_registration); ?> <?php echo __('Allow user registration') ?>
|
||||
<?php echo Form::input('users_frontend_submit', 'users_frontend_submit', array('style' => 'display:none;')); ?>
|
||||
<?php echo Form::close();?>
|
||||
</div>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<!-- Users_list -->
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><?php echo __('Username', 'users'); ?></td>
|
||||
<td><?php echo __('Email', 'users'); ?></td>
|
||||
<td><?php echo __('Registered', 'users'); ?></td>
|
||||
<td><?php echo __('Role', 'users'); ?></td>
|
||||
<td width="30%"><?php echo __('Actions', 'users'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users_list as $user) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo Html::toText($user['login']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo Html::toText($user['email']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo Date::format($user['date_registered']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $roles["{$user['role']}"]; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo Html::anchor(__('Edit', 'users'), 'index.php?id=users&action=edit&user_id='.$user['id'], array('class' => 'btn btn-actions')); ?>
|
||||
<?php echo Html::anchor(__('Delete', 'users'),
|
||||
'index.php?id=users&action=delete&user_id='.$user['id'],
|
||||
array('class' => 'btn btn-actions', 'onclick' => "return confirmDelete('".__('Delete user: :user', 'users', array(':user' => Html::toText($user['login'])))."')"));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- /Users_list -->
|
26
plugins/box/users/views/frontend/edit.view.php
Normal file
26
plugins/box/users/views/frontend/edit.view.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<h3><?php echo __('Edit profile', 'users') ?></h3>
|
||||
<hr>
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
<?php if (Notification::get('error')) Alert::success(Notification::get('error')); ?>
|
||||
|
||||
<form method="post">
|
||||
<?php
|
||||
echo (
|
||||
Form::hidden('csrf', Security::token()).
|
||||
Form::hidden('user_id', $user['id'])
|
||||
);
|
||||
?>
|
||||
<table>
|
||||
<?php if (isset($_SESSION['user_role']) && in_array($_SESSION['user_role'], array('admin'))) { ?>
|
||||
<label><?php echo __('Username', 'users'); ?></label><input type="text" value="<?php echo $user['login']; ?>" name="login">
|
||||
<?php } else { echo Form::hidden('login', $user['login']); } ?>
|
||||
<label><?php echo __('Firstname', 'users'); ?></label><input type="text" value="<?php echo $user['firstname']; ?>" name="firstname">
|
||||
<label><?php echo __('Lastname', 'users'); ?></label><input type="text" value="<?php echo $user['lastname']; ?>" name="lastname">
|
||||
<label><?php echo __('Email', 'users'); ?></label><input type="text" value="<?php echo $user['email']; ?>" name="email">
|
||||
<label><?php echo __('Twitter', 'users'); ?></label><input type="text" value="<?php echo $user['twitter']; ?>" name="twitter">
|
||||
<label><?php echo __('Skype', 'users'); ?></label><input type="text" value="<?php echo $user['skype']; ?>" name="skype">
|
||||
<label><?php echo __('New Password', 'users'); ?></label><input type="text" name="new_password">
|
||||
<br/><input type="submit" class="btn" value="<?php echo __('Save', 'users'); ?>" name="edit_profile">
|
||||
</table>
|
||||
</form>
|
14
plugins/box/users/views/frontend/index.view.php
Normal file
14
plugins/box/users/views/frontend/index.view.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<h3><?php echo __('Users', 'users'); ?></h3>
|
||||
<hr>
|
||||
<table>
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
<?php foreach ($users as $user) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo Site::url(); ?>users/<?php echo $user['id']; ?>"><?php echo $user['login']; ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
10
plugins/box/users/views/frontend/login.view.php
Normal file
10
plugins/box/users/views/frontend/login.view.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<h3><?php echo __('Login', 'users'); ?></h3>
|
||||
<hr>
|
||||
<?php if (Notification::get('error')) Alert::error(Notification::get('error')); ?>
|
||||
<form method="post">
|
||||
<?php echo Form::hidden('csrf', Security::token()); ?>
|
||||
<label><?php echo __('Username', 'users'); ?></label><input name="username" type="text" />
|
||||
<label><?php echo __('Password', 'users'); ?></label><input name="password" type="password" />
|
||||
<br /><input name="login_submit" class="btn" type="submit" value="<?php echo __('Enter', 'users'); ?>" /> <a class="small-grey-text reset-password-btn" href="<?php echo Option::get('siteurl').'users/password-reset'; ?>"><?php echo __('Forgot your password?', 'users');?></a></td></tr>
|
||||
</form>
|
||||
|
25
plugins/box/users/views/frontend/password_reset.view.php
Normal file
25
plugins/box/users/views/frontend/password_reset.view.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<h3><?php echo __('Reset Password', 'users') ?></h3>
|
||||
<hr>
|
||||
|
||||
<?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
|
||||
<?php if (Notification::get('error')) Alert::success(Notification::get('error')); ?>
|
||||
|
||||
<form method="post">
|
||||
<?php
|
||||
echo (Form::hidden('csrf', Security::token()));
|
||||
?>
|
||||
|
||||
<label><?php echo __('Username', 'users'); ?></label><input type="text" value="<?php echo $user_login; ?>" name="login">
|
||||
<?php
|
||||
if (isset($errors['users_user_doesnt_exists'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_user_doesnt_exists'].'</span>';
|
||||
if (isset($errors['users_empty_field'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_empty_field'].'</span>';
|
||||
?>
|
||||
|
||||
<?php if (Option::get('captcha_installed') == 'true') { ?>
|
||||
<label><?php echo __('Captcha'); ?><label>
|
||||
<input type="text" name="answer"><?php if (isset($errors['users_captcha_wrong'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_captcha_wrong'].'</span>'; ?>
|
||||
<?php CryptCaptcha::draw(); ?>
|
||||
<?php } ?>
|
||||
|
||||
<br /><input type="submit" class="btn" value="<?php echo __('Send New Password', 'users'); ?>" name="reset_password_submit">
|
||||
</form>
|
19
plugins/box/users/views/frontend/profile.view.php
Normal file
19
plugins/box/users/views/frontend/profile.view.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<h3><?php echo __('Profile', 'users'); ?></h3>
|
||||
<hr>
|
||||
<?php if ($user) { ?>
|
||||
<table>
|
||||
<tr><td><?php echo __('Username', 'users'); ?></td><td><?php echo $user['login']; ?></td></tr>
|
||||
<tr><td><?php echo __('Firstname', 'users'); ?></td><td><?php echo Html::toText($user['firstname']); ?></td></tr>
|
||||
<tr><td><?php echo __('Lastname', 'users'); ?></td><td><?php echo Html::toText($user['lastname']); ?></td></tr>
|
||||
<tr><td><?php echo __('Email', 'users'); ?></td><td><?php echo Html::toText($user['email']); ?></td></tr>
|
||||
<tr><td><?php echo __('Registered', 'users'); ?></td><td><?php echo Date::format($user['date_registered']); ?></td></tr>
|
||||
<tr><td><?php echo __('Skype', 'users'); ?></td><td><?php echo Html::toText($user['skype']); ?></td></tr>
|
||||
<tr><td><?php echo __('Twitter', 'users'); ?></td><td><?php echo Html::toText($user['twitter']); ?></td></tr>
|
||||
</table>
|
||||
<br />
|
||||
<?php if (Users::isLoged()) { ?>
|
||||
<a href="<?php echo Site::url(); ?>users/<?php echo $user['id']; ?>/edit"><?php echo __('Edit profile', 'users'); ?></a> /
|
||||
<?php if(in_array(Session::get('user_role'), array('admin', 'editor'))) { ?> <a href="<?php echo Site::url(); ?>admin"><?php echo __('Administration', 'system'); ?></a> / <?php } ?>
|
||||
<a href="<?php echo Site::url(); ?>users/logout"><?php echo __('Logout', 'users'); ?></a>
|
||||
<?php } ?>
|
||||
<?php } else { echo __('This users doesnt exists', 'users'); } ?>
|
30
plugins/box/users/views/frontend/registration.view.php
Normal file
30
plugins/box/users/views/frontend/registration.view.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<h3><?php echo __('Registration', 'users'); ?></h3>
|
||||
<hr>
|
||||
<form method="post">
|
||||
<?php
|
||||
echo (Form::hidden('csrf', Security::token()));
|
||||
?>
|
||||
|
||||
<label><?php echo __('Username', 'users'); ?></label><input type="text" value="<?php echo $user_login; ?>" name="login">
|
||||
<?php
|
||||
if (isset($errors['users_this_user_alredy_exists'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_this_user_alredy_exists'].'</span>';
|
||||
if (isset($errors['users_empty_login'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_empty_login'].'</span>';
|
||||
?>
|
||||
<label><?php echo __('Password', 'users'); ?></label><input type="password" value="<?php echo $user_password; ?>" name="password">
|
||||
<?php
|
||||
if (isset($errors['users_empty_password'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_empty_password'].'</span>';
|
||||
?>
|
||||
<label><?php echo __('Email', 'users'); ?></label><input type="text" value="<?php echo $user_email; ?>" name="email">
|
||||
<?php
|
||||
if (isset($errors['users_this_email_alredy_exists'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_this_email_alredy_exists'].'</span>';
|
||||
if (isset($errors['users_empty_email'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_empty_email'].'</span>';
|
||||
if (isset($errors['users_invalid_email'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_invalid_email'].'</span>';
|
||||
?>
|
||||
<?php if (Option::get('captcha_installed') == 'true') { ?>
|
||||
<label><?php echo __('Captcha'); ?><label>
|
||||
<input type="text" name="answer"><?php if (isset($errors['users_captcha_wrong'])) echo Html::nbsp(3).'<span class="error">'.$errors['users_captcha_wrong'].'</span>'; ?>
|
||||
<?php CryptCaptcha::draw(); ?>
|
||||
<?php } ?>
|
||||
|
||||
<br /><input type="submit" class="btn" value="<?php echo __('Register', 'users'); ?>" name="register">
|
||||
</form>
|
13
plugins/box/users/views/frontend/userspanel.view.php
Normal file
13
plugins/box/users/views/frontend/userspanel.view.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<div style="float:right">
|
||||
<?php if (Session::get('user_id')) { ?>
|
||||
<?php echo __('Welcome', 'users'); ?>,
|
||||
<a href="<?php echo Site::url(); ?>users/<?php echo Session::get('user_id'); ?>"><?php echo Session::get('user_login'); ?></a> /
|
||||
<?php if(in_array(Session::get('user_role'), array('admin', 'editor'))) { ?>
|
||||
<a href="<?php echo Site::url(); ?>admin"><?php echo __('Administration', 'system'); ?></a> /
|
||||
<?php } ?>
|
||||
<a href="<?php echo Site::url(); ?>users/logout"><?php echo __('Logout', 'users'); ?></a>
|
||||
<?php } else { ?>
|
||||
<a href="<?php echo Site::url(); ?>users/login"><?php echo __('Login', 'users'); ?></a> /
|
||||
<a href="<?php echo Site::url(); ?>users/registration"><?php echo __('Registration', 'users'); ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
Reference in New Issue
Block a user