diff --git a/controllers/myplugins.php b/controllers/myplugins.php index e4f87d4091f1fdbce0c44a79c895a85ecb4e56db..ca345e1bee93d412c7ea74f564270ef2a4656a36 100755 --- a/controllers/myplugins.php +++ b/controllers/myplugins.php @@ -167,4 +167,15 @@ class MypluginsController extends MarketController $this->redirect('presenting/details/' . $this->release->plugin->getId()); } + + public function delete_action($plugin_id) { + $this->marketplugin = MarketPlugin::find($plugin_id); + if (Request::submitted('delete') && $this->marketplugin->isWritable()) { + CSRFProtection::verifyUnsafeRequest(); + $this->marketplugin->delete(); + $this->redirect('myplugins/overview'); + } + } + + } \ No newline at end of file diff --git a/controllers/presenting.php b/controllers/presenting.php index 6c8121df042d6eb038ac5fd2c8caa00983fb407a..720b3736952e47e942c11328bfed9898806f33a1 100755 --- a/controllers/presenting.php +++ b/controllers/presenting.php @@ -163,12 +163,14 @@ class PresentingController extends MarketController public function details_action($plugin_id) { Navigation::addItem('/pluginmarket/presenting/details', new AutoNavigation(_('Details'), $this->url_for('presenting/details/'.$plugin_id))); $this->marketplugin = new MarketPlugin($plugin_id); + if (Request::isPost() && Request::submitted("delete_plugin") && $this->marketplugin->isRootable()) { $this->marketplugin->delete(); PageLayout::postMessage(MessageBox::success(_("Plugin wurde gelöscht."))); $this->redirect('presenting/overview'); return; } + $this->marketplugin['rating'] = $this->marketplugin->calculateRating(); $this->marketplugin->store(); @@ -342,5 +344,4 @@ class PresentingController extends MarketController } - } diff --git a/views/myplugins/delete.php b/views/myplugins/delete.php new file mode 100644 index 0000000000000000000000000000000000000000..bc836ca852d9aee2453c43627a0c785028e021ff --- /dev/null +++ b/views/myplugins/delete.php @@ -0,0 +1,8 @@ +<form method="post" action="<?= $controller->url_for('myplugins/delete/' . $marketplugin->getId()) ?>"> + <?= CSRFProtection::tokenTag() ?> + <p><?= sprintf(_('Soll das Plugin %s wirklich unwiederruflich gelöscht werden?'), htmlReady($marketplugin->name)) ?></p> + + <div data-dialog-button> + <?= \Studip\Button::create(_('Endgültig löschen'), 'delete') ?> + </div> +</form> \ No newline at end of file diff --git a/views/presenting/details.php b/views/presenting/details.php index b5f5408f158749f93095532588a3159a624fdffe..e79791bf06ca1da4ae967fb4905ec64c45683f93 100755 --- a/views/presenting/details.php +++ b/views/presenting/details.php @@ -295,16 +295,11 @@ if ($icon) { <div style="text-align: center"> <? if ($marketplugin->isWritable()) : ?> + <?= \Studip\LinkButton::create(_("Plugin löschen"), PluginEngine::getURL($plugin, array(), 'myplugins/delete/' . $marketplugin->getId()), array('data-dialog' => 1)) ?> <?= \Studip\LinkButton::create(_("bearbeiten"), PluginEngine::getURL($plugin, array(), "myplugins/edit/" . $marketplugin->getId()), array('data-dialog' => 1)) ?> <?= \Studip\LinkButton::create(_("Release hinzufügen"), PluginEngine::getURL($plugin, array(), "myplugins/add_release/" . $marketplugin->getId()), array('data-dialog' => 1)) ?> <? endif ?> <? if ($marketplugin['user_id'] !== $GLOBALS['user']->id) : ?> <?= \Studip\LinkButton::create(_("Plugin abonnieren"), PluginEngine::getURL($plugin, array(), "presenting/register_for_pluginnews/" . $marketplugin->getId()), array('title' => _("Neuigkeiten des Plugins per Nachricht bekommen."), 'data-dialog' => "1")) ?> <? endif ?> -<? if ($marketplugin->isRootable()) : ?> - <form action="?" method="post" style="display: inline-block; margin: 0px;"> - <input type="hidden" name="plugin_id" value="<?= htmlReady($marketplugin->getId()) ?>"> - <?= \Studip\Button::create(_("Löschen"), "delete_plugin", array('onclick' => "return window.confirm('"._("Plugin wirklich unwiderrufbar löschen?")."');")) ?> - </form> -<? endif ?> </div>