Skip to content

Commit 2fa0795

Browse files
Add files via upload
1 parent ecc90f0 commit 2fa0795

File tree

26 files changed

+450
-0
lines changed

26 files changed

+450
-0
lines changed

admin.php

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<?php
2+
if ( !defined ( 'DOKU_INC' ) ) die ( );
3+
if ( !defined ( 'DOKU_PLUGIN' ) ) define ( 'DOKU_PLUGIN', DOKU_INC.'lib/plugins/' );
4+
5+
require_once ( DOKU_PLUGIN.'admin.php' );
6+
7+
/**
8+
* All DokuWiki plugins to extend the admin function
9+
* need to inherit from this class
10+
*/
11+
class admin_plugin_userhistory extends DokuWiki_Admin_Plugin {
12+
13+
function admin_plugin_userhistory ( ) {
14+
$this->setupLocale ( );
15+
}
16+
17+
/**
18+
* return sort order for position in admin menu
19+
*/
20+
function getMenuSort ( ) {
21+
return 999;
22+
}
23+
24+
/**
25+
* handle user request
26+
*/
27+
function handle ( ) {
28+
}
29+
30+
/**
31+
* output appropriate html
32+
*/
33+
function _userList ( ) {
34+
global $auth;
35+
global $ID;
36+
37+
$user_list = $auth->retrieveUsers ( );
38+
39+
echo ( '<h2 id="'.str_replace ( array ( " ", "'" ), "_", strtolower ( $this->getLang ( 'list' ) ) ).'">'.$this->getLang ( 'list' ).'</h2>' );
40+
41+
ptln ( '<div class = "editor_list"><p class = "editor_counter">'.$this->getLang ( 'total' ).': '.count ( $user_list ).'</p><ol>' );
42+
foreach ( $user_list as $key => $value ) {
43+
$nick = $key;
44+
$name = $value['name'];
45+
$href = wl ( $ID ). ( strpos ( wl ( $ID ), '?' )?'&amp;':'?' ).'do=admin&amp;page='.$this->getPluginName ( ).'&amp;user='.hsc ( $nick );
46+
ptln ( '<li><a href = "'.$href.'">'.$nick.' - '.$name.'</li>' );
47+
}
48+
ptln ( '</ol></div>' );
49+
}
50+
51+
function _getChanges ( $user ) {
52+
global $conf;
53+
54+
function globr ( $dir, $pattern ) {
55+
$files = glob ( $dir.'/'.$pattern );
56+
$subdirs = glob ( $dir.'/*', GLOB_ONLYDIR ); /* Rework by bugmenot2 */
57+
if ( !empty ( $subdirs ) ) {
58+
foreach ( $subdirs as $subdir ) {
59+
$subfiles = globr ( $subdir, $pattern );
60+
if ( !empty ( $subfiles ) && !empty ( $files ) ) {
61+
$files = array_merge ( $files, $subfiles );
62+
}
63+
}
64+
}
65+
return $files;
66+
}
67+
68+
$changes = array ( );
69+
$alllist = globr ( $conf['metadir'], '*.changes' );
70+
$skip = array ( '_comments.changes', '_dokuwiki.changes' );
71+
72+
for ( $i = 0; $i < count ( $alllist ); $i++ ) { /* for all files */
73+
$fullname = $alllist[$i];
74+
$filepart = basename ( $fullname );
75+
if ( in_array ( $filepart, $skip ) ) continue;
76+
77+
$f = file ( $fullname );
78+
for ( $j = 0; $j < count ( $f ); $j++ ) { /* for all lines */
79+
$line = $f[$j];
80+
$change = parseChangelogLine ( $line );
81+
if ( strtolower ( $change['user'] ) == strtolower ( $user ) ) $changes[] = $change;
82+
}
83+
}
84+
85+
function cmp ( $a, $b ) {
86+
$time1 = $a['date'];
87+
$time2 = $b['date'];
88+
if ( $time1 == $time2 ) { return 0; }
89+
return ( $time1 < $time2 ? 1 : -1 );
90+
}
91+
92+
uasort ( $changes, 'cmp' );
93+
94+
return $changes;
95+
}
96+
97+
function _userHistory ( $user ) {
98+
global $conf;
99+
global $ID;
100+
global $lang;
101+
102+
$href = wl ( $ID ). ( strpos ( wl ( $ID ), '?' )?'&amp;':'?' ).'do=admin&amp;page='.$this->getPluginName ( );
103+
ptln ( '<p><a href = "'.$href.'">['.$this->getLang('back').']</a></p>' );
104+
ptln ( '<h2>'.$user.'</h2>' );
105+
$changes = array_values ( $this->_getChanges ( $user ) );
106+
ptln ( '<div class = "edit_list"><p class = "edit_counter">'.$this->getLang ( 'total' ).': '.count ( $changes ).'</p><ol>' );
107+
108+
foreach ( $changes as $key => $change ) {
109+
if ( $key == 1000 ) { /* long list limiter */
110+
break;
111+
};
112+
$date = strftime ( $conf['dformat'], $change['date'] );
113+
ptln ( $change['type'] === 'e' ? '<li class = "minor">' : '<li>' );
114+
ptln ( '<div class = "li"><span class="date">'.$date.'</span>' );
115+
$p = array ( );
116+
$p['src'] = DOKU_BASE.'lib/images/diff.png';
117+
$p['title'] = $lang['diff'];
118+
$p['alt'] = $lang['diff'];
119+
$att = buildAttributes ( $p );
120+
ptln ( '<a class = "diff_link" href = "'.wl ( $change['id'], "do=diff&amp;rev=".$change['date'] ).'"><img '.$att.' /></a>' );
121+
$p['src'] = DOKU_BASE.'lib/images/history.png';
122+
$p['title'] = $lang['btn_revs'];
123+
$p['alt'] = $lang['btn_revs'];
124+
$att = buildAttributes ( $p );
125+
ptln ( '<a class = "revisions_link" href = "'.wl ( $change['id'], "do=revisions" ).'"><img '.$att.' /></a> ' );
126+
ptln ( $change['id'].' &ndash; '.html_wikilink ( ':'.$change['id'], $conf['useheading'] ? NULL : $change['id'] ) );
127+
if ( $change['sum'] != "" ) {
128+
ptln ( ' &ndash; '.hsc ( $change['sum'] ) );
129+
};
130+
ptln ( '</div></li>' );
131+
}
132+
ptln ( '</ol></div>' );
133+
}
134+
135+
function html ( ) {
136+
echo ( '<h1 id="'.str_replace ( array ( " ", "'" ), "_", strtolower ( $this->getLang ( 'menu' ) ) ).'">'.$this->getLang ( 'menu' ).'</h1>' );
137+
138+
if ( isset ( $_REQUEST['user'] ) ) {
139+
$this->_userHistory ( $_REQUEST['user'] );
140+
} else {
141+
$this->_userList ( );
142+
}
143+
}
144+
145+
}

admin.svg

Lines changed: 1 addition & 0 deletions
Loading

lang/be/lang.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Belarussian language file
4+
*
5+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
6+
**/
7+
8+
$lang['menu'] = 'Гісторыя карыстальніка';
9+
$lang['list'] = 'Спіс карыстальнікаў';
10+
$lang['back'] = 'таму';
11+
$lang['total'] = 'Усяго';

lang/bg/lang.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Bulgarian language file
4+
*
5+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
6+
**/
7+
8+
$lang['menu'] = 'Потребителска история';
9+
$lang['list'] = 'Списък с потребители';
10+
$lang['back'] = 'обратно';
11+
$lang['total'] = 'Обща сума';

lang/cs/lang.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Czech language file
4+
*
5+
* @author Ondra Zara <o.z.fw@seznam.cz>
6+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
7+
**/
8+
9+
$lang['menu'] = 'Historie uživatele';
10+
$lang['list'] = 'Seznam uživatelů';
11+
$lang['back'] = 'zpátky';
12+
$lang['total'] = 'Celkový';

lang/da/lang.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Danish language file
4+
*
5+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
6+
**/
7+
8+
$lang['menu'] = 'Brugerhistorik';
9+
$lang['list'] = 'Brugerliste';
10+
$lang['back'] = 'tilbage';
11+
$lang['total'] = 'I alt';

lang/de/lang.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Deutsch language file
4+
*
5+
* @author Ferhat D.
6+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
7+
**/
8+
9+
$lang['menu'] = 'Benutzer Geschichte';
10+
$lang['list'] = 'Benutzerliste';
11+
$lang['back'] = 'zurück';
12+
$lang['total'] = 'Gesamt';

lang/el/lang.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Greek language file
4+
*
5+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
6+
**/
7+
8+
$lang['menu'] = 'Ιστορικό χρηστών';
9+
$lang['list'] = 'Λίστα χρηστών';
10+
$lang['back'] = 'πίσω';
11+
$lang['total'] = 'Σύνολο';

lang/en/lang.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* English language file
4+
*
5+
* @author -
6+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
7+
**/
8+
9+
$lang['menu'] = 'User history';
10+
$lang['list'] = 'User list';
11+
$lang['back'] = 'back';
12+
$lang['total'] = 'Total';

lang/eo/lang.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Esperanto language file
4+
*
5+
* @author Rainbow-Spike <rainbow_spike@derpy.ru>
6+
**/
7+
8+
$lang['menu'] = 'Historio de uzanto';
9+
$lang['list'] = 'Listo de uzantoj';
10+
$lang['back'] = 'reen';
11+
$lang['total'] = 'Tuta';

0 commit comments

Comments
 (0)