aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions_permalinks.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2007-03-06 02:07:15 +0000
committerrvelices <rv-github@modusoptimus.com>2007-03-06 02:07:15 +0000
commitf797f8c7a179c79b1aabdd4c020efb6329699b8e (patch)
treefe13742ab9eb15663239b950f1ff96809050c95d /admin/include/functions_permalinks.php
parent054d7c459fee32853a4bd9e984a7273eb0f52fbd (diff)
permalinks: admin fix on some tricky cases when setting a new permalinks.inc.php
permalinks: added ability to sort the permalink tables in the admin added new action in category_cats.inc.php git-svn-id: http://piwigo.org/svn/trunk@1873 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/functions_permalinks.php')
-rw-r--r--admin/include/functions_permalinks.php44
1 files changed, 21 insertions, 23 deletions
diff --git a/admin/include/functions_permalinks.php b/admin/include/functions_permalinks.php
index 9a36ccf3d..1f10b4379 100644
--- a/admin/include/functions_permalinks.php
+++ b/admin/include/functions_permalinks.php
@@ -102,12 +102,13 @@ function set_cat_permalink( $cat_id, $permalink, $save )
$sanitized_permalink = preg_replace( '#[^a-zA-Z0-9_-]#', '' ,$permalink);
if ( $sanitized_permalink != $permalink
- or preg_match( '#^(\d)+-?#', $permalink) )
+ or preg_match( '#^(\d)+(-.*)?$#', $permalink) )
{
$page['errors'][] = l10n('Permalink_name_rule');
return false;
}
+ // check if the new permalink is actively used
$existing_cat_id = get_cat_id_from_permalink( $permalink );
if ( isset($existing_cat_id) )
{
@@ -126,35 +127,32 @@ function set_cat_permalink( $cat_id, $permalink, $save )
}
}
- if ($save)
+ // check if the new permalink was historically used
+ $old_cat_id = get_cat_id_from_old_permalink($permalink, false);
+ if ( isset($old_cat_id) and $old_cat_id!=$cat_id )
{
- $old_cat_id = get_cat_id_from_old_permalink($permalink, false);
- if ( isset($old_cat_id) )
- {
- if ( $old_cat_id!=$cat_id )
- {
- $page['errors'][] =
- sprintf(
- l10n('Permalink_%s_histo_used_by_%s'),
- $permalink, $old_cat_id
- );
- return false;
- }
- else
- {
- $query = '
-DELETE FROM '.OLD_PERMALINKS_TABLE.'
- WHERE cat_id='.$cat_id.' AND permalink="'.$permalink.'"';
- pwg_query($query);
- }
- }
+ $page['errors'][] =
+ sprintf(
+ l10n('Permalink_%s_histo_used_by_%s'),
+ $permalink, $old_cat_id
+ );
+ return false;
}
-
+
if ( !delete_cat_permalink($cat_id, $save ) )
{
return false;
}
+ if ( isset($old_cat_id) )
+ {// the new permalink must not be active and old at the same time
+ assert( $old_cat_id==$cat_id );
+ $query = '
+DELETE FROM '.OLD_PERMALINKS_TABLE.'
+ WHERE cat_id='.$old_cat_id.' AND permalink="'.$permalink.'"';
+ pwg_query($query);
+ }
+
$query = '
UPDATE '.CATEGORIES_TABLE.'
SET permalink="'.$permalink.'"