--- /dev/null
+<?php
+/**
+ * Create turba base tables
+ *
+ * Copyright 2010 The Horde Project (http://www.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.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Turba
+ */
+class TurbaBaseTables extends Horde_Db_Migration_Base
+{
+ /**
+ * Upgrade.
+ */
+ public function up()
+ {
+ $tableList = $this->tables();
+
+ if (!in_array('turba_objects', $tableList)) {
+ $t = $this->createTable('turba_objects', array('primaryKey' => false));
+ $t->column('object_id', 'string', array('limit' => 32, 'null' => false));
+ $t->column('owner_id', 'string', array('limit' => 255, 'null' => false));
+ $t->column('object_type', 'string', array('limit' => 255, 'default' => 'Object', 'null' => false));
+ $t->column('object_uid', 'string', array('limit' => 255));
+ $t->column('object_members', 'text');
+ $t->column('object_firstname', 'string', array('limit' => 255));
+ $t->column('object_lastname', 'string', array('limit' => 255));
+ $t->column('object_middlenames', 'string', array('limit' => 255));
+ $t->column('object_nameprefix', 'string', array('limit' => 32));
+ $t->column('object_namesuffix', 'string', array('limit' => 32));
+ $t->column('object_alias', 'string', array('limit' => 32));
+ $t->column('object_photo', 'binary');
+ $t->column('object_phototype', 'string', array('limit' => 10));
+ $t->column('object_bday', 'string', array('limit' => 10));
+ $t->column('object_homestreet', 'string', array('limit' => 255));
+ $t->column('object_homepob', 'string', array('limit' => 10));
+ $t->column('object_homecity', 'string', array('limit' => 255));
+ $t->column('object_homeprovince', 'string', array('limit' => 255));
+ $t->column('object_homepostalcode', 'string', array('limit' => 10));
+ $t->column('object_homecountry', 'string', array('limit' => 255));
+ $t->column('object_workstreet', 'string', array('limit' => 255));
+ $t->column('object_workpob', 'string', array('limit' => 10));
+ $t->column('object_workcity', 'string', array('limit' => 255));
+ $t->column('object_workprovince', 'string', array('limit' => 255));
+ $t->column('object_workpostalcode', 'string', array('limit' => 10));
+ $t->column('object_workcountry', 'string', array('limit' => 255));
+ $t->column('object_tz', 'string', array('limit' => 32));
+ $t->column('object_geo', 'string', array('limit' => 255));
+ $t->column('object_email', 'string', array('limit' => 255));
+ $t->column('object_homephone', 'string', array('limit' => 25));
+ $t->column('object_workphone', 'string', array('limit' => 25));
+ $t->column('object_cellphone', 'string', array('limit' => 25));
+ $t->column('object_fax', 'string', array('limit' => 25));
+ $t->column('object_pager', 'string', array('limit' => 25));
+ $t->column('object_title', 'string', array('limit' => 255));
+ $t->column('object_role', 'string', array('limit' => 255));
+ $t->column('object_logo', 'binary');
+ $t->column('object_logo_type', 'string', array('limit' => 10));
+ $t->column('object_company', 'string', array('limit' => 255));
+ $t->column('object_category', 'string', array('limit' => 80));
+ $t->column('object_notes', 'text');
+ $t->column('object_url', 'string', array('limit' => 255));
+ $t->column('object_freebusyurl', 'string', array('limit' => 255));
+ $t->column('object_pgppublickey', 'text');
+ $t->column('object_smimepublickey', 'text');
+ $t->primaryKey(array('object_id'));
+ $t->end();
+
+
+ $this->addIndex('turba_objects', array('owner_id'));
+ $this->addIndex('turba_objects', array('object_email'));
+ $this->addIndex('turba_objects', array('object_firstname'));
+ $this->addIndex('turba_objects', array('object_lastname'));
+ }
+
+ if (!in_array('turba_shares', $tableList)) {
+ $t = $this->createTable('turba_shares', array('primaryKey' => false));
+ $t->column('share_id', 'integer', array('null' => false));
+ $t->column('share_name', 'string', array('limit' => 255, 'null' => false));
+ $t->column('share_owner', 'string', array('limit' => 255, 'null' => false));
+ $t->column('share_flags', 'integer', array('default' => 0, 'null' => false));
+ $t->column('perm_creator', 'integer', array('default' => 0, 'null' => false));
+ $t->column('perm_default', 'integer', array('default' => 0, 'null' => false));
+ $t->column('perm_guest', 'integer', array('default' => 0, 'null' => false));
+ $t->column('attribute_name', 'string', array('limit' => 255, 'null' => false));
+ $t->column('attribute_desc', 'string', array('limit' => 255));
+ $t->column('attribute_params', 'text');
+ $t->primaryKey(array('share_id'));
+ $t->end();
+
+ $this->addIndex('turba_shares', 'share_name');
+ $this->addIndex('turba_shares', 'share_owner');
+ $this->addIndex('turba_shares', 'perm_creator');
+ $this->addIndex('turba_shares', 'perm_default');
+ $this->addIndex('turba_shares', 'perm_guest');
+ }
+
+ if (!in_array('turba_shares_groups', $tableList)) {
+ $t = $this->createTable('turba_shares_groups');
+ $t->column('share_id', 'integer', array('null' => false));
+ $t->column('group_uid', 'string', array('limit' => 255, 'null' => false));
+ $t->column('perm', 'integer', array('null' => false));
+ $t->end();
+
+ $this->addIndex('turba_shares_groups', 'share_id');
+ $this->addIndex('turba_shares_groups', 'group_uid');
+ $this->addIndex('turba_shares_groups', 'perm');
+ }
+
+ if (!in_array('turba_shares_users', $tableList)) {
+ $t = $this->createTable('turba_shares_users');
+
+ $t->column('share_id', 'integer', array('null' => false));
+ $t->column('user_uid', 'string', array('limit' => 255));
+ $t->column('perm', 'integer', array('null' => false));
+ $t->end();
+
+ $this->addIndex('turba_shares_users', 'share_id');
+ $this->addIndex('turba_shares_users', 'user_uid');
+ $this->addIndex('turba_shares_users', 'perm');
+ }
+ }
+
+ /**
+ * Downgrade to 0
+ */
+ public function down()
+ {
+ $this->dropTable('turba_objects');
+ $this->dropTable('turba_shares');
+ $this->dropTable('turba_shares_users');
+ $this->dropTable('turba_shares_groups');
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Adds autoincrement flags
+ *
+ * Copyright 2010 The Horde Project (http://www.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.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/gpl.html GPL
+ * @package Turba
+ */
+class TurbaUpgradeAutoIncrement extends Horde_Db_Migration_Base
+{
+ /**
+ * Upgrade.
+ */
+ public function up()
+ {
+ $this->changeColumn('turba_shares', 'share_id', 'integer', array('null' => false, 'autoincrement' => true));
+ }
+
+ /**
+ * Downgrade
+ */
+ public function down()
+ {
+ $this->changeColumn('turba_shares', 'share_id', 'integer', array('null' => false));
+ }
+
+}
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-
- <name><variable>name</variable></name>
- <create>false</create>
- <overwrite>false</overwrite>
-
- <table>
-
- <name>hordetest_turba_objects</name>
-
- <declaration>
-
- <field>
- <name>object_id</name>
- <type>text</type>
- <length>32</length>
- <notnull>true</notnull>
- </field>
-
- <field>
- <name>owner_id</name>
- <type>text</type>
- <length>255</length>
- <notnull>true</notnull>
- </field>
-
- <field>
- <name>object_type</name>
- <type>text</type>
- <length>255</length>
- <notnull>true</notnull>
- <default>Object</default>
- </field>
-
- <field>
- <name>object_uid</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_members</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_name</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_alias</name>
- <type>text</type>
- <length>32</length>
- </field>
-
- <field>
- <name>object_email</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_homeaddress</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_workaddress</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_homephone</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_workphone</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_cellphone</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_fax</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_title</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_company</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_notes</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_pgppublickey</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_smimepublickey</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_freebusyurl</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <index>
- <name>hordetest_turba_objects_primary</name>
- <primary>true</primary>
- <field>
- <name>object_id</name>
- </field>
- </index>
-
- <index>
- <name>hordetest_turba_objects_owner</name>
- <field>
- <name>owner_id</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- </declaration>
-
- </table>
-
-</database>
+++ /dev/null
-CREATE TABLE turba_objects (
- object_id VARCHAR(32) NOT NULL,
- owner_id VARCHAR(255) NOT NULL,
- object_type VARCHAR(255) DEFAULT 'Object' NOT NULL,
- object_uid VARCHAR(255),
- object_members IMAGE,
- object_firstname VARCHAR(255),
- object_lastname VARCHAR(255),
- object_middlenames VARCHAR(255),
- object_nameprefix VARCHAR(32),
- object_namesuffix VARCHAR(32),
- object_alias VARCHAR(32),
- object_photo IMAGE,
- object_phototype VARCHAR(10),
- object_bday VARCHAR(10),
- object_homestreet VARCHAR(255),
- object_homepob VARCHAR(10),
- object_homecity VARCHAR(255),
- object_homeprovince VARCHAR(255),
- object_homepostalcode VARCHAR(10),
- object_homecountry VARCHAR(255),
- object_workstreet VARCHAR(255),
- object_workpob VARCHAR(10),
- object_workcity VARCHAR(255),
- object_workprovince VARCHAR(255),
- object_workpostalcode VARCHAR(10),
- object_workcountry VARCHAR(255),
- object_tz VARCHAR(32),
- object_geo VARCHAR(255),
- object_email VARCHAR(255),
- object_homephone VARCHAR(25),
- object_workphone VARCHAR(25),
- object_cellphone VARCHAR(25),
- object_fax VARCHAR(25),
- object_pager VARCHAR(25),
- object_title VARCHAR(255),
- object_role VARCHAR(255),
- object_logo IMAGE,
- object_logotype VARCHAR(10),
- object_company VARCHAR(255),
- object_category VARCHAR(80),
- object_notes VARCHAR(MAX),
- object_url VARCHAR(255),
- object_freebusyurl VARCHAR(255),
- object_pgppublickey VARCHAR(MAX),
- object_smimepublickey VARCHAR(MAX),
---
- PRIMARY KEY(object_id)
-);
-
-CREATE INDEX turba_owner_idx ON turba_objects (owner_id);
-CREATE INDEX turba_email_idx ON turba_objects (object_email);
-CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname);
-CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname);
-
-CREATE TABLE turba_shares (
- share_id INT NOT NULL,
- share_name VARCHAR(255) NOT NULL,
- share_owner VARCHAR(255) NOT NULL,
- share_flags SMALLINT DEFAULT 0 NOT NULL,
- perm_creator SMALLINT DEFAULT 0 NOT NULL,
- perm_default SMALLINT DEFAULT 0 NOT NULL,
- perm_guest SMALLINT DEFAULT 0 NOT NULL,
- attribute_name VARCHAR(255) NOT NULL,
- attribute_desc VARCHAR(255),
- attribute_params VARCHAR(MAX),
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id INT NOT NULL,
- group_uid VARCHAR(255) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id INT NOT NULL,
- user_uid VARCHAR(255) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm);
+++ /dev/null
-CREATE TABLE turba_objects (
- object_id VARCHAR2(32) NOT NULL,
- owner_id VARCHAR2(255) NOT NULL,
- object_type VARCHAR2(255) DEFAULT 'Object' NOT NULL,
- object_uid VARCHAR2(255),
- object_members CLOB,
- object_firstname VARCHAR2(255),
- object_lastname VARCHAR2(255),
- object_middlenames VARCHAR2(255),
- object_nameprefix VARCHAR2(32),
- object_namesuffix VARCHAR2(32),
- object_alias VARCHAR2(32),
- object_photo BLOB,
- object_phototype VARCHAR2(10),
- object_bday VARCHAR2(10),
- object_homestreet VARCHAR2(255),
- object_homepob VARCHAR2(10),
- object_homecity VARCHAR2(255),
- object_homeprovince VARCHAR2(255),
- object_homepostalcode VARCHAR2(10),
- object_homecountry VARCHAR2(255),
- object_workstreet VARCHAR2(255),
- object_workpob VARCHAR2(10),
- object_workcity VARCHAR2(255),
- object_workprovince VARCHAR2(255),
- object_workpostalcode VARCHAR2(10),
- object_workcountry VARCHAR2(255),
- object_tz VARCHAR2(32),
- object_geo VARCHAR2(255),
- object_email VARCHAR2(255),
- object_homephone VARCHAR2(25),
- object_workphone VARCHAR2(25),
- object_cellphone VARCHAR2(25),
- object_fax VARCHAR2(25),
- object_pager VARCHAR2(25),
- object_title VARCHAR2(255),
- object_role VARCHAR2(255),
- object_logo BLOB,
- object_logotype VARCHAR2(10),
- object_company VARCHAR2(255),
- object_category VARCHAR2(80),
- object_notes CLOB,
- object_url VARCHAR2(255),
- object_freebusyurl VARCHAR2(255),
- object_pgppublickey CLOB,
- object_smimepublickey CLOB,
- PRIMARY KEY(object_id)
-);
-
-CREATE INDEX turba_owner_idx ON turba_objects (owner_id);
-CREATE INDEX turba_email_idx ON turba_objects (object_email);
-CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname);
-CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname);
-
-CREATE TABLE turba_shares (
- share_id NUMBER(16) NOT NULL,
- share_name VARCHAR2(255) NOT NULL,
- share_owner VARCHAR2(255) NOT NULL,
- share_flags NUMBER(8) DEFAULT 0 NOT NULL,
- perm_creator NUMBER(8) DEFAULT 0 NOT NULL,
- perm_default NUMBER(8) DEFAULT 0 NOT NULL,
- perm_guest NUMBER(8) DEFAULT 0 NOT NULL,
- attribute_name VARCHAR2(255) NOT NULL,
- attribute_desc VARCHAR2(255),
- attribute_params VARCHAR2(4000),
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id NUMBER(16) NOT NULL,
- group_uid VARCHAR2(255) NOT NULL,
- perm NUMBER(8) NOT NULL
-);
-
-CREATE INDEX turba_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id NUMBER(16) NOT NULL,
- user_uid VARCHAR2(255) NOT NULL,
- perm NUMBER(8) NOT NULL
-);
-
-CREATE INDEX turba_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_users_perm_idx ON turba_shares_users (perm);
+++ /dev/null
-CREATE TABLE turba_objects (
- object_id VARCHAR(32) NOT NULL,
- owner_id VARCHAR(255) NOT NULL,
- object_type VARCHAR(255) DEFAULT 'Object' NOT NULL,
- object_uid VARCHAR(255),
- object_members TEXT,
- object_firstname VARCHAR(255),
- object_lastname VARCHAR(255),
- object_middlenames VARCHAR(255),
- object_nameprefix VARCHAR(32),
- object_namesuffix VARCHAR(32),
- object_alias VARCHAR(32),
- object_photo TEXT,
- object_phototype VARCHAR(10),
- object_bday VARCHAR(10),
- object_homestreet VARCHAR(255),
- object_homepob VARCHAR(10),
- object_homecity VARCHAR(255),
- object_homeprovince VARCHAR(255),
- object_homepostalcode VARCHAR(10),
- object_homecountry VARCHAR(255),
- object_workstreet VARCHAR(255),
- object_workpob VARCHAR(10),
- object_workcity VARCHAR(255),
- object_workprovince VARCHAR(255),
- object_workpostalcode VARCHAR(10),
- object_workcountry VARCHAR(255),
- object_tz VARCHAR(32),
- object_geo VARCHAR(255),
- object_email VARCHAR(255),
- object_homephone VARCHAR(25),
- object_workphone VARCHAR(25),
- object_cellphone VARCHAR(25),
- object_fax VARCHAR(25),
- object_pager VARCHAR(25),
- object_title VARCHAR(255),
- object_role VARCHAR(255),
- object_logo TEXT,
- object_logotype VARCHAR(10),
- object_company VARCHAR(255),
- object_category VARCHAR(80),
- object_notes TEXT,
- object_url VARCHAR(255),
- object_freebusyurl VARCHAR(255),
- object_pgppublickey TEXT,
- object_smimepublickey TEXT,
-
- PRIMARY KEY(object_id)
-);
-
-CREATE INDEX turba_owner_idx ON turba_objects (owner_id);
-CREATE INDEX turba_email_idx ON turba_objects (object_email);
-CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname);
-CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname);
-
-CREATE TABLE turba_shares (
- share_id INT NOT NULL,
- share_name VARCHAR(255) NOT NULL,
- share_owner VARCHAR(255) NOT NULL,
- share_flags SMALLINT DEFAULT 0 NOT NULL,
- perm_creator SMALLINT DEFAULT 0 NOT NULL,
- perm_default SMALLINT DEFAULT 0 NOT NULL,
- perm_guest SMALLINT DEFAULT 0 NOT NULL,
- attribute_name VARCHAR(255) NOT NULL,
- attribute_desc VARCHAR(255),
- attribute_params TEXT,
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id INT NOT NULL,
- group_uid VARCHAR(255) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id INT NOT NULL,
- user_uid VARCHAR(255) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm);
-
+++ /dev/null
-CREATE TABLE turba_objects (
- object_id VARCHAR(32) NOT NULL,
- owner_id VARCHAR(255) NOT NULL,
- object_type VARCHAR(255) DEFAULT 'Object' NOT NULL,
- object_uid VARCHAR(255),
- object_members BLOB,
- object_firstname VARCHAR(255),
- object_lastname VARCHAR(255),
- object_middlenames VARCHAR(255),
- object_nameprefix VARCHAR(32),
- object_namesuffix VARCHAR(32),
- object_alias VARCHAR(32),
- object_photo BLOB,
- object_phototype VARCHAR(10),
- object_bday VARCHAR(10),
- object_homestreet VARCHAR(255),
- object_homepob VARCHAR(10),
- object_homecity VARCHAR(255),
- object_homeprovince VARCHAR(255),
- object_homepostalcode VARCHAR(10),
- object_homecountry VARCHAR(255),
- object_workstreet VARCHAR(255),
- object_workpob VARCHAR(10),
- object_workcity VARCHAR(255),
- object_workprovince VARCHAR(255),
- object_workpostalcode VARCHAR(10),
- object_workcountry VARCHAR(255),
- object_tz VARCHAR(32),
- object_geo VARCHAR(255),
- object_email VARCHAR(255),
- object_homephone VARCHAR(25),
- object_workphone VARCHAR(25),
- object_cellphone VARCHAR(25),
- object_fax VARCHAR(25),
- object_pager VARCHAR(25),
- object_title VARCHAR(255),
- object_role VARCHAR(255),
- object_logo BLOB,
- object_logotype VARCHAR(10),
- object_company VARCHAR(255),
- object_category VARCHAR(80),
- object_notes TEXT,
- object_url VARCHAR(255),
- object_freebusyurl VARCHAR(255),
- object_pgppublickey TEXT,
- object_smimepublickey TEXT,
- PRIMARY KEY(object_id)
-);
-
-CREATE INDEX turba_owner_idx ON turba_objects (owner_id);
-CREATE INDEX turba_email_idx ON turba_objects (object_email);
-CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname);
-CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname);
-
-CREATE TABLE turba_shares (
- share_id INT NOT NULL,
- share_name VARCHAR(255) NOT NULL,
- share_owner VARCHAR(255) NOT NULL,
- share_flags SMALLINT DEFAULT 0 NOT NULL,
- perm_creator SMALLINT DEFAULT 0 NOT NULL,
- perm_default SMALLINT DEFAULT 0 NOT NULL,
- perm_guest SMALLINT DEFAULT 0 NOT NULL,
- attribute_name VARCHAR(255) NOT NULL,
- attribute_desc VARCHAR(255),
- attribute_params TEXT,
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id INT NOT NULL,
- group_uid VARCHAR(255) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id INT NOT NULL,
- user_uid VARCHAR(255) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm);
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-
- <name><variable>name</variable></name>
- <create>false</create>
- <overwrite>false</overwrite>
-
- <table>
-
- <name>turba_objects</name>
-
- <declaration>
-
- <field>
- <name>object_id</name>
- <type>text</type>
- <length>32</length>
- <notnull>true</notnull>
- </field>
-
- <field>
- <name>owner_id</name>
- <type>text</type>
- <length>255</length>
- <notnull>true</notnull>
- </field>
-
- <field>
- <name>object_type</name>
- <type>text</type>
- <length>255</length>
- <notnull>true</notnull>
- <default>Object</default>
- </field>
-
- <field>
- <name>object_uid</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_members</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_firstname</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_lastname</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_middlenames</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_nameprefix</name>
- <type>text</type>
- <length>32</length>
- </field>
-
- <field>
- <name>object_namesuffix</name>
- <type>text</type>
- <length>32</length>
- </field>
-
- <field>
- <name>object_alias</name>
- <type>text</type>
- <length>32</length>
- </field>
-
- <field>
- <name>object_photo</name>
- <type>blob</type>
- </field>
-
- <field>
- <name>object_phototype</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_bday</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_homestreet</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_homepob</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_homecity</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_homeprovince</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_homepostalcode</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_homecountry</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_workstreet</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_workpob</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_workcity</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_workprovince</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_workpostalcode</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_workcountry</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_tz</name>
- <type>text</type>
- <length>32</length>
- </field>
-
- <field>
- <name>object_geo</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_email</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_homephone</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_workphone</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_cellphone</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_fax</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_pager</name>
- <type>text</type>
- <length>25</length>
- </field>
-
- <field>
- <name>object_title</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_role</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_logo</name>
- <type>blob</type>
- </field>
-
- <field>
- <name>object_logotype</name>
- <type>text</type>
- <length>10</length>
- </field>
-
- <field>
- <name>object_company</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_category</name>
- <type>text</type>
- <length>80</length>
- </field>
-
- <field>
- <name>object_notes</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_url</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_freebusyurl</name>
- <type>text</type>
- <length>255</length>
- </field>
-
- <field>
- <name>object_pgppublickey</name>
- <type>clob</type>
- </field>
-
- <field>
- <name>object_smimepublickey</name>
- <type>clob</type>
- </field>
-
- <index>
- <name>turba_primary</name>
- <primary>true</primary>
- <field>
- <name>object_id</name>
- </field>
- </index>
-
- <index>
- <name>turba_owner</name>
- <field>
- <name>owner_id</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_email</name>
- <field>
- <name>object_email</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_firstname</name>
- <field>
- <name>object_firstname</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_lastname</name>
- <field>
- <name>object_lastname</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- </declaration>
-
- </table>
-
- <table>
-
- <name>turba_shares</name>
-
- <declaration>
-
- <field>
- <name>share_id</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <length>4</length>
- </field>
-
- <field>
- <name>share_name</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>share_owner</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>share_flags</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <length>2</length>
- </field>
-
- <field>
- <name>perm_creator</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <length>2</length>
- </field>
-
- <field>
- <name>perm_default</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <length>2</length>
- </field>
-
- <field>
- <name>perm_guest</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <length>2</length>
- </field>
-
- <field>
- <name>attribute_name</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>attribute_desc</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>attribute_params</name>
- <type>clob</type>
- </field>
-
- <index>
- <name>turba_shares_name</name>
- <field>
- <name>share_name</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_shares_owner</name>
- <field>
- <name>share_owner</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_shares_creator</name>
- <field>
- <name>perm_creator</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_shares_default</name>
- <field>
- <name>perm_default</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_shares_guest</name>
- <field>
- <name>perm_guest</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_shares_pKey</name>
- <primary>true</primary>
- <field>
- <name>share_id</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- </declaration>
-
- </table>
-
- <table>
-
- <name>turba_shares_groups</name>
-
- <declaration>
-
- <field>
- <name>share_id</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <length>4</length>
- </field>
-
- <field>
- <name>group_uid</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>perm</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <length>2</length>
- </field>
-
- <index>
- <name>turba_groups_share_id</name>
- <field>
- <name>share_id</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_groups_group_uid</name>
- <field>
- <name>group_uid</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_groups_perm</name>
- <field>
- <name>perm</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- </declaration>
-
- </table>
-
- <table>
-
- <name>turba_shares_users</name>
-
- <declaration>
-
- <field>
- <name>share_id</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <length>4</length>
- </field>
-
- <field>
- <name>user_uid</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>perm</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <length>2</length>
- </field>
-
- <index>
- <name>turba_users_share_id</name>
- <field>
- <name>share_id</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_users_user_uid</name>
- <field>
- <name>user_uid</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- <index>
- <name>turba_users_perm</name>
- <field>
- <name>perm</name>
- <sorting>ascending</sorting>
- </field>
- </index>
-
- </declaration>
-
- </table>
-
-</database>
+++ /dev/null
--- You can simply execute this file in your database.
---
--- For MySQL run:
---
--- $ mysql --user=root --password=<MySQL-root-password> <db name> < 1.1_to_1.2.sql
---
--- Or, for PostgreSQL:
---
--- $ psql <db name> -f 1.1_to_1.2.sql
-
-ALTER TABLE turba_objects CHANGE object_homeAddress object_homeaddress VARCHAR(255);
-ALTER TABLE turba_objects CHANGE object_workAddress object_workaddress VARCHAR(255);
-ALTER TABLE turba_objects CHANGE object_homePhone object_homephone VARCHAR(25);
-ALTER TABLE turba_objects CHANGE object_workPhone object_workphone VARCHAR(25);
-ALTER TABLE turba_objects CHANGE object_cellPhone object_cellphone VARCHAR(25);
-ALTER TABLE turba_objects MODIFY object_title VARCHAR(255);
-ALTER TABLE turba_objects MODIFY object_company VARCHAR(255);
-ALTER TABLE turba_objects ADD object_type VARCHAR(255) DEFAULT 'Object' NOT NULL;
-ALTER TABLE turba_objects ADD object_members BLOB;
-CREATE INDEX turba_owner_idx ON turba_objects (owner_id);
-
+++ /dev/null
-ALTER TABLE turba_objects ADD object_uid VARCHAR2(255);
-ALTER TABLE turba_objects ADD object_freebusyurl VARCHAR2(255);
-ALTER TABLE turba_objects ADD object_smimepublickey CLOB;
-ALTER TABLE turba_objects ADD object_pgppublickey CLOB;
+++ /dev/null
--- You can simply execute this file in your database.
---
--- For MySQL run:
---
--- $ mysql --user=root --password=<MySQL-root-password> <db name> < 1.2_to_2.0.sql
---
--- Or, for PostgreSQL:
---
--- $ psql <db name> -f 1.2_to_2.0.sql
-
-
-ALTER TABLE turba_objects ADD COLUMN object_uid VARCHAR(255);
-ALTER TABLE turba_objects ADD COLUMN object_freebusyurl VARCHAR(255);
-ALTER TABLE turba_objects ADD COLUMN object_smimepublickey TEXT;
-ALTER TABLE turba_objects ADD COLUMN object_pgppublickey TEXT;
+++ /dev/null
-CREATE TABLE turba_shares (
- share_id INT NOT NULL,
- share_name VARCHAR(255) NOT NULL,
- share_owner VARCHAR(32) NOT NULL,
- share_flags SMALLINT DEFAULT 0 NOT NULL,
- perm_creator SMALLINT DEFAULT 0 NOT NULL,
- perm_default SMALLINT DEFAULT 0 NOT NULL,
- perm_guest SMALLINT DEFAULT 0 NOT NULL,
- attribute_name VARCHAR(255) NOT NULL,
- attribute_desc VARCHAR(255),
- attribute_params VARCHAR(MAX),
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id INT NOT NULL,
- group_uid INT NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id INT NOT NULL,
- user_uid VARCHAR(32) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm);
+++ /dev/null
-CREATE TABLE turba_shares (
- share_id NUMBER(16) NOT NULL,
- share_name VARCHAR2(255) NOT NULL,
- share_owner VARCHAR2(32) NOT NULL,
- share_flags NUMBER(8) DEFAULT 0 NOT NULL,
- perm_creator NUMBER(8) DEFAULT 0 NOT NULL,
- perm_default NUMBER(8) DEFAULT 0 NOT NULL,
- perm_guest NUMBER(8) DEFAULT 0 NOT NULL,
- attribute_name VARCHAR2(255) NOT NULL,
- attribute_desc VARCHAR2(255),
- attribute_params VARCHAR2(4000),
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id NUMBER(16) NOT NULL,
- group_uid NUMBER(16) NOT NULL,
- perm NUMBER(8) NOT NULL
-);
-
-CREATE INDEX turba_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id NUMBER(16) NOT NULL,
- user_uid VARCHAR2(32) NOT NULL,
- perm NUMBER(8) NOT NULL
-);
-
-CREATE INDEX turba_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_users_perm_idx ON turba_shares_users (perm);
+++ /dev/null
-CREATE TABLE turba_shares (
- share_id SMALLINT NOT NULL,
- share_name VARCHAR(255) NOT NULL,
- share_owner VARCHAR(32) NOT NULL,
- share_flags SMALLINT DEFAULT 0 NOT NULL,
- perm_creator SMALLINT DEFAULT 0 NOT NULL,
- perm_default SMALLINT DEFAULT 0 NOT NULL,
- perm_guest SMALLINT DEFAULT 0 NOT NULL,
- attribute_name VARCHAR(255) NOT NULL,
- attribute_desc VARCHAR(255),
- attribute_params TEXT,
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id SMALLINT NOT NULL,
- group_uid SMALLINT NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id SMALLINT NOT NULL,
- user_uid VARCHAR(32) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm);
+++ /dev/null
-CREATE TABLE turba_shares (
- share_id INT NOT NULL,
- share_name VARCHAR(255) NOT NULL,
- share_owner VARCHAR(32) NOT NULL,
- share_flags SMALLINT DEFAULT 0 NOT NULL,
- perm_creator SMALLINT DEFAULT 0 NOT NULL,
- perm_default SMALLINT DEFAULT 0 NOT NULL,
- perm_guest SMALLINT DEFAULT 0 NOT NULL,
- attribute_name VARCHAR(255) NOT NULL,
- attribute_desc VARCHAR(255),
- attribute_params TEXT,
- PRIMARY KEY (share_id)
-);
-
-CREATE INDEX turba_shares_share_name_idx ON turba_shares (share_name);
-CREATE INDEX turba_shares_share_owner_idx ON turba_shares (share_owner);
-CREATE INDEX turba_shares_perm_creator_idx ON turba_shares (perm_creator);
-CREATE INDEX turba_shares_perm_default_idx ON turba_shares (perm_default);
-CREATE INDEX turba_shares_perm_guest_idx ON turba_shares (perm_guest);
-
-CREATE TABLE turba_shares_groups (
- share_id INT NOT NULL,
- group_uid INT NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_groups_share_id_idx ON turba_shares_groups (share_id);
-CREATE INDEX turba_shares_groups_group_uid_idx ON turba_shares_groups (group_uid);
-CREATE INDEX turba_shares_groups_perm_idx ON turba_shares_groups (perm);
-
-CREATE TABLE turba_shares_users (
- share_id INT NOT NULL,
- user_uid VARCHAR(32) NOT NULL,
- perm SMALLINT NOT NULL
-);
-
-CREATE INDEX turba_shares_users_share_id_idx ON turba_shares_users (share_id);
-CREATE INDEX turba_shares_users_user_uid_idx ON turba_shares_users (user_uid);
-CREATE INDEX turba_shares_users_perm_idx ON turba_shares_users (perm);
-
+++ /dev/null
-#!/usr/bin/php
-<?php
-/**
- * Very basic migration script for moving to the Turba 2.2 default sql schema.
- *
- * Note: This is NOT complete yet, but will get your Turba 2.1 data into
- * enough shape to run with the new default sql schema in Turba 2.2.
- *
- * It is HIGHLY RECOMMENDED to back up your current Turba tables BEFORE
- * attempting this upgrade!
- *
- * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (ASL). If you
- * did not receive this file, see http://www.horde.org/licenses/asl.php.
- */
-
-/* Set this variable to 'true' to activate the script. */
-$for_real = false;
-
-/* If not null, these values overwrite those in the Horde SQL config. */
-$db_user = null;
-$db_pass = null;
-
-/* Default table name. */
-$db_table = 'turba_objects';
-
-/* Allow skipping of parsing certain fields.
- * You can force fields to not be parsed by setting the field to false
- * below. */
-$do_name = true;
-$do_home = true;
-$do_work = true;
-$do_email = true;
-
-/* YOU SHOULD NOT HAVE TO TOUCH ANYTHING BELOW THIS LINE */
-
-/* Set up the CLI environment */
-require_once dirname(__FILE__) . '/../../lib/Application.php';
-Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
-
-require_once 'Horde/Form.php';
-
-$db = $injector->getInstance('Horde_Db_Pear')->getDb();
-
-if (!$for_real) {
- $cli->message('No changes will done to the existing data. Please read the comments in the code, then set the $for_real flag to true before running.', 'cli.message');
-}
-
-/* Define how to transform the address book table */
-$queries = array(
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_firstname VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_lastname VARCHAR(255)',
- 'UPDATE ' . $db_table . ' SET object_lastname = object_name',
- 'ALTER TABLE ' . $db_table . ' DROP COLUMN object_name',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_middlenames VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_nameprefix VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_namesuffix VARCHAR(32)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_phototype VARCHAR(10)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_bday VARCHAR(10)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homestreet VARCHAR(255)',
- 'UPDATE ' . $db_table . ' SET object_homestreet = object_homeaddress',
- 'ALTER TABLE ' . $db_table . ' DROP COLUMN object_homeaddress',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homepob VARCHAR(10)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homecity VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homeprovince VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homepostalcode VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_homecountry VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workstreet VARCHAR(255)',
- 'UPDATE ' . $db_table . ' SET object_workstreet = object_workaddress',
- 'ALTER TABLE ' . $db_table . ' DROP COLUMN object_workaddress',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workpob VARCHAR(10)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workcity VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workprovince VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workpostalcode VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_workcountry VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_tz VARCHAR(32)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_geo VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_pager VARCHAR(25)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_role VARCHAR(255)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logotype VARCHAR(10)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_category VARCHAR(80)',
- 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_url VARCHAR(255)',
- 'CREATE INDEX turba_email_idx ON ' . $db_table . ' (object_email)',
- 'CREATE INDEX turba_firstname_idx ON ' . $db_table . ' (object_firstname)',
- 'CREATE INDEX turba_lastname_idx ON ' . $db_table . ' (object_lastname)',
-);
-
-switch ($config['phptype']) {
-case 'mssql':
- $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_photo VARBINARY(MAX)';
- $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logo VARBINARY(MAX)';
- break;
-
-case 'pgsql':
- $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_photo TEXT';
- $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logo TEXT';
- break;
-
-default:
- $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_photo BLOB';
- $queries[] = 'ALTER TABLE ' . $db_table . ' ADD COLUMN object_logo BLOB';
- break;
-}
-
-/* Perform the queries */
-/* @TODO - Better error handling */
-$error = false;
-foreach ($queries as $query) {
- if ($config['phptype'] == 'oci8') {
- $query = str_replace('ADD COLUMN', 'ADD', $query);
- }
- if ($for_real) {
- $results = $db->query($query);
- if ($results instanceof PEAR_Error) {
- $cli->message($results->toString(), 'cli.error');
- $error = true;
- continue;
- }
- }
- $cli->message($query, 'cli.success');
-}
-if ($error &&
- $cli->prompt('Continue?', array('y' => 'Yes', 'n' => 'No'), 'n') != 'y') {
- exit(1);
-}
-
-/* Attempt to transform the fullname into lastname and firstname */
-if ($do_name) {
- require_once HORDE_BASE . '/turba/lib/Turba.php';
- $sql = 'SELECT object_id, ' . ($for_real ? 'object_lastname' : 'object_name') . ' FROM ' . $db_table;
- $names = $db->getAssoc($sql);
- if ($names instanceof PEAR_Error) {
- $cli->message($names->toString(), 'cli.error');
- exit(1);
- }
- $insert_query = 'UPDATE ' . $db_table . ' SET object_firstname = ?, object_lastname = ? WHERE object_id = ?';
- if (!$for_real) {
- $cli->writeln($insert_query);
- }
- $insert = $db->prepare($insert_query);
- foreach ($names as $id => $name ) {
- $lastname = Turba::guessLastName($name);
- $firstname = '';
- if (strpos($name, ',') !== false) {
- $firstname = preg_replace('/' . preg_quote($lastname, '/') . ',\s*/', '', $name);
- } elseif ($name != $lastname) {
- $firstname = preg_replace('/\s+' . preg_quote($lastname, '/') . '/', '', $name);
- }
- if ($for_real) {
- $db->execute($insert, array($firstname, $lastname, $id));
- } else {
- $cli->writeln("ID=$id\nFirst name: $firstname; Last name: $lastname; Name: $name\n");
- }
- }
- $cli->message('Contact name fields parsed.', 'cli.success');
-} else {
- $cli->message('Contact name fields SKIPPED.', 'cli.success');
-}
-
-if ($do_home) {
- $sql = 'SELECT object_id, ' . ($for_real ? 'object_homestreet' : 'object_homeaddress') . ' FROM ' . $db_table;
- $addresses = $db->getAssoc($sql);
- if ($addresses instanceof PEAR_Error) {
- $cli->message($addresses->toString(), 'cli.error');
- exit(1);
- }
- $insert_query = 'UPDATE ' . $db_table . ' SET object_homestreet = ?, object_homecity = ?, object_homeprovince = ?, object_homepostalcode = ?, object_homecountry = ? WHERE object_id = ?';
- if (!$for_real) {
- $cli->writeln($insert_query);
- }
- $insert = $db->prepare($insert_query);
- parseAddress($addresses, $insert, $for_real);
- $cli->message('Home address fields parsed.', 'cli.success');
-} else {
- $cli->message('Home address fields SKIPPED.', 'cli.success');
-}
-
-if ($do_work) {
- $sql = 'SELECT object_id, ' . ($for_real ? 'object_workstreet' : 'object_workaddress') . ' FROM ' . $db_table;
- $addresses = $db->getAssoc($sql);
- if ($addresses instanceof PEAR_Error) {
- $cli->message($addresses->toString(), 'cli.error');
- exit(1);
- }
- $insert_query = 'UPDATE ' . $db_table . ' SET object_workstreet = ?, object_workcity = ?, object_workprovince = ?, object_workpostalcode = ?, object_workcountry = ? WHERE object_id = ?';
- if (!$for_real) {
- $cli->writeln($insert_query);
- }
- $insert = $db->prepare($insert_query);
- parseAddress($addresses, $insert, $for_real);
- $cli->message('Work address fields parsed.', 'cli.success');
-} else {
- $cli->message('Work address fields SKIPPED.', 'cli.success');
-}
-
-if ($do_email) {
- $sql = 'SELECT object_id, object_email FROM ' . $db_table;
- $emails = $db->getAssoc($sql);
- if ($emails instanceof PEAR_Error) {
- $cli->message($emails->toString(), 'cli.error');
- exit(1);
- }
- $insert_query = 'UPDATE ' . $db_table . ' SET object_email = ? WHERE object_id = ?';
- if (!$for_real) {
- $cli->writeln($insert_query);
- }
- if ($for_real) {
- $insert = $db->prepare($insert_query);
- foreach ($emails as $id => $email) {
- $db->execute($insert, array(getBareEmail($email), $id));
- }
- } else {
- $cli->writeln($insert_query);
- }
-}
-
-/**
- * Helper function to parse out freeform addresses
- *
- * Try to parse out the free form addresses.
- * Assumptions we make to fit into our schema:
- * - Postal code is on the same line as state/province information
- * - If there is a line following the state/province/postal code line,
- * it is taken as a country.
- * - Any lines before the postal code are treated as street address.
- *
- * @param array $addresses An array of addresses to parse.
- * @param object $insert A prepared update query to write the results.
- * @param boolean $for_real Whether to really change any data.
- */
-function parseAddress($addresses, $insert, $for_real)
-{
- global $countries;
-
- foreach ($addresses as $id => $address) {
- if (empty($address)) {
- continue;
- }
- $city = $state = $postalCode = $street = $country = '';
- $p_address = Horde_Form_Type_address::parse($address);
- if (!count($p_address)) {
- $street = $address;
- } else {
- if (!empty($p_address['street'])) {
- $street = $p_address['street'];
- }
- if (!empty($p_address['city'])) {
- $city = $p_address['city'];
- }
- if (!empty($p_address['state'])) {
- $state = $p_address['state'];
- }
- if (!empty($p_address['zip'])) {
- $postalCode = $p_address['zip'];
- }
- if (!empty($p_address['country'])) {
- $country = isset($countries[Horde_String::upper($p_address['country'])])
- ? $countries[Horde_String::upper($p_address['country'])]
- : Horde_String::upper($p_address['country']);
- }
- }
- if ($for_real) {
- $GLOBALS['db']->execute($insert, array($street, $city, $state, $postalCode, $country, $id));
- } else {
- $GLOBALS['cli']->writeln("ID: $id\nStreet: $street\nCity: $city\nState: $state\nPostal Code: $postalCode\nCountry: $country\nAddress:\n$address\n");
- }
- }
-}
-
-/**
- * Static function to make a given email address rfc822 compliant.
- *
- * @param string $address An email address.
- *
- * @return string The RFC822-formatted email address.
- */
-function getBareEmail($address)
-{
- // Empty values are still empty.
- if (!$address) {
- return $address;
- }
-
- $rfc822 = new Horde_Mail_Rfc822();
- $rfc822->validateMailbox($address);
- return Horde_Mime_Address::writeAddress($address->mailbox, $address->host);
-}
+++ /dev/null
-ALTER TABLE turba_shares MODIFY share_owner VARCHAR2(255);
-ALTER TABLE turba_shares_users MODIFY user_uid VARCHAR2(255);
-ALTER TABLE turba_shares_groups MODIFY group_uid VARCHAR2(255);
+++ /dev/null
-ALTER TABLE turba_shares ALTER share_owner TYPE VARCHAR(255);
-ALTER TABLE turba_shares_users ALTER user_uid TYPE VARCHAR(255);
-ALTER TABLE turba_shares_groups ALTER group_uid TYPE VARCHAR(255);
+++ /dev/null
-ALTER TABLE turba_shares CHANGE share_owner share_owner VARCHAR(255);
-ALTER TABLE turba_shares_users CHANGE user_uid user_uid VARCHAR(255);
-ALTER TABLE turba_shares_groups CHANGE group_uid group_uid VARCHAR(255);
+++ /dev/null
-ALTER TABLE turba_shares_users ALTER share_id TYPE integer;
-ALTER TABLE turba_shares_groups ALTER share_id TYPE integer;
-ALTER TABLE turba_shares ALTER share_id TYPE integer;
-
+++ /dev/null
-#!/usr/bin/php
-<?php
-/**
- * Copyright 2005-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (ASL). If you
- * did not receive this file, see http://www.horde.org/licenses/asl.php.
- *
- * @author Jan Schneider <jan@horde.org>
- */
-
-// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/Application.php';
-Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
-
-// Instantiate DataTree.
-require_once 'Horde/DataTree.php';
-$driver = $conf['datatree']['driver'];
-$params = array_merge(Horde::getDriverConfig('datatree', $driver),
- array('group' => 'agora.forums.turba'));
-$datatree = DataTree::singleton($driver, $params);
-
-// Load comments.
-$forums = $datatree->get(DATATREE_FORMAT_TREE, DATATREE_ROOT);
-if (!is_array($forums[DATATREE_ROOT])) {
- exit("No comments.\n");
-}
-
-// Loop through comments.
-$converted = 0;
-foreach ($forums[DATATREE_ROOT] as $source => $comments) {
- if (!is_array($comments)) {
- exit("Comments have already been flattened.\n");
- }
- $source_name = $datatree->getName($source);
- foreach (array_keys($comments) as $comment) {
- $name = $datatree->getName($comment);
- $datatree->rename($name, $source_name . '.' . $datatree->getShortName($name));
- $converted++;
- }
-}
-$forums = $datatree->get(DATATREE_FORMAT_TREE, DATATREE_ROOT, true);
-foreach ($forums[DATATREE_ROOT] as $source => $comments) {
- $source_name = $datatree->getName($source);
- foreach (array_keys($comments) as $comment) {
- $datatree->move($datatree->getName($comment));
- }
- $datatree->remove($source_name);
-}
-
-echo $converted . " comments flattened.\n";
+++ /dev/null
-#!/usr/bin/env php
-<?php
-/**
- * This script deletes old virtual address books that will otherwise
- * confuse the new Turba code.
- */
-
-// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/Application.php';
-Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
-
-// See if any of our sources are configured to use Horde_Share.
-if (empty($_SESSION['turba']['has_share'])) {
- echo "No shares to convert. Done.\n";
- exit(0);
-}
-
-$datatree = $turba_shares->_storage;
-$db = $datatree->_db;
-
-// Get the root vbook element.
-$sql = "SELECT datatree_id FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND datatree_name = 'vbook'";
-$vbook_parent = $db->getOne($sql);
-if ($vbook_parent instanceof PEAR_Error) {
- var_dump($vbook_parent);
- exit(1);
-}
-$vbook_parent = (int)$vbook_parent;
-
-// Get child vbooks.
-$sql = "SELECT datatree_id FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND (datatree_parents = ':$vbook_parent' OR datatree_parents LIKE ':$vbook_parent:%')";
-$vbook_children = $db->getCol($sql);
-if ($vbook_children instanceof PEAR_Error) {
- var_dump($vbook_children);
- exit(1);
-}
-
-// Build list of ids to delete.
-$datatree_ids = array($vbook_parent);
-foreach ($vbook_children as $child) {
- $datatree_ids[] = (int)$child;
-}
-$datatree_ids = implode(',', $datatree_ids);
-
-// Delete.
-$db->query("DELETE FROM horde_datatree_attributes WHERE group_uid = 'horde.shares.turba' AND datatree_id IN ($datatree_ids)");
-$db->query("DELETE FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND datatree_id IN ($datatree_ids)");
-
-// Done.
-echo "Successfully deleted old virtual address books.\n";
-exit(0);
+++ /dev/null
-#!/usr/bin/env php
-<?php
-/**
- * This script flattens shared address books out to meet the
- * requirements of the future Share API.
- */
-
-// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/Application.php';
-Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true));
-
-// Re-load source config.
-require TURBA_BASE . '/config/backends.php';
-
-// See if any of our sources are configured to use Horde_Share.
-if (empty($_SESSION['turba']['has_share'])) {
- echo "No shares to convert. Done.\n";
- exit(0);
-}
-
-// Check for multiple share-enabled backends and use the first one
-// as a 'primary' source - this is in case multiple backends would
-// have children with the same datatree_name (like when using two
-// SQL sources with shares for example
-foreach ($cfgSources as $type => $config) {
- if (!empty($config['use_shares'])) {
- $sourceTypes[] = $type;
- }
-}
-$primary_source = $sourceTypes[0];
-$datatree = $turba_shares->_datatree;
-$db = $datatree->_db;
-
-// Get list of shares.
-$sql = "SELECT datatree_id, datatree_name, datatree_parents FROM horde_datatree WHERE group_uid = 'horde.shares.turba'";
-$datatree_elts = $db->getAssoc($sql);
-
-$changed_dns = array();
-
-// Look at each share, looking for orphans, old parent shares, etc.
-foreach ($datatree_elts as $id => $datatree_elt) {
- $id = (int)$id;
- $attributes = $db->getAll("SELECT * FROM horde_datatree_attributes WHERE datatree_id = $id");
-
- // If there are no attributes, this will be an orphan. Delete it.
- if (!count($attributes)) {
- $db->query("DELETE FROM horde_datatree_attributes WHERE datatree_id = $id");
- $db->query("DELETE FROM horde_datatree WHERE group_uid = 'horde.shares.turba' AND datatree_id = $id");
- continue;
- }
-
- $datatree_name = $datatree_elt[0];
- $datatree_parents = $datatree_elt[1];
-
- // If there are no parents, this share is already flattened; ignore it.
- if (empty($datatree_parents)) {
- continue;
- }
-
- // Insert a new entry with the required params setting.
- $source = $datatree_elts[substr($datatree_parents, 1)][0];
-
- // I *really* don't like doing it this way, but I can't think of any other
- // way to get the correct values for the 'name' param (at least without creating
- // 'upgrade drivers' ;)
- // In what way will this will affect kolab sources??
- switch ($cfgSources[$source]['type']) {
- case 'imsp':
- foreach ($attributes as $attribute) {
- if ($attribute[1] == 'name') {
- $name = $attribute[3];
- }
-
- if ($attribute[1] == 'owner') {
- $owner = $attribute[3];
- }
- }
- $nameparam = $owner . '.' . $name;
- break;
-
- case 'sql':
- foreach ($attributes as $attribute) {
- if ($attribute[1] == 'uid') {
- $nameparam = $attribute[3];
- break;
- }
- }
- break;
- }
-
- $db->query('INSERT INTO horde_datatree_attributes (datatree_id, attribute_name, attribute_key, attribute_value) VALUES (?, ?, ?, ?)',
- array($id, 'params', '', serialize(array('source' => $source, 'name' => $nameparam))));
-
- // Need to check for attribute_name of description and change it desc
- $db->query('ALTER horde_datatree_attributes SET attribute_name = ? WHERE datatree_id = ? AND attribute_name = ?',
- array('desc', $id, 'description'));
-
- // See if we need to differentiate the datatree_name
- // FIXME: Changing the datatree_name will break any contact lists
- // with contacts from this source. We can update the SQL based lists here,
- // but other sources will still break, and if we change the datatree_name
- // here we will have no way to ever map contact list entries that broke
- // to the correct list, since the original value is lost...maybe persist
- // the original value somewhere in the share params then remove it after
- // some sort of upgrade maint. is run after user's next login.
- if ($source != $primary_source) {
- $db->query('UPDATE horde_datatree SET datatree_name = ? WHERE datatree_id = ?', array($source . $datatree_name, $id));
- }
-
- // Delete old sourceType and uid settings.
- $statement = $db->prepare('DELETE FROM horde_datatree_attributes WHERE datatree_id = ? AND attribute_name = ?');
- $db->execute($statement, array($id, 'uid'));
- $db->execute($statement, array($id, 'sourceType'));
-
- // Get rid of the datatree_parents string.
- $db->query('UPDATE horde_datatree SET datatree_parents = ? WHERE group_uid = ? AND datatree_id = ?',
- array('', 'horde.shares.turba', $id));
-
-}
-
-// Done with actual shares
-echo "Successfully flattened shared address books.\n";
-
-exit(0);
+++ /dev/null
--- Simple upgrade script to remove the NOT NULL constraint on the
--- default schema's object_lastname field.
-
-ALTER TABLE turba_objects MODIFY object_lastname VARCHAR(255);
-
--- For posgresql:
--- ALTER TABLE turba_objects ALTER object_lastname DROP NOT NULL;
+++ /dev/null
-ALTER TABLE turba_objects ADD object_middlenames VARCHAR(255);
-ALTER TABLE turba_objects ADD object_namesuffix VARCHAR(32);
-ALTER TABLE turba_objects ADD object_homepob VARCHAR(10);
-ALTER TABLE turba_objects ADD object_workpob VARCHAR(10);
-ALTER TABLE turba_objects ADD object_tz VARCHAR(32);
-ALTER TABLE turba_objects ADD object_geo VARCHAR(255);
-ALTER TABLE turba_objects ADD object_logo BLOB;
-ALTER TABLE turba_objects ADD object_logotype VARCHAR(10);
-
-ALTER TABLE turba_objects CHANGE object_blobtype object_phototype VARCHAR(10);
-
-CREATE INDEX turba_email_idx ON turba_objects (object_email);
-CREATE INDEX turba_firstname_idx ON turba_objects (object_firstname);
-CREATE INDEX turba_lastname_idx ON turba_objects (object_lastname);
+++ /dev/null
-ALTER TABLE turba_shares CHANGE share_owner share_owner VARCHAR(255);
-ALTER TABLE turba_shares_users CHANGE user_uid user_uid VARCHAR(255);
+++ /dev/null
-ALTER TABLE turba_shares_groups CHANGE group_uid group_uid VARCHAR(255);