From: Michael J. Rubinsky Date: Thu, 27 Jan 2011 17:23:37 +0000 (-0500) Subject: Horde 4 style autoloading for kronolith's forms X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=fb33270d9e0978e6efbf62b9970b4c225e42b0c9;p=horde.git Horde 4 style autoloading for kronolith's forms --- diff --git a/kronolith/calendars/create.php b/kronolith/calendars/create.php index 0d222f35f..8d88ccf59 100644 --- a/kronolith/calendars/create.php +++ b/kronolith/calendars/create.php @@ -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)) { diff --git a/kronolith/calendars/delete.php b/kronolith/calendars/delete.php index 48eca31fc..6f2c24ecb 100644 --- a/kronolith/calendars/delete.php +++ b/kronolith/calendars/delete.php @@ -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))) { diff --git a/kronolith/calendars/edit.php b/kronolith/calendars/edit.php index c4c7ebf90..36a90399d 100644 --- a/kronolith/calendars/edit.php +++ b/kronolith/calendars/edit.php @@ -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)) { diff --git a/kronolith/calendars/remote_edit.php b/kronolith/calendars/remote_edit.php index ab6ffa870..96dba3497 100644 --- a/kronolith/calendars/remote_edit.php +++ b/kronolith/calendars/remote_edit.php @@ -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)) { diff --git a/kronolith/calendars/remote_subscribe.php b/kronolith/calendars/remote_subscribe.php index fae59838d..c73265be6 100644 --- a/kronolith/calendars/remote_subscribe.php +++ b/kronolith/calendars/remote_subscribe.php @@ -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)) { diff --git a/kronolith/calendars/remote_unsubscribe.php b/kronolith/calendars/remote_unsubscribe.php index a7780f81f..7f0dfb7ac 100644 --- a/kronolith/calendars/remote_unsubscribe.php +++ b/kronolith/calendars/remote_unsubscribe.php @@ -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 index 000000000..3f810bdde --- /dev/null +++ b/kronolith/lib/Form/CreateCalendar.php @@ -0,0 +1,47 @@ + + * @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 index 000000000..4a9d857a5 --- /dev/null +++ b/kronolith/lib/Form/CreateResource.php @@ -0,0 +1,76 @@ + + * @author Michael J. Rubinsky + * @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 index 000000000..ff3ddb4f0 --- /dev/null +++ b/kronolith/lib/Form/CreateResourceGroup.php @@ -0,0 +1,47 @@ + + * @author Michael J. Rubinsky + * @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 index 000000000..849595bb7 --- /dev/null +++ b/kronolith/lib/Form/DeleteCalendar.php @@ -0,0 +1,49 @@ + + * @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 index 000000000..f6ea739e2 --- /dev/null +++ b/kronolith/lib/Form/DeleteResource.php @@ -0,0 +1,61 @@ + + * @author Michael J. Rubinsky + * @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 index 000000000..46fad26d4 --- /dev/null +++ b/kronolith/lib/Form/DeleteResourceGroup.php @@ -0,0 +1,62 @@ + + * @author Michael J. Rubinsky + * @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 index 000000000..e20b44d5f --- /dev/null +++ b/kronolith/lib/Form/EditCalendar.php @@ -0,0 +1,54 @@ + + * @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 index 000000000..f5b57d524 --- /dev/null +++ b/kronolith/lib/Form/EditRemoteCalendar.php @@ -0,0 +1,48 @@ + + * @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 index 000000000..f72e4b00b --- /dev/null +++ b/kronolith/lib/Form/EditResource.php @@ -0,0 +1,115 @@ + + * @author Michael J. Rubinsky + * @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 index 000000000..d430c01ff --- /dev/null +++ b/kronolith/lib/Form/EditResourceGroup.php @@ -0,0 +1,69 @@ + + * @author Michael J. Rubinsky + * @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 index 000000000..028a06f1c --- /dev/null +++ b/kronolith/lib/Form/SubscribeRemoteCalendar.php @@ -0,0 +1,46 @@ + + * @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 index 000000000..ad2d9cee5 --- /dev/null +++ b/kronolith/lib/Form/UnsubscribeRemoteCalendar.php @@ -0,0 +1,42 @@ + + * @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 index c9ae419b4..000000000 --- a/kronolith/lib/Forms/CreateCalendar.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @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 index a6cca6356..000000000 --- a/kronolith/lib/Forms/CreateResource.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @author Michael J. Rubinsky - * @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 index 5ca78eb03..000000000 --- a/kronolith/lib/Forms/CreateResourceGroup.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @author Michael J. Rubinsky - * @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 index c8ffce14f..000000000 --- a/kronolith/lib/Forms/DeleteCalendar.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @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 index 1bbd5a9ba..000000000 --- a/kronolith/lib/Forms/DeleteResource.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @author Michael J. Rubinsky - * @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 index 9290c08e7..000000000 --- a/kronolith/lib/Forms/DeleteResourceGroup.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @author Michael J. Rubinsky - * @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 index 5dff62dd1..000000000 --- a/kronolith/lib/Forms/EditCalendar.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @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 index 3052957d2..000000000 --- a/kronolith/lib/Forms/EditRemoteCalendar.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @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 index 2885aaaf9..000000000 --- a/kronolith/lib/Forms/EditResource.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @author Michael J. Rubinsky - * @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 index 2feb6c083..000000000 --- a/kronolith/lib/Forms/EditResourceGroup.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @author Michael J. Rubinsky - * @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 index 386598404..000000000 --- a/kronolith/lib/Forms/SubscribeRemoteCalendar.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @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 index 773e115c8..000000000 --- a/kronolith/lib/Forms/UnsubscribeRemoteCalendar.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @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')); - } - -} diff --git a/kronolith/resources/create.php b/kronolith/resources/create.php index 3a6ef7fcd..5280a2f44 100644 --- a/kronolith/resources/create.php +++ b/kronolith/resources/create.php @@ -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)) { diff --git a/kronolith/resources/delete.php b/kronolith/resources/delete.php index 7894c6e11..2a1834125 100644 --- a/kronolith/resources/delete.php +++ b/kronolith/resources/delete.php @@ -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(); diff --git a/kronolith/resources/edit.php b/kronolith/resources/edit.php index 4518f20a6..ff450156c 100644 --- a/kronolith/resources/edit.php +++ b/kronolith/resources/edit.php @@ -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)) { diff --git a/kronolith/resources/groups/create.php b/kronolith/resources/groups/create.php index 4ce77a368..d63ecb08e 100644 --- a/kronolith/resources/groups/create.php +++ b/kronolith/resources/groups/create.php @@ -11,15 +11,13 @@ 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)) { diff --git a/kronolith/resources/groups/delete.php b/kronolith/resources/groups/delete.php index 53af12a7e..097574ca3 100644 --- a/kronolith/resources/groups/delete.php +++ b/kronolith/resources/groups/delete.php @@ -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))) { diff --git a/kronolith/resources/groups/edit.php b/kronolith/resources/groups/edit.php index 033635fb4..0827cb162 100644 --- a/kronolith/resources/groups/edit.php +++ b/kronolith/resources/groups/edit.php @@ -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)) {