[geeklog-cvs] geeklog: Added What's New Block Support for Polls (including new...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Tue Mar 9 19:08:49 EST 2010
changeset 7771:ca1ffd39bb66
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/ca1ffd39bb66
user: Tom <websitemaster at cogeco.net>
date: Tue Mar 09 18:50:14 2010 -0500
description:
Added What's New Block Support for Polls (including new comments)
diffstat:
plugins/polls/functions.inc | 123 +++++++++++++++++++++++++++++-
plugins/polls/install_defaults.php | 20 ++++-
plugins/polls/language/english.php | 6 +
plugins/polls/language/english_utf-8.php | 8 +-
plugins/polls/sql/mssql_updates.php | 32 ++++++++
plugins/polls/sql/mysql_updates.php | 32 ++++++++
public_html/docs/english/polls.html | 21 +++++
7 files changed, 233 insertions(+), 9 deletions(-)
diffs (truncated from 398 to 300 lines):
diff -r bf42ac6ef2d4 -r ca1ffd39bb66 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc Tue Mar 09 18:47:08 2010 -0500
+++ b/plugins/polls/functions.inc Tue Mar 09 18:50:14 2010 -0500
@@ -1185,6 +1185,8 @@
}
}
+ update_ConfValues_2_1_1();
+
$current_version = '2.1.2';
break;
@@ -1235,7 +1237,7 @@
function plugin_getiteminfo_polls($pid, $what, $uid = 0, $options = array())
{
global $_CONF, $_TABLES;
-
+
// parse $what to see what we need to pull from the database
$properties = explode(',', $what);
$fields = array();
@@ -1251,10 +1253,10 @@
$fields[] = 'topic';
break;
case 'url':
- if ($pid == '*') {
- // in this case, we need the pid to build the URL
- $fields[] = 'pid';
- }
+ // needed for $pid == '*', but also in case we're only requesting
+ // the URL (so that $fields isn't emtpy)
+ $fields[] = 'pid';
+
break;
default:
// nothing to do
@@ -1475,4 +1477,115 @@
return $content;
}
+/**
+* Return headlines for New Polls section in the What's New block, if enabled
+*
+* @return mixed array(headline, byline), or boolean false if disabled
+*
+*/
+function plugin_whatsnewsupported_polls()
+{
+ global $_PO_CONF, $LANG_POLLS, $LANG_WHATSNEW;
+
+ if ($_PO_CONF['hidenewpolls'] == 'hide') {
+ $retval = false;
+ } else {
+ $retval = array($LANG_POLLS['polls'],
+ COM_formatTimeString($LANG_WHATSNEW['new_last'],
+ $_PO_CONF['newpollsinterval'])
+ );
+ }
+
+ return $retval;
+}
+
+/**
+* Return new Polls for the What's New block
+*
+* @return string HTML list of new staticpages
+*
+*/
+function plugin_getwhatsnew_polls()
+{
+ global $_CONF, $_TABLES, $_PO_CONF, $LANG_POLLS;
+
+ $retval = '';
+ if ($_PO_CONF['hidenewpolls'] == 'modified') {
+ $datecolumn = 'modified';
+ } else {
+ $datecolumn = 'created';
+ }
+ $sql = array();
+ $sql['mysql'] = "SELECT pid, topic
+ FROM {$_TABLES['polltopics']}
+ WHERE ({$datecolumn} >= (DATE_SUB(NOW(), INTERVAL {$_PO_CONF['newpollsinterval']} SECOND)))
+ " . COM_getPermSQL('AND') . "
+ ORDER BY {$datecolumn} DESC LIMIT 15";
+
+ $sql['pgsql'] = "SELECT pid, topic
+ FROM {$_TABLES['polltopics']}
+ WHERE ({$datecolumn} >= (NOW() - INTERVAL '{$_PO_CONF['newpollsinterval']} SECONDS'))
+ " . COM_getPermSQL('AND') . "
+ ORDER BY {$datecolumn} DESC LIMIT 15";
+
+ $result = DB_query($sql);
+ $nrows = DB_numRows($result);
+
+ if ($nrows > 0) {
+ $newpolls = array();
+
+ for ($x = 0; $x < $nrows; $x++) {
+ $A = DB_fetchArray($result);
+
+ //$url = COM_buildUrl($_CONF['site_url'] . '/polls/index.php?pid=' . $A['pid']);
+ $url = $_CONF['site_url'] . '/polls/index.php?pid=' . $A['pid'];
+
+ $title = COM_undoSpecialChars(stripslashes( $A['topic']));
+ $titletouse = COM_truncate($title, $_PO_CONF['title_trim_length'],
+ '...');
+ if ($title != $titletouse) {
+ $attr = array('title' => htmlspecialchars($title));
+ } else {
+ $attr = array();
+ }
+ $apoll = str_replace('$', '$', $titletouse);
+ $apoll = str_replace(' ', ' ', $apoll);
+
+ $newpolls[] = COM_createLink($apoll, $url, $attr);
+ }
+
+ $retval .= COM_makeList($newpolls, 'list-new-plugins');
+ } else {
+ $retval .= $LANG_POLLS['no_new_polls'] . '<br' . XHTML . '>' . LB;
+ }
+
+ return $retval;
+}
+
+/**
+* Return new Polls comments for the What's New block
+*
+* @return array list of new poll comments (dups, type, title, sid, lastdate)
+*
+*/
+function plugin_getwhatsnewcomment_polls()
+{
+ global $_CONF, $_TABLES;
+
+ // Comments
+ $sql['mysql'] = "SELECT DISTINCT COUNT(*) AS dups, type, title, sid, max(date) AS lastdate FROM {$_TABLES['comments']}, {$_TABLES['polltopics']} pt"
+ . " WHERE (pt.pid = sid)" . COM_getPermSQL('AND', 0, 2, 'pt')
+ . " AND (date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newcommentsinterval']} SECOND))) GROUP BY sid,type, title, sid ORDER BY 5 DESC LIMIT 15";
+
+ $result = DB_query($sql);
+ $nrows = DB_numRows($result);
+ if ($nrows > 0) {
+ for ($x = 0; $x < $nrows; $x++) {
+ $A[] = DB_fetchArray($result);
+ }
+
+ return $A;
+ }
+}
+
?>
diff -r bf42ac6ef2d4 -r ca1ffd39bb66 plugins/polls/install_defaults.php
--- a/plugins/polls/install_defaults.php Tue Mar 09 18:47:08 2010 -0500
+++ b/plugins/polls/install_defaults.php Tue Mar 09 18:50:14 2010 -0500
@@ -83,6 +83,10 @@
*/
$_PO_DEFAULT['aftersave'] = 'list';
+// What's New Block
+$_PO_DEFAULT['new_polls_interval'] = 1209600; // 2 weeks
+$_PO_DEFAULT['hide_new_polls'] = 'hide'; // 'hide', 'created', 'modified'
+$_PO_DEFAULT['title_trim_length'] = 20;
// Display Meta Tags for static pages (1 = show, 0 = don't)
$_PO_DEFAULT['meta_tags'] = 0;
@@ -140,10 +144,20 @@
0, 0, 9, 90, true, 'polls');
$c->add('meta_tags', $_PO_DEFAULT['meta_tags'], 'select',
0, 0, 0, 100, true, 'polls');
+
+ $c->add('fs_whatsnew', NULL, 'fieldset',
+ 0, 1, NULL, 0, true, 'polls');
+ $c->add('newpollsinterval',$_PO_DEFAULT['new_polls_interval'],'text',
+ 0, 1, NULL, 10, TRUE, 'polls');
+ $c->add('hidenewpolls',$_PO_DEFAULT['hide_new_polls'],'select',
+ 0, 1, 5, 20, TRUE, 'polls');
+ $c->add('title_trim_length',$_PO_DEFAULT['title_trim_length'],'text',
+ 0, 1, NULL, 30, TRUE, 'polls');
- $c->add('fs_permissions', NULL, 'fieldset', 0, 1, NULL, 0, true, 'polls');
- $c->add('default_permissions', $_PO_DEFAULT['default_permissions'],
- '@select', 0, 1, 12, 100, true, 'polls');
+ $c->add('fs_permissions', NULL, 'fieldset',
+ 0, 2, NULL, 0, true, 'polls');
+ $c->add('default_permissions', $_PO_DEFAULT['default_permissions'], '@select',
+ 0, 2, 12, 100, true, 'polls');
}
return true;
diff -r bf42ac6ef2d4 -r ca1ffd39bb66 plugins/polls/language/english.php
--- a/plugins/polls/language/english.php Tue Mar 09 18:47:08 2010 -0500
+++ b/plugins/polls/language/english.php Tue Mar 09 18:50:14 2010 -0500
@@ -53,6 +53,7 @@
'pollclosed' => 'This poll is closed for voting.',
'pollhidden' => 'You have already voted. This poll results will only be shown when voting is closed.',
'start_poll' => 'Start Poll',
+ 'no_new_pages' => 'No new pages',
'deny_msg' => 'Access to this poll is denied. Either the poll has been moved/removed or you do not have sufficient permissions.'
);
@@ -128,6 +129,9 @@
'delete_polls' => 'Delete Polls with Owner?',
'aftersave' => 'After Saving Poll',
'default_permissions' => 'Poll Default Permissions',
+ 'newpollsinterval' => 'New Polls Interval',
+ 'hidenewpolls' => 'New Polls',
+ 'title_trim_length' => 'Title Trim Length',
'meta_tags' => 'Enable Meta Tags'
);
@@ -137,6 +141,7 @@
$LANG_fs['polls'] = array(
'fs_main' => 'General Polls Settings',
+ 'fs_whatsnew' => 'What\'s New Block',
'fs_permissions' => 'Default Permissions'
);
@@ -145,6 +150,7 @@
0 => array('True' => 1, 'False' => 0),
1 => array('True' => TRUE, 'False' => FALSE),
2 => array('As Submitted' => 'submitorder', 'By Votes' => 'voteorder'),
+ 5 => array('Hide' => 'hide', 'Show - Use Modified Date' => 'modified', 'Show - Use Created Date' => 'created'),
9 => array('Forward to Poll' => 'item', 'Display Admin List' => 'list', 'Display Public List' => 'plugin', 'Display Home' => 'home', 'Display Admin' => 'admin'),
12 => array('No access' => 0, 'Read-Only' => 2, 'Read-Write' => 3)
);
diff -r bf42ac6ef2d4 -r ca1ffd39bb66 plugins/polls/language/english_utf-8.php
--- a/plugins/polls/language/english_utf-8.php Tue Mar 09 18:47:08 2010 -0500
+++ b/plugins/polls/language/english_utf-8.php Tue Mar 09 18:50:14 2010 -0500
@@ -53,6 +53,7 @@
'pollclosed' => 'This poll is closed for voting.',
'pollhidden' => 'You have already voted. This poll results will only be shown when voting is closed.',
'start_poll' => 'Start Poll',
+ 'no_new_pages' => 'No new pages',
'deny_msg' => 'Access to this poll is denied. Either the poll has been moved/removed or you do not have sufficient permissions.'
);
@@ -99,7 +100,7 @@
37 => 'Hide results while poll is open',
38 => 'While the poll is open, only the owner & root can see the results',
39 => 'The topic will be only displayed if there are more than 1 questions.',
- 40 => 'See all answers to this poll'
+ 40 => 'See all answers to this poll',
);
$PLG_polls_MESSAGE15 = 'Your comment has been submitted for review and will be published when approved by a moderator.';
@@ -128,6 +129,9 @@
'delete_polls' => 'Delete Polls with Owner?',
'aftersave' => 'After Saving Poll',
'default_permissions' => 'Poll Default Permissions',
+ 'newpollsinterval' => 'New Polls Interval',
+ 'hidenewpolls' => 'New Polls',
+ 'title_trim_length' => 'Title Trim Length',
'meta_tags' => 'Enable Meta Tags'
);
@@ -137,6 +141,7 @@
$LANG_fs['polls'] = array(
'fs_main' => 'General Polls Settings',
+ 'fs_whatsnew' => 'What\'s New Block',
'fs_permissions' => 'Default Permissions'
);
@@ -145,6 +150,7 @@
0 => array('True' => 1, 'False' => 0),
1 => array('True' => TRUE, 'False' => FALSE),
2 => array('As Submitted' => 'submitorder', 'By Votes' => 'voteorder'),
+ 5 => array('Hide' => 'hide', 'Show - Use Modified Date' => 'modified', 'Show - Use Created Date' => 'created'),
9 => array('Forward to Poll' => 'item', 'Display Admin List' => 'list', 'Display Public List' => 'plugin', 'Display Home' => 'home', 'Display Admin' => 'admin'),
12 => array('No access' => 0, 'Read-Only' => 2, 'Read-Write' => 3)
);
diff -r bf42ac6ef2d4 -r ca1ffd39bb66 plugins/polls/sql/mssql_updates.php
--- a/plugins/polls/sql/mssql_updates.php Tue Mar 09 18:47:08 2010 -0500
+++ b/plugins/polls/sql/mssql_updates.php Tue Mar 09 18:50:14 2010 -0500
@@ -63,6 +63,7 @@
global $_CONF, $_PO_DEFAULT;
require_once $_CONF['path_system'] . 'classes/config.class.php';
+ require_once $_CONF['path'] . 'plugins/polls/install_defaults.php';
$c = config::get_instance();
@@ -72,4 +73,35 @@
return true;
}
+function update_ConfValues_2_1_1()
+{
+ global $_CONF, $_PO_DEFAULT, $_PO_CONF;
+
+ require_once $_CONF['path_system'] . 'classes/config.class.php';
+ require_once $_CONF['path'] . 'plugins/polls/install_defaults.php';
+
+ $c = config::get_instance();
+
+ // What's New Block
+ $c->add('fs_whatsnew', NULL, 'fieldset',
+ 0, 1, NULL, 0, true, 'polls');
More information about the geeklog-cvs
mailing list