]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Bug fix: add admin page
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Thu, 11 Sep 2008 16:53:16 +0000 (16:53 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Thu, 11 Sep 2008 16:53:16 +0000 (16:53 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@147 b3834d28-1941-0410-a4f8-b48e95affb8f

AUTHORS
admin.php [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
index a45e1e732cc25adc26dd8b3d31e6907175f920ee..cb1f890efb73cf2500c9db0604f664a9bff9148b 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,4 @@
-Scuttle contains code from the following applications:
+Scuttle and SemanticScuttle contain codes from the following applications:
 
 ------------
 GPL Licenced
@@ -15,4 +15,14 @@ UTF8 Helper Functions
 Andreas Gohr <andi@splitbrain.org>
 
 XSPF Web Music Player (Flash)
-http://musicplayer.sourceforge.net/
\ No newline at end of file
+http://musicplayer.sourceforge.net/
+
+
+----
+
+Patches were realised by :
+
+* Simple Admin-Interface for deleting unwanted users
+Idea of the patch from Andreas Jaggi, for details visit:\r
+http://sourceforge.net/tracker/index.php?func=detail&aid=1543065&group_id=134378&atid=729862
+Adaptation by Andreas Keller (aka Arakel) http://akeller.eu for Takuya Misawa. 
diff --git a/admin.php b/admin.php
new file mode 100644 (file)
index 0000000..c5563f6
--- /dev/null
+++ b/admin.php
@@ -0,0 +1,78 @@
+<?php\r
+/***************************************************************************\r
+Copyright (C) 2007 - 2008 SemanticScuttle project (fork from Scuttle)\r
+http://sourceforge.net/projects/semanticscuttle/\r\r
+\r
+This program is free software; you can redistribute it and/or modify\r
+it under the terms of the GNU General Public License as published by\r
+the Free Software Foundation; either version 2 of the License, or\r
+(at your option) any later version.\r
+\r
+This program is distributed in the hope that it will be useful,\r
+but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+GNU General Public License for more details.\r
+You should have received a copy of the GNU General Public License\r
+along with this program; if not, write to the Free Software\r
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+***************************************************************************/\r
+\r
+require_once('header.inc.php');\r
+\r
+$userservice = & ServiceFactory :: getServiceInstance('UserService');\r
+$bookmark2tagservice = & ServiceFactory :: getServiceInstance('Bookmark2Tagservice');\r
+$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
+$tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');\r
+$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');\r
+\r
+// Header variables\r
+$tplVars['subtitle'] = T_('Manage users');\r
+$tplVars['loadjs'] = true;\r
+\r
+if ( !$userservice->isLoggedOn() ) {\r
+    header('Location: '. createURL('login', ''));\r
+    exit();\r
+}\r
+\r
+$currentUser = $userservice->getCurrentUser();\r
+$currentUserID = $userservice->getCurrentUserId();\r
+$currentUsername = $currentUser[$userservice->getFieldName('username')];\r
+\r
+if ( !$userservice->isAdmin($currentUserID) ) {\r
+    header('Location: '. createURL('bookmarks', $currentUsername));\r
+    exit();\r
+}\r
+\r
+@list($url, $action, $user) = isset($_SERVER['PATH_INFO']) ? explode('/', $_SERVER['PATH_INFO']) : NULL;\r
+\r
+if ( $action ) {\r
+       switch ( $action ) {\r
+               case 'delete':\r
+                       if ( $user && ($userinfo = $userservice->getUserByUsername($user)) ) {\r
+                               $uId = $userinfo['uId'];\r
+
+                               $tag2tagservice->removeLinkedTags('','','',$uId);\r
+                               $userservice->deleteUser($uId);\r
+                               $bookmark2tagservice->deleteTagsForUser($uId);\r
+                               // XXX: don't delete bookmarks before tags, else tags can't be deleted !!!\r
+                               $bookmarkservice->deleteBookmarksForUser($uId);\r
+\r
+                               $tplVars['msg'] = sprintf(T_('%s and all his bookmarks and tags were deleted.'), $user);\r
+                       }\r
+                       break;\r
+               default:\r
+                       // DO NOTHING\r
+       }\r
+}\r
+\r
+$templatename = 'userlist.tpl';\r
+$users =& $userservice->getAllUsers();\r
+\r
+if ( !is_array($users) ) {\r
+       $users = array();\r
+}\r
+\r
+$tplVars['users'] =& $users;\r
+\r
+$templateservice->loadTemplate($templatename, $tplVars);\r
+?>\r