[geeklog-cvs] geeklog: Another tiny step to reducing the amount of special han...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Feb 21 14:53:33 EST 2010
changeset 7745:5bab95d23f59
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/5bab95d23f59
user: Dirk Haun <dirk at haun-online.de>
date: Sat Feb 20 22:57:16 2010 +0100
description:
Another tiny step to reducing the amount of special handling in moderation.php
diffstat:
public_html/admin/moderation.php | 56 ++++++++++++++-------------
system/lib-story.php | 35 +++++++++++++++++
2 files changed, 64 insertions(+), 27 deletions(-)
diffs (145 lines):
diff -r afd1a198bfd9 -r 5bab95d23f59 public_html/admin/moderation.php
--- a/public_html/admin/moderation.php Sat Feb 20 22:38:40 2010 +0100
+++ b/public_html/admin/moderation.php Sat Feb 20 22:57:16 2010 +0100
@@ -239,7 +239,7 @@
if ($_CONF['usersubmission'] == 1) {
if (SEC_hasRights('user.edit') && SEC_hasRights('user.delete')) {
- $retval .= userlist ($token);
+ $retval .= userlist($token);
}
}
@@ -267,43 +267,46 @@
$retval = '';
$isplugin = false;
- if ((strlen ($type) > 0) && ($type <> 'story') && ($type <> 'comment')) {
- $function = 'plugin_itemlist_' . $type;
- if (function_exists ($function)) {
- // Great, we found the plugin, now call its itemlist method
- $plugin = new Plugin();
- $plugin = $function();
- if (isset ($plugin)) {
- $helpfile = $plugin->submissionhelpfile;
- $sql = $plugin->getsubmissionssql;
- $H = $plugin->submissionheading;
- $section_title = $plugin->submissionlabel;
- $section_help = $helpfile;
- $isplugin = true;
- }
- }
- } elseif ($type == 'story') { // story submission
- $sql = "SELECT sid AS id,title,date,tid FROM {$_TABLES['storysubmission']}" . COM_getTopicSQL ('WHERE') . " ORDER BY date ASC";
- $H = array($LANG29[10], $LANG29[14], $LANG29[15]);
- $section_title = $LANG29[35];
- $section_help = 'ccstorysubmission.html';
- } elseif ($type == 'comment') {
+ if (empty($type)) {
+ // something is terribly wrong, bail
+ $retval .= COM_errorLog("Submission type not set in moderation.php");
+ return $retval;
+ }
+
+ if ($type == 'comment') {
$sql = "SELECT cid AS id,title,comment,date,uid,type,sid "
. "FROM {$_TABLES['commentsubmissions']} "
. "ORDER BY cid ASC";
$H = array($LANG29[10], $LANG29[36], $LANG29[14]);
$section_title = $LANG29[41];
$section_help = 'cccommentsubmission.html';
+ } else {
+ $function = 'plugin_itemlist_' . $type;
+ if (function_exists($function)) {
+ // Great, we found the plugin, now call its itemlist method
+ $plugin = new Plugin();
+ $plugin = $function();
+ if (isset($plugin)) {
+ $helpfile = $plugin->submissionhelpfile;
+ $sql = $plugin->getsubmissionssql;
+ $H = $plugin->submissionheading;
+ $section_title = $plugin->submissionlabel;
+ $section_help = $helpfile;
+ if ($type <> 'story') {
+ $isplugin = true;
+ }
+ }
+ }
}
// run SQL but this time ignore any errors
- if (!empty ($sql)) {
+ if (!empty($sql)) {
$sql .= ' LIMIT 50'; // quick'n'dirty workaround to prevent timeouts
$result = DB_query($sql, 1);
}
- if (empty ($sql) || DB_error()) {
+ if (empty($sql) || DB_error()) {
// was more than likely a plugin that doesn't need moderation
- //$nrows = -1;
+ $nrows = 0;
return;
} else {
$nrows = DB_numRows($result);
@@ -326,7 +329,6 @@
$data_arr[$i] = $A;
}
-
$header_arr = array( // display 'text' and use table field 'field'
array('text' => $LANG_ADMIN['edit'], 'field' => 0),
array('text' => $H[0], 'field' => 1),
@@ -335,7 +337,7 @@
array('text' => $LANG29[2], 'field' => 'delete'),
array('text' => $LANG29[1], 'field' => 'approve'));
if ($type == 'comment') {
- //data for comment submission headers
+ // data for comment submission headers
$header_arr[6]['text'] = $LANG29[42];
$header_arr[6]['field'] = 'uid';
$header_arr[7]['text'] = $LANG29[43];
diff -r afd1a198bfd9 -r 5bab95d23f59 system/lib-story.php
--- a/system/lib-story.php Sat Feb 20 22:38:40 2010 +0100
+++ b/system/lib-story.php Sat Feb 20 22:57:16 2010 +0100
@@ -954,6 +954,41 @@
return '';
}
+/**
+* Checks that the current user has the rights to moderate stories.
+* Returns true if this is the case, false otherwise
+*
+* @return boolean Returns true if moderator
+*
+*/
+function plugin_ismoderator_story()
+{
+ return SEC_hasRights('story.moderate');
+}
+
+/**
+* Returns SQL & Language texts to moderation.php
+*
+* @return mixed Plugin object or void if not allowed
+*
+*/
+function plugin_itemlist_story()
+{
+ global $_TABLES, $LANG29;
+
+ if (plugin_ismoderator_story()) {
+ $plugin = new Plugin();
+ $plugin->submissionlabel = $LANG29[35];
+ $plugin->submissionhelpfile = 'ccstorysubmission.html';
+ $plugin->getsubmissionssql = "SELECT sid AS id,title,date,tid FROM {$_TABLES['storysubmission']}" . COM_getTopicSQL ('WHERE') . " ORDER BY date ASC";
+ $plugin->addSubmissionHeading($LANG29[10]);
+ $plugin->addSubmissionHeading($LANG29[14]);
+ $plugin->addSubmissionHeading($LANG29[15]);
+
+ return $plugin;
+ }
+}
+
/*
* START SERVICES SECTION
More information about the geeklog-cvs
mailing list