diff --git a/PluginMarket.class.php b/PluginMarket.class.php index 5c1a48c1ccf7f1047a850a8b76f9c28f4bb5a895..e578f496d7267025f9df638db6a3a3e1c40b6b6e 100644 --- a/PluginMarket.class.php +++ b/PluginMarket.class.php @@ -23,6 +23,10 @@ class PluginMarket extends StudIPPlugin implements SystemPlugin { } } } + if ($GLOBALS['perm']->have_perm("root")) { + $approving = new Navigation(_("Qualit�tssicherung"), PluginEngine::getURL($this, array(), "approving/overview")); + $top->addSubNavigation("approving", $approving); + } Navigation::addItem("/pluginmarket", $top); $loginlink = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "presenting/overview")); diff --git a/classes/MarketPlugin.class.php b/classes/MarketPlugin.class.php index 41e6d4273615e54cb366312234b939a642422bac..176a9a0dddabde23213124384463c2b7ab4178a5 100644 --- a/classes/MarketPlugin.class.php +++ b/classes/MarketPlugin.class.php @@ -21,6 +21,25 @@ class MarketPlugin extends SimpleORMap { parent::configure($config); } + public function __construct($id = null) + { + $this->registerCallback('before_store', 'requestReview'); + parent::__construct($id); + } + + public function requestReview() { + if ($this->content['publiclyvisible'] && !$this->content_db['publiclyvisible'] && !$this['approved']) { + $messaging = new messaging(); + foreach (User::findByPerms("root") as $rootuser) { + $messaging->sendSystemMessage( + $rootuser['user_id'], + _("Plugin %s braucht ein Review"), + _("Auf dem Marktplatz wurde ein neues Plugin �ffentlich geschaltet. Es kann allerdings erst �ffentlich auf dem Marktplatz erscheinen, wenn Sie das Plugin einmal reviewt haben und freischalten. Gehen Sie auf den Pluginmarktplatz und den Reiter 'Qualit�tssicherung'.") + ); + } + } + } + public function isWritable($user_id = null) { $user_id || $user_id = $GLOBALS['user']->id; return $this['user_id'] === $user_id; diff --git a/controllers/approving.php b/controllers/approving.php new file mode 100644 index 0000000000000000000000000000000000000000..6fdf680ee61c4b315b61eb20f75858a46db9bb26 --- /dev/null +++ b/controllers/approving.php @@ -0,0 +1,68 @@ +<?php +require_once 'app/controllers/plugin_controller.php'; + +class ApprovingController extends PluginController { + + function before_filter(&$action, &$args) + { + parent::before_filter($action, $args); + if (!$GLOBALS['perm']->have_perm("root")) { + throw new AcessDeniedException("Kein Zutritt"); + } + + Navigation::activateItem("/pluginmarket/approving"); + $this->set_content_type('text/html;charset=windows-1252'); + PageLayout::addStylesheet($this->plugin->getPluginURL()."/assets/pluginmarket.css"); + } + + public function overview_action() + { + $this->plugins = MarketPlugin::findBySQL("approved = 0 AND publiclyvisible = 1 ORDER BY mkdate DESC"); + } + + public function review_action($plugin_id) { + $this->marketplugin = new MarketPlugin($plugin_id); + if ($this->marketplugin['approved']) { + throw new Exception("Plugin ist schon reviewt."); + } + if (Request::isXhr()) { + $this->response->add_header('X-Title', _("Review schreiben")); + $this->set_layout(null); + } + } + + public function approve_action($plugin_id) { + $this->marketplugin = new MarketPlugin($plugin_id); + if ($this->marketplugin['approved']) { + throw new Exception("Plugin ist schon reviewt."); + } + $this->marketplugin['approved'] = (int) Request::int("approved"); + if (!$this->marketplugin['approved']) { + $this->marketplugin['publiclyvisible'] = 0; + } + $this->marketplugin->store(); + + $messaging = new messaging(); + $messaging->insert_message( + sprintf(_("Ihr Plugin %s wurde reviewt:"), $this->marketplugin['name']) + ."\n\n" + .($this->marketplugin['approved'] ? _("Es ist in den Marktplatz aufgenommen worden!") : _("Es ist leider noch nicht in den Marktplatz aufgenommen.")) + ."\n\n" + .(Request::get("review") ? _("Begr�ndung:")."\n\n".Request::get("review") : _("Ein ausf�hrliches Review wurde nicht angegeben und muss bei Bedarf direkt angefragt werden.")), + get_username($this->marketplugin['user_id']), + '', + '', + '', + '', + '', + _("Pluginreview"), + true, + 'normal', + "pluginreview" + ); + + PageLayout::postMessage(MessageBox::success(_("Review wurde gespeichert."))); + $this->redirect("pluginmarket/approving/overview"); + } + +} \ No newline at end of file diff --git a/views/approving/overview.php b/views/approving/overview.php new file mode 100644 index 0000000000000000000000000000000000000000..28ffb3a18dd4df257b43d253d7a141971501df09 --- /dev/null +++ b/views/approving/overview.php @@ -0,0 +1,48 @@ +<table class="default"> + <thead> + <tr> + <th><?= _("Name") ?></th> + <th><?= _("Letztes Update") ?></th> + <th></th> + </tr> + </thead> + <tbody> + <? if (count($plugins)) : ?> + <? foreach ($plugins as $marketplugin) : ?> + <tr> + <td> + <a href="<?= PluginEngine::getLink($plugin, array(), "presenting/details/".$marketplugin->getId()) ?>"> + <?= htmlReady($marketplugin['name']) ?> + </a> + </td> + <td> + <? + $chdate = $marketplugin['chdate']; + foreach ($marketplugin->releases as $release) { + $chdate = max($chdate, $release['chdate']); + } + ?> + <?= date("j.n.Y, G:i", $chdate) ?> <?= _("Uhr") ?> + </td> + <td> + <a href="<?= PluginEngine::getLink($plugin, array(), "approving/review/".$marketplugin->getId()) ?>" data-dialog> + <?= Assets::img("icons/20/blue/assessment") ?> + </a> + </td> + </tr> + <? endforeach ?> + <? else : ?> + <tr> + <td colspan="2" style="text-align: center;"><?= _("Keine Plugins warten auf eine Qualit�tssicherung") ?></td> + </tr> + <? endif ?> + </tbody> +</table> + +<? +$sidebar = Sidebar::Get(); +$sidebar->setImage(Assets::image_path("sidebar/plugin-sidebar.png")); +$actions = new ActionsWidget(); +//$actions->addLink(_("Neues Plugin eintragen"), PluginEngine::getURL($plugin, array(), "myplugins/add"), null, array('data-dialog' => 1)); +//$sidebar->addWidget($actions); + diff --git a/views/approving/review.php b/views/approving/review.php new file mode 100644 index 0000000000000000000000000000000000000000..abe20abeb330937f2d4a0a545bb73f1f79dfd117 --- /dev/null +++ b/views/approving/review.php @@ -0,0 +1,18 @@ +<form action="<?= PluginEngine::getLink($plugin, array(), "approving/approve/".$marketplugin->getId()) ?>" method="post" class="studip_form"> + <fieldset> + <legend> + <?= _("Review schreiben") ?> + </legend> + <label> + <?= _("Plugin wird akzeptiert") ?> + <input type="checkbox" name="approved" value="1"> + </label> + <label> + <?= _("Begr�ndung") ?> + <textarea name="review"></textarea> + </label> + </fieldset> + <div data-dialog-button> + <?= \Studip\Button::create(_("Review abschicken")) ?> + </div> +</form> \ No newline at end of file