Users

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.

Connection

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. Экземпляр класса создается при первом вызове переменной.

Свойства

var id – current user ID.

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.';
}

var admin – user is admin.

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.

  • object $user: current user data

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.

  • integer $id: identification hash ID

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.

  • array $form_values: array with data for authorization - login and password

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.

  • string $name: username
  • string $file: avatar file

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.

  • string $action: action
  • string $module_name: module
  • array $roles: access rights
  • string $type: Part of the site administrative / public

Example:

// check user permission to edit categories of products
if (! $this->diafan->_users->roles("edit", "shop/category"))
{
    echo
"No access to the module.";
}

Users

List of users

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.

Edit of user

Users have the following characteristics:

User groups

List of user groups

Part of the module "User groups" allows you to edit permissions of users.

Edit of user group

User groups have the following characteristics:

Registration

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

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.

Registration form builder

List of fields

The form of registration / editing data can supplement their fields using the form designer.

Form builder – a supplementary registration form fields.

Edit of field

Fields have the following characteristics.

Settings

Settings

Template tags

Для работы с модулем «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"]["название атрибута"].

Database

{users} – Users

{users_actlink} – Код активации аккаунта

{users_param} – Дополнительные поля с данными о пользователях

{users_param_element} – Значения дополнительных полей с данными о пользователях

{users_param_role_rel} – Связи дополнительных полей с данными о пользователях и типов пользователей

{users_param_select} – Варианты значений дополнительных полей с данными о пользователях для типа список

{users_role} – Типы пользователей

{users_role_perm} – Права типов пользователей

Files

  1. modules/registration/js/registration.form.js – JS-сценарий модуля «Регистрация»;

  2. modules/registration/registration.php – Controller;

  3. modules/registration/registration.action.php – Обработка запроса при регистрации пользователя;

  4. modules/registration/registration.model.php – Модель модуля «Регистрация»;

  5. modules/registration/views/registration.view.act.php – Шаблон страницы активации аккаунта;

  6. modules/registration/views/registration.view.form.php – Шаблон формы регистрации;

  7. modules/registration/views/registration.view.images.php – Template attached images;

  8. modules/registration/views/registration.view.show_login.php – Шаблон блока авторизации;

  9. modules/registration/views/registration.view.show_param.php – Шаблон дополнительных полей в форме регистрации данных;

  10. modules/registration/views/registration.view.success.php – Шаблон страницы успешной регистрации;

  11. modules/reminding/reminding.php – Controller;

  12. modules/reminding/reminding.action.php – Обработка запроса при отправке данных из формы восстановления пароля;

  13. modules/reminding/reminding.model.php – Модель модуля «Восстановление пароля»;

  14. modules/reminding/views/reminding.view.form_change_password.php – Шаблон формы смены пароля;

  15. modules/reminding/views/reminding.view.form_mail.php – Шаблон формы восстановления доступа;

  16. modules/reminding/views/reminding.view.success.php – Шаблон страницы успешной смены пароля;

  17. modules/userpage/userpage.php – Controller;

  18. modules/userpage/userpage.model.php – Модель модуля «Страница пользователя»;

  19. modules/userpage/views/userpage.view.orders.php – Шаблон заказов пользователя;

  20. modules/userpage/views/userpage.view.show.php – Шаблон страницы пользователя;

  21. modules/users/admin/js/users.admin.edit.js – Редактирование пользователей, JS-сценарий;

  22. modules/users/admin/js/users.admin.role.js – Редактирование типов пользователей, JS-сценарий;

  23. modules/users/admin/users.admin.php – Редактирование пользователей сайта;

  24. modules/users/admin/users.admin.config.php – Module settings;

  25. modules/users/admin/users.admin.inc.php – Connecting the module to the administrative part of other modules;

  26. modules/users/admin/users.admin.param.php – Registration form builder;

  27. modules/users/admin/users.admin.role.php – Редактирование типов пользователей;

  28. modules/users/users.php – Котроллер модуля «Пользователи на сайте»;

  29. modules/users/users.inc.php – Connection of module;

  30. modules/users/users.install.php – Module installation;

  31. modules/users/users.model.php – Модель модуля «Пользователи на сайте»;

  32. modules/users/views/users.view.show_block.php – Шаблон статистики пользователей на сайте;

  33. modules/usersettings/js/usersettings.form.js – JS-сценарий модуля «Настройки аккаунта»;

  34. modules/usersettings/usersettings.php – Controller;

  35. modules/usersettings/usersettings.action.php – Обработка запроса при изменении данных о пользователе;

  36. modules/usersettings/usersettings.model.php – Модель модуля «Настройки аккаунта»;

  37. modules/usersettings/views/usersettings.view.attachments.php – Шаблон прикрепленных файлов в настройках аккаунта;

  38. modules/usersettings/views/usersettings.view.avatar.php – Шаблон аватара;

  39. modules/usersettings/views/usersettings.view.form.php – Шаблон формы настроек аккаунта;

  40. modules/usersettings/views/usersettings.view.images.php – Template attached images;

  41. modules/usersettings/views/usersettings.view.show_param.php – Шаблон дополнительных в настройках аккаунта.