summaryrefslogtreecommitdiff
path: root/inc/media.php
diff options
context:
space:
mode:
authormichael <michael@content-space.de>2009-01-18 16:43:45 +0100
committermichael <michael@content-space.de>2009-01-18 16:43:45 +0100
commit99c8d7f21203dc68bb191d77e01c2f8a6f0cf5a0 (patch)
tree6797f3dac32455b4ac4ba5ad8ce3ac6a1cf91bd8 /inc/media.php
parent5dfff2790d523c9e0e0c1c4bcb8abd70675a213a (diff)
downloadrpg-99c8d7f21203dc68bb191d77e01c2f8a6f0cf5a0.tar.gz
rpg-99c8d7f21203dc68bb191d77e01c2f8a6f0cf5a0.tar.bz2
Media changelog added
There is a new media changelog now, with the flag RECENTS_MEDIA_CHANGES media changes can be requested from the getRecents()-function or the new getRecentsSince()-function, that returns all changes since a given timestamp and optionally before a given timestamp. The media upload and the XML-RPC-server have been changed to use these functions. Additionally, the event MEDIA_UPLOAD_FINISH has been extended, it has a new $data-attribute (the 5th), that contains a boolean if the file does already exist and will be overwritten. darcs-hash:20090118154345-074e0-5d9a90d269e86d8c6a156ecce5cf63115c827433.gz
Diffstat (limited to 'inc/media.php')
-rw-r--r--inc/media.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/inc/media.php b/inc/media.php
index 5c7dd3843..2d3ca3556 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -187,6 +187,7 @@ function media_delete($id,$auth){
if ($evt->advise_before()) {
$data['unl'] = @unlink($file);
if($data['unl']){
+ addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
$data['del'] = io_sweepNS($id,'mediadir');
}
}
@@ -215,6 +216,7 @@ function media_delete($id,$auth){
* $data[1] fn: the file name of the uploaded file
* $data[2] id: the future directory id of the uploaded file
* $data[3] imime: the mimetype of the uploaded file
+ * $data[4] overwrite: if an existing file is going to be overwritten
*
* @triggers MEDIA_UPLOAD_FINISH
* @author Andreas Gohr <andi@splitbrain.org>
@@ -263,7 +265,8 @@ function media_upload($ns,$auth){
// because a temp file was created already
if(preg_match('/\.('.$regex.')$/i',$fn)){
//check for overwrite
- if(@file_exists($fn) && (!$_REQUEST['ow'] || $auth < AUTH_DELETE)){
+ $overwrite = @file_exists($fn);
+ if($overwrite && (!$_REQUEST['ow'] || $auth < AUTH_DELETE)){
msg($lang['uploadexist'],0);
return false;
}
@@ -285,6 +288,7 @@ function media_upload($ns,$auth){
$data[1] = $fn;
$data[2] = $id;
$data[3] = $imime;
+ $data[4] = $overwrite;
// trigger event
return trigger_event('MEDIA_UPLOAD_FINISH', $data, '_media_upload_action', true);
@@ -301,8 +305,8 @@ function media_upload($ns,$auth){
*/
function _media_upload_action($data) {
// fixme do further sanity tests of given data?
- if(is_array($data) && count($data)===4) {
- return media_upload_finish($data[0], $data[1], $data[2], $data[3]);
+ 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
}
@@ -314,7 +318,7 @@ function _media_upload_action($data) {
* @author Andreas Gohr <andi@splitbrain.org>
* @author Michael Klier <chi@chimeric.de>
*/
-function media_upload_finish($fn_tmp, $fn, $id, $imime) {
+function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite) {
global $conf;
global $lang;
@@ -328,6 +332,12 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime) {
chmod($fn, $conf['fmode']);
msg($lang['uploadsucc'],1);
media_notify($id,$fn,$imime);
+ // add a log entry to the media changelog
+ if ($overwrite) {
+ addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_EDIT);
+ } else {
+ addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_CREATE);
+ }
return $id;
}else{
msg($lang['uploadfail'],-1);