/** * Restore to diff */ public function _handler_restore($handler_id, array $args, array &$data) { $this->_guid = $args[0]; $this->_args = $args; $this->_load_object(); $this->_object->require_do('midgard:update'); // TODO: set another privilege for restoring? // Ensure we get the correct styles midcom::get('style')->prepend_component_styledir('no.bergfald.rcs'); $this->_prepare_toolbars($args[1]); if ($this->_backend->version_exists($args[1]) && $this->_backend->restore_to_revision($args[1])) { midcom::get('uimessages')->add(midcom::get('i18n')->get_string('no.bergfald.rcs', 'no.bergfald.rcs'), sprintf(midcom::get('i18n')->get_string('restore to version %s successful', 'no.bergfald.rcs'), $args[1]), 'ok'); return new midcom_response_relocate(midcom::get('permalinks')->create_permalink($this->_object->guid)); } else { throw new midcom_error(sprintf(midcom::get('i18n')->get_string('restore to version %s failed, reason %s', 'no.bergfald.rcs'), $args[1], $this->_backend->get_error())); } }
/** * Restore to diff * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. * @return boolean Indicating success. */ public function _handler_restore($handler_id, array $args, array &$data) { midcom::get('auth')->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); $this->_guid = $args[0]; $data['args'] = $args; $this->_load_object(); // Store the arguments for later use $data['args'] = $args; $this->_object->require_do('midgard:update'); // TODO: set another privilege for restoring? $this->_prepare_toolbars($args[1]); if ($this->_backend->version_exists($args[1]) && $this->_backend->restore_to_revision($args[1])) { midcom::get('uimessages')->add($this->_l10n->get('no.bergfald.rcs'), sprintf($this->_l10n->get('restore to version %s successful'), $args[1])); return new midcom_response_relocate("__mfa/asgard/object/view/{$this->_guid}/"); } else { throw new midcom_error(sprintf($this->_l10n->get('restore to version %s failed, reason %s'), $args[1], $this->_backend->get_error())); } // Load the toolbars $this->_rcs_toolbar(); }