|
|
@@ -8,13 +8,13 @@ Lib::loadClass('SchemaFactory');
|
|
|
|
|
|
class Route_Storage_AclStruct extends RouteBase {
|
|
|
|
|
|
- public function handleAuth() {
|
|
|
+ function handleAuth() {
|
|
|
if (!User::logged()) {
|
|
|
User::authByRequest();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function defaultAction() {
|
|
|
+ function defaultAction() {
|
|
|
UI::gora();
|
|
|
UI::menu();
|
|
|
// Router::getRoute('Storage')->navView(); // TODO: header like in Storage_AclUsage
|
|
|
@@ -35,6 +35,24 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
// [nsPrefix] => default_db__x3A__CRM_PROCES
|
|
|
// [typeName] => default_db__x3A__CRM_PROCES:CRM_PROCES
|
|
|
// [reinstallLink] => https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=Storage_AclReinstall&namespace=default_db/CRM_PROCES/CRM_PROCES
|
|
|
+
|
|
|
+ if ('_activateTableAclPostTask' === V::get('_postTask', '', $_POST)) {
|
|
|
+ try {
|
|
|
+ $ret = Router::getRoute('Storage')->activateTableAclAjax([ 'namespace' => $namespace ]);
|
|
|
+ if (!empty($ret) && 'success' == $ret['type']) UI::alert('success', $ret['msg']);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ('_deactivateObjectPostTask' === V::get('_postTask', '', $_POST)) {
|
|
|
+ try {
|
|
|
+ $ret = Router::getRoute('Storage')->deactivateObjectAjax([ 'namespace' => $namespace ]);
|
|
|
+ if (!empty($ret) && 'success' == $ret['type']) UI::alert('success', $ret['msg']);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
|
|
|
switch ($item['_type']) {
|
|
|
case 'TableAcl': $this->tableStructView($item, $item['name'], $item['idDatabase']); break;
|
|
|
@@ -50,7 +68,7 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
- public function tableStructAction() {
|
|
|
+ function tableStructAction() {
|
|
|
UI::gora();
|
|
|
UI::menu();
|
|
|
// Router::getRoute('Storage')->navView(); // TODO: header like in Storage_AclUsage
|
|
|
@@ -213,9 +231,9 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
]),
|
|
|
UI::h('div', ['style'=>"padding:4px 24px; border-top:1px solid #fff"], [
|
|
|
UI::h('span', ['style'=>"margin-right:12px"], [
|
|
|
- ( ($item['idZasob'] > 0)
|
|
|
- ? UI::h('span', [ 'title' => "Nr zasobu '{$item['idZasob']}'" ], "Nr zasobu [{$item['idZasob']}]")
|
|
|
- : UI::h('span', [ 'title' => "Brak nr zasobu - dodaj do zasobów" ], [
|
|
|
+ ( ($item['idZasob'] > 0)
|
|
|
+ ? UI::h('span', [ 'title' => "Nr zasobu '{$item['idZasob']}'" ], "Nr zasobu [{$item['idZasob']}]")
|
|
|
+ : UI::h('span', [ 'title' => "Brak nr zasobu - dodaj do zasobów" ], [
|
|
|
UI::hButtonAjax("+ do zasobów", 'addAclObjectToZasobyAjax', [
|
|
|
'class' => "btn btn-xs btn-primary",
|
|
|
'href' => Router::getRoute('Storage')->getLink('addAclObjectToZasobyAjax'),
|
|
|
@@ -227,41 +245,53 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
])
|
|
|
),
|
|
|
]),
|
|
|
- // UI::h('span', ['style'=>"margin:0 12px"], [
|
|
|
- // ( ($item['isObjectActive'] > 0)
|
|
|
- // ? UI::h('span', [ 'class' => "label label-success", 'title' => "Namespace active" ], "Active")
|
|
|
- // : UI::h('span', [ 'title' => "Namespace not active" ], [
|
|
|
- // ($item['idZasob'] > 0)
|
|
|
- // ? UI::hButtonAjax("Aktywuj", 'activateObjectAjax', [
|
|
|
- // 'class' => "btn btn-xs btn-primary",
|
|
|
- // 'href' => Router::getRoute('Storage')->getLink('activateObjectAjax'),
|
|
|
- // 'data' => [
|
|
|
- // 'namespace' => $item['namespace'],
|
|
|
- // ]
|
|
|
- // ])
|
|
|
- // : '',
|
|
|
- // ])
|
|
|
- // ),
|
|
|
- // ]),
|
|
|
+ UI::h('span', ['style'=>"margin:0 12px"], [
|
|
|
+ ( ($item['isObjectActive'] > 0)
|
|
|
+ ? UI::h('span', [ 'class' => "label label-success", 'title' => "Namespace active" ], "Active")
|
|
|
+ : UI::h('span', [ 'title' => "Namespace not active" ], [
|
|
|
+ ($item['idZasob'] > 0)
|
|
|
+ ? UI::hButtonPost("Aktywuj", [
|
|
|
+ 'class' => "btn btn-xs btn-primary",
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => '_activateTableAclPostTask',
|
|
|
+ 'namespace' => $item['namespace'],
|
|
|
+ ]
|
|
|
+ ])
|
|
|
+ : '',
|
|
|
+ ])
|
|
|
+ ),
|
|
|
+ ( ($item['isObjectActive'] > 0)
|
|
|
+ ? UI::h('span', [ 'title' => "Namespace is active" ], [
|
|
|
+ UI::hButtonPost("Wyłącz", [
|
|
|
+ 'class' => "btn btn-xs btn-default",
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => '_deactivateObjectPostTask',
|
|
|
+ 'namespace' => $item['namespace'],
|
|
|
+ ]
|
|
|
+ ])
|
|
|
+ ])
|
|
|
+ : ''
|
|
|
+ ),
|
|
|
+ ]),
|
|
|
UI::h('a', [
|
|
|
'href' => "index.php?_route=ViewTableAjax&namespace={$item['namespace']}",
|
|
|
'class' => "btn btn-sm btn-link"
|
|
|
], "Przeglądaj tabelę"),
|
|
|
- ( ($item['idZasob'] > 0)
|
|
|
- ? UI::h('a', [
|
|
|
+ ( ($item['idZasob'] > 0)
|
|
|
+ ? UI::h('a', [
|
|
|
'href' => "procesy5.php?task=CRM_LISTA_ZASOBOW&filtr_id={$item['idZasob']}&filtr_ids=%2B&filtr_ob=%2B",
|
|
|
'class' => "btn btn-sm btn-link",
|
|
|
'title' => "Struktura tabeli w drzewie zasobów"
|
|
|
], "Zasoby")
|
|
|
- : ''
|
|
|
+ : ''
|
|
|
),
|
|
|
- ( ($item['idZasob'] > 0)
|
|
|
- ? UI::h('a', [
|
|
|
+ ( ($item['idZasob'] > 0)
|
|
|
+ ? UI::h('a', [
|
|
|
'href' => "index.php?FUNCTION_INIT=PROCES_MENU&HEADER_NOT_INIT=YES&_task=PROCES_FOR_TABLE&tblId={$item['idZasob']}",
|
|
|
'class' => "btn btn-sm btn-link",
|
|
|
'title' => "Procesy dla aktualnie przeglądanej tabeli"
|
|
|
], "Procesy")
|
|
|
- : ''
|
|
|
+ : ''
|
|
|
),
|
|
|
// UI::h('a', [
|
|
|
// 'href' => Router::getRoute('Storage_AclReinstall')->getLink('', [ 'namespace' => $item['namespace'] ]),
|
|
|
@@ -284,6 +314,47 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
], "xsd"),
|
|
|
])
|
|
|
]);
|
|
|
+
|
|
|
+ $listFieldNames = array_map(V::makePick('name'), $tableList);
|
|
|
+ if ('_setTableAclPrimaryKey' === V::get('_postTask', '', $_POST)) {
|
|
|
+ $primaryKey = V::get('primryKey', '', $_POST);
|
|
|
+ DBG::nicePrint($primaryKey, "\$primaryKey='{$primaryKey}'");
|
|
|
+ if (!in_array($primaryKey, $listFieldNames)) {
|
|
|
+ UI::alert('danger', "Wybrano niewłaściwe pole");
|
|
|
+ } else {
|
|
|
+ UI::alert('warning', "TODO: ustaw '{$primaryKey}'");
|
|
|
+ SchemaFactory::loadDefaultObject('SystemObject')->updateItem([
|
|
|
+ 'namespace' => $item['namespace'],
|
|
|
+ 'primaryKey' => $primaryKey,
|
|
|
+ ]);
|
|
|
+ $item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($item['namespace'], [ 'propertyName' => '*,field' ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $primaryKey = $item['primaryKey'];
|
|
|
+ echo UI::h('form', [
|
|
|
+ 'class' => "form-inline",
|
|
|
+ 'style' => "margin:12px 0",
|
|
|
+ 'method' => "POST",
|
|
|
+ ], [
|
|
|
+ UI::h('label', [], "Primary Key:"),
|
|
|
+ UI::h('select', [ 'type' => "select", 'class' => "form-control", 'name' => "primryKey" ],
|
|
|
+ array_merge(
|
|
|
+ [ UI::h('option', [ 'value' => "-1" ], " [ wybierz ] ") ],
|
|
|
+ array_map(function ($itemTableList) use ($primaryKey) {
|
|
|
+ return UI::h('option', array_merge(
|
|
|
+ [ 'value' => $itemTableList['name'] ],
|
|
|
+ ($primaryKey === $itemTableList['name'])
|
|
|
+ ? [ 'selected' => "selected" ]
|
|
|
+ : []
|
|
|
+ ), $itemTableList['name']);
|
|
|
+ }, $tableList)
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ UI::h('input', [ 'type' => "hidden", 'name' => "_postTask", 'value' => "_setTableAclPrimaryKey" ]),
|
|
|
+ UI::h('input', [ 'type' => "submit", 'class' => "btn btn-default", 'value' => "Zapisz" ]),
|
|
|
+ ]);
|
|
|
+ if (!$item['primaryKey']) UI::alert('danger', "Nie ustawiono primaryKey");
|
|
|
+
|
|
|
UI::table([
|
|
|
'__html_id' => 'struct_table',
|
|
|
'caption' => "Struktura tabeli {$tblName} [{$idTable}]",
|