generated from mirzaev/pot
renamed + organistaion page + autonoms and structors
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "svoboda/svoboder",
|
||||
"name": "svoboda/antivertical",
|
||||
"description": "Svoboda Telegram chat-robot",
|
||||
"homepage": "https://git.svoboda.works/svoboda/svoboder",
|
||||
"homepage": "https://git.svoboda.works/svoboda/antivertical",
|
||||
"type": "chat-robot",
|
||||
"keywords": [
|
||||
"svoboda",
|
||||
@@ -21,13 +21,13 @@
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"wiki": "https://git.svoboda.works/svoboda/svoboder/wiki",
|
||||
"issues": "https://git.svoboda.works/svoboda/svoboder/issues"
|
||||
"wiki": "https://git.svoboda.works/svoboda/antivertical/wiki",
|
||||
"issues": "https://git.svoboda.works/svoboda/antivertical/issues"
|
||||
},
|
||||
"require": {
|
||||
"php": "^8.4",
|
||||
"mirzaev/minimal": "^3.4.0",
|
||||
"mirzaev/baza": "^3.1.0",
|
||||
"mirzaev/minimal": "^3.6.2",
|
||||
"mirzaev/baza": "^3.4",
|
||||
"svoboda/time": "^1.0",
|
||||
"badfarm/zanzara": "^0.9.1",
|
||||
"react/filesystem": "^0.1.2",
|
||||
@@ -35,12 +35,12 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"svoboda\\svoboder\\": "svoboda/svoboder/system"
|
||||
"svoboda\\antivertical\\": "svoboda/antivertical/system"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"svoboda\\svoboder\\tests\\": "svoboda/svoboder/tests"
|
||||
"svoboda\\antivertical\\tests\\": "svoboda/antivertical/tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
@@ -2,10 +2,10 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\controllers;
|
||||
namespace svoboda\antivertical\controllers;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core as models;
|
||||
use svoboda\antivertical\models\core as models;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\core as minimal,
|
||||
@@ -16,7 +16,7 @@ use mirzaev\minimal\core as minimal,
|
||||
/**
|
||||
* Controllers core
|
||||
*
|
||||
* @package svoboda\svoboder\controllers
|
||||
* @package svoboda\antivertical\controllers
|
||||
*
|
||||
* @param language $language Language
|
||||
* @param response $response Response
|
||||
@@ -25,7 +25,7 @@ use mirzaev\minimal\core as minimal,
|
||||
* @method void __construct(minimal $minimal, bool $initialize) Constructor
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author svoboda <mail@domain.zone>
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
class core extends controller
|
||||
{
|
@@ -1,3 +1,3 @@
|
||||
!.gitignore
|
||||
*.baza
|
||||
*.php
|
||||
# *.php
|
59
svoboda/antivertical/system/databases/accounts.php
Normal file
59
svoboda/antivertical/system/databases/accounts.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\account;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\record;
|
||||
|
||||
// Enabling debugging
|
||||
/* ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1); */
|
||||
|
||||
// Initializing path to the public directory
|
||||
define('INDEX', __DIR__);
|
||||
|
||||
// Initializing path to the root directory
|
||||
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Initializing path to the settings directory
|
||||
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
||||
|
||||
// Initializing path to the storage directory
|
||||
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
|
||||
|
||||
// Initializing path to the databases directory
|
||||
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
|
||||
|
||||
// Initializing path to the localizations directory
|
||||
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
|
||||
|
||||
// Initiailizing telegram key
|
||||
define('TELEGRAM_KEY', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
|
||||
|
||||
// Initializing dependencies
|
||||
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing the account model
|
||||
$model = new account();
|
||||
|
||||
var_dump(
|
||||
$model->database->read(
|
||||
update: function (record &$record) {
|
||||
$record->authorized_system_accounts = 1;
|
||||
$record->authorized_system_distributions = 1;
|
||||
$record->authorized_system_settings = 1;
|
||||
$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: 1,
|
||||
offset: 0
|
||||
)
|
||||
);
|
@@ -4,73 +4,97 @@
|
||||
return [
|
||||
// System
|
||||
'svoboda' => 'Svoboda',
|
||||
'antivertical' => 'Antivertical',
|
||||
'empty' => 'Empty',
|
||||
'yes' => 'Yes',
|
||||
'no' => 'No',
|
||||
|
||||
// Main menu
|
||||
'menu_title' => 'Main menu',
|
||||
'menu_title' => 'Antivertical',
|
||||
'menu_accounts' => 'Accounts',
|
||||
'menu_members' => 'Members',
|
||||
'menu_distributions' => 'Distributions',
|
||||
'menu_not_syncronized' => 'The database does not synchronize with the blockchain network',
|
||||
'menu_structors' => 'Structors',
|
||||
'menu_autonoms' => 'Autonoms',
|
||||
'menu_volunteers' => 'Volunteers',
|
||||
'menu_investors' => 'Investors',
|
||||
'menu_recruiters' => 'Recruiters',
|
||||
/* 'menu_' => '', */
|
||||
'menu_not_syncronized' => 'The database are not synchronized with the blockchain network',
|
||||
'menu_warning_database' => 'The database are publish into the repository everyday',
|
||||
'menu_button_channel' => 'Channel',
|
||||
'menu_button_site' => 'Site',
|
||||
'menu_button_map' => 'Map',
|
||||
'menu_button_blog' => 'Blog',
|
||||
'menu_button_projects' => 'Projects',
|
||||
'menu_button_members' => 'Members',
|
||||
'menu_button_chats' => 'Chats',
|
||||
'menu_button_channels' => 'Channels',
|
||||
'menu_button_memberships' => 'Memberships',
|
||||
'menu_button_distributions' => 'Distributions',
|
||||
'menu_button_projects' => 'Projects',
|
||||
'menu_button_events' => 'Events',
|
||||
'menu_button_organisation' => 'Organisation',
|
||||
|
||||
// Members
|
||||
'members_title' => 'Registry of members',
|
||||
'members_description' => 'Member is a person who has any form of affiliation with *Svoboda*',
|
||||
'members_button_search' => 'Search',
|
||||
// Thinking stuff
|
||||
'thing_about_it_1' => 'Great names are created in the East',
|
||||
'thing_about_it_1_author' => 'Lermontov M. Y.',
|
||||
'thing_about_it_2' => '',
|
||||
'thing_about_it_3' => '',
|
||||
'thing_about_it_4' => '',
|
||||
'thing_about_it_5' => '',
|
||||
/* 'thing_about_it_' => '',
|
||||
'thing_about_it__author' => '', */
|
||||
|
||||
// Members search
|
||||
'member_search_started' => 'Process of the member search started',
|
||||
'member_search_not_started' => 'Process of the member search has not started',
|
||||
'member_search_ended' => 'Process of the member search ended',
|
||||
'member_search_not_localized' => 'Failed to initialize the member account localization',
|
||||
'member_search_not_named' => 'No name',
|
||||
'member_search_status' => 'Status',
|
||||
'member_search_status_2' => 'Member',
|
||||
'member_search_status_1' => 'Planned',
|
||||
'member_search_status_0' => 'Unknown',
|
||||
'member_search_continiued' => 'Process of the member search found and continiued',
|
||||
'member_search_empty' => 'No members found',
|
||||
'member_search_title' => 'Member search',
|
||||
'member_search_distribution' => 'Distribution',
|
||||
'member_search_page_next_exists' => 'There are more members in the registry',
|
||||
'member_search_page_next_not_exists' => 'There are no more members in the registry',
|
||||
'member_search_button_name' => 'Name',
|
||||
'member_search_name_request_title' => 'Enter name',
|
||||
'member_search_name_request_description' => 'Search will be conducted by members names using the Levenshtein function',
|
||||
'member_search_name_request_not_acceptable' => 'Failed to process the name',
|
||||
'member_search_name_request_too_short' => 'Name length must be \>\= 2 and \<\= 128',
|
||||
'member_search_name_request_too_long' => 'Name length must be \>\= 2 and \<\= 128',
|
||||
'member_search_name_request_restricted_characters_title' => "Restricted any characters except letters, dashes and spaces",
|
||||
'member_search_name_request_restricted_characters_description' => "Remove these characters:",
|
||||
'member_search_name_update_success' => 'Name replaced:',
|
||||
'member_search_name_update_fail' => 'Failed to replace name',
|
||||
'member_search_distribution_selection_description' => 'The selected distribution will be used to search for members',
|
||||
'member_search_distribution_update_success' => 'Distribution replaced:',
|
||||
'member_search_distribution_update_fail' => 'Failed to replace distribution',
|
||||
'member_search_status_select_title' => 'Select the member status',
|
||||
'member_search_status_update_success' => 'Status replaced:',
|
||||
'member_search_status_update_fail' => 'Failed to replace status',
|
||||
'member_search_button_start' => 'Start the search',
|
||||
'member_search_button_end' => 'End the search',
|
||||
'member_search_button_page_next' => 'Next page',
|
||||
'member_search_button_message' => 'Message',
|
||||
'member_search_button_distribution' => 'Distribution',
|
||||
'member_search_button_status' => 'Status',
|
||||
'member_search_button_status_2' => 'Member',
|
||||
'member_search_button_status_1' => 'Planned',
|
||||
'member_search_button_status_0' => 'Unknown',
|
||||
|
||||
// Structor
|
||||
'memberships_title' => 'Registry of structors',
|
||||
'memberships_structor' => 'Structor \- an anarchist representing the distribution',
|
||||
'memberships_autonom' => 'Autonom - an anarchist representing only himself personally',
|
||||
'memberships_button_search' => 'Search',
|
||||
|
||||
// Memberships search
|
||||
'membership_search_started' => 'Process of the membership search started',
|
||||
'membership_search_not_started' => 'Process of the membership search has not started',
|
||||
'membership_search_ended' => 'Process of the membership search ended',
|
||||
'membership_search_not_localized' => 'Failed to initialize the membership account localization',
|
||||
'membership_search_not_named' => 'No name',
|
||||
'membership_search_status' => 'Status',
|
||||
'membership_search_status_2' => 'Membership',
|
||||
'membership_search_status_1' => 'Planned',
|
||||
'membership_search_status_0' => 'Unknown',
|
||||
'membership_search_continiued' => 'Process of the membership search found and continiued',
|
||||
'membership_search_empty' => 'No memberships found',
|
||||
'membership_search_title' => 'Membership search',
|
||||
'membership_search_distribution' => 'Distribution',
|
||||
'membership_search_page_next_exists' => 'There are more memberships in the registry',
|
||||
'membership_search_page_next_not_exists' => 'There are no more memberships in the registry',
|
||||
'membership_search_button_name' => 'Name',
|
||||
'membership_search_name_request_title' => 'Enter name',
|
||||
'membership_search_name_request_description' => 'Search will be conducted by memberships names using the Levenshtein function',
|
||||
'membership_search_name_request_not_acceptable' => 'Failed to process the name',
|
||||
'membership_search_name_request_too_short' => 'Name length must be \>\= 2 and \<\= 128',
|
||||
'membership_search_name_request_too_long' => 'Name length must be \>\= 2 and \<\= 128',
|
||||
'membership_search_name_request_restricted_characters_title' => "Restricted any characters except letters, dashes and spaces",
|
||||
'membership_search_name_request_restricted_characters_description' => "Remove these characters:",
|
||||
'membership_search_name_update_success' => 'Name replaced:',
|
||||
'membership_search_name_update_fail' => 'Failed to replace name',
|
||||
'membership_search_distribution_selection_description' => 'The selected distribution will be used to search for memberships',
|
||||
'membership_search_distribution_update_success' => 'Distribution replaced:',
|
||||
'membership_search_distribution_update_fail' => 'Failed to replace distribution',
|
||||
'membership_search_status_select_title' => 'Select the membership status',
|
||||
'membership_search_status_update_success' => 'Status replaced:',
|
||||
'membership_search_status_update_fail' => 'Failed to replace status',
|
||||
'membership_search_button_start' => 'Start the search',
|
||||
'membership_search_button_end' => 'End the search',
|
||||
'membership_search_button_page_next' => 'Next page',
|
||||
'membership_search_button_message' => 'Message',
|
||||
'membership_search_button_distribution' => 'Distribution',
|
||||
'membership_search_button_status' => 'Status',
|
||||
'membership_search_button_status_2' => 'Membership',
|
||||
'membership_search_button_status_1' => 'Planned',
|
||||
'membership_search_button_status_0' => 'Unknown',
|
||||
|
||||
// Distributions
|
||||
'distributions_title' => 'Registry of distributions',
|
||||
'distributions_description' => '*Distribution* is an autonomous cell of Svoboda, representing any type of formation \(for example: commune\), but necessarily inherits the *Vhod* protocol and tied to a location',
|
||||
'distributions_description' => '*Distribution* is an autonomous cell of Svoboda, representing any type of formation, but necessarily inherits the codex',
|
||||
'distributions_declared' => 'Declared',
|
||||
'distributions_recognized' => 'Recognized',
|
||||
'distributions_button_search' => 'Search',
|
||||
@@ -139,7 +163,7 @@ return [
|
||||
'distribution_search_continiued' => 'Process of the distribution search found and continiued',
|
||||
'distribution_search_empty' => 'No distributions found',
|
||||
'distribution_search_title' => 'Distribution search',
|
||||
'distribution_search_members' => 'Members',
|
||||
'distribution_search_memberships' => 'Memberships',
|
||||
'distribution_search_recognized' => 'Recognized',
|
||||
'distribution_search_planners' => 'Planners',
|
||||
'distribution_search_volunteers' => 'Volunteers',
|
||||
@@ -182,7 +206,7 @@ return [
|
||||
'distribution_search_button_end' => 'End the search',
|
||||
'distribution_search_button_page_next' => 'Next page',
|
||||
'distribution_search_button_map' => 'Map',
|
||||
'distribution_search_button_members' => 'Members',
|
||||
'distribution_search_button_memberships' => 'Memberships',
|
||||
'distribution_search_button_volunteers' => 'Volunteers',
|
||||
'distribution_search_button_plan' => 'Plan',
|
||||
'distribution_search_button_unplan' => 'Cancel the planning',
|
||||
@@ -193,18 +217,18 @@ return [
|
||||
'distribution_search_button_join' => 'Join',
|
||||
'distribution_search_button_leave' => 'Leave',
|
||||
'distribution_search_joined_title' => 'You joined the distribution',
|
||||
'distribution_search_joined_description' => 'You have claimed to be a member of the distribution, now you need to get recognition from its members',
|
||||
'distribution_search_already_joined' => 'You are already joined to the distribution',
|
||||
'distribution_search_joined_description' => 'You stated yourself as the distribution structor',
|
||||
'distribution_search_already_joined' => 'You are already stated as the distribution structor',
|
||||
'distribution_search_leaved' => 'You leaved the distribution',
|
||||
'distribution_search_already_leaved' => 'You are already leaved the distribution',
|
||||
'distribution_search_button_message' => 'Message',
|
||||
'distribution_search_km' => 'km',
|
||||
'distribution_search_mi' => 'ml',
|
||||
'distribution_search_member_not_updated' => 'Failed to update the member record in the database',
|
||||
'distribution_search_member_not_created' => 'Failed to create the member record in the database',
|
||||
'distribution_search_membership_not_updated' => 'Failed to update the membership record in the database',
|
||||
'distribution_search_membership_not_created' => 'Failed to create the membership record in the database',
|
||||
'distribution_search_distribution_not_initialized' => 'Failed to initalize the distribution',
|
||||
'distribution_search_message_not_initialized' => 'Failed to initialized the message',
|
||||
'distribution_search_another_joined' => 'You are already a member of another distribution',
|
||||
'distribution_search_another_joined' => 'You are already a membership of another distribution',
|
||||
'distribution_search_another_planned' => 'You are already planning to join another distribution',
|
||||
|
||||
// Distribution select
|
||||
@@ -256,20 +280,38 @@ return [
|
||||
'distribution_select_km' => 'km',
|
||||
'distribution_select_mi' => 'ml',
|
||||
|
||||
// Organisation
|
||||
'organisation_title' => 'Organisation',
|
||||
'organisation_description' => 'International association of all who want to live honestly and freely',
|
||||
'organisation_structor' => 'Structor \- an anarchist representing the distribution',
|
||||
'organisation_autonom' => 'Autonom - an anarchist representing only himself personally',
|
||||
'organisation_warning_legal' => 'Do not do anything that breaks the law of the country you are in, do not trust anyone and think with your own head',
|
||||
'organisation_warning_administration' => 'At this stage of the Antivertical project development, the administration reserves the right to make a sole decision on the removal of materials that are potentially dangerous for the organization and its participants',
|
||||
'organisation_button_help' => 'Help',
|
||||
'organisation_button_investor' => 'Investor',
|
||||
'organisation_button_volunteer' => 'Volunteer',
|
||||
'organisation_button_structor' => 'Structor',
|
||||
'organisation_button_structor_distribution' => 'Distribution',
|
||||
'organisation_button_autonom' => 'Autonom',
|
||||
|
||||
// Account
|
||||
'account_title' => 'Account',
|
||||
'account_export' => 'This account can be exported to the Svoboda main blockchain network in the future',
|
||||
'account_data' => "⚠️ Your data may be given to the special services of Russia\nBe careful and think with your head.",
|
||||
'account_identifier' => 'Identifier',
|
||||
'account_export' => 'Export to the main blockchain network is available',
|
||||
/* 'account_data' => "⚠️ Your data may be given to the special services of Russia\nBe careful and think with your head",
|
||||
'account_security_repository' => 'Information security',
|
||||
'account_security_repository_mirror_github' => 'mirror',
|
||||
'account_security_repository_mirror_github' => 'mirror', */
|
||||
'account_authorized_system' => 'Access to the system',
|
||||
'account_authorized_messages' => 'Access to messages',
|
||||
'account_authorized_joins' => 'Access to joins',
|
||||
'account_authorized_autonom' => 'Be an autonom',
|
||||
'account_authorized_structor' => 'Be a structor',
|
||||
'account_authorized_volunteer' => 'Be a volunteer',
|
||||
'account_authorized_investor' => 'Be an investor',
|
||||
'account_authorized_recruiter' => 'Be a recruiter',
|
||||
'account_authorized_settings' => 'Access to settings',
|
||||
'account_authorized_system_accounts' => 'System access to accounts management',
|
||||
'account_authorized_system_distributions' => 'System access to distributions management',
|
||||
'account_authorized_system_members' => 'System access to members management',
|
||||
'account_authorized_system_settings' => 'System access to system settings',
|
||||
'account_authorized_system_accounts' => 'Access to the accounts system',
|
||||
'account_authorized_system_distributions' => 'Access to the distributions system',
|
||||
'account_authorized_system_settings' => 'Access to the system settings',
|
||||
'account_button_localizations' => 'Localizations',
|
||||
'account_localization_create_failted_to_initialize_language' => 'Failed to initialize language',
|
||||
|
@@ -4,73 +4,96 @@
|
||||
return [
|
||||
// Система
|
||||
'svoboda' => 'Свобода',
|
||||
'antivertical' => 'Антивертикаль',
|
||||
'empty' => 'Пусто',
|
||||
'yes' => 'Да',
|
||||
'no' => 'Нет',
|
||||
|
||||
// Главное меню
|
||||
'menu_title' => 'Главное меню',
|
||||
'menu_title' => 'Антивертикаль',
|
||||
'menu_accounts' => 'Аккаунты',
|
||||
'menu_members' => 'Участники',
|
||||
'menu_distributions' => 'Дистрибутивы',
|
||||
'menu_not_syncronized' => 'База данных не синхронизируется с блокчейн сетью',
|
||||
'menu_structors' => 'Структоры',
|
||||
'menu_autonoms' => 'Автономы',
|
||||
'menu_volunteers' => 'Волонтёры',
|
||||
'menu_investors' => 'Инвесторы',
|
||||
'menu_recruiters' => 'Вербовщики',
|
||||
/* 'menu_' => '', */
|
||||
'menu_not_syncronized' => 'База данных не синхронизирована с блокчейн сетью',
|
||||
'menu_warning_database' => 'База данных публикуется в репозиторий ежедневно',
|
||||
'menu_button_channel' => 'Канал',
|
||||
'menu_button_site' => 'Сайт',
|
||||
'menu_button_map' => 'Карта',
|
||||
'menu_button_blog' => 'Блог',
|
||||
'menu_button_projects' => 'Проекты',
|
||||
'menu_button_members' => 'Участники',
|
||||
'menu_button_chats' => 'Чаты',
|
||||
'menu_button_channels' => 'Каналы',
|
||||
'menu_button_memberships' => 'Участники',
|
||||
'menu_button_distributions' => 'Дистрибутивы',
|
||||
'menu_button_projects' => 'Проекты',
|
||||
'menu_button_events' => 'События',
|
||||
'menu_button_organisation' => 'Организация',
|
||||
|
||||
// Думающие штуки
|
||||
'thing_about_it_1' => 'Великие имена создаются на востоке',
|
||||
'thing_about_it_1_author' => 'Лермонтов М. Ю.',
|
||||
'thing_about_it_2' => '',
|
||||
'thing_about_it_3' => '',
|
||||
'thing_about_it_4' => '',
|
||||
'thing_about_it_5' => '',
|
||||
/* 'thing_about_it_' => '',
|
||||
'thing_about_it__author' => '', */
|
||||
|
||||
// Участники
|
||||
'members_title' => 'Реестр участников',
|
||||
'members_description' => 'Участник \- личность имеющая любую форму взаимоотношений со *Свободой*',
|
||||
'members_button_search' => 'Поиск',
|
||||
'memberships_title' => 'Реестр участников',
|
||||
'memberships_structor' => '*Структор* \- анархист, представляющий дистрибутив',
|
||||
'memberships_autonom' => '*Автоном* \- анархист, представляющий только себя лично',
|
||||
'memberships_button_search' => 'Поиск',
|
||||
|
||||
// Поиск участника
|
||||
'member_search_started' => 'Процесс поиска участника дистрибутива запущен',
|
||||
'member_search_not_started' => 'Процесс поиска участника дистрибутива не запущен',
|
||||
'member_search_ended' => 'Процесс поиска участника дистрибутива завершён',
|
||||
'member_search_not_localized' => 'Не удалось инициализировать локализацию аккаунта участника',
|
||||
'member_search_not_named' => 'Нет имени',
|
||||
'member_search_status' => 'Статус',
|
||||
'member_search_status_2' => 'Участие',
|
||||
'member_search_status_2_emoji' => '🧳',
|
||||
'member_search_status_1' => 'Планирование',
|
||||
'member_search_status_1_emoji' => '📅',
|
||||
'member_search_status_0' => 'Неизвестно',
|
||||
'member_search_status_0_emoji' => '👽',
|
||||
'member_search_continiued' => 'Процесс поиска участника дистрибутива найден и продолжен',
|
||||
'member_search_empty' => 'Не найдены участники дистрибутивов',
|
||||
'member_search_title' => 'Поиск участника дистрибутива',
|
||||
'member_search_distribution' => 'Дистрибутив',
|
||||
'member_search_page_next_exists' => 'В реестре есть ещё участники дистрибутивов',
|
||||
'member_search_page_next_not_exists' => 'В реестре больше нет участников дистрибутивов',
|
||||
'member_search_button_name' => 'Имя',
|
||||
'member_search_name_request_title' => 'Введи имя',
|
||||
'member_search_name_request_description' => 'Поиск будет проводиться по именам участников дистрибутивов с использованием функции Левенштейна',
|
||||
'member_search_name_request_not_acceptable' => 'Не удалось обработать имя',
|
||||
'member_search_name_request_too_short' => 'Длина имени должна быть \>\= 2 и \<\= 128',
|
||||
'member_search_name_request_too_long' => 'Длина имени должна быть \>\= 2 и \<\= 128',
|
||||
'member_search_name_request_restricted_characters_title' => "Запрещены любые символы кроме букв",
|
||||
'member_search_name_request_restricted_characters_description' => "Удали эти символы:",
|
||||
'member_search_name_update_success' => 'Имя заменено:',
|
||||
'member_search_name_update_fail' => 'Не удалось заменить имя',
|
||||
'member_search_button_start' => 'Начать поиск',
|
||||
'member_search_button_end' => 'Завершить поиск',
|
||||
'member_search_button_page_next' => 'Следующая страница',
|
||||
'member_search_button_message' => 'Сообщение',
|
||||
'member_search_button_distribution' => 'Дистрибутив',
|
||||
'member_search_button_status' => 'Статус',
|
||||
'member_search_button_status_2' => 'участие',
|
||||
'member_search_button_status_2_emoji' => '🧳',
|
||||
'member_search_button_status_1' => 'планирование',
|
||||
'member_search_button_status_1_emoji' => '📅',
|
||||
'member_search_button_status_0' => 'неизвестно',
|
||||
'member_search_button_status_0_emoji' => '👽',
|
||||
'membership_search_started' => 'Процесс поиска участника дистрибутива запущен',
|
||||
'membership_search_not_started' => 'Процесс поиска участника дистрибутива не запущен',
|
||||
'membership_search_ended' => 'Процесс поиска участника дистрибутива завершён',
|
||||
'membership_search_not_localized' => 'Не удалось инициализировать локализацию аккаунта участника',
|
||||
'membership_search_not_named' => 'Нет имени',
|
||||
'membership_search_status' => 'Статус',
|
||||
'membership_search_status_2' => 'Участие',
|
||||
'membership_search_status_2_emoji' => '🧳',
|
||||
'membership_search_status_1' => 'Планирование',
|
||||
'membership_search_status_1_emoji' => '📅',
|
||||
'membership_search_status_0' => 'Неизвестно',
|
||||
'membership_search_status_0_emoji' => '👽',
|
||||
'membership_search_continiued' => 'Процесс поиска участника дистрибутива найден и продолжен',
|
||||
'membership_search_empty' => 'Не найдены участники дистрибутивов',
|
||||
'membership_search_title' => 'Поиск участника дистрибутива',
|
||||
'membership_search_distribution' => 'Дистрибутив',
|
||||
'membership_search_page_next_exists' => 'В реестре есть ещё участники дистрибутивов',
|
||||
'membership_search_page_next_not_exists' => 'В реестре больше нет участников дистрибутивов',
|
||||
'membership_search_button_name' => 'Имя',
|
||||
'membership_search_name_request_title' => 'Введи имя',
|
||||
'membership_search_name_request_description' => 'Поиск будет проводиться по именам участников дистрибутивов с использованием функции Левенштейна',
|
||||
'membership_search_name_request_not_acceptable' => 'Не удалось обработать имя',
|
||||
'membership_search_name_request_too_short' => 'Длина имени должна быть \>\= 2 и \<\= 128',
|
||||
'membership_search_name_request_too_long' => 'Длина имени должна быть \>\= 2 и \<\= 128',
|
||||
'membership_search_name_request_restricted_characters_title' => "Запрещены любые символы кроме букв",
|
||||
'membership_search_name_request_restricted_characters_description' => "Удали эти символы:",
|
||||
'membership_search_name_update_success' => 'Имя заменено:',
|
||||
'membership_search_name_update_fail' => 'Не удалось заменить имя',
|
||||
'membership_search_button_start' => 'Начать поиск',
|
||||
'membership_search_button_end' => 'Завершить поиск',
|
||||
'membership_search_button_page_next' => 'Следующая страница',
|
||||
'membership_search_button_message' => 'Сообщение',
|
||||
'membership_search_button_distribution' => 'Дистрибутив',
|
||||
'membership_search_button_status' => 'Статус',
|
||||
'membership_search_button_status_2' => 'участие',
|
||||
'membership_search_button_status_2_emoji' => '🧳',
|
||||
'membership_search_button_status_1' => 'планирование',
|
||||
'membership_search_button_status_1_emoji' => '📅',
|
||||
'membership_search_button_status_0' => 'неизвестно',
|
||||
'membership_search_button_status_0_emoji' => '👽',
|
||||
|
||||
// Дистрибутивы
|
||||
'distributions_title' => 'Реестр дистрибутивов',
|
||||
'distributions_description' => '*Дистрибутив* \- это автономная ячейка Свободы, являющаяся любым видом формирования \(например: коммуна\), но обязательно наследующая *Vhod* протокол, участвующая в глобальных процессах организации и привязанная к местоположению',
|
||||
'distributions_description' => '*Дистрибутив* \- автономная ячейка Свободы, являющаяся любым видом формирования, подразумевающее безоговорочный солидарный союз со всеми признанными дистрибутивами внутри организации',
|
||||
'distributions_declared' => 'Объявленные',
|
||||
'distributions_recognized' => 'Признанные',
|
||||
'distributions_button_search' => 'Поиск',
|
||||
@@ -139,7 +162,7 @@ return [
|
||||
'distribution_search_continiued' => 'Процесс поиска дистрибутива найден и продолжен',
|
||||
'distribution_search_empty' => 'Не найдены дистрибутивы',
|
||||
'distribution_search_title' => 'Поиск дистрибутива',
|
||||
'distribution_search_members' => 'Участники',
|
||||
'distribution_search_memberships' => 'Участники',
|
||||
'distribution_search_recognized' => 'Признанные',
|
||||
'distribution_search_planners' => 'Планирующие',
|
||||
'distribution_search_volunteers' => 'Волонтёры',
|
||||
@@ -182,7 +205,7 @@ return [
|
||||
'distribution_search_button_end' => 'Завершить поиск',
|
||||
'distribution_search_button_page_next' => 'Следующая страница',
|
||||
'distribution_search_button_map' => 'Карта',
|
||||
'distribution_search_button_members' => 'Участники',
|
||||
'distribution_search_button_memberships' => 'Участники',
|
||||
'distribution_search_button_volunteers' => 'Волонтёры',
|
||||
'distribution_search_button_plan' => 'Запланировать',
|
||||
'distribution_search_button_unplan' => 'Отменить планирование',
|
||||
@@ -193,15 +216,15 @@ return [
|
||||
'distribution_search_button_join' => 'Присоединиться',
|
||||
'distribution_search_button_leave' => 'Покинуть',
|
||||
'distribution_search_joined_title' => 'Ты вступил в дистрибутив',
|
||||
'distribution_search_joined_description' => 'Ты заявил о том, что являешься участником дистрибутива, теперь тебе надо получить признание от его участников',
|
||||
'distribution_search_already_joined' => 'Ты уже вступил дистрибутив',
|
||||
'distribution_search_joined_description' => 'Ты заявил о том, что являешься структором дистрибутива',
|
||||
'distribution_search_already_joined' => 'Ты уже заявил себя структором дистрибутива',
|
||||
'distribution_search_leaved' => 'Ты покинул дистрибутив',
|
||||
'distribution_search_already_leaved' => 'Ты уже покинул дистрибутив',
|
||||
'distribution_search_button_message' => 'Сообщение',
|
||||
'distribution_search_km' => 'км',
|
||||
'distribution_search_mi' => 'мл',
|
||||
'distribution_search_member_not_updated' => 'Не удалось обновить запись участника дистрибутива в базе данных',
|
||||
'distribution_search_member_not_created' => 'Не удалось создать запись участника дистрибутива в базе данных',
|
||||
'distribution_search_membership_not_updated' => 'Не удалось обновить запись участника дистрибутива в базе данных',
|
||||
'distribution_search_membership_not_created' => 'Не удалось создать запись участника дистрибутива в базе данных',
|
||||
'distribution_search_distribution_not_initialized' => 'Не удалось инициализировать дистрибутив',
|
||||
'distribution_search_message_not_initialized' => 'Не удалось инициализировать сообщение',
|
||||
'distribution_search_another_joined' => 'Ты уже являешься участником другого дистрибутива',
|
||||
@@ -253,20 +276,39 @@ return [
|
||||
'distribution_select_button_cancel' => 'Отменить выбор',
|
||||
'distribution_select_button_page_next' => 'Следующая страница',
|
||||
|
||||
// Организация
|
||||
'organisation_title' => 'Организация',
|
||||
'organisation_description' => 'Интернациональное объединение всех кто хочет жить честно и свободно, где никто ни от кого ничего не требует и ни к чему не принуждает',
|
||||
'organisation_structor' => '*Структор* \- анархист, представляющий дистрибутив',
|
||||
'organisation_autonom' => '*Автоном* \- анархист, представляющий только себя лично',
|
||||
'organisation_warning_legal' => 'Не делайте ничего, что нарушает закон страны в которой вы находитесь, не доверяйте никому и думайте своей головой',
|
||||
'organisation_warning_administration' => 'На данном этапе развития проекта Антивертикаль администрация сохраняет за собой право единолично принимать решение по удалению потенциально опасных для организации и её участников материалов',
|
||||
'organisation_button_help' => 'Помощь',
|
||||
'organisation_button_investor' => 'Инвестор',
|
||||
'organisation_button_volunteer' => 'Волонтёр',
|
||||
'organisation_button_structor' => 'Структор',
|
||||
'organisation_button_structor_distribution' => 'Дистрибутив',
|
||||
'organisation_button_autonom' => 'Автоном',
|
||||
|
||||
// Аккаунт
|
||||
'account_title' => 'Аккаунт',
|
||||
'account_export' => 'Этот аккаунт может быть экспортирован в основную блокчейн сеть Свободы в будущем',
|
||||
'account_data' => "⚠️ Твои данные могут быть выданы спецслужбам России\nБудь осторожен и думай своей головой",
|
||||
'account_identifier' => 'Идентификатор',
|
||||
'account_export' => 'Доступен экспорт в основную блокчейн сеть',
|
||||
/* 'account_data' => "⚠️ Твои данные могут быть выданы спецслужбам России\nБудь осторожен и думай своей головой",
|
||||
'account_security_repository' => 'Информационная безопасность',
|
||||
'account_security_repository_mirror_github' => 'зеркало',
|
||||
'account_security_repository_mirror_github' => 'зеркало', */
|
||||
'account_authorized_system' => 'Доступ к системе',
|
||||
'account_authorized_messages' => 'Доступ к сообщениям',
|
||||
'account_authorized_joins' => 'Доступ к вступлениям',
|
||||
'account_authorized_settings' => 'Доступ к изменению настроек',
|
||||
'account_authorized_system_accounts' => 'Системный доступ к управлению аккаунтами',
|
||||
'account_authorized_system_distributions' => 'Системный доступ к управлению дистрибутивами',
|
||||
'account_authorized_system_members' => 'Системный доступ к управлению участниками дистрибутивов',
|
||||
'account_authorized_system_settings' => 'Системный доступ к системным настройкам',
|
||||
'account_authorized_authonom' => 'Становиться автономом',
|
||||
'account_authorized_structor' => 'Становиться структором',
|
||||
'account_authorized_volunteer' => 'Становиться волонтёром',
|
||||
'account_authorized_investor' => 'Становиться инвестором',
|
||||
'account_authorized_recruiter' => 'Становиться вербовщиком',
|
||||
'account_authorized_relations' => 'Доступ к отношениям',
|
||||
'account_authorized_settings' => 'Доступ к настройкам',
|
||||
'account_authorized_system_accounts' => 'Доступ к системе аккаунтов',
|
||||
'account_authorized_system_distributions' => 'Доступ к системе дистрибутивов',
|
||||
'account_authorized_system_settings' => 'Доступ к системным настройкам',
|
||||
'account_button_localizations' => 'Локализации',
|
||||
'account_localization_create_failted_to_initialize_language' => 'Не удалось инициализировать язык',
|
||||
|
484
svoboda/antivertical/system/models/account.php
Executable file
484
svoboda/antivertical/system/models/account.php
Executable file
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\connection,
|
||||
svoboda\antivertical\models\telegram,
|
||||
svoboda\antivertical\models\membership,
|
||||
svoboda\antivertical\models\interfaces\ar as active_record,
|
||||
svoboda\antivertical\models\traits\ar as active_record_trait,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\enumerations\membership\status,
|
||||
svoboda\antivertical\models\account\localization;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime,
|
||||
LogicException as exception_logic,
|
||||
InvalidArgumentException as exception_invalid_argument;
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* @uses active_record
|
||||
* @uses active_record_trait
|
||||
*
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @property string $file Path to the database file
|
||||
* @property database $database The database
|
||||
* @property record $record The database record
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class account extends core implements active_record
|
||||
{
|
||||
use active_record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'accounts.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $database The database
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var localization $localization The localizations implementator
|
||||
*/
|
||||
public protected(set) localization $localization;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param record|null $record The database record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::utf8)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('name', type::string, ['length' => 64]),
|
||||
new column('language', type::string, ['length' => 2]),
|
||||
new column('authorized_system', type::char),
|
||||
new column('authorized_messages', type::char),
|
||||
new column('authorized_authonom', type::char),
|
||||
new column('authorized_structor', type::char),
|
||||
new column('authorized_volunteer', type::char),
|
||||
new column('authorized_investor', type::char),
|
||||
new column('authorized_recruiter', type::char),
|
||||
new column('authorized_settings', type::char),
|
||||
new column('authorized_system_accounts', type::char),
|
||||
new column('authorized_system_distributions', type::char),
|
||||
new column('authorized_system_settings', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($this->file);
|
||||
|
||||
// Initializing the localizations implementator
|
||||
$this->localization = new localization;
|
||||
|
||||
// Initializing the database record
|
||||
if ($record) $this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*
|
||||
* Searches for the account record by the telegram account in the database,
|
||||
* and if it does not find it, then create the account record and the connection record
|
||||
*
|
||||
* @param telegram $telegram The telegram account
|
||||
*
|
||||
* @throws exception_runtime if failed to deactivate the connection between missing account and the telegram account
|
||||
* @throws exception_runtime if failed to connect the account with the telegram account
|
||||
* @throws exception_runtime if failed to find the created account
|
||||
* @throws exception_runtime if failed to create the account
|
||||
*
|
||||
* @return static The account record implementator
|
||||
*/
|
||||
public function initialize(telegram $telegram): static
|
||||
{
|
||||
// Initializing the connection model
|
||||
$connection = new connection;
|
||||
|
||||
// Searching for the connection record between theaccount and the telegram account in the database
|
||||
$connected = $connection->read(filter: fn(record $record) => $record->telegram === $telegram->identifier);
|
||||
|
||||
if ($connected instanceof connection) {
|
||||
// Found the connection record between the account and the telegram account
|
||||
|
||||
// Searching for the account in the database
|
||||
$account = $this->read(filter: fn(record $record) => $record->identifier === $connected->account);
|
||||
|
||||
if ($account instanceof static) {
|
||||
// Found the account
|
||||
|
||||
// Exit (success)
|
||||
return $account;
|
||||
} else {
|
||||
// Not found the account
|
||||
|
||||
// Deactivating the connection between missing account and the telegram account
|
||||
$deactivated = $connected->update(
|
||||
filter: fn(record $record) => $record->identifier === $connected->identifier,
|
||||
update: function (record &$record) {
|
||||
$record->active = 0;
|
||||
$record->updated = svoboda::timestamp();
|
||||
}
|
||||
);
|
||||
|
||||
if ($deactivated instanceof connection && $deactivated->active === 0) {
|
||||
// Deactivated the connection between missing account and the telegram account
|
||||
|
||||
// Creating the account
|
||||
goto create;
|
||||
} else {
|
||||
// Failed to deactivate the connection between missing account and the telegram account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to deactivate the connection between missing account and the telegram account');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not found the connection record between the account and the telegram account
|
||||
|
||||
// Creating the account process start
|
||||
create:
|
||||
|
||||
// Creating the account
|
||||
$identifier = $this->create("$telegram->name_first $telegram->name_second", language::{$telegram->language ?? language::en->name} ?? language::en);
|
||||
|
||||
if ($identifier) {
|
||||
// Created the account
|
||||
|
||||
// Searching for the created account in the database
|
||||
$account = $this->read(filter: fn(record $record) => $record->identifier === $identifier);
|
||||
|
||||
if ($account instanceof static) {
|
||||
// Found the created account
|
||||
|
||||
// Connecting the created account with the telegram account
|
||||
$connected = $connection->create(account: $account->identifier, telegram: $telegram->identifier);
|
||||
|
||||
if ($connected) {
|
||||
// Connected the created account with the telegram account
|
||||
|
||||
// Exit (success)
|
||||
return $account;
|
||||
} else {
|
||||
// Not connected the created account with the telegram account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to connect the account with the telegram account');
|
||||
}
|
||||
} else {
|
||||
// Not found the created account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to find the created account');
|
||||
}
|
||||
} else {
|
||||
// Not created the account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to create the account');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Creates the account record in the database
|
||||
*
|
||||
* @param string $name Name
|
||||
* @param language $language Language for generating views
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function create(string $name, language $language): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$identifier,
|
||||
$name,
|
||||
$language->name,
|
||||
ACCOUNT_ACCESS_SYSTEM,
|
||||
ACCOUNT_ACCESS_MESSAGES,
|
||||
ACCOUNT_ACCESS_AUTHONOM,
|
||||
ACCOUNT_ACCESS_STRUCTOR,
|
||||
ACCOUNT_ACCESS_VOLUNTEER,
|
||||
ACCOUNT_ACCESS_INVESTOR,
|
||||
ACCOUNT_ACCESS_RECRUITER,
|
||||
ACCOUNT_ACCESS_SETTINGS,
|
||||
ACCOUNT_ACCESS_SYSTEM_ACCOUNTS,
|
||||
ACCOUNT_ACCESS_SYSTEM_DISTRIBUTIONS,
|
||||
ACCOUNT_ACCESS_SYSTEM_SETTINGS,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Creating the record in the database
|
||||
$created = $this->database->write($record);
|
||||
|
||||
// Exit (success)
|
||||
return $created ? $identifier : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Distribution
|
||||
*
|
||||
* Search for the account distribution
|
||||
*
|
||||
* @return distribution|false The account distribution, if found
|
||||
*/
|
||||
public function distribution(): distribution|false
|
||||
{
|
||||
// Searching for the distribution membership
|
||||
$membership = $this->memberships(amount: 1, offset: 0)[0] ?? false;
|
||||
|
||||
if ($membership instanceof membership) {
|
||||
// Initialized the distribution membership
|
||||
|
||||
// Initializing the distribution model
|
||||
$model = new distribution();
|
||||
|
||||
// Searching for the distribution
|
||||
$distribution = $model->read(filter: fn(record $record) => $record->identifier === $membership->distribution);
|
||||
|
||||
// Exit (success/fail)
|
||||
return $distribution;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Memberships
|
||||
*
|
||||
* @param status $status A membership status
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array The account memberships
|
||||
*/
|
||||
public function memberships(
|
||||
status $status = status::joined,
|
||||
int $amount = 100,
|
||||
int $offset = 0
|
||||
): array {
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->account === $this->identifier && $record->status === $status->value,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Declaring the buffer of implemented records
|
||||
$implemented = [];
|
||||
|
||||
foreach ($memberships as $record) {
|
||||
// Iterating over memberships records
|
||||
|
||||
// Initializing the implementator object
|
||||
$implementator = new membership();
|
||||
|
||||
if ($implementator instanceof active_record) {
|
||||
// The implementator object implements the Active Record pattern
|
||||
|
||||
// Writing the record into the implementator object
|
||||
$implementator->record = $record;
|
||||
} else {
|
||||
// The implementator object not implements the Active Record pattern
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_logic('The implementator object not implements the Active Record pattern');
|
||||
}
|
||||
|
||||
// Writing into the buffer of implemented record;
|
||||
$implemented[] = $implementator;
|
||||
}
|
||||
|
||||
// Exit (success)
|
||||
return $implemented;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structors
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array Structors
|
||||
*/
|
||||
public static function structors(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->status === status::joined->value,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Exit (success)
|
||||
return $memberships;
|
||||
}
|
||||
|
||||
/**
|
||||
* Planned
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array Planned
|
||||
*/
|
||||
public static function planned(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->status === status::planned,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Exit (success)
|
||||
return $memberships;
|
||||
}
|
||||
|
||||
/**
|
||||
* Autonoms
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array Autonoms
|
||||
*/
|
||||
public static function autonoms(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->status === status::joined,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Exit (success)
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Volunteers
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array Volunteers
|
||||
*/
|
||||
public static function volunteers(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->status === status::joined,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Exit (success)
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Investors
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array Investors
|
||||
*/
|
||||
public static function investors(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->status === status::joined,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Exit (success)
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Recruiters
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offset
|
||||
*
|
||||
* @return array Recruiters
|
||||
*/
|
||||
public static function recruiters(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model = new membership;
|
||||
|
||||
// Initializing the account memberships
|
||||
$memberships = $model->database->read(
|
||||
filter: fn(record $record) => $record->status === status::joined,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Exit (success)
|
||||
return [];
|
||||
}
|
||||
}
|
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\account;
|
||||
namespace svoboda\antivertical\models\account;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
@@ -28,7 +28,7 @@ use Exception as exception,
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @package svoboda\svoboder\models\account
|
||||
* @package svoboda\antivertical\models\account
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
128
svoboda/antivertical/system/models/connection.php
Executable file
128
svoboda/antivertical/system/models/connection.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\entity,
|
||||
svoboda\antivertical\models\enumerations\membership\status,
|
||||
svoboda\antivertical\models\interfaces\ar as active_record,
|
||||
svoboda\antivertical\models\traits\ar as active_record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Connection between account::class and telegram::class
|
||||
*
|
||||
* @uses active_record
|
||||
* @uses active_record_trait
|
||||
*
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @property string $file Path to the database file
|
||||
* @property database $database The database
|
||||
* @property record $record The database record
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class connection extends core implements active_record
|
||||
{
|
||||
use active_record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'connection.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* Identifier: The record identifier
|
||||
* Account: The account identifier
|
||||
* Telegram: The telegram account identifier
|
||||
* Updated: Timestamp of the last the record update
|
||||
* Created: Timestamp of the record creating
|
||||
*
|
||||
* @var database $database The database
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param record|null $record The database record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::ascii)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('account', type::long_long_unsigned),
|
||||
new column('telegram', type::long_long_unsigned),
|
||||
new column('active', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($this->file);
|
||||
|
||||
// Initializing the database record
|
||||
if ($record) $this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Creates the member record in the database
|
||||
*
|
||||
* @param int $account Identifier of the account
|
||||
* @param int $telegram Identifier of the telegram account
|
||||
* @param bool $active Is the connection active?
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function create(int $account, int $telegram, bool $active = true): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$identifier,
|
||||
$account,
|
||||
$telegram,
|
||||
(int) $active,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Creating the record in the database
|
||||
$created = $this->database->write($record);
|
||||
|
||||
// Exit (success)
|
||||
return $created ? $identifier : false;
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models;
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\model;
|
||||
@@ -18,7 +18,7 @@ use exception;
|
||||
/**
|
||||
* Core
|
||||
*
|
||||
* @package svoboda\svoboder\models
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @method void __construct() Constructor
|
||||
*
|
331
svoboda/antivertical/system/models/distribution.php
Executable file
331
svoboda/antivertical/system/models/distribution.php
Executable file
@@ -0,0 +1,331 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\distribution\localization,
|
||||
svoboda\antivertical\models\distribution\message,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\interfaces\ar as active_record,
|
||||
svoboda\antivertical\models\traits\ar as active_record_trait,
|
||||
svoboda\antivertical\models\enumerations\membership\status;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Distribution
|
||||
*
|
||||
* @uses active_record
|
||||
* @uses active_record_trait
|
||||
*
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @property string $file Path to the database file
|
||||
* @property database $database The database
|
||||
* @property record $record The database record
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class distribution extends core implements active_record
|
||||
{
|
||||
use active_record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'distributions.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $database The database
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var localization $localization The localizations implementator
|
||||
*/
|
||||
public protected(set) localization $localization;
|
||||
|
||||
/**
|
||||
* Message
|
||||
*
|
||||
* @var localization $localization The messages implementator
|
||||
*/
|
||||
public protected(set) message $message;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param record|null $record The database record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::ascii)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('creator', type::long_long_unsigned),
|
||||
new column('latitude', type::float),
|
||||
new column('longitude', type::float),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($this->file);
|
||||
|
||||
// Initializing the localizations implementator
|
||||
$this->localization = new localization;
|
||||
|
||||
// Initializing the messages implementator
|
||||
$this->message = new message;
|
||||
|
||||
// Initializing the database record
|
||||
if ($record) $this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Creates the distribution record in the database
|
||||
*
|
||||
* @param int $creator Identifier of the creator account (svoboda\antivertical\models\account)
|
||||
* @param float $latitude Latitude
|
||||
* @param float $longitude Longitude
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function create(int $creator, float $latitude = 0, float $longitude = 0): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$identifier,
|
||||
$creator,
|
||||
$latitude,
|
||||
$longitude,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Creating the record in the database
|
||||
$created = $this->database->write($record);
|
||||
|
||||
// Exit (success)
|
||||
return $created ? $identifier : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* Initialize the distribution localization
|
||||
* Priority: $language argument > english > the distribution creator language > first in the localizations registry
|
||||
*
|
||||
* @param language $language Language
|
||||
*
|
||||
* @return localization|false The distribtion localization, if initialized
|
||||
*/
|
||||
public function localization(language $language): localization|false
|
||||
{
|
||||
// Initializing localizations
|
||||
$localizations = $this->localization->database->read(
|
||||
filter: fn(record $localization) => $localization->distribution === $this->identifier,
|
||||
amount: DISTRIBUTIONS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
);
|
||||
|
||||
|
||||
if (count($localizations) > 0) {
|
||||
// Initialized the distributions localizations
|
||||
|
||||
foreach ($localizations as $record) {
|
||||
// Iterating over localizations
|
||||
|
||||
if ($record->language === $language->name) {
|
||||
// Found localization by the account language
|
||||
|
||||
// Initializing localization by the account language
|
||||
$this->localization->record = $record;
|
||||
|
||||
// Exit (success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->localization->record)) {
|
||||
// Not initialized localization by the account language
|
||||
|
||||
foreach ($localizations as $record) {
|
||||
// Iterating over localizations
|
||||
|
||||
if ($record->language === 'en') {
|
||||
// Found localization by english language
|
||||
|
||||
// Initializing localization by english language
|
||||
$this->localization->record = $record;
|
||||
|
||||
// Exit (success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->localization->record)) {
|
||||
// Not initialized localization by english language
|
||||
|
||||
// Initializing the account model
|
||||
$model_account = new account;
|
||||
|
||||
// Initializing the distribution creator account
|
||||
$creator = $model_account->read(filter: fn(record $account) => $account->identifier === $this->creator);
|
||||
|
||||
if ($creator instanceof account) {
|
||||
// Initialized the distribution creator account
|
||||
|
||||
foreach ($localizations as $record) {
|
||||
// Iterating over localizations
|
||||
|
||||
if ($record->language === $creator->language) {
|
||||
// Found localization by the distribution creator account language
|
||||
|
||||
// Initializing localization by the distribution creator account language
|
||||
$values = $record;
|
||||
|
||||
// Exit (success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->localization->record)) {
|
||||
// Not initialized localization by the distribution creator account language
|
||||
|
||||
// Initializing localization by the first found record
|
||||
$this->localization->record = $localizations[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exit (success/fail)
|
||||
return $this->localization;
|
||||
}
|
||||
|
||||
/**
|
||||
* Structors
|
||||
*
|
||||
* Search for the distribution structors
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offest
|
||||
*
|
||||
* @return array The distribution structors
|
||||
*/
|
||||
public function structors(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership();
|
||||
|
||||
// Searching for memberships
|
||||
$memberships = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->distribution === $this->identifier && $record->status === status::joined->value,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Initializing the account model
|
||||
$model_account = new account();
|
||||
|
||||
// Declaring the buffer of found structors
|
||||
$structors = [];
|
||||
|
||||
foreach ($memberships as $membership) {
|
||||
// Iterating over memberships
|
||||
|
||||
// Searching for the structor account
|
||||
$structor = $model_account->read(filter: fn(record $record) => $record->identifier === $membership->account);
|
||||
|
||||
if ($structor instanceof account) {
|
||||
// Initialized the structor account
|
||||
|
||||
// Writing into the buffer of found structors
|
||||
$structors[] = $structor;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return $structors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Planners
|
||||
*
|
||||
* Search for the distribution planners
|
||||
*
|
||||
* @param int $amount Amount
|
||||
* @param int $offset Offest
|
||||
*
|
||||
* @return array The distribution planners
|
||||
*/
|
||||
public function planners(int $amount = 100, int $offset = 0): array
|
||||
{
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership();
|
||||
|
||||
// Searching for memberships
|
||||
$memberships = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->distribution === $this->identifier && $record->status === status::planned->value,
|
||||
amount: $amount,
|
||||
offset: $offset
|
||||
);
|
||||
|
||||
// Initializing the account model
|
||||
$model_account = new account();
|
||||
|
||||
// Declaring the buffer of found planners
|
||||
$planners = [];
|
||||
|
||||
foreach ($memberships as $membership) {
|
||||
// Iterating over memberships
|
||||
|
||||
// Searching for the planner account
|
||||
$planner = $model_account->read(filter: fn(record $record) => $record->identifier === $membership->account);
|
||||
|
||||
if ($planner instanceof account) {
|
||||
// Initialized the planner account
|
||||
|
||||
// Writing into the buffer of found planners
|
||||
$planners[] = $planner;
|
||||
}
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return $planners;
|
||||
}
|
||||
|
||||
}
|
@@ -2,11 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\distribution;
|
||||
namespace svoboda\antivertical\models\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\interfaces\ar as active_record,
|
||||
svoboda\antivertical\models\traits\ar as active_record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
@@ -28,13 +30,22 @@ use Exception as exception,
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @package svoboda\svoboder\models\distributions
|
||||
* @uses active_record
|
||||
* @uses active_record_trait
|
||||
*
|
||||
* @package svoboda\antivertical\models\distribution
|
||||
*
|
||||
* @property string $file Path to the database file
|
||||
* @property database $database The database
|
||||
* @property record $record The database record
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class localization extends core
|
||||
final class localization extends core implements active_record
|
||||
{
|
||||
use active_record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\distribution;
|
||||
namespace svoboda\antivertical\models\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\entity;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\entity;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
@@ -28,7 +28,7 @@ use Exception as exception,
|
||||
/**
|
||||
* Message
|
||||
*
|
||||
* @package svoboda\svoboder\models\distributions
|
||||
* @package svoboda\antivertical\models\distributions
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\enumerations;
|
||||
namespace svoboda\antivertical\models\enumerations;
|
||||
|
||||
/**
|
||||
* Entity
|
||||
*
|
||||
* Types of entities
|
||||
*
|
||||
* @package svoboda\svoboder\models\enumerations
|
||||
* @package svoboda\antivertical\models\enumerations
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\enumerations;
|
||||
namespace svoboda\antivertical\models\enumerations;
|
||||
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* Types of languages by ISO 639-1 standart
|
||||
*
|
||||
* @package svoboda\svoboder\models\enumerations
|
||||
* @package svoboda\antivertical\models\enumerations
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\enumerations\member;
|
||||
namespace svoboda\antivertical\models\enumerations\membership;
|
||||
|
||||
/**
|
||||
* Status
|
||||
*
|
||||
* Member status
|
||||
* Membership status
|
||||
*
|
||||
* @package svoboda\svoboder\models\enumerations\member
|
||||
* @package svoboda\antivertical\models\enumerations\membership
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
22
svoboda/antivertical/system/models/enumerations/relation/type.php
Executable file
22
svoboda/antivertical/system/models/enumerations/relation/type.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models\enumerations\relation;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*
|
||||
* Relation type
|
||||
*
|
||||
* @package svoboda\antivertical\models\enumerations\relation
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
enum status: int
|
||||
{
|
||||
case unknown = 0;
|
||||
case recognition = 1;
|
||||
case unrecognition = 2;
|
||||
}
|
69
svoboda/antivertical/system/models/interfaces/ar.php
Normal file
69
svoboda/antivertical/system/models/interfaces/ar.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models\interfaces;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\core;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime,
|
||||
LogicException as exception_logic,
|
||||
InvalidArgumentException as exception_invalid_argument;
|
||||
|
||||
/**
|
||||
* AR
|
||||
*
|
||||
* The "Active Record" architectural pattern
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/Active_record_pattern Active Record
|
||||
*
|
||||
* @package svoboda\antivertical\models\interfaces
|
||||
*
|
||||
* @method static|false read(callable $filter) Read from the database
|
||||
* @method static|false update() Update the record in the database
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
interface ar
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @throws exception_invalid_argument If not initialized the database columns parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct();
|
||||
|
||||
/**
|
||||
* Read
|
||||
*
|
||||
* Search for the record in the database
|
||||
*
|
||||
* @return static|false The record impementator object, if found
|
||||
*/
|
||||
public function read(callable $filter): static|false;
|
||||
|
||||
/**
|
||||
* Update
|
||||
*
|
||||
* Write the record new values into the database
|
||||
*
|
||||
* @return static|false The updated record, if updated (new instance)
|
||||
*/
|
||||
public function update(): static|false;
|
||||
}
|
129
svoboda/antivertical/system/models/membership.php
Executable file
129
svoboda/antivertical/system/models/membership.php
Executable file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\interfaces\ar as active_record,
|
||||
svoboda\antivertical\models\traits\ar as active_record_trait,
|
||||
svoboda\antivertical\models\enumerations\entity,
|
||||
svoboda\antivertical\models\enumerations\membership\status;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Membership
|
||||
*
|
||||
* @uses active_record
|
||||
* @uses active_record_trait
|
||||
*
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @property string $file Path to the database file
|
||||
* @property database $database The database
|
||||
* @property record $record The database record
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class membership extends core implements active_record
|
||||
{
|
||||
use active_record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'memberships.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* Identifier: The record identifier
|
||||
* Distribution: The distribution
|
||||
* Account: The account
|
||||
* Status: @see status::class
|
||||
* Updated: Timestamp of the last the record update
|
||||
* Created: Timestamp of the record creating
|
||||
*
|
||||
* @var database $database The database
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param record|null $record The database record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::ascii)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('distribution', type::long_long_unsigned),
|
||||
new column('account', type::long_long_unsigned),
|
||||
new column('status', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($this->file);
|
||||
|
||||
// Initializing the database record
|
||||
if ($record) $this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Creates the membership record in the database
|
||||
*
|
||||
* @param int $distribution Identifier of the distribution
|
||||
* @param int $account Identifier of the account
|
||||
* @param status $status The distribution membership status
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function create(int $distribution, int $account, status $status = status::unknown): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$identifier,
|
||||
$distribution,
|
||||
$account,
|
||||
$status->value,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Creating the record in the database
|
||||
$created = $this->database->write($record);
|
||||
|
||||
// Exit (success)
|
||||
return $created ? $identifier : false;
|
||||
}
|
||||
}
|
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models;
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\entity,
|
||||
svoboda\svoboder\models\enumerations\member\status;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\entity,
|
||||
svoboda\antivertical\models\enumerations\member\status;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
@@ -27,29 +27,29 @@ use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Member
|
||||
* Relation
|
||||
*
|
||||
* @package svoboda\svoboder\models
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class member extends core
|
||||
final class relation extends core
|
||||
{
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'members.baza';
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'relations.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* Identifier: The record identifier
|
||||
* Distribution: The distribution
|
||||
* Account: The account
|
||||
* Status: 1 - planned; 2 - joined
|
||||
* From: The account identifier
|
||||
* To: The account identifier
|
||||
* Type: Type
|
||||
* Updated: Timestamp of the last the record update
|
||||
* Created: Timestamp of the record creating
|
||||
*
|
||||
@@ -68,10 +68,10 @@ final class member extends core
|
||||
$this->database = new database()
|
||||
->encoding(encoding::ascii)
|
||||
->columns(
|
||||
new column('identifier', type::integer_unsigned),
|
||||
new column('distribution', type::integer_unsigned),
|
||||
new column('account', type::integer_unsigned),
|
||||
new column('status', type::char),
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('from', type::long_long_unsigned),
|
||||
new column('to', type::long_long_unsigned),
|
||||
new column('type', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
@@ -83,14 +83,14 @@ final class member extends core
|
||||
*
|
||||
* Creates the member record in the database
|
||||
*
|
||||
* @param int $distribution Identifier of the distribution
|
||||
* @param int $account Identifier of the account
|
||||
* @param status $status The distribution memberhip status
|
||||
* @param int $from Identifier of the account (svoboda\antivertical\models\account)
|
||||
* @param int $to Identifier of the account (svoboda\antivertical\models\account)
|
||||
* @param type $type Type of the relation
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function create(int $distribution, int $account, status $status = status::unknown): int|false
|
||||
{var_dump($this->database->count());
|
||||
public function create(int $from, int $to, type $type): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
|
@@ -2,11 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models;
|
||||
namespace svoboda\antivertical\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account\localization;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account\localization,
|
||||
svoboda\antivertical\models\interfaces\ar as active_record,
|
||||
svoboda\antivertical\models\traits\ar as active_record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
@@ -19,28 +21,37 @@ use mirzaev\baza\database,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram;
|
||||
use Zanzara\Telegram\Type\User as model;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Account
|
||||
* Telegram account
|
||||
*
|
||||
* @package svoboda\svoboder\models
|
||||
* @uses active_record
|
||||
* @uses active_record_trait
|
||||
*
|
||||
* @package svoboda\antivertical\models
|
||||
*
|
||||
* @property string $file Path to the database file
|
||||
* @property database $database The database
|
||||
* @property record $record The database record
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class account extends core
|
||||
final class telegram extends core implements active_record
|
||||
{
|
||||
use active_record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'accounts.baza';
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'telegram.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
@@ -59,30 +70,22 @@ final class account extends core
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param record|null $record The database record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(?record $record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::utf8)
|
||||
->columns(
|
||||
new column('identifier', type::integer_unsigned),
|
||||
new column('identifier_telegram', type::integer),
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('domain', type::string, ['length' => 32]),
|
||||
new column('name_first', type::string, ['length' => 64]),
|
||||
new column('name_second', type::string, ['length' => 64]),
|
||||
new column('language', type::string, ['length' => 2]),
|
||||
new column('robot', type::char),
|
||||
new column('authorized_system', type::char),
|
||||
new column('authorized_messages', type::char),
|
||||
new column('authorized_joins', type::char),
|
||||
new column('authorized_settings', type::char),
|
||||
new column('authorized_system_accounts', type::char),
|
||||
new column('authorized_system_distributions', type::char),
|
||||
new column('authorized_system_members', type::char),
|
||||
/* new column('authorized_system_', type::char), */
|
||||
new column('authorized_system_settings', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
@@ -90,50 +93,52 @@ final class account extends core
|
||||
|
||||
// Initializing the localizations implementator
|
||||
$this->localization = new localization;
|
||||
|
||||
// Initializing the database record
|
||||
if ($record) $this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*
|
||||
* Searches for the account record in the database, and if it does not find it, it creates it
|
||||
* Searches for the telegram account record in the database, and if it does not find it, then create
|
||||
*
|
||||
* @param telegram $telegram The telegram account
|
||||
* @param model $telegram The telegram account
|
||||
*
|
||||
* @throws exception_runtime if update the account record in the database by the telegram account values
|
||||
* @throws exception_runtime if failed to find the registered account
|
||||
* @throws exception_runtime if failed to registrate the account
|
||||
* @throws exception_runtime if update the telegram account record in the database by the telegram account values
|
||||
* @throws exception_runtime if failed to find the created telegram account
|
||||
* @throws exception_runtime if failed to create the telegram account
|
||||
*
|
||||
* @return record The account record from the database
|
||||
* @return static The telegram account record implementator
|
||||
*/
|
||||
public function initialize(telegram $telegram): record
|
||||
public function initialize(model $telegram): static
|
||||
{
|
||||
// Searching for the account in the database
|
||||
$account = $this->database->read(filter: fn(record $record) => $record->identifier_telegram === $telegram->getId(), amount: 1)[0] ?? null;
|
||||
$instance = $this->read(filter: fn(record $record) => $record->identifier === $telegram->getId());
|
||||
|
||||
if ($account instanceof record) {
|
||||
// Found the account record
|
||||
if ($instance instanceof static) {
|
||||
// Found the telegram account record
|
||||
|
||||
if (
|
||||
$account->name_first !== $telegram->getFirstName() ||
|
||||
$account->name_second !== $telegram->getLastName() ||
|
||||
$account->domain !== $telegram->getUsername()
|
||||
$instance->name_first !== $telegram->getFirstName() ||
|
||||
$instance->name_second !== $telegram->getLastName() ||
|
||||
$instance->domain !== $telegram->getUsername()
|
||||
) {
|
||||
// The telegram account was updated
|
||||
|
||||
// Updating the account in the database
|
||||
$updated = $this->database->read(
|
||||
filter: fn(record $record) => $record->identifier_telegram === $telegram->getId(),
|
||||
update: function (record &$record) use ($telegram){
|
||||
$updated = $this->update(
|
||||
filter: fn(record $record) => $record->identifier === $telegram->getId(),
|
||||
update: function (record &$record) use ($telegram) {
|
||||
// Writing new values into the record
|
||||
$record->name_first = $telegram->getFirstName();
|
||||
$record->name_second = $telegram->getLastName();
|
||||
$record->domain = $telegram->getUsername();
|
||||
$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
}
|
||||
);
|
||||
|
||||
if ($updated instanceof record && $updated->values() !== $account->values()) {
|
||||
if ($updated instanceof record && $updated->values() !== $instance->record->values()) {
|
||||
// Updated the account in the database
|
||||
|
||||
// Exit (success)
|
||||
@@ -147,67 +152,58 @@ final class account extends core
|
||||
}
|
||||
|
||||
// Exit (success)
|
||||
return $account;
|
||||
return $instance;
|
||||
} else {
|
||||
// Not found the account record
|
||||
|
||||
if ($this->registrate($telegram)) {
|
||||
// Registered the account
|
||||
if ($this->create($telegram)) {
|
||||
// Created the account
|
||||
|
||||
// Searching for the registered account in the database
|
||||
$account = $this->database->read(filter: fn(record $record) => $record->identifier_telegram === $telegram->getId(), amount: 1)[0] ?? null;
|
||||
// Searching for the created telegram account in the database
|
||||
$account = $this->read(filter: fn(record $record) => $record->identifier === $telegram->getId());
|
||||
|
||||
if ($account instanceof record) {
|
||||
// Found the registered account
|
||||
if ($account instanceof static) {
|
||||
// Found the created telegram account
|
||||
|
||||
// Exit (success)
|
||||
return $account;
|
||||
} else {
|
||||
// Not found the registered account
|
||||
// Not found the created telegram account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to find the registered account');
|
||||
throw new exception_runtime('Failed to find the created telegram account');
|
||||
}
|
||||
} else {
|
||||
// Not registered the account
|
||||
// Not created the telegram account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to registrate the account');
|
||||
throw new exception_runtime('Failed to create the telegram account');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registrate
|
||||
* Create
|
||||
*
|
||||
* Creates the account record in the database
|
||||
*
|
||||
* @param telegram $telegram The telegram account
|
||||
* @param model $telegram The telegram account
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function registrate(telegram $telegram): int|false
|
||||
public function create(model $telegram): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
$identifier = (int) $telegram->getId();
|
||||
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$identifier,
|
||||
(int) $telegram->getId(),
|
||||
$telegram->getUsername(),
|
||||
$telegram->getFirstName(),
|
||||
$telegram->getLastName(),
|
||||
$telegram->getUsername(),
|
||||
$telegram->getLanguageCode(),
|
||||
(int) $telegram->isBot(),
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
@@ -218,12 +214,4 @@ final class account extends core
|
||||
// Exit (success)
|
||||
return $created ? $identifier : false;
|
||||
}
|
||||
|
||||
public function localizations(): array|false
|
||||
{
|
||||
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram;
|
||||
namespace svoboda\antivertical\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account as model,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account as model,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -22,7 +22,7 @@ use Error as error;
|
||||
/**
|
||||
* Telegram account
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram
|
||||
* @package svoboda\antivertical\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -43,7 +43,7 @@ final class account extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -148,7 +148,7 @@ final class account extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\buttons\account\localization;
|
||||
namespace svoboda\antivertical\models\telegram\buttons\account\localization;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\telegram\selections,
|
||||
svoboda\svoboder\models\telegram\processes\account\localization\create as process_account_localization_create;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\telegram\selections,
|
||||
svoboda\antivertical\models\telegram\processes\account\localization\create as process_account_localization_create;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -21,7 +21,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram account localization create buttons
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\buttons\account\localization
|
||||
* @package svoboda\antivertical\models\telegram\buttons\account\localization
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -42,7 +42,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -144,7 +144,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -168,7 +168,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -216,7 +216,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\buttons\account\localization;
|
||||
namespace svoboda\antivertical\models\telegram\buttons\account\localization;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\telegram\selections,
|
||||
svoboda\svoboder\models\telegram\processes\account\localization\update as process_account_localization_update;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\telegram\selections,
|
||||
svoboda\antivertical\models\telegram\processes\account\localization\update as process_account_localization_update;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -21,7 +21,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram account localization update buttons
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\buttons\account\localization
|
||||
* @package svoboda\antivertical\models\telegram\buttons\account\localization
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -42,7 +42,7 @@ final class update extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -90,7 +90,7 @@ final class update extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,15 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\buttons\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\buttons\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\telegram\processes\language\select as process_language_select,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\declaration as process_distribution_declaration,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\telegram\processes\language\select as process_language_select,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\declaration as process_distribution_declaration,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -22,7 +22,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram distribution declaration buttons
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\buttons\distribution
|
||||
* @package svoboda\antivertical\models\telegram\buttons\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -43,7 +43,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -104,7 +104,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -126,7 +126,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -172,7 +172,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -194,7 +194,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -265,7 +265,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,14 +2,14 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\buttons\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\buttons\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\member,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\search as process_distribution_search,
|
||||
svoboda\svoboder\models\enumerations\member\status;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\membership,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\search as process_distribution_search,
|
||||
svoboda\antivertical\models\enumerations\membership\status;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -24,7 +24,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram distribution search buttons
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\buttons\distribution
|
||||
* @package svoboda\antivertical\models\telegram\buttons\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -45,7 +45,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -101,7 +101,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -123,7 +123,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -193,7 +193,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -215,7 +215,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -272,7 +272,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -294,7 +294,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -330,24 +330,24 @@ final class search extends core
|
||||
if ($distribution instanceof record) {
|
||||
// Initialized the distribution
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
// Initializing function of the message join buttom updating
|
||||
$update = function (context $context, record $member) use ($account, $localization, $distribution, $name, $recognized, $model_member): void {
|
||||
// Searching for the another member records
|
||||
$another = $model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $member->identifier && $record->account === $member->accoount && $record->status !== status::unknown->value,
|
||||
// Initializing function of the message join button updating
|
||||
$update = function (context $context, record $membership) use ($account, $localization, $distribution, $name, $recognized, $model_membership): void {
|
||||
// Searching for the another membership records
|
||||
$another = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $membership->identifier && $record->account === $membership->accoount && $record->status !== status::unknown->value,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
// Initializing the updated inline keyboard of the message
|
||||
$keyboard = process_distribution_search::keyboard(
|
||||
distribution: $distribution,
|
||||
member: $another ?? $member,
|
||||
membership: $another ?? $membership,
|
||||
localization: $localization,
|
||||
messages: $account->authorized_messages === 1,
|
||||
joins: $account->authorized_joins === 1,
|
||||
memberships: $account->authorized_memberships === 1,
|
||||
);
|
||||
|
||||
// Initializing the updated text of the message
|
||||
@@ -368,8 +368,10 @@ final class search extends core
|
||||
);
|
||||
};
|
||||
|
||||
if (!empty($model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution !== $distribution->identifier && $member->account === $account->identifier && $member->status === status::joined->value,
|
||||
if (!empty($model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution !== $distribution->identifier
|
||||
&& $membership->account === $account->identifier
|
||||
&& $membership->status === status::joined->value,
|
||||
amount: 1
|
||||
))) {
|
||||
// Found joining to another distribution
|
||||
@@ -386,8 +388,8 @@ final class search extends core
|
||||
// Not found joining to another distribution
|
||||
|
||||
|
||||
if (!empty($model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution !== $distribution->identifier && $member->account === $account->identifier && $member->status === status::planned->value,
|
||||
if (!empty($model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution !== $distribution->identifier && $membership->account === $account->identifier && $membership->status === status::planned->value,
|
||||
amount: 1
|
||||
))) {
|
||||
// Found planning to join to another distribution
|
||||
@@ -403,21 +405,21 @@ final class search extends core
|
||||
} else {
|
||||
// Not found planned to join to another distribution
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->distribution === $distribution->identifier && $record->account === $account->identifier,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
if ($member->status === status::unknown->value) {
|
||||
if ($membership->status === status::unknown->value) {
|
||||
// The account has leaved the distribution
|
||||
|
||||
// Updating the member record
|
||||
$updated = $model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $member->identifier,
|
||||
// Updating the membership record
|
||||
$updated = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $membership->identifier,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::planned->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
@@ -426,16 +428,16 @@ final class search extends core
|
||||
)[0] ?? null;
|
||||
|
||||
if ($updated) {
|
||||
// Updated the member record
|
||||
// Updated the membership record
|
||||
|
||||
// Deprecating other records
|
||||
$model_member->database->read(
|
||||
$model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $updated->identifier && $record->account === $updated->account,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::unknown->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBER_DEPRECATING_RECORDS_AMOUNT
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBERSHIP_DEPRECATING_RECORDS_AMOUNT
|
||||
)[0] ?? null;
|
||||
|
||||
// Sending the message
|
||||
@@ -450,10 +452,10 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not updated the member record
|
||||
// Not updated the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_updated'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_updated'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -461,83 +463,83 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else if ($member->status === status::planned->value) {
|
||||
} else if ($membership->status === status::planned->value) {
|
||||
// The account has already planned to join to the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_already_planned'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the plan button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else if ($member->status === status::joined->value) {
|
||||
} else if ($membership->status === status::joined->value) {
|
||||
// The account has already joined to the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_already_joined'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the plan button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Creating the member record
|
||||
$record = $model_member->create(
|
||||
// Creating the membership record
|
||||
$record = $model_membership->create(
|
||||
distribution: $distribution->identifier,
|
||||
account: $account->identifier,
|
||||
status: status::planned
|
||||
);
|
||||
|
||||
if ($record) {
|
||||
// Created the member record
|
||||
// Created the membership record
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->identifier === $record,
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->identifier === $record,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
// Deprecating other records
|
||||
$model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $member->identifier && $record->account === $member->account,
|
||||
$model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $membership->identifier && $record->account === $membership->account,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::unknown->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBER_DEPRECATING_RECORDS_AMOUNT
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBERSHIP_DEPRECATING_RECORDS_AMOUNT
|
||||
)[0] ?? null;
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('📅 *' . $localization['distribution_search_planned'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the plan button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -546,10 +548,10 @@ final class search extends core
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not created the member record
|
||||
// Not created the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -612,7 +614,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -636,7 +638,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -672,18 +674,18 @@ final class search extends core
|
||||
if ($distribution instanceof record) {
|
||||
// Initialized the distribution
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
// Initializing function of the message join buttom updating
|
||||
$update = function (context $context, record $member) use ($account, $localization, $distribution, $name, $recognized): void {
|
||||
$update = function (context $context, record $membership) use ($account, $localization, $distribution, $name, $recognized): void {
|
||||
// Initializing the updated inline keyboard of the message
|
||||
$keyboard = process_distribution_search::keyboard(
|
||||
distribution: $distribution,
|
||||
member: $member,
|
||||
membership: $membership,
|
||||
localization: $localization,
|
||||
messages: $account->authorized_messages === 1,
|
||||
joins: $account->authorized_joins === 1,
|
||||
memberships: $account->authorized_memberships === 1,
|
||||
);
|
||||
|
||||
// Initializing the updated text of the message
|
||||
@@ -704,35 +706,35 @@ final class search extends core
|
||||
);
|
||||
};
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->distribution === $distribution->identifier && $record->account === $account->identifier,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
if ($member->status === status::unknown->value) {
|
||||
if ($membership->status === status::unknown->value) {
|
||||
// The account has leaved the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_already_unplanned'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the plan button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else if ($member->status === status::planned->value) {
|
||||
} else if ($membership->status === status::planned->value) {
|
||||
// The account has planned to join to the distribution
|
||||
|
||||
// Updating the member record
|
||||
$updated = $model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $member->identifier,
|
||||
// Updating the membership record
|
||||
$updated = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $membership->identifier,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::unknown->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
@@ -741,7 +743,7 @@ final class search extends core
|
||||
)[0] ?? null;
|
||||
|
||||
if ($updated) {
|
||||
// Updated the member record
|
||||
// Updated the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('❌ *' . $localization['distribution_search_unplanned'] . '*')
|
||||
@@ -755,10 +757,10 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not updated the member record
|
||||
// Not updated the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_updated'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_updated'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -766,59 +768,59 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else if ($member->status === status::joined->value) {
|
||||
} else if ($membership->status === status::joined->value) {
|
||||
// The account has already joined to the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_already_joined'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the plan button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Creating the member record
|
||||
$record = $model_member->create(
|
||||
// Creating the membership record
|
||||
$record = $model_membership->create(
|
||||
distribution: $distribution->identifier,
|
||||
account: $account->identifier,
|
||||
status: status::unknown
|
||||
);
|
||||
|
||||
if ($record) {
|
||||
// Created the member record
|
||||
// Created the membership record
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->identifier === $record,
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->identifier === $record,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('❌ *' . $localization['distribution_search_unplanned'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the plan button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -827,10 +829,10 @@ final class search extends core
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not created the member record
|
||||
// Not created the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -891,7 +893,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -915,7 +917,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -952,23 +954,23 @@ final class search extends core
|
||||
// Initialized the distribution
|
||||
|
||||
// Initializing the distribution model
|
||||
$model_member = new member;
|
||||
$model_membership = new membership;
|
||||
|
||||
// Initializing function of the message join buttom updating
|
||||
$update = function (context $context, record $member) use ($account, $localization, $distribution, $name, $recognized, $model_member): void {
|
||||
// Searching for the another member records
|
||||
$another = $model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $member->identifier && $record->account === $member->accoount && $record->status !== status::unknown->value,
|
||||
$update = function (context $context, record $membership) use ($account, $localization, $distribution, $name, $recognized, $model_membership): void {
|
||||
// Searching for the another membership records
|
||||
$another = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $membership->identifier && $record->account === $membership->accoount && $record->status !== status::unknown->value,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
// Initializing the updated inline keyboard of the message
|
||||
$keyboard = process_distribution_search::keyboard(
|
||||
distribution: $distribution,
|
||||
member: $another ?? $member,
|
||||
membership: $another ?? $membership,
|
||||
localization: $localization,
|
||||
messages: $account->authorized_messages === 1,
|
||||
joins: $account->authorized_joins === 1,
|
||||
memberships: $account->authorized_memberships === 1,
|
||||
);
|
||||
|
||||
// Initializing the updated text of the message
|
||||
@@ -989,8 +991,8 @@ final class search extends core
|
||||
);
|
||||
};
|
||||
|
||||
if (!empty($model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution !== $distribution->identifier && $member->account === $account->identifier && $member->status === status::joined->value,
|
||||
if (!empty($model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution !== $distribution->identifier && $membership->account === $account->identifier && $membership->status === status::joined->value,
|
||||
amount: 1
|
||||
))) {
|
||||
// Found joining to another distribution
|
||||
@@ -1006,21 +1008,21 @@ final class search extends core
|
||||
} else {
|
||||
// Not found joining to another distribution
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution === $distribution->identifier && $member->account === $account->identifier,
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution === $distribution->identifier && $membership->account === $account->identifier,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
if ($member->status === status::unknown->value || $member->status === status::planned->value) {
|
||||
if ($membership->status === status::unknown->value || $membership->status === status::planned->value) {
|
||||
// The account has planned to join to the distribution or leaved the distribution
|
||||
|
||||
// Updating the member record
|
||||
$updated = $model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $member->identifier,
|
||||
// Updating the membership record
|
||||
$updated = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $membership->identifier,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::joined->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
@@ -1029,16 +1031,16 @@ final class search extends core
|
||||
)[0] ?? null;
|
||||
|
||||
if ($updated instanceof record) {
|
||||
// Updated the member record
|
||||
// Updated the membership record
|
||||
|
||||
// Deprecating other records
|
||||
$model_member->database->read(
|
||||
$model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $updated->identifier && $record->account === $updated->account,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::unknown->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBER_DEPRECATING_RECORDS_AMOUNT
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBERSHIP_DEPRECATING_RECORDS_AMOUNT
|
||||
)[0] ?? null;
|
||||
|
||||
// Initializing the message title
|
||||
@@ -1064,10 +1066,10 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not updated the member record
|
||||
// Not updated the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_updated'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_updated'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1075,51 +1077,51 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else if ($member->status === status::joined->value) {
|
||||
} else if ($membership->status === status::joined->value) {
|
||||
// The account has already joined to the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_already_joined'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the join button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Creating the member record
|
||||
$record = $model_member->create(
|
||||
// Creating the membership record
|
||||
$record = $model_membership->create(
|
||||
distribution: $distribution->identifier,
|
||||
account: $account->identifier,
|
||||
status: status::joined
|
||||
);
|
||||
|
||||
if ($record) {
|
||||
// Created the member record
|
||||
// Created the membership record
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->identifier === $record,
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->identifier === $record,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
// Deprecating other records
|
||||
$model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $member->identifier && $record->account === $member->account,
|
||||
$model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier !== $membership->identifier && $record->account === $membership->account,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::unknown->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBER_DEPRECATING_RECORDS_AMOUNT
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBERSHIP_DEPRECATING_RECORDS_AMOUNT
|
||||
)[0] ?? null;
|
||||
|
||||
// Initializing the message title
|
||||
@@ -1135,20 +1137,20 @@ final class search extends core
|
||||
|
||||
$description
|
||||
TXT
|
||||
)->then(function (message $message) use ($context, $update, $member) {
|
||||
)->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the join button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1157,10 +1159,10 @@ final class search extends core
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not created the member record
|
||||
// Not created the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1222,7 +1224,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1246,7 +1248,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1282,18 +1284,18 @@ final class search extends core
|
||||
if ($distribution instanceof record) {
|
||||
// Initialized the distribution
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
// Initializing function of the message join buttom updating
|
||||
$update = function (context $context, record $member) use ($account, $localization, $distribution, $name, $recognized): void {
|
||||
$update = function (context $context, record $membership) use ($account, $localization, $distribution, $name, $recognized): void {
|
||||
// Initializing the updated inline keyboard of the message
|
||||
$keyboard = process_distribution_search::keyboard(
|
||||
distribution: $distribution,
|
||||
member: $member,
|
||||
membership: $membership,
|
||||
localization: $localization,
|
||||
messages: $account->authorized_messages === 1,
|
||||
joins: $account->authorized_joins === 1,
|
||||
memberships: $account->authorized_memberships === 1,
|
||||
);
|
||||
|
||||
// Initializing the updated text of the message
|
||||
@@ -1314,35 +1316,35 @@ final class search extends core
|
||||
);
|
||||
};
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->distribution === $distribution->identifier && $record->account === $account->identifier,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
if ($member->status === status::unknown->value || $member->status === status::planned->value) {
|
||||
if ($membership->status === status::unknown->value || $membership->status === status::planned->value) {
|
||||
// The account has planned to join to the distribution or leaved the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_already_leaved'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the join button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else if ($member->status === 2) {
|
||||
} else if ($membership->status === 2) {
|
||||
// The account has joined to the distribution
|
||||
|
||||
// Updating the member record
|
||||
$updated = $model_member->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $member->identifier,
|
||||
// Updating the membership record
|
||||
$updated = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $membership->identifier,
|
||||
update: function (record &$record) {
|
||||
$record->status = status::unknown->value;
|
||||
$record->updated = svoboda::timestamp();
|
||||
@@ -1351,7 +1353,7 @@ final class search extends core
|
||||
)[0] ?? null;
|
||||
|
||||
if ($updated instanceof record) {
|
||||
// Updated the member record
|
||||
// Updated the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('👋 *' . $localization['distribution_search_leaved'] . '*')
|
||||
@@ -1365,10 +1367,10 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not updated the member record
|
||||
// Not updated the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_updated'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_updated'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1378,43 +1380,43 @@ final class search extends core
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Creating the member record
|
||||
$record = $model_member->create(
|
||||
// Creating the membership record
|
||||
$record = $model_membership->create(
|
||||
distribution: $distribution->identifier,
|
||||
account: $account->identifier,
|
||||
status: status::unknown
|
||||
);
|
||||
|
||||
if ($record) {
|
||||
// Created the member record
|
||||
// Created the membership record
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->identifier === $record,
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->identifier === $record,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Found the member of the distribution
|
||||
if ($membership instanceof record) {
|
||||
// Found the membership of the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('👋 *' . $localization['distribution_search_leaved'] . '*')
|
||||
->then(function (message $message) use ($context, $update, $member) {
|
||||
->then(function (message $message) use ($context, $update, $membership) {
|
||||
// Sended the message
|
||||
|
||||
// Updating the message with the join button
|
||||
$update($context, $member);
|
||||
$update($context, $membership);
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
} else {
|
||||
// Not found the member of the distribution
|
||||
// Not found the membership of the distribution
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1423,10 +1425,10 @@ final class search extends core
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not created the member record
|
||||
// Not created the membership record
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_member_not_created'] . '*')
|
||||
$context->sendMessage('⚠️ *' . $localization['distribution_search_membership_not_created'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1487,7 +1489,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\buttons\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\buttons\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\select as process_distribution_select;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\select as process_distribution_select;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -18,7 +18,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram distribution select buttons
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\buttons\distribution
|
||||
* @package svoboda\antivertical\models\telegram\buttons\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -39,7 +39,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -95,7 +95,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -117,7 +117,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -187,7 +187,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -209,7 +209,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -266,7 +266,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,16 +2,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\buttons\member;
|
||||
namespace svoboda\antivertical\models\telegram\buttons\membership;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\select as process_distribution_select,
|
||||
svoboda\svoboder\models\telegram\processes\member\search as process_member_search,
|
||||
svoboda\svoboder\models\enumerations\member\status,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\select as process_distribution_select,
|
||||
svoboda\antivertical\models\telegram\processes\membership\search as process_membership_search,
|
||||
svoboda\antivertical\models\enumerations\membership\status,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -23,9 +23,9 @@ use Zanzara\Context as context,
|
||||
use mirzaev\baza\record;
|
||||
|
||||
/**
|
||||
* Telegram member search buttons
|
||||
* Telegram membership search buttons
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\buttons\member
|
||||
* @package svoboda\antivertical\models\telegram\buttons\membership
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -46,7 +46,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -56,7 +56,7 @@ final class search extends core
|
||||
// Initialized localization
|
||||
|
||||
// Reading from the telegram user buffer
|
||||
$context->getUserDataItem(process_member_search::PROCESS)
|
||||
$context->getUserDataItem(process_membership_search::PROCESS)
|
||||
->then(function ($search) use ($context, $account, $localization) {
|
||||
// Readed from the telegram user buffer
|
||||
|
||||
@@ -64,10 +64,10 @@ final class search extends core
|
||||
// Found started search process
|
||||
|
||||
// Initializing title for the message
|
||||
$title = '📄 *' . $localization[process_member_search::PROCESS . '_name_request_title'] . '*';
|
||||
$title = '📄 *' . $localization[process_membership_search::PROCESS . '_name_request_title'] . '*';
|
||||
|
||||
// Initializing description for the message
|
||||
$description = $localization[process_member_search::PROCESS . '_name_request_description'];
|
||||
$description = $localization[process_membership_search::PROCESS . '_name_request_description'];
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(<<<TXT
|
||||
@@ -78,14 +78,14 @@ final class search extends core
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
// Writing into the member search buffer
|
||||
$context->nextStep([process_member_search::class, 'name']);
|
||||
// Writing into the membership search buffer
|
||||
$context->nextStep([process_membership_search::class, 'name']);
|
||||
});
|
||||
} else {
|
||||
// Not found started search process
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization[process_member_search::PROCESS . '_not_started'] . '*');
|
||||
$context->sendMessage('⚠️ *' . $localization[process_membership_search::PROCESS . '_not_started'] . '*');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -102,7 +102,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -124,7 +124,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -134,7 +134,7 @@ final class search extends core
|
||||
// Initialized localization
|
||||
|
||||
// Reading from the telegram user buffer
|
||||
$context->getUserDataItem(process_member_search::PROCESS)
|
||||
$context->getUserDataItem(process_membership_search::PROCESS)
|
||||
->then(function ($search) use ($context, $account, $localization) {
|
||||
// Readed from the telegram user buffer
|
||||
|
||||
@@ -153,12 +153,12 @@ final class search extends core
|
||||
$search['distribution'] = $distribution;
|
||||
|
||||
// Writing to the telegram user buffer
|
||||
$context->setUserDataItem(process_member_search::PROCESS, $search)
|
||||
$context->setUserDataItem(process_membership_search::PROCESS, $search)
|
||||
->then(function () use ($context) {
|
||||
// Writed into the telegram user buffer
|
||||
|
||||
// Sending the list of found distributions and menu
|
||||
process_member_search::menu($context);
|
||||
process_membership_search::menu($context);
|
||||
});
|
||||
} else {
|
||||
// Not initialized the distribution
|
||||
@@ -172,25 +172,25 @@ final class search extends core
|
||||
];
|
||||
|
||||
// Writing to the telegram user buffer
|
||||
$context->setUserDataItem(process_member_search::PROCESS, $search)
|
||||
$context->setUserDataItem(process_membership_search::PROCESS, $search)
|
||||
->then(function () use ($context) {
|
||||
// Writed into the telegram user buffer
|
||||
|
||||
// Sending the list of found distributions and menu
|
||||
process_member_search::menu($context);
|
||||
process_membership_search::menu($context);
|
||||
});
|
||||
},
|
||||
cancel: function (context $context) {
|
||||
// Sending the list of found distributions and menu
|
||||
process_member_search::menu($context);
|
||||
process_membership_search::menu($context);
|
||||
},
|
||||
description: $localization[process_member_search::PROCESS . '_distribution_selection_description']
|
||||
description: $localization[process_membership_search::PROCESS . '_distribution_selection_description']
|
||||
);
|
||||
} else {
|
||||
// Not found started search process
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization[process_member_search::PROCESS . '_not_started'] . '*');
|
||||
$context->sendMessage('⚠️ *' . $localization[process_membership_search::PROCESS . '_not_started'] . '*');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -207,7 +207,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -229,7 +229,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -239,7 +239,7 @@ final class search extends core
|
||||
// Initialized localization
|
||||
|
||||
// Reading from the telegram user buffer
|
||||
$context->getUserDataItem(process_member_search::PROCESS)
|
||||
$context->getUserDataItem(process_membership_search::PROCESS)
|
||||
->then(function ($search) use ($context, $account, $localization) {
|
||||
// Readed from the telegram user buffer
|
||||
|
||||
@@ -250,7 +250,7 @@ final class search extends core
|
||||
$keyboard = [[]];
|
||||
|
||||
// Initializing the amount of buttons in one row
|
||||
$amount = MEMBERS_SEARCH_STATUS_ROW_AMOUNT ?? 8;
|
||||
$amount = MEMBERSHIPS_SEARCH_STATUS_ROW_AMOUNT ?? 8;
|
||||
|
||||
// Initializing the rows iterator
|
||||
$row = 0;
|
||||
@@ -258,6 +258,9 @@ final class search extends core
|
||||
foreach (status::cases() as $status) {
|
||||
// Iterating over statuses
|
||||
|
||||
// Skipping the unknown status
|
||||
if ($status === status::unknown) continue;
|
||||
|
||||
// Moving to the next row
|
||||
if (count($keyboard[$row]) >= $amount) ++$row;
|
||||
|
||||
@@ -266,14 +269,14 @@ final class search extends core
|
||||
|
||||
// Generating the button and writing into the keyboard buffer
|
||||
$keyboard[$row][] = [
|
||||
'text' => $status->emoji() . ' ' . $localization[process_member_search::PROCESS . "_button_status_$status->value"],
|
||||
'callback_data' => process_member_search::PROCESS . "_status_$status->name"
|
||||
'text' => $status->emoji() . ' ' . $localization[process_membership_search::PROCESS . "_button_status_$status->value"],
|
||||
'callback_data' => process_membership_search::PROCESS . "_status_$status->name"
|
||||
];
|
||||
}
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
'👤 *' . $localization[process_member_search::PROCESS . '_status_select_title'] . '*',
|
||||
'👤 *' . $localization[process_membership_search::PROCESS . '_status_select_title'] . '*',
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => $keyboard,
|
||||
@@ -285,7 +288,7 @@ final class search extends core
|
||||
// Not found started search process
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization[process_member_search::PROCESS . '_not_started'] . '*');
|
||||
$context->sendMessage('⚠️ *' . $localization[process_membership_search::PROCESS . '_not_started'] . '*');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -302,7 +305,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,15 +2,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram;
|
||||
namespace svoboda\antivertical\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\member,
|
||||
svoboda\svoboder\models\telegram\processes\language\select as process_language_select,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\telegram,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\membership,
|
||||
svoboda\antivertical\models\telegram\processes\language\select as process_language_select,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -23,7 +24,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram commands
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram
|
||||
* @package svoboda\antivertical\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -44,7 +45,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -53,26 +54,26 @@ final class commands extends core
|
||||
if ($localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Initializing the title
|
||||
$title = '📋 *' . $localization['menu_title'] . '*';
|
||||
// Initializing title for the message
|
||||
$title = '📡 *' . $localization['menu_title'] . '*';
|
||||
|
||||
// Initializing accounts
|
||||
$accounts = '*' . $localization['menu_accounts'] . ':* ' . ((new account)->database->count() ?? 0);
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
// Searching for members records
|
||||
$records = $model_member->database->read(
|
||||
filter: function (record $member, array $records = []) {
|
||||
if ($member->status === 2) {
|
||||
// Searching for memberships records
|
||||
$records = $model_membership->database->read(
|
||||
filter: function (record $membership, array $records = []) {
|
||||
if ($membership->status === 2) {
|
||||
// The account joined to the distribution
|
||||
|
||||
foreach ($records as $record) {
|
||||
// Iterating over readed records
|
||||
|
||||
if ($record->identifier === $member->identifier) {
|
||||
// Found a dublicate of the member
|
||||
if ($record->identifier === $membership->identifier) {
|
||||
// Found a dublicate of the membership
|
||||
|
||||
// Exit (success)
|
||||
return false;
|
||||
@@ -86,36 +87,79 @@ final class commands extends core
|
||||
// Exit (success)
|
||||
return false;
|
||||
},
|
||||
amount: MENU_MEMBERS_AMOUNT
|
||||
amount: MENU_MEMBERSHIPS_AMOUNT
|
||||
) ?? [];
|
||||
|
||||
// Initializing members
|
||||
$members = '*' . $localization['menu_members'] . ':* ' . count($records);
|
||||
|
||||
// Initializing distributions
|
||||
$distributions = '*' . $localization['menu_distributions'] . ':* ' . ((new distribution)->database->count() ?? 0);
|
||||
|
||||
// Initializing amount of planned
|
||||
$planned = count(account::planned(PHP_INT_MAX));
|
||||
|
||||
// Initializing amount of structors
|
||||
$structors = '*' . $localization['menu_structors'] . ':* ' . count(account::structors(PHP_INT_MAX)) . ($planned > 0 ? " + $planned" : '');
|
||||
|
||||
// Initializing amount of autonoms
|
||||
$autonoms = '*' . $localization['menu_autonoms'] . ':* ' . count(account::autonoms(PHP_INT_MAX));
|
||||
|
||||
// Initializing amount of volunteers
|
||||
$volunteers = '*' . $localization['menu_volunteers'] . ':* ' . count(account::volunteers(PHP_INT_MAX));
|
||||
|
||||
// Initializing amount of investors
|
||||
$investors = '*' . $localization['menu_investors'] . ':* ' . count(account::investors(PHP_INT_MAX));
|
||||
|
||||
// Initializing amount of recruiters
|
||||
$recruiters = '*' . $localization['menu_recruiters'] . ':* ' . count(account::recruiters(PHP_INT_MAX));
|
||||
|
||||
// Initializing the data syncronization for the message
|
||||
$syncronization = '⛓️💥 ' . $localization['menu_not_syncronized'];
|
||||
|
||||
// Initializing the database syncronization for the message
|
||||
$database = '⚠️ ' . $localization['menu_warning_database'];
|
||||
|
||||
// Initializing channels
|
||||
$channels = [];
|
||||
|
||||
// Initializing chats
|
||||
$chats = [];
|
||||
|
||||
// Initializing projects
|
||||
$projects = [];
|
||||
|
||||
// Initializing events
|
||||
$events = [];
|
||||
|
||||
// Thinking stuff
|
||||
$thing_about_index = rand(1, 1);
|
||||
$thing_about_it = $localization['thing_about_it_' . $thing_about_index] ?? null;
|
||||
$thing_about_author = $localization['thing_about_it_' . $thing_about_index . '_author'] ?? null;
|
||||
$thinking_stuff = !empty($thing_about_it) ? "\n\n**>\"" . ($thing_about_it . (!empty($thing_about_author) ? "\"\n>\n>_*" . preg_replace('/\./', '\.', $thing_about_author) . '*_||' : '')) : '';
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
<<<TXT
|
||||
$title
|
||||
|
||||
$accounts
|
||||
$members
|
||||
|
||||
$distributions
|
||||
$structors
|
||||
$autonoms
|
||||
$volunteers
|
||||
$investors
|
||||
$recruiters
|
||||
|
||||
$syncronization
|
||||
$database$thinking_stuff
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => [
|
||||
[
|
||||
[
|
||||
'text' => '🔥 ' . $localization['menu_button_projects'],
|
||||
'callback_data' => 'projects'
|
||||
'text' => '🔥 ' . $localization['menu_button_channel'],
|
||||
'url' => 'https://t.me/antivertical'
|
||||
],
|
||||
[
|
||||
'text' => '🗺 ' . $localization['menu_button_map'],
|
||||
@@ -129,18 +173,40 @@ final class commands extends core
|
||||
]
|
||||
],
|
||||
[
|
||||
/* [
|
||||
'text' => '🏗 ' . $localization['menu_button_projects'],
|
||||
'callback_data' => 'prjects'
|
||||
], */
|
||||
[
|
||||
'text' => '🐣 ' . $localization['menu_button_members'],
|
||||
'callback_data' => 'members'
|
||||
'text' => '🚸 ' . $localization['menu_button_chats'] . ': ' . count($chats),
|
||||
'url' => 'https://t.me/chats_antivertical_bot'
|
||||
],
|
||||
[
|
||||
'text' => '📣 ' . $localization['menu_button_channels'] . ': ' . count($channels),
|
||||
'url' => 'https://t.me/channels_antivertical_bot'
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => '🏗 ' . $localization['menu_button_projects'] . ': ' . count($projects),
|
||||
'callback_data' => 'projects'
|
||||
],
|
||||
[
|
||||
'text' => '📅 ' . $localization['menu_button_events'] . ': ' . count($events),
|
||||
'url' => 'https://t.me/events_antivertical_bot'
|
||||
],
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => '🐣 ' . $localization['menu_button_memberships'],
|
||||
'callback_data' => 'memberships'
|
||||
],
|
||||
[
|
||||
'text' => '🏘 ' . $localization['menu_button_distributions'],
|
||||
'callback_data' => 'distributions'
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => '🌏 ' . $localization['menu_button_organisation'],
|
||||
'callback_data' => 'organisation'
|
||||
],
|
||||
]
|
||||
],
|
||||
'disable_notification' => true,
|
||||
@@ -165,7 +231,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -189,7 +255,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the title
|
||||
@@ -197,7 +263,7 @@ final class commands extends core
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(<<<TXT
|
||||
*⚠️ Failed to initialize your Telegram account*
|
||||
*⚠️ Failed to initialize the account*
|
||||
TXT)
|
||||
->then(function (message $message) use ($context) {
|
||||
//
|
||||
@@ -206,7 +272,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -215,22 +281,22 @@ final class commands extends core
|
||||
}
|
||||
|
||||
/**
|
||||
* Members
|
||||
* Memberships
|
||||
*
|
||||
* Responce for the command: "/members"
|
||||
* Responce for the command: "/memberships"
|
||||
*
|
||||
* Sends the members menu
|
||||
* Sends the memberships menu
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function members(context $context): void
|
||||
public static function memberships(context $context): void
|
||||
{
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -246,25 +312,25 @@ final class commands extends core
|
||||
// Initialized localization
|
||||
|
||||
// Initializing the message title
|
||||
$title = '🐣 *' . $localization['members_title'] . '*';
|
||||
$title = '🐣 *' . $localization['memberships_title'] . '*';
|
||||
|
||||
// Initializing the message description
|
||||
$description = $localization['members_description'];
|
||||
$structor = $localization['memberships_structor'];
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
<<<TXT
|
||||
$title
|
||||
|
||||
$description
|
||||
$structor
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => [
|
||||
[
|
||||
[
|
||||
'text' => '🔎 ' . $localization['members_button_search'],
|
||||
'callback_data' => 'member_search_start'
|
||||
'text' => '🔎 ' . $localization['memberships_button_search'],
|
||||
'callback_data' => 'membership_search_start'
|
||||
]
|
||||
]
|
||||
],
|
||||
@@ -297,7 +363,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -322,7 +388,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -405,7 +471,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -413,6 +479,185 @@ final class commands extends core
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Organisation
|
||||
*
|
||||
* Responce for the command: "/organisation"
|
||||
*
|
||||
* Sends information about organisation with menu
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function organisation(context $context): void
|
||||
{
|
||||
// Initializing the telegram account
|
||||
$telegram = $context->get('telegram');
|
||||
|
||||
if ($telegram instanceof telegram) {
|
||||
// Initialized the telegram account
|
||||
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
$language = $context->get('language');
|
||||
|
||||
if ($language instanceof language) {
|
||||
// Initialized language
|
||||
|
||||
|
||||
// Initializing localization
|
||||
$localization = $context->get('localization');
|
||||
|
||||
if ($localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Initializing title for the message
|
||||
$title = match (rand(1, 3)) {
|
||||
1 => '🌏 ',
|
||||
2 => '🌍 ',
|
||||
3 => '🌎 '
|
||||
} . '*' . $localization['organisation_title'] . '*';
|
||||
|
||||
// Initializing the organisation description for the message
|
||||
$description = $localization['organisation_description'];
|
||||
|
||||
// Initializing the structor description for the message
|
||||
$structor = $localization['organisation_structor'];
|
||||
|
||||
// Initializing the autonom description for the message
|
||||
$autonom = $localization['organisation_autonom'];
|
||||
|
||||
// Initializing the warning for the message
|
||||
$warning_legal = '⚠️ ' . $localization['organisation_warning_legal'];
|
||||
|
||||
// Initializing the warning for the message
|
||||
$warning_administration = '⚠️ ' . $localization['organisation_warning_administration'];
|
||||
|
||||
// Initiailzing the account distribution
|
||||
$distribution = $account->distribution();
|
||||
|
||||
// Declaring the membership keyboard
|
||||
$keyboard_membership = [];
|
||||
|
||||
if ($distribution instanceof distribution) {
|
||||
// Structor
|
||||
|
||||
// Initializing the account distribution localization
|
||||
$distribution_localization = $distribution->localization(language: $language);
|
||||
|
||||
// Initializing the distribution structors
|
||||
$distribution_structors = count($distribution->structors(PHP_INT_MAX) ?? []);
|
||||
|
||||
// Initializing the distribution plannert
|
||||
$distribution_planners = count($distribution->planners(PHP_INT_MAX) ?? []);
|
||||
|
||||
// Initializing the membership keyboard
|
||||
$keyboard_membership = [
|
||||
[
|
||||
[
|
||||
'text' => '🏘 ' . $localization['organisation_button_structor_distribution'] . ': ' . $distribution_localization->name . ' (' . $distribution_structors . ($distribution_planners > 0 ? ' + ' . $distribution_planners : '') . ')',
|
||||
'callback_data' => 'distributions'
|
||||
]
|
||||
]
|
||||
];
|
||||
} else if (false) {
|
||||
// Autonom
|
||||
} else if (false) {
|
||||
// Volunteer
|
||||
} else {
|
||||
// Stranger
|
||||
|
||||
// Initializing the membership keyboard
|
||||
$keyboard_membership = [
|
||||
[
|
||||
[
|
||||
'text' => '🧱 ' . $localization['organisation_button_structor'],
|
||||
'callback_data' => 'distributions'
|
||||
],
|
||||
[
|
||||
'text' => '🐣 ' . $localization['organisation_button_autonom'],
|
||||
'callback_data' => 'autonom'
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
<<<TXT
|
||||
$title
|
||||
|
||||
$description
|
||||
|
||||
$structor
|
||||
$autonom
|
||||
|
||||
$warning_legal
|
||||
|
||||
$warning_administration
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => $keyboard_membership,
|
||||
'remove_keyboard' => true,
|
||||
'disable_notification' => true
|
||||
],
|
||||
'link_preview_options' => [
|
||||
'is_disabled' => true
|
||||
]
|
||||
]
|
||||
);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized language
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize language*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the telegram account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize the telegram account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
@@ -426,97 +671,133 @@ final class commands extends core
|
||||
*/
|
||||
public static function account(context $context): void
|
||||
{
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
// Initializing the telegram account
|
||||
$telegram = $context->get('telegram');
|
||||
|
||||
if ($account instanceof record) {
|
||||
// Initialized the account
|
||||
if ($telegram instanceof telegram) {
|
||||
// Initialized the telegram account
|
||||
|
||||
// Initializing localization
|
||||
$localization = $context->get('localization');
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($localization) {
|
||||
// Initialized localization
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing title for the message
|
||||
$title = '🫵 ' . $localization['account_title'];
|
||||
// Initializing localization
|
||||
$localization = $context->get('localization');
|
||||
|
||||
// Declaring buufer of rows about authorizations
|
||||
$authorizations = '';
|
||||
if ($localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Initializing rows about authorization
|
||||
foreach ($account->values() as $key => $value) {
|
||||
// Iterating over account parameters
|
||||
// Initializing title for the message
|
||||
$title = '🫵 ' . $localization['account_title'];
|
||||
|
||||
if (str_starts_with($key, 'authorized_')) {
|
||||
// Iterating over account authorizations
|
||||
// Initializing the account identifier row for the message
|
||||
$identifier = '*' . $localization['account_identifier'] . ":* $account->identifier \($telegram->identifier\)";
|
||||
|
||||
// Skipping system authorizations
|
||||
if (str_starts_with($key, 'authorized_system_')) continue;
|
||||
// Declaring the buffer of authorizations
|
||||
$authorizations = '';
|
||||
|
||||
// Writing into buffer of rows about authorizations
|
||||
$authorizations .= ($value ? '✅' : '❎') . ' *' . ($localization["account_$key"] ?? $key) . ':* ' . ($value ? $localization['yes'] : $localization['no']) . "\n";
|
||||
// Initializing rows about authorization
|
||||
foreach ($account->record->values() as $key => $value) {
|
||||
// Iterating over account parameters
|
||||
|
||||
if (str_starts_with($key, 'authorized_')) {
|
||||
// Iterating over account authorizations
|
||||
|
||||
// Skipping system authorizations
|
||||
if (str_starts_with($key, 'authorized_system_')) continue;
|
||||
|
||||
// Writing into the buffer of authorizations
|
||||
$authorizations .= ($value ? '✅' : '❎') . ' *' . ($localization["account_$key"] ?? preg_replace('/_/', '\\_', $key)) . ':* ' . ($value ? $localization['yes'] : $localization['no']) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trimming the last line break character
|
||||
$authorizations = trim($authorizations, "\n");
|
||||
// Trimming the last line break character
|
||||
$authorizations = trim($authorizations, "\n");
|
||||
|
||||
// Initializing the data export for the message
|
||||
$export = '📤 ' . $localization['account_export'];
|
||||
// Declaring the buffer of system authorizations
|
||||
$authorizations_system = '';
|
||||
|
||||
// Initializing the data security for the message
|
||||
$data = $localization['account_data'];
|
||||
// Initializing rows about authorization
|
||||
foreach ($account->record->values() as $key => $value) {
|
||||
// Iterating over account parameters
|
||||
|
||||
// Initializing the data security repository for the message
|
||||
$security = '📁 [' . $localization['account_security_repository'] . '](https://git.svoboda.works/mirzaev/security) \([' . $localization['account_security_repository_mirror_github'] . '](https://github.com/mature-woman/security)\)';
|
||||
if (str_starts_with($key, 'authorized_')) {
|
||||
// Iterating over account authorizations
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
<<<TXT
|
||||
$title
|
||||
if (str_starts_with($key, 'authorized_system_') && $value) {
|
||||
// System authorization
|
||||
|
||||
$authorizations
|
||||
// Writing into the buffer of system authorizations
|
||||
$authorizations_system .= ($value ? '🔐' : '🔒') . ' *' . ($localization["account_$key"] ?? preg_replace('/_/', '\\_', $key)) . ':* ' . ($value ? $localization['yes'] : $localization['no']) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$export
|
||||
// Trimming the last line break character
|
||||
$authorizations_system = trim($authorizations_system, "\n");
|
||||
|
||||
$data
|
||||
// Initializing the line break for the buffer of system authorizations
|
||||
if (!empty($authorizations_system)) $authorizations_system = "\n\n" . $authorizations_system;
|
||||
|
||||
$security
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => [
|
||||
[
|
||||
// Initializing the data export for the message
|
||||
$export = '📤 ' . $localization['account_export'];
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
<<<TXT
|
||||
$title
|
||||
|
||||
$identifier
|
||||
|
||||
$authorizations$authorizations_system
|
||||
|
||||
$export
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => [
|
||||
[
|
||||
'text' => '🗺 ' . $localization['account_button_localizations'],
|
||||
'callback_data' => 'account_localizations'
|
||||
[
|
||||
'text' => '🗺 ' . $localization['account_button_localizations'],
|
||||
'callback_data' => 'account_localizations'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'remove_keyboard' => true,
|
||||
'disable_notification' => true
|
||||
],
|
||||
'remove_keyboard' => true,
|
||||
'disable_notification' => true
|
||||
],
|
||||
'link_preview_options' => [
|
||||
'is_disabled' => true
|
||||
'link_preview_options' => [
|
||||
'is_disabled' => true
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized localization
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
// Not initialized the telegram account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the telegram account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -540,7 +821,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -590,7 +871,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -616,7 +897,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -670,7 +951,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -694,7 +975,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -772,7 +1053,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -796,7 +1077,7 @@ final class commands extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -827,7 +1108,7 @@ final class commands extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram;
|
||||
namespace svoboda\antivertical\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution as model,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution as model,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -20,7 +20,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram distribution
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram
|
||||
* @package svoboda\antivertical\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -31,7 +31,7 @@ final class distribution extends core
|
||||
* Distributions
|
||||
*
|
||||
* Sends a message with a list of distributions to
|
||||
* which the account is a creator, member, planned or volunteer
|
||||
* which the account is a creator, membership, planned or volunteer
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
@@ -42,7 +42,7 @@ final class distribution extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -60,11 +60,11 @@ final class distribution extends core
|
||||
// Initializing accounts
|
||||
$accounts = '*' . $localization['menu_accounts'] . ':* ' . ($model_account->database->count() ?? 0);
|
||||
|
||||
// Initializing members
|
||||
$members = '*' . $localization['menu_members'] . ':* ' . 0;
|
||||
// Initializing memberships
|
||||
$memberships = '*' . $localization['menu_memberships'] . ':* ' . 0;
|
||||
|
||||
// Initializing trusted members
|
||||
$members_trusted = '*' . $localization['menu_members_trusted'] . ':* ' . 0;
|
||||
// Initializing trusted memberships
|
||||
$memberships_trusted = '*' . $localization['menu_memberships_trusted'] . ':* ' . 0;
|
||||
|
||||
// Initializing planners
|
||||
$planners = '*' . $localization['menu_planners'] . ':* ' . 0;
|
||||
@@ -91,8 +91,8 @@ final class distribution extends core
|
||||
|
||||
$accounts
|
||||
|
||||
$members
|
||||
$members_trusted
|
||||
$memberships
|
||||
$memberships_trusted
|
||||
$planners
|
||||
$volunteers
|
||||
|
||||
@@ -125,7 +125,7 @@ final class distribution extends core
|
||||
'callback_data' => 'prjects'
|
||||
], */
|
||||
[
|
||||
'text' => '🐣 ' . $localization['menu_button_members'],
|
||||
'text' => '🐣 ' . $localization['menu_button_memberships'],
|
||||
'callback_data' => 'message'
|
||||
],
|
||||
[
|
||||
@@ -138,10 +138,9 @@ final class distribution extends core
|
||||
'remove_keyboard' => true
|
||||
],
|
||||
]
|
||||
)
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
});
|
||||
)->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
});
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
@@ -156,7 +155,7 @@ final class distribution extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,12 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram;
|
||||
namespace svoboda\antivertical\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\telegram,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -23,13 +24,59 @@ use Error as error;
|
||||
/**
|
||||
* Telegram middlewares
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram
|
||||
* @package svoboda\antivertical\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class middlewares extends core
|
||||
{
|
||||
/**
|
||||
* Telegram account (middleware)
|
||||
*
|
||||
* Initialize or registrate the account and write it to the `telegram` variable inside the `$context`
|
||||
*
|
||||
* @param context $context
|
||||
* @param node $next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function telegram(context $context, node $next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($context->get('stop')) return;
|
||||
|
||||
// Initializing the telegram account
|
||||
$telegram = $context->getEffectiveUser();
|
||||
|
||||
// Initializing the telegram model
|
||||
$model = new telegram();
|
||||
|
||||
// Initializing the telegram accont instance
|
||||
$instance = $model->initialize($telegram);
|
||||
|
||||
if ($instance instanceof telegram) {
|
||||
// Initialized the telegram account
|
||||
|
||||
// Writing the account into the context variable
|
||||
$context->set('telegram', $instance);
|
||||
|
||||
// Continuation of the process
|
||||
$next($context);
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize the telegram account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Account (middleware)
|
||||
*
|
||||
@@ -46,25 +93,42 @@ final class middlewares extends core
|
||||
if ($context->get('stop')) return;
|
||||
|
||||
// Initializing the telegram account
|
||||
$telegram = $context->getEffectiveUser();
|
||||
$telegram = $context->get('telegram');
|
||||
|
||||
// Initializing the account
|
||||
/* $account = new account()->initialize($telegram); */
|
||||
$account = (new account())->initialize($telegram);
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($telegram instanceof telegram) {
|
||||
// Initialized the account
|
||||
|
||||
// Writing the account into the context variable
|
||||
$context->set('account', $account);
|
||||
// Initializing the account model
|
||||
$model = new account();
|
||||
|
||||
// Continuation of the process
|
||||
$next($context);
|
||||
// Initializing the account
|
||||
$instance = $model->initialize($telegram);
|
||||
|
||||
if ($instance instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Writing the account into the context variable
|
||||
$context->set('account', $instance);
|
||||
|
||||
// Continuation of the process
|
||||
$next($context);
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
// Not initialized the telegram account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the telegram account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -92,7 +156,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($account->language) {
|
||||
@@ -120,7 +184,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -148,7 +212,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the language
|
||||
@@ -213,7 +277,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -241,7 +305,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($account->authorized_system) {
|
||||
@@ -286,7 +350,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -314,7 +378,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($account->authorized_contact) {
|
||||
@@ -359,7 +423,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -370,16 +434,16 @@ final class middlewares extends core
|
||||
}
|
||||
|
||||
/**
|
||||
* Join (middleware)
|
||||
* Membership (middleware)
|
||||
*
|
||||
* Check the account for access to join to distributions
|
||||
* Check the account for access to memberships
|
||||
*
|
||||
* @param context $context
|
||||
* @param node $next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function join(context $context, node $next): void
|
||||
public static function memberships(context $context, node $next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($context->get('stop')) return;
|
||||
@@ -387,7 +451,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -396,16 +460,16 @@ final class middlewares extends core
|
||||
if ($localization) {
|
||||
// Initialized localization
|
||||
|
||||
if ($account->authorized_joins) {
|
||||
// Authorized the account to joint to distributions
|
||||
if ($account->authorized_memberships) {
|
||||
// Authorized the account to create memberships
|
||||
|
||||
// Continuation of the process
|
||||
$next($context);
|
||||
} else {
|
||||
// Not authorized the account to joint to distributions
|
||||
// Not authorized the account to create memberships
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⛔ *' . $localization['not_authorized_joins'] . '*')
|
||||
$context->sendMessage('⛔ *' . $localization['not_authorized_memberships'] . '*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -432,7 +496,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -460,7 +524,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($account->authorized_settings) {
|
||||
@@ -505,7 +569,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -533,7 +597,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($account->authorized_system_settings) {
|
||||
@@ -578,7 +642,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -606,7 +670,7 @@ final class middlewares extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($account->authorized_system_distributions) {
|
||||
@@ -651,7 +715,7 @@ final class middlewares extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,15 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\account\localization;
|
||||
namespace svoboda\antivertical\models\telegram\processes\account\localization;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\telegram\account as telegram_account,
|
||||
svoboda\svoboder\models\telegram\buttons\account\localization\create as button_account_localization_create,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\telegram\account as telegram_account,
|
||||
svoboda\antivertical\models\telegram\buttons\account\localization\create as button_account_localization_create,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -25,7 +25,7 @@ use Error as error;
|
||||
/**
|
||||
* Account localization create process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\account\localization
|
||||
* @package svoboda\antivertical\models\telegram\processes\account\localization
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -53,7 +53,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -179,7 +179,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -202,7 +202,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -268,7 +268,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -293,7 +293,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -408,7 +408,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -433,7 +433,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -558,7 +558,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -583,7 +583,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -683,7 +683,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -707,7 +707,7 @@ final class create extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -899,7 +899,7 @@ final class create extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,15 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\account\localization;
|
||||
namespace svoboda\antivertical\models\telegram\processes\account\localization;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\telegram\account as telegram_account,
|
||||
svoboda\svoboder\models\telegram\buttons\account\localization\update as button_account_localization_update,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\telegram\account as telegram_account,
|
||||
svoboda\antivertical\models\telegram\buttons\account\localization\update as button_account_localization_update,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -28,7 +28,7 @@ use Error as error;
|
||||
/**
|
||||
* Account localization update process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\account\localization
|
||||
* @package svoboda\antivertical\models\telegram\processes\account\localization
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -57,7 +57,7 @@ final class update extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -162,7 +162,7 @@ final class update extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -185,7 +185,7 @@ final class update extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -251,7 +251,7 @@ final class update extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -276,7 +276,7 @@ final class update extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -394,7 +394,7 @@ final class update extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -419,7 +419,7 @@ final class update extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -548,7 +548,7 @@ final class update extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -572,7 +572,7 @@ final class update extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -764,7 +764,7 @@ final class update extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,14 +2,15 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\processes\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\declaration as button_distribution_declaration;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\declaration as button_distribution_declaration;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -24,7 +25,7 @@ use Error as error;
|
||||
/**
|
||||
* Distribution declaration process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\distribution
|
||||
* @package svoboda\antivertical\models\telegram\processes\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -52,7 +53,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -136,7 +137,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -159,7 +160,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -225,7 +226,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -250,7 +251,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -387,7 +388,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -412,7 +413,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -541,7 +542,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function ($message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -564,7 +565,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -658,7 +659,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -680,7 +681,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -888,7 +889,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -910,7 +911,7 @@ final class declaration extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1109,7 +1110,7 @@ final class declaration extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\processes\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -19,7 +19,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Distribution localization process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\distribution
|
||||
* @package svoboda\antivertical\models\telegram\processes\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -40,7 +40,7 @@ final class localization extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -130,7 +130,7 @@ final class localization extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -152,7 +152,7 @@ final class localization extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -227,7 +227,7 @@ final class localization extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
@@ -2,17 +2,17 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\processes\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\member,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\search as button_distribution_search,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands,
|
||||
svoboda\svoboder\models\traits\coordinates;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\membership,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\search as button_distribution_search,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands,
|
||||
svoboda\antivertical\models\traits\coordinates;
|
||||
|
||||
// Event-driven library for PHP
|
||||
use function React\Async\await;
|
||||
@@ -31,7 +31,7 @@ use Exception as exception,
|
||||
/**
|
||||
* Distribution search process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\distribution
|
||||
* @package svoboda\antivertical\models\telegram\processes\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -63,7 +63,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -152,7 +152,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -176,7 +176,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -236,7 +236,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -260,7 +260,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -445,8 +445,8 @@ final class search extends core
|
||||
if (count($distributions) > 0) {
|
||||
// Initialized distributions
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
foreach ($distributions as $distribution) {
|
||||
// Iterating over found distributions
|
||||
@@ -545,25 +545,25 @@ final class search extends core
|
||||
});
|
||||
}
|
||||
|
||||
// Searching for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution === $distribution->identifier && $member->account === $account->identifier,
|
||||
// Searching for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution === $distribution->identifier && $membership->account === $account->identifier,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
// Searching for the another member records
|
||||
$another = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution !== $distribution->identifier && $member->account === $account->identifier && $member->status !== 0,
|
||||
// Searching for the another membership records
|
||||
$another = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution !== $distribution->identifier && $membership->account === $account->identifier && $membership->status !== 0,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
// Initializing buffer of keyboard
|
||||
$keyboard = static::keyboard(
|
||||
distribution: $distribution,
|
||||
member: $another ?? $member,
|
||||
membership: $another ?? $membership,
|
||||
localization: $localization,
|
||||
messages: $account->authorized_messages === 1,
|
||||
joins: $account->authorized_joins === 1,
|
||||
memberships: $account->authorized_memberships === 1,
|
||||
);
|
||||
|
||||
/* if ($account->authorized_system_distributions) {
|
||||
@@ -734,7 +734,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -758,7 +758,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -950,7 +950,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -974,7 +974,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1175,7 +1175,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -1197,7 +1197,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1375,7 +1375,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1409,23 +1409,23 @@ final class search extends core
|
||||
// Initializing accepting status for the message
|
||||
$recognized = $recognized ? '🪽' : '';
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
// Searching for members records
|
||||
$members = $model_member->database->read(
|
||||
// Searching for memberships records
|
||||
$memberships = $model_membership->database->read(
|
||||
filter: fn(record $record) => $record->distribution === $distribution->identifier,
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBERS_AMOUNT
|
||||
amount: DISTRIBUTIONS_SEARCH_MEMBERSHIPS_AMOUNT
|
||||
) ?? [];
|
||||
|
||||
// Initializing amount of recognized members for the message
|
||||
$members_recognized = '*' . $localization[static::PROCESS . '_recognized'] . ':* ' . 0;
|
||||
// Initializing amount of recognized memberships for the message
|
||||
$memberships_recognized = '*' . $localization[static::PROCESS . '_recognized'] . ':* ' . 0;
|
||||
|
||||
// Initializing amount of members for the message
|
||||
$amount = '*' . $localization[static::PROCESS . '_members'] . ':* ' . count(array_filter($members, fn(record $member) => $member?->status === 2));
|
||||
// Initializing amount of memberships for the message
|
||||
$amount = '*' . $localization[static::PROCESS . '_memberships'] . ':* ' . count(array_filter($memberships, fn(record $membership) => $membership?->status === 2));
|
||||
|
||||
// Initializing planners
|
||||
$planners = '*' . $localization[static::PROCESS . '_planners'] . ':* ' . count(array_filter($members, fn(record $member) => $member?->status === 1));
|
||||
$planners = '*' . $localization[static::PROCESS . '_planners'] . ':* ' . count(array_filter($memberships, fn(record $membership) => $membership?->status === 1));
|
||||
|
||||
// Initializing volunteers
|
||||
$volunteers = '*' . $localization[static::PROCESS . '_volunteers'] . ':* ' . 0;
|
||||
@@ -1441,7 +1441,7 @@ final class search extends core
|
||||
$distribution->identifier *$name* $recognized
|
||||
|
||||
$amount
|
||||
$members_recognized
|
||||
$memberships_recognized
|
||||
$planners
|
||||
$volunteers
|
||||
|
||||
@@ -1457,21 +1457,21 @@ final class search extends core
|
||||
* Generate inline keyboard for the distribution
|
||||
*
|
||||
* @param record $distribution The distribution
|
||||
* @param record|null $member The distribution member
|
||||
* @param record|null $membership The distribution membership
|
||||
* @param array $localization The account localization
|
||||
* @param bool $planned Is the account planned to join to the distribution?
|
||||
* @param bool $joined Is the account joined to the distribution?
|
||||
* @param bool $messages Generate messages buttons? (is the account allowed to send messages?)
|
||||
* @param bool $joins Generate joining buttons? (is the account allowed to join?)
|
||||
* @param bool $memberships Generate memberships buttons? (is the account allowed to join?)
|
||||
*
|
||||
* @return array Generated inline keyboard
|
||||
*/
|
||||
public static function keyboard(
|
||||
record $distribution,
|
||||
?record $member,
|
||||
?record $membership,
|
||||
array $localization,
|
||||
bool $messages = false,
|
||||
bool $joins = false,
|
||||
bool $memberships = false,
|
||||
): array {
|
||||
// Initializing the buffer of keyboard
|
||||
$keyboard = [
|
||||
@@ -1494,8 +1494,8 @@ final class search extends core
|
||||
'callback_data' => static::PROCESS . '_volunteers'
|
||||
],
|
||||
[
|
||||
'text' => '🐣 ' . $localization[static::PROCESS . '_button_members'],
|
||||
'callback_data' => static::PROCESS . '_members'
|
||||
'text' => '🐣 ' . $localization[static::PROCESS . '_button_memberships'],
|
||||
'callback_data' => static::PROCESS . '_memberships'
|
||||
]
|
||||
]
|
||||
]
|
||||
@@ -1506,17 +1506,17 @@ final class search extends core
|
||||
],
|
||||
], */;
|
||||
|
||||
if ($joins) {
|
||||
// Requested joining buttons
|
||||
if ($memberships) {
|
||||
// Requested memberships buttons
|
||||
|
||||
if ($member instanceof record) {
|
||||
// Initialized the member
|
||||
if ($membership instanceof record) {
|
||||
// Initialized the membership
|
||||
|
||||
if ($member->distribution === $distribution->identifier) {
|
||||
// The member distribution matched the distribution
|
||||
if ($membership->distribution === $distribution->identifier) {
|
||||
// The membership distribution matched the distribution
|
||||
|
||||
if ($member->status === 2) {
|
||||
// The member was joined to the distribution
|
||||
if ($membership->status === 2) {
|
||||
// The membership was joined to the distribution
|
||||
|
||||
// Writing the joining buttons into the buffer of keyboard
|
||||
$keyboard[] = [
|
||||
@@ -1525,8 +1525,8 @@ final class search extends core
|
||||
'callback_data' => static::PROCESS . '_leave'
|
||||
]
|
||||
];
|
||||
} else if ($member->status === 1) {
|
||||
// The member was planning to join to the distribution
|
||||
} else if ($membership->status === 1) {
|
||||
// The membership was planning to join to the distribution
|
||||
|
||||
// Writing the joining buttons into the buffer of keyboard
|
||||
$keyboard[] = [
|
||||
@@ -1540,7 +1540,7 @@ final class search extends core
|
||||
]
|
||||
];
|
||||
} else {
|
||||
// The member status is unknown
|
||||
// The membership status is unknown
|
||||
|
||||
// Writing the joining buttons into the buffer of keyboard
|
||||
$keyboard[] = [
|
||||
@@ -1555,16 +1555,16 @@ final class search extends core
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// The member distribution not matched the distribution
|
||||
// The membership distribution not matched the distribution
|
||||
|
||||
if ($member->status === 2) {
|
||||
// The member was joined to the distribution
|
||||
if ($membership->status === 2) {
|
||||
// The membership was joined to the distribution
|
||||
|
||||
} else if ($member->status === 1) {
|
||||
// The member was planning to join to the distribution
|
||||
} else if ($membership->status === 1) {
|
||||
// The membership was planning to join to the distribution
|
||||
|
||||
} else {
|
||||
// The member status is unknown
|
||||
// The membership status is unknown
|
||||
|
||||
// Writing the joining buttons into the buffer of keyboard
|
||||
$keyboard[] = [
|
||||
@@ -1580,7 +1580,7 @@ final class search extends core
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not initialized the member
|
||||
// Not initialized the membership
|
||||
|
||||
// Writing the joining buttons into the buffer of keyboard
|
||||
$keyboard[] = [
|
@@ -2,17 +2,17 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\distribution;
|
||||
namespace svoboda\antivertical\models\telegram\processes\distribution;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\member,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\select as button_distribution_select,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands,
|
||||
svoboda\svoboder\models\traits\coordinates;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\membership,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\select as button_distribution_select,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands,
|
||||
svoboda\antivertical\models\traits\coordinates;
|
||||
|
||||
// Event-driven library for PHP
|
||||
use function React\Async\await;
|
||||
@@ -31,7 +31,7 @@ use Exception as exception,
|
||||
/**
|
||||
* Distribution select process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\distribution
|
||||
* @package svoboda\antivertical\models\telegram\processes\distribution
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -67,7 +67,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -173,7 +173,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -198,7 +198,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -260,7 +260,7 @@ final class select extends core
|
||||
// Searching for the distribution localizations records
|
||||
$distribution_localizations = $model_distribution->localization->database->read(
|
||||
filter: fn(record $localization) => $localization->distribution === $distribution['distribution']->identifier,
|
||||
amount: MEMBERS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
amount: MEMBERSHIPS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
);
|
||||
|
||||
if (count($distribution_localizations) > 0) {
|
||||
@@ -399,7 +399,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -424,7 +424,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -481,7 +481,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -506,7 +506,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -563,7 +563,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -587,7 +587,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -772,8 +772,8 @@ final class select extends core
|
||||
if (count($distributions) > 0) {
|
||||
// Initialized distributions
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
foreach ($distributions as $distribution) {
|
||||
// Iterating over found distributions
|
||||
@@ -872,9 +872,9 @@ final class select extends core
|
||||
});
|
||||
}
|
||||
|
||||
// Search for the member record
|
||||
$member = $model_member->database->read(
|
||||
filter: fn(record $member) => $member->distribution === $distribution->identifier && $member->account === $account->identifier,
|
||||
// Search for the membership record
|
||||
$membership = $model_membership->database->read(
|
||||
filter: fn(record $membership) => $membership->distribution === $distribution->identifier && $membership->account === $account->identifier,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
@@ -1048,7 +1048,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1072,7 +1072,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1264,7 +1264,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1288,7 +1288,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1489,7 +1489,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
@@ -1511,7 +1511,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1689,7 +1689,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\language;
|
||||
namespace svoboda\antivertical\models\telegram\processes\language;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\enumerations\language;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\enumerations\language;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
@@ -18,7 +18,7 @@ use mirzaev\baza\record;
|
||||
/**
|
||||
* Telegram language select
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\language
|
||||
* @package svoboda\antivertical\models\telegram\processes\language
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -43,7 +43,7 @@ final class select extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -96,7 +96,7 @@ final class select extends core
|
||||
$keyboard[$row === 0 && empty($keyboard[0]) ? 0 : ++$row] = [
|
||||
[
|
||||
'text' => '🗂 ' . $localization['select_language_button_add'],
|
||||
'url' => 'https://git.svoboda.works/svoboda/svoboder/src/branch/stable/svoboda/svoboder/system/localizations'
|
||||
'url' => 'https://git.svoboda.works/svoboda/antivertical/src/branch/stable/svoboda/antivertical/system/localizations'
|
||||
]
|
||||
];
|
||||
|
||||
@@ -138,7 +138,7 @@ final class select extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
@@ -2,18 +2,18 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram\processes\member;
|
||||
namespace svoboda\antivertical\models\telegram\processes\membership;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\member,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\telegram\buttons\member\search as button_member_search,
|
||||
svoboda\svoboder\models\enumerations\member\status,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\commands,
|
||||
svoboda\svoboder\models\traits\coordinates;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\membership,
|
||||
svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\telegram\buttons\membership\search as button_membership_search,
|
||||
svoboda\antivertical\models\enumerations\membership\status,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\commands,
|
||||
svoboda\antivertical\models\traits\coordinates;
|
||||
|
||||
// Event-driven library for PHP
|
||||
use function React\Async\await;
|
||||
@@ -30,9 +30,9 @@ use Exception as exception,
|
||||
Error as error;
|
||||
|
||||
/**
|
||||
* Member search process
|
||||
* Membership search process
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram\processes\member
|
||||
* @package svoboda\antivertical\models\telegram\processes\membership
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -48,12 +48,12 @@ final class search extends core
|
||||
*
|
||||
* @var const string PROCESS Name of the process in the telegram user buffer
|
||||
*/
|
||||
public const string PROCESS = 'member_search';
|
||||
public const string PROCESS = 'membership_search';
|
||||
|
||||
/**
|
||||
* Start
|
||||
*
|
||||
* Starting the member search process
|
||||
* Starting the membership search process
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
@@ -64,7 +64,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -123,7 +123,7 @@ final class search extends core
|
||||
// Searching for the distribution localizations records
|
||||
$distribution_localizations = $model_distribution->localization->database->read(
|
||||
filter: fn(record $localization) => $localization->distribution === $distribution['distribution']->identifier,
|
||||
amount: MEMBERS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
amount: MEMBERSHIPS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
);
|
||||
|
||||
if (count($distribution_localizations) > 0) {
|
||||
@@ -221,20 +221,20 @@ final class search extends core
|
||||
->then(function () use ($context) {
|
||||
// Writing into the telegram user buffer
|
||||
|
||||
// Sending the list of found member and menu
|
||||
// Sending the list of found membership and menu
|
||||
static::menu($context);
|
||||
});
|
||||
} else {
|
||||
// Not initialized the distribution
|
||||
|
||||
// Sending the list of found member and menu
|
||||
// Sending the list of found membership and menu
|
||||
static::menu($context);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Not found started search process
|
||||
|
||||
// Initializing the member search buffer
|
||||
// Initializing the membership search buffer
|
||||
$search = [
|
||||
'name' => null,
|
||||
'distribution' => $distribution,
|
||||
@@ -252,7 +252,7 @@ final class search extends core
|
||||
->then(function (message $message) use ($context, $account, $localization) {
|
||||
// Sended the message
|
||||
|
||||
// Sending the list of found member and menu
|
||||
// Sending the list of found membership and menu
|
||||
static::menu($context);
|
||||
});
|
||||
});
|
||||
@@ -286,7 +286,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -299,7 +299,7 @@ final class search extends core
|
||||
/**
|
||||
* End
|
||||
*
|
||||
* Ending the member search process
|
||||
* Ending the membership search process
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
@@ -310,7 +310,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -340,8 +340,8 @@ final class search extends core
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
|
||||
// Sending the members menu
|
||||
commands::members($context);
|
||||
// Sending the memberships menu
|
||||
commands::memberships($context);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -350,8 +350,8 @@ final class search extends core
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
|
||||
// Sending the members menu
|
||||
commands::members($context);
|
||||
// Sending the memberships menu
|
||||
commands::memberships($context);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -370,7 +370,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -383,7 +383,7 @@ final class search extends core
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Sends the list of found members and menu with parameters: name, distribution, status
|
||||
* Sends the list of found memberships and menu with parameters: name, distribution, status
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
@@ -396,7 +396,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
@@ -423,19 +423,19 @@ final class search extends core
|
||||
$keyboard = [
|
||||
[
|
||||
[
|
||||
'text' => empty($search['name']) ? '🔴 ' . $localization[static::PROCESS . '_button_name'] : '🟢 ' . $localization['member_search_button_name'] . ': ' . $search['name'],
|
||||
'text' => empty($search['name']) ? '🔴 ' . $localization[static::PROCESS . '_button_name'] : '🟢 ' . $localization['membership_search_button_name'] . ': ' . $search['name'],
|
||||
'callback_data' => static::PROCESS . '_name'
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => empty($search['distribution']['distribution']) || empty($search['distribution']['localization']) ? '🔴 ' . $localization[static::PROCESS . '_button_distribution'] : '🟢 ' . $localization['member_search_button_distribution'] . ': ' . $search['distribution']['localization']->name,
|
||||
'text' => empty($search['distribution']['distribution']) || empty($search['distribution']['localization']) ? '🔴 ' . $localization[static::PROCESS . '_button_distribution'] : '🟢 ' . $localization['membership_search_button_distribution'] . ': ' . $search['distribution']['localization']->name,
|
||||
'callback_data' => static::PROCESS . '_distribution'
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
'text' => ($search['status']->emoji() ?? status::unknown->emoji()) . ' ' . $localization['member_search_button_status'] . ': ' . $localization['member_search_button_status_' . ($search['status']->value ?? status::unknown->value)],
|
||||
'text' => ($search['status']->emoji() ?? status::unknown->emoji()) . ' ' . $localization['membership_search_button_status'] . ': ' . $localization['membership_search_button_status_' . ($search['status']->value ?? status::unknown->value)],
|
||||
'callback_data' => static::PROCESS . '_status'
|
||||
]
|
||||
],
|
||||
@@ -446,11 +446,11 @@ final class search extends core
|
||||
->then(function () use ($context, $account, $language, $localization, $search, $keyboard) {
|
||||
// Deinitialized the conversation process
|
||||
|
||||
// Initializing the member model
|
||||
$model_member = new member;
|
||||
// Initializing the membership model
|
||||
$model_membership = new membership;
|
||||
|
||||
// Initializing amount of readed members per page
|
||||
$page = MEMBERS_SEARCH_PAGE;
|
||||
// Initializing amount of readed memberships per page
|
||||
$page = MEMBERSHIPS_SEARCH_PAGE;
|
||||
|
||||
if (
|
||||
empty($search['name']) &&
|
||||
@@ -460,8 +460,8 @@ final class search extends core
|
||||
) {
|
||||
// Each search parameter is empty
|
||||
|
||||
// Search for members
|
||||
$members = $model_member->database->read(
|
||||
// Search for memberships
|
||||
$memberships = $model_membership->database->read(
|
||||
amount: $page + 1,
|
||||
offset: $search['page'] < 1 ? 0 : $page * $search['page']
|
||||
);
|
||||
@@ -471,9 +471,9 @@ final class search extends core
|
||||
// Initializing the account model
|
||||
$model_account = new account;
|
||||
|
||||
// Search for members
|
||||
$members = $model_member->database->read(
|
||||
filter: function (record $member) use ($search, $model_account) {
|
||||
// Search for memberships
|
||||
$memberships = $model_membership->database->read(
|
||||
filter: function (record $membership) use ($search, $model_account) {
|
||||
// Initializing the matched buffer
|
||||
$matched = false;
|
||||
|
||||
@@ -482,8 +482,8 @@ final class search extends core
|
||||
|
||||
// Initializing the account localizations
|
||||
$localizations = $model_account->localization->database->read(
|
||||
filter: fn(record $localization) => $localization->account === $member->account,
|
||||
amount: MEMBERS_SEARCH_ACCOUNT_LOCALIZATIONS_AMOUNT
|
||||
filter: fn(record $localization) => $localization->account === $membership->account,
|
||||
amount: MEMBERSHIPS_SEARCH_ACCOUNT_LOCALIZATIONS_AMOUNT
|
||||
);
|
||||
|
||||
// Initializing the result status
|
||||
@@ -498,7 +498,7 @@ final class search extends core
|
||||
foreach ($parts as $part) {
|
||||
// Iterating over localization name parts
|
||||
|
||||
if (levenshtein($part, $search['name']) <= MEMBERS_SEARCH_MEMBER_NAME_LEVENSHTEIN_DISTANCE) {
|
||||
if (levenshtein($part, $search['name']) <= MEMBERSHIPS_SEARCH_membership_NAME_LEVENSHTEIN_DISTANCE) {
|
||||
// Names matched by Levenshtein function
|
||||
|
||||
// Reinitializing the matched buffer
|
||||
@@ -526,7 +526,7 @@ final class search extends core
|
||||
if (!empty($search['distribution']['distribution'])) {
|
||||
// Requested search by distribution
|
||||
|
||||
if ($member->distribution === $search['distribution']['distribution']?->identifier) {
|
||||
if ($membership->distribution === $search['distribution']['distribution']?->identifier) {
|
||||
// Distributions matched
|
||||
|
||||
// Reinitializing the matched buffer
|
||||
@@ -542,7 +542,7 @@ final class search extends core
|
||||
if ($search['status'] instanceof status) {
|
||||
// Requested search by status
|
||||
|
||||
if ($member->status === $search['status']->value) {
|
||||
if ($membership->status === $search['status']->value) {
|
||||
// Statuses matched
|
||||
|
||||
// Reinitializing the matched buffer
|
||||
@@ -564,10 +564,10 @@ final class search extends core
|
||||
}
|
||||
|
||||
// Initializing the next page existence status
|
||||
$next = count($members) > $page;
|
||||
$next = count($memberships) > $page;
|
||||
|
||||
// Deleting the additional readed members
|
||||
unset($members[$page]);
|
||||
// Deleting the additional readed memberships
|
||||
unset($memberships[$page]);
|
||||
|
||||
// Initializing the title
|
||||
$title = '🔍 *' . $localization[static::PROCESS . '_title'] . '*';
|
||||
@@ -584,14 +584,14 @@ final class search extends core
|
||||
'remove_keyboard' => true
|
||||
],
|
||||
]
|
||||
)->then(function (message $message) use ($context, $account, $language, $localization, $search, $page, $next, $members) {
|
||||
)->then(function (message $message) use ($context, $account, $language, $localization, $search, $page, $next, $memberships) {
|
||||
// Sended the message
|
||||
|
||||
if (count($members) > 0) {
|
||||
// Initialized members
|
||||
if (count($memberships) > 0) {
|
||||
// Initialized memberships
|
||||
|
||||
foreach ($members as $member) {
|
||||
// Iterating over found members
|
||||
foreach ($memberships as $membership) {
|
||||
// Iterating over found memberships
|
||||
|
||||
// Declaring the buffer of localized values
|
||||
$values = null;
|
||||
@@ -601,12 +601,12 @@ final class search extends core
|
||||
|
||||
// Initializing localizations
|
||||
$localizations = $model_account->localization->database->read(
|
||||
filter: fn(record $localization) => $localization->account === $member->account,
|
||||
amount: MEMBERS_SEARCH_ACCOUNT_LOCALIZATIONS_AMOUNT
|
||||
filter: fn(record $localization) => $localization->account === $membership->account,
|
||||
amount: MEMBERSHIPS_SEARCH_ACCOUNT_LOCALIZATIONS_AMOUNT
|
||||
);
|
||||
|
||||
if (count($localizations) > 0) {
|
||||
// Initialized the members localizations
|
||||
// Initialized the memberships localizations
|
||||
|
||||
foreach ($localizations as $record) {
|
||||
// Iterating over localizations
|
||||
@@ -645,22 +645,22 @@ final class search extends core
|
||||
// Initializing the account model
|
||||
$model_account = new account;
|
||||
|
||||
// Initializing the member account
|
||||
$member_account = $model_account->database->read(
|
||||
filter: fn(record $account) => $account->identifier === $member->account,
|
||||
// Initializing the membership account
|
||||
$membership_account = $model_account->database->read(
|
||||
filter: fn(record $account) => $account->identifier === $membership->account,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($member_account instanceof record) {
|
||||
// Initialized the member account
|
||||
if ($membership_account instanceof account) {
|
||||
// Initialized the membership account
|
||||
|
||||
foreach ($localizations as $record) {
|
||||
// Iterating over localizations
|
||||
|
||||
if ($record->language === $member_account->language) {
|
||||
// Found localization by the member account language
|
||||
if ($record->language === $membership_account->language) {
|
||||
// Found localization by the membership account language
|
||||
|
||||
// Initializing localization by the member account language
|
||||
// Initializing localization by the membership account language
|
||||
$values = $record;
|
||||
|
||||
// Exit (success)
|
||||
@@ -670,7 +670,7 @@ final class search extends core
|
||||
}
|
||||
|
||||
if (is_null($values)) {
|
||||
// Not initialized localization by the member account language
|
||||
// Not initialized localization by the membership account language
|
||||
|
||||
// Initializing localization by the first found record
|
||||
$values = $localizations[0];
|
||||
@@ -678,7 +678,7 @@ final class search extends core
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not initialized the members localizations
|
||||
// Not initialized the memberships localizations
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *' . $localization[static::PROCESS . '_not_localized'] . '*')
|
||||
@@ -692,7 +692,7 @@ final class search extends core
|
||||
|
||||
// Initializing buffer of keyboard
|
||||
$keyboard = static::keyboard(
|
||||
member: $member,
|
||||
membership: $membership,
|
||||
localization: $localization,
|
||||
messages: $account->authorized_messages === 1,
|
||||
);
|
||||
@@ -718,7 +718,7 @@ final class search extends core
|
||||
static::message(
|
||||
context: $context,
|
||||
language: $language,
|
||||
member: $member,
|
||||
membership: $membership,
|
||||
localization: $localization,
|
||||
name: $values?->name,
|
||||
recognized: false
|
||||
@@ -794,7 +794,7 @@ final class search extends core
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized members
|
||||
// Not initialized memberships
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage(
|
||||
@@ -834,8 +834,8 @@ final class search extends core
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
|
||||
// Sending the members menu
|
||||
commands::members($context);
|
||||
// Sending the memberships menu
|
||||
commands::memberships($context);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -867,7 +867,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -880,7 +880,7 @@ final class search extends core
|
||||
/**
|
||||
* Name
|
||||
*
|
||||
* Write name into the member search buffer
|
||||
* Write name into the membership search buffer
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
*
|
||||
@@ -891,7 +891,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -947,7 +947,7 @@ final class search extends core
|
||||
// Initializing the old name
|
||||
$old = empty($search['name']) ? '_' . $localization['empty'] . '_' : $search['name'];
|
||||
|
||||
// Writing into the member search process buffer
|
||||
// Writing into the membership search process buffer
|
||||
$search['name'] = $new;
|
||||
|
||||
// Writing to the telegram user buffer
|
||||
@@ -1001,7 +1001,7 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
|
||||
// Requesting to enter name again
|
||||
button_member_search::name($context);
|
||||
button_membership_search::name($context);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -1016,7 +1016,7 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
|
||||
// Requesting to enter name again
|
||||
button_member_search::name($context);
|
||||
button_membership_search::name($context);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -1031,7 +1031,7 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
|
||||
// Requesting to enter name again
|
||||
button_member_search::name($context);
|
||||
button_membership_search::name($context);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -1046,7 +1046,7 @@ final class search extends core
|
||||
$context->endConversation();
|
||||
|
||||
// Requesting to enter name again
|
||||
button_member_search::name($context);
|
||||
button_membership_search::name($context);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
@@ -1060,8 +1060,8 @@ final class search extends core
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
||||
|
||||
// Sending the members menu
|
||||
commands::members($context);
|
||||
// Sending the memberships menu
|
||||
commands::memberships($context);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1081,7 +1081,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1094,10 +1094,10 @@ final class search extends core
|
||||
/**
|
||||
* Status
|
||||
*
|
||||
* Write status into the member search buffer
|
||||
* Write status into the membership search buffer
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
* @param status $status The member status
|
||||
* @param status $status The membership status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -1106,7 +1106,7 @@ final class search extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -1126,7 +1126,7 @@ final class search extends core
|
||||
// Initializing the old status
|
||||
$old = empty($search['status']) ? '_' . $localization['empty'] . '_' : $search['status']->emoji() . ' ' . $localization[static::PROCESS . '_status_' . $search['status']->value];
|
||||
|
||||
// Writing into the member search process buffer
|
||||
// Writing into the membership search process buffer
|
||||
$search['status'] = $status;
|
||||
|
||||
// Writing to the telegram user buffer
|
||||
@@ -1176,7 +1176,7 @@ final class search extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Sended the message
|
||||
|
||||
@@ -1190,20 +1190,20 @@ final class search extends core
|
||||
/**
|
||||
* Message text
|
||||
*
|
||||
* Generate text with the distribution member infornation
|
||||
* Generate text with the distribution membership infornation
|
||||
*
|
||||
* @param context $context Request data from Telegram
|
||||
* @param record $member The distribution member
|
||||
* @param record $membership The distribution membership
|
||||
* @param language $language The account language
|
||||
* @param array $localization The account localization
|
||||
* @param string|null $name Localized name of the member
|
||||
* @param bool $recognized Add the icon for recognized distribution member?
|
||||
* @param string|null $name Localized name of the membership
|
||||
* @param bool $recognized Add the icon for recognized distribution membership?
|
||||
*
|
||||
* @return string Generated text
|
||||
*/
|
||||
public static function message(
|
||||
context $context,
|
||||
record $member,
|
||||
record $membership,
|
||||
language $language,
|
||||
array $localization,
|
||||
?string $name = null,
|
||||
@@ -1221,7 +1221,7 @@ final class search extends core
|
||||
|
||||
// Searching for the distribution
|
||||
$distribution = $model_distribution->database->read(
|
||||
filter: fn(record $distribution) => $distribution->identifier === $member->distribution,
|
||||
filter: fn(record $distribution) => $distribution->identifier === $membership->distribution,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
@@ -1231,7 +1231,7 @@ final class search extends core
|
||||
// Searching for the distribution localizations records
|
||||
$distribution_localizations = $model_distribution->localization->database->read(
|
||||
filter: fn(record $localization) => $localization->distribution === $distribution->identifier,
|
||||
amount: MEMBERS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
amount: MEMBERSHIPS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT
|
||||
);
|
||||
|
||||
// Declaring the buffer of the distribution localization
|
||||
@@ -1327,20 +1327,20 @@ final class search extends core
|
||||
// Initializing relation for the message
|
||||
$relation = '*' . $localization[static::PROCESS . '_distribution'] . ':* ' . $distribution_localization->name;
|
||||
|
||||
// Initializing the member status
|
||||
$status = status::from($member->status) ?? status::unknown;
|
||||
// Initializing the membership status
|
||||
$status = status::from($membership->status) ?? status::unknown;
|
||||
|
||||
// Initializing status for the message
|
||||
$_status = '*' . $localization[static::PROCESS . '_status'] . ':* ' . $status->emoji() . ' ' . $localization[static::PROCESS . "_status_$status->value"];
|
||||
|
||||
/* // Initializing amount of recognized members for the message
|
||||
$members_recognized = '*' . $localization[static::PROCESS . '_recognized'] . ':* ' . 0;
|
||||
/* // Initializing amount of recognized memberships for the message
|
||||
$memberships_recognized = '*' . $localization[static::PROCESS . '_recognized'] . ':* ' . 0;
|
||||
|
||||
// Initializing amount of members for the message
|
||||
$amount = '*' . $localization[static::PROCESS . '_members'] . ':* ' . count(array_filter($members, fn(record $member) => $member?->status === 2));
|
||||
// Initializing amount of memberships for the message
|
||||
$amount = '*' . $localization[static::PROCESS . '_memberships'] . ':* ' . count(array_filter($memberships, fn(record $membership) => $membership?->status === 2));
|
||||
|
||||
// Initializing planners
|
||||
$planners = '*' . $localization[static::PROCESS . '_planners'] . ':* ' . count(array_filter($members, fn(record $member) => $member?->status === 1));
|
||||
$planners = '*' . $localization[static::PROCESS . '_planners'] . ':* ' . count(array_filter($memberships, fn(record $membership) => $membership?->status === 1));
|
||||
|
||||
// Initializing volunteers
|
||||
$volunteers = '*' . $localization[static::PROCESS . '_volunteers'] . ':* ' . 0;
|
||||
@@ -1353,7 +1353,7 @@ final class search extends core
|
||||
|
||||
// Exit (success)
|
||||
return <<<TXT
|
||||
$distribution->identifier:$member->identifier:$member->account *$name* $recognized
|
||||
$distribution->identifier:$membership->identifier:$membership->account *$name* $recognized
|
||||
|
||||
$relation
|
||||
$_status
|
||||
@@ -1371,16 +1371,16 @@ final class search extends core
|
||||
/**
|
||||
* Keyboard (inline)
|
||||
*
|
||||
* Generate inline keyboard for the member
|
||||
* Generate inline keyboard for the membership
|
||||
*
|
||||
* @param record $member The member
|
||||
* @param record $membership The membership
|
||||
* @param array $localization The account localization
|
||||
* @param bool $messages Generate messages buttons? (is the account allowed to send messages?)
|
||||
*
|
||||
* @return array Generated inline keyboard
|
||||
*/
|
||||
public static function keyboard(
|
||||
record $member,
|
||||
record $membership,
|
||||
array $localization,
|
||||
bool $messages = false,
|
||||
): array {
|
@@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\telegram;
|
||||
namespace svoboda\antivertical\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\middlewares;
|
||||
use svoboda\antivertical\models\core,
|
||||
svoboda\antivertical\models\account,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\middlewares;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Zanzara,
|
||||
@@ -25,7 +25,7 @@ use Error as error;
|
||||
/**
|
||||
* Telegram settings
|
||||
*
|
||||
* @package svoboda\svoboder\models\telegram
|
||||
* @package svoboda\antivertical\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
@@ -47,7 +47,7 @@ final class settings extends core
|
||||
// Initializing the account
|
||||
$account = $context->get('account');
|
||||
|
||||
if ($account instanceof record) {
|
||||
if ($account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
@@ -146,7 +146,7 @@ final class settings extends core
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
||||
->then(function (message $message) use ($context) {
|
||||
// Ending the conversation process
|
||||
$context->endConversation();
|
157
svoboda/antivertical/system/models/traits/ar.php
Normal file
157
svoboda/antivertical/system/models/traits/ar.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\antivertical\models\traits;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\antivertical\models\core;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime,
|
||||
LogicException as exception_logic,
|
||||
InvalidArgumentException as exception_invalid_argument;
|
||||
|
||||
/**
|
||||
* AR
|
||||
*
|
||||
* The "Active Record" architectural pattern
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/Active_record_pattern Active Record
|
||||
*
|
||||
* @package svoboda\antivertical\models\traits
|
||||
*
|
||||
* @method self __construct(?record $record) Constructor
|
||||
* @method static|false read(callable $filter) Read from the database
|
||||
* @method static|false update() Update the record in the database
|
||||
* @method void __set(string $name, mixed $value = null) Write into the database record property
|
||||
* @method mixed __get(string $name) Read from the database record property
|
||||
* @method bool __isset(string $name) Check that the database record property is initialized
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
trait ar
|
||||
{
|
||||
/**
|
||||
* Read
|
||||
*
|
||||
* Search for the record in the database
|
||||
*
|
||||
* @return static|false The record impementator object, if found
|
||||
*/
|
||||
public function read(callable $filter): static|false
|
||||
{
|
||||
// Reading from the database
|
||||
$record = $this->database->read(
|
||||
filter: $filter,
|
||||
amount: 1,
|
||||
offset: 0
|
||||
)[0] ?? false;
|
||||
|
||||
if ($record instanceof record) {
|
||||
// Initialized the record
|
||||
|
||||
// Exit (success)
|
||||
return new static($record);
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update
|
||||
*
|
||||
* Write the record new values into the database
|
||||
*
|
||||
* @return static|false The updated record, if updated (new instance)
|
||||
*/
|
||||
public function update(): static|false
|
||||
{
|
||||
// Writing into the database
|
||||
$record = $this->database->read(
|
||||
filter: fn(record $record) => $record->identifier === $this->record->identifier,
|
||||
update: function (record &$record) {
|
||||
$this->record->updated = svoboda::timestamp();
|
||||
$record = $this->record;
|
||||
},
|
||||
amount: 1,
|
||||
offset: 0
|
||||
)[0] ?? false;
|
||||
|
||||
if ($record instanceof record) {
|
||||
// Initialized the record
|
||||
|
||||
// Exit (success)
|
||||
return new static($record);
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* Write into the database record property
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
* @param mixed $value Value of the property
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $name, mixed $value = null): void
|
||||
{
|
||||
match ($name) {
|
||||
'record' => $this->record = $value,
|
||||
default => $this->record->{$name} = $value
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Read
|
||||
*
|
||||
* Read from the database record property
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return mixed Content of the property, if they are found
|
||||
*/
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
return match ($name) {
|
||||
'record' => $this->record,
|
||||
default => $this->record->{$name}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for initialization
|
||||
*
|
||||
* Check that the database record property is initialized
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return bool The property is initialized?
|
||||
*/
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
// Check of initialization of the property and exit (success)
|
||||
return match ($name) {
|
||||
'record' => isset($this->record),
|
||||
default => isset($this->record->{$name})
|
||||
};
|
||||
}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models\traits;
|
||||
namespace svoboda\antivertical\models\traits;
|
||||
|
||||
/**
|
||||
* Coordinates
|
||||
@@ -11,7 +11,7 @@ namespace svoboda\svoboder\models\traits;
|
||||
*
|
||||
* @method int|float distance(float $from_latitude, float $from_longitude, float $to_latitude, float $to_longitude, int $planet)
|
||||
*
|
||||
* @package svoboda\svoboder\models\traits
|
||||
* @package svoboda\antivertical\models\traits
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
@@ -2,23 +2,23 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder;
|
||||
namespace svoboda\antivertical;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\localization\distribution as distribution_localization,
|
||||
svoboda\svoboder\models\telegram\middlewares,
|
||||
svoboda\svoboder\models\telegram\commands,
|
||||
svoboda\svoboder\models\telegram\buttons,
|
||||
svoboda\svoboder\models\telegram\selections,
|
||||
svoboda\svoboder\models\telegram\settings,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\registration as process_distribution_registration,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\search as process_distribution_search,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\registration as button_distribution_registration,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\search as button_distribution_search,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\administration as button_distribution_administration,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\localization as process_distribution_localization;
|
||||
use svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\localization\distribution as distribution_localization,
|
||||
svoboda\antivertical\models\telegram\middlewares,
|
||||
svoboda\antivertical\models\telegram\commands,
|
||||
svoboda\antivertical\models\telegram\buttons,
|
||||
svoboda\antivertical\models\telegram\selections,
|
||||
svoboda\antivertical\models\telegram\settings,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\registration as process_distribution_registration,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\search as process_distribution_search,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\registration as button_distribution_registration,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\search as button_distribution_search,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\administration as button_distribution_administration,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\localization as process_distribution_localization;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\core,
|
@@ -2,32 +2,32 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder;
|
||||
namespace svoboda\antivertical;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\localization\distribution as distribution_localization,
|
||||
svoboda\svoboder\models\telegram\middlewares,
|
||||
svoboda\svoboder\models\telegram\commands,
|
||||
svoboda\svoboder\models\telegram\buttons,
|
||||
svoboda\svoboder\models\telegram\account,
|
||||
svoboda\svoboder\models\telegram\settings,
|
||||
svoboda\svoboder\models\enumerations\member\status,
|
||||
svoboda\svoboder\models\enumerations\language,
|
||||
svoboda\svoboder\models\telegram\processes\member\search as process_member_search,
|
||||
svoboda\svoboder\models\telegram\buttons\member\search as button_member_search,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\declaration as process_distribution_declaration,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\search as process_distribution_search,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\select as process_distribution_select,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\declaration as button_distribution_declaration,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\search as button_distribution_search,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\select as button_distribution_select,
|
||||
svoboda\svoboder\models\telegram\processes\account\localization\create as process_account_localization_create,
|
||||
svoboda\svoboder\models\telegram\processes\account\localization\update as process_account_localization_update,
|
||||
svoboda\svoboder\models\telegram\buttons\account\localization\create as button_account_localization_create,
|
||||
svoboda\svoboder\models\telegram\buttons\account\localization\update as button_account_localization_update,
|
||||
svoboda\svoboder\models\telegram\buttons\distribution\administration as button_distribution_administration,
|
||||
svoboda\svoboder\models\telegram\processes\distribution\localization as process_distribution_localization;
|
||||
use svoboda\antivertical\models\distribution,
|
||||
svoboda\antivertical\models\localization\distribution as distribution_localization,
|
||||
svoboda\antivertical\models\telegram\middlewares,
|
||||
svoboda\antivertical\models\telegram\commands,
|
||||
svoboda\antivertical\models\telegram\buttons,
|
||||
svoboda\antivertical\models\telegram\account,
|
||||
svoboda\antivertical\models\telegram\settings,
|
||||
svoboda\antivertical\models\enumerations\membership\status,
|
||||
svoboda\antivertical\models\enumerations\language,
|
||||
svoboda\antivertical\models\telegram\processes\membership\search as process_membership_search,
|
||||
svoboda\antivertical\models\telegram\buttons\membership\search as button_membership_search,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\declaration as process_distribution_declaration,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\search as process_distribution_search,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\select as process_distribution_select,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\declaration as button_distribution_declaration,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\search as button_distribution_search,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\select as button_distribution_select,
|
||||
svoboda\antivertical\models\telegram\processes\account\localization\create as process_account_localization_create,
|
||||
svoboda\antivertical\models\telegram\processes\account\localization\update as process_account_localization_update,
|
||||
svoboda\antivertical\models\telegram\buttons\account\localization\create as button_account_localization_create,
|
||||
svoboda\antivertical\models\telegram\buttons\account\localization\update as button_account_localization_update,
|
||||
svoboda\antivertical\models\telegram\buttons\distribution\administration as button_distribution_administration,
|
||||
svoboda\antivertical\models\telegram\processes\distribution\localization as process_distribution_localization;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Zanzara as zanzara,
|
||||
@@ -78,6 +78,7 @@ $robot = new Zanzara(TELEGRAM_KEY, $config);
|
||||
$robot->onUpdate(function (Context $context): void {});
|
||||
|
||||
// Initializing the robot middlewares
|
||||
$robot->middleware([middlewares::class, 'telegram']);
|
||||
$robot->middleware([middlewares::class, 'account']);
|
||||
$robot->middleware([middlewares::class, 'language']);
|
||||
$robot->middleware([middlewares::class, 'localization']);
|
||||
@@ -86,17 +87,18 @@ $robot->middleware([middlewares::class, 'system']);
|
||||
// Initializing the robot commands handlers
|
||||
$robot->onCommand('start', [commands::class, 'menu']);
|
||||
$robot->onCommand('menu', [commands::class, 'menu']);
|
||||
$robot->onCommand('members', [commands::class, 'members']);
|
||||
$robot->onCommand('memberships', [commands::class, 'memberships']);
|
||||
$robot->onCommand('account', [commands::class, 'account']);
|
||||
$robot->onCommand('distributions', [commands::class, 'distributions']);
|
||||
/* $robot->onCommand('request', [telegram::class, 'request_start'])->middleware([telegram::class, 'request']); */
|
||||
/* $robot->onCommand('svoboda', [commands::class, 'svoboda']);
|
||||
$robot->onCommand('members', [commands::class, 'members']); */
|
||||
$robot->onCommand('memberships', [commands::class, 'memberships']); */
|
||||
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
|
||||
$robot->onCommand('repository', [commands::class, 'repository']);
|
||||
/* $robot->onCommand('projects', [commands::class, 'projects']); */
|
||||
$robot->onCommand('author', [commands::class, 'author']);
|
||||
$robot->onCommand('society', [commands::class, 'society']);
|
||||
$robot->onCommand('organisation', [commands::class, 'organisation']);
|
||||
/* $robot->onCommand('system_settings', [commands::class, 'system_settings'])->middleware([middlewares::class, 'system_settings']); */
|
||||
|
||||
// Initializing the robot buttons handlers
|
||||
@@ -107,12 +109,12 @@ $robot->onCbQueryData(['distribution_search_name'], [button_distribution_search:
|
||||
$robot->onCbQueryData(['distribution_search_end'], [process_distribution_search::class, 'end']);
|
||||
$robot->onCbQueryData(['distribution_search_location'], [button_distribution_search::class, 'location']);
|
||||
$robot->onCbQueryData(['distribution_search_distance'], [button_distribution_search::class, 'distance']);
|
||||
$robot->onCbQueryData(['distribution_search_plan'], [button_distribution_search::class, 'plan'])->middleware([middlewares::class, 'join']);
|
||||
$robot->onCbQueryData(['distribution_search_unplan'], [button_distribution_search::class, 'unplan'])->middleware([middlewares::class, 'join']);
|
||||
$robot->onCbQueryData(['distribution_search_join'], [button_distribution_search::class, 'join'])->middleware([middlewares::class, 'join']);
|
||||
$robot->onCbQueryData(['distribution_search_leave'], [button_distribution_search::class, 'leave'])->middleware([middlewares::class, 'join']);
|
||||
$robot->onCbQueryData(['distribution_search_plan'], [button_distribution_search::class, 'plan'])->middleware([middlewares::class, 'memberships']);
|
||||
$robot->onCbQueryData(['distribution_search_unplan'], [button_distribution_search::class, 'unplan'])->middleware([middlewares::class, 'memberships']);
|
||||
$robot->onCbQueryData(['distribution_search_join'], [button_distribution_search::class, 'join'])->middleware([middlewares::class, 'memberships']);
|
||||
$robot->onCbQueryData(['distribution_search_leave'], [button_distribution_search::class, 'leave'])->middleware([middlewares::class, 'memberships']);
|
||||
$robot->onCbQueryData(['distribution_search_location'], [button_distribution_search::class, 'location']);
|
||||
$robot->onCbQueryData(['distribution_search_members'], [process_member_search::class, 'start']);
|
||||
$robot->onCbQueryData(['distribution_search_memberships'], [process_membership_search::class, 'start']);
|
||||
|
||||
$robot->onCbQueryData(['distribution_select_name'], [button_distribution_select::class, 'name']);
|
||||
$robot->onCbQueryData(['distribution_select_location'], [button_distribution_select::class, 'location']);
|
||||
@@ -157,14 +159,14 @@ foreach (language::cases() as $language) {
|
||||
// Initializing the robot distributions menu buttons handlers
|
||||
/* $robot->onCbQueryData(['distributions_search_start'], [process_distribution_search::class, 'start']); */
|
||||
|
||||
$robot->onCbQueryData(['members'], [commands::class, 'members']); // Remake to buttons?
|
||||
$robot->onCbQueryData(['member_search_start'], [process_member_search::class, 'start']);
|
||||
$robot->onCbQueryData(['member_search_name'], [button_member_search::class, 'name']);
|
||||
$robot->onCbQueryData(['member_search_distribution'], [button_member_search::class, 'distribution']);
|
||||
$robot->onCbQueryData(['memberships'], [commands::class, 'memberships']); // Remake to buttons?
|
||||
$robot->onCbQueryData(['membership_search_start'], [process_membership_search::class, 'start']);
|
||||
$robot->onCbQueryData(['membership_search_name'], [button_membership_search::class, 'name']);
|
||||
$robot->onCbQueryData(['membership_search_distribution'], [button_membership_search::class, 'distribution']);
|
||||
foreach (status::cases() as $status)
|
||||
$robot->onCbQueryData(['member_search_status_' . $status->name], fn(context $context) => process_member_search::status($context, $status));
|
||||
$robot->onCbQueryData(['member_search_status'], [button_member_search::class, 'status']);
|
||||
$robot->onCbQueryData(['member_search_end'], [process_member_search::class, 'end']);
|
||||
$robot->onCbQueryData(['membership_search_status_' . $status->name], fn(context $context) => process_membership_search::status($context, $status));
|
||||
$robot->onCbQueryData(['membership_search_status'], [button_membership_search::class, 'status']);
|
||||
$robot->onCbQueryData(['membership_search_end'], [process_membership_search::class, 'end']);
|
||||
|
||||
$robot->onCbQueryData(['account_localizations'], [account::class, 'localizations']);
|
||||
$robot->onCbQueryData(['account_localization_create_start'], [process_account_localization_create::class, 'start']);
|
||||
@@ -181,6 +183,9 @@ $robot->onCbQueryData(['account_localization_create_name'], [button_account_loca
|
||||
$robot->onCbQueryData(['account_localization_update_name'], [button_account_localization_update::class, 'name']);
|
||||
/* $robot->onCbQueryData(['account_localizations_search'], [process_account_localization_search::class, 'start']); */
|
||||
|
||||
|
||||
$robot->onCbQueryData(['organisation'], [commands::class, 'organisation']); // Remake to buttons?
|
||||
|
||||
// Initializing the robot settings language buttons handlers
|
||||
foreach (language::cases() as $language) {
|
||||
// Iterating over languages
|
37
svoboda/antivertical/system/settings/system.php
Executable file
37
svoboda/antivertical/system/settings/system.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
define('MENU_MEMBERSHIPS_AMOUNT', 10000000);
|
||||
|
||||
define('DISTRIBUTIONS_SEARCH_PAGE', 3);
|
||||
define('DISTRIBUTIONS_SEARCH_DISTRIBUTION_DISTANCE', 300);
|
||||
define('DISTRIBUTIONS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('DISTRIBUTIONS_SEARCH_DISTRIBUTION_NAME_LEVENSHTEIN_DISTANCE', 4);
|
||||
define('DISTRIBUTIONS_SEARCH_MEMBERSHIP_DEPRECATING_RECORDS_AMOUNT', 500);
|
||||
define('DISTRIBUTIONS_SEARCH_MEMBERSHIPS_AMOUNT', 10000000);
|
||||
|
||||
define('DISTRIBUTIONS_SELECT_PAGE', 10);
|
||||
define('DISTRIBUTIONS_SELECT_DISTRIBUTION_DISTANCE', 300);
|
||||
define('DISTRIBUTIONS_SELECT_DISTRIBUTION_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('DISTRIBUTIONS_SELECT_DISTRIBUTION_NAME_LEVENSHTEIN_DISTANCE', 4);
|
||||
define('DISTRIBUTIONS_SELECT_MEMBERSHIP_DEPRECATING_RECORDS_AMOUNT', 500);
|
||||
define('DISTRIBUTIONS_SELECT_MEMBERSHIPS_AMOUNT', 10000000);
|
||||
|
||||
define('MEMBERSHIPS_SEARCH_PAGE', 3);
|
||||
define('MEMBERSHIPS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('MEMBERSHIPS_SEARCH_ACCOUNT_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('MEMBERSHIPS_SEARCH_MEMBERSHIP_NAME_LEVENSHTEIN_DISTANCE', 4);
|
||||
define('MEMBERSHIPS_SEARCH_STATUS_ROW_AMOUNT', 3);
|
||||
|
||||
define('ACCOUNT_LOCALIZATION_ACCOUNT_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('ACCOUNT_LOCALIZATION_CREATE_ACCOUNT_LOCALIZATIONS_AMOUNT', 100);
|
||||
|
||||
define('ACCOUNT_ACCESS_SYSTEM', 1);
|
||||
define('ACCOUNT_ACCESS_MESSAGES', 1);
|
||||
define('ACCOUNT_ACCESS_AUTHONOM', 1);
|
||||
define('ACCOUNT_ACCESS_STRUCTOR', 1);
|
||||
define('ACCOUNT_ACCESS_VOLUNTEER', 1);
|
||||
define('ACCOUNT_ACCESS_INVESTOR', 1);
|
||||
define('ACCOUNT_ACCESS_RECRUITER', 1);
|
||||
define('ACCOUNT_ACCESS_SETTINGS', 1);
|
||||
define('ACCOUNT_ACCESS_SYSTEM_ACCOUNTS', 0);
|
||||
define('ACCOUNT_ACCESS_SYSTEM_DISTRIBUTIONS', 0);
|
||||
define('ACCOUNT_ACCESS_SYSTEM_SETTINGS', 0);
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
89
svoboda/antivertical/tests/test.php
Normal file
89
svoboda/antivertical/tests/test.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\tests;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\account,
|
||||
svoboda\svoboder\models\distribution,
|
||||
svoboda\svoboder\models\telegram;
|
||||
|
||||
// Enabling debugging
|
||||
/* ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1); */
|
||||
|
||||
// Initializing path to the public directory
|
||||
define('INDEX', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . 'public');
|
||||
|
||||
// Initializing path to the root directory
|
||||
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Initializing path to the settings directory
|
||||
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
||||
|
||||
// Initializing path to the storage directory
|
||||
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
|
||||
|
||||
// Initializing path to the databases directory
|
||||
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
|
||||
|
||||
// Initializing path to the localizations directory
|
||||
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
|
||||
|
||||
// Initiailizing telegram key
|
||||
define('TELEGRAM_KEY', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
|
||||
|
||||
// Initializing dependencies
|
||||
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing system settings
|
||||
require SETTINGS . DIRECTORY_SEPARATOR . 'system.php';
|
||||
|
||||
echo <<<TXT
|
||||
###############################
|
||||
########### ACCOUNT ###########
|
||||
###############################
|
||||
\n
|
||||
TXT;
|
||||
|
||||
// Initializing the account model
|
||||
$model = new account;
|
||||
|
||||
var_dump($model->database->read(
|
||||
/* filter: fn (record $record) => $record-), */
|
||||
amount: 1000000
|
||||
));
|
||||
|
||||
echo <<<TXT
|
||||
\n\n
|
||||
###############################
|
||||
###### TELEGRAM ACCOUNT #######
|
||||
###############################
|
||||
\n
|
||||
TXT;
|
||||
|
||||
// Initializing the telegram account model
|
||||
$model = new telegram;
|
||||
|
||||
var_dump($model->database->read(
|
||||
/* filter: fn (record $record) => $record-), */
|
||||
amount: 1000000
|
||||
));
|
||||
|
||||
echo <<<TXT
|
||||
\n\n
|
||||
###############################
|
||||
######## DISTRIBUTION #########
|
||||
###############################
|
||||
\n
|
||||
TXT;
|
||||
|
||||
// Initializing the distribution model
|
||||
$model = new distribution;
|
||||
|
||||
var_dump($model->database->read(
|
||||
/* filter: fn (record $record) => $record-), */
|
||||
amount: 1000000
|
||||
));
|
Binary file not shown.
@@ -1,126 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace svoboda\svoboder\models;
|
||||
|
||||
// Files of the project
|
||||
use svoboda\svoboder\models\core,
|
||||
svoboda\svoboder\models\distribution\localization,
|
||||
svoboda\svoboder\models\distribution\message;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Distribution
|
||||
*
|
||||
* @package svoboda\svoboder\models
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class distribution extends core
|
||||
{
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'distributions.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $database The database
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var localization $localization The localizations implementator
|
||||
*/
|
||||
public protected(set) localization $localization;
|
||||
|
||||
/**
|
||||
* Message
|
||||
*
|
||||
* @var localization $localization The messages implementator
|
||||
*/
|
||||
public protected(set) message $message;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::ascii)
|
||||
->columns(
|
||||
new column('identifier', type::integer_unsigned),
|
||||
new column('creator', type::integer_unsigned),
|
||||
new column('latitude', type::float),
|
||||
new column('longitude', type::float),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($this->file);
|
||||
|
||||
// Initializing the localizations implementator
|
||||
$this->localization = new localization;
|
||||
|
||||
// Initializing the messages implementator
|
||||
$this->message = new message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create
|
||||
*
|
||||
* Creates the distribution record in the database
|
||||
*
|
||||
* @param int $creator Identifier of the creator account
|
||||
* @param float $latitude Latitude
|
||||
* @param float $longitude Longitude
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function create(int $creator, float $latitude = 0, float $longitude = 0): int|false
|
||||
{
|
||||
// Initializing the identifier
|
||||
$identifier = $this->database->count() + 1;
|
||||
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$identifier,
|
||||
$creator,
|
||||
$latitude,
|
||||
$longitude,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Creating the record in the database
|
||||
$created = $this->database->write($record);
|
||||
|
||||
// Exit (success)
|
||||
return $created ? $identifier : false;
|
||||
}
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
define('MENU_MEMBERS_AMOUNT', 10000000);
|
||||
|
||||
define('DISTRIBUTIONS_SEARCH_PAGE', 3);
|
||||
define('DISTRIBUTIONS_SEARCH_DISTRIBUTION_DISTANCE', 300);
|
||||
define('DISTRIBUTIONS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('DISTRIBUTIONS_SEARCH_DISTRIBUTION_NAME_LEVENSHTEIN_DISTANCE', 4);
|
||||
define('DISTRIBUTIONS_SEARCH_MEMBER_DEPRECATING_RECORDS_AMOUNT', 500);
|
||||
define('DISTRIBUTIONS_SEARCH_MEMBERS_AMOUNT', 10000000);
|
||||
|
||||
define('DISTRIBUTIONS_SELECT_PAGE', 10);
|
||||
define('DISTRIBUTIONS_SELECT_DISTRIBUTION_DISTANCE', 300);
|
||||
define('DISTRIBUTIONS_SELECT_DISTRIBUTION_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('DISTRIBUTIONS_SELECT_DISTRIBUTION_NAME_LEVENSHTEIN_DISTANCE', 4);
|
||||
define('DISTRIBUTIONS_SELECT_MEMBER_DEPRECATING_RECORDS_AMOUNT', 500);
|
||||
define('DISTRIBUTIONS_SELECT_MEMBERS_AMOUNT', 10000000);
|
||||
|
||||
define('MEMBERS_SEARCH_PAGE', 3);
|
||||
define('MEMBERS_SEARCH_DISTRIBUTION_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('MEMBERS_SEARCH_ACCOUNT_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('MEMBERS_SEARCH_MEMBER_NAME_LEVENSHTEIN_DISTANCE', 4);
|
||||
define('MEMBERS_SEARCH_STATUS_ROW_AMOUNT', 3);
|
||||
|
||||
define('ACCOUNT_LOCALIZATION_ACCOUNT_LOCALIZATIONS_AMOUNT', 100);
|
||||
define('ACCOUNT_LOCALIZATION_CREATE_ACCOUNT_LOCALIZATIONS_AMOUNT', 100);
|
Reference in New Issue
Block a user