Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9d1b3b2
Update for PHP 8.3 and Phalcon 5.8
jorikfon Oct 1, 2024
421e69b
Check select from dropdown for LADP user #5
jorikfon Oct 7, 2024
a9d872f
Check select from the dropdown for LADP user #5
jorikfon Oct 7, 2024
1f3db5b
Update for PHP 8.3 and Phalcon 5.8
jorikfon Oct 7, 2024
c654a95
Update for PHP 8.3 and Phalcon 5.8
jorikfon Oct 7, 2024
e7a14d1
Translated using Weblate (English)
weblate Oct 7, 2024
e6940dd
Translated using Weblate (Azerbaijani)
weblate Oct 7, 2024
ff57561
Translated using Weblate (Czech)
weblate Oct 7, 2024
fb2bbf4
Translated using Weblate (Danish)
weblate Oct 7, 2024
308f2b5
Translated using Weblate (German)
weblate Oct 7, 2024
e9a5665
Translated using Weblate (Greek)
weblate Oct 7, 2024
e285e36
Translated using Weblate (Spanish)
weblate Oct 7, 2024
2f9b000
Translated using Weblate (French)
weblate Oct 7, 2024
8fc638f
Translated using Weblate (Italian)
weblate Oct 7, 2024
abd3bc3
Translated using Weblate (Japanese)
weblate Oct 7, 2024
29474f2
Translated using Weblate (Georgian)
weblate Oct 7, 2024
3027c02
Translated using Weblate (Dutch)
weblate Oct 7, 2024
193f53e
Translated using Weblate (Polish)
weblate Oct 7, 2024
5fbc639
Translated using Weblate (Portuguese)
weblate Oct 7, 2024
ee28371
Translated using Weblate (Portuguese (Brazil))
weblate Oct 7, 2024
f3659a5
Translated using Weblate (Swedish)
weblate Oct 7, 2024
a906a51
Translated using Weblate (Turkish)
weblate Oct 7, 2024
f3bac11
Translated using Weblate (Ukrainian)
weblate Oct 7, 2024
7e34bf1
Translated using Weblate (Vietnamese)
weblate Oct 7, 2024
03c3196
Translated using Weblate (Chinese (Simplified))
weblate Oct 7, 2024
b09a653
Translated using Weblate (Romanian)
weblate Oct 7, 2024
673c0cb
Translated using Weblate (Thai)
weblate Oct 7, 2024
f0f2c8c
Translated using Weblate (Hungarian)
weblate Oct 7, 2024
dd84c20
Translated using Weblate (Finnish)
weblate Oct 7, 2024
18dfe71
Update for PHP 8.3 and Phalcon 5.8
jorikfon Oct 9, 2024
46d3d54
Merge remote-tracking branch 'origin/develop' into develop
jorikfon Oct 9, 2024
86bd117
Update user password hashing mechanism
jorikfon Oct 11, 2024
17100c1
Доступ к фильтрам должен быть и в случае доступа к расширенному журна…
boffart Oct 15, 2024
7ce5305
Добавил фильтр для Cdr "Иходящие по выбранным номерам"
boffart Oct 15, 2024
0d5b0d4
Refactor checkbox usage
jorikfon Oct 16, 2024
784906c
Merge remote-tracking branch 'origin/develop' into develop
jorikfon Oct 16, 2024
2c70679
Translated using Weblate (English)
weblate Oct 15, 2024
8db309c
Translated using Weblate (Azerbaijani)
weblate Oct 15, 2024
39c50c7
Translated using Weblate (Czech)
weblate Oct 15, 2024
4fd1b02
Translated using Weblate (Danish)
weblate Oct 15, 2024
a48375e
Translated using Weblate (German)
weblate Oct 15, 2024
e269589
Translated using Weblate (Greek)
weblate Oct 15, 2024
18fce25
Translated using Weblate (Spanish)
weblate Oct 15, 2024
97fcc6b
Translated using Weblate (French)
weblate Oct 15, 2024
9ff89d9
Translated using Weblate (Italian)
weblate Oct 15, 2024
5245552
Translated using Weblate (Japanese)
weblate Oct 15, 2024
248f014
Translated using Weblate (Georgian)
weblate Oct 15, 2024
34ba0bc
Translated using Weblate (Dutch)
weblate Oct 15, 2024
0e7d3b6
Translated using Weblate (Polish)
weblate Oct 15, 2024
f80fd00
Translated using Weblate (Portuguese)
weblate Oct 15, 2024
079a062
Translated using Weblate (Portuguese (Brazil))
weblate Oct 15, 2024
ecaf0bf
Translated using Weblate (Swedish)
weblate Oct 15, 2024
c1801ad
Translated using Weblate (Turkish)
weblate Oct 15, 2024
a7cb63a
Translated using Weblate (Ukrainian)
weblate Oct 15, 2024
f1b0caf
Translated using Weblate (Vietnamese)
weblate Oct 15, 2024
3dd556c
Translated using Weblate (Chinese (Simplified))
weblate Oct 15, 2024
299ec3c
Translated using Weblate (Romanian)
weblate Oct 15, 2024
e41bf10
Translated using Weblate (Thai)
weblate Oct 15, 2024
9e9bb67
Translated using Weblate (Hungarian)
weblate Oct 15, 2024
89189e5
Translated using Weblate (Finnish)
weblate Oct 15, 2024
f4fb5ef
Поправил поведение Radio для phalcon4
boffart Oct 21, 2024
406e222
Поправил отображение вкладки фильтра истории звонков.
boffart Oct 21, 2024
5fa499e
Поправил ошибку совместимости с phalcon5
boffart Oct 21, 2024
ceb2513
Added translation using Weblate (Croatian)
weblate Nov 18, 2024
fc2cc88
Translated using Weblate (Croatian)
weblate Nov 18, 2024
819f4c7
Move to github actions
jorikfon Nov 22, 2024
b6d377c
Merge remote-tracking branch 'origin/develop' into develop
jorikfon Nov 22, 2024
e11175a
Update the github actions
jorikfon Jan 16, 2025
ae36f20
refactor: Improve ModuleUsersUI code structure and add validation
jorikfon Jan 21, 2025
81793d2
Merge branch 'master' into develop
jorikfon May 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
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.80"
secrets: inherit
8 changes: 5 additions & 3 deletions App/Controllers/AccessGroupCDRFilterController.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 All @@ -22,6 +23,7 @@
use MikoPBX\Common\Models\Extensions;
use MikoPBX\Common\Models\Users;
use Modules\ModuleUsersUI\Models\AccessGroupCDRFilter;

use function MikoPBX\Common\Config\appPath;

class AccessGroupCDRFilterController extends ModuleUsersUIBaseController
Expand Down Expand Up @@ -99,13 +101,13 @@ public function getTheListOfUsersForCDRFilter(string $group_id): array
$extensionTable[$extension->userid]['mobile'] = '';
}

$extensionTable[$extension->userid]['avatar'] = $this->url->get().'assets/img/unknownPerson.jpg';
$extensionTable[$extension->userid]['avatar'] = $this->url->get() . 'assets/img/unknownPerson.jpg';
if ($extension->avatar) {
$filename = md5($extension->avatar);
$imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache');
$imgFile = "{$imgCacheDir}/{$filename}.jpg";
if (file_exists($imgFile)) {
$extensionTable[$extension->userid]['avatar'] = $this->url->get()."assets/img/cache/{$filename}.jpg";
$extensionTable[$extension->userid]['avatar'] = $this->url->get() . "assets/img/cache/{$filename}.jpg";
}
}
break;
Expand Down Expand Up @@ -153,4 +155,4 @@ public function saveCdrFilter(string $accessGroupId, array $cdrFilterUsers): boo
}
return true;
}
}
}
38 changes: 19 additions & 19 deletions App/Controllers/AccessGroupsController.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 All @@ -18,6 +19,7 @@
*/

namespace Modules\ModuleUsersUI\App\Controllers;

use MikoPBX\AdminCabinet\Providers\AssetProvider;
use Modules\ModuleUsersUI\App\Forms\AccessGroupForm;
use Modules\ModuleUsersUI\Lib\Constants;
Expand All @@ -43,7 +45,7 @@ public function modifyAction(string $id = null): void
$footerCollection
->addJs('js/pbx/main/form.js', true)
->addJs('js/vendor/datatable/dataTables.semanticui.js', true)
->addJs('js/cache/'.$this->moduleUniqueID.'/module-users-ui-modify-ag.js', true);
->addJs('js/cache/' . $this->moduleUniqueID . '/module-users-ui-modify-ag.js', true);

$record = AccessGroups::findFirstById($id);
if ($record === null) {
Expand All @@ -52,13 +54,13 @@ public function modifyAction(string $id = null): void
$record->name = '';
$record->description = '';
} else {
$this->view->members = $this->getTheListOfUsersForDisplayInTheFilter($record->id??'');
$this->view->members = $this->getTheListOfUsersForDisplayInTheFilter($record->id ?? '');
$cdrFilterController = new AccessGroupCDRFilterController();
$this->view->cdrFilterMembers = $cdrFilterController->getTheListOfUsersForCDRFilter($record->id);
}
$groupRightsController = new AccessGroupsRightsController();
$groupRights = $groupRightsController->getGroupRights($record->id??'');
$this->view->form = new AccessGroupForm($record,['groupRights'=>$groupRights]);
$groupRights = $groupRightsController->getGroupRights($record->id ?? '');
$this->view->form = new AccessGroupForm($record, ['groupRights' => $groupRights]);
$this->view->represent = $record->getRepresent();
$this->view->id = $id;
$this->view->groupRights = $groupRights;
Expand All @@ -72,7 +74,7 @@ public function modifyAction(string $id = null): void
public function saveAction(): void
{
if (!$this->request->isPost()) {
return;
return;
}
$data = $this->request->getPost();

Expand All @@ -82,17 +84,17 @@ public function saveAction(): void
if (array_key_exists('id', $data)) {
$accessGroupEntity = AccessGroups::findFirstById($data['id']);
}
if ($accessGroupEntity===null) {
$accessGroupEntity=new AccessGroups();
if ($accessGroupEntity === null) {
$accessGroupEntity = new AccessGroups();
$accessGroupEntity->id = $data['id'];
}
if (empty($data['cdrFilterMode'])){
if (empty($data['cdrFilterMode'])) {
$accessGroupEntity->cdrFilterMode = Constants::CDR_FILTER_DISABLED;
} else {
$accessGroupEntity->cdrFilterMode = $data['cdrFilterMode'];
}

if (empty($data['homePage'])){
if (empty($data['homePage'])) {
$accessGroupEntity->homePage = $this->url->get('session/end');
} else {
$accessGroupEntity->homePage = $data['homePage'];
Expand All @@ -103,7 +105,7 @@ public function saveAction(): void
$accessGroupEntity->fullAccess = $data['fullAccess'];

// Save the access group object
if ($this->saveEntity($accessGroupEntity)===false){
if ($this->saveEntity($accessGroupEntity) === false) {
// If there are validation errors, display them and return false
$this->db->rollback();
return;
Expand All @@ -112,26 +114,26 @@ public function saveAction(): void
// Save access group rights
$accessGroupController = new AccessGroupsRightsController();
// Parse access group rights from the posted JSON string
$accessGroupRightsFromPost = json_decode($data['access_group_rights'], true)??[];
if ($accessGroupController->saveAccessGroupRights($accessGroupEntity->id, $accessGroupRightsFromPost)===false){
$accessGroupRightsFromPost = json_decode($data['access_group_rights'], true) ?? [];
if ($accessGroupController->saveAccessGroupRights($accessGroupEntity->id, $accessGroupRightsFromPost) === false) {
$this->db->rollback();
return;
}

// Save users credentials
$usersCredentialsController = new UsersCredentialsController();
// Parse group members from the posted JSON string
$membersOfTheGroup = json_decode($data['members'], true)??[];
if ($usersCredentialsController->saveUsersCredentials($accessGroupEntity->id, $membersOfTheGroup)===false){
$membersOfTheGroup = json_decode($data['members'], true) ?? [];
if ($usersCredentialsController->saveUsersCredentials($accessGroupEntity->id, $membersOfTheGroup) === false) {
$this->db->rollback();
return;
}

// Save CDR filter
$cdrFilterController = new AccessGroupCDRFilterController();
// Parse cdr filter from the posted JSON string
$cdrFilterUsers = json_decode($data['cdrFilter'], true)??[];
if ($cdrFilterController->saveCdrFilter($accessGroupEntity->id, $cdrFilterUsers)===false){
$cdrFilterUsers = json_decode($data['cdrFilter'], true) ?? [];
if ($cdrFilterController->saveCdrFilter($accessGroupEntity->id, $cdrFilterUsers) === false) {
$this->db->rollback();
return;
}
Expand All @@ -144,7 +146,6 @@ public function saveAction(): void
if (empty($data['id'])) {
$this->view->reload = "module-users-u-i/access-groups/modify/{$accessGroupEntity->id}";
}

}

/**
Expand All @@ -165,5 +166,4 @@ public function deleteAction(string $groupId): void

$this->forward('module-users-u-i/module-users-u-i/index');
}

}
}
33 changes: 16 additions & 17 deletions App/Controllers/AccessGroupsRightsController.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 All @@ -23,13 +24,14 @@
use MikoPBX\Common\Providers\PBXConfModulesProvider;
use MikoPBX\Modules\Config\RestAPIConfigInterface;
use Modules\ModuleUsersUI\Lib\Constants;
use Modules\ModuleUsersUI\Lib\MikoPBXVersion;
use Modules\ModuleUsersUI\Lib\UsersUIACL;
use Modules\ModuleUsersUI\Models\AccessGroupsRights;
use Phalcon\Annotations\Reader;
use Phalcon\Annotations\Reflection;
use Phalcon\Text;
use ReflectionClass;
use Throwable;

use function MikoPBX\Common\Config\appPath;

class AccessGroupsRightsController extends ModuleUsersUIBaseController
Expand Down Expand Up @@ -92,7 +94,6 @@ private function getAvailableUIControllersActions(): array
[$excludedControllers, $excludedActions] = $this->getExclusionsActionsControllers();

foreach ($controllerFiles as $file) {

$className = pathinfo($file)['filename'];
$controllerClass = 'MikoPBX\AdminCabinet\Controllers\\' . $className;

Expand All @@ -105,7 +106,6 @@ private function getAvailableUIControllersActions(): array
if (count($publicMethods) > 0) {
$controllers[Constants::ADMIN_CABINET]['APP'][$controllerClass] = $publicMethods;
}

}
// Sort the controllers array by translated controller name
uksort($controllers[Constants::ADMIN_CABINET]['APP'], function ($a, $b) {
Expand Down Expand Up @@ -137,11 +137,11 @@ private function getExclusionsActionsControllers(): array
$arrayOfExclusions = [];

// Get the list of linked controllers and actions which we hide from settings
foreach (UsersUIACL::getLinkedControllerActions() as $controllerClass=> $actions) {
foreach (UsersUIACL::getLinkedControllerActions() as $controllerClass => $actions) {
// Iterate through the main controllers actions
foreach ($actions as $action=>$linkedControllers) {
foreach ($actions as $action => $linkedControllers) {
// Iterate through the linked controllers actions
foreach ($linkedControllers as $linkedController=>$linkedActions) {
foreach ($linkedControllers as $linkedController => $linkedActions) {
if (array_key_exists($linkedController, $arrayOfExclusions)) {
$arrayOfExclusions[$linkedController] = array_merge($arrayOfExclusions[$linkedController], $linkedActions);
$arrayOfExclusions[$linkedController] = array_unique($arrayOfExclusions[$linkedController]);
Expand All @@ -155,11 +155,13 @@ private function getExclusionsActionsControllers(): array
$arrayOfExclusions = array_merge_recursive(UsersUIACL::getAlwaysAllowed(), UsersUIACL::getAlwaysDenied(), $arrayOfExclusions);
// Iterate through the always allowed and disallowed controllers and actions
foreach ($arrayOfExclusions as $controllerClass => $actions) {
if ($actions === '*'
|| (is_array($actions) && in_array('*', $actions))) {
if (
$actions === '*'
|| (is_array($actions) && in_array('*', $actions))
) {
// Add the controller with all actions to the excluded from settings array
$excludedControllers[] = $controllerClass;
} elseif (is_array($actions)){
} elseif (is_array($actions)) {
// Add the controller with defined actions to the excluded from settings array
$excludedActions[$controllerClass] = $actions;
}
Expand Down Expand Up @@ -197,7 +199,7 @@ private function getControllersActions(string $controllerClass, array $excludedA
// Remove "Action" from the action name
$actionName = substr($actionName, 0, -6);
// Remove always allowed or always disallowed actions
if (!in_array($actionName, $excludedActions[$controllerClass])) {
if (!in_array($actionName, $excludedActions[$controllerClass] ?? [])) {
$publicMethods[$actionName] = false;
}
}
Expand All @@ -224,7 +226,6 @@ private function getAvailableRESTControllersActions(): array
[$excludedControllers, $excludedActions] = $this->getExclusionsActionsControllers();

foreach ($controllerFiles as $file) {

$className = pathinfo($file)['filename'];
$subClassName = basename(pathinfo($file)['dirname']);
$controllerClass = 'MikoPBX\PBXCoreREST\Controllers\\' . $subClassName . '\\' . $className;
Expand Down Expand Up @@ -328,8 +329,8 @@ private function getAvailableRESTActionsInModules(): array

// Create a reflection of the controller class
$reflection = new Reflection($parsedClass);

$controllerName = '/pbxcore/api/modules/' . Text::uncamelize($configObject->moduleUniqueId, '-');
$textClass = MikoPBXVersion::getTextClass();
$controllerName = '/pbxcore/api/modules/' . $textClass::uncamelize($configObject->moduleUniqueId, '-');

// Get the actions of the controller if they are defined in the method description
$actions = [];
Expand Down Expand Up @@ -402,7 +403,6 @@ private function getAvailableRESTActionsInModules(): array
$currentContext = array_merge($currentContext ?? [], $actions);
}
}

}
return $controllers;
}
Expand All @@ -424,7 +424,8 @@ public function fillAllowed(array $combined, array $allowedRights): array
foreach ($actions as $actionName => $value) {
foreach ($allowedRights as $allowedRight) {
$allowedActions = json_decode($allowedRight['actions'], true);
if ($allowedRight['module_id'] === $moduleId
if (
$allowedRight['module_id'] === $moduleId
&& $allowedRight['controller'] === $controllerClass
&& in_array($actionName, $allowedActions)
) {
Expand Down Expand Up @@ -472,9 +473,7 @@ public function saveAccessGroupRights(string $accessGroupId, array $accessGroupR
// If there are validation errors, display them and return false
return false;
}

}

}
return true;
}
Expand Down
36 changes: 21 additions & 15 deletions App/Controllers/LdapConfigController.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 @@ -28,7 +29,6 @@

class LdapConfigController extends ModuleUsersUIBaseController
{

/**
* Save LDAP configuration.
*
Expand All @@ -54,8 +54,10 @@ public function saveAction(): void
case 'id':
break;
case 'administrativePassword':
if (isset($data['administrativePasswordHidden'])
&& $data['administrativePasswordHidden'] !== Constants::HIDDEN_PASSWORD) {
if (
isset($data['administrativePasswordHidden'])
&& $data['administrativePasswordHidden'] !== Constants::HIDDEN_PASSWORD
) {
$ldapConfig->$name = $data['administrativePasswordHidden'];
}
break;
Expand All @@ -78,7 +80,7 @@ public function saveAction(): void
* @return void
* @throws Exception
*/
public function searchLdapUserAction(string $pattern=''): void
public function searchLdapUserAction(string $pattern = ''): void
{
/** @var Redis $redis */
$redis = $this->di->getShared(ManagedCacheProvider::SERVICE_NAME);
Expand All @@ -96,12 +98,14 @@ public function searchLdapUserAction(string $pattern=''): void
}
$pattern = urldecode($pattern);
$usersForDropDown = [];
foreach ($availableUsers as $user){
if ( stripos($user['name'], $pattern)!==false
|| stripos($user['login'], $pattern)!==false){
$usersForDropDown[]=[
'title'=>$user['login'],
'description'=>$user['name'],
foreach ($availableUsers as $user) {
if (
mb_stripos($user['name'], $pattern) !== false
|| mb_stripos($user['login'], $pattern) !== false
) {
$usersForDropDown[] = [
'title' => $user['login'],
'description' => $user['name'],
];
}
}
Expand Down Expand Up @@ -169,15 +173,17 @@ private function prepareLdapCredentialsArrayFromPost(array $postData): array
{
// Admin password can be stored in DB on the time, on this way it has only xxxxxx value.
// It can be empty as well, if some password manager tried to fill it.
if (empty($postData['administrativePasswordHidden'])
|| $postData['administrativePasswordHidden'] === Constants::HIDDEN_PASSWORD) {
if (
empty($postData['administrativePasswordHidden'])
|| $postData['administrativePasswordHidden'] === Constants::HIDDEN_PASSWORD
) {
$ldapConfig = LdapConfig::findFirst();
$postData['administrativePassword'] = $ldapConfig->administrativePassword??'';
$postData['administrativePassword'] = $ldapConfig->administrativePassword ?? '';
} else {
$postData['administrativePassword'] = $postData['administrativePasswordHidden'];
}

return [
return [
'serverName' => $postData['serverName'],
'serverPort' => $postData['serverPort'],
'baseDN' => $postData['baseDN'],
Expand All @@ -190,4 +196,4 @@ private function prepareLdapCredentialsArrayFromPost(array $postData): array
'ldapType' => $postData['ldapType'],
];
}
}
}
Loading