The module is designed to work with the users of the site and their properties.
The administrative part of the module refers to the part of the CMS «Management» and is required for installation.
The user of the module installed optional and consists of three parts: a user page, registration, password recovery.
Connect is used to access properties of the current user and work with the current user.
Подключаемая часть – файл modules/users/users.inc.php. В нем описан класс
Users_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_users
. Экземпляр класса создается при первом вызове
переменной.
Example:
// modules/usersettings/usersettings.php
// Similar design is used very often, when it is necessary to determine,
// if the user is logged in or not. In this example, the "guest"
// will be redirected to the error 403 page.
if(! $this->diafan->_users->id)
{
Custom::inc('includes/403.php');
}
var role_id – current user role.
var checked – verified by user's identification hash.
Example:
// in the file adm/includes/action.php
// when submitting a form is checked for uniqueness of each request by a user hash
if (! $this->diafan->_users->checked)
{
echo 'The user failed the test.';
}
Example:
// We use the test to display the properties of the admin administrator greetings
if($this->diafan->_users->admin)
{
echo 'Hello, administratior!';
}
var errauth – authorisation error.
Example:
// authorization error contains the error constant
switch ($this->diafan->_users->errauth)
{
case 'wrong_login_or_pass':
echo 'Incorrect e-mail or password.';
break;
case 'blocked_30_min':
echo 'You have exceeded the maximum number of attempts for this action. Please retry doing the same in 30 minutes.';
break;
case 'blocked':
echo 'Login is not activated or blocked.';
break;
}
var fields = array('name', 'fio', 'mail', 'phone', 'created', 'role_id', 'lang_id', 'htmleditor', 'admin_nastr', 'start_admin', 'useradmin', 'copy_files', 'config') – user specifications.
The fields included in this array, you can call through the variable $this->diafan->_users
. A utility function __get()
will return the value of the field from the database for the current user.
Example:
echo 'Hello, '.$this->diafan->_users->fio.'!
Your username: '.$this->diafan->_users->name.'
Your e-mail: '.$this->diafan->_users->mail.'
Your phone: '.$this->diafan->_users->phone.'
You have registered on the site: '.date("d.m.Y H:i", $this->diafan->_users->created);
void set (object $user) – Sets current user.
Example:
// authorizing the current visitor as a user with ID=5
$user = DB::query_fetch_object("SELECT * FROM {users} WHERE id=5");
$this->diafan->_users->set($user);
void delete_session_hash (integer $id) – Delete identification hash.
string get_hash () – Generates an identification user hash.
Example:
// includes/action.php
// it is used to verify the uniqueness of the request for the user
$this->result["hash"] = $this->diafan->_users->get_hash();
boolean true logout () – Clears information about the current user.
Example:
// includes/init.php
// initiates user logoff
if (strpos($_GET["rewrite"], "logout") !== false)
{
$this->_users->logout();
}
array auth (array $form_values) – Check whether the user is authorized.
Example:
// includes/init.php
// data validation when the user authorization
if (! empty($_POST['action']) && $_POST['action'] == 'auth')
{
$this->_users->auth($_POST);
}
void create_avatar (string $name, string $file) – Uploads avatar.
Example:
// generate avatar for user with login alex
// from the file http://site.com/userfiles/alex_avatar.jpg
$name_user = 'alex';
$path_to_img = ABSOLUTE_PATH.USERFILES.'/alex_avatar.jpg';
$this->diafan->_users->create_avatar($name_user, $path_to_img);
boolean roles (string $action, [string $module_name = ''], [array $roles = array()], [string $type = 'admin']) – Checks if the user has the right to the action for the module.
Example:
// check user permission to edit categories of products
if (! $this->diafan->_users->roles("edit", "shop/category"))
{
echo "No access to the module.";
}
By default, the system has a chief administrator name and password that you specified during installation DIAFAN.CMS.
You can not delete, lock yourself or change yourself permissions.
Users can search by name.
Users have the following characteristics:
Part of the module "User groups" allows you to edit permissions of users.
User groups have the following characteristics:
The module "Registration" allows users to log on to the site for more options.
To display the registration form / online editing, you need to attach the module to the page of the site.
Recording and editing are carried out using Ajax technology, ie without reloading the whole page.
Restore access to account – it is a separate module in the user part of the site (reminding). It is installed with the module "Registration" and needs to recover the user's password.
To display the form to restore access to the site, you need to attach the module to the page of the site.
Restoring implemented using Ajax technology, ie without reloading the whole page.
The form of registration / editing data can supplement their fields using the form designer.
Form builder – a supplementary registration form fields.
Fields have the following characteristics.
Для работы с модулем «Users» служат следующие шаблонные теги:
show_block – выводит статистику пользователей на сайте.
Атрибуты:
— defer – deferred load tag template tag: event – load content only at the request of the user when you click "Upload", emergence – load content only when the client window appears in the browser window, async – asynchronous (simultaneous) content loading together with the content of template tags with the same marker, sync – synchronous (sequential) load of content in conjunction with the content of template tags with the same marker, by default, downloading content only at the request of the user;
— defer_title – text string displayed at the point where the loadable content appears with the help of delayed loading of the template tag;
— template – tag template (file modules/users/views/users.view.show_block_template.php; default - file modules/users/views/users.view.show_block.php).
Example:
<insert name="show_block" module="users">
выведет «Сейчас на сайте: 13 гостей, 9 пользователей.»
В шаблоне тега можно получить значение любого атрибута через переменную $result["attributes"]["название атрибута"]
.
show_login module="registration" – выводит форму авторизации или приветствие и ссылки на редактирование данных и выход, если пользователь авторизован.
Атрибуты:
— defer – deferred load tag template tag: event – load content only at the request of the user when you click "Upload", emergence – load content only when the client window appears in the browser window, async – asynchronous (simultaneous) content loading together with the content of template tags with the same marker, sync – synchronous (sequential) load of content in conjunction with the content of template tags with the same marker, by default, downloading content only at the request of the user;
— defer_title – text string displayed at the point where the loadable content appears with the help of delayed loading of the template tag;
— template – tag template (file modules/registration/views/registration.view.show_login_template.php; default - file modules/registration/views/registration.view.show_login.php).
Example:
<insert name="show_login" module="registration">
выведет форму авторизации
В шаблоне тега можно получить значение любого атрибута через переменную $result["attributes"]["название атрибута"]
.
{users} – Users
{users_actlink} – Код активации аккаунта
{users_param} – Дополнительные поля с данными о пользователях
{users_param_element} – Значения дополнительных полей с данными о пользователях
{users_param_role_rel} – Связи дополнительных полей с данными о пользователях и типов пользователей
{users_param_select} – Варианты значений дополнительных полей с данными о пользователях для типа список
{users_role} – Типы пользователей
{users_role_perm} – Права типов пользователей
modules/registration/js/registration.form.js – JS-сценарий модуля «Регистрация»;
modules/registration/registration.php – Controller;
modules/registration/registration.action.php – Обработка запроса при регистрации пользователя;
modules/registration/registration.model.php – Модель модуля «Регистрация»;
modules/registration/views/registration.view.act.php – Шаблон страницы активации аккаунта;
modules/registration/views/registration.view.form.php – Шаблон формы регистрации;
modules/registration/views/registration.view.images.php – Template attached images;
modules/registration/views/registration.view.show_login.php – Шаблон блока авторизации;
modules/registration/views/registration.view.show_param.php – Шаблон дополнительных полей в форме регистрации данных;
modules/registration/views/registration.view.success.php – Шаблон страницы успешной регистрации;
modules/reminding/reminding.php – Controller;
modules/reminding/reminding.action.php – Обработка запроса при отправке данных из формы восстановления пароля;
modules/reminding/reminding.model.php – Модель модуля «Восстановление пароля»;
modules/reminding/views/reminding.view.form_change_password.php – Шаблон формы смены пароля;
modules/reminding/views/reminding.view.form_mail.php – Шаблон формы восстановления доступа;
modules/reminding/views/reminding.view.success.php – Шаблон страницы успешной смены пароля;
modules/userpage/userpage.php – Controller;
modules/userpage/userpage.model.php – Модель модуля «Страница пользователя»;
modules/userpage/views/userpage.view.orders.php – Шаблон заказов пользователя;
modules/userpage/views/userpage.view.show.php – Шаблон страницы пользователя;
modules/users/admin/js/users.admin.edit.js – Редактирование пользователей, JS-сценарий;
modules/users/admin/js/users.admin.role.js – Редактирование типов пользователей, JS-сценарий;
modules/users/admin/users.admin.php – Редактирование пользователей сайта;
modules/users/admin/users.admin.config.php – Module settings;
modules/users/admin/users.admin.inc.php – Connecting the module to the administrative part of other modules;
modules/users/admin/users.admin.param.php – Registration form builder;
modules/users/admin/users.admin.role.php – Редактирование типов пользователей;
modules/users/users.php – Котроллер модуля «Пользователи на сайте»;
modules/users/users.inc.php – Connection of module;
modules/users/users.install.php – Module installation;
modules/users/users.model.php – Модель модуля «Пользователи на сайте»;
modules/users/views/users.view.show_block.php – Шаблон статистики пользователей на сайте;
modules/usersettings/js/usersettings.form.js – JS-сценарий модуля «Настройки аккаунта»;
modules/usersettings/usersettings.php – Controller;
modules/usersettings/usersettings.action.php – Обработка запроса при изменении данных о пользователе;
modules/usersettings/usersettings.model.php – Модель модуля «Настройки аккаунта»;
modules/usersettings/views/usersettings.view.attachments.php – Шаблон прикрепленных файлов в настройках аккаунта;
modules/usersettings/views/usersettings.view.avatar.php – Шаблон аватара;
modules/usersettings/views/usersettings.view.form.php – Шаблон формы настроек аккаунта;
modules/usersettings/views/usersettings.view.images.php – Template attached images;
modules/usersettings/views/usersettings.view.show_param.php – Шаблон дополнительных в настройках аккаунта.