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')) {
}
$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)) {
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();
$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))) {
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();
$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)) {
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')) {
$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)) {
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)) {
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')) {
$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))) {
--- /dev/null
+<?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);
+ }
+
+}
--- /dev/null
+<?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();
+ }
+ }
+ }
+
+}
--- /dev/null
+<?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));
+ }
+
+}
--- /dev/null
+<?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);
+ }
+
+}
--- /dev/null
+<?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()));
+ }
+ }
+
+}
--- /dev/null
+<?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()));
+ }
+ }
+
+}
--- /dev/null
+<?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);
+ }
+
+}
--- /dev/null
+<?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')));
+ }
+
+}
--- /dev/null
+<?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;
+ }
+
+}
--- /dev/null
+<?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;
+ }
+
+}
--- /dev/null
+<?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);
+ }
+
+}
--- /dev/null
+<?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'));
+ }
+
+}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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();
- }
- }
- }
-
-}
+++ /dev/null
-<?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));
- }
-
-}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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()));
- }
- }
-
-}
+++ /dev/null
-<?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()));
- }
- }
-
-}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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')));
- }
-
-}
+++ /dev/null
-<?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;
- }
-
-}
+++ /dev/null
-<?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;
- }
-
-}
+++ /dev/null
-<?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);
- }
-
-}
+++ /dev/null
-<?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'));
- }
-
-}
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)) {
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();
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();
$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)) {
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)) {
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();
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))) {
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();
$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)) {