• R/O
  • HTTP
  • SSH
  • HTTPS

pukiwiki: Commit


Commit MetaInfo

Revisione0226e99c53e23624259f42b2a4005abb4ebcbea (tree)
Time2016-02-03 01:55:41
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/374 Show authors on backup list

Change Summary

Incremental Difference

--- a/lib/backup.php
+++ b/lib/backup.php
@@ -13,7 +13,7 @@
1313 * @create
1414 * @version $Id: backup.php,v 1.13 2011/01/25 15:01:01 henoheno Exp $
1515 * Copyright (C)
16- * 2002-2006 PukiWiki Developers Team
16+ * 2002-2016 PukiWiki Development Team
1717 * 2001-2002 Originally written by yu-ji
1818 * License: GPL v2 or (at your option) any later version
1919 **/
@@ -33,6 +33,7 @@ function make_backup($page, $delete = FALSE)
3333 {
3434 global $cycle, $maxage;
3535 global $do_backup, $del_backup;
36+ global $auth_user;
3637
3738 if (PKWK_READONLY || ! $do_backup) return;
3839
@@ -44,7 +45,22 @@ function make_backup($page, $delete = FALSE)
4445 if (! is_page($page)) return;
4546
4647 $lastmod = _backup_get_filetime($page);
47- if ($lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle)
48+ $backups = get_backup($page);
49+ $is_author_differ = false;
50+ $need_backup_by_time = $lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle;
51+ if (!$need_backup_by_time) {
52+ // Backup file is saved recently, but the author may differ.
53+ $last_content = get_source($page, FALSE, TRUE);
54+ $m = array();
55+ if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/m', $last_content, $m)) {
56+ $prev_author = $m[2];
57+ $simple_author =preg_replace('/^[^:]:/', '', $prev_author);
58+ if ($simple_author !== $auth_user) {
59+ $is_author_differ = true;
60+ }
61+ }
62+ }
63+ if ($need_backup_by_time || $is_author_differ)
4864 {
4965 $backups = get_backup($page);
5066 $count = count($backups) + 1;
@@ -105,6 +121,11 @@ function get_backup($page, $age = 0)
105121
106122 // Allocate
107123 $retvars[$_age] = array('time'=>$match[1], 'data'=>array());
124+ } else if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/', $line, $match)) {
125+ $retvars[$_age]['author_datetime'] = $match[1];
126+ $retvars[$_age]['author'] = $match[2];
127+ $retvars[$_age]['author_fullname'] = $match[3];
128+ $retvars[$_age]['data'][] = $line;
108129 } else {
109130 // The first ... the last line of the data
110131 $retvars[$_age]['data'][] = $line;
@@ -306,4 +327,3 @@ else
306327 array();
307328 }
308329 }
309-?>
--- a/plugin/backup.inc.php
+++ b/plugin/backup.inc.php
@@ -1,8 +1,8 @@
11 <?php
22 // PukiWiki - Yet another WikiWikiWeb clone.
3-// $Id: backup.inc.php,v 1.29 2011/01/25 15:01:01 henoheno Exp $
3+// backup.inc.php
44 // Copyright (C)
5-// 2002-2005 PukiWiki Developers Team
5+// 2002-2016 PukiWiki Development Team
66 // 2001-2002 Originally written by yu-ji
77 // License: GPL v2 or (at your option) any later version
88 //
@@ -218,12 +218,17 @@ EOD;
218218 $_anchor_to = '</a>';
219219 }
220220 $date = format_date($data['time'], TRUE);
221+ $author_info = '';
222+ if (isset($data['author'])) {
223+ $author_info = htmlsc('by ' . $data['author_fullname']
224+ . '(' . $data['author'] . ')');
225+ }
221226 $retval[1] .= <<<EOD
222227 <li>$_anchor_from$age $date$_anchor_to
223228 [ <a href="$href$age&amp;action=diff">$_msg_diff</a>
224229 | <a href="$href$age&amp;action=nowdiff">$_msg_nowdiff</a>
225230 | <a href="$href$age&amp;action=source">$_msg_source</a>
226- ]
231+ ] $author_info
227232 </li>
228233 EOD;
229234 }
@@ -244,4 +249,3 @@ function plugin_backup_get_list_all($withfilename = FALSE)
244249 return page_list($pages, 'backup', $withfilename);
245250 }
246251 }
247-?>
Show on old repository browser