Added group admin pages and logic.

This commit is contained in:
Andre Lorbach 2008-07-15 17:48:39 +02:00
parent e71e4b7d75
commit 251b00ea30
9 changed files with 385 additions and 22 deletions

265
src/admin/groups.php Normal file
View File

@ -0,0 +1,265 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Group Admin File
*
* -> Helps administrating groups
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
// Only if the user is an admin!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] );
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWGROUP'] = "true";
$content['GROUP_FORMACTION'] = "addnewgroup";
$content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADD'];
//PreInit these values
$content['groupname'] = "";
$content['groupdescription'] = "";
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWGROUP'] = "true";
$content['GROUP_FORMACTION'] = "edituser";
$content['GROUP_SENDBUTTON'] = $content['LN_GROUP_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['GROUPID'] = DB_RemoveBadChars($_GET['id']);
$sqlquery = "SELECT * " .
" FROM " . DB_GROUPS .
" WHERE ID = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$myuser = DB_GetSingleRow($result, true);
if ( isset($myuser['groupname']) )
{
$content['GROUPID'] = $myuser['ID'];
$content['groupname'] = $myuser['groupname'];
$content['groupdescription'] = $myuser['groupdescription'];
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['GROUPID'] = DB_RemoveBadChars($_GET['id']);
// Get GroupInfo
$result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['groupname']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['USERID'] );
}
else
{
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_GROUP_WARNDELETEGROUP'], $myrow['groupname'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_DELGROUP'], $content['USERID'] );
}
else
DB_FreeQuery($result);
// TODO: DELETE GROUP SETTINGS, GROUP MEMBERSHIP ...
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENDEL'], $myrow['groupname'] ) , "groups.php" );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP'];
}
}
if ( isset($_POST['op']) )
{
if ( isset ($_POST['id']) ) { $content['GROUPID'] = DB_RemoveBadChars($_POST['id']); } else {$content['GROUPID'] = ""; }
if ( isset ($_POST['groupname']) ) { $content['groupname'] = DB_RemoveBadChars($_POST['groupname']); } else {$content['groupname'] = ""; }
if ( isset ($_POST['groupdescription']) ) { $content['groupdescription'] = DB_RemoveBadChars($_POST['groupdescription']); } else {$content['groupdescription'] = ""; }
// Check mandotary values
if ( $content['groupname'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPEMPTY'];
}
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewgroup" )
{
$result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE groupname = '" . $content['groupname'] . "'");
$myrow = DB_GetSingleRow($result, true);
if ( isset($myrow['groupname']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPNAMETAKEN'];
}
else
{
// Add new Group now!
$result = DB_Query("INSERT INTO " . DB_GROUPS . " (groupname, groupdescription)
VALUES ( '" . $content['groupname'] . "',
'" . $content['groupdescription'] . "' )");
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_HASBEENADDED'], $content['groupname'] ) , "groups.php" );
}
}
else if ( $_POST['op'] == "edituser" )
{
$result = DB_Query("SELECT ID FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] );
}
else
{
// Edit the User now!
$result = DB_Query("UPDATE " . DB_GROUPS . " SET
groupname = '" . $content['groupname'] . "',
groupdescription = '" . $content['groupdescription'] . "'
WHERE ID = " . $content['GROUPID']);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENEDIT'], $content['groupname']) , "groups.php" );
}
}
}
}
}
else
{
// Default Mode = List Groups
$content['LISTGROUPS'] = "true";
// Read all Serverentries
$sqlquery = "SELECT ID, " .
" groupname, " .
" groupdescription " .
" FROM " . DB_GROUPS.
" ORDER BY ID ";
$result = DB_Query($sqlquery);
$content['GROUPS'] = DB_GetAllRows($result, true);
if ( count($content['GROUPS']) > 0 )
{
// --- Process Groups
for($i = 0; $i < count($content['GROUPS']); $i++)
{
// --- Set CSS Class
if ( $i % 2 == 0 )
$content['GROUPS'][$i]['cssclass'] = "line1";
else
$content['GROUPS'][$i]['cssclass'] = "line2";
// ---
}
// ---
}
else
$content['EMPTYGROUPS'] = "true";
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: Group Options";
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_groups.html");
$page -> output();
// ---
?>

View File

@ -3,9 +3,9 @@
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Admin Index File
* User Admin File
*
* -> Shows ...
* -> Helps administrating users
*
* All directives are explained within this file
*
@ -40,9 +40,6 @@ include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Include LogStream facility
// include($gl_root_path . 'classes/logstream.class.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
@ -158,7 +155,7 @@ if ( isset($_GET['op']) )
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = "*Error, invalid ID, User not found";
$content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID'];
}
}
else if ($_GET['op'] == "delete")

View File

@ -69,3 +69,9 @@
{
height: 16px;
}
.borderless
{
border:0px solid;
background-color: transparent;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

View File

@ -477,6 +477,10 @@ function InitFrontEndVariables()
$content['MENU_KB'] = $content['BASEPATH'] . "images/icons/books.png";
$content['MENU_DOCUMENTVIEW'] = $content['BASEPATH'] . "images/icons/document_view.png";
$content['MENU_DATAEDIT'] = $content['BASEPATH'] . "images/icons/data_edit.png";
$content['MENU_ADDUSER'] = $content['BASEPATH'] . "images/icons/businessman_add.png";
$content['MENU_ADD'] = $content['BASEPATH'] . "images/icons/add.png";
$content['MENU_EDIT'] = $content['BASEPATH'] . "images/icons/edit.png";
$content['MENU_DELETE'] = $content['BASEPATH'] . "images/icons/delete.png";
$content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png";
$content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png";

View File

@ -40,12 +40,12 @@ $content['LN_ADMIN_UNKNOWNSTATE'] = "Unknown State";
$content['LN_ADMIN_ERROR_NOTALLOWED'] = "You are not allowed to access this page with your user level.";
$content['LN_DELETEYES'] = "Yes";
$content['LN_DELETENO'] = "No";
$content['LN_GEN_ACTIONS'] = "Available Actions";
// User Center
$content['LN_USER_CENTER'] = "User Options";
$content['LN_USER_ID'] = "ID";
$content['LN_USER_NAME'] = "Username";
$content['LN_USER_ACTIONS'] = "Available Actions";
$content['LN_USER_ADD'] = "Add User";
$content['LN_USER_EDIT'] = "Edit User";
$content['LN_USER_DELETE'] = "Delete User";
@ -54,9 +54,9 @@ $content['LN_USER_PASSWORD2'] = "Confirm Password";
$content['LN_USER_ERROR_IDNOTFOUND'] = "Error, User with ID '%1' , was not found";
$content['LN_USER_ERROR_WTFOMFGGG'] = "Error, erm wtf you don't have a username omfg pls mowl?";
$content['LN_USER_ERROR_DONOTDELURSLF'] = "Error, you can not DELETE YOURSELF!";
$content['LN_USER_ERROR_DELUSER'] = "Error deleting the User!";
$content['LN_USER_ERROR_DELUSER'] = "Deleting of the user with id '%1' failed!";
$content['LN_USER_ERROR_INVALIDID'] = "Error, invalid ID, User not found";
$content['LN_USER_ERROR_HASBEENDEL'] = "User '%1' has been successfully DELETED!";
$content['LN_USER_ERROR_HASBEENDEL'] = "The User '%1' has been successfully DELETED!";
$content['LN_USER_ERROR_USEREMPTY'] = "Error, Username was empty";
$content['LN_USER_ERROR_USERNAMETAKEN'] = "Error, this Username is already taken!";
$content['LN_USER_ERROR_PASSSHORT'] = "Error, Password was to short, or did not match";
@ -67,10 +67,28 @@ $content['LN_USER_ADDEDIT'] = "Add/Edit User";
$content['LN_USER_WARNREMOVEADMIN'] = "You are about to revoke your own administrative priviledges. Are you sure to remove your admin status?";
$content['LN_USER_WARNDELETEUSER'] = "Are you sure that you want to delete the User '%1'? All his personal settings will be deleted as well.";
$content['LN_USER_'] = "";
$content['LN_USER_'] = "";
$content['LN_USER_'] = "";
$content['LN_USER_'] = "";
// Group center
$content['LN_GROUP_ID'] = "ID";
$content['LN_GROUP_NAME'] = "Groupname";
$content['LN_GROUP_DESCRIPTION'] = "Groupdescription";
$content['LN_GROUP_TYPE'] = "Grouptype";
$content['LN_GROUP_ADD'] = "Add Group";
$content['LN_GROUP_EDIT'] = "Edit Group";
$content['LN_GROUP_DELETE'] = "Delete Group";
$content['LN_GROUP_NOGROUPS'] = "No groups have been added yet";
$content['LN_GROUP_ADDEDIT'] = "Add/Edit Group";
$content['LN_GROUP_ERROR_GROUPEMPTY'] = "The groupname cannot be empty.";
$content['LN_GROUP_ERROR_GROUPNAMETAKEN'] = "The groupname has already been taken.";
$content['LN_GROUP_HASBEENADDED'] = "The group '%1' has been successfully added.";
$content['LN_GROUP_ERROR_IDNOTFOUND'] = "The group with ID '%1' could not be found.";
$content['LN_GROUP_ERROR_HASBEENEDIT'] = "The group '%1' has been successfully edited.";
$content['LN_GROUP_ERROR_INVALIDGROUP'] = "Error, invalid ID, Group not found";
$content['LN_GROUP_WARNDELETEGROUP'] = "Are you sure that you want to delete the Group '%1'? All Groupsettings will be deleted as well.";
$content['LN_GROUP_ERROR_DELGROUP'] = "Deleting of the group with id '%1' failed!";
$content['LN_GROUP_ERROR_HASBEENDEL'] = "The Group '%1' has been successfully DELETED!";
$content['LN_GROUP_'] = "";
$content['LN_GROUP_'] = "";
$content['LN_GROUP_'] = "";
?>

View File

@ -0,0 +1,78 @@
<!-- INCLUDE include_header.html -->
<!-- IF ISERROR="true" -->
<center>
<h3><font color="red">{ERROR_MSG}</font></h3>
</center>
<!-- ENDIF ISERROR="true" -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
<tr>
<td colspan="3" class="title" nowrap><B>{LN_USER_CENTER}</B></td>
</tr>
<tr>
<td align="center" class="line2">
<br><br>
<!-- IF LISTGROUPS="true" -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr>
<td align="center" width="50" class="cellmenu1"><b>{LN_GROUP_ID}</b></td>
<td align="center" width="100" class="cellmenu1"><b>{LN_GROUP_NAME}</b></td>
<td align="center" width="300" class="cellmenu1"><b>{LN_GROUP_DESCRIPTION}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_GEN_ACTIONS}</b></td>
</tr>
<!-- IF EMPTYGROUPS="true" -->
<tr>
<td align="center" class="line1" colspan="4"><b>{LN_GROUP_NOGROUPS}</b></td>
</tr>
<!-- ENDIF EMPTYGROUPS="true" -->
<!-- BEGIN GROUPS -->
<tr>
<td align="center" class="{cssclass}"><b>{ID}</b></td>
<td align="center" class="{cssclass}"><a href="{BASEPATH}admin/groups.php?op=edit&id={ID}">{groupname}</a></td>
<td align="center" class="{cssclass}">{groupdescription}</td>
<td align="center" class="{cssclass}">
&nbsp;<a href="{BASEPATH}admin/groups.php?op=adduser&id={ID}"><img src="{MENU_ADDUSER}" width="16" title="{LN_USER_ADD}"></a>
&nbsp;<a href="{BASEPATH}admin/groups.php?op=edit&id={ID}"><img src="{MENU_EDIT}" width="16" title="{LN_GROUP_EDIT}"></a>
&nbsp;<a href="{BASEPATH}admin/groups.php?op=delete&id={ID}"><img src="{MENU_DELETE}" width="16" title="{LN_GROUP_DELETE}"></a>
</td>
</tr>
<!-- END GROUPS -->
<tr>
<td align="center" colspan="4" class="line0"><b><a href="{BASEPATH}admin/groups.php?op=add"><img src="{MENU_ADD}" title="{LN_GROUP_ADD}">&nbsp;{LN_GROUP_ADD}</a></b></td>
</tr>
</table>
<!-- ENDIF LISTGROUPS="true" -->
<!-- IF ISEDITORNEWGROUP="true" -->
<form action="" method="post">
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_GROUP_ADDEDIT}</b></td>
<tr>
<td align="left" class="cellmenu2" width="150" nowrap><b>{LN_GROUP_NAME}</b></td>
<td align="right" class="line0" width="100%"><input type="text" name="groupname" size="40" maxlength="64" value="{groupname}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_GROUP_DESCRIPTION}</b></td>
<td align="right" class="line1"><input type="text" name="groupdescription" size="40" maxlength="255" value="{groupdescription}"></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="{GROUP_SENDBUTTON}">
<input type="hidden" name="op" value="{GROUP_FORMACTION}">
<input type="hidden" name="id" value="{GROUPID}">
</td>
</tr>
</table>
</form>
<!-- ENDIF ISEDITORNEWGROUP="true" -->
<br><br>
</td>
</tr>
</table>
<!-- INCLUDE include_footer.html -->

View File

@ -20,7 +20,7 @@
<td align="center" width="50" class="cellmenu1"><b>{LN_USER_ID}</b></td>
<td align="center" width="300" class="cellmenu1"><b>{LN_USER_NAME}</b></td>
<td align="center" width="100" class="cellmenu1"><b>{LN_USER_ISADMIN}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_USER_ACTIONS}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_GEN_ACTIONS}</b></td>
</tr>
<!-- BEGIN USERS -->
<tr>
@ -28,13 +28,13 @@
<td align="center" class="{cssclass}"><a href="{BASEPATH}admin/users.php?op=edit&id={ID}">{username}</a></td>
<td align="center" class="{cssclass}"><a href="{BASEPATH}admin/users.php?miniop=setisadmin&id={ID}&newval={set_isadmin}"><img src="{is_isadmin_string}" width="16"></a></td>
<td align="center" class="{cssclass}">
&nbsp;<a href="{BASEPATH}admin/users.php?op=edit&id={ID}"><img src="{BASEPATH}images/icons/edit.png" width="16" title="{LN_USER_EDIT}"></a>
&nbsp;<a href="{BASEPATH}admin/users.php?op=delete&id={ID}"><img src="{BASEPATH}images/icons/delete.png" width="16" title="{LN_USER_DELETE}"></a>
&nbsp;<a href="{BASEPATH}admin/users.php?op=edit&id={ID}"><img src="{MENU_EDIT}" width="16" title="{LN_USER_EDIT}"></a>
&nbsp;<a href="{BASEPATH}admin/users.php?op=delete&id={ID}"><img src="{MENU_DELETE}" width="16" title="{LN_USER_DELETE}"></a>
</td>
</tr>
<!-- END USERS -->
<tr>
<td align="center" colspan="4" class="line0"><b><a href="{BASEPATH}admin/users.php?op=add"><img src="{BASEPATH}images/icons/add.png" title="{LN_USER_ADD}">&nbsp;{LN_USER_ADD}</a></b></td>
<td align="center" colspan="4" class="line0"><b><a href="{BASEPATH}admin/users.php?op=add"><img src="{MENU_ADDUSER}" title="{LN_USER_ADD}">&nbsp;{LN_USER_ADD}</a></b></td>
</tr>
</table>
<!-- ENDIF LISTUSERS="true" -->

View File

@ -446,8 +446,3 @@ select, input, button, textarea
color: #BB0000
}
.borderless
{
border:0px solid;
background-color: transparent;
}