[geeklog-cvs] geeklog: Updated Polls Plugin to 2.1.4

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Thu Sep 29 14:10:05 EDT 2011


changeset 8430:f21bb80385b1
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/f21bb80385b1
user: Tom <websitemaster at cogeco.net>
date: Thu Sep 29 14:01:20 2011 -0400
description:
Updated Polls Plugin to 2.1.4
Polls plugin now takes into account if a group has been deleted.
Poll block has been converted to a dynamic block that is configurable in the Geeklog Configuration.

diffstat:

 plugins/polls/autoinstall.php            |    8 +-
 plugins/polls/functions.inc              |  105 ++++++++++++++++++++++++++++++-
 plugins/polls/install_defaults.php       |   44 ++++++++++++-
 plugins/polls/install_updates.php        |   45 +++++++++++++
 plugins/polls/language/english.php       |   23 +++++-
 plugins/polls/language/english_utf-8.php |   23 +++++-
 plugins/polls/sql/mssql_install.php      |    2 -
 plugins/polls/sql/mssql_updates.php      |   84 ++++++++++++++++--------
 plugins/polls/sql/mysql_install.php      |    2 -
 plugins/polls/sql/mysql_updates.php      |   86 ++++++++++++++++--------
 plugins/polls/sql/pgsql_install.php      |    2 -
 plugins/polls/sql/pgsql_updates.php      |   28 ++++++++
 public_html/docs/english/polls.html      |   34 ++++++++++
 13 files changed, 407 insertions(+), 79 deletions(-)

diffs (truncated from 737 to 300 lines):

diff -r 5bfe36b142ca -r f21bb80385b1 plugins/polls/autoinstall.php
--- a/plugins/polls/autoinstall.php	Thu Sep 29 13:58:03 2011 -0400
+++ b/plugins/polls/autoinstall.php	Thu Sep 29 14:01:20 2011 -0400
@@ -51,7 +51,7 @@
     $info = array(
         'pi_name'         => $pi_name,
         'pi_display_name' => $pi_display_name,
-        'pi_version'      => '2.1.3',
+        'pi_version'      => '2.1.4',
         'pi_gl_version'   => '1.8.0',
         'pi_homepage'     => 'http://www.geeklog.net/'
     );
@@ -65,7 +65,8 @@
         'config.' . $pi_name . '.tab_whatsnew'              => 'Access to configure ' . $pi_name . ' what\'s new block',
         'config.' . $pi_name . '.tab_main'                  => 'Access to configure general ' . $pi_name . ' settings',
         'config.' . $pi_name . '.tab_permissions'           => 'Access to configure ' . $pi_name . ' default permissions',
-        'config.' . $pi_name . '.tab_autotag_permissions'   => 'Access to configure ' . $pi_name . ' autotag usage permissions'
+        'config.' . $pi_name . '.tab_autotag_permissions'   => 'Access to configure ' . $pi_name . ' autotag usage permissions', 
+        'config.' . $pi_name . '.tab_poll_block'            => 'Access to configure ' . $pi_name . ' block'
     );
 
     $mappings = array(
@@ -73,7 +74,8 @@
         'config.' . $pi_name . '.tab_whatsnew'              => array($pi_admin),
         'config.' . $pi_name . '.tab_main'                  => array($pi_admin),
         'config.' . $pi_name . '.tab_permissions'           => array($pi_admin),
-        'config.' . $pi_name . '.tab_autotag_permissions'   => array($pi_admin)        
+        'config.' . $pi_name . '.tab_autotag_permissions'   => array($pi_admin), 
+        'config.' . $pi_name . '.tab_poll_block'            => array($pi_admin)        
     );
 
     $tables = array(
diff -r 5bfe36b142ca -r f21bb80385b1 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc	Thu Sep 29 13:58:03 2011 -0400
+++ b/plugins/polls/functions.inc	Thu Sep 29 14:01:20 2011 -0400
@@ -404,7 +404,8 @@
                             'config.polls.tab_whatsnew',
                             'config.polls.tab_main',
                             'config.polls.tab_permissions',
-                            'config.polls.tab_autotag_permissions'),
+                            'config.polls.tab_autotag_permissions',
+                            'config.polls.tab_poll_block'),
         /* give the full name of the block, including 'phpblock_', etc */
         'php_blocks' => array('phpblock_polls'),
         /* give all vars with their name */
@@ -1244,6 +1245,23 @@
 
             $current_version = '2.1.3';
             break;
+            
+        case '2.1.3':
+            if (isset($_UPDATES[$current_version])) {
+                $_SQL = $_UPDATES[$current_version];
+                foreach ($_SQL as $sql) {
+                    DB_query($sql);
+                }
+            }
+
+            if (! $current_config) {
+                polls_update_ConfValues_2_1_3();
+                
+                polls_update_ConfigSecurity_2_1_3();
+            }
+
+            $current_version = '2.1.4';
+            break;            
 
         default:
             $done = true;
@@ -1732,4 +1750,89 @@
     }
 }
 
+/**
+* Gets Geeklog blocks from plugins
+*
+* Returns data for blocks on a given side and, potentially, for
+* a given topic.
+*
+* @param    string  $side   Side to get blocks for (right or left for now)
+* @param    string  $topic  Only get blocks for this topic
+* @return   array           array of block data
+* @link     http://wiki.geeklog.net/index.php/Dynamic_Blocks
+*
+*/
+function plugin_getBlocks_polls($side, $topic='')
+{
+    global $_TABLES, $_CONF, $_PO_CONF, $LANG_POLLS;
+    
+    $retval = array();
+    
+    $owner_id = SEC_getDefaultRootUser();
+
+    // Check permissions first
+    if ($_PO_CONF['block_enable'] && SEC_hasAccess($owner_id, $_PO_CONF['block_group_id'], $_PO_CONF['block_permissions'][0], $_PO_CONF['block_permissions'][1], $_PO_CONF['block_permissions'][2], $_PO_CONF['block_permissions'][3])) {
+        // Check if right topic
+        if (($_PO_CONF['block_topic_option'] == TOPIC_ALL_OPTION) || ($_PO_CONF['block_topic_option'] == TOPIC_HOMEONLY_OPTION && COM_onFrontpage()) || ($_PO_CONF['block_topic_option'] == TOPIC_SELECTED_OPTION && in_array($topic, $_PO_CONF['block_topic']))) {
+            if (($side=='left' && $_PO_CONF['block_isleft'] == 1) || ($side=='right' && $_PO_CONF['block_isleft'] == 0)) { // Create a block
+                $display = phpblock_polls();
+                
+                $retval[] = array('name'           => 'polls',
+                                  'type'           => 'dynamic',
+                                  'onleft'         => 1,
+                                  'title'          => $LANG_POLLS['poll'],
+                                  'blockorder'     => $_PO_CONF['block_order'],
+                                  'content'        => $display,
+                                  'allow_autotags' => false,
+                                  'help'           => '');
+            }
+        }
+    }
+    
+    return $retval;
+}
+
+/**
+* This function is called to inform plugins when a group's information has
+* changed or a new group has been created.
+*
+* @param    int     $grp_id     Group ID
+* @param    string  $mode       type of change: 'new', 'edit', or 'delete'
+* @return   void
+*
+*/
+function plugin_group_changed_polls($grp_id, $mode)
+{
+    global $_TABLES, $_GROUPS, $_PO_CONF;
+    
+    if ($mode == 'delete') {
+        // Change any deleted group ids to Polls Admin if exist, if does not change to root group
+        $new_group_id = 0;
+        if (isset($_GROUPS['Polls Admin'])) {
+            $new_group_id = $_GROUPS['Polls Admin'];
+        } else {
+            $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Polls Admin'");
+            if ($new_group_id == 0) {
+                if (isset($_GROUPS['Root'])) {
+                    $new_group_id = $_GROUPS['Root'];
+                } else {
+                    $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
+                }
+            }
+        }    
+        
+        // Update Polls with new group id
+        $sql = "UPDATE {$_TABLES['polltopics']} SET group_id = $new_group_id WHERE group_id = $grp_id";        
+        $result = DB_query($sql);
+        
+        // Update Polls Block group if need be
+        if ($_PO_CONF['block_group_id'] == $grp_id) {
+            // Now save it to the configuration
+            $c = config::get_instance();
+            $c->set('block_group_id', $new_group_id, 'polls');
+            
+        }
+   }
+}
+
 ?>
diff -r 5bfe36b142ca -r f21bb80385b1 plugins/polls/install_defaults.php
--- a/plugins/polls/install_defaults.php	Thu Sep 29 13:58:03 2011 -0400
+++ b/plugins/polls/install_defaults.php	Thu Sep 29 14:01:20 2011 -0400
@@ -91,6 +91,14 @@
 // Display Meta Tags for static pages (1 = show, 0 = don't) 
 $_PO_DEFAULT['meta_tags'] = 0;
 
+// Poll Block
+$_PO_DEFAULT['block_isleft'] = 0;
+$_PO_DEFAULT['block_order'] = 100;
+$_PO_DEFAULT['block_topic_option'] = TOPIC_ALL_OPTION;
+$_PO_DEFAULT['block_topic'] = array();
+$_PO_DEFAULT['block_enable'] = true;
+$_PO_DEFAULT['block_permissions'] = array (2, 2, 2, 2);
+
 // Define default permissions for new polls created from the Admin panel.
 // Permissions are perm_owner, perm_group, perm_members, perm_anon (in that
 // order). Possible values:
@@ -123,7 +131,7 @@
 */
 function plugin_initconfig_polls()
 {
-    global $_CONF, $_PO_CONF, $_PO_DEFAULT;
+    global $_CONF, $_PO_CONF, $_PO_DEFAULT, $_TABLES, $_GROUPS;
 
     if (is_array($_PO_CONF) && (count($_PO_CONF) > 1)) {
         $_PO_DEFAULT = array_merge($_PO_DEFAULT, $_PO_CONF);
@@ -177,7 +185,39 @@
         $c->add('autotag_permissions_poll_vote', $_PO_DEFAULT['autotag_permissions_poll_vote'], '@select', 
                 0, 10, 13, 10, true, 'polls', 10);       
         $c->add('autotag_permissions_poll_result', $_PO_DEFAULT['autotag_permissions_poll_result'], '@select', 
-                0, 10, 13, 10, true, 'polls', 10);       
+                0, 10, 13, 10, true, 'polls', 10);
+        
+        $c->add('tab_poll_block', NULL, 'tab', 0, 20, NULL, 0, true, 'polls', 20);
+        $c->add('fs_block_settings', NULL, 'fieldset', 0, 10, NULL, 0, true, 'polls', 20);
+        $c->add('block_enable', $_PO_DEFAULT['block_enable'], 'select', 
+                0, 10, 0, 10, true, 'polls', 20);
+        $c->add('block_isleft', $_PO_DEFAULT['block_isleft'], 'select', 
+                0, 10, 0, 20, true, 'polls', 20);
+        $c->add('block_order', $_PO_DEFAULT['block_order'], 'text',
+                0, 10, 0, 30, true, 'polls', 20);
+        $c->add('block_topic_option', $_PO_DEFAULT['block_topic_option'],'select',
+                0, 10, 16, 40, true, 'polls', 20);  
+        $c->add('block_topic', $_PO_DEFAULT['block_topic'], '%select',
+                0, 10, 17, 50, true, 'polls', 20);
+    
+        $c->add('fs_block_permissions', NULL, 'fieldset', 0, 20, NULL, 0, true, 'polls', 20);
+        $new_group_id = 0;
+        if (isset($_GROUPS['Polls Admin'])) {
+            $new_group_id = $_GROUPS['Polls Admin'];
+        } else {
+            $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Polls Admin'");
+            if ($new_group_id == 0) {
+                if (isset($_GROUPS['Root'])) {
+                    $new_group_id = $_GROUPS['Root'];
+                } else {
+                    $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
+                }
+            }
+        }         
+        $c->add('block_group_id', $new_group_id,'select',
+                0, 20, 15, 10, TRUE, 'polls', 20);        
+        $c->add('block_permissions', $_PO_DEFAULT['block_permissions'], '@select', 
+                0, 20, 14, 20, true, 'polls', 20);       
     }
 
     return true;
diff -r 5bfe36b142ca -r f21bb80385b1 plugins/polls/install_updates.php
--- a/plugins/polls/install_updates.php	Thu Sep 29 13:58:03 2011 -0400
+++ b/plugins/polls/install_updates.php	Thu Sep 29 14:01:20 2011 -0400
@@ -29,4 +29,49 @@
     return true;
 }
 
+function polls_update_ConfValues_2_1_3()
+{
+    global $_CONF, $_PO_DEFAULT, $_PO_CONF, $_GROUPS, $_TABLES;
+
+    require_once $_CONF['path_system'] . 'classes/config.class.php';
+    
+    $c = config::get_instance();
+    
+    require_once $_CONF['path'] . 'plugins/polls/install_defaults.php';
+
+    $c->add('tab_poll_block', NULL, 'tab', 0, 20, NULL, 0, true, 'polls', 20);
+    $c->add('fs_block_settings', NULL, 'fieldset', 0, 10, NULL, 0, true, 'polls', 20);
+    $c->add('block_enable', $_PO_DEFAULT['block_enable'], 'select', 
+            0, 10, 0, 10, true, 'polls', 20);
+    $c->add('block_isleft', $_PO_DEFAULT['block_isleft'], 'select', 
+            0, 10, 0, 20, true, 'polls', 20);
+    $c->add('block_order', $_PO_DEFAULT['block_order'], 'text',
+            0, 10, 0, 30, true, 'polls', 20);
+    $c->add('block_topic_option', $_PO_DEFAULT['block_topic_option'],'select',
+            0, 10, 16, 40, true, 'polls', 20);  
+    $c->add('block_topic', $_PO_DEFAULT['block_topic'], '%select',
+            0, 10, 17, 50, true, 'polls', 20);
+
+    $c->add('fs_block_permissions', NULL, 'fieldset', 0, 20, NULL, 0, true, 'polls', 20);
+    $new_group_id = 0;
+    if (isset($_GROUPS['Polls Admin'])) {
+        $new_group_id = $_GROUPS['Polls Admin'];
+    } else {
+        $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Polls Admin'");
+        if ($new_group_id == 0) {
+            if (isset($_GROUPS['Root'])) {
+                $new_group_id = $_GROUPS['Root'];
+            } else {
+                $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
+            }
+        }
+    }         
+    $c->add('block_group_id', $new_group_id,'select',
+            0, 20, 15, 10, TRUE, 'polls', 20);        
+    $c->add('block_permissions', $_PO_DEFAULT['block_permissions'], '@select', 
+            0, 20, 14, 20, true, 'polls', 20);       
+
+    return true;
+}
+    
 ?>
\ No newline at end of file
diff -r 5bfe36b142ca -r f21bb80385b1 plugins/polls/language/english.php
--- a/plugins/polls/language/english.php	Thu Sep 29 13:58:03 2011 -0400
+++ b/plugins/polls/language/english.php	Thu Sep 29 14:01:20 2011 -0400
@@ -30,6 +30,7 @@
 
 $LANG_POLLS = array(
     'polls'             => 'Polls',
+    'poll'               => 'Poll',
     'results'           => 'Results',
     'pollresults'       => 'Poll Results',
     'votes'             => 'votes',
@@ -139,7 +140,14 @@
     'newpollsinterval' => 'New Polls Interval',
     'hidenewpolls' => 'New Polls',
     'title_trim_length' => 'Title Trim Length',
-    'meta_tags' => 'Enable Meta Tags'
+    'meta_tags' => 'Enable Meta Tags',
+    'block_enable' => 'Enabled',
+    'block_isleft' => 'Display Block on Left',



More information about the geeklog-cvs mailing list