$p = $pm->getPluginByName('docman');
if ($p && $pm->isPluginAvailable($p)) {
    // Need to setup the controller so the notification & logging works (setup in controler constructor)
    $controler = new Docman_Controller($p, $p->getPluginPath(), $p->getThemePath(), $request);
} else {
    $GLOBALS['Response']->redirect('/');
}
$func = $request->getValidated('func', new Valid_WhiteList('func', array('confirm_restore_item', 'confirm_restore_version')));
$groupId = $request->getValidated('group_id', 'uint', 0);
$id = $request->getValidated('id', 'uint', 0);
if ($request->existAndNonEmpty('func')) {
    switch ($func) {
        case 'confirm_restore_item':
            $itemFactory = new Docman_ItemFactory($groupId);
            $item = $itemFactory->getItemFromDb($id, array('ignore_deleted' => true));
            if ($itemFactory->restore($item)) {
                $url = $p->getPluginPath() . '/?group_id=' . $groupId . '&action=details&id=' . $id . '&section=properties';
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_docman', 'item_restored', array($url)), CODENDI_PURIFIER_DISABLED);
                $GLOBALS['Response']->redirect('/admin/show_pending_documents.php?group_id=' . $groupId . '&focus=item');
            } else {
                exit_error($Language->getText('plugin_docman', 'error'), $Language->getText('plugin_docman', 'item_not_restored'));
            }
            break;
        case 'confirm_restore_version':
            $versionFactory = new Docman_VersionFactory();
            $version = $versionFactory->getSpecificVersionById($id);
            if ($versionFactory->restore($version)) {
                $url = $p->getPluginPath() . '/?group_id=' . $groupId . '&action=details&id=' . $version->getItemId() . '&section=history';
                $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_docman', 'version_restored', array($url)), CODENDI_PURIFIER_DISABLED);
                $GLOBALS['Response']->redirect('/admin/show_pending_documents.php?group_id=' . $groupId . '&focus=version');
            } else {