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
This commit is contained in:
parent
e57f06df4a
commit
55095f9ce9
2 changed files with 26 additions and 74 deletions
|
@ -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';
|
||||
}
|
||||
|
||||
// uppercats array associates a category id to the list of uppercats id.
|
||||
$uppercats = array();
|
||||
|
||||
foreach (array_keys($uppercat_ids) as $id)
|
||||
{
|
||||
$uppercats[$id] = array();
|
||||
|
||||
$uppercat = $id;
|
||||
|
||||
while ($uppercat != 'NULL')
|
||||
{
|
||||
array_push($uppercats[$id], $uppercat);
|
||||
$uppercat = $uppercat_ids[$uppercat];
|
||||
}
|
||||
}
|
||||
$cat_map = hash_from_query($query, 'id');
|
||||
|
||||
$datas = array();
|
||||
|
||||
foreach ($uppercats as $id => $list)
|
||||
foreach ($cat_map as $id => $cat)
|
||||
{
|
||||
array_push(
|
||||
$datas,
|
||||
array(
|
||||
'id' => $id,
|
||||
'uppercats' => implode(',', array_reverse($list))
|
||||
)
|
||||
);
|
||||
}
|
||||
$upper_list = array();
|
||||
|
||||
$uppercat = $id;
|
||||
while ($uppercat)
|
||||
{
|
||||
array_push($upper_list, $uppercat);
|
||||
$uppercat = $cat_map[$uppercat]['id_uppercat'];
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
|
|
|
@ -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'.
|
||||
'&image_id='.$_GET['image_id'].
|
||||
(isset($_GET['cat_id']) ? '&cat_id='.$_GET['cat_id'] : '').
|
||||
'&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'))
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue