|
|
@@ -21,6 +21,30 @@ class Route_Storage_AclReinstall extends RouteBase {
|
|
|
$namespace = V::get('namespace', '', $_GET);
|
|
|
if (empty($namespace)) throw new Exception("Missing param namespace");
|
|
|
echo UI::h('h3', [], $namespace);
|
|
|
+ echo UI::h('p', [], [
|
|
|
+ UI::h('a', [
|
|
|
+ 'href' => Router::getRoute('Storage_AclStruct')->getLink('', [ 'namespace' => $namespace ]),
|
|
|
+ 'class' => "btn btn-md btn-link",
|
|
|
+ ], "<i class=\"glyphicon glyphicon-arrow-left\"></i> Wróć do struktury"),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ('reinstall' !== V::get('_postTask', '', $_POST)) {
|
|
|
+ echo UI::hButtonPost("Reinstall", [
|
|
|
+ 'data' => [
|
|
|
+ '_postTask' => 'reinstall'
|
|
|
+ ],
|
|
|
+ 'class' => 'btn btn-md btn-danger',
|
|
|
+ 'title' => "Reinstall structure"
|
|
|
+ ]);
|
|
|
+ echo '<hr>';
|
|
|
+ try {
|
|
|
+ $this->printReinstallPreview($namespace);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ DBG::log($e);
|
|
|
+ UI::alert('danger', $e->getMessage());
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
Lib::loadClass('Schema_SystemObjectFieldStorageAcl');
|
|
|
$objFieldAcl = new Schema_SystemObjectFieldStorageAcl();
|
|
|
@@ -61,4 +85,62 @@ class Route_Storage_AclReinstall extends RouteBase {
|
|
|
UI::dol();
|
|
|
}
|
|
|
|
|
|
+ public function printReinstallPreview($namespace) {
|
|
|
+ $objectItem = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => "*,field" ]);
|
|
|
+ DBG::log($objectItem, 'array', '$objectItem preview');
|
|
|
+
|
|
|
+ switch ($objectItem['_type']) {
|
|
|
+ case 'AntAcl': $this->printReinstallAntAclPreview($objectItem); break;
|
|
|
+ case 'TableAcl': $this->printReinstallTableAclPreview($objectItem); break;
|
|
|
+ default: throw new Exception("TODO: Not Implemented type '{$objectItem['_type']}'");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function printReinstallAntAclPreview($item) {
|
|
|
+ $antAclPath = APP_PATH_SCHEMA . DS . 'ant-object' . DS . str_replace(['__x3A__', ':'], ['.', '/'], $item['typeName']);
|
|
|
+ if (!file_exists("{$antAclPath}/build.xml")) throw new Exception("Ant build file not exists");
|
|
|
+
|
|
|
+ Lib::loadClass('XML');
|
|
|
+ $xsdType = XML::getXsdTypeFromXsdSchema("{$antAclPath}/{$item['name']}.xsd", $namespace = $item['namespace'], $name = $item['name']);
|
|
|
+ DBG::nicePrint($xsdType, '$xsdType');
|
|
|
+ if (empty($xsdType['struct'])) throw new Exception("Field list not found for '{$item['namespace']}'");
|
|
|
+ foreach ($xsdType['struct'] as $fieldName => $x) {
|
|
|
+ $listEnum = [];
|
|
|
+ if (!empty($x['restrictions']['enumeration'])) {
|
|
|
+ $listEnum = $x['restrictions']['enumeration'];
|
|
|
+ unset($x['restrictions']['enumeration']);
|
|
|
+ }
|
|
|
+ // DB::getPDO()->insertOrUpdate($this->_rootTableName, [
|
|
|
+ // 'namespace' => "{$item['namespace']}/{$fieldName}",
|
|
|
+ // 'objectNamespace' => $item['namespace'],
|
|
|
+ // 'idDatabase' => $item['idDatabase'],
|
|
|
+ // '_rootTableName' => $item['_rootTableName'],
|
|
|
+ // 'fieldNamespace' => $fieldName,
|
|
|
+ // 'xsdType' => $x['type'],
|
|
|
+ // 'xsdRestrictions' => json_encode($x['restrictions']),
|
|
|
+ // 'appInfo' => json_encode($x['appInfo']),
|
|
|
+ // 'minOccurs' => $x['minOccurs'],
|
|
|
+ // 'maxOccurs' => $x['maxOccurs'],
|
|
|
+ // 'isActive' => 1
|
|
|
+ // ]);
|
|
|
+ if (!empty($listEnum)) {
|
|
|
+ DBG::nicePrint($listEnum, "\$listEnum for field '{$fieldName}'");
|
|
|
+ foreach ($listEnum as $value => $label) {
|
|
|
+ // DB::getPDO()->insertOrUpdate("{$this->_rootTableName}_enum", [
|
|
|
+ // 'namespace' => "{$item['namespace']}/{$fieldName}/@{$value}",
|
|
|
+ // 'fieldNamespace' => $fieldName,
|
|
|
+ // 'objectNamespace' => $item['namespace'],
|
|
|
+ // 'value' => $value,
|
|
|
+ // 'label' => $label,
|
|
|
+ // 'isActive' => 1
|
|
|
+ // ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ throw new Exception("TODO: printReinstallAntAclPreview...");
|
|
|
+ }
|
|
|
+ public function printReinstallTableAclPreview($item) {
|
|
|
+ throw new Exception("TODO: printReinstallTableAclPreview...");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|