public function download_action($release) { $release = new MarketRelease($release); $release['downloads'] += 1; $release->store(); $this->set_content_type($release->getMimeType()); $this->response->add_header('Content-Disposition', 'attachment;filename="' . addslashes($release->getFilename()) . '"'); $this->response->add_header('Content-Length', $release->getContentLength()); $this->render_text($release->getContent()); }
public function save_action() { if (!Request::isPost()) { throw new Exception("Method not allowed. Try a POST request."); } $this->marketplugin = new MarketPlugin(Request::option("id") ?: null); if (!$this->marketplugin->isNew() && !$this->marketplugin->isWritable()) { throw new AccessDeniedException("Kein Zugriff"); } if (Request::submitted("data")) { $data = Request::getArray("data"); if (!isset($data["publiclyvisible"])) { $data['publiclyvisible'] = 0; } if (!isset($data["donationsaccepted"])) { $data['donationsaccepted'] = 0; } $this->marketplugin->setData($data); if ($this->marketplugin->isNew()) { $this->marketplugin['user_id'] = $GLOBALS['user']->id; } } $this->marketplugin->store(); $this->marketplugin->setTags(array_map("trim", explode(",", Request::get("tags")))); if (Request::submitted("image_order")) { $order = array_flip(Request::getArray("image_order")); foreach ($this->marketplugin->images as $image) { $image['position'] = $order[$image->getId()] + 1; $image->store(); } } if (Request::submitted("delete_image")) { foreach (Request::getArray("delete_image") as $image_id) { MarketImage::find($image_id)->delete(); } } if (Request::submitted("edit_images")) { $files = $_FILES['new_images']; $position = count($this->marketplugin->images); foreach ($files['name'] as $index => $name) { if ($files['size'][$index]) { $position++; $file = new MarketImage(); $file['plugin_id'] = $this->marketplugin->getId(); $file['filename'] = $name; $file['mimetype'] = mime_content_type($files['tmp_name'][$index]); $file['position'] = $position; $file->installFromPath($files['tmp_name'][$index]); $file->store(); } } } if (Request::submitted("release")) { $release_data = Request::getArray("release"); if ($release_data['type'] !== "zipfile" || $_FILES['release_file']['tmp_name']) { $release = new MarketRelease(); if (!isset($release_data['repository_overwrites_descriptionfrom'])) { $release_data['repository_overwrites_descriptionfrom'] = 0; } $release->setData($release_data); $release['plugin_id'] = $this->marketplugin->getId(); $release['user_id'] = $GLOBALS['user']->id; $release->installFile(); $release->store(); } } PageLayout::postMessage(MessageBox::success(_("Plugin wurde gespeichert."))); $this->redirect('presenting/details/' . $this->marketplugin->getId()); }