diff --git a/controllers/update.php b/controllers/update.php index f9a2425477f85176e136c5937445471ce519b327..8ff7d914ba85ae36de7651231fdcc85d41525b10 100755 --- a/controllers/update.php +++ b/controllers/update.php @@ -27,6 +27,26 @@ class UpdateController extends MarketController $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) { diff --git a/views/update/save_usage.php b/views/update/save_usage.php new file mode 100644 index 0000000000000000000000000000000000000000..f0279c6dd8e778fa74bcdba0312d5fd81dbaa1e5 --- /dev/null +++ b/views/update/save_usage.php @@ -0,0 +1,3 @@ +<p> + <?= sprintf(_('%s Benutzungen eingetragen'), $done) ?> +</p> \ No newline at end of file diff --git a/views/update/usage.php b/views/update/usage.php new file mode 100644 index 0000000000000000000000000000000000000000..3e31f3c74cace2b1d7403b544874be90e37a9aa3 --- /dev/null +++ b/views/update/usage.php @@ -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> +