Skip to content
Code-Schnipsel Gruppen Projekte
Commit 8d8f50ea erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: patch for brick uid

Übergeordneter 1b231a55
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
...@@ -828,6 +828,10 @@ define('package/quiqqer/bricks/bin/Site/Area', [ ...@@ -828,6 +828,10 @@ define('package/quiqqer/bricks/bin/Site/Area', [
data = QUIFormUtils.getFormData(Form), data = QUIFormUtils.getFormData(Form),
brickId = Select.getParent().get('id'); brickId = Select.getParent().get('id');
if (typeof self.$brickCustomData[brickId] === 'undefined') {
self.$brickCustomData[brickId] = {};
}
self.$brickCustomData[brickId].customfields = JSON.encode(data); self.$brickCustomData[brickId].customfields = JSON.encode(data);
Win.close(); Win.close();
......
<?php <?php
define('QUIQQER_SYSTEM', true); define('QUIQQER_SYSTEM', true);
define('SYSTEM_INTERN', true);
require dirname(dirname(dirname(dirname(__FILE__)))).'/header.php'; require dirname(dirname(dirname(dirname(__FILE__)))).'/header.php';
// workaround for older patch // workaround for older patch
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
)); ));
// if unique ids already exist, the pages no longer have to be passed through // 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; echo 'Already executed'.PHP_EOL;
return; return;
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
$id = $id['id']; $id = $id['id'];
try { try {
$Site = $Project->get($id); $Site = new QUI\Projects\Site\Edit($Project, $id);
$areas = $Site->getAttribute('quiqqer.bricks.areas'); $areas = $Site->getAttribute('quiqqer.bricks.areas');
if ($areas === false) { if ($areas === false) {
...@@ -59,10 +60,11 @@ ...@@ -59,10 +60,11 @@
echo $Project->getName().'-'.$Project->getLang().'-'.$id.PHP_EOL; echo $Project->getName().'-'.$Project->getLang().'-'.$id.PHP_EOL;
$Edit = $Site->getEdit(); $Site->unlockWithRights();
$Edit->load(); $Site->load();
$Edit->save(QUI::getUsers()->getSystemUser()); $Site->save(QUI::getUsers()->getSystemUser());
} catch (QUI\Exception $Exception) { } catch (QUI\Exception $Exception) {
echo $Exception->getMessage().PHP_EOL;
continue; continue;
} }
} }
...@@ -70,3 +72,23 @@ ...@@ -70,3 +72,23 @@
unset($Edit); unset($Edit);
unset($Project); 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;
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
*/ */
class Events class Events
{ {
protected static $saved = array();
/** /**
* Event : on site save * Event : on site save
* Create site brick cache, for inheritance * Create site brick cache, for inheritance
...@@ -25,6 +27,10 @@ class Events ...@@ -25,6 +27,10 @@ class Events
*/ */
public static function onSiteSave($Site) public static function onSiteSave($Site)
{ {
if (isset(self::$saved[$Site->getId()])) {
return;
}
QUI\Permissions\Permission::checkPermission('quiqqer.bricks.assign'); QUI\Permissions\Permission::checkPermission('quiqqer.bricks.assign');
$areas = $Site->getAttribute('quiqqer.bricks.areas'); $areas = $Site->getAttribute('quiqqer.bricks.areas');
...@@ -146,6 +152,8 @@ public static function onSiteSave($Site) ...@@ -146,6 +152,8 @@ public static function onSiteSave($Site)
)); ));
} }
self::$saved[$Site->getId()] = true;
// save bricks with unique ids // save bricks with unique ids
$Site->setAttribute('quiqqer.bricks.areas', json_encode($areas)); $Site->setAttribute('quiqqer.bricks.areas', json_encode($areas));
$Site->save(); $Site->save();
......
...@@ -470,7 +470,15 @@ public function getBrickByUID($uid) ...@@ -470,7 +470,15 @@ public function getBrickByUID($uid)
$attributes = $data['attributes']; $attributes = $data['attributes'];
$attributes = json_decode($attributes, true); $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); $Original->setAttribute('id', $brickId);
$Clone = clone $Original; $Clone = clone $Original;
...@@ -838,7 +846,7 @@ public function saveBrick($brickId, array $brickData) ...@@ -838,7 +846,7 @@ public function saveBrick($brickId, array $brickData)
* *
* @return String * @return String
*/ */
protected function getTable() public static function getTable()
{ {
return QUI::getDBTableName(self::TABLE); return QUI::getDBTableName(self::TABLE);
} }
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren