diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ffe4e67 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,15 @@ +name: Build and Publish + +on: + push: + branches: + - master + - develop + workflow_dispatch: + +jobs: + build: + uses: mikopbx/.github-workflows/.github/workflows/extension-publish.yml@master + with: + initial_version: "1.70" + secrets: inherit \ No newline at end of file diff --git a/App/Controllers/ModuleUsersGroupsController.php b/App/Controllers/ModuleUsersGroupsController.php index 6fa907c..f7ea66d 100644 --- a/App/Controllers/ModuleUsersGroupsController.php +++ b/App/Controllers/ModuleUsersGroupsController.php @@ -1,4 +1,5 @@ $b['username']; + usort($extensionTable, function ($a, $b) { + return strcmp($a['username'], $b['username']); }); $this->view->members = $extensionTable; @@ -679,5 +681,4 @@ public function changeDefaultAction(): void } } } - -} \ No newline at end of file +} diff --git a/App/Forms/ModuleUsersGroupsForm.php b/App/Forms/ModuleUsersGroupsForm.php index 6f90f30..75e5362 100644 --- a/App/Forms/ModuleUsersGroupsForm.php +++ b/App/Forms/ModuleUsersGroupsForm.php @@ -1,4 +1,5 @@ add(new Text('name')); // Description - $this->addTextArea('description',$entity->description??'',90); + $this->addTextArea('description', $entity->description ?? '', 90); // Patterns $patternsPlaceholder = ''; for ($i = 1; $i < 8; $i++) { - $patternsPlaceholder .= $this->translation->_("mod_usrgr_PatternsInstructions$i").PHP_EOL; + $patternsPlaceholder .= $this->translation->_("mod_usrgr_PatternsInstructions$i") . PHP_EOL; } - $this->addTextArea('patterns',$entity->patterns??'',90, ['placeholder' => $patternsPlaceholder]); + $this->addTextArea('patterns', $entity->patterns ?? '', 90, ['placeholder' => $patternsPlaceholder]); // select-extension-field $extension = new Select( - 'select-extension-field', [], [ + 'select-extension-field', + [], + [ 'using' => [ 'id', 'name', ], 'useEmpty' => true, 'class' => 'ui selection dropdown search select-extension-field', - ] + ] ); $this->add($extension); // isolate - $isolate = ['value' => null]; - if ($entity->isolate === '1') { - $isolate = ['checked' => 'checked', 'value' => null]; - } - $this->add(new Check('isolate', $isolate)); - + $this->addCheckBox('isolate', intval($entity->isolate) === 1); // isolatePickUp - $isolatePickUp = ['value' => null]; - if ($entity->isolatePickUp === '1') { - $isolatePickUp = ['checked' => 'checked', 'value' => null]; + $this->addCheckBox('isolatePickUp', intval($entity->isolatePickUp) === 1); + } + + /** + * Adds a checkbox to the form field with the given name. + * Can be deleted if the module depends on MikoPBX later than 2024.3.0 + * + * @param string $fieldName The name of the form field. + * @param bool $checked Indicates whether the checkbox is checked by default. + * @param string $checkedValue The value assigned to the checkbox when it is checked. + * @return void + */ + public function addCheckBox(string $fieldName, bool $checked, string $checkedValue = 'on'): void + { + $checkAr = ['value' => null]; + if ($checked) { + $checkAr = ['checked' => $checkedValue,'value' => $checkedValue]; } - $this->add(new Check('isolatePickUp', $isolatePickUp)); + $this->add(new Check($fieldName, $checkAr)); } -} \ No newline at end of file +} diff --git a/Lib/MikoPBXVersion.php b/Lib/MikoPBXVersion.php index 0a8553f..dccfee1 100644 --- a/Lib/MikoPBXVersion.php +++ b/Lib/MikoPBXVersion.php @@ -1,6 +1,24 @@ . + */ namespace Modules\ModuleUsersGroups\Lib; + use MikoPBX\Common\Models\PbxSettings; class MikoPBXVersion @@ -9,7 +27,7 @@ class MikoPBXVersion * Return true if current version of PBX based on Phalcon 5+ * @return bool */ - public static function isPhalcon5Version():bool + public static function isPhalcon5Version(): bool { $pbxVersion = PbxSettings::getValueByKey('PBXVersion'); return version_compare($pbxVersion, '2024.2.30', '>'); @@ -19,7 +37,7 @@ public static function isPhalcon5Version():bool * Return Di interface for the current version of PBX * @return \Phalcon\Di\DiInterface|null */ - public static function getDefaultDi():\Phalcon\Di\DiInterface|null + public static function getDefaultDi() { if (self::isPhalcon5Version()) { return \Phalcon\Di\Di::getDefault(); @@ -32,7 +50,7 @@ public static function getDefaultDi():\Phalcon\Di\DiInterface|null * Return Validation class for the current version of PBX * @return class-string<\Phalcon\Filter\Validation>|class-string<\Phalcon\Validation> */ - public static function getValidationClass():string + public static function getValidationClass(): string { if (self::isPhalcon5Version()) { return \Phalcon\Filter\Validation::class; @@ -45,7 +63,7 @@ public static function getValidationClass():string * Return Uniqueness class for the current version of PBX * @return class-string<\Phalcon\Filter\Validation\Validator\Uniqueness>|class-string<\Phalcon\Validation\Validator\Uniqueness> */ - public static function getUniquenessClass():string + public static function getUniquenessClass(): string { if (self::isPhalcon5Version()) { return \Phalcon\Filter\Validation\Validator\Uniqueness::class; @@ -59,7 +77,7 @@ public static function getUniquenessClass():string * * @return class-string<\MikoPBX\Common\Library\Text>|class-string<\Phalcon\Text> */ - public static function getTextClass():string + public static function getTextClass(): string { if (self::isPhalcon5Version()) { return \MikoPBX\Common\Library\Text::class; @@ -73,7 +91,7 @@ public static function getTextClass():string * * @return class-string<\Phalcon\Logger\Logger>|class-string<\Phalcon\Logger> */ - public static function getLoggerClass():string + public static function getLoggerClass(): string { if (self::isPhalcon5Version()) { return \Phalcon\Logger\Logger::class; @@ -81,4 +99,4 @@ public static function getLoggerClass():string return \Phalcon\Logger::class; } } -} \ No newline at end of file +} diff --git a/Lib/UsersGroupsConf.php b/Lib/UsersGroupsConf.php index 1213f85..d53c550 100644 --- a/Lib/UsersGroupsConf.php +++ b/Lib/UsersGroupsConf.php @@ -207,7 +207,7 @@ public function generatePeersPj(): string * * @return void */ - public function modelsEventChangeData(mixed $data): void + public function modelsEventChangeData($data): void { $called_class = $data['model'] ?? ''; switch ($called_class) { @@ -323,7 +323,7 @@ public function onVoltBlockCompile(string $controller, string $blockName, View $ * * @return void */ - public function onBeforeFormInitialize(Form $form, mixed $entity, mixed $options): void + public function onBeforeFormInitialize(Form $form, $entity, $options): void { if (is_a($form, ExtensionEditForm::class)) { ExtensionEditAdditionalForm::prepareAdditionalFields($form, $entity, $options); diff --git a/Messages/hr.php b/Messages/hr.php new file mode 100644 index 0000000..2500068 --- /dev/null +++ b/Messages/hr.php @@ -0,0 +1,57 @@ +. + */ + 'repModuleUsersGroups' => 'Modul telefonskih grupa - %repesent%', + 'mo_ModuleModuleUsersGroups' => 'Dial Group Management', + 'BreadcrumbModuleUsersGroups' => 'Dial Group Management', + 'BreadcrumbModuleUsersGroupsModify' => 'Postavljanje grupe za biranje', + 'SubHeaderModuleUsersGroups' => 'Postavljanje prava za odlazne pozive, upravljanje odlaznim ID-om pozivatelja, organiziranje grupa za preuzimanje poziva', + 'mod_usrgr_patterns' => 'Predlošci brojeva koji se odnose na grupu. Član grupe će moći pozivati samo te brojeve', + 'mod_usrgr_Connected' => 'Modul spojen', + 'mod_usrgr_Disconnected' => 'Modul onemogućen', + 'mod_usrgr_isolate' => 'Izolirajte grupu zaposlenika', + 'mod_usrgr_isolatePickUp' => 'Izolirajte funkciju preuzimanja', + 'mod_usrgr_Groups' => 'Popis grupa za biranje', + 'mod_usrgr_Users' => 'Zaposlenici', + 'mod_usrgr_AddNewUsersGroup' => 'Stvorite grupu za biranje', + 'mod_usrgr_ColumnGroupName' => 'Skupina', + 'mod_usrgr_ColumnGroupDescription' => 'Opis', + 'mod_usrgr_ColumnGroupMembersCount' => 'Broj sudionika', + 'mod_usrgr_ValidateNameIsEmpty' => 'Provjerite polje za naziv grupe', + 'mod_usrgr_ColumnGroup' => 'Skupina', + 'mod_usrgr__GeneralSettings' => 'Postavke grupe', + 'mod_usrgr_UsersFilter' => 'Zaposlenici grupe', + 'mod_usrgr_RoutingRules' => 'Pravila odlaznog usmjeravanja', + 'mod_usrgr_ColumnCallerId' => 'ID pozivatelja', + 'mod_usrgr_SelectMemberToAddToGroup' => 'Odaberite zaposlenika', + 'mod_usrgr_SelectUserGroup' => 'Odaberite telefonsku grupu za zaposlenika', + 'mod_usrgr_PatternsInstructions1' => 'Predlošci mogu koristiti simbol od 1 do 9 i simbol X (bilo koji broj od 1-9)', + 'mod_usrgr_PatternsInstructions2' => 'Član grupe moći će birati samo one brojeve koji odgovaraju obrascima', + 'mod_usrgr_PatternsInstructions3' => ' ', + 'mod_usrgr_PatternsInstructions4' => 'Primjeri predložaka:', + 'mod_usrgr_PatternsInstructions5' => '2XX - brojevi od 200 do 299', + 'mod_usrgr_PatternsInstructions6' => '200001 - izričito naveden interni broj, na primjer broj reda čekanja', + 'mod_usrgr_PatternsInstructions7' => '7XXXXXXXXXX - bilo koji 11-znamenkasti broj koji počinje sa 7', + 'mod_usrgr_IsolateInstructions1' => 'Zaposlenici grupe moći će pozivati samo brojeve u svojoj grupi.', + 'mod_usrgr_IsolateInstructions2' => 'Zaposlenici iz drugih grupa neće moći nazvati izoliranu grupu.', + 'mod_usrgr_ColumnDefaultGroup' => 'Zadana grupa', + 'mod_usrgr_ErrorOnDeleteDefaultGroup' => 'Ne možete izbrisati zadanu grupu', + 'mod_usrgr_SelectDefaultGroup' => 'Odaberite grupu', + 'mod_usrgr_DefaultGroup' => 'Zadana grupa', +]; diff --git a/README.md b/README.md new file mode 100644 index 0000000..f233026 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +## Module Users Groups + +This module provides functionality for managing user groups and their associated permissions, including: + +**Inputs** + +* **Group Name**: Defines a unique name for the user group. +* **Description**: A brief explanation or details about the purpose of the group. +* **Patterns**: A list of number patterns that group members are allowed to call. This can include specific numbers, ranges, or patterns using wildcards. +* **Isolate**: Enables isolation for the group, restricting members to call only within their group or to numbers matching the defined patterns. +* **Isolate Pickup**: Enables isolation for the call pickup function, allowing only group members to pick up calls from other members within the same group. +* **Default Group**: Sets a specific group as the default group for new users. +* **Users**: Selects individual users to assign to a specific group. +* **Routing Rules**: Defines outbound routing rules and applies them to specific groups, along with custom caller IDs for each rule. + +**Outputs** + +* **User Groups**: Creates and manages user groups with the specified settings. +* **Group Membership**: Assigns individual users to specific groups. +* **Call Restrictions**: Implements call restrictions based on group settings, allowing or denying calls based on isolation and defined patterns. +* **Call Pickup Restrictions**: Implements restrictions on call pickup based on group settings, allowing only members within the same group to pick up calls from each other. +* **Outbound Routing Rules**: Applies outbound routing rules to specific groups and sets custom caller IDs for those rules. + +This module enhances call management and security by providing granular control over user permissions and call routing based on group affiliations. It allows administrators to define specific communication policies for different user groups, ensuring efficient and secure call handling within the organization. \ No newline at end of file diff --git a/composer.json b/composer.json index 79961ca..e43decc 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mikopbx/moduleusersgroups", "description": "ModuleUsersGroups", "require": { - "php": "^7.4 || ^8.0", + "php": "^7.4", "mikopbx/core": ">=2021.1.55" }, "autoload": { @@ -55,7 +55,7 @@ "config": { "sort-packages": true, "platform": { - "php": "^7.4 || ^8.0" + "php": "7.4.0" } } } diff --git a/module.json b/module.json index c485708..d966ce2 100644 --- a/module.json +++ b/module.json @@ -7,5 +7,10 @@ "wiki_links": { "ru": {"https://wiki.mikopbx.com/module-users-groups": "https://docs.mikopbx.com/mikopbx/modules/miko/module-users-groups"}, "en": {"https://wiki.mikopbx.com/module-users-groups": "https://docs.mikopbx.com/mikopbx/v/english/modules/miko/module-users-groups"} + }, + "release_settings": { + "publish_release": true, + "changelog_enabled": true, + "create_github_release": true } } \ No newline at end of file