diff --git a/PluginMarket.class.php b/PluginMarket.class.php index b39d88faa2cc2966f260d77b922b4240b04301f7..ecb7e874d6e9d382dd62743cb79516987059aad9 100644 --- a/PluginMarket.class.php +++ b/PluginMarket.class.php @@ -13,6 +13,15 @@ class PluginMarket extends StudIPPlugin implements SystemPlugin { if ($GLOBALS['perm']->have_perm("autor")) { $top->addSubNavigation("myplugins", new Navigation(_("Meine Plugins"), PluginEngine::getURL($this, array(), "myplugins/overview"))); } + if ($GLOBALS['perm']->have_perm("user")) { + $last_visit = object_get_visit(get_class($this), "plugin"); + if ($last_visit !== false) { + $badge_number = MarketPlugin::countBySql("mkdate > ?", array($last_visit)); + if ($badge_number > 0) { + $top->setBadgeNumber($badge_number); + } + } + } Navigation::addItem("/pluginmarket", $top); $loginlink = new Navigation($this->getDisplayTitle(), PluginEngine::getURL($this, array(), "presenting/overview")); diff --git a/classes/MarketRelease.class.php b/classes/MarketRelease.class.php index 1e6e6a99257fe6a1d9f389aa73aebc31d15e8d46..0c774dca680a6ba7db616018fdafa47812ada3b0 100644 --- a/classes/MarketRelease.class.php +++ b/classes/MarketRelease.class.php @@ -68,6 +68,10 @@ class MarketRelease extends SimpleORMap { return md5_file($this->getFilePath()); } + public function getSecurityHash() { + return md5($this->getId()."-".$this['mkdate']); + } + protected function installFromDirectory($dir) { $manifest = PluginManager::getInstance()->getPluginManifest($dir); $this['studip_min_version'] = $manifest['studipMinVersion']; diff --git a/controllers/myplugins.php b/controllers/myplugins.php index 62f81b552478a47f75ead190afdc522b2804ffeb..e58b6bed2999057b6cc6beec4995a4ca095353de 100644 --- a/controllers/myplugins.php +++ b/controllers/myplugins.php @@ -32,6 +32,14 @@ class MypluginsController extends PluginController { } } + public function edit_release_action($release_id) { + $this->release = new MarketRelease($release_id); + if (Request::isXhr()) { + $this->response->add_header('X-Title', _("Plugin bearbeiten")); + $this->set_layout(null); + } + } + public function save_action() { if (!Request::isPost()) { throw new Exception("Method not allowed. Try a POST request."); @@ -55,4 +63,21 @@ class MypluginsController extends PluginController { $this->redirect("pluginmarket/presenting/details/".$this->marketplugin->getId()); } + public function save_release_action() { + if (!Request::isPost()) { + throw new Exception("Method not allowed. Try a POST request."); + } + $this->release = new MarketRelease(Request::option("id")); + $release_data = Request::getArray("release"); + $this->release->setData($release_data); + if ($release_data['type'] === "zipfile") { + $this->release['repository_download_url'] = null; + } + $this->release->installFile(); + $this->release->store(); + + PageLayout::postMessage(MessageBox::success(_("Release wurde gespeichert."))); + $this->redirect("pluginmarket/presenting/details/".$this->release->plugin->getId()); + } + } \ No newline at end of file diff --git a/controllers/presenting.php b/controllers/presenting.php index 4d8b4f349d40a8641fabe5c04c488eb1da399255..aea04e2353036e2456a9ee685698cce06a6be523 100644 --- a/controllers/presenting.php +++ b/controllers/presenting.php @@ -8,10 +8,21 @@ class PresentingController extends PluginController { parent::before_filter($action, $args); Navigation::activateItem("/pluginmarket/presenting"); + if ($GLOBALS['perm']->have_perm("user")) { + object_set_visit(get_class($this->plugin), "plugin"); + } } public function overview_action() { - $this->plugins = MarketPlugin::findBySQL("1=1"); + + if ($GLOBALS['perm']->have_perm("user")) { + $last_visit = object_get_visit(get_class($this->plugin), "plugin"); + if ($last_visit !== false) { + $this->new_plugins = MarketPlugin::findBySql("mkdate > ? ORDER BY mkdate DESC", array($last_visit)); + } + } + + $this->plugins = MarketPlugin::findBySQL("1=1 ORDER BY name ASC"); } public function details_action($plugin_id) { diff --git a/controllers/update.php b/controllers/update.php index baa870912d92ebbe99c230950fa9fab29d573053..8e98dba944af50502fb468798b14627d2dfd0da7 100644 --- a/controllers/update.php +++ b/controllers/update.php @@ -13,6 +13,9 @@ class UpdateController extends PluginController { echo "OK"; die(); } + if ($release->getSecurityHash() === Request::get("s")) { + $release->installFile(); + } } } \ No newline at end of file diff --git a/views/myplugins/_edit_release.php b/views/myplugins/_edit_release.php new file mode 100644 index 0000000000000000000000000000000000000000..b9a093628d9e5d1c451aaa35bd06b82c21e01087 --- /dev/null +++ b/views/myplugins/_edit_release.php @@ -0,0 +1,65 @@ +<? +if (strpos($_SERVER['SERVER_NAME'], ':') !== false) { + list($_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT']) = + explode(':', $_SERVER['SERVER_NAME']); +} + +$DOMAIN_STUDIP = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; +$DOMAIN_STUDIP .= '://'.$_SERVER['SERVER_NAME']; + +if ($_SERVER['HTTPS'] == 'on' && $_SERVER['SERVER_PORT'] != 443 || + $_SERVER['HTTPS'] != 'on' && $_SERVER['SERVER_PORT'] != 80) { + $DOMAIN_STUDIP .= ':'.$_SERVER['SERVER_PORT']; +} + +?> + +<fieldset> + <legend> + <?= _("Release hinzuf�gen") ?> + </legend> + + <div> + <label> + <input type="radio" name="release[type]" value="zipfile"<?= !$release['repository_download_url'] ? " checked" : "" ?>> + <?= _("Als Datei") ?> + </label> + <label> + <input type="radio" name="release[type]" value="git"<?= $release['repository_download_url'] ? " checked" : "" ?>> + <?= _("Als Git-Branch") ?> + </label> + </div> + + <fieldset> + <legend> + <?= _("ZIP ausw�hlen") ?> + </legend> + <label> + <a style="cursor: pointer"> + <?= Assets::img("icons/20/blue/upload") ?> + <input type="file" name="release_file"> + </a> + </label> + </fieldset> + + <fieldset> + <legend> + <?= _("Git-Branch") ?> + </legend> + + <label> + <?= _("Download-URL des Branches oder des Tags") ?> + <input type="text" name="release[repository_download_url]" value="<?= htmlReady($release['repository_download_url']) ?>"> + </label> + <p class="info"> + <?= _("Github.com und gitlab bieten zu jedem Branch und Tag den Download als ZIP-Datei an. Klicken Sie dort mit rechter Maustaste auf den Downloadbutton und kopieren Sie die URL, um sie hier einzuf�gen. Nach dem Speichern hier k�nnen Sie auf github bzw. gitlab Webhooks einrichten, damit der Marktplatz sich automatisch die neuste Version des Plugins vom Repository holt. Damit ist das Plugin auf dem Pluginmarktplatz immer brandaktuell.") ?> + </p> + <? if (!$release->isNew()) : ?> + <p class="info"> + <?= _("Webhook-URL zum Einf�gen in github oder gitlab:") ?> + <input type="text" style="border: thin solid #cccccc; background-color: #eeeeee;" value="<?= $DOMAIN_STUDIP.URLHelper::getLink("plugins.php/pluginmarket/upate/".$release->getId(), array('s' => $release->getSecurityHash()), true) ?>"> + </p> + <? endif ?> + + </fieldset> +</fieldset> \ No newline at end of file diff --git a/views/myplugins/edit.php b/views/myplugins/edit.php index d37a4c0ca9af4d54373a2ac6ca6a2944ed1b75b7..d02c3d05511976a889e38eb230ab8a21c36d5b43 100644 --- a/views/myplugins/edit.php +++ b/views/myplugins/edit.php @@ -37,60 +37,7 @@ </div> </fieldset> - <fieldset> - <legend> - <?= _("Release hinzuf�gen") ?> - </legend> - - <label> - <?= _("Releasebezeichnung") ?> - <input type="text" name="release[version]" placeholder="<?= _("z.B. Rocky Raccoon 3.0.1") ?>"> - </label> - - <div> - <label> - <input type="radio" name="release[type]" value="zipfile"> - <?= _("Als Datei") ?> - </label> - <label> - <input type="radio" name="release[type]" value="git"> - <?= _("Als Git-Branch") ?> - </label> - <label> - <input type="radio" name="release[type]" value=""> - <?= _("Kein Release hinzuf�gen") ?> - </label> - </div> - - <fieldset> - <legend> - <?= _("ZIP ausw�hlen") ?> - </legend> - <label> - <a style="cursor: pointer"> - <?= Assets::img("icons/20/blue/upload") ?> - <input type="file" name="release_file"> - </a> - </label> - </fieldset> - - <fieldset> - <legend> - <?= _("Git-Branch") ?> - </legend> - - <label> - <?= _("Download-URL des Branches oder des Tags") ?> - <input type="text" name="release[repository_download_url]"> - </label> - <p class="info"> - <?= _("Github.com und gitlab bieten zu jedem Branch und Tag den Download als ZIP-Datei an. Klicken Sie dort mit rechter Maustaste auf den Downloadbutton und kopieren Sie die URL, um sie hier einzuf�gen. Nach dem Speichern hier k�nnen Sie auf github bzw. gitlab Webhooks einrichten, damit der Marktplatz sich automatisch die neuste Version des Plugins vom Repository holt. Damit ist das Plugin auf dem Pluginmarktplatz immer brandaktuell.") ?> - </p> - - </fieldset> - </fieldset> - - + <?= $this->render_partial("myplugins/_edit_release.php", array('release' => new MarketRelease())) ?> <div data-dialog-button> <?= \Studip\Button::create(_("speichern")) ?> diff --git a/views/myplugins/edit_release.php b/views/myplugins/edit_release.php new file mode 100644 index 0000000000000000000000000000000000000000..5fcae4a0f8d496a20c817aa2e1192e139e471497 --- /dev/null +++ b/views/myplugins/edit_release.php @@ -0,0 +1,8 @@ +<form action="<?= PluginEngine::getLink($plugin, array(), "myplugins/save_release") ?>" method="post" class="studip_form" enctype="multipart/form-data"> + <input type="hidden" name="id" value="<?= $release->getId() ?>"> + <?= $this->render_partial("myplugins/_edit_release.php", array('release' => $release)) ?> + + <div data-dialog-button> + <?= \Studip\Button::create(_("speichern")) ?> + </div> +</form> \ No newline at end of file diff --git a/views/presenting/details.php b/views/presenting/details.php index b09b9c4958dc7fa596cef6c1c89f0b0816613674..5a7bc4654a928f9c43ce3b256e9d5651a32948b8 100644 --- a/views/presenting/details.php +++ b/views/presenting/details.php @@ -29,7 +29,11 @@ <td><?= htmlReady($release->getChecksum()) ?></td> <td><?= htmlReady($release['downloads']) ?></td> <td> - + <? if ($marketplugin['user_id'] === $GLOBALS['user']->id) : ?> + <a href="<?= PluginEngine::getLink($plugin, array(), "myplugins/edit_release/".$release->getId()) ?>" data-dialog> + <?= Assets::img("icons/20/blue/edit", array('class' => "text-bottom")) ?> + </a> + <? endif ?> </td> </tr> <? endforeach ?> @@ -37,5 +41,5 @@ </table> <div style="text-align: center"> - <?= \Studip\LinkButton::create(_("bearbeiten"), PluginEngine::getURL($plugin, array(), "myplugins/edit/".$marketplugin->getId())) ?> + <?= \Studip\LinkButton::create(_("bearbeiten"), PluginEngine::getURL($plugin, array(), "myplugins/edit/".$marketplugin->getId()), array('data-dialog' => 1)) ?> </div> \ No newline at end of file diff --git a/views/presenting/overview.php b/views/presenting/overview.php index 8eb1da321f109ccf68780c471cf2d8e02fe5171c..c3cdae947a77e96a107ca5c62b7bec2d27879b5f 100644 --- a/views/presenting/overview.php +++ b/views/presenting/overview.php @@ -42,21 +42,23 @@ } </style> +<? if (isset($new_plugins) && count($new_plugins)) : ?> + <h2><?= _("Neue Plugins seit Ihrem letzten Besuch") ?></h2> + <div class="plugins_shortview"> + <? foreach ($new_plugins as $marketplugin) : ?> + <article> + <h1><a href="<?= PluginEngine::getLink($plugin, array(), "presenting/details/".$marketplugin->getId()) ?>"><?= htmlReady($marketplugin['name']) ?></a></h1> + <div class="image" style="background-image: url(http://plugins.studip.de/content/screenshots/a1d85f695cfe506241d398d272ae43f0_thumb);"></div> + <p class="shortdescription"> + <?= htmlReady($marketplugin['short_description']) ?> + </p> + </article> + <? endforeach ?> + </div> +<? endif ?> + + <div class="plugins_shortview"> - <article> - <h1><a href="">BlubberMail</a></h1> - <div class="image" style="background-image: url(http://plugins.studip.de/content/screenshots/a1d85f695cfe506241d398d272ae43f0_thumb);"></div> - <p class="shortdescription"> - Blubbern �ber Email. Man bekommt Mails, wenn die Diskussion weiter geht, man kann per Mail darauf antworten und man kann Blubberstreams per Mail abonnieren. - </p> - </article> - <article> - <h1>ArchivierungsPlugin</h1> - <div class="image" style="background-image: url(http://plugins.studip.de/content/screenshots/5c6b989378b09deb4b5a79b32a0aa0bc);"></div> - <p class="shortdescription"> - Zentrale Archivierung/L�schung von Veranstaltungen durch Admins. Die Veranstaltungen k�nnen nach verschiedenen Kriterien eingeschr�nkt werden. - </p> - </article> <? foreach ($plugins as $marketplugin) : ?> <article> <h1><a href="<?= PluginEngine::getLink($plugin, array(), "presenting/details/".$marketplugin->getId()) ?>"><?= htmlReady($marketplugin['name']) ?></a></h1>