PukiWiki
修訂 | 46036e1878d8a02fa83465b69a6b9c54ccf1a524 (tree) |
---|---|
時間 | 2016-02-08 02:26:50 |
作者 | umorigu <umorigu@gmai...> |
Commiter | umorigu |
BugTrack2/374 Fix recording username logic
* Recoard username and fullname for each post
* If fullname is empty, use username as his/her fullname
* Take backup if username differs from previous post
@@ -49,14 +49,14 @@ function make_backup($page, $is_delete, $wikitext) | ||
49 | 49 | $need_backup_by_time = $lastmod == 0 || UTIME - $lastmod > 60 * 60 * $cycle; |
50 | 50 | if (!$need_backup_by_time) { |
51 | 51 | // Backup file is saved recently, but the author may differ. |
52 | - $last_content = get_source($page, FALSE, TRUE); | |
52 | + $last_content = get_source($page, TRUE, TRUE); | |
53 | 53 | $m = array(); |
54 | - if (preg_match('/^\s*#author\("([^"]+)","([^"]+)","([^"]*)"\)/m', $last_content, $m)) { | |
55 | - $prev_author = $m[2]; | |
56 | - $simple_author =preg_replace('/^[^:]:/', '', $prev_author); | |
57 | - if ($simple_author !== $auth_user) { | |
58 | - $is_author_differ = true; | |
59 | - } | |
54 | + $prev_author = null; | |
55 | + if (preg_match('/^#author\("([^"]+)","([^"]*)","([^"]*)"\)/m', $last_content, $m)) { | |
56 | + $prev_author = preg_replace('/^[^:]+:/', '', $m[2]); | |
57 | + } | |
58 | + if ($prev_author !== $auth_user) { | |
59 | + $is_author_differ = true; | |
60 | 60 | } |
61 | 61 | } |
62 | 62 | if ($need_backup_by_time || $is_author_differ || $is_delete) |
@@ -171,7 +171,12 @@ function add_author_info($wikitext) | ||
171 | 171 | { |
172 | 172 | global $auth_user, $auth_user_fullname, $auth_type, $ldap_user_account; |
173 | 173 | $author = preg_replace('/"/', '', $auth_user); |
174 | - $displayname = preg_replace('/"/', '', $auth_user_fullname); | |
174 | + $fullname = $auth_user_fullname; | |
175 | + if (!$fullname && $author) { | |
176 | + // Fullname is empty, use $author as its fullname | |
177 | + $fullname = preg_replace('/^[^:]*:/', '', $author); | |
178 | + } | |
179 | + $displayname = preg_replace('/"/', '', $fullname); | |
175 | 180 | $user_prefix = ''; |
176 | 181 | switch ($auth_type) { |
177 | 182 | case AUTH_TYPE_BASIC: |