Skip to content
Snippets Groups Projects
Commit fb2e983b authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

add reviews by Root

parent fc4ea3e6
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,10 @@ class PluginMarket extends StudIPPlugin implements SystemPlugin {
}
}
}
if ($GLOBALS['perm']->have_perm("root")) {
$approving = new Navigation(_("Qualittssicherung"), 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"));
......
......@@ -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 'Qualittssicherung'.")
);
}
}
}
public function isWritable($user_id = null) {
$user_id || $user_id = $GLOBALS['user']->id;
return $this['user_id'] === $user_id;
......
<?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") ? _("Begrndung:")."\n\n".Request::get("review") : _("Ein ausfhrliches 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
<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 Qualittssicherung") ?></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);
<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>
<?= _("Begrndung") ?>
<textarea name="review"></textarea>
</label>
</fieldset>
<div data-dialog-button>
<?= \Studip\Button::create(_("Review abschicken")) ?>
</div>
</form>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment