Horde 4 style autoloading for kronolith's forms
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 27 Jan 2011 17:23:37 +0000 (12:23 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 27 Jan 2011 17:23:37 +0000 (12:23 -0500)
36 files changed:
kronolith/calendars/create.php
kronolith/calendars/delete.php
kronolith/calendars/edit.php
kronolith/calendars/remote_edit.php
kronolith/calendars/remote_subscribe.php
kronolith/calendars/remote_unsubscribe.php
kronolith/lib/Form/CreateCalendar.php [new file with mode: 0755]
kronolith/lib/Form/CreateResource.php [new file with mode: 0644]
kronolith/lib/Form/CreateResourceGroup.php [new file with mode: 0644]
kronolith/lib/Form/DeleteCalendar.php [new file with mode: 0644]
kronolith/lib/Form/DeleteResource.php [new file with mode: 0644]
kronolith/lib/Form/DeleteResourceGroup.php [new file with mode: 0644]
kronolith/lib/Form/EditCalendar.php [new file with mode: 0644]
kronolith/lib/Form/EditRemoteCalendar.php [new file with mode: 0644]
kronolith/lib/Form/EditResource.php [new file with mode: 0644]
kronolith/lib/Form/EditResourceGroup.php [new file with mode: 0644]
kronolith/lib/Form/SubscribeRemoteCalendar.php [new file with mode: 0644]
kronolith/lib/Form/UnsubscribeRemoteCalendar.php [new file with mode: 0644]
kronolith/lib/Forms/CreateCalendar.php [deleted file]
kronolith/lib/Forms/CreateResource.php [deleted file]
kronolith/lib/Forms/CreateResourceGroup.php [deleted file]
kronolith/lib/Forms/DeleteCalendar.php [deleted file]
kronolith/lib/Forms/DeleteResource.php [deleted file]
kronolith/lib/Forms/DeleteResourceGroup.php [deleted file]
kronolith/lib/Forms/EditCalendar.php [deleted file]
kronolith/lib/Forms/EditRemoteCalendar.php [deleted file]
kronolith/lib/Forms/EditResource.php [deleted file]
kronolith/lib/Forms/EditResourceGroup.php [deleted file]
kronolith/lib/Forms/SubscribeRemoteCalendar.php [deleted file]
kronolith/lib/Forms/UnsubscribeRemoteCalendar.php [deleted file]
kronolith/resources/create.php
kronolith/resources/delete.php
kronolith/resources/edit.php
kronolith/resources/groups/create.php
kronolith/resources/groups/delete.php
kronolith/resources/groups/edit.php

index 0d222f3..8d88ccf 100644 (file)
@@ -15,8 +15,6 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->setAnchor('calendar:internal')->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/CreateCalendar.php';
-
 // Exit if this isn't an authenticated user or if the user can't
 // create new calendars (default share is locked).
 if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('default_share')) {
@@ -24,7 +22,7 @@ if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('default_share')) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$form = new Kronolith_CreateCalendarForm($vars);
+$form = new Kronolith_Form_CreateCalendar($vars);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index 48eca31..6f2c24e 100644 (file)
@@ -11,8 +11,6 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('kronolith');
 
-require_once KRONOLITH_BASE . '/lib/Forms/DeleteCalendar.php';
-
 // Exit if this isn't an authenticated user.
 if (!$GLOBALS['registry']->getAuth()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
@@ -36,7 +34,7 @@ if ($calendar->get('owner') != $GLOBALS['registry']->getAuth() &&
     $notification->push(_("You are not allowed to delete this calendar."), 'horde.error');
     Horde::url('calendars/', true)->redirect();
 }
-$form = new Kronolith_DeleteCalendarForm($vars, $calendar);
+$form = new Kronolith_Form_DeleteCalendar($vars, $calendar);
 
 // Execute if the form is valid (must pass with POST variables only).
 if ($form->validate(new Horde_Variables($_POST))) {
index c4c7ebf..36a9039 100644 (file)
@@ -17,8 +17,6 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->setAnchor('calendar:internal|' . $vars->get('c'))->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/EditCalendar.php';
-
 // Exit if this isn't an authenticated user.
 if (!$GLOBALS['registry']->getAuth()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
@@ -35,7 +33,7 @@ if ($calendar->get('owner') != $GLOBALS['registry']->getAuth() &&
     $notification->push(_("You are not allowed to change this calendar."), 'horde.error');
     Horde::url('calendars/', true)->redirect();
 }
-$form = new Kronolith_EditCalendarForm($vars, $calendar);
+$form = new Kronolith_Form_EditCalendar($vars, $calendar);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index ab6ffa8..96dba34 100644 (file)
@@ -18,8 +18,6 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->setAnchor('calendar:remote|' . rawurlencode($url))->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/EditRemoteCalendar.php';
-
 // Exit if this isn't an authenticated user or if the user can't
 // subscribe to remote calendars (remote_cals is locked).
 if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('remote_cals')) {
@@ -38,8 +36,7 @@ if (is_null($remote_calendar)) {
     $notification->push(_("The remote calendar was not found."), 'horde.error');
     Horde::url('calendars/', true)->redirect();
 }
-
-$form = new Kronolith_EditRemoteCalendarForm($vars, $remote_calendar);
+$form = new Kronolith_Form_EditRemoteCalendar($vars, $remote_calendar);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index fae5983..c73265b 100644 (file)
@@ -18,15 +18,13 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->setAnchor('calendar:remote|' . rawurlencode($url))->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/SubscribeRemoteCalendar.php';
-
 // Exit if this isn't an authenticated user or if the user can't
 // subscribe to remote calendars (remote_cals is locked).
 if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('remote_cals')) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
 }
 
-$form = new Kronolith_SubscribeRemoteCalendarForm($vars);
+$form = new Kronolith_Form_SubscribeRemoteCalendar($vars);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index a7780f8..7f0dfb7 100644 (file)
@@ -18,8 +18,6 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->setAnchor('calendar:remote|' . rawurlencode($url))->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/UnsubscribeRemoteCalendar.php';
-
 // Exit if this isn't an authenticated user or if the user can't
 // subscribe to remote calendars (remote_cals is locked).
 if (!$GLOBALS['registry']->getAuth() || $prefs->isLocked('remote_cals')) {
@@ -39,7 +37,7 @@ if (is_null($remote_calendar)) {
     $notification->push(_("The remote calendar was not found."), 'horde.error');
     Horde::url('calendars/', true)->redirect();
 }
-$form = new Kronolith_UnsubscribeRemoteCalendarForm($vars, $remote_calendar);
+$form = new Kronolith_Form_UnsubscribeRemoteCalendar($vars, $remote_calendar);
 
 // Execute if the form is valid (must pass with POST variables only).
 if ($form->validate(new Horde_Variables($_POST))) {
diff --git a/kronolith/lib/Form/CreateCalendar.php b/kronolith/lib/Form/CreateCalendar.php
new file mode 100755 (executable)
index 0000000..3f810bd
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Horde_Form for creating calendars.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_CreateCalendarForm class provides the form for creating a
+ * calendar.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_CreateCalendar extends Horde_Form
+{
+    public function __construct($vars)
+    {
+        parent::__construct($vars, _("Create Calendar"));
+
+        $this->addVariable(_("Name"), 'name', 'text', true);
+        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
+        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Tags"), 'tags', 'text', false);
+        if ($GLOBALS['registry']->isAdmin()) {
+            $this->addVariable(_("System Calendar"), 'system', 'boolean', false, false, _("System calendars don't have an owner. Only administrators can change the calendar settings and permissions."));
+        }
+
+        $this->setButtons(array(_("Create")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $info = array();
+        foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
+            $info[$key] = $this->_vars->get($key);
+        }
+        return Kronolith::addShare($info);
+    }
+
+}
diff --git a/kronolith/lib/Form/CreateResource.php b/kronolith/lib/Form/CreateResource.php
new file mode 100644 (file)
index 0000000..4a9d857
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Horde_Form for creating resources.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_CreateResourceForm class provides the form for creating a
+ * resource.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_CreateResource extends Horde_Form
+{
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function __construct($vars)
+    {
+        parent::__construct($vars, _("Create Resource"));
+
+        $responses =  array(Kronolith_Resource::RESPONSETYPE_ALWAYS_ACCEPT => _("Always Accept"),
+                            Kronolith_Resource::RESPONSETYPE_ALWAYS_DECLINE => _("Always Decline"),
+                            Kronolith_Resource::RESPONSETYPE_AUTO => _("Automatically"),
+                            Kronolith_Resource::RESPONSETYPE_MANUAL => _("Manual"),
+                            Kronolith_Resource::RESPONSETYPE_NONE => _("None"));
+
+        /* Get a list of available resource groups */
+        $groups = Kronolith::getDriver('Resource')
+            ->listResources(Horde_Perms::READ,
+                            array('type' => Kronolith_Resource::TYPE_GROUP));
+        $enum = array();
+        foreach ($groups as $id => $group) {
+            $enum[$id] = $group->get('name');
+        }
+
+        $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));
+        $this->setButtons(array(_("Create")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $new = array('name' => $this->_vars->get('name'),
+                     'description' => $this->_vars->get('description'),
+                     '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');
+        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/Form/CreateResourceGroup.php b/kronolith/lib/Form/CreateResourceGroup.php
new file mode 100644 (file)
index 0000000..ff3ddb4
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Horde_Form for creating resource groups.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_CreateResourceGroupForm class provides the form for creating
+ * a resource group.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_CreateResourceGroup extends Horde_Form
+{
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function __construct($vars)
+    {
+        parent::__construct($vars, _("Create Resource"));
+
+        $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('type' => Kronolith_Resource::TYPE_SINGLE));
+        $enum = array();
+        foreach ($resources as $resource) {
+            $enum[$resource->getId()] = htmlspecialchars($resource->get('name'));
+        }
+        $this->addVariable(_("Name"), 'name', 'text', true);
+        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Resources"), 'members', 'multienum', false, false, null, array('enum' => $enum));
+        $this->setButtons(array(_("Create")));
+    }
+
+    public function execute()
+    {
+        $new = array('name' => $this->_vars->get('name'),
+                     'description' => $this->_vars->get('description'),
+                     'members' => $this->_vars->get('members'));
+        return Kronolith_Resource::addResource(new Kronolith_Resource_Group($new));
+    }
+
+}
diff --git a/kronolith/lib/Form/DeleteCalendar.php b/kronolith/lib/Form/DeleteCalendar.php
new file mode 100644 (file)
index 0000000..849595b
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Horde_Form for deleting calendars.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_DeleteCalendarForm class provides the form for deleting a
+ * calendar.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_DeleteCalendar extends Horde_Form
+{
+    /**
+     * Calendar being deleted.
+     */
+    protected $_calendar;
+
+    public function __construct($vars, $calendar)
+    {
+        $this->_calendar = $calendar;
+        parent::__construct($vars, sprintf(_("Delete %s"), $calendar->get('name')));
+
+        $this->addHidden('', 'c', 'text', true);
+        $this->addVariable(sprintf(_("Really delete the calendar \"%s\"? This cannot be undone and all data on this calendar will be permanently removed."), $this->_calendar->get('name')), 'desc', 'description', false);
+
+        $this->setButtons(array(_("Delete"), _("Cancel")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        // If cancel was clicked, return false.
+        if ($this->_vars->get('submitbutton') == _("Cancel")) {
+            return false;
+        }
+
+        return Kronolith::deleteShare($this->_calendar);
+    }
+
+}
diff --git a/kronolith/lib/Form/DeleteResource.php b/kronolith/lib/Form/DeleteResource.php
new file mode 100644 (file)
index 0000000..f6ea739
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Horde_Form for deleting resources.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_DeleteResourceForm class provides the form for deleting a
+ * resource.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_DeleteResource extends Horde_Form
+{
+    /**
+     * Resource being deleted.
+     *
+     * @var Kronolith_Resource_Single
+     */
+    protected $_resource;
+
+    public function __construct($vars, $resource)
+    {
+        $this->_resource = $resource;
+        parent::__construct($vars, sprintf(_("Delete %s"), $resource->get('name')));
+
+        $this->addHidden('', 'c', 'text', true);
+        $this->addVariable(sprintf(_("Really delete the resource \"%s\"? This cannot be undone and all data on this resource will be permanently removed."), $this->_resource->get('name')), 'desc', 'description', false);
+
+        $this->setButtons(array(_("Delete"), _("Cancel")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        // If cancel was clicked, return false.
+        if ($this->_vars->get('submitbutton') == _("Cancel")) {
+            return;
+        }
+
+        if (!($this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE))) {
+            throw new Kronolith_Exception(_("Permission denied"));
+        }
+
+        // Delete the resource.
+        try {
+            Kronolith::getDriver('Resource')->delete($this->_resource);
+        } catch (Exception $e) {
+            throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
+        }
+    }
+
+}
diff --git a/kronolith/lib/Form/DeleteResourceGroup.php b/kronolith/lib/Form/DeleteResourceGroup.php
new file mode 100644 (file)
index 0000000..46fad26
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Horde_Form for deleting resource groups.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_DeleteResourceGroupForm class provides the form for deleting
+ * a resource group.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_DeleteResourceGroup extends Horde_Form
+{
+    /**
+     * Resource group being deleted.
+     *
+     * @var Kronolith_Resource_Group
+     */
+    protected $_resource;
+
+    public function __construct($vars, $resource)
+    {
+        $this->_resource = $resource;
+        parent::__construct($vars, sprintf(_("Delete %s"), $resource->get('name')));
+
+        $this->addHidden('', 'c', 'text', true);
+        $this->addVariable(
+            sprintf(_("Really delete the resource \"%s\"? This cannot be undone and all data on this resource will be permanently removed."), $this->_resource->get('name')),
+            'desc', 'description', false);
+        $this->setButtons(array(_("Delete"), _("Cancel")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        // If cancel was clicked, return false.
+        if ($this->_vars->get('submitbutton') == _("Cancel")) {
+            return;
+        }
+
+        if (!($this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE))) {
+            throw new Kronolith_Exception(_("Permission denied"));
+        }
+
+        // Delete the resource.
+        try {
+            Kronolith::getDriver('Resource')->delete($this->_resource);
+        } catch (Exception $e) {
+            throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
+        }
+    }
+
+}
diff --git a/kronolith/lib/Form/EditCalendar.php b/kronolith/lib/Form/EditCalendar.php
new file mode 100644 (file)
index 0000000..e20b44d
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Horde_Form for editing calendars.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_EditCalendarForm class provides the form for editing a
+ * calendar.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_EditCalendar extends Horde_Form
+{
+    /**
+     * Calendar being edited.
+     */
+    protected $_calendar;
+
+    public function __construct($vars, $calendar)
+    {
+        $this->_calendar = $calendar;
+        parent::__construct($vars, sprintf(_("Edit %s"), $calendar->get('name')));
+
+        $this->addHidden('', 'c', 'text', true);
+        $this->addVariable(_("Name"), 'name', 'text', true);
+        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
+        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Tags"), 'tags', 'text', false);
+        if ($GLOBALS['registry']->isAdmin()) {
+            $this->addVariable(_("System Calendar"), 'system', 'boolean', false, false, _("System calendars don't have an owner. Only administrators can change the calendar settings and permissions."));
+        }
+
+        $this->setButtons(array(_("Save")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $info = array();
+        foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
+            $info[$key] = $this->_vars->get($key);
+        }
+        return Kronolith::updateShare($this->_calendar, $info);
+    }
+
+}
diff --git a/kronolith/lib/Form/EditRemoteCalendar.php b/kronolith/lib/Form/EditRemoteCalendar.php
new file mode 100644 (file)
index 0000000..f5b57d5
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Horde_Form for editing remote calendars.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_EditRemoteCalendarForm class provides the form for editing a
+ * remote calendar.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_EditRemoteCalendar extends Horde_Form
+{
+    public function __construct($vars, $remote_calendar)
+    {
+        parent::__construct($vars, sprintf(_("Edit %s"), $remote_calendar['name']));
+
+        $this->addHidden('', 'url', 'text', true);
+        $this->addVariable(_("Name"), 'name', 'text', true);
+        $v = &$this->addVariable(_("URL"), 'new_url', 'text', true);
+        $v->setDefault($vars->get('url'));
+        $this->addVariable(_("Username"), 'user', 'text', false);
+        $this->addVariable(_("Password"), 'password', 'password', false);
+        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
+        $this->addVariable(_("Description"), 'desc', 'longtext', false, false, null, array(4, 60));
+
+        $this->setButtons(array(_("Save")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $info = array();
+        foreach (array('name', 'new_url', 'user', 'password', 'color', 'desc') as $key) {
+            $info[$key == 'new_url' ? 'url' : $key] = $this->_vars->get($key);
+        }
+        Kronolith::subscribeRemoteCalendar($info, trim($this->_vars->get('url')));
+    }
+
+}
diff --git a/kronolith/lib/Form/EditResource.php b/kronolith/lib/Form/EditResource.php
new file mode 100644 (file)
index 0000000..f72e4b0
--- /dev/null
@@ -0,0 +1,115 @@
+<?php
+/**
+ * Horde_Form for editing resources.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_EditResourceForm class provides the form for editing a
+ * resource.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_EditResource extends Horde_Form
+{
+    /**
+     * Resource being edited.
+     *
+     * @var Kronolith_Resource_Single
+     */
+    protected $_resource;
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function __construct($vars, $resource)
+    {
+        $this->_resource = $resource;
+        parent::__construct($vars, sprintf(_("Edit %s"), $resource->get('name')));
+
+        $responses =  array(Kronolith_Resource::RESPONSETYPE_ALWAYS_ACCEPT => _("Always Accept"),
+                            Kronolith_Resource::RESPONSETYPE_ALWAYS_DECLINE => _("Always Decline"),
+                            Kronolith_Resource::RESPONSETYPE_AUTO => _("Automatically"),
+                            Kronolith_Resource::RESPONSETYPE_MANUAL => _("Manual"),
+                            Kronolith_Resource::RESPONSETYPE_NONE => _("None"));
+
+        /* Get a list of available resource groups */
+        $groups = Kronolith::getDriver('Resource')
+            ->listResources(Horde_Perms::READ,
+                            array('type' => Kronolith_Resource::TYPE_GROUP));
+        $enum = array();
+        foreach ($groups as $id => $group) {
+            $enum[$id] = $group->get('name');
+        }
+
+        $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));
+        $this->setButtons(array(_("Save")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $original_name = $this->_resource->get('name');
+        $new_name = $this->_vars->get('name');
+        $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');
+        $existing_groups = $driver->getGroupMemberships($this->_resource->getId());
+        $new_groups = $this->_vars->get('category');
+        $new_groups = (is_null($new_groups) ? array() : $new_groups);
+        foreach ($existing_groups as $gid) {
+             $i = array_search($gid, $new_groups);
+             if ($i === false) {
+                 // No longer in this group
+                 $group = $driver->getResource($gid);
+                 $members = $group->get('members');
+                 $idx = array_search($this->_resource->getId(), $members);
+                 if ($idx !== false) {
+                     unset($members[$idx]);
+                     reset($members);
+                     $group->set('members', $members);
+                     $group->save();
+                 }
+             } else {
+                 // We know it's already in the group, remove it so we don't
+                 // have to check/add it again later.
+                 unset($new_groups[$i]);
+             }
+        }
+
+        reset($new_groups);
+        foreach ($new_groups as $gid) {
+            $group = $driver->getResource($gid);
+            $members = $group->get('members');
+            $members[] = $this->_resource->getId();
+            $group->set('members', $members);
+            $group->save();
+        }
+
+        try {
+            $result = $this->_resource->save();
+        } catch (Exception $e) {
+            throw new Kronolith_Exception(sprintf(_("Unable to save resource \"%s\": %s"), $new_name, $e->getMessage()));
+        }
+
+        return $this->_resource;
+    }
+
+}
diff --git a/kronolith/lib/Form/EditResourceGroup.php b/kronolith/lib/Form/EditResourceGroup.php
new file mode 100644 (file)
index 0000000..d430c01
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Horde_Form for editing resource groups.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_EditResourceGroupForm class provides the form for editing
+ * resource groups.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael J. Rubinsky <mrubinsk@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_EditResourceGroup extends Horde_Form
+{
+    /**
+     * Resource group being edited.
+     *
+     * @var Kronolith_Resource_Single
+     */
+    protected $_resource;
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function __construct($vars, $resource)
+    {
+        $this->_resource = $resource;
+        parent::__construct($vars, sprintf(_("Edit %s"), $resource->get('name')));
+
+        $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('type' => Kronolith_Resource::TYPE_SINGLE));
+        $enum = array();
+        foreach ($resources as $r) {
+            $enum[$r->getId()] = htmlspecialchars($r->get('name'));
+        }
+
+        $this->addHidden('', 'c', 'text', true);
+        $this->addVariable(_("Name"), 'name', 'text', true);
+        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Resources"), 'members', 'multienum', false, false, null, array('enum' => $enum));
+        $this->setButtons(array(_("Save")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $original_name = $this->_resource->get('name');
+        $new_name = $this->_vars->get('name');
+        $this->_resource->set('name', $new_name);
+        $this->_resource->set('description', $this->_vars->get('description'));
+        $this->_resource->set('members', $this->_vars->get('members'));
+
+        try {
+            $this->_resource->save();
+        } catch (Exception $e) {
+            throw new Kronolith_Exception(sprintf(_("Unable to save resource \"%s\": %s"), $new_name, $e->getMessage()));
+        }
+
+        return $this->_resource;
+    }
+
+}
diff --git a/kronolith/lib/Form/SubscribeRemoteCalendar.php b/kronolith/lib/Form/SubscribeRemoteCalendar.php
new file mode 100644 (file)
index 0000000..028a06f
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Horde_Form for subscribing to remote calendars.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_SubscribeRemoteCalendarForm class provides the form for
+ * subscribing to remote calendars.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_SubscribeRemoteCalendar extends Horde_Form
+{
+    public function __construct($vars)
+    {
+        parent::__construct($vars, _("Subscribe to a Remote Calendar"));
+
+        $this->addVariable(_("Name"), 'name', 'text', true);
+        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
+        $this->addVariable(_("URL"), 'url', 'text', true);
+        $this->addVariable(_("Description"), 'desc', 'longtext', false, false, null, array(4, 60));
+        $this->addVariable(_("Username"), 'user', 'text', false);
+        $this->addVariable(_("Password"), 'password', 'password', false);
+
+        $this->setButtons(array(_("Subscribe")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        $info = array();
+        foreach (array('name', 'url', 'user', 'password', 'color', 'desc') as $key) {
+            $info[$key] = $this->_vars->get($key);
+        }
+        Kronolith::subscribeRemoteCalendar($info);
+    }
+
+}
diff --git a/kronolith/lib/Form/UnsubscribeRemoteCalendar.php b/kronolith/lib/Form/UnsubscribeRemoteCalendar.php
new file mode 100644 (file)
index 0000000..ad2d9ce
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Horde_Form for unsubscribing from remote calendars.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Kronolith
+ */
+
+/**
+ * The Kronolith_UnsubscribeRemoteCalendarForm class provides the form for
+ * unsubscribing from remote calendars.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @package Kronolith
+ */
+class Kronolith_Form_UnsubscribeRemoteCalendar extends Horde_Form
+{
+    public function __construct($vars, $calendar)
+    {
+        parent::__construct($vars, sprintf(_("Unsubscribe from %s"), $calendar['name']));
+
+        $this->addHidden('', 'url', 'text', true);
+        $this->addVariable(sprintf(_("Really unsubscribe from the calendar \"%s\" (%s)?"), $calendar['name'], $calendar['url']), 'desc', 'description', false);
+
+        $this->setButtons(array(_("Unsubscribe"), _("Cancel")));
+    }
+
+    /**
+     * @throws Kronolith_Exception
+     */
+    public function execute()
+    {
+        // If cancel was clicked, return false.
+        if ($this->_vars->get('submitbutton') == _("Cancel")) {
+            return false;
+        }
+        return Kronolith::unsubscribeRemoteCalendar($this->_vars->get('url'));
+    }
+
+}
diff --git a/kronolith/lib/Forms/CreateCalendar.php b/kronolith/lib/Forms/CreateCalendar.php
deleted file mode 100755 (executable)
index c9ae419..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Horde_Form for creating calendars.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_CreateCalendarForm class provides the form for creating a
- * calendar.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Kronolith
- */
-class Kronolith_CreateCalendarForm extends Horde_Form
-{
-    public function __construct($vars)
-    {
-        parent::Horde_Form($vars, _("Create Calendar"));
-
-        $this->addVariable(_("Name"), 'name', 'text', true);
-        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
-        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
-        $this->addVariable(_("Tags"), 'tags', 'text', false);
-        if ($GLOBALS['registry']->isAdmin()) {
-            $this->addVariable(_("System Calendar"), 'system', 'boolean', false, false, _("System calendars don't have an owner. Only administrators can change the calendar settings and permissions."));
-        }
-
-        $this->setButtons(array(_("Create")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $info = array();
-        foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
-            $info[$key] = $this->_vars->get($key);
-        }
-        return Kronolith::addShare($info);
-    }
-
-}
diff --git a/kronolith/lib/Forms/CreateResource.php b/kronolith/lib/Forms/CreateResource.php
deleted file mode 100644 (file)
index a6cca63..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * Horde_Form for creating resources.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_CreateResourceForm class provides the form for creating a
- * resource.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_CreateResourceForm extends Horde_Form
-{
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function __construct($vars)
-    {
-        parent::Horde_Form($vars, _("Create Resource"));
-
-        $responses =  array(Kronolith_Resource::RESPONSETYPE_ALWAYS_ACCEPT => _("Always Accept"),
-                            Kronolith_Resource::RESPONSETYPE_ALWAYS_DECLINE => _("Always Decline"),
-                            Kronolith_Resource::RESPONSETYPE_AUTO => _("Automatically"),
-                            Kronolith_Resource::RESPONSETYPE_MANUAL => _("Manual"),
-                            Kronolith_Resource::RESPONSETYPE_NONE => _("None"));
-
-        /* Get a list of available resource groups */
-        $groups = Kronolith::getDriver('Resource')
-            ->listResources(Horde_Perms::READ,
-                            array('type' => Kronolith_Resource::TYPE_GROUP));
-        $enum = array();
-        foreach ($groups as $id => $group) {
-            $enum[$id] = $group->get('name');
-        }
-
-        $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));
-        $this->setButtons(array(_("Create")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $new = array('name' => $this->_vars->get('name'),
-                     'description' => $this->_vars->get('description'),
-                     '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');
-        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/CreateResourceGroup.php b/kronolith/lib/Forms/CreateResourceGroup.php
deleted file mode 100644 (file)
index 5ca78eb..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * Horde_Form for creating resource groups.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_CreateResourceGroupForm class provides the form for creating
- * a resource group.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_CreateResourceGroupForm extends Horde_Form
-{
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function __construct($vars)
-    {
-        parent::Horde_Form($vars, _("Create Resource"));
-
-        $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('type' => Kronolith_Resource::TYPE_SINGLE));
-        $enum = array();
-        foreach ($resources as $resource) {
-            $enum[$resource->getId()] = htmlspecialchars($resource->get('name'));
-        }
-        $this->addVariable(_("Name"), 'name', 'text', true);
-        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
-        $this->addVariable(_("Resources"), 'members', 'multienum', false, false, null, array('enum' => $enum));
-        $this->setButtons(array(_("Create")));
-    }
-
-    public function execute()
-    {
-        $new = array('name' => $this->_vars->get('name'),
-                     'description' => $this->_vars->get('description'),
-                     'members' => $this->_vars->get('members'));
-        return Kronolith_Resource::addResource(new Kronolith_Resource_Group($new));
-    }
-
-}
diff --git a/kronolith/lib/Forms/DeleteCalendar.php b/kronolith/lib/Forms/DeleteCalendar.php
deleted file mode 100644 (file)
index c8ffce1..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * Horde_Form for deleting calendars.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_DeleteCalendarForm class provides the form for deleting a
- * calendar.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Kronolith
- */
-class Kronolith_DeleteCalendarForm extends Horde_Form
-{
-    /**
-     * Calendar being deleted.
-     */
-    protected $_calendar;
-
-    public function __construct($vars, $calendar)
-    {
-        $this->_calendar = $calendar;
-        parent::Horde_Form($vars, sprintf(_("Delete %s"), $calendar->get('name')));
-
-        $this->addHidden('', 'c', 'text', true);
-        $this->addVariable(sprintf(_("Really delete the calendar \"%s\"? This cannot be undone and all data on this calendar will be permanently removed."), $this->_calendar->get('name')), 'desc', 'description', false);
-
-        $this->setButtons(array(_("Delete"), _("Cancel")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        // If cancel was clicked, return false.
-        if ($this->_vars->get('submitbutton') == _("Cancel")) {
-            return false;
-        }
-
-        return Kronolith::deleteShare($this->_calendar);
-    }
-
-}
diff --git a/kronolith/lib/Forms/DeleteResource.php b/kronolith/lib/Forms/DeleteResource.php
deleted file mode 100644 (file)
index 1bbd5a9..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * Horde_Form for deleting resources.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_DeleteResourceForm class provides the form for deleting a
- * resource.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_DeleteResourceForm extends Horde_Form
-{
-    /**
-     * Resource being deleted.
-     *
-     * @var Kronolith_Resource_Single
-     */
-    protected $_resource;
-
-    public function __construct($vars, $resource)
-    {
-        $this->_resource = $resource;
-        parent::Horde_Form($vars, sprintf(_("Delete %s"), $resource->get('name')));
-
-        $this->addHidden('', 'c', 'text', true);
-        $this->addVariable(sprintf(_("Really delete the resource \"%s\"? This cannot be undone and all data on this resource will be permanently removed."), $this->_resource->get('name')), 'desc', 'description', false);
-
-        $this->setButtons(array(_("Delete"), _("Cancel")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        // If cancel was clicked, return false.
-        if ($this->_vars->get('submitbutton') == _("Cancel")) {
-            return;
-        }
-
-        if (!($this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE))) {
-            throw new Kronolith_Exception(_("Permission denied"));
-        }
-
-        // Delete the resource.
-        try {
-            Kronolith::getDriver('Resource')->delete($this->_resource);
-        } catch (Exception $e) {
-            throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
-        }
-    }
-
-}
diff --git a/kronolith/lib/Forms/DeleteResourceGroup.php b/kronolith/lib/Forms/DeleteResourceGroup.php
deleted file mode 100644 (file)
index 9290c08..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * Horde_Form for deleting resource groups.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_DeleteResourceGroupForm class provides the form for deleting
- * a resource group.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_DeleteResourceGroupForm extends Horde_Form
-{
-    /**
-     * Resource group being deleted.
-     *
-     * @var Kronolith_Resource_Group
-     */
-    protected $_resource;
-
-    public function __construct($vars, $resource)
-    {
-        $this->_resource = $resource;
-        parent::Horde_Form($vars, sprintf(_("Delete %s"), $resource->get('name')));
-
-        $this->addHidden('', 'c', 'text', true);
-        $this->addVariable(sprintf(_("Really delete the resource \"%s\"? This cannot be undone and all data on this resource will be permanently removed."), $this->_resource->get('name')), 'desc', 'description', false);
-
-        $this->setButtons(array(_("Delete"), _("Cancel")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        // If cancel was clicked, return false.
-        if ($this->_vars->get('submitbutton') == _("Cancel")) {
-            return;
-        }
-
-        if (!($this->_resource->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE))) {
-            throw new Kronolith_Exception(_("Permission denied"));
-        }
-
-        // Delete the resource.
-        try {
-            Kronolith::getDriver('Resource')->delete($this->_resource);
-        } catch (Exception $e) {
-            throw new Kronolith_Exception(sprintf(_("Unable to delete \"%s\": %s"), $this->_resource->get('name'), $e->getMessage()));
-        }
-    }
-
-}
diff --git a/kronolith/lib/Forms/EditCalendar.php b/kronolith/lib/Forms/EditCalendar.php
deleted file mode 100644 (file)
index 5dff62d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * Horde_Form for editing calendars.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_EditCalendarForm class provides the form for editing a
- * calendar.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Kronolith
- */
-class Kronolith_EditCalendarForm extends Horde_Form
-{
-    /**
-     * Calendar being edited.
-     */
-    protected $_calendar;
-
-    public function __construct($vars, $calendar)
-    {
-        $this->_calendar = $calendar;
-        parent::Horde_Form($vars, sprintf(_("Edit %s"), $calendar->get('name')));
-
-        $this->addHidden('', 'c', 'text', true);
-        $this->addVariable(_("Name"), 'name', 'text', true);
-        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
-        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
-        $this->addVariable(_("Tags"), 'tags', 'text', false);
-        if ($GLOBALS['registry']->isAdmin()) {
-            $this->addVariable(_("System Calendar"), 'system', 'boolean', false, false, _("System calendars don't have an owner. Only administrators can change the calendar settings and permissions."));
-        }
-
-        $this->setButtons(array(_("Save")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $info = array();
-        foreach (array('name', 'color', 'description', 'tags', 'system') as $key) {
-            $info[$key] = $this->_vars->get($key);
-        }
-        return Kronolith::updateShare($this->_calendar, $info);
-    }
-
-}
diff --git a/kronolith/lib/Forms/EditRemoteCalendar.php b/kronolith/lib/Forms/EditRemoteCalendar.php
deleted file mode 100644 (file)
index 3052957..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * Horde_Form for editing remote calendars.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_EditRemoteCalendarForm class provides the form for editing a
- * remote calendar.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Kronolith
- */
-class Kronolith_EditRemoteCalendarForm extends Horde_Form
-{
-    public function __construct($vars, $remote_calendar)
-    {
-        parent::Horde_Form($vars, sprintf(_("Edit %s"), $remote_calendar['name']));
-
-        $this->addHidden('', 'url', 'text', true);
-        $this->addVariable(_("Name"), 'name', 'text', true);
-        $v = &$this->addVariable(_("URL"), 'new_url', 'text', true);
-        $v->setDefault($vars->get('url'));
-        $this->addVariable(_("Username"), 'user', 'text', false);
-        $this->addVariable(_("Password"), 'password', 'password', false);
-        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
-        $this->addVariable(_("Description"), 'desc', 'longtext', false, false, null, array(4, 60));
-
-        $this->setButtons(array(_("Save")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $info = array();
-        foreach (array('name', 'new_url', 'user', 'password', 'color', 'desc') as $key) {
-            $info[$key == 'new_url' ? 'url' : $key] = $this->_vars->get($key);
-        }
-        Kronolith::subscribeRemoteCalendar($info, trim($this->_vars->get('url')));
-    }
-
-}
diff --git a/kronolith/lib/Forms/EditResource.php b/kronolith/lib/Forms/EditResource.php
deleted file mode 100644 (file)
index 2885aaa..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-/**
- * Horde_Form for editing resources.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_EditResourceForm class provides the form for editing a
- * resource.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_EditResourceForm extends Horde_Form
-{
-    /**
-     * Resource being edited.
-     *
-     * @var Kronolith_Resource_Single
-     */
-    protected $_resource;
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function __construct($vars, $resource)
-    {
-        $this->_resource = $resource;
-        parent::Horde_Form($vars, sprintf(_("Edit %s"), $resource->get('name')));
-
-        $responses =  array(Kronolith_Resource::RESPONSETYPE_ALWAYS_ACCEPT => _("Always Accept"),
-                            Kronolith_Resource::RESPONSETYPE_ALWAYS_DECLINE => _("Always Decline"),
-                            Kronolith_Resource::RESPONSETYPE_AUTO => _("Automatically"),
-                            Kronolith_Resource::RESPONSETYPE_MANUAL => _("Manual"),
-                            Kronolith_Resource::RESPONSETYPE_NONE => _("None"));
-
-        /* Get a list of available resource groups */
-        $groups = Kronolith::getDriver('Resource')
-            ->listResources(Horde_Perms::READ,
-                            array('type' => Kronolith_Resource::TYPE_GROUP));
-        $enum = array();
-        foreach ($groups as $id => $group) {
-            $enum[$id] = $group->get('name');
-        }
-
-        $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));
-        $this->setButtons(array(_("Save")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $original_name = $this->_resource->get('name');
-        $new_name = $this->_vars->get('name');
-        $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');
-        $existing_groups = $driver->getGroupMemberships($this->_resource->getId());
-        $new_groups = $this->_vars->get('category');
-        $new_groups = (is_null($new_groups) ? array() : $new_groups);
-        foreach ($existing_groups as $gid) {
-             $i = array_search($gid, $new_groups);
-             if ($i === false) {
-                 // No longer in this group
-                 $group = $driver->getResource($gid);
-                 $members = $group->get('members');
-                 $idx = array_search($this->_resource->getId(), $members);
-                 if ($idx !== false) {
-                     unset($members[$idx]);
-                     reset($members);
-                     $group->set('members', $members);
-                     $group->save();
-                 }
-             } else {
-                 // We know it's already in the group, remove it so we don't
-                 // have to check/add it again later.
-                 unset($new_groups[$i]);
-             }
-        }
-
-        reset($new_groups);
-        foreach ($new_groups as $gid) {
-            $group = $driver->getResource($gid);
-            $members = $group->get('members');
-            $members[] = $this->_resource->getId();
-            $group->set('members', $members);
-            $group->save();
-        }
-
-        try {
-            $result = $this->_resource->save();
-        } catch (Exception $e) {
-            throw new Kronolith_Exception(sprintf(_("Unable to save resource \"%s\": %s"), $new_name, $e->getMessage()));
-        }
-
-        return $this->_resource;
-    }
-
-}
diff --git a/kronolith/lib/Forms/EditResourceGroup.php b/kronolith/lib/Forms/EditResourceGroup.php
deleted file mode 100644 (file)
index 2feb6c0..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-/**
- * Horde_Form for editing resource groups.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_EditResourceGroupForm class provides the form for editing
- * resource groups.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael J. Rubinsky <mrubinsk@horde.org>
- * @package Kronolith
- */
-class Kronolith_EditResourceGroupForm extends Horde_Form
-{
-    /**
-     * Resource group being edited.
-     *
-     * @var Kronolith_Resource_Single
-     */
-    protected $_resource;
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function __construct($vars, $resource)
-    {
-        $this->_resource = $resource;
-        parent::Horde_Form($vars, sprintf(_("Edit %s"), $resource->get('name')));
-
-        $resources = Kronolith::getDriver('Resource')->listResources(Horde_Perms::READ, array('type' => Kronolith_Resource::TYPE_SINGLE));
-        $enum = array();
-        foreach ($resources as $r) {
-            $enum[$r->getId()] = htmlspecialchars($r->get('name'));
-        }
-
-        $this->addHidden('', 'c', 'text', true);
-        $this->addVariable(_("Name"), 'name', 'text', true);
-        $this->addVariable(_("Description"), 'description', 'longtext', false, false, null, array(4, 60));
-        $this->addVariable(_("Resources"), 'members', 'multienum', false, false, null, array('enum' => $enum));
-        $this->setButtons(array(_("Save")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $original_name = $this->_resource->get('name');
-        $new_name = $this->_vars->get('name');
-        $this->_resource->set('name', $new_name);
-        $this->_resource->set('description', $this->_vars->get('description'));
-        $this->_resource->set('members', $this->_vars->get('members'));
-
-        try {
-            $this->_resource->save();
-        } catch (Exception $e) {
-            throw new Kronolith_Exception(sprintf(_("Unable to save resource \"%s\": %s"), $new_name, $e->getMessage()));
-        }
-
-        return $this->_resource;
-    }
-
-}
diff --git a/kronolith/lib/Forms/SubscribeRemoteCalendar.php b/kronolith/lib/Forms/SubscribeRemoteCalendar.php
deleted file mode 100644 (file)
index 3865984..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/**
- * Horde_Form for subscribing to remote calendars.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_SubscribeRemoteCalendarForm class provides the form for
- * subscribing to remote calendars.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Kronolith
- */
-class Kronolith_SubscribeRemoteCalendarForm extends Horde_Form
-{
-    public function __construct($vars)
-    {
-        parent::Horde_Form($vars, _("Subscribe to a Remote Calendar"));
-
-        $this->addVariable(_("Name"), 'name', 'text', true);
-        $this->addVariable(_("Color"), 'color', 'colorpicker', false);
-        $this->addVariable(_("URL"), 'url', 'text', true);
-        $this->addVariable(_("Description"), 'desc', 'longtext', false, false, null, array(4, 60));
-        $this->addVariable(_("Username"), 'user', 'text', false);
-        $this->addVariable(_("Password"), 'password', 'password', false);
-
-        $this->setButtons(array(_("Subscribe")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        $info = array();
-        foreach (array('name', 'url', 'user', 'password', 'color', 'desc') as $key) {
-            $info[$key] = $this->_vars->get($key);
-        }
-        Kronolith::subscribeRemoteCalendar($info);
-    }
-
-}
diff --git a/kronolith/lib/Forms/UnsubscribeRemoteCalendar.php b/kronolith/lib/Forms/UnsubscribeRemoteCalendar.php
deleted file mode 100644 (file)
index 773e115..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
- * Horde_Form for unsubscribing from remote calendars.
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @package Kronolith
- */
-
-/**
- * The Kronolith_UnsubscribeRemoteCalendarForm class provides the form for
- * unsubscribing from remote calendars.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Kronolith
- */
-class Kronolith_UnsubscribeRemoteCalendarForm extends Horde_Form
-{
-    public function __construct($vars, $calendar)
-    {
-        parent::Horde_Form($vars, sprintf(_("Unsubscribe from %s"), $calendar['name']));
-
-        $this->addHidden('', 'url', 'text', true);
-        $this->addVariable(sprintf(_("Really unsubscribe from the calendar \"%s\" (%s)?"), $calendar['name'], $calendar['url']), 'desc', 'description', false);
-
-        $this->setButtons(array(_("Unsubscribe"), _("Cancel")));
-    }
-
-    /**
-     * @throws Kronolith_Exception
-     */
-    public function execute()
-    {
-        // If cancel was clicked, return false.
-        if ($this->_vars->get('submitbutton') == _("Cancel")) {
-            return false;
-        }
-        return Kronolith::unsubscribeRemoteCalendar($this->_vars->get('url'));
-    }
-
-}
index 3a6ef7f..5280a2f 100644 (file)
@@ -20,10 +20,8 @@ if (!$registry->isAdmin()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/CreateResource.php';
-
 $vars = Horde_Variables::getDefaultVariables();
-$form = new Kronolith_CreateResourceForm($vars);
+$form = new Kronolith_Form_CreateResource($vars);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index 7894c6e..2a18341 100644 (file)
@@ -15,8 +15,6 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/DeleteResource.php';
-
 // Exit if this isn't an authenticated administrative user.
 if (!$registry->isAdmin()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
index 4518f20..ff45015 100644 (file)
@@ -15,8 +15,6 @@ if (Kronolith::showAjaxView()) {
     Horde::url('', true)->redirect();
 }
 
-require_once KRONOLITH_BASE . '/lib/Forms/EditResource.php';
-
 // Exit if this isn't an authenticated administrative user.
 if (!$registry->isAdmin()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
@@ -33,7 +31,7 @@ try {
     $notification->push($e, 'horde.error');
     Horde::url('resources/', true)->redirect();
 }
-$form = new Kronolith_EditResourceForm($vars, $resource);
+$form = new Kronolith_Form_EditResource($vars, $resource);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index 4ce77a3..d63ecb0 100644 (file)
 require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('kronolith');
 
-require_once KRONOLITH_BASE . '/lib/Forms/CreateResourceGroup.php';
-
 // Exit if this isn't an authenticated, administrative user
 if (!$registry->isAdmin()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$form = new Kronolith_CreateResourceGroupForm($vars);
+$form = new Kronolith_Form_CreateResourceGroup($vars);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {
index 53af12a..097574c 100644 (file)
@@ -11,8 +11,6 @@
 require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('kronolith');
 
-require_once KRONOLITH_BASE . '/lib/Forms/DeleteResourceGroup.php';
-
 // Exit if this isn't an authenticated administrative user.
 if (!$registry->isAdmin()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
@@ -30,7 +28,7 @@ try {
     Horde::url('resources/groups/', true)->redirect();
 }
 
-$form = new Kronolith_DeleteResourceGroupForm($vars, $resource);
+$form = new Kronolith_Form_DeleteResourceGroup($vars, $resource);
 
 // Execute if the form is valid (must pass with POST variables only).
 if ($form->validate(new Horde_Variables($_POST))) {
index 033635f..0827cb1 100644 (file)
@@ -11,8 +11,6 @@
 require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('kronolith');
 
-require_once KRONOLITH_BASE . '/lib/Forms/EditResourceGroup.php';
-
 // Exit if this isn't an authenticated administrative user.
 if (!$registry->isAdmin()) {
     Horde::url($prefs->getValue('defaultview') . '.php', true)->redirect();
@@ -29,7 +27,7 @@ try {
     $notification->push($e, 'horde.error');
     Horde::url('resources/groups/', true)->redirect();
 }
-$form = new Kronolith_EditResourceGroupForm($vars, $group);
+$form = new Kronolith_Form_EditResourceGroup($vars, $group);
 
 // Execute if the form is valid.
 if ($form->validate($vars)) {