From 8d8f50eadc79b880a4fa34cc2d656b09f51f30fa Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Thu, 5 Oct 2017 12:25:45 +0200 Subject: [PATCH] fix: patch for brick uid --- bin/Site/Area.js | 4 ++++ patches/uniqueIds.php | 32 +++++++++++++++++++++++++++----- src/QUI/Bricks/Events.php | 8 ++++++++ src/QUI/Bricks/Manager.php | 12 ++++++++++-- 4 files changed, 49 insertions(+), 7 deletions(-) diff --git a/bin/Site/Area.js b/bin/Site/Area.js index 2f9d210..91d41a6 100644 --- a/bin/Site/Area.js +++ b/bin/Site/Area.js @@ -828,6 +828,10 @@ define('package/quiqqer/bricks/bin/Site/Area', [ data = QUIFormUtils.getFormData(Form), brickId = Select.getParent().get('id'); + if (typeof self.$brickCustomData[brickId] === 'undefined') { + self.$brickCustomData[brickId] = {}; + } + self.$brickCustomData[brickId].customfields = JSON.encode(data); Win.close(); diff --git a/patches/uniqueIds.php b/patches/uniqueIds.php index 047fa3f..8b83912 100644 --- a/patches/uniqueIds.php +++ b/patches/uniqueIds.php @@ -1,6 +1,7 @@ <?php define('QUIQQER_SYSTEM', true); +define('SYSTEM_INTERN', true); require dirname(dirname(dirname(dirname(__FILE__)))).'/header.php'; // workaround for older patch @@ -11,7 +12,7 @@ )); // if unique ids already exist, the pages no longer have to be passed through -if (isset($result[0]) && isset($result[0]['count']) && $result[0]['count']) { +if (false && isset($result[0]) && isset($result[0]['count']) && $result[0]['count']) { echo 'Already executed'.PHP_EOL; return; @@ -44,7 +45,7 @@ $id = $id['id']; try { - $Site = $Project->get($id); + $Site = new QUI\Projects\Site\Edit($Project, $id); $areas = $Site->getAttribute('quiqqer.bricks.areas'); if ($areas === false) { @@ -59,10 +60,11 @@ echo $Project->getName().'-'.$Project->getLang().'-'.$id.PHP_EOL; - $Edit = $Site->getEdit(); - $Edit->load(); - $Edit->save(QUI::getUsers()->getSystemUser()); + $Site->unlockWithRights(); + $Site->load(); + $Site->save(QUI::getUsers()->getSystemUser()); } catch (QUI\Exception $Exception) { + echo $Exception->getMessage().PHP_EOL; continue; } } @@ -70,3 +72,23 @@ unset($Edit); unset($Project); } + +echo 'Bricks saving...'; + +// alle bausteine speichern +$bricks = QUI::getDataBase()->fetch(array( + 'from' => $Bricks->getTable() +)); + +foreach ($bricks as $brick) { + try { + $Brick = $Bricks->getBrickById($brick['id']); + $Bricks->saveBrick($brick['id'], $Brick->getAttributes()); + } catch (QUI\Exception $Exception) { + QUI\System\Log::writeException($Exception); + echo $Exception->getMessage().PHP_EOL; + } +} + +echo '[done]'; +echo PHP_EOL; diff --git a/src/QUI/Bricks/Events.php b/src/QUI/Bricks/Events.php index 8c70aae..9e2cc20 100644 --- a/src/QUI/Bricks/Events.php +++ b/src/QUI/Bricks/Events.php @@ -17,6 +17,8 @@ */ class Events { + protected static $saved = array(); + /** * Event : on site save * Create site brick cache, for inheritance @@ -25,6 +27,10 @@ class Events */ public static function onSiteSave($Site) { + if (isset(self::$saved[$Site->getId()])) { + return; + } + QUI\Permissions\Permission::checkPermission('quiqqer.bricks.assign'); $areas = $Site->getAttribute('quiqqer.bricks.areas'); @@ -146,6 +152,8 @@ public static function onSiteSave($Site) )); } + self::$saved[$Site->getId()] = true; + // save bricks with unique ids $Site->setAttribute('quiqqer.bricks.areas', json_encode($areas)); $Site->save(); diff --git a/src/QUI/Bricks/Manager.php b/src/QUI/Bricks/Manager.php index 8ef9e30..851fe95 100644 --- a/src/QUI/Bricks/Manager.php +++ b/src/QUI/Bricks/Manager.php @@ -470,7 +470,15 @@ public function getBrickByUID($uid) $attributes = $data['attributes']; $attributes = json_decode($attributes, true); - $Original = new Brick($attributes); + $real = QUI::getDataBase()->fetch(array( + 'from' => $this->getTable(), + 'where' => array( + 'id' => (int)$brickId + ), + 'limit' => 1 + )); + + $Original = new Brick($real[0]); $Original->setAttribute('id', $brickId); $Clone = clone $Original; @@ -838,7 +846,7 @@ public function saveBrick($brickId, array $brickData) * * @return String */ - protected function getTable() + public static function getTable() { return QUI::getDBTableName(self::TABLE); } -- GitLab