Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #61 from derfl0/master
Browse files Browse the repository at this point in the history
#20 let multiple plugin usages be reported

Besten Dank!
  • Loading branch information
Krassmus committed Nov 27, 2015
2 parents 91ebf8d + 8622d6a commit 3d2328a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
20 changes: 20 additions & 0 deletions controllers/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ public function release_action($release_id)
$this->render_text("Insecure request.");
}
}

public function usage_action() {
$this->plugins = MarketPlugin::findManyByName(Request::getArray('plugins'));
$this->mostlikely = MarketPluginUsage::findOneBySQL('user_id = ? GROUP BY name ORDER BY count(*) DESC', array(User::findCurrent()->id))->name;
}

public function save_usage_action() {
// delete old usage
MarketPluginUsage::deleteBySQL('user_id = ? AND name = ?', array(User::findCurrent()->id, Request::get('tag')));

// create new usages
foreach (Request::getArray('plugins') as $pluginid) {
MarketPluginUsage::create(array(
'plugin_id' => $pluginid,
'user_id' => User::findCurrent()->id,
'name' => Request::get('tag')
));
$this->done++;
}
}

protected function verify_secret($secret)
{
Expand Down
3 changes: 3 additions & 0 deletions views/update/save_usage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
<?= sprintf(_('%s Benutzungen eingetragen'), $done) ?>
</p>
27 changes: 27 additions & 0 deletions views/update/usage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<form class="studip_form" method="post" action="<?= PluginEngine::getLink($plugin, array(), 'update/save_usage/') ?>">
<fieldset>
<legend>
<?= _('Pluginnutzung') ?>
</legend>

<fieldset>
<legend>
<?= _('Plugins') ?>
</legend>
<? foreach ($plugins as $plugin): ?>
<label>
<input type="checkbox" name="plugins[]" value="<?= $plugin->id ?>" checked>
<?= htmlReady($plugin->name); ?>
</label>
<? endforeach; ?>
</fieldset>

<label>
<?= _('In Benutzung bei') ?>
<input type="text" name="tag" value="<?= htmlReady($mostlikely) ?>">
</label>

<?= Studip\Button::create(_('Eintragen')) ?>
</fieldset>
</form>

0 comments on commit 3d2328a

Please sign in to comment.