Skip to content

Commit

Permalink
Merge pull request #30 from mikopbx/develop
Browse files Browse the repository at this point in the history
Перенесем правки в основную ветку
  • Loading branch information
boffart authored Dec 9, 2024
2 parents 31ec6af + 7b1579d commit 6f7082a
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 32 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 5 additions & 4 deletions App/Controllers/ModuleUsersGroupsController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* MikoPBX - free phone system for small business
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
Expand Down Expand Up @@ -32,6 +33,7 @@
use MikoPBX\Modules\PbxExtensionUtils;
use Modules\ModuleUsersGroups\App\Forms\DefaultGroupForm;
use Modules\ModuleUsersGroups\App\Forms\ModuleUsersGroupsForm;

use function MikoPBX\Common\Config\appPath;

class ModuleUsersGroupsController extends BaseController
Expand Down Expand Up @@ -275,8 +277,8 @@ public function modifyAction(string $id = null): void
default:
}
}
usort($extensionTable, function($a, $b) {
return $a['username'] > $b['username'];
usort($extensionTable, function ($a, $b) {
return strcmp($a['username'], $b['username']);
});
$this->view->members = $extensionTable;

Expand Down Expand Up @@ -679,5 +681,4 @@ public function changeDefaultAction(): void
}
}
}

}
}
45 changes: 28 additions & 17 deletions App/Forms/ModuleUsersGroupsForm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* MikoPBX - free phone system for small business
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
Expand Down Expand Up @@ -27,7 +28,6 @@

class ModuleUsersGroupsForm extends BaseForm
{

public function initialize($entity = null, $options = null): void
{
// id
Expand All @@ -37,41 +37,52 @@ public function initialize($entity = null, $options = null): void
$this->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));
}
}
}
32 changes: 25 additions & 7 deletions Lib/MikoPBXVersion.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
<?php

/*
* MikoPBX - free phone system for small business
* Copyright © 2017-2024 Alexey Portnov and Nikolay Beketov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace Modules\ModuleUsersGroups\Lib;

use MikoPBX\Common\Models\PbxSettings;

class MikoPBXVersion
Expand All @@ -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', '>');
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -73,12 +91,12 @@ 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;
} else {
return \Phalcon\Logger::class;
}
}
}
}
4 changes: 2 additions & 2 deletions Lib/UsersGroupsConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
57 changes: 57 additions & 0 deletions Messages/hr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
return [
/*
* MikoPBX - free phone system for small business
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
'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',
];
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mikopbx/moduleusersgroups",
"description": "ModuleUsersGroups",
"require": {
"php": "^7.4 || ^8.0",
"php": "^7.4",
"mikopbx/core": ">=2021.1.55"
},
"autoload": {
Expand Down Expand Up @@ -55,7 +55,7 @@
"config": {
"sort-packages": true,
"platform": {
"php": "^7.4 || ^8.0"
"php": "7.4.0"
}
}
}
5 changes: 5 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 6f7082a

Please sign in to comment.