From ec59f3878a9c02a1464e649b5fc0c48d0e93064b Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 28 Apr 2009 22:57:16 +0200 Subject: [PATCH] The form to allow object actions. --- koward/lib/Form/Actions.php | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 koward/lib/Form/Actions.php diff --git a/koward/lib/Form/Actions.php b/koward/lib/Form/Actions.php new file mode 100644 index 000000000..73cd95203 --- /dev/null +++ b/koward/lib/Form/Actions.php @@ -0,0 +1,63 @@ +koward = &Koward_Koward::singleton(); + + $this->object = &$object; + + parent::Horde_Form(Variables::getDefaultVariables()); + + $this->setTitle(_("Object actions")); + + $class_name = get_class($this->object); + foreach ($this->koward->objects as $name => $config) { + if ($config['class'] == $class_name) { + $this->type = $name; + if (!empty($config['preferred'])) { + break; + } + } + } + + $buttons = array(); + foreach ($this->object->getActions() as $action) { + if (isset($this->koward->objects[$this->type]['actions'][$action])) { + $buttons[] = $this->koward->objects[$this->type]['actions'][$action]; + } + } + + if (!empty($buttons)) { + $this->setButtons($buttons); + } + } + + function &execute() + { + require_once 'Horde/Util.php'; + + $submit = Util::getFormData('submitbutton'); + if (!empty($submit)) { + foreach ($this->koward->objects[$this->type]['actions'] as $action => $label) { + if ($submit == $label) { + $this->object->$action(); + } + } + } + } +} -- 2.11.0