Skip to content

Commit

Permalink
Added basic contact groups feature
Browse files Browse the repository at this point in the history
  • Loading branch information
thomascube committed Mar 26, 2010
1 parent c75f8e9 commit a61bbb2
Show file tree
Hide file tree
Showing 26 changed files with 729 additions and 133 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CHANGELOG RoundCube Webmail
===========================

- Added contact groups in address book (not finished yet)
- Added PageUp/PageDown/Home/End keys support on lists (#1486430)
- Added possibility to select all messages in a folder (#1484756)
- Added 'imap_force_caps' option for after-login CAPABILITY checking (#1485750)
Expand Down
25 changes: 25 additions & 0 deletions SQL/mysql.initial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,31 @@ CREATE TABLE `contacts` (
INDEX `user_contacts_index` (`user_id`,`email`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;

-- Table structure for table `contactgroups`

CREATE TABLE `contactgroups` (
`contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`del` tinyint(1) NOT NULL DEFAULT '0',
`name` varchar(128) NOT NULL DEFAULT '',
PRIMARY KEY(`contactgroup_id`),
CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX `contactgroups_user_index` (`user_id`,`del`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;

CREATE TABLE `contactgroupmembers` (
`contactgroup_id` int(10) UNSIGNED NOT NULL,
`contact_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`contactgroup_id`, `contact_id`),
CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
) /*!40000 ENGINE=INNODB */;


-- Table structure for table `identities`

Expand Down
23 changes: 23 additions & 0 deletions SQL/mysql.update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,27 @@ ALTER TABLE `contacts` ALTER `surname` SET DEFAULT '';

ALTER TABLE `identities` ADD INDEX `user_identities_index` (`user_id`, `del`);

CREATE TABLE `contactgroups` (
`contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`changed` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`del` tinyint(1) NOT NULL DEFAULT '0',
`name` varchar(128) NOT NULL DEFAULT '',
PRIMARY KEY(`contactgroup_id`),
CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX `contactgroups_user_index` (`user_id`,`del`)
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;

CREATE TABLE `contactgroupmembers` (
`contactgroup_id` int(10) UNSIGNED NOT NULL,
`contact_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`contactgroup_id`, `contact_id`),
CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
) /*!40000 ENGINE=INNODB */;

/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
22 changes: 21 additions & 1 deletion SQL/sqlite.initial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CREATE INDEX ix_cache_created ON cache(created);
-- --------------------------------------------------------

--
-- Table structure for table contacts
-- Table structure for table contacts and related
--

CREATE TABLE contacts (
Expand All @@ -36,6 +36,26 @@ CREATE TABLE contacts (

CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);


CREATE TABLE contactgroups (
contactgroup_id integer NOT NULL PRIMARY KEY,
user_id integer NOT NULL default '0',
changed datetime NOT NULL default '0000-00-00 00:00:00',
del tinyint NOT NULL default '0',
name varchar(128) NOT NULL default ''
);

CREATE INDEX ix_contactgroups_user_id ON contactgroups(user_id, del);


CREATE TABLE contactgroupmembers (
contactgroup_id integer NOT NULL,
contact_id integer NOT NULL default '0',
created datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (contactgroup_id, contact_id)
);


-- --------------------------------------------------------

--
Expand Down
18 changes: 18 additions & 0 deletions SQL/sqlite.update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,21 @@ CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);

DROP INDEX ix_identities_user_id;
CREATE INDEX ix_identities_user_id ON identities (user_id, del);

CREATE TABLE contactgroups (
contactgroup_id integer NOT NULL PRIMARY KEY,
user_id integer NOT NULL default '0',
changed datetime NOT NULL default '0000-00-00 00:00:00',
del tinyint NOT NULL default '0',
name varchar(128) NOT NULL default ''
);

CREATE INDEX ix_contactgroups_user_id ON contactgroups(user_id, del);

CREATE TABLE contactgroupmembers (
contactgroup_id integer NOT NULL,
contact_id integer NOT NULL default '0',
created datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (contactgroup_id, contact_id)
);

4 changes: 4 additions & 0 deletions config/db.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ $rcmail_config['db_table_identities'] = 'identities';

$rcmail_config['db_table_contacts'] = 'contacts';

$rcmail_config['db_table_contactgroups'] = 'contactgroups';

$rcmail_config['db_table_contactgroupmembers'] = 'contactgroupmembers';

$rcmail_config['db_table_session'] = 'session';

$rcmail_config['db_table_cache'] = 'cache';
Expand Down
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@

'addressbook' => array(
'add' => 'edit.inc',
'create-group' => 'groups.inc',
'delete-group' => 'groups.inc',
'removefromgroup' => 'groups.inc',
'add2group' => 'groups.inc',
),

'settings' => array(
Expand Down
14 changes: 8 additions & 6 deletions program/include/rcmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,21 @@ public function get_address_sources($writeable = false)
if ($abook_type != 'ldap') {
$list['0'] = array(
'id' => 0,
'name' => rcube_label('personaladrbook'),
'name' => rcube_label('personaladrbook'),
'groups' => true,
'readonly' => false,
'autocomplete' => in_array('sql', $autocomplete)
'autocomplete' => in_array('sql', $autocomplete)
);
}

if (is_array($ldap_config)) {
foreach ($ldap_config as $id => $prop)
$list[$id] = array(
'id' => $id,
'name' => $prop['name'],
'readonly' => !$prop['writable'],
'autocomplete' => in_array('sql', $autocomplete)
'id' => $id,
'name' => $prop['name'],
'groups' => false,
'readonly' => !$prop['writable'],
'autocomplete' => in_array('sql', $autocomplete)
);
}

Expand Down
14 changes: 14 additions & 0 deletions program/include/rcube_addressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ abstract class rcube_addressbook
{
/** public properties */
var $primary_key;
var $groups = false;
var $readonly = true;
var $ready = false;
var $list_page = 1;
Expand Down Expand Up @@ -62,6 +63,13 @@ abstract function reset();
*/
abstract function list_records($cols=null, $subset=0);

/**
* List all active contact groups of this source
*
* @return array Indexed list of contact groups, each a hash array
*/
function list_groups() { }

/**
* Search records
*
Expand Down Expand Up @@ -123,6 +131,12 @@ function set_pagesize($size)
$this->page_size = (int)$size;
}

/**
* Setter for the current group
* (empty, has to be re-implemented by extending class)
*/
function set_group($gid) { }

/**
* Create a new contact record
*
Expand Down
Loading

0 comments on commit a61bbb2

Please sign in to comment.