Example #1
0
/**
*   Upgrade the evList plugin
*
*   @return boolean     True on success, False on failure
*/
function evlist_upgrade()
{
    global $_TABLES, $_CONF, $_EV_CONF, $_DB_table_prefix, $_DB_dbms, $c;
    $currentVersion = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name='evlist'");
    $_TABLES['evlist_settings'] = $_DB_table_prefix . 'evlist_settings';
    switch ($currentVersion) {
        case '1.0':
        case '1.0.0':
        case '1.0.1':
            DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.0.2' WHERE pi_name = '{$pi_name}'");
        case '1.0.2':
            //upgrade to version 1.1
            DB_query("ALTER TABLE {$_TABLES['evlist_events']}\n                ADD enable_reminders TINYINT(1) NOT NULL default '1' AFTER hits,\n                CHANGE time_start1 time_start1 VARCHAR(8) NOT NULL DEFAULT '0'\n                ");
            DB_query("ALTER TABLE {$_TABLES['evlist_submissions']}\n                ADD enable_reminders TINYINT(1) NOT NULL default '0' AFTER hits,\n                CHANGE time_start1 time_start1 VARCHAR(8) NOT NULL DEFAULT '0'\n                ");
            if (file_exists($_CONF['path'] . 'plugins/evlist/sql/def_events.php')) {
                //because the default events have been updated with new information
                include_once $_CONF['path'] . 'plugins/evlist/sql/def_events.php';
                DB_query($DEFVALUES['evlist_events']);
            } else {
                //you won't get the new info, but your default events will still work.
                DB_query("UPDATE IGNORE {$_TABLES['evlist_events']}\n                    SET time_start1 = '0' WHERE id = '20070924175337252'\n                    OR id = '20070922110402423' OR id = '20070924133400211'\n                    ");
            }
            DB_query("CREATE TABLE {$_TABLES['evlist_remlookup']} (\n                id VARCHAR(40) NOT NULL,\n                eid VARCHAR(40) NOT NULL,\n                date_start INT UNSIGNED NOT NULL,\n                timestamp INT UNSIGNED,\n                email VARCHAR(96) NOT NULL,\n                days_notice SMALLINT(3) NOT NULL default '7',\n                UNIQUE eid (eid,timestamp,email,days_notice)\n                ) ENGINE=MyISAM\n                ");
            DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.1' WHERE pi_name = '{$pi_name}'");
        case '1.1':
        case '1.1.1.fusion':
        case '1.1.3.fusion':
            // need to migrate the configuration to our new online configuration.
            plugin_initconfig_evlist();
            include $_CONF['path'] . 'plugins/evlist/evlist.php';
            DB_query("DROP TABLE {$_TABLES['evlist_settings']}", 1);
            DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.1.4.fusion', pi_gl_version='1.1.0',pi_homepage='http://www.glfusion.org' WHERE pi_name = '{$pi_name}'");
        case '1.1.4.fusion':
            $c->add('enable_reminders', 1, 'select', 0, 0, 0, 80, true, 'evlist');
            $c->add('reminder_days', 7, 'text', 0, 0, NULL, 90, true, 'evlist');
            DB_query("ALTER TABLE {$_TABLES['evlist_remlookup']}\n                ADD uid MEDIUMINT(8) NOT NULL default '1' AFTER timestamp");
            DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '1.2.0.fusion', pi_gl_version='1.1.0',pi_homepage='http://www.glfusion.org' WHERE pi_name = '{$pi_name}'");
        case '1.2.0':
        case '1.2.1':
        case '1.2.2':
        case '1.2.3':
        case '1.2.4':
        case '1.2.5':
            $c->add('displayblocks', 0, 'select', 0, 1, 13, 25, true, 'evlist');
            // no db or config changes
            DB_query("UPDATE {$_TABLES['groups']} SET grp_gl_core=2 WHERE grp_name='evList Admin'", 1);
            DB_query("INSERT INTO {$_TABLES['blocks']} (\n                is_enabled, name, type, title, tid, blockorder, onleft, \n                phpblockfn, group_id, owner_id, \n                perm_owner, perm_group, perm_members, perm_anon\n            ) VALUES (\n                '0', 'evlist_smallmonth', 'phpblock', 'Event Calendar', 'all', 0, 0,\n                'phpblock_evlist_smallmonth', 4, 2, \n                3, 3, 2, 2\n            )");
        case '1.2.6':
            // Lots of updates
            $status = evlist_upgrade_1_3_0();
            if ($status > 0) {
                break;
            }
        case '1.3.0':
        case '1.3.0.1':
        case '1.3.0.2':
        case '1.3.1':
            $error = EVLIST_do_upgrade_sql('1.3.2');
            if ($error) {
                break;
            }
            // Add the enable_ical option to the calendar table
            /*COM_errorLog('Adding ical-enable field to calendars table');
              DB_query("ALTER TABLE {$_TABLES['evlist_calendars']}
                  ADD `cal_ena_ical` tinyint(1) unsigned DEFAULT '1'
                  AFTER `cal_status`", 1);*/
            //if (DB_error()) break;
            // Change the recurring interval type to an array to support
            // multiple occurrences per month for DOM-type events
            $sql = "SELECT id, rec_data\n                    FROM {$_TABLES['evlist_events']}\n                    WHERE recurring = 1";
            $res = DB_query($sql, 1);
            if (!$res) {
                COM_errorLog("Error retrieving recurring events");
                break;
            }
            while ($A = DB_fetchArray($res, false)) {
                $data = @unserialize($A['rec_data']);
                if (!$data) {
                    // rec_data *should* be a serialized array, but if it isn't
                    // then there's nothing useful here anyway.
                    COM_errorLog("Error unserializing rec_data- id {$A['id']}");
                    continue;
                }
                if (isset($data['interval']) && !is_array($data['interval'])) {
                    $data['interval'] = array($data['interval']);
                    $data = DB_escapeString(serialize($data));
                    DB_query("UPDATE {$_TABLES['evlist_events']}\n                            SET rec_data = '{$data}'\n                            WHERE id = '{$A['id']}'", 1);
                    if (DB_error()) {
                        break 2;
                    }
                }
            }
        case '1.3.4':
            // This is likely to fail, rec_option has been unused since 1.3.0
            // but was never removed via upgrading
            DB_query("ALTER TABLE {$_TABLES['evlist_events']} DROP rec_option", 1);
        case '1.3.5':
            DB_query("UPDATE {$_TABLES['conf_values']}\n                    SET selectionArray = 9\n                    WHERE name = 'enable_centerblock'\n                    AND group_name = '{$_EV_CONF['pi_name']}'");
    }
    // Recent updates, check for version less than current rather than
    // exact versions
    if ($currentVersion < '1.3.7') {
        // Update versions less than 1.3.7
        $error = EVLIST_do_upgrade_sql('1.3.7');
        if (!$error) {
            // Remove date and time formats, global configs are used instead.
            $c->del('week_begins', 'evlist');
            $c->del('date_format', 'evlist');
            $c->del('time_format', 'evlist');
            $c->add('cal_tmpl', 'html', 'select', 0, 1, 16, 130, true, 'evlist');
            $c->add('sg_rsvp', NULL, 'subgroup', 20, 0, NULL, 0, true, 'evlist');
            $c->add('fs_rsvp', NULL, 'fieldset', 20, 10, NULL, 0, true, 'evlist');
            $c->add('enable_rsvp', $CONF_EVLIST_DEFAULT['enable_rsvp'], 'select', 20, 10, 17, 10, true, 'evlist');
            $c->add('rsvp_print', $CONF_EVLIST_DEFAULT['rsvp_print'], 'select', 20, 10, 17, 20, true, 'evlist');
        } else {
            return false;
        }
    }
    CTL_clearCache();
    DB_query("UPDATE {$_TABLES['plugins']}\n        SET \n            pi_version='{$_EV_CONF['pi_version']}',\n            pi_gl_version='{$_EV_CONF['gl_version']}'\n        WHERE \n            pi_name='evlist' LIMIT 1", 1);
    if (DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name='evlist'") == $_EV_CONF['pi_version']) {
        return true;
    } else {
        return false;
    }
}
Example #2
0
/**
* Loads the configuration records for the Online Config Manager
*
* @return   boolean     true = proceed with install, false = an error occured
*
*/
function plugin_load_configuration_evlist()
{
    global $_CONF;
    require_once $_CONF['path'] . 'plugins/evlist/install_defaults.php';
    return plugin_initconfig_evlist();
}