From e4f389ef1728a0f86164a0e4b88626be9860dabb Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 26 May 2011 14:23:33 +0300 Subject: media version saving --- inc/changelog.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 15cd46d77..0bbb77540 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -138,6 +138,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', // add changelog lines $logline = implode("\t", $logline)."\n"; io_saveFile($conf['media_changelog'],$logline,true); //global media changelog cache + io_saveFile(mediaMetaFN($id,'.changes'),$logline,true); //media file's changelog } /** @@ -301,7 +302,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ * * @author Ben Coburn */ -function getRevisionInfo($id, $rev, $chunk_size=8192) { +function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { global $cache_revinfo; $cache =& $cache_revinfo; if (!isset($cache[$id])) { $cache[$id] = array(); } @@ -312,7 +313,11 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { return $cache[$id][$rev]; } - $file = metaFN($id, '.changes'); + if ($media) { + $file = mediaMetaFN($id, '.changes'); + } else { + $file = metaFN($id, '.changes'); + } if (!@file_exists($file)) { return false; } if (filesize($file)<$chunk_size || $chunk_size==0) { // read whole file @@ -398,7 +403,7 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { * * @author Ben Coburn */ -function getRevisions($id, $first, $num, $chunk_size=8192) { +function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { global $cache_revinfo; $cache =& $cache_revinfo; if (!isset($cache[$id])) { $cache[$id] = array(); } @@ -406,11 +411,15 @@ function getRevisions($id, $first, $num, $chunk_size=8192) { $revs = array(); $lines = array(); $count = 0; - $file = metaFN($id, '.changes'); + if ($media) { + $file = mediaMetaFN($id, '.changes'); + } else { + $file = metaFN($id, '.changes'); + } $num = max($num, 0); $chunk_size = max($chunk_size, 0); if ($first<0) { $first = 0; } - else if (@file_exists(wikiFN($id))) { + else if (!$media && @file_exists(wikiFN($id)) || $media && @file_exists(mediaFN($id))) { // skip current revision if the page exists $first = max($first+1, 0); } -- cgit v1.2.3 From 29778747fefc70b9f318ba91b47e9207aebc1a95 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 4 Jun 2011 19:19:27 +0300 Subject: media revisions in recent changes --- inc/changelog.php | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 0bbb77540..d21c31198 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -152,6 +152,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_INCLUDE_MEDIA - return both media changes and page changes * * @param int $first number of first entry returned (for paginating * @param int $num return $num entries @@ -159,6 +160,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * @param bool $flags see above * * @author Ben Coburn + * @author Kate Arzamastseva */ function getRecents($first,$num,$ns='',$flags=0){ global $conf; @@ -174,20 +176,46 @@ function getRecents($first,$num,$ns='',$flags=0){ } else { $lines = @file($conf['changelog']); } + $lines_position = count($lines)-1; + + if ($flags & RECENTS_INCLUDE_MEDIA) { + $media_lines = @file($conf['media_changelog']); + $media_lines_position = count($media_lines)-1; + } - // handle lines $seen = array(); // caches seen lines, _handleRecent() skips them - for($i = count($lines)-1; $i >= 0; $i--){ - $rec = _handleRecent($lines[$i], $ns, $flags, $seen); - if($rec !== false) { - if(--$first >= 0) continue; // skip first entries - $recent[] = $rec; - $count++; - // break when we have enough entries - if($count >= $num){ break; } + + // handle lines + while ($lines_position >= 0 || (($flags & RECENTS_INCLUDE_MEDIA) && $media_lines_position >=0)) { + if (empty($rec) && $lines_position >= 0) { + $rec = _handleRecent(@$lines[$lines_position], $ns, $flags, $seen); + if (!$rec) { + $lines_position --; + continue; + } + } + if (($flags & RECENTS_INCLUDE_MEDIA) && empty($media_rec) && $media_lines_position >= 0) { + $media_rec = _handleRecent(@$media_lines[$media_lines_position], $ns, $flags, $seen); + if (!$media_rec) { + $media_lines_position --; + continue; + } } + if (($flags & RECENTS_INCLUDE_MEDIA) && @$media_rec['date'] >= @$rec['date']) { + $media_lines_position--; + $x = $media_rec; + $media_rec = false; + } else { + $lines_position--; + $x = $rec; + $rec = false; + } + if(--$first >= 0) continue; // skip first entries + $recent[] = $x; + $count++; + // break when we have enough entries + if($count >= $num){ break; } } - return $recent; } @@ -301,6 +329,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ * requested changelog line is read. * * @author Ben Coburn + * @author Kate Arzamastseva */ function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { global $cache_revinfo; @@ -402,6 +431,7 @@ function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { * lines are recieved. * * @author Ben Coburn + * @author Kate Arzamastseva */ function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { global $cache_revinfo; -- cgit v1.2.3 From 61f1aad8f877bdf33a160812d88b60c56aed1040 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 5 Jun 2011 21:00:51 +0300 Subject: media version saving fixes --- inc/changelog.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index d21c31198..937214a6a 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -151,7 +151,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_SKIP_PAGES - return media changes instead of page changes * RECENTS_INCLUDE_MEDIA - return both media changes and page changes * * @param int $first number of first entry returned (for paginating @@ -171,7 +171,7 @@ function getRecents($first,$num,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_MEDIA_CHANGES) { + if ($flags & RECENTS_SKIP_PAGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); @@ -229,7 +229,7 @@ function getRecents($first,$num,$ns='',$flags=0){ * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_SKIP_PAGES - return media changes instead of page changes * * @param int $from date of the oldest entry to return * @param int $to date of the newest entry to return (for pagination, optional) @@ -247,7 +247,7 @@ function getRecentsSince($from,$to=null,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_MEDIA_CHANGES) { + if ($flags & RECENTS_SKIP_PAGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); @@ -314,7 +314,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ if ($recent['perms'] < AUTH_READ) return false; // check existance - $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); + $fn = (($flags & RECENTS_SKIP_PAGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false; return $recent; -- cgit v1.2.3 From 0b926329daf6b9cd03c01a4e5b26b968d6cb16a8 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 10 Jun 2011 13:19:28 +0300 Subject: recent changes fix --- inc/changelog.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 937214a6a..e9b271363 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -151,8 +151,8 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_SKIP_PAGES - return media changes instead of page changes - * RECENTS_INCLUDE_MEDIA - return both media changes and page changes + * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_MEDIA_PAGES_MIXED - return both media changes and page changes * * @param int $first number of first entry returned (for paginating * @param int $num return $num entries @@ -171,14 +171,14 @@ function getRecents($first,$num,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_SKIP_PAGES) { + if ($flags & RECENTS_MEDIA_CHANGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); } $lines_position = count($lines)-1; - if ($flags & RECENTS_INCLUDE_MEDIA) { + if ($flags & RECENTS_MEDIA_PAGES_MIXED) { $media_lines = @file($conf['media_changelog']); $media_lines_position = count($media_lines)-1; } @@ -186,7 +186,7 @@ function getRecents($first,$num,$ns='',$flags=0){ $seen = array(); // caches seen lines, _handleRecent() skips them // handle lines - while ($lines_position >= 0 || (($flags & RECENTS_INCLUDE_MEDIA) && $media_lines_position >=0)) { + while ($lines_position >= 0 || (($flags & RECENTS_MEDIA_PAGES_MIXED) && $media_lines_position >=0)) { if (empty($rec) && $lines_position >= 0) { $rec = _handleRecent(@$lines[$lines_position], $ns, $flags, $seen); if (!$rec) { @@ -194,14 +194,14 @@ function getRecents($first,$num,$ns='',$flags=0){ continue; } } - if (($flags & RECENTS_INCLUDE_MEDIA) && empty($media_rec) && $media_lines_position >= 0) { + if (($flags & RECENTS_MEDIA_PAGES_MIXED) && empty($media_rec) && $media_lines_position >= 0) { $media_rec = _handleRecent(@$media_lines[$media_lines_position], $ns, $flags, $seen); if (!$media_rec) { $media_lines_position --; continue; } } - if (($flags & RECENTS_INCLUDE_MEDIA) && @$media_rec['date'] >= @$rec['date']) { + if (($flags & RECENTS_MEDIA_PAGES_MIXED) && @$media_rec['date'] >= @$rec['date']) { $media_lines_position--; $x = $media_rec; $media_rec = false; @@ -229,7 +229,7 @@ function getRecents($first,$num,$ns='',$flags=0){ * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_SKIP_PAGES - return media changes instead of page changes + * RECENTS_MEDIA_CHANGES - return media changes instead of page changes * * @param int $from date of the oldest entry to return * @param int $to date of the newest entry to return (for pagination, optional) @@ -247,7 +247,7 @@ function getRecentsSince($from,$to=null,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_SKIP_PAGES) { + if ($flags & RECENTS_MEDIA_CHANGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); @@ -314,7 +314,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ if ($recent['perms'] < AUTH_READ) return false; // check existance - $fn = (($flags & RECENTS_SKIP_PAGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); + $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false; return $recent; -- cgit v1.2.3 From b5941dfab8516bd445afebc91d6a4942cab4d5f0 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 25 Jul 2011 14:06:25 +0300 Subject: Recent Changes integration of media changes --- inc/changelog.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index e9b271363..578a04298 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -204,6 +204,7 @@ function getRecents($first,$num,$ns='',$flags=0){ if (($flags & RECENTS_MEDIA_PAGES_MIXED) && @$media_rec['date'] >= @$rec['date']) { $media_lines_position--; $x = $media_rec; + $x['media'] = true; $media_rec = false; } else { $lines_position--; -- cgit v1.2.3 From 421ec38e1988e77c10f4c97aa48edfbf7aadd402 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 30 Jul 2011 16:13:23 +0300 Subject: issue #38 links and icons in recent changes --- inc/changelog.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 578a04298..188670397 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -209,6 +209,7 @@ function getRecents($first,$num,$ns='',$flags=0){ } else { $lines_position--; $x = $rec; + if ($flags & RECENTS_MEDIA_CHANGES) $x['media'] = true; $rec = false; } if(--$first >= 0) continue; // skip first entries -- cgit v1.2.3 From 6dd095f599ed20044f98d324cda37bedd57b3d3e Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 2 Aug 2011 19:15:11 +0300 Subject: issue #10 media revisions/changes in RSS feed --- inc/changelog.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 188670397..395e793c1 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -316,8 +316,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ if ($recent['perms'] < AUTH_READ) return false; // check existance - $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); - if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false; + if(!@file_exists(wikiFN($recent['id'])) && !@file_exists(mediaFN($recent['id'])) && $flags & RECENTS_SKIP_DELETED) return false; return $recent; } -- cgit v1.2.3 From 42025dfd31bb5f331c665ae7dbb016fac993d52d Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Sun, 21 Aug 2011 01:01:59 +0200 Subject: Fix the permission and file existence check in the recent changes Before it was possible that changes for media files the user can't access were shown if the user could access a page with the same name. This also reverts the file existence check so it now really checks for media changes that the media file exists and for page changes the page and that not one of the two suffice for both. --- inc/changelog.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'inc/changelog.php') diff --git a/inc/changelog.php b/inc/changelog.php index 395e793c1..fea39f9f7 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -188,14 +188,14 @@ function getRecents($first,$num,$ns='',$flags=0){ // handle lines while ($lines_position >= 0 || (($flags & RECENTS_MEDIA_PAGES_MIXED) && $media_lines_position >=0)) { if (empty($rec) && $lines_position >= 0) { - $rec = _handleRecent(@$lines[$lines_position], $ns, $flags, $seen); + $rec = _handleRecent(@$lines[$lines_position], $ns, $flags & ~RECENTS_MEDIA_CHANGES, $seen); if (!$rec) { $lines_position --; continue; } } if (($flags & RECENTS_MEDIA_PAGES_MIXED) && empty($media_rec) && $media_lines_position >= 0) { - $media_rec = _handleRecent(@$media_lines[$media_lines_position], $ns, $flags, $seen); + $media_rec = _handleRecent(@$media_lines[$media_lines_position], $ns, $flags | RECENTS_MEDIA_CHANGES, $seen); if (!$media_rec) { $media_lines_position --; continue; @@ -312,11 +312,16 @@ function _handleRecent($line,$ns,$flags,&$seen){ if (($flags & RECENTS_SKIP_SUBSPACES) && (getNS($recent['id']) != $ns)) return false; // check ACL - $recent['perms'] = auth_quickaclcheck($recent['id']); + if ($flags & RECENTS_MEDIA_CHANGES) { + $recent['perms'] = auth_quickaclcheck(getNS($recent['id']).':*'); + } else { + $recent['perms'] = auth_quickaclcheck($recent['id']); + } if ($recent['perms'] < AUTH_READ) return false; // check existance - if(!@file_exists(wikiFN($recent['id'])) && !@file_exists(mediaFN($recent['id'])) && $flags & RECENTS_SKIP_DELETED) return false; + $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); + if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false; return $recent; } -- cgit v1.2.3