mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-11 13:38:39 +00:00
crash backup
This commit is contained in:
parent
18453a392d
commit
847efda976
|
|
@ -357,8 +357,8 @@ final class ApiController extends Controller
|
|||
{
|
||||
/** @var \Modules\Admin\Models\Account $account */
|
||||
$account = $request->hasData('user')
|
||||
? AccountMapper::get()->where('login', (string) $request->getData('user'))->execute()
|
||||
: AccountMapper::get()->where('email', (string) $request->getData('email'))->execute();
|
||||
? AccountMapper::get()->where('login', $request->getDataString('user') ?? '')->execute()
|
||||
: AccountMapper::get()->where('email', $request->getDataString('email') ?? '')->execute();
|
||||
|
||||
/** @var \Model\Setting[] $forgotten */
|
||||
$forgotten = $this->app->appSettings->get(
|
||||
|
|
@ -486,7 +486,7 @@ final class ApiController extends Controller
|
|||
$forgotten = $this->app->appSettings->get(
|
||||
names: [SettingsEnum::LOGIN_FORGOTTEN_DATE, SettingsEnum::LOGIN_FORGOTTEN_TOKEN],
|
||||
module: self::NAME,
|
||||
account: (int) $request->getData('user')
|
||||
account: $request->getDataInt('user') ?? 0
|
||||
);
|
||||
|
||||
$date = new \DateTime($forgotten[SettingsEnum::LOGIN_FORGOTTEN_DATE]->content);
|
||||
|
|
@ -508,7 +508,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var \Modules\Admin\Models\Account $account */
|
||||
$account = AccountMapper::get()->where('id', (int) $request->getData('user'))->execute();
|
||||
$account = AccountMapper::get()->where('id', $request->getDataInt('user') ?? 0)->execute();
|
||||
|
||||
$account->generatePassword($pass = StringRng::generateString(10, 14, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_-+=/\\{}<>?'));
|
||||
|
||||
|
|
@ -854,7 +854,7 @@ final class ApiController extends Controller
|
|||
|
||||
// test old password is correct
|
||||
if ($account->login === null
|
||||
|| AccountMapper::login($account->login, (string) $request->getData('oldpass')) !== $requestAccount
|
||||
|| AccountMapper::login($account->login, $request->getDataString('oldpass') ?? '') !== $requestAccount
|
||||
) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, '', 'Invalid old password', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
|
@ -863,7 +863,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
// test password repetition
|
||||
if (((string) $request->getData('newpass')) !== ((string) $request->getData('reppass'))) {
|
||||
if ($request->getDataString('newpass') !== $request->getDataString('reppass')) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, '', 'Invalid password repetition', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
||||
|
|
@ -873,14 +873,14 @@ final class ApiController extends Controller
|
|||
// test password complexity
|
||||
/** @var \Model\Setting $complexity */
|
||||
$complexity = $this->app->appSettings->get(names: SettingsEnum::PASSWORD_PATTERN, module: 'Admin');
|
||||
if (\preg_match($complexity->content, (string) $request->getData('newpass')) !== 1) {
|
||||
if (\preg_match($complexity->content, $request->getDataString('newpass') ?? '') !== 1) {
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, '', 'Invalid password complexity', []);
|
||||
$response->header->status = RequestStatusCode::R_403;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$account->generatePassword((string) $request->getData('newpass'));
|
||||
$account->generatePassword($request->getDataString('newpass') ?? '');
|
||||
|
||||
AccountMapper::update()->execute($account);
|
||||
|
||||
|
|
@ -953,7 +953,7 @@ final class ApiController extends Controller
|
|||
/** @var \Modules\Admin\Models\Account $account */
|
||||
$account = AccountMapper::get()
|
||||
->with('l11n')
|
||||
->where('l11n/id', (int) $request->getData('id'))
|
||||
->where('l11n/id', $request->getDataInt('id') ?? 0)
|
||||
->execute();
|
||||
|
||||
$requestAccount = $request->header->account;
|
||||
|
|
@ -991,7 +991,7 @@ final class ApiController extends Controller
|
|||
|
||||
if ($account->l11n->id === 0) {
|
||||
$l11n = LocalizationMapper::get()
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('id', $request->getDataInt('id') ?? 0)
|
||||
->execute();
|
||||
} else {
|
||||
$l11n = $account->l11n;
|
||||
|
|
@ -1338,7 +1338,7 @@ final class ApiController extends Controller
|
|||
public function apiGroupGet(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
/** @var \Modules\Admin\Models\Group $group */
|
||||
$group = GroupMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$group = GroupMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->createStandardReturnResponse($request, $response, $group);
|
||||
}
|
||||
|
||||
|
|
@ -1358,7 +1358,7 @@ final class ApiController extends Controller
|
|||
public function apiGroupUpdate(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
/** @var \Modules\Admin\Models\Group $old */
|
||||
$old = GroupMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = GroupMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$new = $this->updateGroupFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, GroupMapper::class, 'group', $request->getOrigin());
|
||||
|
|
@ -1475,7 +1475,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
if (((int) $request->getData('id')) === 3) {
|
||||
if (($request->getDataInt('id') ?? 0) === 3) {
|
||||
// admin group cannot be deleted
|
||||
$this->createInvalidDeleteResponse($request, $response, []);
|
||||
|
||||
|
|
@ -1483,7 +1483,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var \Modules\Admin\Models\Group $group */
|
||||
$group = GroupMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$group = GroupMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModel($request->header->account, $group, GroupMapper::class, 'group', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $group);
|
||||
}
|
||||
|
|
@ -1551,7 +1551,7 @@ final class ApiController extends Controller
|
|||
public function apiAccountGet(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
/** @var Account $account */
|
||||
$account = AccountMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$account = AccountMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->createStandardReturnResponse($request, $response, $account);
|
||||
}
|
||||
|
||||
|
|
@ -2344,7 +2344,7 @@ final class ApiController extends Controller
|
|||
public function apiAccountDelete(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
/** @var Account $account */
|
||||
$account = AccountMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$account = AccountMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModel($request->header->account, $account, AccountMapper::class, 'account', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $account);
|
||||
}
|
||||
|
|
@ -2366,7 +2366,7 @@ final class ApiController extends Controller
|
|||
{
|
||||
/** @var Account $old */
|
||||
$old = AccountMapper::get()
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('id', $request->getDataInt('id') ?? 0)
|
||||
->execute();
|
||||
|
||||
$new = $this->updateAccountFromRequest($request, clone $old);
|
||||
|
|
@ -2438,7 +2438,7 @@ final class ApiController extends Controller
|
|||
$old = ModuleMapper::get()->where('id', $module)->execute();
|
||||
|
||||
$this->app->eventManager->triggerSimilar(
|
||||
'PRE:Module:Admin-module-status-update', '',
|
||||
'PRE:Admin-module-status-update', '',
|
||||
[
|
||||
$request->header->account,
|
||||
['status' => $status, 'module' => $module],
|
||||
|
|
@ -2572,7 +2572,7 @@ final class ApiController extends Controller
|
|||
$new = ModuleMapper::get()->where('id', $module)->execute();
|
||||
|
||||
$this->app->eventManager->triggerSimilar(
|
||||
'POST:Module:Admin-module-status-update', '',
|
||||
'POST:Admin-module-status-update', '',
|
||||
[
|
||||
$request->header->account,
|
||||
$old, $new,
|
||||
|
|
@ -2613,7 +2613,7 @@ final class ApiController extends Controller
|
|||
public function apiAccountPermissionGet(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
/** @var AccountPermission $account */
|
||||
$account = AccountPermissionMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$account = AccountPermissionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->createStandardReturnResponse($request, $response, $account);
|
||||
}
|
||||
|
||||
|
|
@ -2633,7 +2633,7 @@ final class ApiController extends Controller
|
|||
public function apiGroupPermissionGet(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
/** @var GroupPermission $group */
|
||||
$group = GroupPermissionMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$group = GroupPermissionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->createStandardReturnResponse($request, $response, $group);
|
||||
}
|
||||
|
||||
|
|
@ -2660,7 +2660,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var GroupPermission $permission */
|
||||
$permission = GroupPermissionMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$permission = GroupPermissionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
|
||||
if ($permission->getGroup() === 3) {
|
||||
// admin group cannot be deleted
|
||||
|
|
@ -2696,7 +2696,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var AccountPermission $permission */
|
||||
$permission = AccountPermissionMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$permission = AccountPermissionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModel($request->header->account, $permission, AccountPermissionMapper::class, 'user-permission', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $permission);
|
||||
}
|
||||
|
|
@ -2872,7 +2872,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var AccountPermission $old */
|
||||
$old = AccountPermissionMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = AccountPermissionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
|
||||
/** @var AccountPermission $new */
|
||||
$new = $this->updatePermissionFromRequest($request, clone $old);
|
||||
|
|
@ -2904,7 +2904,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var GroupPermission $old */
|
||||
$old = GroupPermissionMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = GroupPermissionMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
|
||||
if ($old->getGroup() === 3) {
|
||||
// admin group cannot be deleted
|
||||
|
|
@ -3385,7 +3385,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$settings = SettingMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$settings = SettingMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModel($request->header->account, $settings, SettingMapper::class, 'settings', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $settings);
|
||||
}
|
||||
|
|
@ -3432,7 +3432,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var App $old */
|
||||
$old = AppMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = AppMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$new = $this->updateApplicationFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AppMapper::class, 'application', $request->getOrigin());
|
||||
|
|
@ -3498,7 +3498,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var \Modules\Admin\Models\App $application */
|
||||
$application = AppMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$application = AppMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModel($request->header->account, $application, AppMapper::class, 'application', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $application);
|
||||
}
|
||||
|
|
@ -3642,7 +3642,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var Contact $old */
|
||||
$old = ContactMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = ContactMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$new = $this->updateContactFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, ContactMapper::class, 'contact', $request->getOrigin());
|
||||
|
|
@ -3712,7 +3712,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var \Modules\Admin\Models\Contact $contact */
|
||||
$contact = ContactMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$contact = ContactMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModelRelation($request->header->account, (int) $request->getData('account'), [$contact->id], AccountMapper::class, 'contacts', 'account-contact', $request->getOrigin());
|
||||
$this->deleteModel($request->header->account, $contact, ContactMapper::class, 'contact', $request->getOrigin());
|
||||
|
||||
|
|
@ -3825,7 +3825,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var \Modules\Admin\Models\DataChange $data */
|
||||
$data = DataChangeMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$data = DataChangeMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModel($request->header->account, $data, DataChangeMapper::class, 'data', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $data);
|
||||
}
|
||||
|
|
@ -3872,7 +3872,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var \phpOMS\Stdlib\Base\Address $address */
|
||||
$address = AddressMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$address = AddressMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$this->deleteModelRelation($request->header->account, (int) $request->getData('account'), [$address->id], AccountMapper::class, 'addresses', 'account-address', $request->getOrigin());
|
||||
$this->deleteModel($request->header->account, $address, AddressMapper::class, 'address', $request->getOrigin());
|
||||
|
||||
|
|
@ -3923,7 +3923,7 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
/** @var Address $old */
|
||||
$old = AddressMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$old = AddressMapper::get()->where('id', $request->getDataInt('id') ?? 0)->execute();
|
||||
$new = $this->updateAddressFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AddressMapper::class, 'address', $request->getOrigin());
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ final class BackendController extends Controller
|
|||
$account = AccountMapper::get()
|
||||
->with('groups')
|
||||
->with('l11n')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('id', $request->getDataInt('id') ?? 0)
|
||||
->execute();
|
||||
|
||||
if ($account->l11n->id === 0) {
|
||||
|
|
@ -209,7 +209,7 @@ final class BackendController extends Controller
|
|||
|
||||
/** @var \Modules\Admin\Models\AccountPermission[] $permissions */
|
||||
$permissions = AccountPermissionMapper::getAll()
|
||||
->where('account', (int) $request->getData('id'))
|
||||
->where('account', $request->getDataInt('id') ?? 0)
|
||||
->executeGetArray();
|
||||
|
||||
$view->data['permissions'] = $permissions;
|
||||
|
|
@ -419,12 +419,12 @@ final class BackendController extends Controller
|
|||
|
||||
$view->data['group'] = GroupMapper::get()
|
||||
->with('accounts')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('id', $request->getDataInt('id') ?? 0)
|
||||
->execute();
|
||||
|
||||
/** @var \Modules\Admin\Models\GroupPermission[] $permissions */
|
||||
$permissions = GroupPermissionMapper::getAll()
|
||||
->where('group', (int) $request->getData('id'))
|
||||
->where('group', $request->getDataInt('id') ?? 0)
|
||||
->executeGetArray();
|
||||
|
||||
$view->data['permissions'] = $permissions;
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ class AccountMapper extends DataMapperFactory
|
|||
{
|
||||
$accounts = [];
|
||||
|
||||
// Find accounts with permission
|
||||
$sql = <<<SQL
|
||||
SELECT account_permission_account as account
|
||||
FROM account_permission
|
||||
|
|
@ -313,6 +314,7 @@ class AccountMapper extends DataMapperFactory
|
|||
$accounts[] = (int) $result['account'];
|
||||
}
|
||||
|
||||
// Find groups with permission and return all of their accounts
|
||||
$sql = <<<SQL
|
||||
SELECT account_group_account as account
|
||||
FROM account_group
|
||||
|
|
@ -333,4 +335,65 @@ class AccountMapper extends DataMapperFactory
|
|||
|
||||
return \array_unique($accounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find accounts that have read permission
|
||||
*
|
||||
* @param int $unitId Unit id
|
||||
* @param string $module Module name
|
||||
* @param int $category Category
|
||||
* @param int $element Element id
|
||||
*
|
||||
* @return int[] Account ids
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function findCreatePermission(
|
||||
int $unitId,
|
||||
string $module,
|
||||
int $category,
|
||||
int $element,
|
||||
) : array
|
||||
{
|
||||
$accounts = [];
|
||||
|
||||
// Find accounts with permission
|
||||
$sql = <<<SQL
|
||||
SELECT account_permission_account as account
|
||||
FROM account_permission
|
||||
WHERE (account_permission_unit = {$unitId} OR account_permission_unit IS NULL)
|
||||
AND (account_permission_module = "{$module}" OR account_permission_module IS NULL)
|
||||
AND (account_permission_category = {$category} OR account_permission_category IS NULL)
|
||||
AND (account_permission_element = {$element} OR account_permission_element IS NULL)
|
||||
AND account_permission_hascreate = 1;
|
||||
SQL;
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
foreach ($results as $result) {
|
||||
$accounts[] = (int) $result['account'];
|
||||
}
|
||||
|
||||
// Find groups with permission and return all of their accounts
|
||||
$sql = <<<SQL
|
||||
SELECT account_group_account as account
|
||||
FROM account_group
|
||||
LEFT JOIN group_permission ON account_group.account_group_group = group_permission.group_permission_group
|
||||
WHERE (group_permission_unit = {$unitId} OR group_permission_unit IS NULL)
|
||||
AND (group_permission_module = "{$module}" OR group_permission_module IS NULL)
|
||||
AND (group_permission_category = {$category} OR group_permission_category IS NULL)
|
||||
AND (group_permission_element = {$element} OR group_permission_element IS NULL)
|
||||
AND group_permission_hascreate = 1;
|
||||
SQL;
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
foreach ($results as $result) {
|
||||
$accounts[] = (int) $result['account'];
|
||||
}
|
||||
|
||||
return \array_unique($accounts);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,4 +142,86 @@ final class GroupMapper extends DataMapperFactory
|
|||
|
||||
return $result === null ? [] : $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find groups that have read permission
|
||||
*
|
||||
* @param int $unitId Unit id
|
||||
* @param string $module Module name
|
||||
* @param int $category Category
|
||||
* @param int $element Element id
|
||||
*
|
||||
* @return int[] Group ids
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function findReadPermission(
|
||||
int $unitId,
|
||||
string $module,
|
||||
int $category,
|
||||
int $element,
|
||||
) : array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
$sql = <<<SQL
|
||||
SELECT group_permission_group as group
|
||||
FROM group_permission
|
||||
WHERE (group_permission_unit = {$unitId} OR group_permission_unit IS NULL)
|
||||
AND (group_permission_module = "{$module}" OR group_permission_module IS NULL)
|
||||
AND (group_permission_category = {$category} OR group_permission_category IS NULL)
|
||||
AND (group_permission_element = {$element} OR group_permission_element IS NULL)
|
||||
AND group_permission_hasread = 1;
|
||||
SQL;
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
foreach ($results as $result) {
|
||||
$groups[] = (int) $result['group'];
|
||||
}
|
||||
|
||||
return \array_unique($groups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find groups that have read permission
|
||||
*
|
||||
* @param int $unitId Unit id
|
||||
* @param string $module Module name
|
||||
* @param int $category Category
|
||||
* @param int $element Element id
|
||||
*
|
||||
* @return int[] Group ids
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function findCreatePermission(
|
||||
int $unitId,
|
||||
string $module,
|
||||
int $category,
|
||||
int $element,
|
||||
) : array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
$sql = <<<SQL
|
||||
SELECT group_permission_group as group
|
||||
FROM group_permission
|
||||
WHERE (group_permission_unit = {$unitId} OR group_permission_unit IS NULL)
|
||||
AND (group_permission_module = "{$module}" OR group_permission_module IS NULL)
|
||||
AND (group_permission_category = {$category} OR group_permission_category IS NULL)
|
||||
AND (group_permission_element = {$element} OR group_permission_element IS NULL)
|
||||
AND group_permission_hascreate = 1;
|
||||
SQL;
|
||||
|
||||
$query = new Builder(self::$db);
|
||||
$results = $query->raw($sql)->execute()?->fetchAll(\PDO::FETCH_ASSOC) ?? [];
|
||||
|
||||
foreach ($results as $result) {
|
||||
$groups[] = (int) $result['group'];
|
||||
}
|
||||
|
||||
return \array_unique($groups);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class GroupTagSelectorView extends View
|
|||
$this->id = $data[0];
|
||||
$this->isRequired = $data[1] ?? false;
|
||||
|
||||
$this->getData('group-selector-popup')->id = $this->id;
|
||||
$this->data['group-selector-popup']->id = $this->id;
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ $tableView->setObjects($accounts);
|
|||
|
||||
$previous = $tableView->getPreviousLink(
|
||||
$this->request,
|
||||
empty($this->objects) || !$this->getData('hasPrevious') ? null : \reset($this->objects)
|
||||
empty($this->objects) || !($this->data['hasPrevious'] ?? false) ? null : \reset($this->objects)
|
||||
);
|
||||
|
||||
$next = $tableView->getNextLink(
|
||||
$this->request,
|
||||
empty($this->objects) ? null : \end($this->objects),
|
||||
$this->getData('hasNext') ?? false
|
||||
$this->data['hasNext'] ?? false
|
||||
);
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
|
|
@ -107,12 +107,12 @@ echo $this->data['nav']->render(); ?>
|
|||
</table>
|
||||
</div>
|
||||
<!--
|
||||
<?php if ($this->getData('hasPrevious') || $this->getData('hasNext')) : ?>
|
||||
<?php if (($this->data['hasPrevious'] ?? false) || ($this->data['hasNext'] ?? false)) : ?>
|
||||
<div class="portlet-foot">
|
||||
<?php if ($this->getData('hasPrevious')) : ?>
|
||||
<?php if ($this->data['hasPrevious']) : ?>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><i class="g-icon">chevron_left</i></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->getData('hasNext')) : ?>
|
||||
<?php if ($this->data['hasNext']) : ?>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><i class="g-icon">chevron_right</i></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ $tableView->setObjects($audits);
|
|||
|
||||
$previous = $tableView->getPreviousLink(
|
||||
$this->request,
|
||||
empty($tableView->objects) || !$this->getData('hasPrevious') ? null : \reset($tableView->objects)
|
||||
empty($tableView->objects) || !($this->data['hasPrevious'] ?? false) ? null : \reset($tableView->objects)
|
||||
);
|
||||
|
||||
$next = $tableView->getNextLink(
|
||||
$this->request,
|
||||
empty($tableView->objects) ? null : \end($tableView->objects),
|
||||
$this->getData('hasNext') ?? false
|
||||
$this->data['hasNext'] ?? false
|
||||
);
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
|
|
@ -519,12 +519,12 @@ echo $this->data['nav']->render(); ?>
|
|||
</table>
|
||||
</div>
|
||||
<!--
|
||||
<?php if ($this->getData('hasPrevious') || $this->getData('hasNext')) : ?>
|
||||
<?php if (($this->data['hasPrevious'] ?? false) || ($this->data['hasNext'] ?? false)) : ?>
|
||||
<div class="portlet-foot">
|
||||
<?php if ($this->getData('hasPrevious')) : ?>
|
||||
<?php if ($this->data['hasPrevious']) : ?>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><i class="g-icon">chevron_left</i></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->getData('hasNext')) : ?>
|
||||
<?php if ($this->data['hasNext']) : ?>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><i class="g-icon">chevron_right</i></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<?= $this->data['editor']->render('group-editor'); ?>
|
||||
</div>
|
||||
|
||||
<?= $this->data['editor']->getData('text')->render('group-editor', 'description', 'fGroupCreate'); ?>
|
||||
<?= $this->data['editor']->data['text']->render('group-editor', 'description', 'fGroupCreate'); ?>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
<input type="submit" id="iCreateGroup" name="create" value="<?= $this->getHtml('Create', '0', '0'); ?>">
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ $tableView->setObjects($groups);
|
|||
|
||||
$previous = $tableView->getPreviousLink(
|
||||
$this->request,
|
||||
empty($this->objects) || !$this->getData('hasPrevious') ? null : \reset($this->objects)
|
||||
empty($this->objects) || !($this->data['hasPrevious'] ?? false) ? null : \reset($this->objects)
|
||||
);
|
||||
|
||||
$next = $tableView->getNextLink(
|
||||
$this->request,
|
||||
empty($this->objects) ? null : \end($this->objects),
|
||||
$this->getData('hasNext') ?? false
|
||||
$this->data['hasNext'] ?? false
|
||||
);
|
||||
|
||||
echo $this->data['nav']->render(); ?>
|
||||
|
|
@ -104,12 +104,12 @@ echo $this->data['nav']->render(); ?>
|
|||
</table>
|
||||
</div>
|
||||
<!--
|
||||
<?php if ($this->getData('hasPrevious') || $this->getData('hasNext')) : ?>
|
||||
<?php if (($this->data['hasPrevious'] ?? false) || ($this->data['hasNext'] ?? false)) : ?>
|
||||
<div class="portlet-foot">
|
||||
<?php if ($this->getData('hasPrevious')) : ?>
|
||||
<?php if ($this->data['hasPrevious']) : ?>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><i class="g-icon">chevron_left</i></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($this->getData('hasNext')) : ?>
|
||||
<?php if ($this->data['hasNext']) : ?>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><i class="g-icon">chevron_right</i></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -71,10 +71,10 @@ echo $this->data['nav']->render(); ?>
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= $this->getData('editor')->render('group-editor'); ?>
|
||||
<?= $this->data['editor']->render('group-editor'); ?>
|
||||
</div>
|
||||
|
||||
<?= $this->getData('editor')->getData('text')->render(
|
||||
<?= $this->data['editor']->data['text']->render(
|
||||
'group-editor',
|
||||
'description',
|
||||
'fGroupEdit',
|
||||
|
|
@ -105,8 +105,8 @@ echo $this->data['nav']->render(); ?>
|
|||
<input id="iGroupId" name="group" type="hidden" value="<?= $group->id; ?>" disabled>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAccount"><?= $this->getHtml('Name'); ?></label>
|
||||
<?= $this->getData('accGrpSelector')->render('iAccount', 'group', true); ?>
|
||||
<label for="iiAccount"><?= $this->getHtml('Name'); ?></label>
|
||||
<?= $this->data['accGrpSelector']->render('iAccount', 'group', true); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ declare(strict_types=1);
|
|||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
$hooks = $this->data['hooks'] ?? [];
|
||||
$module = $this->getData('module') ?? '';
|
||||
$module = $this->data['module'] ?? '';
|
||||
|
||||
echo $this->data['nav']->render();
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use phpOMS\Router\RouteVerb;
|
|||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
$routes = $this->data['routes'] ?? [];
|
||||
$module = $this->getData('module') ?? '';
|
||||
$module = $this->data['module'] ?? '';
|
||||
|
||||
echo $this->data['nav']->render();
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ $settings = $this->data['settings'] ?? [];
|
|||
echo $this->data['nav']->render();
|
||||
|
||||
if ($this->hasData('settingsTpl')
|
||||
&& \is_file($this->getData('settingsTpl'))
|
||||
&& \is_file($this->data['settingsTpl'])
|
||||
) :
|
||||
include $this->data['settingsTpl'];
|
||||
else :
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ use phpOMS\Uri\UriFactory;
|
|||
<?php
|
||||
$name = $setting->name;
|
||||
|
||||
if ($this->getData('settings_class') !== null) {
|
||||
$name = $this->getData('settings_class')::getName($setting->name);
|
||||
if ($this->data['settings_class'] !== null) {
|
||||
$name = $this->data['settings_class']::getName($setting->name);
|
||||
|
||||
if (!\is_string($name)) {
|
||||
$name = $setting->name;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user