function DLM_approveNewDownload($id) { global $_TABLES, $_CONF, $_DLM_CONF; $result = DB_query("SELECT url, logourl, date, secret_id " . "FROM {$_TABLES['downloads']} " . "WHERE lid = '" . addslashes($id) . "'"); list($url, $logourl, $date, $secret_id) = DB_fetchArray($result); $safename = DLM_encodeFileName($url); $tmpfile = $_DLM_CONF['path_filestore'] . 'tmp' . date('YmdHis', $date) . $safename; $newfile = $_DLM_CONF['path_filestore'] . $secret_id . '_' . $safename; $success = DLM_moveNewFile($tmpfile, $newfile); if ($success && !empty($logourl)) { $safename = DLM_encodeFileName($logourl); $tmpfile = $_DLM_CONF['path_snapstore'] . 'tmp' . date('YmdHis', $date) . $safename; $newfile = $_DLM_CONF['path_snapstore'] . $safename; $success = DLM_moveNewFile($tmpfile, $newfile); if ($success) { DLM_makeThumbnail($safename); } } if ($success) { // PLG_itemSaved($lid, 'downloads'); // COM_rdfUpToDateCheck('downloads', $cid, $lid); // Send a email to submitter notifying them that file was approved if ($_DLM_CONF['download_emailoption']) { DLM_sendNotification($id); } } }
/** * Approve submitted download file information */ function approve() { global $_TABLES, $_CONF, $_DLM_CONF, $LANG_DLM; $this->initCatTree(); $this->_loadFromArgs($_POST); if (empty($this->_lid)) { $this->_lid = $this->_old_lid; } if (empty($this->_cid)) { $this->_cid = $this->_cat_tree->getRootid(); } // Move file from tmp directory under the document filestore to the main file directory $result = DB_query("SELECT url, logourl, secret_id FROM {$_TABLES['downloadsubmission']} " . "WHERE lid = '" . addslashes($this->_old_lid) . "'"); list($url, $logourl, $secret_id) = DB_fetchArray($result); $this->_secret_id = $secret_id; $success = false; if (!empty($url)) { $tmpfile = $_DLM_CONF['path_filestore'] . 'tmp' . date('YmdHis', $this->_old_date) . DLM_createSafeFileName($url); $newfile = $_DLM_CONF['path_filestore'] . DLM_createSafeFileName($url, $secret_id); $success = $this->_moveNewFile($tmpfile, $newfile); if (!$success) { $this->_retry = true; $this->_reedit('showEditor', array($this->_editor_mode)); } } if ($success && !empty($logourl)) { $safename = DLM_createSafeFileName($logourl); $tmpfile = $_DLM_CONF['path_snapstore'] . 'tmp' . date('YmdHis', $this->_old_date) . $safename; $newfile = $_DLM_CONF['path_snapstore'] . $safename; $success = $this->_moveNewFile($tmpfile, $newfile); if (!$success) { $this->_retry = true; $this->_reedit('showEditor', array($this->_editor_mode)); } DLM_makeThumbnail($safename); } if ($success) { $this->_addToDatabase(); DB_delete($_TABLES['downloadsubmission'], "lid", addslashes($this->_old_lid)); // Send an email to submitter notifying them that file was approved if ($_DLM_CONF['download_emailoption']) { DLM_sendNotification($this->_lid); } } return PLG_afterSaveSwitch('admin', '', 'downloads', 102); }