--- /dev/null
+<?php
+/**
+ * Table Definition for Images
+ */
+require_once 'DB/DataObject.php';
+
+class Pman_Core_DataObjects_Images extends DB_DataObject
+{
+ ###START_AUTOCODE
+ /* the code below is auto generated do not remove the above tag */
+
+ public $__table = 'Images'; // table name
+ public $id; // int(11) not_null primary_key auto_increment
+ public $filename; // string(255) not_null
+ public $ontable; // string(32) not_null multiple_key
+ public $onid; // int(11) not_null
+ public $mimetype; // string(64) not_null
+ public $width; // int(11) not_null
+ public $height; // int(11) not_null
+ public $filesize; // int(11) not_null
+ public $displayorder; // int(11) not_null
+ public $language; // string(6) not_null
+ public $parent_image_id; // int(11) not_null
+ public $created; // datetime(19) not_null binary
+ public $imgtype; // string(32) not_null
+ public $linkurl; // string(254) not_null
+ public $descript; // blob(65535) not_null blob
+ public $title; // string(128) not_null
+
+
+ /* the code above is auto generated do not remove the tag below */
+ ###END_AUTOCODE
+ /**
+ * create an email from file.
+ * these must have been set first.
+ * ontable / onid.
+ *
+ */
+ function createFrom($file)
+ {
+ // copy the file into the storage area..
+ if (!file_exists($file) || !filesize($file)) {
+ return false;
+ }
+
+
+ $imgs = @getimagesize($file);
+
+ if (empty($imgs) || empty($imgs[0]) || empty($imgs[1])) {
+ // it's a file!!!!
+ } else {
+ list($this->width , $this->height) = $imgs;
+ }
+
+ $this->filesize = filesize($file);
+ $this->created = date('Y-m-d H:i:s');
+
+ if (empty($this->mimetype)) {
+ require_once 'File/MimeType.php';
+ $y = new File_MimeType();
+ $this->mimetype = $y->fromFilename($file);
+ }
+
+
+ if (empty($this->filename)) {
+ $this->filename = basename($file);
+ }
+
+ //DB_DataObject::debugLevel(1);
+ if (!$this->id) {
+ $this->insert();
+ } else {
+ $this->update();
+ }
+
+
+
+ $f = $this->getStoreName();
+ $dest = dirname($f);
+ if (!file_exists($dest)) {
+
+ $oldumask = umask(0);
+ mkdir($dest, 0770, true);
+ umask($oldumask);
+ }
+
+ copy($file,$f);
+
+ // fill in details..
+
+ /* thumbnails */
+
+
+ // $this->createThumbnail(0,50);
+ return true;
+
+ }
+
+ /**
+ * Calculate target file name
+ *
+ * @return - target file name
+ */
+ function getStoreName()
+ {
+ $opts = PEAR::getStaticProperty('Pman', 'options');
+ $fn = preg_replace('/[^a-z0-9\.]+/i', '_', $this->filename);
+ return implode( '/', array(
+ $opts['storedir'], '_images_', date('Y/m', strtotime($this->created)), $this->id . '-'. $fn
+ ));
+
+ }
+
+
+ /**
+ * deletes all the image instances of it...
+ *
+ *
+ */
+ function beforeDelete()
+ {
+ $fn = $this->getStoreName();
+ if (file_exists($fn)) {
+ unlink($fn);
+ }
+ // delete thumbs..
+ $b = basename($fn);
+ $d = dirname($fn);
+ if (file_exists($d)) {
+
+ $dh = opendir($d);
+ while (false !== ($fn = readdir($dh))) {
+ if (substr($fn, 0, strlen($b)) == $b) {
+ unlink($d. '/'. $fn);
+ }
+ }
+ }
+
+ }
+
+
+ /**
+ * onUpload (singlely attached image to a table)
+ */
+
+ function onUploadWithTbl($tbl, $fld)
+ {
+ if ( $tbl->__table == 'Images') {
+ return; // not upload to self...
+ }
+ if (empty($_FILES['imageUpload']['tmp_name']) ||
+ empty($_FILES['imageUpload']['name']) ||
+ empty($_FILES['imageUpload']['type'])
+ ) {
+ return false;
+ }
+ if ($tbl->$fld) {
+ $image = DB_DataObject::factory('Images');
+ $image->get($tbl->$fld);
+ $image->beforeDelete();
+ $image->delete();
+ }
+
+ $image = DB_DataObject::factory('Images');
+ $image->onid = $tbl->id;
+ $image->ontable = $tbl->__table;
+ $image->filename = $_FILES['imageUpload']['name'];
+ $image->mimetype = $_FILES['imageUpload']['type'];
+
+ if (!$image->createFrom($_FILES['imageUpload']['tmp_name'])) {
+ return false;
+ }
+ $old = clone($tbl);
+ $tbl->$fld = $image->id;
+ $tbl->update($old);
+
+ }
+
+ // direct via roo...
+ function onUpload($ctrl)
+ {
+
+ if (empty($_FILES['imageUpload']['tmp_name']) ||
+ empty($_FILES['imageUpload']['name']) ||
+ empty($_FILES['imageUpload']['type'])
+ ) {
+ $this->err = "Missing file details";
+ return false;
+ }
+
+ if ($this->id) {
+ $this->beforeDelete();
+ }
+ if ( empty($this->ontable)) {
+ $this->err = "Missing ontable";
+ return false;
+ }
+
+ if (!empty($this->imgtype) && $this->imgtype[0] == '-' && !empty($this->onid)) {
+ // then its an upload
+ $img = DB_DataObject::factory('Images');
+ $img->onid = $this->onid;
+ $img->ontable = $this->ontable;
+ $img->imgtype = $this->imgtype;
+
+ $img->find();
+ while ($img->fetch()) {
+ $img->beforeDelete();
+ $img->delete();
+ }
+
+ }
+
+
+
+ require_once 'File/MimeType.php';
+ $y = new File_MimeType();
+ $this->mimetype = $_FILES['imageUpload']['type'];
+ if (in_array($this->mimetype, array('text/application', 'application/octet-stream'))) { // weird tyeps..
+ $inf = pathinfo($_FILES['imageUpload']['name']);
+ $this->mimetype = $y->fromExt($inf['extension']);
+ }
+
+
+ $ext = $y->toExt(trim((string) $this->mimetype ));
+
+ $this->filename = empty($this->filename) ?
+ $_FILES['imageUpload']['name'] : ($this->filename .'.'. $ext);
+
+
+
+ if (!$this->createFrom($_FILES['imageUpload']['tmp_name'])) {
+ return false;
+ }
+ return true;
+
+ }
+
+ /**
+ * return a list of images for an object, optionally with a mime regex.
+ * eg. '%/pdf' or 'image/%'
+ */
+ function gather($obj, $mime_like='')
+ {
+ //DB_DataObject::debugLevel(1);
+ if (empty($obj->id)) {
+ return array();
+ }
+ $c = clone($this);
+ $c->ontable = $obj->tableName();
+ $c->onid = $obj->id;
+ if (!empty($mime_like)) {
+ $c->whereAdd("mimetype LIKE '". $c->escape($mime_like) ."'");
+ }
+
+ return $c->fetchAll();
+ }
+
+
+ function toRooArray($req = array()) {
+ // echo '<PRE>';print_r($req);exit;
+ $ret= $this->toArray();
+
+
+ if (!empty($req['query']['imagesize'])) {
+ $baseURL = isset($req['query']['imageBaseURL']) ? $req['query']['imageBaseURL'] : false;
+
+ $ret['url'] = $this->URL(-1, '/Images/Download',$baseURL);
+
+ $ret['url_view'] = $this->URL(-1, '/Images',$baseURL);
+
+ if (!empty($req['query']['imagesize'])) {
+ $ret['url_thumb'] = $this->URL($req['query']['imagesize'], '/Images/Thumb',$baseURL);
+ }
+ }
+
+
+
+ return $ret;
+ }
+
+ /**
+ * URL - create a url for the image.
+ * size - use -1 to show full size.
+ * provier = baseURL + /Images/Thumb ... use '/Images/' for full
+ *
+ *
+ */
+ function URL($size , $provider = '/Images/Thumb', $baseURL=false)
+ {
+ if (!$this->id) {
+ return 'about:blank';
+
+ }
+
+ $ff = HTML_FlexyFramework::get();
+ $baseURL = $baseURL ? $baseURL : $ff->baseURL ;
+ if ($size < 0) {
+ return $baseURL . $provider . "/{$this->id}/{$this->filename}";
+ }
+ //-- max?
+ //$size = max(100, (int) $size);
+ //$size = min(1024, (int) $size);
+
+
+ return $baseURL . $provider . "/$size/{$this->id}/{$this->filename}";
+ }
+ /**
+ * size could be 123x345
+ *
+ *
+ */
+ function toHTML($size, $provider = '/Images/Thumb')
+ {
+
+
+
+ $sz = explode('x', $size);
+ $sx = $sz[0];
+ //var_dump($sz);
+ if (!$this->id) {
+ $this->height = $sx;
+ $this->width = empty($sz[1]) ? $sx : $sz[1];
+ $sy = $this->width ;
+ }
+ if (empty($sz[1])) {
+ $ratio = $this->height/ ($this->width *1.0);
+ $sy = $ration * $sx;
+ } else {
+ $sy = $sz[1];
+ }
+ // create it?
+
+
+ return '<img src="' . $this->URL($size, $provider) . '" width="'. $sx . '" height="'. $sy . '">';
+
+
+ }
+
+
+
+
+ function setFromRoo($ar, $roo)
+ {
+ // not sure why we do this..
+
+ // if imgtype starts with '-' ? then we set the 'old' (probably to delete later)
+ if (!empty($ar['imgtype']) && !empty($ar['ontable']) && !empty($ar['onid']) && ($ar['imgtype'][0] == '-')) {
+ $this->setFrom($ar);
+ $this->limit(1);
+ if ($this->find(true)) {
+ $roo->old = clone($this);
+ }
+ }
+
+
+ if (!empty($ar['_copy_from'])) {
+ $copy = DB_DataObject::factory('Images');
+ $copy->get($ar['_copy_from']);
+ $this->setFrom($copy->toArray());
+ $this->setFrom($ar);
+ $this->createFrom($copy->getStoreName());
+
+ $roo->addEvent("ADD", $this, $this->toEventString());
+
+ $r = DB_DataObject::factory($this->tableName());
+ $r->id = $this->id;
+ $roo->loadMap($r);
+ $r->limit(1);
+ $r->find(true);
+ $roo->jok($r->toArray());
+
+
+ }
+
+
+
+ // FIXME - we should be checking perms here...
+ //if (method_exists($x, 'checkPerm') && !$x->checkPerm('E', $this->authUser)) {
+ // $this->jerr("PERMISSION DENIED");
+ // }
+ // this should be doign update
+ $this->setFrom($ar);
+
+ if (!isset($_FILES['imageUpload'])) {
+ return; // standard update...
+ }
+
+ if ( !$this->onUpload($this)) {
+ $this->jerr("File upload failed");
+ }
+ $roo->addEvent("ADD", $this, $this->toEventString());
+
+ $r = DB_DataObject::factory($this->tableName());
+ $r->id = $this->id;
+ $roo->loadMap($r);
+ $r->limit(1);
+ $r->find(true);
+ $roo->jok($r->toArray());
+
+ }
+ function toEventString()
+ {
+
+ //$p = DB_DataObject::factory($this->ontable);
+ //if (!is_$p) {
+ // return "ERROR unknown table? {$this->ontable}";
+ // }
+ //$p->get($p->onid);
+
+ return $this->filename .' - on ' . $this->ontable . ':' . $this->onid;
+ //$p->toEventString();
+ }
+ }
--- /dev/null
+
+CREATE TABLE `Companies` (
+ `code` varchar(32) NOT NULL,
+ `name` varchar(128) default NULL,
+ `remarks` text ,
+ `owner_id` int(11) NOT NULL,
+ `address` text ,
+ `tel` varchar(32) default NULL,
+ `fax` varchar(32) default NULL,
+ `email` varchar(128) default NULL,
+ `id` int(11) NOT NULL auto_increment,
+ `isOwner` int(11) default NULL,
+ PRIMARY KEY (`id`)
+
+) ;
+ALTER TABLE `Company_Name` ADD INDEX name_lookup (`name`);
+
+
+alter table Companies change column isOwner isOwner int(11);
+ALTER TABLE Companies ADD COLUMN logo_id INT(11) NOT NULL;
+ALTER TABLE Companies ADD COLUMN background_color varchar(8) NOT NULL;
+ALTER TABLE Companies ADD COLUMN comptype varchar(8) NOT NULL;
+
+
+ALTER TABLE `Companies` ADD COLUMN `url` varchar(254) NOT NULL;
+ALTER TABLE `Companies` ADD COLUMN `main_office_id` int(11) NOT NULL;
+
+
+ALTER TABLE `Companies` ADD COLUMN `created_by` int(11) NOT NULL;
+ALTER TABLE `Companies` ADD COLUMN `created_dt` datetime NOT NULL;
+ALTER TABLE `Companies` ADD COLUMN `updated_by` int(11) NOT NULL;
+ALTER TABLE `Companies` ADD COLUMN `updated_dt` datetime NOT NULL;
+
+ALTER TABLE `Companies` ADD COLUMN `passwd` varchar(64) NOT NULL;
+
+
+ALTER TABLE Companies
+ ADD COLUMN dispatch_port varchar(255) NOT NULL DEFAULT '',
+ ADD COLUMN province varchar(255) NOT NULL DEFAULT '',
+ ADD COLUMN country varchar(4) NOT NULL DEFAULT '';
+
+
+UPDATE Companies set comptype='OWNER' where isOwner=1;
+
+
+CREATE TABLE `core_company_type` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(64) NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+
+CREATE TABLE `Events` (
+ `id` int(11) NOT NULL auto_increment,
+ `person_name` varchar(128) default NULL,
+ `event_when` datetime default NULL,
+ `action` varchar(32) default NULL,
+ `ipaddr` varchar(16) default NULL,
+ `on_id` int(11) default NULL,
+ `on_table` varchar(64) default NULL,
+ `person_id` int(11) default NULL,
+ `remarks` text ,
+ PRIMARY KEY (`id`)
+) ;
+
+
+ALTER TABLE Events CHANGE COLUMN EventID id INT(11) AUTO_INCREMENT NOT NULL;
+ALTER TABLE Events CHANGE COLUMN User person_name VARCHAR(128);
+ALTER TABLE Events ADD COLUMN person_id INT(11);
+ALTER TABLE Events CHANGE COLUMN Date event_when DATETIME;
+ALTER TABLE Events CHANGE COLUMN Event action VARCHAR(32);
+ALTER TABLE Events CHANGE COLUMN Host ipaddr VARCHAR(16);
+ALTER TABLE Events CHANGE COLUMN ItemID on_id INT(11);
+ALTER TABLE Events CHANGE COLUMN Container on_table VARCHAR(64);
+ALTER TABLE Events ADD COLUMN remarks INT(11);
+
+
+
+CREATE TABLE `Group_Members` (
+ `group_id` int(11) default NULL,
+ `id` int(11) NOT NULL auto_increment,
+ `user_id` int(11) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+);
+
+
+CREATE TABLE `Group_Rights` (
+ `rightname` varchar(64) NOT NULL,
+ `group_id` int(11) NOT NULL,
+ `AccessMask` varchar(10) NOT NULL,
+ `id` int(11) NOT NULL auto_increment,
+ PRIMARY KEY (`id`)
+) ;
+
+
+
+
+CREATE TABLE `Groups` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(64) NOT NULL,
+ `type` int(11) default NULL,
+ `leader` int(11) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+);
+
+
+
+alter table Groups add column type int(11) default 0;
+ALTER TABLE `Groups` ADD COLUMN `leader` int(11) NOT NULL default 0;
+ALTER TABLE Groups CHANGE COLUMN type type int(11) default 0;
+
+
+
+
+CREATE TABLE `Office` (
+ `id` int(11) NOT NULL auto_increment,
+ `company_id` int(11) NOT NULL default '0',
+ `name` varchar(64) NOT NULL,
+ `address` text NOT NULL,
+ `phone` varchar(32) NOT NULL,
+ `fax` varchar(32) NOT NULL,
+ `email` varchar(128) NOT NULL,
+ `role` varchar(32) NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `Person` (
+ `id` int(11) NOT NULL auto_increment,
+ `office_id` int(11) default '0',
+ `name` varchar(128) NOT NULL,
+ `phone` varchar(32) NOT NULL,
+ `fax` varchar(32) NOT NULL,
+ `email` varchar(128) NOT NULL,
+ `company_id` int(11) default '0',
+ `role` varchar(32) NOT NULL,
+ `active` int(11) default NULL,
+ `remarks` text NOT NULL,
+ `passwd` varchar(64) NOT NULL,
+ `owner_id` int(11) NOT NULL,
+ `lang` varchar(8) default 'en',
+ `no_reset_sent` int(11) default '0',
+ PRIMARY KEY (`id`)
+) ;
+
+
+
+ALTER TABLE Person ADD COLUMN no_reset_sent INT(11) DEFAULT 0;
+ALTER TABLE Person ADD COLUMN action_type VARCHAR(32) DEFAULT '';
+ ALTER TABLE Person ADD COLUMN project_id int(11) default 0;
+
+ALTER TABLE Person ADD COLUMN action_type VARCHAR(32) default '';
+
+ALTER TABLE Person ADD COLUMN deleted_by INT(11) NOT NULL default 0 ;
+ALTER TABLE Person ADD COLUMN deleted_dt DATETIME;
+
+ alter table Person change column active active int(11) NOT NULL DEFAULT 1 ;
+
+
+CREATE TABLE `Projects` (
+ `id` int(11) NOT NULL auto_increment,
+ `name` varchar(254) NOT NULL,
+ `remarks` text NOT NULL,
+ `owner_id` int(11) default NULL,
+ `code` varchar(32) NOT NULL,
+ `active` int(11) default '1',
+ `type` varchar(1) NOT NULL default 'P',
+ `client_id` int(11) NOT NULL default '0',
+ `team_id` int(11) NOT NULL default '0',
+ `file_location` varchar(254) NOT NULL default '',
+ `open_date` date default NULL,
+ `open_by` int(11) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+
+) ;
+ALTER TABLE `Projects` ADD INDEX `plookup` (`code`);
+
+alter table Projects add column active int(11) default 1;
+alter table Projects add index plookup(code);
+
+ALTER TABLE Projects ADD COLUMN `type` varchar(1) NOT NULL DEFAULT 'P';
+ ALTER TABLE Projects ADD COLUMN `client_id` int(11) NOT NULL DEFAULT 0 ;
+ ALTER TABLE Projects ADD COLUMN `team_id` int(11) NOT NULL DEFAULT 0;
+ ALTER TABLE Projects ADD COLUMN `file_location` varchar(254) NOT NULL DEFAULT '';
+ ALTER TABLE Projects ADD COLUMN `open_date` date ;
+ ALTER TABLE Projects ADD COLUMN `close_date` date ;
+ ALTER TABLE Projects ADD COLUMN `open_by` int(11) NOT NULL DEFAULT 0;
+
+ALTER TABLE `Projects` ADD COLUMN `countries` varchar(128) NOT NULL;
+ALTER TABLE `Projects` ADD COLUMN `languages` varchar(128) NOT NULL;
+
+ALTER TABLE Projects ADD COLUMN agency_id int(11) NOT NULL DEFAULT 0 ;
+
+
+#-- we duplicate office_id and company_id here...
+#-- not sure if we should keep doing that in the new design...
+#-- we should improve our links code to handle this..
+CREATE TABLE `ProjectDirectory` (
+ `id` int(11) NOT NULL auto_increment,
+ `project_id` int(11) NOT NULL,
+ `person_id` int(11) NOT NULL,
+ `ispm` int(11) NOT NULL,
+ `role` varchar(16) NOT NULL,
+ PRIMARY KEY (`id`)
+) ;
+
+
+CREATE TABLE `Images` (
+ `id` int(11) NOT NULL auto_increment,
+ `filename` varchar(255) NOT NULL default '',
+ `ontable` varchar(32) NOT NULL default '',
+ `onid` int(11) NOT NULL default '0',
+ `mimetype` varchar(64) NOT NULL default '',
+ `width` int(11) NOT NULL default '0',
+ `height` int(11) NOT NULL default '0',
+ `filesize` int(11) NOT NULL default '0',
+ `displayorder` int(11) NOT NULL default '0',
+ `language` varchar(6) NOT NULL default 'en',
+ `parent_image_id` int(11) NOT NULL default '0',
+ PRIMARY KEY (`id`)
+);
+
+
+
+ALTER TABLE images ADD COLUMN `width` int(11) NOT NULL default '0';
+ALTER TABLE images ADD COLUMN `height` int(11) NOT NULL default '0';
+ALTER TABLE images ADD COLUMN `filesize` int(11) NOT NULL default '0';
+ALTER TABLE images ADD COLUMN `displayorder` int(11) NOT NULL default '0';
+ALTER TABLE images ADD COLUMN `language` varchar(6) NOT NULL default 'en';
+ALTER TABLE images ADD COLUMN `parent_image_id` int(11) NOT NULL default '0';
+
+
+
+ALTER TABLE `Images` ADD INDEX `lookup`(`ontable`, `onid`);
+
+ALTER TABLE `Images` ADD COLUMN `created` datetime NOT NULL;
+ALTER TABLE `Images` ADD COLUMN `imgtype` VARCHAR(32) DEFAULT '' NOT NULL;
+ALTER TABLE `Images` ADD COLUMN `linkurl` VARCHAR(254) DEFAULT '' NOT NULL;
+ALTER TABLE `Images` ADD COLUMN `descript` TEXT DEFAULT '' NOT NULL;
+ALTER TABLE `Images` ADD COLUMN `title` VARCHAR(128) DEFAULT '' NOT NULL;
+
+CREATE TABLE `core_image_type` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `name` varchar(64) NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+CREATE TABLE `i18n` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `ltype` varchar(1) NOT NULL,
+ `lkey` varchar(8) NOT NULL,
+ `inlang` varchar(8) NOT NULL,
+ `lval` varchar(64) NOT NULL,
+ PRIMARY KEY (`id`)
+
+);
+ALTER TABLE i18n ADD INDEX `lookup` (`ltype`, `lkey`, `inlang`);
+
+
+
+
+CREATE TABLE core_locking (
+ `int` int(11) NOT NULL AUTO_INCREMENT,
+ `on_table` varchar(64) NOT NULL,
+ `on_id` int(11) NOT NULL,
+ `person_id` int(11) NOT NULL,
+ `created` datetime NOT NULL,
+ PRIMARY KEY (`int`)
+);
+alter table core_locking ADD INDEX `lookup`(`on_table`, `on_id`, `person_id`, `created`);
+
+
+# -- a generic enumeraction
+
+CREATE TABLE `core_enum` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `etype` varchar(32) NOT NULL,
+ `name` varchar(255) NOT NULL,
+ `active` int(2) NOT NULL DEFAULT 1,
+ `seqid` int(11) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`),
+ INDEX `lookup`(`seqid`, `active`, `name`, `etype`)
+)
+ENGINE = MyISAM;
+
+
+
+
+CREATE TABLE `translations` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `module` varchar(64) NOT NULL,
+ tfile varchar(128) NOT NULL,
+ tlang varchar(8) NOT NULL,
+ tkey varchar(32) NOT NULL,
+ tval longtext NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+ALTER TABLE translations ADD INDEX qlookup (module, tfile, tlang, tkey);
+
+
+# - used to trigger emails about changes to items being watched.
+
+CREATE TABLE `core_watch` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `ontable` varchar(128) NOT NULL,
+ `onid` int(11) NOT NULL,
+ `person_id` int(11) NOT NULL,
+ `event` varchar(128) NOT NULL,
+ `medium` varchar(128) NOT NULL,
+ `active` int(11) NOT NULL DEFAULT '1',
+ PRIMARY KEY (id)
+) ;
+ALTER TABLE core_watch ADD INDEX qlookup (`ontable`,`onid`,`user_id`,`event`,`medium`);
+
+CREATE TABLE core_notify (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `act_when` DATETIME NOT NULL,
+ `onid` int(11) NOT NULL DEFAULT 0,
+ `ontable` varchar(128) NOT NULL DEFAULT '',
+ `person_id` int(11) NOT NULL DEFAULT 0,
+ `msgid` varchar(128) NOT NULL DEFAULT '',
+ `sent` DATETIME NOT NULL,
+ `bounced` int(4) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`),
+ INDEX `lookup`(`act_when`, `msgid`)
+);
+ALTER TABLE core_notify CHANGE COLUMN bounced event_id INT(11) DEFAULT 0;
+
+
+ALTER TABLE core_notify CHANGE COLUMN bounced event_id INT(11) NOT NULL DEFAULT 0;
+
+
+# - used by email / tracker to handle alises - we have to be carefull adding to this table...
+
+CREATE TABLE `core_person_alias` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `person_id` varchar(128) DEFAULT NULL,
+ `alias` varchar(254) NOT NULL,
+ PRIMARY KEY (`id`)
+) ;
+ALTER TABLE core_watch ADD INDEX qlookup (`alias`);