Users Plugin
Users plugin is a plugin that allows you to manage users and their roles.
Features
Invites
By default, the invite system is disabled. To start working with this system,
go to festi_settings
, and change the value of the enable_user_invites
column
to 1.
Google Re-Captcha v2
The Google Re-Captcha function is available.
You can activate this function by going to festi_settings
, and changing the value of the enable_captcha
column to 1.
For correct operation, you need a site_key
and secret_key
.
You can get them at Re-Captcha in the admin panel.
Installation
For the PHP_Festi_Plugin_Users
plugin to work correctly, you need to install additional plugins: Jimbo and Mail
Installing Jimbo
git submodule add [email protected]:FestiCore/PHP_Festi_Plugin_Jimbo.git plugins/Jimbo
Installing Mail
git submodule add [email protected]:FestiPlugins/PHP_Festi_Plugin_Mail.git plugins/Mail
Installing Users
git submodule add [email protected]:FestiCore/php_festi_plugin_users.git plugins/Users
Next, you need to install the dumps from the install folder install.sql
- installation of basic configurations
To add the ability to edit user contact information, you need to connect user_dashboard.js
index.php
$usersPlugin = $core->getPluginInstance('Users');
$usersPlugin->includeStatic('js/user_dashboard.js');
After connecting, the username in the menu will become clickable
The following links have been added
Url | Description |
---|---|
/festi/users/Users/ | User management (only for admins) |
/festi/roles/Users/ | Role management (only for admins) |
/profile/ | User profile |
/invites/ | User invites page |
Dump
Adding columns to the users table and creating user_invites
ALTER TABLE `users` ADD `cdate` DATE NULL AFTER `email`;
ALTER TABLE `users` ADD `ctime` TIME NULL AFTER `cdate`;
ALTER TABLE `users` ADD `access_token` VARCHAR(32) NULL DEFAULT NULL AFTER `ctime`;
ALTER TABLE `users` ADD `id_parent` INT(11) UNSIGNED DEFAULT NULL AFTER `access_token`;
ALTER TABLE `users` ADD `invites_count` INT(11) UNSIGNED DEFAULT NULL AFTER `id_parent`;
ALTER TABLE `users` ADD `balance` decimal(10,2) NOT NULL AFTER `invites_count`;
CREATE TABLE `user_invites` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_owner` int(10) unsigned NOT NULL,
`id_user` int(10) unsigned DEFAULT NULL,
`code` varchar(6) NOT NULL,
`email` varchar(128) NOT NULL,
`is_used` int(1) DEFAULT NULL,
`cdate` date NOT NULL,
`mdate` date DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `id_owner` (`id_owner`),
KEY `id_user` (`id_user`),
CONSTRAINT `user_invites_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `users` (`id`) ON UPDATE CASCADE,
CONSTRAINT `user_invites_ibfk_1` FOREIGN KEY (`id_owner`) REFERENCES `users` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Inserting additional configurations
INSERT INTO `festi_settings` (`id`, `caption`, `name`, `value`)
VALUES
(NULL, '', 'auth_email_column', 'email'),
(NULL, '', 'default_user_type', '2'),
(NULL, '', 'auth_invite_column', 'code'),
(NULL, '', 'user_invites_table', 'user_invites'),
(NULL, '', 'auth_parent_column', 'id_parent'),
(NULL, '', 'enable_forgot_password', '1');
Adding and redefining URLs
INSERT INTO `festi_plugins` (`id`, `status`, `ident`, `version`)
VALUES (NULL, 'active', 'Users', NULL);
UPDATE `festi_url_rules` SET `plugin` = 'Users' WHERE `pattern` = ' ~^/login/$~';
/* Page ~^/profile/$~ */
INSERT INTO `festi_url_rules` (`id`, `plugin`, `pattern`, `method`)
VALUES (NULL, 'Users', '~^/profile/$~', 'onDisplayProfile');
INSERT INTO `festi_url_rules2areas`(`id`, `id_url_rule`, `area`)
VALUES (NULL, LAST_INSERT_ID(), 'backend');
/* Page ~^/invites/$~ */
INSERT INTO `festi_url_rules` (`id`, `plugin`, `pattern`, `method`)
VALUES (NULL, 'Users', '~^/invites/$~', 'onDisplayInvites');
INSERT INTO `festi_url_rules2areas`(`id`, `id_url_rule`, `area`)
VALUES (NULL, LAST_INSERT_ID(), 'backend');
/* Page ~^/signup/$~ */
INSERT INTO `festi_url_rules` (`id`, `plugin`, `pattern`, `method`)
VALUES (NULL, 'Users', '~^/signup/$~', 'onDisplaySignup');
INSERT INTO `festi_url_rules2areas`(`id`, `id_url_rule`, `area`)
VALUES (NULL, LAST_INSERT_ID(), 'backend');
/* Page ~^/forgot/$~ */
INSERT INTO `festi_url_rules` (`id`, `plugin`, `pattern`, `method`)
VALUES (NULL, 'Users', '~^/forgot/$~', 'onDisplayFrogotPassword');
INSERT INTO `festi_url_rules2areas`(`id`, `id_url_rule`, `area`)
VALUES (NULL, LAST_INSERT_ID(), 'backend');
Adding Users Section for roles
/* Add Users Section By Admin*/
INSERT INTO `festi_sections` (`id`, `caption`, `ident`, `mask`)
VALUES (1, 'Users', 'users', '2');
INSERT INTO `festi_sections_user_types_permission` (`id`, `id_section`, `id_user_type`, `value`)
VALUES (1, 1, 1, 2);
Email Templates for plugin Mail
/* Add Emails Templates. Must be Mail Plugin [email protected]:FestiPlugins/PHP_Festi_Plugin_Mail.git */
INSERT INTO `email_templates` (`id`, `ident`, `caption`, `subject`, `title`, `body`, `template`)
VALUES
(NULL, 'invite_user', 'You have received an invitation', 'You have received an invitation', 'You have received an invitation', '<h2>You have received an invitation</h2>\n<h1>Welcome</h1>\n<p>\nCongratulations! <?php echo $user[\'name\'].\' \'.$user[\'lastname\'];?>\n</p>\n<p>\nTo activate your account, please click the <a href=\"<?php echo $href; ?>\">Link<a>.\n</p>\n<p>\nOr add your invitation code: <br />\n<?php $urlClear = explode(\'?\', $href);?>\n<a href=\"<?php echo $urlClear[0]; ?>\"><?php echo $urlClear[0]; ?></a>\n</p>\n<p>\nInvitation Code: <br />\n<strong><?php echo $code; ?></strong>\n</p>', 'basic'),
(NULL, 'signup_invite', 'Someone has just registered\r\n', 'Someone has just registered', 'Someone has just registered', '<h2>Someone has just registered</h2>\n<p>\nHello <?php echo $user[\'name\'].\' \'.$user[\'lastname\']; ?>,\n</p>\n<p>\n<?php echo $email; ?> has just registered.\n</p>', 'basic'),
(NULL, 'email_forgot_password', 'Reset your password.', 'Reset your password.', 'Reset your password.', '<h2>Reset your password.</h2>\n<p>\nDear <?php echo $user[\'name\'].\' \'.$user[\'lastname\']; ?>,\n</p>\n<p>\nWe received a request to reset the password associated with this email address. If you made this request, please follow the instructions below.\nClick the link below to reset your password using our secure server:\n</p>\n<a href=\'<?php echo $url; ?>\'><?php echo $url; ?></a>\n<p>\nIf you did not request to have your password reset, you can safely ignore this email. Rest assured your customer account is safe.\n</p>', 'basic'),
(NULL, 'email_new_password', 'Your password has been changed.', 'Your password has been changed.', 'Your password has been changed.', '<h2>Your ... password has been changed.</h2>\n<p>\nThank you for your inquiry. According to our records, your Log-In information is as follows:\n</p>\n<p>\nPassword: <?php echo $password; ?>\n</p>\n<p>\nPlease remember that your password is confidential and should never be shared with others.\n</p>', 'basic'),
(NULL, 'user_signup_complete', 'Sign-up', 'Sign-up', 'Sign-up', '<h2>Sign-up</h2>\n<p>\nHi <?php echo $user[\'name\'].\' \'.$user[\'lastname\']; ?>,\n</p>\n<p>\nYour information is:\nUsername: <?php echo $user[\'login\'] ?>\n</p>\n<p>\nIf you need to recover your password at any time, simply go to the password recovery page and enter your information to set up a new password.\n</p>\n', 'basic');