function &execute() { $submit = Horde_Util::getFormData('submitbutton'); if (!empty($submit)) { $type = $this->koward->getType($this->object); foreach ($this->koward->objects[$type]['actions'] as $action => $label) { if ($submit == $label) { return $action; } } } }
public function __construct(&$vars, &$object, $params = array()) { $this->koward =& Koward::singleton(); $this->object =& $object; parent::__construct($vars); $type = false; if (empty($this->object)) { $title = _("Add Object"); $this->setButtons(_("Add")); foreach ($this->koward->objects as $key => $config) { if (!$this->koward->hasAccess('object/add/' . $key, Koward::PERM_EDIT)) { continue; } $options[$key] = $config['label']; } $v = $this->addVariable(_("Choose an object type"), 'type', 'enum', true, false, null, array($options, true)); $action = Horde_Form_Action::factory('submit'); $v->setAction($action); $v->setOption('trackchange', true); if (is_null($vars->get('formname')) && $vars->get($v->getVarName()) != $vars->get('__old_' . $v->getVarName())) { $this->koward->notification->push(sprintf(_("Selected object type \"%s\"."), $object_conf[$vars->get('type')]['label']), 'horde.message'); } $type = $vars->get('type'); } else { $title = _("Edit Object"); $type = $this->koward->getType($this->object); if (empty($type)) { throw new Koward_Exception('Undefined object class!'); } if (!$this->isSubmitted()) { $vars->set('type', $type); $keys = array_keys($this->_getFields($this->koward->objects[$type])); $vars->set('object', $this->object->toHash($keys)); $this->setButtons(true); } } if (isset($params['title'])) { $title = $params['title']; } $this->setTitle($title); if (!empty($type)) { $this->_addFields($this->koward->objects[$type]); } }