New Feature: add users admin page with delete function
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@146 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
bfdc6bd738
commit
1d059dc06d
6 changed files with 107 additions and 6 deletions
|
@ -179,6 +179,26 @@ class Bookmark2TagService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allow deletion in admin page */
|
||||||
|
function deleteTagsForUser($uId) {
|
||||||
|
$qmask = 'DELETE FROM %s USING %s, %s WHERE %s.bId = %s.bId AND %s.uId = %d';
|
||||||
|
$query = sprintf($qmask,
|
||||||
|
$this->getTableName(),
|
||||||
|
$this->getTableName(),
|
||||||
|
$GLOBALS['tableprefix'].'bookmarks',
|
||||||
|
$this->getTableName(),
|
||||||
|
$GLOBALS['tableprefix'].'bookmarks',
|
||||||
|
$GLOBALS['tableprefix'].'bookmarks',
|
||||||
|
$uId);
|
||||||
|
|
||||||
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not delete tags', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function &getTagsForBookmark($bookmarkid) {
|
function &getTagsForBookmark($bookmarkid) {
|
||||||
if (!is_int($bookmarkid)) {
|
if (!is_int($bookmarkid)) {
|
||||||
message_die(GENERAL_ERROR, 'Could not get tags (invalid bookmarkid)', '', __LINE__, __FILE__, $query);
|
message_die(GENERAL_ERROR, 'Could not get tags (invalid bookmarkid)', '', __LINE__, __FILE__, $query);
|
||||||
|
|
|
@ -416,6 +416,17 @@ class BookmarkService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteBookmarksForUser($uId) {
|
||||||
|
$query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'bookmarks WHERE uId = '. intval($uId);
|
||||||
|
|
||||||
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not delete bookmarks', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function countOthers($address) {
|
function countOthers($address) {
|
||||||
if (!$address) {
|
if (!$address) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -234,15 +234,17 @@ class Tag2TagService {
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeLinkedTags($tag1, $tag2, $relationType, $uId) {
|
function removeLinkedTags($tag1, $tag2, $relationType, $uId) {
|
||||||
if($tag1 == $tag2 || strlen($tag1) == 0 || strlen($tag2) == 0
|
if(($tag1 != '' && $tag1 == $tag2) ||
|
||||||
|| ($relationType != ">" && $relationType != "=")) {
|
($relationType != ">" && $relationType != "=" && $relationType != "") ||
|
||||||
|
($tag1 == '' && $tag2 == '' && $relationType == '' && $uId == '')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$query = 'DELETE FROM '. $this->getTableName();
|
$query = 'DELETE FROM '. $this->getTableName();
|
||||||
$query.= ' WHERE tag1 = "'. $tag1 .'"';
|
$query.= ' WHERE 1=1';
|
||||||
$query.= ' AND tag2 = "'. $tag2 .'"';
|
$query.= strlen($tag1)>0 ? ' AND tag1 = "'. $tag1 .'"' : '';
|
||||||
$query.= ' AND relationType = "'. $relationType .'"';
|
$query.= strlen($tag2)>0 ? ' AND tag2 = "'. $tag2 .'"' : '';
|
||||||
$query.= ' AND uId = "'. $uId .'"';
|
$query.= strlen($relationType)>0 ? ' AND relationType = "'. $relationType .'"' : '';
|
||||||
|
$query.= strlen($uId)>0 ? ' AND uId = "'. $uId .'"' : '';
|
||||||
|
|
||||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||||
message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db);
|
message_die(GENERAL_ERROR, 'Could not remove tag relation', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
|
|
@ -336,6 +336,35 @@ class UserService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllUsers ( ) {
|
||||||
|
$query = 'SELECT * FROM '. $this->getTableName();
|
||||||
|
|
||||||
|
if (! ($dbresult =& $this->db->sql_query($query)) ) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get users', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
|
||||||
|
while ( $row = $this->db->sql_fetchrow($dbresult) ) {
|
||||||
|
$rows[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteUser($uId) {
|
||||||
|
$query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
|
||||||
|
|
||||||
|
if (!($dbresult = & $this->db->sql_query($query))) {
|
||||||
|
message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $query, $this->db);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sanitisePassword($password) {
|
function sanitisePassword($password) {
|
||||||
return sha1(trim($password));
|
return sha1(trim($password));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ if ($userservice->isLoggedOn()) {
|
||||||
$cUser = $userservice->getCurrentUser();
|
$cUser = $userservice->getCurrentUser();
|
||||||
$cUserId = $userservice->getCurrentUserId();
|
$cUserId = $userservice->getCurrentUserId();
|
||||||
$cUsername = $cUser[$userservice->getFieldName('username')];
|
$cUsername = $cUser[$userservice->getFieldName('username')];
|
||||||
|
$isAdmin = $userservice->isAdmin($cUser[$userservice->getFieldname('primary')]);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<ul id="navigation">
|
<ul id="navigation">
|
||||||
|
@ -14,6 +15,10 @@ if ($userservice->isLoggedOn()) {
|
||||||
<li><a href="<?php echo createURL('bookmarks', $cUsername . '?action=add'); ?>"><?php echo T_('Add a Bookmark'); ?></a></li>
|
<li><a href="<?php echo createURL('bookmarks', $cUsername . '?action=add'); ?>"><?php echo T_('Add a Bookmark'); ?></a></li>
|
||||||
<li class="access"><?php echo $cUsername?><a href="<?php echo $GLOBALS['root']; ?>?action=logout">(<?php echo T_('Log Out'); ?>)</a></li>
|
<li class="access"><?php echo $cUsername?><a href="<?php echo $GLOBALS['root']; ?>?action=logout">(<?php echo T_('Log Out'); ?>)</a></li>
|
||||||
<li><a href="<?php echo createURL('about'); ?>"><?php echo T_('About'); ?></a></li>
|
<li><a href="<?php echo createURL('about'); ?>"><?php echo T_('About'); ?></a></li>
|
||||||
|
<?php if($isAdmin): ?>
|
||||||
|
<li><a href="<?php echo createURL('admin', ''); ?>"><?php echo '['.T_('Admin').']'; ?></a></li>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
34
templates/userlist.tpl.php
Normal file
34
templates/userlist.tpl.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
||||||
|
|
||||||
|
$currentUser = $userservice->getCurrentUser();
|
||||||
|
$currentUserID = $userservice->getCurrentUserId();
|
||||||
|
$currentUsername = $currentUser[$userservice->getFieldName('username')];
|
||||||
|
|
||||||
|
|
||||||
|
$this->includeTemplate($GLOBALS['top_include']);
|
||||||
|
|
||||||
|
echo '<ol id="bookmarks">';
|
||||||
|
|
||||||
|
foreach(array_keys($users) as $key) {
|
||||||
|
|
||||||
|
echo '<li class="xfolkentry">'."\n";
|
||||||
|
|
||||||
|
echo '<div class="link">';
|
||||||
|
echo '<a href="'.createURL('profile', $users[$key][$userservice->getFieldname('username')]).'">'.$users[$key][$userservice->getFieldName('username')].'</a>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
if($users[$key][$userservice->getFieldName('username')] != $currentUsername) {
|
||||||
|
echo '<div class="meta">';
|
||||||
|
echo '<a href="'.createURL('admin','delete/'.$users[$key][$userservice->getFieldname('username')]).'" onclick="return confirm(\''.T_('Are you sure?').'\');">'.T_('Delete').'</a>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '</li>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->includeTemplate('sidebar.tpl');
|
||||||
|
$this->includeTemplate($GLOBALS['bottom_include']);
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in a new issue