2008-09-11 18:53:16 +02:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
2008-11-25 17:23:55 +01:00
|
|
|
Copyright (C) 2007 - 2008 SemanticScuttle project (fork from Scuttle)
|
|
|
|
http://sourceforge.net/projects/semanticscuttle/
|
2008-09-11 18:53:16 +02:00
|
|
|
|
2008-11-25 17:23:55 +01:00
|
|
|
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.
|
2008-09-11 18:53:16 +02:00
|
|
|
|
2008-11-25 17:23:55 +01:00
|
|
|
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
|
|
|
|
***************************************************************************/
|
2008-09-11 18:53:16 +02:00
|
|
|
|
|
|
|
require_once('header.inc.php');
|
2008-11-25 16:57:29 +01:00
|
|
|
|
|
|
|
/* Service creation: only useful services are created */
|
2008-09-11 18:53:16 +02:00
|
|
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
|
|
|
$bookmark2tagservice = & ServiceFactory :: getServiceInstance('Bookmark2Tagservice');
|
|
|
|
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
|
|
|
|
$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
|
2008-11-25 17:23:55 +01:00
|
|
|
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
|
|
|
|
|
|
|
|
/* Managing current logged user */
|
|
|
|
$currentUser = $userservice->getCurrentObjectUser();
|
2008-09-11 18:53:16 +02:00
|
|
|
|
|
|
|
// Header variables
|
|
|
|
$tplVars['subtitle'] = T_('Manage users');
|
2008-11-25 16:57:29 +01:00
|
|
|
$tplVars['loadjs'] = true;
|
2008-12-03 14:24:17 +01:00
|
|
|
$tplVars['sidebar_blocks'] = array('users' );
|
|
|
|
$tplVars['error'] = '';
|
|
|
|
$tplVars['msg'] = '';
|
2008-09-11 18:53:16 +02:00
|
|
|
|
|
|
|
if ( !$userservice->isLoggedOn() ) {
|
2008-11-25 17:23:55 +01:00
|
|
|
header('Location: '. createURL('login', ''));
|
|
|
|
exit();
|
|
|
|
}
|
2008-09-11 18:53:16 +02:00
|
|
|
|
2008-11-25 17:23:55 +01:00
|
|
|
if ( !$currentUser->isAdmin() ) {
|
|
|
|
header('Location: '. createURL('bookmarks', $currentUser->getUsername()));
|
|
|
|
exit();
|
2008-09-11 18:53:16 +02:00
|
|
|
}
|
|
|
|
|
2008-11-27 11:31:03 +01:00
|
|
|
@list($url, $action, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;
|
2008-12-03 12:11:08 +01:00
|
|
|
|
2008-09-11 18:53:16 +02:00
|
|
|
|
2008-11-25 17:23:55 +01:00
|
|
|
if ( $action
|
2008-11-27 11:31:03 +01:00
|
|
|
&& strpos($_SERVER['HTTP_REFERER'], ROOT.'admin.php') === 0 // Prevent CSRF attacks
|
2008-11-25 17:23:55 +01:00
|
|
|
) {
|
2008-09-11 18:53:16 +02:00
|
|
|
switch ( $action ) {
|
|
|
|
case 'delete':
|
|
|
|
if ( $user && ($userinfo = $userservice->getUserByUsername($user)) ) {
|
|
|
|
$uId = $userinfo['uId'];
|
|
|
|
|
|
|
|
$tag2tagservice->removeLinkedTags('','','',$uId);
|
|
|
|
$userservice->deleteUser($uId);
|
|
|
|
$bookmark2tagservice->deleteTagsForUser($uId);
|
|
|
|
// XXX: don't delete bookmarks before tags, else tags can't be deleted !!!
|
|
|
|
$bookmarkservice->deleteBookmarksForUser($uId);
|
|
|
|
|
|
|
|
$tplVars['msg'] = sprintf(T_('%s and all his bookmarks and tags were deleted.'), $user);
|
2008-12-03 12:11:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'checkUrl' :
|
2008-12-03 14:24:17 +01:00
|
|
|
$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, NULL, NULL, getSortOrder());
|
|
|
|
foreach($bookmarks['bookmarks'] as $bookmark) {
|
|
|
|
if(!checkUrl($bookmark['bAddress'])) {
|
|
|
|
$tplVars['error'].= T_('Problem with ').$bookmark['bAddress'].' ('. $bookmark['username'] .')<br/>';
|
|
|
|
}
|
|
|
|
}
|
2008-09-11 18:53:16 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// DO NOTHING
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-03 14:24:17 +01:00
|
|
|
$templatename = 'admin.tpl';
|
2008-11-25 16:57:29 +01:00
|
|
|
$users =& $userservice->getObjectUsers();
|
2008-09-11 18:53:16 +02:00
|
|
|
|
|
|
|
if ( !is_array($users) ) {
|
|
|
|
$users = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$tplVars['users'] =& $users;
|
|
|
|
|
|
|
|
$templateservice->loadTemplate($templatename, $tplVars);
|
2008-11-25 17:23:55 +01:00
|
|
|
?>
|