[geeklog-cvs] geeklog: Updated Calendar Plugin to 1.1.3
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Thu Sep 29 14:10:05 EDT 2011
changeset 8429:5bfe36b142ca
url: http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/5bfe36b142ca
user: Tom <websitemaster at cogeco.net>
date: Thu Sep 29 13:58:03 2011 -0400
description:
Updated Calendar Plugin to 1.1.3
Calendar plugin now takes into account if a group has been deleted.
Calendar plugin block (Events) has been converted to a dynamic block that is configurable in the Geeklog Configuration.
diffstat:
plugins/calendar/autoinstall.php | 8 +-
plugins/calendar/functions.inc | 109 +++++++++++++++++++++++++++-
plugins/calendar/install_defaults.php | 44 ++++++++++-
plugins/calendar/install_updates.php | 45 +++++++++++
plugins/calendar/language/english.php | 22 ++++-
plugins/calendar/language/english_utf-8.php | 22 ++++-
plugins/calendar/sql/mssql_install.php | 2 -
plugins/calendar/sql/mssql_updates.php | 26 ++++++
plugins/calendar/sql/mysql_install.php | 2 -
plugins/calendar/sql/mysql_updates.php | 28 ++++++-
plugins/calendar/sql/pgsql_install.php | 2 -
plugins/calendar/sql/pgsql_updates.php | 26 ++++++
public_html/docs/english/calendar.html | 33 ++++++++
13 files changed, 348 insertions(+), 21 deletions(-)
diffs (truncated from 585 to 300 lines):
diff -r 8595e3f17f4c -r 5bfe36b142ca plugins/calendar/autoinstall.php
--- a/plugins/calendar/autoinstall.php Thu Sep 29 13:54:38 2011 -0400
+++ b/plugins/calendar/autoinstall.php Thu Sep 29 13:58:03 2011 -0400
@@ -44,7 +44,7 @@
$info = array(
'pi_name' => $pi_name,
'pi_display_name' => $pi_display_name,
- 'pi_version' => '1.1.2',
+ 'pi_version' => '1.1.3',
'pi_gl_version' => '1.8.0',
'pi_homepage' => 'http://www.geeklog.net/'
);
@@ -59,7 +59,8 @@
$pi_name . '.submit' => 'May skip the event submission queue',
'config.' . $pi_name . '.tab_main' => 'Access to configure general calendar settings',
'config.' . $pi_name . '.tab_permissions' => 'Access to configure event default permissions',
- 'config.' . $pi_name . '.tab_autotag_permissions' => 'Access to configure event autotag usage permissions'
+ 'config.' . $pi_name . '.tab_autotag_permissions' => 'Access to configure event autotag usage permissions',
+ 'config.' . $pi_name . '.tab_events_block' => 'Access to configure events block'
);
$mappings = array(
@@ -68,7 +69,8 @@
$pi_name . '.submit' => 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_events_block' => array($pi_admin)
);
$tables = array(
diff -r 8595e3f17f4c -r 5bfe36b142ca plugins/calendar/functions.inc
--- a/plugins/calendar/functions.inc Thu Sep 29 13:54:38 2011 -0400
+++ b/plugins/calendar/functions.inc Thu Sep 29 13:58:03 2011 -0400
@@ -1594,6 +1594,23 @@
$current_version = '1.1.2';
break;
+
+ case '1.1.2':
+ if (isset($_UPDATES[$current_version])) {
+ $_SQL = $_UPDATES[$current_version];
+ foreach ($_SQL as $sql) {
+ DB_query($sql);
+ }
+ }
+
+ if (! $current_config) {
+ calendar_update_ConfValues_1_1_2();
+
+ calendar_update_ConfigSecurity_1_1_2();
+ }
+
+ $current_version = '1.1.3';
+ break;
default:
$done = true;
@@ -1674,7 +1691,8 @@
'calendar.submit',
'config.calendar.tab_main',
'config.calendar.tab_permissions',
- 'config.calendar.tab_autotag_permissions'),
+ 'config.calendar.tab_autotag_permissions',
+ 'config.calendar.tab_events_block'),
/* give the full name of the block, including 'phpblock_', etc */
'php_blocks' => array('phpblock_calendar'),
/* give all vars with their name */
@@ -2111,4 +2129,93 @@
return;
}
+/**
+* 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_calendar($side, $topic='')
+{
+ global $_TABLES, $_CONF, $_CA_CONF, $LANG_CAL_1;
+
+ $retval = array();
+
+ $owner_id = SEC_getDefaultRootUser();
+
+ // Check permissions first
+ if ($_CA_CONF['block_enable'] && SEC_hasAccess($owner_id, $_CA_CONF['block_group_id'], $_CA_CONF['block_permissions'][0], $_CA_CONF['block_permissions'][1], $_CA_CONF['block_permissions'][2], $_CA_CONF['block_permissions'][3])) {
+ // Check if right topic
+ if (($_CA_CONF['block_topic_option'] == TOPIC_ALL_OPTION) || ($_CA_CONF['block_topic_option'] == TOPIC_HOMEONLY_OPTION && COM_onFrontpage()) || ($_CA_CONF['block_topic_option'] == TOPIC_SELECTED_OPTION && in_array($topic, $_CA_CONF['block_topic']))) {
+ if (($side=='left' && $_CA_CONF['block_isleft'] == 1) || ($side=='right' && $_CA_CONF['block_isleft'] == 0)) { // Create a block
+ $display = phpblock_calendar();
+
+ $retval[] = array('name' => 'polls',
+ 'type' => 'dynamic',
+ 'onleft' => 1,
+ 'title' => $LANG_CAL_1[50],
+ 'blockorder' => $_CA_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_calendar($grp_id, $mode)
+{
+ global $_TABLES, $_GROUPS, $_CA_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['Calendar Admin'])) {
+ $new_group_id = $_GROUPS['Calendar Admin'];
+ } else {
+ $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Calendar 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 Events with new group id
+ $sql = "UPDATE {$_TABLES['events']} SET group_id = $new_group_id WHERE group_id = $grp_id";
+ $result = DB_query($sql);
+
+ // Update Events with new group id
+ $sql = "UPDATE {$_TABLES['personal_events']} SET group_id = $new_group_id WHERE group_id = $grp_id";
+ $result = DB_query($sql);
+
+ // Update Events Block group if need be
+ if ($_CA_CONF['block_group_id'] == $grp_id) {
+ // Now save it to the configuration
+ $c = config::get_instance();
+ $c->set('block_group_id', $new_group_id, 'calendar');
+
+ }
+ }
+}
+
?>
diff -r 8595e3f17f4c -r 5bfe36b142ca plugins/calendar/install_defaults.php
--- a/plugins/calendar/install_defaults.php Thu Sep 29 13:54:38 2011 -0400
+++ b/plugins/calendar/install_defaults.php Thu Sep 29 13:58:03 2011 -0400
@@ -91,6 +91,14 @@
*/
$_CA_DEFAULT['aftersave'] = 'list';
+// Events Block
+$_CA_DEFAULT['block_isleft'] = 1;
+$_CA_DEFAULT['block_order'] = 50;
+$_CA_DEFAULT['block_topic_option'] = TOPIC_ALL_OPTION;
+$_CA_DEFAULT['block_topic'] = array();
+$_CA_DEFAULT['block_enable'] = true;
+$_CA_DEFAULT['block_permissions'] = array (2, 2, 2, 2);
+
// Define default permissions for new events created from the Admin panel.
// Permissions are perm_owner, perm_group, perm_members, perm_anon (in that
// order). Possible values:
@@ -120,7 +128,7 @@
*/
function plugin_initconfig_calendar()
{
- global $_CONF, $_CA_CONF, $_CA_DEFAULT;
+ global $_CONF, $_CA_CONF, $_CA_DEFAULT, $_TABLES, $_GROUPS;
if (is_array($_CA_CONF) && (count($_CA_CONF) > 1)) {
$_CA_DEFAULT = array_merge($_CA_DEFAULT, $_CA_CONF);
@@ -178,7 +186,39 @@
$c->add('tab_autotag_permissions', NULL, 'tab', 0, 10, NULL, 0, true, 'calendar', 10);
$c->add('fs_autotag_permissions', NULL, 'fieldset', 0, 10, NULL, 0, true, 'calendar', 10);
$c->add('autotag_permissions_event', $_CA_DEFAULT['autotag_permissions_event'], '@select',
- 0, 10, 13, 10, true, 'calendar', 10);
+ 0, 10, 13, 10, true, 'calendar', 10);
+
+ $c->add('tab_events_block', NULL, 'tab', 0, 20, NULL, 0, true, 'calendar', 20);
+ $c->add('fs_block_settings', NULL, 'fieldset', 0, 10, NULL, 0, true, 'calendar', 20);
+ $c->add('block_enable', $_CA_DEFAULT['block_enable'], 'select',
+ 0, 10, 0, 10, true, 'calendar', 20);
+ $c->add('block_isleft', $_CA_DEFAULT['block_isleft'], 'select',
+ 0, 10, 0, 20, true, 'calendar', 20);
+ $c->add('block_order', $_CA_DEFAULT['block_order'], 'text',
+ 0, 10, 0, 30, true, 'calendar', 20);
+ $c->add('block_topic_option', $_CA_DEFAULT['block_topic_option'],'select',
+ 0, 10, 16, 40, true, 'calendar', 20);
+ $c->add('block_topic', $_CA_DEFAULT['block_topic'], '%select',
+ 0, 10, 17, 50, true, 'calendar', 20);
+
+ $c->add('fs_block_permissions', NULL, 'fieldset', 0, 20, NULL, 0, true, 'calendar', 20);
+ $new_group_id = 0;
+ if (isset($_GROUPS['Calendar Admin'])) {
+ $new_group_id = $_GROUPS['Calendar Admin'];
+ } else {
+ $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Calendar 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, 'calendar', 20);
+ $c->add('block_permissions', $_CA_DEFAULT['block_permissions'], '@select',
+ 0, 20, 14, 20, true, 'calendar', 20);
}
return true;
diff -r 8595e3f17f4c -r 5bfe36b142ca plugins/calendar/install_updates.php
--- a/plugins/calendar/install_updates.php Thu Sep 29 13:54:38 2011 -0400
+++ b/plugins/calendar/install_updates.php Thu Sep 29 13:58:03 2011 -0400
@@ -24,4 +24,49 @@
return true;
}
+function calendar_update_ConfValues_1_1_2()
+{
+ global $_CONF, $_CA_DEFAULT, $_CA_CONF, $_GROUPS, $_TABLES;
+
+ require_once $_CONF['path_system'] . 'classes/config.class.php';
+
+ $c = config::get_instance();
+
+ require_once $_CONF['path'] . 'plugins/calendar/install_defaults.php';
+
+ $c->add('tab_events_block', NULL, 'tab', 0, 20, NULL, 0, true, 'calendar', 20);
+ $c->add('fs_block_settings', NULL, 'fieldset', 0, 10, NULL, 0, true, 'calendar', 20);
+ $c->add('block_enable', $_CA_DEFAULT['block_enable'], 'select',
+ 0, 10, 0, 10, true, 'calendar', 20);
+ $c->add('block_isleft', $_CA_DEFAULT['block_isleft'], 'select',
+ 0, 10, 0, 20, true, 'calendar', 20);
+ $c->add('block_order', $_CA_DEFAULT['block_order'], 'text',
+ 0, 10, 0, 30, true, 'calendar', 20);
+ $c->add('block_topic_option', $_CA_DEFAULT['block_topic_option'],'select',
+ 0, 10, 16, 40, true, 'calendar', 20);
+ $c->add('block_topic', $_CA_DEFAULT['block_topic'], '%select',
+ 0, 10, 17, 50, true, 'calendar', 20);
+
+ $c->add('fs_block_permissions', NULL, 'fieldset', 0, 20, NULL, 0, true, 'calendar', 20);
+ $new_group_id = 0;
+ if (isset($_GROUPS['Calendar Admin'])) {
+ $new_group_id = $_GROUPS['Calendar Admin'];
+ } else {
+ $new_group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Calendar 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, 'calendar', 20);
+ $c->add('block_permissions', $_CA_DEFAULT['block_permissions'], '@select',
+ 0, 20, 14, 20, true, 'calendar', 20);
+
+ return true;
+}
+
?>
\ No newline at end of file
diff -r 8595e3f17f4c -r 5bfe36b142ca plugins/calendar/language/english.php
--- a/plugins/calendar/language/english.php Thu Sep 29 13:54:38 2011 -0400
+++ b/plugins/calendar/language/english.php Thu Sep 29 13:58:03 2011 -0400
@@ -211,7 +211,14 @@
'delete_event' => 'Delete Events with Owner?',
'aftersave' => 'After Saving Event',
'default_permissions' => 'Event Default Permissions',
- 'autotag_permissions_event' => '[event: ] Permissions'
+ 'autotag_permissions_event' => '[event: ] Permissions',
+ 'block_enable' => 'Enabled',
+ 'block_isleft' => 'Display Block on Left',
+ 'block_order' => 'Block Order',
+ 'block_topic_option' => 'Topic Options',
+ 'block_topic' => 'Topic',
+ 'block_group_id' => 'Group',
More information about the geeklog-cvs
mailing list