[geeklog-hg] geeklog: Checks are now done to make sure you cannot use a dupli...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Sep 23 11:38:53 EDT 2012
changeset 8828:df0c6cb8336f
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/df0c6cb8336f
user: Tom <websitemaster at cogeco.net>
date: Sun Sep 23 11:36:29 2012 -0400
description:
Checks are now done to make sure you cannot use a duplicate topic id when saving a new topic or updating a topic (bug #0001472)
diffstat:
language/english.php | 1 +
language/english_utf-8.php | 1 +
public_html/admin/topic.php | 36 +++++++++++++++++++++++++++++-------
3 files changed, 31 insertions(+), 7 deletions(-)
diffs (99 lines):
diff -r e2c37a381a90 -r df0c6cb8336f language/english.php
--- a/language/english.php Sun Sep 23 02:31:30 2012 +0900
+++ b/language/english.php Sun Sep 23 11:36:29 2012 -0400
@@ -910,6 +910,7 @@
46 => 'Your parent topic cannot be the Archive topic. Please choose a different Parent Topic.',
47 => 'An Archive Topic cannot have any child topics. Please remove any child topics before making a topic the Archive Topic.',
48 => 'Parent Topic Id not found.',
+ 49 => 'This Topic ID is already being used. Please choose another one.',
'breadcrumb_separator' => '>',
'breadcrumb_root' => 'Home'
);
diff -r e2c37a381a90 -r df0c6cb8336f language/english_utf-8.php
--- a/language/english_utf-8.php Sun Sep 23 02:31:30 2012 +0900
+++ b/language/english_utf-8.php Sun Sep 23 11:36:29 2012 -0400
@@ -910,6 +910,7 @@
46 => 'Your parent topic cannot be the Archive topic. Please choose a different Parent Topic.',
47 => 'An Archive Topic cannot have any child topics. Please remove any child topics before making a topic the Archive Topic.',
48 => 'Parent Topic Id not found.',
+ 49 => 'This Topic ID is already being used. Please choose another one.',
'breadcrumb_separator' => '>',
'breadcrumb_root' => 'Home'
);
diff -r e2c37a381a90 -r df0c6cb8336f public_html/admin/topic.php
--- a/public_html/admin/topic.php Sun Sep 23 02:31:30 2012 +0900
+++ b/public_html/admin/topic.php Sun Sep 23 11:36:29 2012 -0400
@@ -366,10 +366,30 @@
// Check if tid is a restricted name
$restricted_tid = false;
- if ($tid == TOPIC_ALL_OPTION || $tid == TOPIC_NONE_OPTION || $tid == TOPIC_HOMEONLY_OPTION || $tid == TOPIC_SELECTED_OPTION || $tid == TOPIC_ROOT) {
+ if (!strcasecmp($tid, TOPIC_ALL_OPTION) || !strcasecmp($tid, TOPIC_NONE_OPTION) || !strcasecmp($tid, TOPIC_HOMEONLY_OPTION) || !strcasecmp($tid, TOPIC_SELECTED_OPTION) || !strcasecmp($tid, TOPIC_ROOT)) {
$restricted_tid = true;
}
+ // Check if tid is used by another topic
+ $duplicate_tid = false;
+ $old_tid = '';
+ if (isset($_POST['old_tid'])) {
+ $old_tid = COM_applyFilter($_POST['old_tid']);
+ if (!empty($old_tid)) {
+ $old_tid = COM_sanitizeID($old_tid);
+ // See if new topic id
+ if (strcasecmp($tid, $old_tid)) {
+ if (!strcasecmp($tid, DB_getItem($_TABLES['topics'], 'tid', "tid = '$tid'"))) {
+ $duplicate_tid = true;
+ }
+ }
+ } else {
+ if (!strcasecmp($tid, DB_getItem($_TABLES['topics'], 'tid', "tid = '$tid'"))) {
+ $duplicate_tid = true;
+ }
+ }
+ }
+
// Make sure parent id exists
$parent_id_found = false;
if ($parent_id == DB_getItem($_TABLES['topics'], 'tid', "tid = '$parent_id'") || $parent_id == TOPIC_ROOT) {
@@ -428,7 +448,7 @@
$retval .= COM_showMessageText($MESSAGE[29], $MESSAGE[30]);
$retval = COM_createHTMLDocument($retval, array('pagetitle' => $MESSAGE[30]));
COM_accessLog("User {$_USER['username']} tried to illegally assign topic $tid to $parent_id.");
- } elseif (!empty($tid) && !empty($topic) && !$restricted_tid && !$archive_parent && !$archive_child && $parent_id_found) {
+ } elseif (!empty($tid) && !empty($topic) && !$restricted_tid && !$duplicate_tid && !$archive_parent && !$archive_child && $parent_id_found) {
if ($imageurl == '/images/topics/') {
$imageurl = '';
}
@@ -471,10 +491,9 @@
$hidden = 0;
}
- if (isset($_POST['old_tid'])) {
- $old_tid = COM_applyFilter($_POST['old_tid']);
- if (! empty($old_tid)) {
- $old_tid = COM_sanitizeID($old_tid);
+ // If not a new topic and id change then...
+ if (!empty($old_tid)) {
+ if ($tid != $old_tid) {
changetopicid($tid, $old_tid);
$old_tid = addslashes($old_tid);
@@ -483,7 +502,7 @@
}
DB_save($_TABLES['topics'],'tid, topic, inherit, hidden, parent_id, imageurl, meta_description, meta_keywords, sortnum, limitnews, is_default, archive_flag, owner_id, group_id, perm_owner, perm_group, perm_members, perm_anon',"'$tid', '$topic', $inherit, $hidden, '$parent_id', '$imageurl', '$meta_description', '$meta_keywords','$sortnum','$limitnews',$is_default,'$is_archive',$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon");
-
+
// Update Topics Array to reflect any changes since not sure what is called after
$_TOPICS = TOPIC_buildTree(TOPIC_ROOT, true);
@@ -501,6 +520,9 @@
} elseif ($restricted_tid) {
$retval .= COM_errorLog($LANG27[31], 2);
$retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG27[1]));
+ } elseif ($duplicate_tid) {
+ $retval .= COM_errorLog($LANG27[49], 2);
+ $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG27[1]));
} elseif ($archive_parent) {
$retval .= COM_errorLog($LANG27[46], 2);
$retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG27[1]));
More information about the geeklog-cvs
mailing list