mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
// +-----------------------------------------------------------------------+
|
|
// | This file is part of Piwigo. |
|
|
// | |
|
|
// | For copyright and license information, please view the COPYING.txt |
|
|
// | file that was distributed with this source code. |
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
|
|
|
|
$upgrade_description = 'add ASC keyword to categories image_order field';
|
|
|
|
|
|
$query = '
|
|
SELECT id, image_order
|
|
FROM '.CATEGORIES_TABLE.'
|
|
WHERE image_order != ""
|
|
;';
|
|
$cats = hash_from_query($query, 'id');
|
|
|
|
foreach ($cats as $id => &$data)
|
|
{
|
|
$image_order = explode(',',$data['image_order']);
|
|
foreach ($image_order as &$order)
|
|
{
|
|
if (strpos($order, ' ASC')===false && strpos($order, ' DESC')===false)
|
|
{
|
|
$order.= ' ASC';
|
|
}
|
|
}
|
|
unset($order);
|
|
$data['image_order'] = implode(',',$image_order);
|
|
}
|
|
unset($data);
|
|
|
|
mass_updates(CATEGORIES_TABLE,
|
|
array(
|
|
'primary' => array('id'),
|
|
'update' => array('image_order'),
|
|
),
|
|
$cats
|
|
);
|
|
|
|
|
|
echo "\n".$upgrade_description."\n";
|
|
|
|
?>
|