mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 00:17:03 +03:00
Update contacts schema
This commit is contained in:
parent
98cc5c0fe6
commit
b92f26e88b
3 changed files with 52 additions and 46 deletions
|
|
@ -14,16 +14,6 @@ class Contact
|
||||||
*/
|
*/
|
||||||
public $IdUser;
|
public $IdUser;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $DisplayName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $DisplayEmail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,6 +29,11 @@ class Contact
|
||||||
*/
|
*/
|
||||||
public $IsShare;
|
public $IsShare;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $CanBeChanged;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
@ -68,17 +63,16 @@ class Contact
|
||||||
{
|
{
|
||||||
$this->IdContact = 0;
|
$this->IdContact = 0;
|
||||||
$this->IdUser = 0;
|
$this->IdUser = 0;
|
||||||
$this->DisplayName = '';
|
|
||||||
$this->DisplayEmail = '';
|
|
||||||
$this->DisplayInList = '';
|
$this->DisplayInList = '';
|
||||||
$this->IsAuto = false;
|
$this->IsAuto = false;
|
||||||
$this->IsShare = false;
|
$this->IsShare = false;
|
||||||
|
$this->CanBeChanged = false;
|
||||||
$this->Changed = \time();
|
$this->Changed = \time();
|
||||||
$this->Tags = array();
|
$this->Tags = array();
|
||||||
$this->Properties = array();
|
$this->Properties = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function InitBeforeWrite()
|
public function UpdateDependentValues()
|
||||||
{
|
{
|
||||||
$sDisplayName = '';
|
$sDisplayName = '';
|
||||||
$sDisplayEmail = '';
|
$sDisplayEmail = '';
|
||||||
|
|
@ -87,24 +81,21 @@ class Contact
|
||||||
{
|
{
|
||||||
if ($oProperty)
|
if ($oProperty)
|
||||||
{
|
{
|
||||||
$oProperty->InitBeforeWrite();
|
$oProperty->UpdateDependentValues();
|
||||||
|
|
||||||
if ('' === $sDisplayName && \RainLoop\Providers\PersonalAddressBook\Enumerations\PropertyType::FULLNAME === $oProperty->Type)
|
if ('' === $sDisplayName && \RainLoop\Providers\PersonalAddressBook\Enumerations\PropertyType::FULLNAME === $oProperty->Type &&
|
||||||
|
0 < \strlen($oProperty->Value))
|
||||||
{
|
{
|
||||||
$sDisplayName = $oProperty->Value;
|
$sDisplayName = $oProperty->Value;
|
||||||
}
|
}
|
||||||
|
else if ('' === $sDisplayEmail && $oProperty->IsEmail() &&
|
||||||
if ('' === $sDisplayEmail && $oProperty->IsEmail())
|
0 < \strlen($oProperty->Value))
|
||||||
{
|
{
|
||||||
$sDisplayEmail = $oProperty->Value;
|
$sDisplayEmail = $oProperty->Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->DisplayName = $sDisplayName;
|
$this->DisplayInList = 0 < \strlen($sDisplayName) ? $sDisplayName : (!empty($sDisplayEmail) ? $sDisplayEmail : '');
|
||||||
$this->DisplayEmail = $sDisplayEmail;
|
|
||||||
$this->DisplayInList = 0 < \strlen($this->DisplayName) ? $this->DisplayName : (!empty($this->DisplayEmail) ? $this->DisplayEmail : '');
|
|
||||||
|
|
||||||
$this->Changed = \time();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class Property
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function InitBeforeWrite()
|
public function UpdateDependentValues()
|
||||||
{
|
{
|
||||||
// trimer
|
// trimer
|
||||||
$this->Value = \trim($this->Value);
|
$this->Value = \trim($this->Value);
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@
|
||||||
-- Table structure for table `rainloop_system`
|
-- Table structure for table `rainloop_system`
|
||||||
CREATE TABLE IF NOT EXISTS `rainloop_system` (
|
CREATE TABLE IF NOT EXISTS `rainloop_system` (
|
||||||
`name` varchar(50) NOT NULL,
|
`name` varchar(50) NOT NULL,
|
||||||
`value_int` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
`value_int` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
`value_str` varchar(255) NOT NULL DEFAULT ''
|
`value_str` varchar(255) NOT NULL DEFAULT ''
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
|
||||||
-- Table structure for table `rainloop_pab_users`
|
-- Table structure for table `rainloop_users`
|
||||||
CREATE TABLE IF NOT EXISTS `rainloop_pab_users` (
|
CREATE TABLE IF NOT EXISTS `rainloop_users` (
|
||||||
`id_user` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id_user` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`email` varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL,
|
`email` varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL,
|
||||||
|
|
||||||
UNIQUE `email_unique` (`email`),
|
UNIQUE `email_unique` (`email`),
|
||||||
|
|
@ -20,43 +20,57 @@ CREATE TABLE IF NOT EXISTS `rainloop_pab_users` (
|
||||||
|
|
||||||
-- Table structure for table `rainloop_pab_contacts`
|
-- Table structure for table `rainloop_pab_contacts`
|
||||||
CREATE TABLE IF NOT EXISTS `rainloop_pab_contacts` (
|
CREATE TABLE IF NOT EXISTS `rainloop_pab_contacts` (
|
||||||
`id_contact` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id_contact` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`id_user` int(10) UNSIGNED NOT NULL,
|
`id_user` int(11) UNSIGNED NOT NULL,
|
||||||
`display_name` varchar(255) NOT NULL DEFAULT '',
|
|
||||||
`display_email` varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL DEFAULT '',
|
|
||||||
`display_in_list` varchar(255) NOT NULL DEFAULT '',
|
`display_in_list` varchar(255) NOT NULL DEFAULT '',
|
||||||
`is_auto` tinyint(1) NOT NULL DEFAULT '0',
|
`is_auto` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`is_share` tinyint(1) NOT NULL DEFAULT '0',
|
`is_share` tinyint(1) NOT NULL DEFAULT '0',
|
||||||
`changed` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
`changed` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
|
|
||||||
CONSTRAINT `id_user_fk_rainloop_pab_contacts` FOREIGN KEY (`id_user`)
|
CONSTRAINT `id_user_fk_rainloop_pab_contacts` FOREIGN KEY (`id_user`)
|
||||||
REFERENCES `rainloop_pab_users` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE,
|
REFERENCES `rainloop_users` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
PRIMARY KEY(`id_contact`)
|
PRIMARY KEY(`id_contact`)
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
|
||||||
-- Table structure for table `rainloop_pab_prop`
|
-- Table structure for table `rainloop_pab_prop`
|
||||||
CREATE TABLE IF NOT EXISTS `rainloop_pab_prop` (
|
CREATE TABLE IF NOT EXISTS `rainloop_pab_prop` (
|
||||||
`id_contact` int(10) UNSIGNED NOT NULL,
|
`id_contact` int(11) UNSIGNED NOT NULL,
|
||||||
`id_user` int(10) UNSIGNED NOT NULL,
|
`id_user` int(11) UNSIGNED NOT NULL,
|
||||||
`type` int(10) UNSIGNED NOT NULL,
|
`type` int(11) UNSIGNED NOT NULL,
|
||||||
`type_custom` varchar(50) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL DEFAULT '',
|
`type_custom` varchar(50) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL DEFAULT '',
|
||||||
`value` varchar(255) NOT NULL DEFAULT '',
|
`value` varchar(255) NOT NULL DEFAULT '',
|
||||||
`value_custom` varchar(255) NOT NULL DEFAULT '',
|
`value_custom` varchar(255) NOT NULL DEFAULT '',
|
||||||
`frec` int(10) UNSIGNED NOT NULL DEFAULT '0',
|
`frec` int(11) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
|
|
||||||
|
INDEX `id_user_id_contact_index` (`id_user`, `id_contact`),
|
||||||
|
INDEX `id_user_value_index` (`id_user`, `value`),
|
||||||
CONSTRAINT `id_contact_fk_rainloop_pab_prop` FOREIGN KEY (`id_contact`)
|
CONSTRAINT `id_contact_fk_rainloop_pab_prop` FOREIGN KEY (`id_contact`)
|
||||||
REFERENCES `rainloop_pab_contacts` (`id_contact`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `rainloop_pab_contacts` (`id_contact`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
|
||||||
-- Table structure for table `rainloop_pab_tags`
|
-- Table structure for table `rainloop_pab_tags`
|
||||||
CREATE TABLE IF NOT EXISTS `rainloop_pab_tags` (
|
CREATE TABLE IF NOT EXISTS `rainloop_pab_tags` (
|
||||||
`id_user` int(10) UNSIGNED NOT NULL,
|
`id_tag` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`id_contact` int(10) UNSIGNED NOT NULL,
|
`id_contact` int(11) UNSIGNED NOT NULL,
|
||||||
|
`id_user` int(11) UNSIGNED NOT NULL,
|
||||||
`name` varchar(255) NOT NULL,
|
`name` varchar(255) NOT NULL,
|
||||||
|
|
||||||
UNIQUE `id_user_name_unique` (`id_user`, `name`),
|
UNIQUE `id_user_name_unique` (`id_user`, `name`),
|
||||||
CONSTRAINT `id_contact_fk_rainloop_pab_tags` FOREIGN KEY (`id_contact`)
|
CONSTRAINT `id_user_fk_rainloop_pab_tags` FOREIGN KEY (`id_user`)
|
||||||
REFERENCES `rainloop_pab_contacts` (`id_contact`) ON DELETE CASCADE ON UPDATE CASCADE
|
REFERENCES `rainloop_users` (`id_user`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
PRIMARY KEY(`id_tag`)
|
||||||
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
|
||||||
|
-- Table structure for table `rainloop_pab_tags_contacts`
|
||||||
|
CREATE TABLE IF NOT EXISTS `rainloop_pab_tags_contacts` (
|
||||||
|
`id_tag` int(11) UNSIGNED NOT NULL,
|
||||||
|
`id_contact` int(11) UNSIGNED NOT NULL,
|
||||||
|
|
||||||
|
UNIQUE `id_user_name_unique` (`id_user`, `name`),
|
||||||
|
CONSTRAINT `id_contact_fk_rainloop_tags_contacts` FOREIGN KEY (`id_contact`)
|
||||||
|
REFERENCES `rainloop_pab_contacts` (`id_contact`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `id_tag_fk_rainloop_tags_contacts` FOREIGN KEY (`id_tag`)
|
||||||
|
REFERENCES `rainloop_pab_tags` (`id_tag`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
|
||||||
|
|
||||||
-- RainLoop Webmail update contacts database structure
|
-- RainLoop Webmail update contacts database structure
|
||||||
|
|
@ -71,12 +85,12 @@ BEGIN
|
||||||
DECLARE current_version INT DEFAULT 0;
|
DECLARE current_version INT DEFAULT 0;
|
||||||
SELECT IFNULL(MAX(`value_int`), 0) INTO current_version FROM `rainloop_system` WHERE `name` = 'rainloop-pab-db-version';
|
SELECT IFNULL(MAX(`value_int`), 0) INTO current_version FROM `rainloop_system` WHERE `name` = 'rainloop-pab-db-version';
|
||||||
|
|
||||||
IF current_version < 1 THEN
|
|
||||||
ALTER TABLE `rainloop_pab_prop` ADD INDEX `id_user_id_contact_index` (`id_user`, `id_contact`);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
-- TODO
|
-- TODO
|
||||||
--
|
--
|
||||||
|
-- IF current_version < 1 THEN
|
||||||
|
-- ALTER TABLE `rainloop_pab_prop` ADD INDEX `id_user_id_contact_index` (`id_user`, `id_contact`);
|
||||||
|
-- END IF;
|
||||||
|
--
|
||||||
-- IF current_version < 2 THEN
|
-- IF current_version < 2 THEN
|
||||||
-- ALTER TABLE `rainloop_pab_prop` ADD INDEX `id_user_id_contact_index` (`id_user`, `id_contact`);
|
-- ALTER TABLE `rainloop_pab_prop` ADD INDEX `id_user_id_contact_index` (`id_user`, `id_contact`);
|
||||||
-- END IF;
|
-- END IF;
|
||||||
|
|
@ -85,7 +99,8 @@ BEGIN
|
||||||
INSERT INTO `rainloop_system` (`name`, `value_int`) VALUES ('rainloop-pab-db-version', new_version);
|
INSERT INTO `rainloop_system` (`name`, `value_int`) VALUES ('rainloop-pab-db-version', new_version);
|
||||||
END$$
|
END$$
|
||||||
|
|
||||||
CALL rainloop_pab_upgrade_database() $$
|
-- TODO
|
||||||
|
-- CALL rainloop_pab_upgrade_database() $$
|
||||||
|
|
||||||
DROP PROCEDURE IF EXISTS rainloop_pab_upgrade_database $$
|
DROP PROCEDURE IF EXISTS rainloop_pab_upgrade_database $$
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue