$this->allowEdit = $this->koward->hasAccess('object/edit/' . $this->object_type,
Koward::PERM_EDIT);
- $actions = $this->object->getActions();
- if (!empty($actions)) {
- $buttons = array();
- foreach ($actions as $action) {
- if (isset($this->koward->objects[$this->object_type]['actions'][$action])
- && $this->koward->hasAccess('object/action/' . $this->object_type . '/' . $action,
- Koward::PERM_EDIT)) {
- $buttons[] = $this->koward->objects[$this->object_type]['actions'][$action];
- }
- }
- }
-
+ $buttons = $this->_getButtons($this->object, $this->object_type);
if (!empty($buttons)) {
try {
- $this->actions = new Koward_Form_Actions($buttons);
+ $this->actions = new Koward_Form_Actions($this->object, $buttons);
$this->post = $this->urlFor(array('controller' => 'object',
'action' => 'view',
/** Reload the object */
$this->object = $this->koward->getObject($this->params->id);
- $actions = $this->object->getActions();
- $this->actions = new Koward_Form_Actions($this->object);
+ $buttons = $this->_getButtons($this->object, $this->object_type);
+ $this->actions = new Koward_Form_Actions($this->object, $buttons);
}
} catch (Exception $e) {
$this->koward->notification->push($e->getMessage(), 'horde.error');
$this->render();
}
+ private function _getButtons(&$object, $type)
+ {
+ $actions = $object->getActions();
+ if (!empty($actions)) {
+ $buttons = array();
+ foreach ($actions as $action) {
+ if (isset($this->koward->objects[$type]['actions'][$action])
+ && $this->koward->hasAccess('object/action/' . $type . '/' . $action,
+ Koward::PERM_EDIT)) {
+ $buttons[] = $this->koward->objects[$type]['actions'][$action];
+ }
+ }
+ }
+ return $buttons;
+ }
+
public function add()
{
$this->object = null;
*/
protected $koward;
- public function __construct($buttons)
+ public function __construct(&$object, $buttons)
{
$this->koward = &Koward::singleton();
$this->setTitle(_("Object actions"));
+ $this->object = $object;
+
if (!empty($buttons)) {
$this->setButtons($buttons);
}
$submit = Util::getFormData('submitbutton');
if (!empty($submit)) {
- foreach ($this->koward->objects[$this->type]['actions'] as $action => $label) {
+ $type = $this->koward->getType($this->object);
+ foreach ($this->koward->objects[$type]['actions'] as $action => $label) {
if ($submit == $label) {
$this->object->$action();
}