From 251b00ea30ec82385436f45eda9d785913f3a534 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Tue, 15 Jul 2008 17:48:39 +0200 Subject: [PATCH] Added group admin pages and logic. --- src/admin/groups.php | 265 ++++++++++++++++++++++++++ src/admin/users.php | 9 +- src/css/defaults.css | 6 + src/images/icons/businessman_add.png | Bin 0 -> 859 bytes src/include/functions_common.php | 4 + src/lang/en/admin.php | 32 +++- src/templates/admin/admin_groups.html | 78 ++++++++ src/templates/admin/admin_users.html | 8 +- src/themes/default/main.css | 5 - 9 files changed, 385 insertions(+), 22 deletions(-) create mode 100644 src/admin/groups.php create mode 100644 src/images/icons/businessman_add.png create mode 100644 src/templates/admin/admin_groups.html diff --git a/src/admin/groups.php b/src/admin/groups.php new file mode 100644 index 0000000..6fc1f67 --- /dev/null +++ b/src/admin/groups.php @@ -0,0 +1,265 @@ + 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 . + * + * 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(); +// --- + +?> \ No newline at end of file diff --git a/src/admin/users.php b/src/admin/users.php index 02f3e0f..8dfb82b 100644 --- a/src/admin/users.php +++ b/src/admin/users.php @@ -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") diff --git a/src/css/defaults.css b/src/css/defaults.css index 9dc39ec..ebddd41 100644 --- a/src/css/defaults.css +++ b/src/css/defaults.css @@ -69,3 +69,9 @@ { height: 16px; } + +.borderless +{ + border:0px solid; + background-color: transparent; +} diff --git a/src/images/icons/businessman_add.png b/src/images/icons/businessman_add.png new file mode 100644 index 0000000000000000000000000000000000000000..db9ec1e61c81e8acafe394ea9ef708e68f05a619 GIT binary patch literal 859 zcmV-h1ElWdKBPATcx`PH%P~GB7YQATc&NG&4FdHXti7F)%RO1yJn(000McNliru z)&&<0F)A3N=<@&o010qNS#tmY3h)2`3h)6!tTdPa000DMK}|sb0I`n?{9y$E00Of~ zL_t(|+I^F4NK;W5$NzU;r+am|=E~f#bb*Q$Hlbi3O#%zC4`F?Xrr#n7!U}{$=u2;3 zoKiyC7paVt0+R@#w-0_wq>@l9rF_GjI_KP`cdw`CUhhK8I`BK^T+Vs^&w0-M9}b(^ z(>k2y^=MH5y8~+&UGU<5Ll?SfDM-YzO-o5m-Z!CUhXqfJnaJRIC^TxA4OwD1j% zV}iD<6Ktyh|7Vtl+SF7imKFh@4@ihxIdD1^%4qhP_(%l)DG-gpFg6C1+N*KA%7NA8 zIS4CrNFVw{ryQ};maqR6@Oa?0WZO`9_$Zx52Vy*Rc zSSl(iYN3S?5&K)<;;(WjBR6_%?T+f5A1FJAy4l)@!CW$WJ7hmZdK+O^QAquy{8!|5 zJ#^l7YbNGwUtq_&82i%ujztFtSl@Vz^$Z6X++eNiE{3~cZnygZMTjD)kZQXYFgYxt zwo4~+QvALkTz25GM+aV5Le*;?XWr_h%&{1C5ukpx{sNjXLa{a?ok!4HUA)(%Tl9xf zVAbR0pdW0CP_0OTt#vLbI2;b6(N%$XJdQgZZ^Y!4L^rQ9YfGb4;EKRt-KD|zc>%rA zT+FKdQpU^8k0hbS+6vrk@29)L20*rS0tHKCEeE5RUkITjKNHzmN}P3CF>KW0S#bn< zK8}-}s*Mr^3TZ|k_4C9GA#gZQlSj@!hYa&UQ(j?Cx*^M?)M_lEJRw@4? lg)G2iza(8N7UGdd{05!t_|-9PDM0`L002ovPDHLkV1kg}cGCa= literal 0 HcmV?d00001 diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 071eda9..359fcda 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -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"; diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index dfdc53f..b639a1e 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -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_'] = ""; ?> \ No newline at end of file diff --git a/src/templates/admin/admin_groups.html b/src/templates/admin/admin_groups.html new file mode 100644 index 0000000..8dc9cbb --- /dev/null +++ b/src/templates/admin/admin_groups.html @@ -0,0 +1,78 @@ + + + +
+

{ERROR_MSG}

+
+ + + + + + + + + +
{LN_USER_CENTER}
+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
{LN_GROUP_ID}{LN_GROUP_NAME}{LN_GROUP_DESCRIPTION}{LN_GEN_ACTIONS}
{LN_GROUP_NOGROUPS}
{ID}{groupname}{groupdescription} +   +   +   +
 {LN_GROUP_ADD}
+ + + +
+ + + + + + + + + + + + + + +
{LN_GROUP_ADDEDIT}
{LN_GROUP_NAME}
{LN_GROUP_DESCRIPTION}
+ + + +
+
+ + +

+ +
+ + \ No newline at end of file diff --git a/src/templates/admin/admin_users.html b/src/templates/admin/admin_users.html index 0129d40..6f994a4 100644 --- a/src/templates/admin/admin_users.html +++ b/src/templates/admin/admin_users.html @@ -20,7 +20,7 @@ {LN_USER_ID} {LN_USER_NAME} {LN_USER_ISADMIN} - {LN_USER_ACTIONS} + {LN_GEN_ACTIONS} @@ -28,13 +28,13 @@ {username} -   -   +   +   -  {LN_USER_ADD} +  {LN_USER_ADD} diff --git a/src/themes/default/main.css b/src/themes/default/main.css index 1dd5333..44eec8d 100644 --- a/src/themes/default/main.css +++ b/src/themes/default/main.css @@ -446,8 +446,3 @@ select, input, button, textarea color: #BB0000 } -.borderless -{ - border:0px solid; - background-color: transparent; -}