summaryrefslogtreecommitdiff
path: root/admin.php
blob: 200cf4ee5f3f9d65d3c71ae6c763d3b249a76606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php
/**
 * Welcome page for the administration module
 *
 * webtrees: Web based Family History software
 * Copyright (C) 2010 webtrees development team.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package webtrees
 * @subpackage Admin
 * @version $Id$
 */

define('WT_SCRIPT_NAME', 'admin.php');

require './includes/session.php';
require WT_ROOT.'includes/functions/functions_edit.php';

// Only managers can access this page
if (!WT_USER_GEDCOM_ADMIN) {
	// TODO: Check if we are a manager in *any* gedcom, not just the current one
	header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.'login.php?url='.WT_SCRIPT_NAME);
	exit;
}

print_header(WT_I18N::translate('Administration'));

// Check for updates
$latest_version_txt=fetch_latest_version();
if ($latest_version_txt) {
	list($latest_version, $earliest_version, $download_url)=explode('|', $latest_version_txt);
	// If the latest version is newer than this version, show a download link.
	if (version_compare(WT_VERSION, $latest_version)<=0) {
		// A newer version is available.  Make a link to it
		$latest_version='<a href="'.$download_url.'" style="font-weight:bold; color:red;">'.$latest_version.'</a>';
	}
} else {
	// Cannot determine the latest version
	$latest_version='-';
}

// Load all available gedcoms
$all_gedcoms = get_all_gedcoms();

$stats=new WT_Stats(WT_GEDCOM);
	$totusers  =0;       // Total number of users
	$warnusers =0;       // Users with warning
	$applusers =0;       // Users who have not verified themselves
	$nverusers =0;       // Users not verified by admin but verified themselves
	$adminusers=0;       // Administrators
	$userlang  =array(); // Array for user languages
	$gedadmin  =array(); // Array for managers
	
// Display a series of "blocks" of general information, vary according to admin or manager.

echo '<div id="content_container">';

echo '<div id="x">';// div x - manages the accordion effect

echo '<h2>', WT_I18N::translate('About webtrees'), '</h2>',
	'<div id="about">',
	'<p>', WT_I18N::translate('Welcome to the <b>webtrees</b> administration page. This page provides access to all the site and family tree configuration settings as well as providing some useful information blocks. Administrators can upgrade to the lastest version with a single click, whenever the page reports that a new version is available.'), '</p>',
	'<p>' ,WT_I18N::translate('Your installed  version of <b>webtrees</b> is: %s', WT_VERSION_TEXT),'</p>';
if (version_compare(WT_VERSION, $latest_version)>0) {
	echo '<p>' ,WT_I18N::translate('The latest stable <b>webtrees</b> version is: %s', $latest_version), '&nbsp;<span class="accepted">' ,WT_I18N::translate('No upgrade required.'), '</span></p>';
} else {
	echo '<p class="warning">' ,WT_I18N::translate('We recommend you click here to upgrade to the latest stable <b>webtrees</b> version: %s', $latest_version), '</p>';
}
echo
	'</div>';

echo
	'<h2>', WT_I18N::translate('Users'), '</h2>',
	'<div id="users">'; //id = users

		foreach(get_all_users() as $user_id=>$user_name) {
			$totusers = $totusers + 1;
			if (((date("U") - (int)get_user_setting($user_id, 'reg_timestamp')) > 604800) && !get_user_setting($user_id, 'verified')) {
				$warnusers++;
			}
			if (!get_user_setting($user_id, 'verified_by_admin') && get_user_setting($user_id, 'verified')) {
				$nverusers++;
			}
			if (!get_user_setting($user_id, 'verified')) {
				$applusers++;
			}
			if (get_user_setting($user_id, 'canadmin')) {
				$adminusers++;
			}
			foreach ($all_gedcoms as $ged_id=>$ged_name) {
				if (get_user_gedcom_setting($user_id, $ged_id, 'canedit')=='admin') {
					$title=PrintReady(strip_tags(get_gedcom_setting($ged_id, 'title')));
					if (isset($gedadmin[$title])) {
						$gedadmin[$title]["number"]++;
					} else {
						$gedadmin[$title]["name"] = $title;
						$gedadmin[$title]["number"] = 1;
						$gedadmin[$title]["ged"] = $ged_name;
					}
				}
			}
			if ($user_lang=get_user_setting($user_id, 'language')) {
				if (isset($userlang[$user_lang]))
					$userlang[$user_lang]["number"]++;
				else {
					$userlang[$user_lang]["langname"] = Zend_Locale::getTranslation($user_lang, 'language', WT_LOCALE);
					$userlang[$user_lang]["number"] = 1;
				}
			}
		}	

	echo
		'<table>',
		'<tr><td>', WT_I18N::translate('Total number of users'), '</td><td>', $totusers, '</td></tr>',
		'<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="admin_users.php?action=listusers&amp;filter=adminusers">', WT_I18N::translate('Administrators'), '</a></td><td>', $adminusers, '</td></tr>',
		'<tr><td colspan="2">', WT_I18N::translate('Managers'), '</td></tr>';
		foreach ($gedadmin as $key=>$geds) {
			echo '<tr><td><div><a href="admin_users.php?action=listusers&amp;filter=gedadmin&amp;ged='.rawurlencode($geds['ged']), '">', $geds['name'], '</a></div></td><td>', $geds['number'], '</td></tr>';
		}
	echo '<tr><td>';
	if ($warnusers == 0) {
		echo WT_I18N::translate('Users with warnings');
	} else {
		echo '<a href="admin_users.php?action=listusers&amp;filter=warnings">', WT_I18N::translate('Users with warnings'), '</a>';
	}
	echo '</td><td>', $warnusers, '</td></tr><tr><td>';
	if ($applusers == 0) {
		echo WT_I18N::translate('Unverified by User');
	} else {
		echo '<a href="admin_users.php?action=listusers&amp;filter=usunver">', WT_I18N::translate('Unverified by User'), '</a>';
	}
	echo '</td><td>', $applusers, '</td></tr><tr><td>';
	if ($nverusers == 0) {
		echo WT_I18N::translate('Unverified by Administrator');
	} else {
		echo '<a href="admin_users.php?action=listusers&amp;filter=admunver">', WT_I18N::translate('Unverified by Administrator'), '</a>';
	}
	echo '</td><td>', $nverusers, '</td></tr>';
	echo '<tr><td colspan="2">', WT_I18N::translate('Users\' languages'), '</td></tr>';
	foreach ($userlang as $key=>$ulang) {
		echo '<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;<a href="admin_users.php?action=listusers&amp;filter=language&amp;usrlang=', $key, '">', $ulang['langname'], '</a></td><td>', $ulang['number'], '</td></tr>';
	}
	echo
		'</tr>',
		'<tr><td colspan="2">', WT_I18N::translate('Users Logged In'), '</td></tr>',
		'<tr><td colspan="2"><div>', $stats->_usersLoggedIn('list'), '</div></td></tr>',
		'</table>';
echo '</div>'; // id = users

echo
	'<h2>', WT_I18N::translate('Family trees'), '</h2>',
	'<div id="trees">',// id=trees
	'<div id="tree_stats">';
$n=0;
foreach ($all_gedcoms as $ged_id=>$gedcom) {
	$stats = new WT_Stats($gedcom);
	if ($ged_id==WT_GED_ID) {
		$accordion_element=$n;
	}
	++$n;
	echo
		'<h3>', $stats->gedcomTitle(), '</h3>',
		'<div>',
		'<table>',
		'<tr><td>&nbsp;</td><td><span>', WT_I18N::translate('Count'), '</span></td></tr>',
		'<tr><th><a href="indilist.php?ged=',  rawurlencode($gedcom), '">',
		WT_I18N::translate('Individuals'), '</a></th><td>', $stats->totalIndividuals(),
		'</td></tr>',
		'<tr><th><a href="famlist.php?ged=',   rawurlencode($gedcom), '">',
		WT_I18N::translate('Families'), '</a></th><td>', $stats->totalFamilies(),
		'</td></tr>',
		'<tr><th><a href="sourlist.php?ged=',  rawurlencode($gedcom), '">',
		WT_I18N::translate('Sources'), '</a></th><td>', $stats->totalSources(),
		'</td></tr>',
		'<tr><th><a href="repolist.php?ged=',  rawurlencode($gedcom), '">',
		WT_I18N::translate('Repositories'), '</a></th><td>', $stats->totalRepositories(),
		'</td></tr>',
		'<tr><th><a href="medialist.php?ged=', rawurlencode($gedcom), '">',
		WT_I18N::translate('Media objects'), '</a></th><td>', $stats->totalMedia(),
		'</td></tr>',
		'<tr><th><a href="notelist.php?ged=',  rawurlencode($gedcom), '">',
		WT_I18N::translate('Notes'), '</a></th><td>', $stats->totalNotes(),
		'</td></tr>',
		'</table>',
		'</div>';
}
echo
	'</div>', // id=tree_stats
	WT_JS_START,
	'jQuery("#tree_stats").accordion({active:',$accordion_element,', icons:false});',
	WT_JS_END,
	'</div>'; // id=trees

echo
	'<h2>', WT_I18N::translate('Recent changes'), '</h2>',
	'<div id="recent2">'; //id=recent
	echo
	'<div id="changes">';
$n=0;
foreach ($all_gedcoms as $ged_id=>$gedcom) {
	if ($ged_id==WT_GED_ID) {
		$accordion_element=$n;
	}
	++$n;
	echo 
		'<h3>', get_gedcom_setting($ged_id, 'title'), '</h3>',
		'<div>',
		'<table>',
		'<tr><td>&nbsp;</td><td><span>', WT_I18N::translate('Day'), '</span></td><td><span>', WT_I18N::translate('Week'), '</span></td><td><span>', WT_I18N::translate('Month'), '</span></td></tr>',
		'<tr><th>', WT_I18N::translate('Individuals'), '</th><td>', count_changes_today($GEDCOM_ID_PREFIX, $ged_id), '</td><td>', count_changes_week($GEDCOM_ID_PREFIX, $ged_id), '</td><td>', count_changes_month($GEDCOM_ID_PREFIX, $ged_id), '</td></tr>',
		'<tr><th>', WT_I18N::translate('Families'), '</th><td>', count_changes_today($FAM_ID_PREFIX, $ged_id), '</td><td>', count_changes_week($FAM_ID_PREFIX, $ged_id), '</td><td>', count_changes_month($FAM_ID_PREFIX, $ged_id), '</td></tr>',
		'<tr><th>', WT_I18N::translate('Sources'), '</th><td>', count_changes_today($SOURCE_ID_PREFIX, $ged_id), '</td><td>', count_changes_week($SOURCE_ID_PREFIX, $ged_id), '</td><td>', count_changes_month($SOURCE_ID_PREFIX, $ged_id), '</td></tr>',
		'<tr><th>', WT_I18N::translate('Repositories'), '</th><td>', count_changes_today($REPO_ID_PREFIX, $ged_id), '</td><td>', count_changes_week($REPO_ID_PREFIX, $ged_id), '</td><td>', count_changes_month($REPO_ID_PREFIX, $ged_id), '</td></tr>',
		'<tr><th>', WT_I18N::translate('Media objects'), '</th><td>', count_changes_today($MEDIA_ID_PREFIX, $ged_id), '</td><td>', count_changes_week($MEDIA_ID_PREFIX, $ged_id), '</td><td>', count_changes_month($MEDIA_ID_PREFIX, $ged_id), '</td></tr>',
		'<tr><th>', WT_I18N::translate('Notes'), '</th><td>', count_changes_today($NOTE_ID_PREFIX, $ged_id), '</td><td>', count_changes_week($NOTE_ID_PREFIX, $ged_id), '</td><td>', count_changes_month($NOTE_ID_PREFIX, $ged_id), '</td></tr>',
		'</table>',
		'</div>';
	}
echo
	'</div>', // id=changes
	WT_JS_START,
	'jQuery("#changes").accordion({active:',$accordion_element,', icons:false});',
	WT_JS_END,
	'</div>'; // id=recent

echo
	'</div>', //id = "x"
	WT_JS_START,
	'jQuery("#x").accordion({active:0, icons:false});',
	WT_JS_END,
	'</div>'; //id = content_container



print_footer();