steffen: server/kolab-horde-fbview/kolab-horde-fbview/fbview/kronolith/scripts .htaccess, NONE, 1.1 add_meetings.sql, NONE, 1.1 add_meetings_psql.sql, NONE, 1.1 convert_categories.php, NONE, 1.1 create_default_history.php, NONE, 1.1 guid_convert.sql, NONE, 1.1 guid_convert_mysql.sql, NONE, 1.1 mcal_to_sql.php, NONE, 1.1 reminders.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Mon Oct 31 12:43:24 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-fbview/kolab-horde-fbview/fbview/kronolith/scripts
In directory doto:/tmp/cvs-serv18388/kolab-horde-fbview/kolab-horde-fbview/fbview/kronolith/scripts

Added Files:
	.htaccess add_meetings.sql add_meetings_psql.sql 
	convert_categories.php create_default_history.php 
	guid_convert.sql guid_convert_mysql.sql mcal_to_sql.php 
	reminders.php 
Log Message:
Fbview in separate package

--- NEW FILE: .htaccess ---
Deny from all

--- NEW FILE: add_meetings.sql ---
-- $Horde: kronolith/scripts/add_meetings.sql,v 1.2 2004/05/22 12:26:33 mdjukic Exp $

ALTER TABLE kronolith_events ADD COLUMN event_status INT DEFAULT 0 AFTER event_location;
ALTER TABLE kronolith_events ADD COLUMN event_attendees TEXT AFTER event_status;


CREATE TABLE kronolith_storage (
    vfb_owner      VARCHAR(255) DEFAULT NULL,
    vfb_email      VARCHAR(255) NOT NULL DEFAULT '',
    vfb_serialized TEXT NOT NULL
);

CREATE INDEX kronolith_vfb_owner_idx ON kronolith_storage (vfb_owner);
CREATE INDEX kronolith_vfb_email_idx ON kronolith_storage (vfb_email);

GRANT SELECT, INSERT, UPDATE, DELETE ON kronolith_storage TO horde;

--- NEW FILE: add_meetings_psql.sql ---
-- $Horde: kronolith/scripts/add_meetings_psql.sql,v 1.1 2004/03/12 03:23:43 chuck Exp $

ALTER TABLE kronolith_events ADD COLUMN event_status INT;
ALTER TABLE kronolith_events ALTER COLUMN event_status SET DEFAULT 0;
ALTER TABLE kronolith_events ADD COLUMN event_attendees TEXT;


CREATE TABLE kronolith_storage (
    vfb_owner      VARCHAR(255) DEFAULT NULL,
    vfb_email      VARCHAR(255) NOT NULL DEFAULT '',
    vfb_serialized TEXT NOT NULL
);

CREATE INDEX kronolith_vfb_owner_idx ON kronolith_storage (vfb_owner);
CREATE INDEX kronolith_vfb_email_idx ON kronolith_storage (vfb_email);

GRANT SELECT, INSERT, UPDATE, DELETE ON kronolith_storage TO horde;

--- NEW FILE: convert_categories.php ---
#!/usr/local/bin/php
<?php
/**
 * $Horde: kronolith/scripts/convert_categories.php,v 1.4 2004/05/19 20:26:24 chuck Exp $
 *
 * Copyright 2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('AUTH_HANDLER', true);
@define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
require_once KRONOLITH_BASE . '/lib/base.php';

// Run through every calendar.
$cals = $kronolith_shares->listAllShares();
foreach ($cals as $calid => $calshare) {
    echo "Converting categories for $calid ...\n";

    if ($kronolith->getCalendar() != $calid) {
        $kronolith->close();
        $kronolith->open($calid);
    }

    $categories = listCategories($calid);

    // List all events.
    $events = $kronolith->listEvents();
    foreach ($events as $eventId) {
        $event = &$kronolith->getEvent($eventId);
        if (isset($categories[$event->getCategory()])) {
            $event->setCategory($categories[$event->getCategory()]);
            $result = $event->save();
            if (is_a($result, 'PEAR_Error')) {
                Horde::fatal($result);
            }
        }
    }
}

echo "\n** Categories successfully converted ***\n";
exit;

function listCategories($calendar = null)
{
    global $prefs;

    static $catString, $categories;

    $cur = getPrefByShare('event_categories', $calendar);
    if (is_null($catString) || $catString != $cur) {
        $categories = array(0 => _("Unfiled"));

        $catString = $cur;
        if (empty($catString)) {
            return $categories;
        }

        $cats = explode('|', $catString);
        foreach ($cats as $cat) {
            list($key, $val) = explode(':', $cat);
            $categories[$key] = _($val);
        }
    }

    asort($categories);
    return $categories;
}

function getPrefByShare($pref, $share = null)
{
    if (!is_a($share, 'DataTreeObject_Share')) {
        $share = $GLOBALS['kronolith_shares']->getShare($share);
        if (is_a($share, 'PEAR_Error')) {
            return null;
        }
    }

    $owner = $share->get('owner');
    $userprefs = &Prefs::singleton($GLOBALS['conf']['prefs']['driver'],
                                   $GLOBALS['registry']->getApp(),
                                   $owner, '', null, false);
    $userprefs->retrieve();
    return $userprefs->getValue($pref);
}

--- NEW FILE: create_default_history.php ---
#!/usr/local/bin/php
<?php
/**
 * $Horde: kronolith/scripts/create_default_history.php,v 1.7 2004/04/07 14:43:29 chuck Exp $
 *
 * Copyright 1999-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('AUTH_HANDLER', true);
@define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
require_once KRONOLITH_BASE . '/lib/base.php';
require_once 'Horde/History.php';

$history = &Horde_History::singleton();

// Run through every calendar.
$cals = $kronolith_shares->listAllShares();
foreach ($cals as $calid => $calshare) {
    echo "Creating default histories for $calid ...\n";

    if ($kronolith->getCalendar() != $calid) {
        $kronolith->close();
        $kronolith->open($calid);
    }

    // List all events.
    $events = $kronolith->listEvents();
    foreach ($events as $eventId) {
        /* Get the event's history. */
        $log = $history->getHistory($kronolith->getGUID($eventId));
        $created = false;
        foreach ($log->getData() as $entry) {
            if ($entry['action'] == 'add') {
                $created = true;
                break;
            }
        }

        // If there isn't an add entry, add one at the current time.
        if (!$created) {
            $history->log($kronolith->getGUID($eventId), array('action' => 'add'), true);
        }
    }
}

echo "\n** Default histories successfully created ***\n";

--- NEW FILE: guid_convert.sql ---
-- More generic script for converting event_id to a 32-character
-- string (see guid_convert_mysql.sql for MySQL; it's much
-- simpler). This general process worked for me on Postgres.

ALTER TABLE kronolith_events ADD COLUMN new_id VARCHAR(32);
UPDATE kronolith_events SET new_id = event_id;
ALTER TABLE kronolith_events DROP COLUMN event_id;
ALTER TABLE kronolith_events RENAME COLUMN new_id TO event_id;
ALTER TABLE kronolith_events ALTER COLUMN event_id SET NOT NULL;
CREATE INDEX kronolith_events_pkey ON kronolith_events (event_id);

--- NEW FILE: guid_convert_mysql.sql ---
-- MySQL script for converting event_id to a 32-character string.

ALTER TABLE kronolith_events CHANGE COLUMN event_id event_id VARCHAR(32) NOT NULL;

--- NEW FILE: mcal_to_sql.php ---
#!/usr/local/bin/php
<?php
/**
 * $Horde: kronolith/scripts/mcal_to_sql.php,v 1.7 2004/04/26 19:33:48 chuck Exp $
 *
 * Copyright 1999-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (GPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
 */

@define('AUTH_HANDLER', true);
@define('KRONOLITH_BASE', dirname(__FILE__) . '/..');
require_once KRONOLITH_BASE . '/lib/base.php';

// Set these as required.
$sqlparams = $conf['sql'];

// Create a calendar backend object.
$sqlcal = &Kronolith_Driver::factory('sql', $sqlparams);
$mcal = $kronolith;

// Run through every calendar.
$cals = $kronolith_shares->listAllShares();
foreach ($cals as $calid => $calshare) {
    echo "Converting $calid ...\n";

    if ($mcal->getCalendar() != $calid) {
        $mcal->close();
        $mcal->open($calid);
    }
    if ($sqlcal->getCalendar() != $calid) {
        $sqlcal->close();
        $sqlcal->open($calid);
    }

    // List all events.
    $events = $mcal->listEvents();
    echo count($events) . "\n\n";

    foreach ($events as $eventId) {
        $event = $mcal->getEvent($eventId);
        $newevent = $sqlcal->getEvent();

        foreach ((array)$event as $key => $value) {
            if ($key != 'eventID') {
                $newevent->$key = $value;
            }
        }

        $kronolith = $sqlcal;
        $success = $newevent->save();
        if (is_a($success, 'PEAR_Error')) {
            var_dump($success);
        }
        $kronolith = $mcal;
    }
}

--- NEW FILE: reminders.php ---
#!/usr/local/bin/php -q
<?php
/**
 * $Horde: kronolith/scripts/reminders.php,v 1.15 2004/05/20 04:06:14 chuck Exp $
 *
 * Copyright 2003-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

// Find the base file path of Horde.
@define('HORDE_BASE', dirname(__FILE__) . '/../..');

// Find the base file path of Kronolith.
@define('KRONOLITH_BASE', dirname(__FILE__) . '/..');

// Do CLI checks and environment setup first.
require_once HORDE_BASE . '/lib/core.php';
require_once 'Horde/CLI.php';

// Make sure no one runs this from the web.
if (!Horde_CLI::runningFromCLI()) {
    exit("Must be run from the command line\n");
}

// Load the CLI environment - make sure there's no time limit, init
// some variables, etc.
Horde_CLI::init();

// Now load the Registry and setup conf, etc.
$registry = &Registry::singleton();
$registry->pushApp('kronolith', false);

// Include needed libraries.
require_once 'Date/Calc.php';
require_once 'Horde/Scheduler.php';
require_once KRONOLITH_BASE . '/lib/Kronolith.php';
require_once KRONOLITH_BASE . '/lib/Scheduler/kronolith.php';

// Create a share instance. This must exist in the global scope for
// Kronolith's API calls to function properly.
require_once 'Horde/Share.php';
$shares = &Horde_Share::singleton($registry->getApp());

// Create a calendar backend object. This must exist in the global
// scope for Kronolith's API calls to function properly.
$kronolith = &Kronolith_Driver::factory();

// Get an instance of the Kronolith schedulerr.
$reminder = &Horde_Scheduler::unserialize('Horde_Scheduler_kronolith');

// Start the daemon going.
$reminder->run();





More information about the commits mailing list