/** * @fn download * @short Action method that performs the download of a software artifact. * @details For software artifacts that are locally hosted, a DownloadManager is instantiated and the download * is automatically started. For externally hosted artifacts, the client is redirected to the appropriate URL. */ public function download() { if (!empty($_REQUEST['id'])) { $artifact = new SoftwareArtifact(); if ($artifact->find_by_id($_REQUEST['id']) === FALSE) { HTTP::error(404); } $artifact->downloads++; $artifact->save(); if (self::SOFTWARE_SAVE_DOWNLOADS) { // Logs the download $download = new SoftwareDownload(); $download->artifact_id = $_REQUEST['id']; $download->save(); } // Expires the cache of Download Stats // Remember: Download Stats are cached by release_id $this->expire_cached_page(array('action' => 'download_stats', 'id' => $artifact->release_id)); if ($artifact->URL) { $this->redirect_to($artifact->URL); } else { $filename = $artifact->local_file(); if ($filename) { $dl_mgr = new DownloadManager($filename); $dl_mgr->start_download(); } } } $this->redirect_to(array('action' => 'index')); }
/** * @fn software_artifact_add * @short Action method to save a software artifact. */ public function software_artifact_add() { if (!isset($_POST)) { $this->redirect_to(array('action' => 'software_list')); } $artifact = new SoftwareArtifact($_POST); if (!isset($_POST['enabled'])) { $artifact->enabled = '0'; } if (!isset($_POST['visible'])) { $artifact->visible = '0'; } $artifact->save(); // Expires the cache of Software & Sparkle feeds $this->expire_cached_software_pages(); $this->redirect_to(array('action' => 'software_artifact_list', 'id' => $_POST['release_id'])); }