From: Michael J. Rubinsky Date: Thu, 8 Apr 2010 18:49:05 +0000 (-0400) Subject: Initial support for resources to contain email addresses. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6088737580d296bba258f85ad6f0a7edc7ddb14f;p=horde.git Initial support for resources to contain email addresses. No notifications are sent, just stores the email address. Needed for synch clients that support resource attendees. --- diff --git a/kronolith/lib/Driver/Resource.php b/kronolith/lib/Driver/Resource.php index 1efdd1e84..16b9aec37 100644 --- a/kronolith/lib/Driver/Resource.php +++ b/kronolith/lib/Driver/Resource.php @@ -67,15 +67,15 @@ class Kronolith_Driver_Resource extends Kronolith_Driver_Sql public function save($resource) { if ($resource->getId()) { - $query = 'UPDATE kronolith_resources SET resource_name = ?, resource_calendar = ? , resource_description = ?, resource_response_type = ?, resource_type = ?, resource_members = ? WHERE resource_id = ?'; - $values = array($this->convertToDriver($resource->get('name')), $resource->get('calendar'), $this->convertToDriver($resource->get('description')), $resource->get('response_type'), $resource->get('type'), serialize($resource->get('members')), $resource->getId()); + $query = 'UPDATE kronolith_resources SET resource_name = ?, resource_calendar = ? , resource_description = ?, resource_response_type = ?, resource_type = ?, resource_members = ?, resource_email = ? WHERE resource_id = ?'; + $values = array($this->convertToDriver($resource->get('name')), $resource->get('calendar'), $this->convertToDriver($resource->get('description')), $resource->get('response_type'), $resource->get('type'), serialize($resource->get('members')), $resource->get('email'), $resource->getId()); $result = $this->_write_db->query($query, $values); $this->handleError($result); } else { - $query = 'INSERT INTO kronolith_resources (resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members)'; - $cols_values = ' VALUES (?, ?, ?, ?, ?, ?, ?)'; + $query = 'INSERT INTO kronolith_resources (resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members, resource_email)'; + $cols_values = ' VALUES (?, ?, ?, ?, ?, ?, ?, ?)'; $id = $this->_db->nextId('kronolith_resources'); - $values = array($id, $this->convertToDriver($resource->get('name')), $resource->get('calendar'), $this->convertToDriver($resource->get('description')), $resource->get('response_type'), $resource->get('type'), serialize($resource->get('members'))); + $values = array($id, $this->convertToDriver($resource->get('name')), $resource->get('calendar'), $this->convertToDriver($resource->get('description')), $resource->get('response_type'), $resource->get('type'), serialize($resource->get('members'), $resource->get('email'))); $result = $this->_write_db->query($query . $cols_values, $values); $this->handleError($result); $resource->setId($id); @@ -116,7 +116,7 @@ class Kronolith_Driver_Resource extends Kronolith_Driver_Sql */ public function getResource($id) { - $query = 'SELECT resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members FROM kronolith_resources WHERE resource_id = ?'; + $query = 'SELECT resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members, resource_email FROM kronolith_resources WHERE resource_id = ?'; $results = $this->_db->getRow($query, array($id), DB_FETCHMODE_ASSOC); $this->handleError($results); if (empty($results)) { @@ -170,7 +170,7 @@ class Kronolith_Driver_Resource extends Kronolith_Driver_Sql return array(); } - $query = 'SELECT resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members FROM kronolith_resources'; + $query = 'SELECT resource_id, resource_name, resource_calendar, resource_description, resource_response_type, resource_type, resource_members, resource_email FROM kronolith_resources'; if (count($filter)) { $clause = ' WHERE '; $i = 0; diff --git a/kronolith/lib/Forms/CreateResource.php b/kronolith/lib/Forms/CreateResource.php index fd9ef25d0..a118007ad 100644 --- a/kronolith/lib/Forms/CreateResource.php +++ b/kronolith/lib/Forms/CreateResource.php @@ -42,6 +42,7 @@ class Kronolith_CreateResourceForm extends Horde_Form $this->addVariable(_("Name"), 'name', 'text', true); $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); + $this->addVariable(_("Email"), 'email', 'email', false); $v = &$this->addVariable(_("Response type"), 'responsetype', 'enum', true, false, null, array('enum' => $responses)); $v->setDefault(Kronolith_Resource::RESPONSETYPE_AUTO); $this->addVariable(_("Groups"), 'category', 'multienum', false, false, null, array('enum' => $enum)); @@ -55,17 +56,20 @@ class Kronolith_CreateResourceForm extends Horde_Form { $new = array('name' => $this->_vars->get('name'), 'description' => $this->_vars->get('description'), - 'response_type' => $this->_vars->get('responsetype')); + 'response_type' => $this->_vars->get('responsetype'), + 'email' => $this->_vars->get('email')); $resource = Kronolith_Resource::addResource(new Kronolith_Resource_Single($new)); /* Do we need to add this to any groups? */ $groups = $this->_vars->get('category'); - foreach ($groups as $group_id) { - $group = Kronolith::getDriver('Resource')->getResource($group_id); - $members = $group->get('members'); - $members[] = $resource->getId(); - $group->set('members', $members); - $group->save(); + if (!empty($groups)) { + foreach ($groups as $group_id) { + $group = Kronolith::getDriver('Resource')->getResource($group_id); + $members = $group->get('members'); + $members[] = $resource->getId(); + $group->set('members', $members); + $group->save(); + } } } diff --git a/kronolith/lib/Forms/EditResource.php b/kronolith/lib/Forms/EditResource.php index c73841595..2885aaaf9 100644 --- a/kronolith/lib/Forms/EditResource.php +++ b/kronolith/lib/Forms/EditResource.php @@ -50,6 +50,7 @@ class Kronolith_EditResourceForm extends Horde_Form $this->addHidden('', 'c', 'text', true); $this->addVariable(_("Name"), 'name', 'text', true); + $this->addVariable(_("Email"), 'email', 'email', false); $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60)); $this->addVariable(_("Response type"), 'responsetype', 'enum', true, false, null, array('enum' => $responses)); $this->addVariable(_("Groups"), 'category', 'multienum', false, false, null, array('enum' => $enum)); @@ -66,6 +67,7 @@ class Kronolith_EditResourceForm extends Horde_Form $this->_resource->set('name', $new_name); $this->_resource->set('description', $this->_vars->get('description')); $this->_resource->set('response_type', $this->_vars->get('responsetype')); + $this->_resource->set('email', $this->_vars->get('email')); /* Update group memberships */ $driver = Kronolith::getDriver('Resource'); diff --git a/kronolith/lib/Resource/Base.php b/kronolith/lib/Resource/Base.php index f6c6b0337..e8ff47a46 100644 --- a/kronolith/lib/Resource/Base.php +++ b/kronolith/lib/Resource/Base.php @@ -54,7 +54,8 @@ abstract class Kronolith_Resource_Base $this->_params = array_merge(array('description' => '', 'response_type' => Kronolith_Resource::RESPONSETYPE_MANUAL, 'members' => '', - 'calendar' => ''), + 'calendar' => '', + 'email' => ''), $params); } diff --git a/kronolith/resources/edit.php b/kronolith/resources/edit.php index 60bd7f6ae..41d271e96 100644 --- a/kronolith/resources/edit.php +++ b/kronolith/resources/edit.php @@ -53,6 +53,7 @@ if ($form->validate($vars)) { } $vars->set('name', $resource->get('name')); +$vars->set('email', $resource->get('email')); $vars->set('description', $resource->get('description')); $vars->set('category', Kronolith::getDriver('Resource')->getGroupMemberships($resource->getId())); $vars->set('responsetype', $resource->get('response_type')); diff --git a/kronolith/scripts/sql/kronolith.mssql.sql b/kronolith/scripts/sql/kronolith.mssql.sql index 5b77ea022..7ef80a86a 100644 --- a/kronolith/scripts/sql/kronolith.mssql.sql +++ b/kronolith/scripts/sql/kronolith.mssql.sql @@ -91,6 +91,7 @@ CREATE TABLE kronolith_resources ( resource_response_type INT, resource_type VARCHAR(255) NOT NULL, resource_members VARCHAR(MAX), + resource_email VARCHAR(255), PRIMARY KEY (resource_id) ); diff --git a/kronolith/scripts/sql/kronolith.mysql.sql b/kronolith/scripts/sql/kronolith.mysql.sql index 5c3858747..ffd6d06e5 100644 --- a/kronolith/scripts/sql/kronolith.mysql.sql +++ b/kronolith/scripts/sql/kronolith.mysql.sql @@ -91,6 +91,7 @@ CREATE TABLE kronolith_resources ( resource_response_type INT, resource_type VARCHAR(255) NOT NULL, resource_members TEXT, + resource_email VARCHAR(255), PRIMARY KEY (resource_id) ); diff --git a/kronolith/scripts/sql/kronolith.oci8.sql b/kronolith/scripts/sql/kronolith.oci8.sql index 584809400..8e90e7b38 100644 --- a/kronolith/scripts/sql/kronolith.oci8.sql +++ b/kronolith/scripts/sql/kronolith.oci8.sql @@ -91,6 +91,7 @@ CREATE TABLE kronolith_resources ( resource_description CLOB, resource_response_type NUMBER(16), resource_type VARCHAR2(255) NOT NULL, + resource_email VARCHAR2(255), resource_members CLOB, diff --git a/kronolith/scripts/sql/kronolith.pgsql.sql b/kronolith/scripts/sql/kronolith.pgsql.sql index c9edefb7b..858b46873 100644 --- a/kronolith/scripts/sql/kronolith.pgsql.sql +++ b/kronolith/scripts/sql/kronolith.pgsql.sql @@ -91,6 +91,7 @@ CREATE TABLE kronolith_resources ( resource_response_type INT, resource_type VARCHAR(255) NOT NULL, resource_members TEXT, + resource_email VARCHAR(255), PRIMARY KEY (resource_id) ); diff --git a/kronolith/scripts/sql/kronolith.sql b/kronolith/scripts/sql/kronolith.sql index 15f634525..0db36d577 100644 --- a/kronolith/scripts/sql/kronolith.sql +++ b/kronolith/scripts/sql/kronolith.sql @@ -91,6 +91,7 @@ CREATE TABLE kronolith_resources ( resource_response_type INT, resource_type VARCHAR(255) NOT NULL, resource_members TEXT, + resource_email VARCHAR(255), PRIMARY KEY (resource_id) ); diff --git a/kronolith/scripts/sql/kronolith.xml b/kronolith/scripts/sql/kronolith.xml index 1680f5834..90f66b660 100644 --- a/kronolith/scripts/sql/kronolith.xml +++ b/kronolith/scripts/sql/kronolith.xml @@ -537,7 +537,12 @@ resource_members clob - + + + resource_email + text + 255 + kronolith_resources_type_idx diff --git a/kronolith/scripts/upgrades/2010-04-08_add_resourceemail.oci8.sql b/kronolith/scripts/upgrades/2010-04-08_add_resourceemail.oci8.sql new file mode 100644 index 000000000..0f67f382c --- /dev/null +++ b/kronolith/scripts/upgrades/2010-04-08_add_resourceemail.oci8.sql @@ -0,0 +1 @@ +ALTER TABLE kronolith_resources ADD resource_email VARCHAR2(255); diff --git a/kronolith/scripts/upgrades/2010-04-08_add_resourceemail.sql b/kronolith/scripts/upgrades/2010-04-08_add_resourceemail.sql new file mode 100644 index 000000000..ca96724ec --- /dev/null +++ b/kronolith/scripts/upgrades/2010-04-08_add_resourceemail.sql @@ -0,0 +1 @@ +ALTER TABLE kronolith_resources ADD resource_email VARCHAR(255);