/** * Callback adapter for media_upload_finish() * @author Michael Klier <*****@*****.**> */ function _media_upload_action($data) { // fixme do further sanity tests of given data? if (is_array($data) && count($data) === 5) { return media_upload_finish($data[0], $data[1], $data[2], $data[3], $data[4]); } else { return false; //callback error } }
/** * Restores an old revision of a media file * * @param string $image * @param int $rev * @param int $auth * @return string - file's id * @author Kate Arzamastseva <*****@*****.**> */ function media_restore($image, $rev, $auth) { global $conf; if ($auth < AUTH_UPLOAD || !$conf['mediarevisions']) { return false; } $removed = !file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')); if (!$image || !file_exists(mediaFN($image)) && !$removed) { return false; } if (!$rev || !file_exists(mediaFN($image, $rev))) { return false; } list(, $imime, ) = mimetype($image); $res = media_upload_finish(mediaFN($image, $rev), mediaFN($image), $image, $imime, true, 'copy'); if (is_array($res)) { msg($res[0], $res[1]); return false; } return $res; }
function _apply_result() { ### _apply_result : store the content in dokuwiki page and the attache file (img) in dokuwiki media # OUTPUT : # * true -> process successfully # * false -> something wrong; using _msg to display what's wrong global $INFO; // Save the content in data/page saveWikiText($this->pageName, $this->result, $this->getLang('parserSummary') . $this->odtFileName); if (!page_exists($this->pageName)) { return $this->_msg('er_apply_content'); } // Check if the user could upload file (ACL : permission lvl 8) if (auth_quickaclcheck($ID) >= AUTH_UPLOAD) { // Import the image file in the mediaManager (data/media) $destDir = mediaFN($this->nsName); if (!(file_exists($destDir) || mkdir($destDir))) { return $this->_msg(array('er_apply_dirCreate')); } if ($this->file_import) { foreach ($this->file_import as $pict) { $destFile = mediaFN($this->nsName . ':' . $pict); list($ext, $mime) = mimetype($this->uploadDir . '/Pictures/' . $pict); if (media_upload_finish($this->uploadDir . '/Pictures/' . $pict, $destFile, $this->nsName, $mime, @file_exists($destFile), 'rename') != $this->nsName) { return $this->_msg(array('er_apply_img', $this->uploadDir . '/Pictures/' . $pict)); } } } // Keep the original file (import the upload file in the mediaManager) $destFile = mediaFN($this->nsName . ':' . $this->odtFileName); list($ext, $mime) = mimetype($this->uploadDir . '/' . $this->odtFileName); if (media_upload_finish($this->uploadDir . '/' . $this->odtFileName, $destFile, $this->nsName, $mime, @file_exists($destFile), 'rename') != $this->nsName) { return $this->_msg(array('er_apply_odtFile')); } } else { // If not allowed to upload, display a message. $this->_msg('inf_acl_upload', 0, true); } # Refresh info about the current page (see doku.php where $INFO is initiate) - Needed for edit or preview "parserPostDisplay" option $INFO = pageinfo(); return true; }