[geeklog-cvs] geeklog: Topics can now have parent topics.
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Oct 10 14:26:26 EDT 2011
changeset 8441:7ea02c9ca0d2
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/7ea02c9ca0d2
user: Tom <websitemaster at cogeco.net>
date: Mon Oct 10 13:57:56 2011 -0400
description:
Topics can now have parent topics.
Anonymous Sessions now tracked and whos online block now sets flag instead of deleting session data.
diffstat:
language/english.php | 16 +-
language/english_utf-8.php | 16 +-
public_html/admin/topic.php | 216 ++++++---
public_html/layout/professional/admin/topic/topiceditor.thtml | 16 +
public_html/layout/professional/topicoption.thtml | 2 +-
public_html/layout/professional/topicoption_off.thtml | 2 +-
public_html/lib-common.php | 209 ++++++--
sql/mssql_tableanddata.php | 7 +-
sql/mysql_tableanddata.php | 5 +
sql/pgsql_tableanddata.php | 5 +
sql/updates/mssql_1.8.1_to_1.9.0.php | 8 +
sql/updates/mysql_1.8.1_to_1.9.0.php | 8 +
sql/updates/pgsql_1.8.1_to_1.9.0.php | 8 +
system/lib-sessions.php | 34 +-
system/lib-topic.php | 124 +++++
15 files changed, 523 insertions(+), 153 deletions(-)
diffs (truncated from 1065 to 300 lines):
diff -r f88c78b4368b -r 7ea02c9ca0d2 language/english.php
--- a/language/english.php Mon Oct 03 09:07:12 2011 +0200
+++ b/language/english.php Mon Oct 10 13:57:56 2011 -0400
@@ -728,7 +728,7 @@
44 => 'Multiple',
45 => "You are trying to access a block that you don't have rights to. This attempt has been logged. Please <a href=\"{$_CONF['site_admin_url']}/block.php\">go back to the block administration screen</a>.",
46 => 'Move',
- 47 => '',
+ 47 => 'None',
48 => 'Block Name',
49 => '(no spaces)',
50 => 'The Block Name can not be empty',
@@ -860,7 +860,7 @@
3 => 'Topic Name',
4 => 'Topic Image',
5 => '(do not use spaces)',
- 6 => 'Deleting a topic deletes all stories and blocks associated with it',
+ 6 => 'Deleting a topic deletes all stories and submissions associated with it.',
7 => 'Please fill in the Topic ID and Topic Name fields',
8 => 'Topic Manager',
9 => 'To modify or delete a topic, click on that topic. To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
@@ -877,15 +877,21 @@
20 => 'cancel',
21 => 'delete',
22 => 'Default',
- 23 => 'make this the default topic for new story submissions',
+ 23 => 'Make this the default topic for new story submissions',
24 => '(*)',
25 => 'Archive Topic',
- 26 => 'make this the default topic for archived stories. Only one topic allowed.',
+ 26 => 'Make this the default topic for archived stories. Only one topic allowed',
27 => 'Or Upload Topic Icon',
28 => 'Maximum',
29 => 'File Upload Errors',
30 => 'Stories in Topic',
- 31 => 'You have used a restricted Topic ID. Please choose another one.'
+ 31 => 'You have used a restricted Topic ID. Please choose another one.',
+ 32 => 'Parent Topic',
+ 33 => 'Inherit',
+ 34 => 'Items of child topic are inherited',
+ 35 => 'Hidden',
+ 36 => 'Topic will be hidden and cannot be viewed directly, only inherited',
+ 37 => 'Root'
);
###############################################################################
diff -r f88c78b4368b -r 7ea02c9ca0d2 language/english_utf-8.php
--- a/language/english_utf-8.php Mon Oct 03 09:07:12 2011 +0200
+++ b/language/english_utf-8.php Mon Oct 10 13:57:56 2011 -0400
@@ -728,7 +728,7 @@
44 => 'Multiple',
45 => "You are trying to access a block that you don't have rights to. This attempt has been logged. Please <a href=\"{$_CONF['site_admin_url']}/block.php\">go back to the block administration screen</a>.",
46 => 'Move',
- 47 => '',
+ 47 => 'None',
48 => 'Block Name',
49 => '(no spaces)',
50 => 'The Block Name can not be empty',
@@ -860,7 +860,7 @@
3 => 'Topic Name',
4 => 'Topic Image',
5 => '(do not use spaces)',
- 6 => 'Deleting a topic deletes all stories and blocks associated with it',
+ 6 => 'Deleting a topic deletes all stories and submissions associated with it.',
7 => 'Please fill in the Topic ID and Topic Name fields',
8 => 'Topic Manager',
9 => 'To modify or delete a topic, click on that topic. To create a new topic, click on "Create New" above. You will find your access level for each topic in parenthesis. The asterisk(*) denotes the default topic.',
@@ -877,15 +877,21 @@
20 => 'cancel',
21 => 'delete',
22 => 'Default',
- 23 => 'make this the default topic for new story submissions',
+ 23 => 'Make this the default topic for new story submissions',
24 => '(*)',
25 => 'Archive Topic',
- 26 => 'make this the default topic for archived stories. Only one topic allowed.',
+ 26 => 'Make this the default topic for archived stories. Only one topic allowed',
27 => 'Or Upload Topic Icon',
28 => 'Maximum',
29 => 'File Upload Errors',
30 => 'Stories in Topic',
- 31 => 'You have used a restricted Topic ID. Please choose another one.'
+ 31 => 'You have used a restricted Topic ID. Please choose another one.',
+ 32 => 'Parent Topic',
+ 33 => 'Inherit',
+ 34 => 'Items of child topic are inherited',
+ 35 => 'Hidden',
+ 36 => 'Topic will be hidden and cannot be viewed directly, only inherited',
+ 37 => 'Root'
);
###############################################################################
diff -r f88c78b4368b -r 7ea02c9ca0d2 public_html/admin/topic.php
--- a/public_html/admin/topic.php Mon Oct 03 09:07:12 2011 +0200
+++ b/public_html/admin/topic.php Mon Oct 10 13:57:56 2011 -0400
@@ -88,6 +88,9 @@
$A['tid'] = '';
$A['topic'] = '';
$A['sortnum'] = 0;
+ $A['parent_id'] = TOPIC_ROOT;
+ $A['inherit'] = 1;
+ $A['hidden'] = 0;
$A['limitnews'] = ''; // leave empty!
$A['is_default'] = 0;
$A['archive_flag'] = 0;
@@ -134,6 +137,27 @@
}
$topic_templates->set_var('lang_topicid', $LANG27[2]);
$topic_templates->set_var('topic_id', $A['tid']);
+
+ $topic_templates->set_var('lang_parent_id', $LANG27[32]);
+ $topic_templates->set_var('parent_id_options',
+ TOPIC_getListSelect($A['parent_id'], true, $A['tid']));
+
+ $topic_templates->set_var('lang_inherit', $LANG27[33]);
+ $topic_templates->set_var('lang_inherit_info', $LANG27[34]);
+ if ($A['inherit'] == 1) {
+ $topic_templates->set_var ('inherit_checked', 'checked="checked"');
+ } else {
+ $topic_templates->set_var ('inherit_checked', '');
+ }
+
+ $topic_templates->set_var('lang_hidden', $LANG27[35]);
+ $topic_templates->set_var('lang_hidden_info', $LANG27[36]);
+ if ($A['hidden'] == 1) {
+ $topic_templates->set_var ('hidden_checked', 'checked="checked"');
+ } else {
+ $topic_templates->set_var ('hidden_checked', '');
+ }
+
$topic_templates->set_var('lang_donotusespaces', $LANG27[5]);
$topic_templates->set_var('lang_accessrights',$LANG_ACCESS['accessrights']);
$topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
@@ -265,7 +289,8 @@
{
global $_TABLES;
- DB_change($_TABLES['blocks'], 'tid', $tid, 'tid', $old_tid);
+ DB_change($_TABLES['topic_assignments'], 'tid', $tid, 'tid', $old_tid);
+ DB_change($_TABLES['topics'], 'parent_id', $tid, 'parent_id', $old_tid);
DB_change($_TABLES['stories'], 'tid', $tid, 'tid', $old_tid);
DB_change($_TABLES['storysubmission'], 'tid', $tid, 'tid', $old_tid);
DB_change($_TABLES['syndication'], 'header_tid', $tid,
@@ -331,7 +356,7 @@
* @param string $is_archive 'on' if this is the archive topic
* @return string HTML redirect or error message
*/
-function savetopic($tid,$topic,$imageurl,$meta_description,$meta_keywords,$sortnum,$limitnews,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$is_default,$is_archive)
+function savetopic($tid,$topic,$inherit,$hidden,$parent_id,$imageurl,$meta_description,$meta_keywords,$sortnum,$limitnews,$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon,$is_default,$is_archive)
{
global $_CONF, $_TABLES, $LANG27, $MESSAGE;
@@ -344,7 +369,7 @@
// Check if tid is a restricted name
$restricted_tid = false;
- if ($tid == TOPIC_ALL_OPTION || $tid == TOPIC_HOMEONLY_OPTION || $tid == TOPIC_SELECTED_OPTION) {
+ if ($tid == TOPIC_ALL_OPTION || $tid == TOPIC_HOMEONLY_OPTION || $tid == TOPIC_SELECTED_OPTION || $tid == TOPIC_ROOT) {
$restricted_tid = true;
}
@@ -364,73 +389,105 @@
. COM_showMessageText($MESSAGE[29], $MESSAGE[30])
. COM_siteFooter();
COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic $tid.");
- } elseif (!empty($tid) && !empty($topic) && !$restricted_tid) {
- if ($imageurl == '/images/topics/') {
- $imageurl = '';
+ } else {
+ // Now check access to parent topic
+ if ($parent_id != TOPIC_ROOT) {
+ if (DB_count ($_TABLES['topics'], 'tid', $parent_id) > 0) {
+ $result = DB_query ("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['topics']} WHERE tid = '{$parent_id}'");
+ $A = DB_fetchArray ($result);
+ $access = SEC_hasAccess ($A['owner_id'], $A['group_id'],
+ $A['perm_owner'], $A['perm_group'], $A['perm_members'],
+ $A['perm_anon']);
+ }
+ $in_Group = SEC_inGroup($A['group_id']);
+ } else {
+ $access = 3;
+ $in_Group = true;
}
- $topic = addslashes($topic);
- $meta_description = addslashes(strip_tags($meta_description));
- $meta_keywords = addslashes(strip_tags($meta_keywords));
-
- if ($is_default == 'on') {
- $is_default = 1;
- DB_query ("UPDATE {$_TABLES['topics']} SET is_default = 0 WHERE is_default = 1");
+ if (($access < 3) || !$in_Group) {
+ $retval .= COM_siteHeader('menu', $MESSAGE[30])
+ . COM_showMessageText($MESSAGE[29], $MESSAGE[30])
+ . COM_siteFooter();
+ COM_accessLog("User {$_USER['username']} tried to illegally assign topic $tid to $parent_id.");
+ } elseif (!empty($tid) && !empty($topic) && !$restricted_tid) {
+ if ($imageurl == '/images/topics/') {
+ $imageurl = '';
+ }
+ $topic = addslashes($topic);
+ $meta_description = addslashes(strip_tags($meta_description));
+ $meta_keywords = addslashes(strip_tags($meta_keywords));
+
+ if ($is_default == 'on') {
+ $is_default = 1;
+ DB_query ("UPDATE {$_TABLES['topics']} SET is_default = 0 WHERE is_default = 1");
+ } else {
+ $is_default = 0;
+ }
+
+ $is_archive = ($is_archive == 'on') ? 1 : 0;
+
+ $archivetid = DB_getItem ($_TABLES['topics'], 'tid', "archive_flag=1");
+ if ($is_archive) {
+ // $tid is the archive topic
+ // - if it wasn't already, mark all its stories "archived" now
+ if ($archivetid != $tid) {
+ DB_query ("UPDATE {$_TABLES['stories']} SET featured = 0, frontpage = 0, statuscode = " . STORY_ARCHIVE_ON_EXPIRE . " WHERE tid = '$tid'");
+ DB_query ("UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1");
+ }
+ } else {
+ // $tid is not the archive topic
+ // - if it was until now, reset the "archived" status of its stories
+ if ($archivetid == $tid) {
+ DB_query ("UPDATE {$_TABLES['stories']} SET statuscode = 0 WHERE tid = '$tid'");
+ DB_query ("UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1");
+ }
+ }
+
+ $inherit = ($inherit == 'on') ? 1 : 0;
+
+ $hidden = ($hidden == 'on') ? 1 : 0;
+ // Cannot hide root topics so switch if needed
+ if ($parent_id == TOPIC_ROOT && $hidden == 1) {
+ $hidden = 0;
+ }
+
+ if (isset($_POST['old_tid'])) {
+ $old_tid = COM_applyFilter($_POST['old_tid']);
+ if (! empty($old_tid)) {
+ $old_tid = COM_sanitizeID($old_tid);
+ changetopicid($tid, $old_tid);
+
+ $old_tid = addslashes($old_tid);
+ DB_delete($_TABLES['topics'], 'tid', $old_tid);
+ }
+ }
+
+ 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);
+
+ if ($old_tid != $tid) {
+ PLG_itemSaved($tid, 'topic', $old_tid);
+ } else {
+ PLG_itemSaved($tid, 'topic');
+ }
+
+ // update feed(s) and Older Stories block
+ COM_rdfUpToDateCheck('article', $tid);
+ COM_olderStuff();
+
+ $retval = COM_refresh ($_CONF['site_admin_url'] . '/topic.php?msg=13');
+ } elseif ($restricted_tid) {
+ $retval .= COM_siteHeader('menu', $LANG27[1]);
+ $retval .= COM_errorLog($LANG27[31], 2);
+ $retval .= COM_siteFooter();
} else {
- $is_default = 0;
+ $retval .= COM_siteHeader('menu', $LANG27[1]);
+ $retval .= COM_errorLog($LANG27[7], 2);
+ $retval .= COM_siteFooter();
}
-
- $is_archive = ($is_archive == 'on') ? 1 : 0;
-
- $archivetid = DB_getItem ($_TABLES['topics'], 'tid', "archive_flag=1");
- if ($is_archive) {
- // $tid is the archive topic
- // - if it wasn't already, mark all its stories "archived" now
- if ($archivetid != $tid) {
- DB_query ("UPDATE {$_TABLES['stories']} SET featured = 0, frontpage = 0, statuscode = " . STORY_ARCHIVE_ON_EXPIRE . " WHERE tid = '$tid'");
- DB_query ("UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1");
- }
- } else {
- // $tid is not the archive topic
- // - if it was until now, reset the "archived" status of its stories
- if ($archivetid == $tid) {
- DB_query ("UPDATE {$_TABLES['stories']} SET statuscode = 0 WHERE tid = '$tid'");
- DB_query ("UPDATE {$_TABLES['topics']} SET archive_flag = 0 WHERE archive_flag = 1");
- }
- }
-
- if (isset($_POST['old_tid'])) {
- $old_tid = COM_applyFilter($_POST['old_tid']);
- if (! empty($old_tid)) {
- $old_tid = COM_sanitizeID($old_tid);
- changetopicid($tid, $old_tid);
-
More information about the geeklog-cvs
mailing list