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

some debugging and checksum

parent fb4a6a57
No related branches found
No related tags found
No related merge requests found
.DS_Store 0 → 100644
File added
...@@ -47,6 +47,27 @@ class MarketRelease extends SimpleORMap { ...@@ -47,6 +47,27 @@ class MarketRelease extends SimpleORMap {
unlink($file); unlink($file);
} }
protected function getFilePath() {
if (!file_exists(self::getReleaseDataPath())) {
mkdir(self::getReleaseDataPath());
}
if (!$this->getId()) {
$this->setId($this->getNewId());
}
return self::getReleaseDataPath()."/".$this->getId();
}
public function outputZip() {
$path = self::getReleaseDataPath()."/".$this->getId();
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=".$this->plugin['name'].".zip");
echo file_get_contents($path);
}
public function getChecksum() {
return md5_file($this->getFilePath());
}
protected function installFromDirectory($dir) { protected function installFromDirectory($dir) {
$manifest = PluginManager::getInstance()->getPluginManifest($dir); $manifest = PluginManager::getInstance()->getPluginManifest($dir);
$this['studip_min_version'] = $manifest['studipMinVersion']; $this['studip_min_version'] = $manifest['studipMinVersion'];
...@@ -55,19 +76,11 @@ class MarketRelease extends SimpleORMap { ...@@ -55,19 +76,11 @@ class MarketRelease extends SimpleORMap {
$this['version'] = $manifest['version']; $this['version'] = $manifest['version'];
} }
$hash = md5(uniqid()); $hash = md5(uniqid());
$plugin = $GLOBALS['TMP_PATH']."/plugin_$hash.zip"; $plugin_raw = $GLOBALS['TMP_PATH']."/plugin_$hash.zip";
create_zip_from_directory($dir, $plugin); create_zip_from_directory($dir, $plugin_raw);
$RELEASE_DATA_PATH = self::getReleaseDataPath();
if (!file_exists($RELEASE_DATA_PATH)) {
mkdir($RELEASE_DATA_PATH);
}
if (!$this->getId()) {
$this->setId($this->getNewId());
}
copy($plugin, $RELEASE_DATA_PATH."/".$this->getId()); copy($plugin_raw, $this->getFilePath());
unlink($plugin); unlink($plugin_raw);
return true; return true;
} }
......
...@@ -18,4 +18,12 @@ class PresentingController extends PluginController { ...@@ -18,4 +18,12 @@ class PresentingController extends PluginController {
$this->marketplugin = new MarketPlugin($plugin_id); $this->marketplugin = new MarketPlugin($plugin_id);
} }
public function download_action($release) {
$release = new MarketRelease($release);
$release->outputZip();
$release['downloads'] += 1;
$release->store();
$this->render_nothing();
}
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<? if (count($plugins)) : ?>
<? foreach ($plugins as $marketplugin) : ?> <? foreach ($plugins as $marketplugin) : ?>
<tr> <tr>
<td><?= htmlReady($marketplugin['name']) ?></td> <td><?= htmlReady($marketplugin['name']) ?></td>
...@@ -15,6 +16,11 @@ ...@@ -15,6 +16,11 @@
</td> </td>
</tr> </tr>
<? endforeach ?> <? endforeach ?>
<? else : ?>
<tr>
<td colspan="2" style="text-align: center;"><?= _("Sie haben noch kein Plugin eingestellt.") ?></td>
</tr>
<? endif ?>
</tbody> </tbody>
</table> </table>
......
...@@ -10,14 +10,27 @@ ...@@ -10,14 +10,27 @@
<th><?= _("Version") ?></th> <th><?= _("Version") ?></th>
<th><?= _("Miniale Stud.IP-Versionsnummer") ?></th> <th><?= _("Miniale Stud.IP-Versionsnummer") ?></th>
<th><?= _("Maximale Stud.IP-Versionsnummer") ?></th> <th><?= _("Maximale Stud.IP-Versionsnummer") ?></th>
<th><?= _("MD5-Prfsumme") ?></th>
<th><?= _("Downloads") ?></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<? foreach ($marketplugin->releases as $release) : ?> <? foreach ($marketplugin->releases as $release) : ?>
<tr> <tr>
<td><?= htmlReady($release['version']) ?></td> <td>
<a href="<?= PluginEngine::getLink($plugin, array(), "presenting/download/".$release->getId()) ?>">
<?= Assets::img("icons/20/blue/download", array('class' => "text-bottom")) ?>
<?= htmlReady($release['version']) ?>
</a>
</td>
<td><?= $release['studip_min_version'] ? htmlReady($release['studip_min_version']) : " - " ?></td> <td><?= $release['studip_min_version'] ? htmlReady($release['studip_min_version']) : " - " ?></td>
<td><?= $release['studip_max_version'] ? htmlReady($release['studip_max_version']) : " - " ?></td> <td><?= $release['studip_max_version'] ? htmlReady($release['studip_max_version']) : " - " ?></td>
<td><?= htmlReady($release->getChecksum()) ?></td>
<td><?= htmlReady($release['downloads']) ?></td>
<td>
</td>
</tr> </tr>
<? endforeach ?> <? endforeach ?>
</tbody> </tbody>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment