aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-04-19 03:00:11 +0000
committerrvelices <rv-github@modusoptimus.com>2008-04-19 03:00:11 +0000
commit55095f9ce9d32fc12a6be8070adf74c9423d1d95 (patch)
tree81a7b1370b327d8aa1ef34497e393d84c391cbc0
parente57f06df4a089d4fb7ed45fa6f3cc61357ebf3d1 (diff)
merge -r 2303 from branch-1_7 to trunk
- removed some unused code - mass_updates function does not need SELECT VERSION() - rewrote update_uppercats to avoid db update if no change git-svn-id: http://piwigo.org/svn/trunk@2304 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions.php81
-rw-r--r--admin/picture_modify.php11
2 files changed, 22 insertions, 70 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index fb9be0cd8..63e173619 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -59,8 +59,6 @@ DELETE FROM '.SITES_TABLE.'
// The function works recursively.
function delete_categories($ids)
{
- global $counts;
-
if (count($ids) == 0)
{
return;
@@ -121,10 +119,6 @@ DELETE FROM '.OLD_PERMALINKS_TABLE.'
WHERE cat_id IN ('.implode(',',$ids).')';
pwg_query($query);
- if (isset($counts['del_categories']))
- {
- $counts['del_categories']+= count($ids);
- }
trigger_action('delete_categories', $ids);
}
@@ -135,8 +129,6 @@ DELETE FROM '.OLD_PERMALINKS_TABLE.'
// - all the favorites associated to elements
function delete_elements($ids)
{
- global $counts;
-
if (count($ids) == 0)
{
return;
@@ -198,10 +190,6 @@ DELETE FROM '.IMAGES_TABLE.'
;';
pwg_query($query);
- if (isset($counts['del_elements']))
- {
- $counts['del_elements']+= count($ids);
- }
trigger_action('delete_elements', $ids);
}
@@ -436,21 +424,6 @@ SELECT id
}
}
-function date_convert_back( $date )
-{
- // date arrives at this format : YYYY-MM-DD
- // It must be transformed in DD/MM/YYYY
- if ( $date != '' )
- {
- list($year,$month,$day) = explode( '-', $date );
- return $day.'/'.$month.'/'.$year;
- }
- else
- {
- return '';
- }
-}
-
/**
* returns an array containing sub-directories which can be a category,
* recursive by default
@@ -575,9 +548,7 @@ function mass_updates($tablename, $dbfields, $datas)
{
// depending on the MySQL version, we use the multi table update or N
// update queries
- $query = 'SELECT VERSION() AS version;';
- list($mysql_version) = mysql_fetch_array(pwg_query($query));
- if (count($datas) < 10 or version_compare($mysql_version, '4.0.4') < 0)
+ if (count($datas) < 10 or version_compare(mysql_get_server_info(), '4.0.4') < 0)
{
// MySQL is prior to version 4.0.4, multi table update feature is not
// available
@@ -1184,48 +1155,36 @@ DELETE
*/
function update_uppercats()
{
- $uppercat_ids = array();
-
$query = '
-SELECT id, id_uppercat
+SELECT id, id_uppercat, uppercats
FROM '.CATEGORIES_TABLE.'
;';
- $result = pwg_query($query);
- while ($row = mysql_fetch_array($result))
- {
- $uppercat_ids[$row['id']] =
- !empty($row['id_uppercat']) ? $row['id_uppercat'] : 'NULL';
- }
+ $cat_map = hash_from_query($query, 'id');
- // uppercats array associates a category id to the list of uppercats id.
- $uppercats = array();
-
- foreach (array_keys($uppercat_ids) as $id)
+ $datas = array();
+ foreach ($cat_map as $id => $cat)
{
- $uppercats[$id] = array();
+ $upper_list = array();
$uppercat = $id;
-
- while ($uppercat != 'NULL')
+ while ($uppercat)
{
- array_push($uppercats[$id], $uppercat);
- $uppercat = $uppercat_ids[$uppercat];
+ array_push($upper_list, $uppercat);
+ $uppercat = $cat_map[$uppercat]['id_uppercat'];
}
- }
-
- $datas = array();
- foreach ($uppercats as $id => $list)
- {
- array_push(
- $datas,
- array(
- 'id' => $id,
- 'uppercats' => implode(',', array_reverse($list))
- )
- );
+ $new_uppercats = implode(',', array_reverse($upper_list));
+ if ($new_uppercats != $cat['uppercats'])
+ {
+ array_push(
+ $datas,
+ array(
+ 'id' => $id,
+ 'uppercats' => $new_uppercats
+ )
+ );
+ }
}
-
$fields = array('primary' => array('id'), 'update' => array('uppercats'));
mass_updates(CATEGORIES_TABLE, $fields, $datas);
}
diff --git a/admin/picture_modify.php b/admin/picture_modify.php
index e27b1eae0..2fbaf901b 100644
--- a/admin/picture_modify.php
+++ b/admin/picture_modify.php
@@ -188,11 +188,6 @@ SELECT tag_id
;';
$selected_tags = array_from_query($query, 'tag_id');
-// Navigation path
-
-$date = isset($_POST['date_creation']) && empty($page['errors'])
-?$_POST['date_creation']:date_convert_back(@$row['date_creation']);
-
// +-----------------------------------------------------------------------+
// | template init |
// +-----------------------------------------------------------------------+
@@ -224,7 +219,7 @@ else
$template->assign(
array(
'U_SYNC' =>
- PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
+ get_root_url().'admin.php?page=picture_modify'.
'&amp;image_id='.$_GET['image_id'].
(isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '').
'&amp;sync_metadata=1',
@@ -246,8 +241,6 @@ $template->assign(
'AUTHOR' => isset($_POST['author']) ? $_POST['author'] : @$row['author'],
- 'CREATION_DATE' => $date,
-
'TAG_SELECTION' => $tag_selection,
'DESCRIPTION' =>
@@ -255,7 +248,7 @@ $template->assign(
stripslashes($_POST['description']) : @$row['comment'] ),
'F_ACTION' =>
- PHPWG_ROOT_PATH.'admin.php'
+ get_root_url().'admin.php'
.get_query_string_diff(array('sync_metadata'))
)
);