From: Michael J. Rubinsky Date: Thu, 16 Sep 2010 22:17:38 +0000 (-0400) Subject: Add upgrade/migration script for new style format. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9ac68806590918892ec7626bc1ef3f99c005cc97;p=horde.git Add upgrade/migration script for new style format. Run this after the db migration is run. Do not remove or change anything in the config/styles.php before this is run. --- diff --git a/ansel/scripts/upgrades/2010-09-16_migrate_styles.php b/ansel/scripts/upgrades/2010-09-16_migrate_styles.php new file mode 100644 index 000000000..b698fb077 --- /dev/null +++ b/ansel/scripts/upgrades/2010-09-16_migrate_styles.php @@ -0,0 +1,45 @@ +#!/usr/bin/env php + + */ +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); + +// Make sure we have the full styles array. +require ANSEL_BASE . '/config/styles.php'; + +$sql = 'SELECT share_id, attribute_style FROM ansel_shares'; +$cli->message('Migrating gallery styles.', 'cli.message'); +$defaults = array( + 'thumbstyle' => 'Thumb', + 'background' => 'none', + 'gallery_view' => 'Gallery', + 'widgets' => array( + 'Tags' => array('view' => 'gallery'), + 'OtherGalleries' => array(), + 'Geotag' => array(), + 'Links' => array(), + 'GalleryFaces' => array(), + 'OwnerFaces' => array())); + +$rows = $ansel_db->queryAll($sql); +$update = $ansel_db->prepare('UPDATE ansel_shares SET attribute_style=? WHERE share_id=?;'); +foreach ($rows as $row) { + if ($row[1] == 'ansel_default') { + $newStyle = ''; + } else { + $properties = array_merge($defaults, $styles[$row[1]]); + unset($properties['requires_png']); + unset($properties['name']); + unset($properties['title']); + unset($properties['hide']); + $newStyle = serialize(new Ansel_Style($properties)); + } + $update->execute(array($newStyle, $row[0])); +} +$cli->message('Gallery styles successfully migrated.', 'cli.success');