From 037356b55490de5a6b4dddf5a8b94dd7c4b7e22b Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 18 Jul 2008 16:17:47 +0200 Subject: [PATCH] Start adding views admin into admin center. But not fully functional yet, working on it. --- src/admin/searches.php | 32 +- src/admin/views.php | 457 ++++++++++++++++++++++++ src/images/icons/delete_disabled.png | Bin 0 -> 893 bytes src/images/icons/edit_disabled.png | Bin 0 -> 894 bytes src/images/icons/gear.png | Bin 0 -> 995 bytes src/include/functions_common.php | 5 +- src/include/functions_config.php | 58 ++- src/include/functions_users.php | 33 ++ src/lang/en/admin.php | 35 +- src/templates/admin/admin_searches.html | 4 +- src/templates/admin/admin_views.html | 128 +++++++ 11 files changed, 736 insertions(+), 16 deletions(-) create mode 100644 src/admin/views.php create mode 100644 src/images/icons/delete_disabled.png create mode 100644 src/images/icons/edit_disabled.png create mode 100644 src/images/icons/gear.png create mode 100644 src/templates/admin/admin_views.html diff --git a/src/admin/searches.php b/src/admin/searches.php index 3b4ce41..2d77f40 100644 --- a/src/admin/searches.php +++ b/src/admin/searches.php @@ -73,8 +73,15 @@ if ( isset($_GET['op']) ) $content['userid'] = null; $content['CHECKED_ISUSERONLY'] = ""; $content['SEARCHID'] = ""; - + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + $content['ISGROUPSAVAILABLE'] = true; + else + $content['ISGROUPSAVAILABLE'] = false; + + /* $sqlquery = "SELECT " . DB_GROUPS . ".ID as mygroupid, " . DB_GROUPS . ".groupname " . @@ -93,7 +100,7 @@ if ( isset($_GET['op']) ) array_unshift( $content['SUBGROUPS'], array ("mygroupid" => -1, "groupname" => $content['LN_SEARCH_SELGROUPENABLE'], "group_selected" => "") ); } else - $content['ISGROUPSAVAILABLE'] = false; + $content['ISGROUPSAVAILABLE'] = false;*/ // --- } else if ($_GET['op'] == "edit") @@ -124,6 +131,26 @@ if ( isset($_GET['op']) ) else $content['CHECKED_ISUSERONLY'] = ""; + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + { + // Process All Groups + for($i = 0; $i < count($content['SUBGROUPS']); $i++) + { + if ( $mysearch['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysearch['groupid'] ) + $content['SUBGROUPS'][$i]['group_selected'] = "selected"; + else + $content['SUBGROUPS'][$i]['group_selected'] = ""; + } + + // Enable Group Selection + $content['ISGROUPSAVAILABLE'] = true; + } + else + $content['ISGROUPSAVAILABLE'] = false; + // --- +/* // --- Check if groups are available $sqlquery = "SELECT " . DB_GROUPS . ".ID as mygroupid, " . @@ -150,6 +177,7 @@ if ( isset($_GET['op']) ) else $content['ISGROUPSAVAILABLE'] = false; // --- +*/ } else { diff --git a/src/admin/views.php b/src/admin/views.php new file mode 100644 index 0000000..738ac95 --- /dev/null +++ b/src/admin/views.php @@ -0,0 +1,457 @@ + Helps administrating custom user views + * + * 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['ISEDITORNEWVIEW'] = "true"; + $content['VIEW_FORMACTION'] = "addnewview"; + $content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_ADD']; + + //PreInit these values + $content['DisplayName'] = ""; + $content['userid'] = null; + $content['CHECKED_ISUSERONLY'] = ""; + $content['VIEWID'] = ""; + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + $content['ISGROUPSAVAILABLE'] = true; + else + $content['ISGROUPSAVAILABLE'] = false; + // --- + } + else if ($_GET['op'] == "edit") + { + // Set Mode to edit + $content['ISEDITORNEWVIEW'] = "true"; + $content['VIEW_FORMACTION'] = "editview"; + $content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_EDIT']; + + // View must be loaded as well already! + if ( isset($_GET['id']) && $content['VIEWS'][$_GET['id']] ) + { + //PreInit these values + $content['VIEWID'] = DB_RemoveBadChars($_GET['id']); + + $sqlquery = "SELECT ID, DisplayName " . + " FROM " . DB_VIEWS . + " WHERE ID = " . $content['VIEWID']; + + $result = DB_Query($sqlquery); + $myview = DB_GetSingleRow($result, true); + if ( isset($myview['DisplayName']) ) + { + $content['VIEWID'] = $myview['ID']; + +/* + $content['DisplayName'] = $mysearch['DisplayName']; + $content['SearchQuery'] = $mysearch['SearchQuery']; + if ( $mysearch['userid'] != null ) + $content['CHECKED_ISUSERONLY'] = "checked"; + else + $content['CHECKED_ISUSERONLY'] = ""; +*/ + + // --- Check if groups are available + $content['SUBGROUPS'] = GetGroupsForSelectfield(); + if ( is_array($content['SUBGROUPS']) ) + { + // Process All Groups + for($i = 0; $i < count($content['SUBGROUPS']); $i++) + { + if ( $myview['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $myview['groupid'] ) + $content['SUBGROUPS'][$i]['group_selected'] = "selected"; + else + $content['SUBGROUPS'][$i]['group_selected'] = ""; + } + + // Enable Group Selection + $content['ISGROUPSAVAILABLE'] = true; + } + else + $content['ISGROUPSAVAILABLE'] = false; + // --- + } + else + { + $content['ISEDITORNEWVIEW'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); + } + } + else + { + $content['ISEDITORNEWVIEW'] = false; + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_INVALIDID']; + } + } + else if ($_GET['op'] == "delete") + { + if ( isset($_GET['id']) ) + { + //PreInit these values + $content['VIEWID'] = DB_RemoveBadChars($_GET['id']); + + // Get UserInfo + $result = DB_Query("SELECT DisplayName FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] ); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['DisplayName']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] ); + } + + // --- 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_VIEWS_WARNDELETEVIEW'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] ); + } + // --- + + // do the delete! + $result = DB_Query( "DELETE FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] ); + if ($result == FALSE) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_DELSEARCH'], $content['VIEWID'] ); + } + else + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "views.php" ); + } + else + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_INVALIDID']; + } + } +} + +// --- Additional work todo for the edit view +if ( isset($content['ISEDITORNEWVIEW']) && $content['ISEDITORNEWVIEW'] ) +{ + // Read Columns from FORM data! + if ( isset($_POST['Columns']) ) + { + // --- Read Columns from Formdata + if ( is_array($_POST['Columns']) ) + { + } + else // One element only + $content['COLUMNS'][$_POST['Columns']]['ColFieldID'] = $_POST['Columns']; + // --- + + // --- Process Columns for display + $i = 0; // Help counter! + foreach ($content['COLUMNS'] as $key => &$myColumn ) + { + // Set Fieldcaption + if ( isset($content[ $fields[$key]['FieldCaptionID'] ]) ) + $myColumn['ColCaption'] = $content[ $fields[$key]['FieldCaptionID'] ]; + else + $myColumn['ColCaption'] = $key; + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $myColumn['colcssclass'] = "line1"; + else + $myColumn['colcssclass'] = "line2"; + $i++; + // --- + } + // --- + } + + // --- Copy fields data array + $content['FIELDS'] = $fields; + + // removed already added fields and set fieldcaption + foreach ($content['FIELDS'] as $key => &$myField ) + { + // Set Fieldcaption + if ( isset($content[ $myField['FieldCaptionID'] ]) ) + $myField['FieldCaption'] = $content[ $myField['FieldCaptionID'] ]; + else + $myField['FieldCaption'] = $key; + } + // --- + +} +// --- + +// --- Process POST Form Data +if ( isset($_POST['op']) ) +{ + if ( isset ($_POST['id']) ) { $content['VIEWID'] = DB_RemoveBadChars($_POST['id']); } else {$content['VIEWID'] = ""; } + if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } +// if ( isset ($_POST['SearchQuery']) ) { $content['SearchQuery'] = DB_RemoveBadChars($_POST['SearchQuery']); } else {$content['SearchQuery'] = ""; } + + // User & Group handeled specially + if ( isset ($_POST['isuseronly']) ) + { + $content['userid'] = $content['SESSION_USERID']; + $content['groupid'] = "null"; // Either user or group not both! + } + else + { + $content['userid'] = "null"; + if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 ) + $content['groupid'] = intval($_POST['groupid']); + else + $content['groupid'] = "null"; + } + + // --- Check mandotary values + if ( $content['DisplayName'] == "" ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY']; + } + // --- + + if ( !isset($content['ISERROR']) ) + { + // Check subop's first! + if ( isset($_POST['subop']) ) + { + // Get NewColID + $szNewColID = DB_RemoveBadChars($_POST['newcolumn']); + + // Add a new Column into our list! + if ( $_POST['subop'] == $content['LN_VIEWS_ADDCOLUMN'] && isset($_POST['newcolumn']) ) + { + // Add New entry into columnlist + $content['COLUMNS'][$szNewColID]['ColFieldID'] = $szNewColID; + // Set Fieldcaption + if ( isset($content[ $fields[$szNewColID]['FieldCaptionID'] ]) ) + $content['COLUMNS'][$szNewColID]['ColCaption'] = $content[ $fields[$szNewColID]['FieldCaptionID'] ]; + else + $content['COLUMNS'][$szNewColID]['ColCaption'] = $szNewColID; + + // Set CSSClass + $content['COLUMNS'][$szNewColID]['colcssclass'] = count($content['COLUMNS']) % 2 == 0 ? "line1" : "line2"; + } +// else if () +// { +// } + } + else // Now SUBOP means normal processing! + { + // Everything was alright, so we go to the next step! + if ( $_POST['op'] == "addnewsearch" ) + { + // Add custom search now! + $sqlquery = "INSERT INTO " . DB_SEARCHES . " (DisplayName, SearchQuery, userid, groupid) + VALUES ('" . $content['DisplayName'] . "', + '" . $content['SearchQuery'] . "', + " . $content['userid'] . ", + " . $content['groupid'] . " + )"; + $result = DB_Query($sqlquery); + DB_FreeQuery($result); + + // Do the final redirect + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], $content['DisplayName'] ) , "searches.php" ); + } + else if ( $_POST['op'] == "editsearch" ) + { + $result = DB_Query("SELECT ID FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID']); + $myrow = DB_GetSingleRow($result, true); + if ( !isset($myrow['ID']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] ); + } + else + { + // Edit the Search Entry now! + $result = DB_Query("UPDATE " . DB_SEARCHES . " SET + DisplayName = '" . $content['DisplayName'] . "', + SearchQuery = '" . $content['SearchQuery'] . "', + userid = " . $content['userid'] . ", + groupid = " . $content['groupid'] . " + WHERE ID = " . $content['SEARCHID']); + DB_FreeQuery($result); + + // Done redirect! + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], $content['DisplayName']) , "searches.php" ); + } + } + } + } +} + +if ( !isset($_POST['op']) && !isset($_GET['op']) ) +{ + // Default Mode = List Searches + $content['LISTVIEWS'] = "true"; +/* + // Read all Serverentries + $sqlquery = "SELECT " . + DB_VIEWS . ".ID, " . + DB_VIEWS . ".DisplayName, " . + DB_VIEWS . ".Columns, " . + DB_VIEWS . ".userid, " . + DB_VIEWS . ".groupid, " . + DB_USERS . ".username, " . + DB_GROUPS . ".groupname " . + " FROM " . DB_VIEWS . + " LEFT OUTER JOIN (" . DB_USERS . ", " . DB_GROUPS . + ") ON (" . + DB_VIEWS . ".userid=" . DB_USERS . ".ID AND " . + DB_VIEWS . ".groupid=" . DB_GROUPS . ".ID " . + ") " . + " ORDER BY " . DB_VIEWS . ".userid, " . DB_VIEWS . ".groupid, " . DB_VIEWS . ".DisplayName"; +//echo $sqlquery; + $result = DB_Query($sqlquery); + $content['VIEWS'] = DB_GetAllRows($result, true); +*/ + + // Copy Views array for further modifications + $content['VIEWS'] = $content['Views']; + + // --- Process Users + $i = 0; // Help counter! + foreach ($content['VIEWS'] as &$myView ) + { + // So internal Views can not be edited but seen + if ( is_numeric($myView['ID']) ) + { + $myView['ActionsAllowed'] = true; + + // --- Set Image for Type + if ( $myView['userid'] != null ) + { + $myView['SearchTypeImage'] = $content["MENU_ADMINUSERS"]; + $myView['SearchTypeText'] = $content["LN_GEN_USERONLY"]; + } + else if ( $myView['groupid'] != null ) + { + $myView['SearchTypeImage'] = $content["MENU_ADMINGROUPS"]; + $myView['SearchTypeText'] = $content["LN_GEN_GROUPONLY"]; + } + else + { + $myView['SearchTypeImage'] = $content["MENU_GLOBAL"]; + $myView['SearchTypeText'] = $content["LN_GEN_GLOBAL"]; + } + // --- + } + else + { + $myView['ActionsAllowed'] = false; + + $myView['SearchTypeImage'] = $content["MENU_INTERNAL"]; + $myView['SearchTypeText'] = $content["LN_GEN_INTERNAL"]; + } + + // --- Add DisplayNames to columns + $iBegin = true; + foreach ($myView['Columns'] as $myCol ) + { + // Get Fieldcaption + if ( isset($content[ $fields[$myCol]['FieldCaptionID'] ]) ) + $myView['COLUMNS'][$myCol]['FieldCaption'] = $content[ $fields[$myCol]['FieldCaptionID'] ]; + else + $myView['COLUMNS'][$myCol]['FieldCaption'] = $myCol; + + if ( $iBegin ) + { + $myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ""; + $iBegin = false; + } + else + $myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ", "; + + } + // --- + + // --- Set CSS Class + if ( $i % 2 == 0 ) + $myView['cssclass'] = "line1"; + else + $myView['cssclass'] = "line2"; + $i++; + // --- + } + // --- +} +// --- END Custom Code + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_VIEWSOPT']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "admin/admin_views.html"); +$page -> output(); +// --- + +?> \ No newline at end of file diff --git a/src/images/icons/delete_disabled.png b/src/images/icons/delete_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..d856cdd09dbc8dfa942425b2773bd187d9acffce GIT binary patch literal 893 zcmV-@1A_dCP) z000W>0fLJSS^xk82}wjjRCt_alTAotcNE2s4!X&d%76^Cj0>a74&qKXf*?d5Rz=Df zQ{$pUNb(}akdcJEynOHk37CKod14;H5~W?J0Wljvf-660gOa@7q}W zwu=jw|DW^Y-org0iI);Z@vYnK_PX8fyd+5_zu#Z7+wJ-3>1ls=clS2{S^zYCsd;Sz zfq*FziTt^@x5wk-WA5+ob9;N6nx-)pi_z(H{xLi}{3C#`0lfJaAQ%h|$K&z8PESvn z%jKx5DmOMZxVE;&cs$N%G)hHLD2n29e}BINKs$hDl7QFi{VE&|m(R}5xVgDWRaLpZ zzD`wDnM@|Ryu8e-t1D(Q8HPe3TCLWy!C(;dNt!S>Hz#GYS>|#%CK3srpP#c@t#WB; ziHf4|@$r!)xw^VaS(fQ?x!Bv=y8+-k04?x%Jg515o|>jHl}a&{O0ia}@#5lwH#avV z$%BIf%CbyZmg#o8X)>991MmZYcaS9MA)C!InM_huRffZ1USD7H>FJ4$MuWv-k+Li^ z6bez2B)VKKPE1Tx0eAs?fZy+b%w#f5Bob5;ouM*#0r&*q9RRcl zg7A~wZm++H0)YU1J|7ns7rC&oK%33Rsi`TBjg8gY+uMHz5C-rOKt; zOGOk#&d<+N6h+R?&eCeNa&mH#f*{=M;uQcU0Br!8UI5Ji-Wv>t?|XWBw4tG)-$zGB z??*;P?gs`23Pz*x7k%uoE`I-d%CDgS-ssei`hK5vrxm^br2n=3FHB!RngF!w=5zos z>eZpYwf;BGe*+nJ2TAfD%x3@q02*{fSad;kbZBpK099;dVPqgvd2@7SZF4LjNp52< T$sIm+00000NkvXXu0mjf)uNMS literal 0 HcmV?d00001 diff --git a/src/images/icons/edit_disabled.png b/src/images/icons/edit_disabled.png new file mode 100644 index 0000000000000000000000000000000000000000..1fa39aab78023a857cb93fbad6cd1953caec0d21 GIT binary patch literal 894 zcmV-^1A+XBP) z000W>0fLJSS^xk83Q0skRCt_ikwHjX2LOiuv>S9il%efdahuhHqbrr^WtSZUF$>Dm z7>E(ygzgZdf(H}PA|Xks-~%NNTsGhAVTL#8CQd~NvouwL5HRkAo%H53Z-O}A3rkR+ zwC~>~mVqAr+y8xs|3@ekx-W|2N@r*1jK|}7>~_1qb~>GnEiEk%>~{NY0M`N7`uh5w zilX?h!{JC&RaM;wa07r1;c)nQFc^F(2tryAgumL`+xJ^rTQhBKZGX7k?rc+2(_=+Z z0+J+Iv$M1G`Fw0>Xm|zSA%Gj0pP&CHnM}S3hr{gc?WND>qa;a;L?YJ6$Vgrggul18 zw$2lY1Y@xn1AzeTc6$zh7r=*56lHgJclS*$m*d*n8dp|U7>~!PC<+%A7U=i;sVE9} zc6Jzx#pv~VUze4Y{RF@d;3LSg{HLz#Rz9C+Hk+kk7;iHDRF#!Y@ME-QdL!+pPzGeb(Iqn6I@1MmpIy$hHm5DW%q_xARzVzJ0{ zI!#^IIX*tlo}M0dbac?;@vy$WK3*E_QvmN?z$Agu(b4Gk_O@l3CRJ7C;o%{ho0~Z} zILNuVIcl25#>U2<0eAqE{~sm^3=a=K+1%W;bX{jEm7=C;R8^IxX;Rm99vmFd>2xjt z=mb!9N#OVU0~;F~mSGrNUtj0Z(GhdG9Ccmi+1VNM`8-8Y{2jnI06w@%;7ulz7D;9@ z8Sd}zGnGm)9*-A>hK4c@hvT=(%F6EmhydAKGW+`J?J@E(9K01N>L0_X+c0`Mh(&j5S^;C88JyGn2kz%2lkrH}6d zc)tW(2VlDjyvTp`$Q6JC{~H_t000_vMObt}b#!QNasX9qWnp9>Q+acAWo>gTAW3dx UF3BA}b^rhX07*qoM6N<$f(o&XFaQ7m literal 0 HcmV?d00001 diff --git a/src/images/icons/gear.png b/src/images/icons/gear.png new file mode 100644 index 0000000000000000000000000000000000000000..8e1411f2876ffc929705cba5e08946a3f1aba8ab GIT binary patch literal 995 zcmV<9104K`P)WdKueAT%IKVQwHYFfcSAF*!OgI65>iAS*C2FfbHbcz*x@00(qQO+^RR z1s4r65*v&It^fc432;bRa{vGf5dZ)S5dnW>Uy%R+00d`2O+f$vv5yPS~^};SD(l@or9k4?!oIe+u6%3tMTysbR4&c+xL_I1D6%p5gQwu2hN|j=UFVJ zJ)NBoAK7eWciP$9Y&*;E-28dY__U> zCX)_D6Y%oo3yz`~qOq|}$8k=7)`>*O0)2h1SZk{_e{(YlOG`0Gr81z?v0HsKnt*g# z0*}YL_3!ltg#P}!%|74M1ct_B2Si1Mqnu&X^`b}sO;b=%z`*=`5JZsztyYNw87M5& z!Ja)v5QH@S?c3x=DCAwh*s!9jtIrXMtmVbyo4BZkl9GIQ@Zg0sH1vFgVTkypOP!}0 z8Y~)ukWkbI!^0oe{r)N0cnPwgC@NA9x3{0B6$%Q1!8qC!f#bX$m+R>t-0$~mBp9&Nd1v6wZ2AfHtPk|aT;((EEh{Y-Q7)x?n_j&m$a zs0o6=c@;D@9ooh7i4u{F`0~nPEw#$(&$D42@53% zDOgzvW3?VHhe8X}!Qgx#cMs&t6RoemSa;@3BNGa(V;%&|b}?2Uf%!;7Ag~6zcN;;Y zVIds$&$`{OcsV!7RIZHT-n|WJEYAg}bDH}6dCVV+iRzk~GID%;8b(JaB%0QM!B9-h z&G}RuH~Jo9-Xb0(zI7897spnj(X@}_#`#a52E3xkCaS9H%HF*BkQ^Gi^Tg$v`2Oox zs%B>9{YWIj%eU|gB3DTyvPY5oLZk{|YinDMm6z|o$#D~JXJ=n~ac)ehWZ7g=FyQzn zGK#F`0=GXbRrY-_$U&q|E*0WL1Vn?ZBM~IMQ($|OldDDYvw`7UK(X{ R?9%`M002ovPDHLkV1ip}$Qu9v literal 0 HcmV?d00001 diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 648d5f5..39b136c 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -432,6 +432,9 @@ function InitFrontEndVariables() $content['MENU_EDIT'] = $content['BASEPATH'] . "images/icons/edit.png"; $content['MENU_DELETE'] = $content['BASEPATH'] . "images/icons/delete.png"; $content['MENU_GLOBAL'] = $content['BASEPATH'] . "images/icons/earth.png"; + $content['MENU_INTERNAL'] = $content['BASEPATH'] . "images/icons/gear.png"; + $content['MENU_EDIT_DISABLED'] = $content['BASEPATH'] . "images/icons/edit_disabled.png"; + $content['MENU_DELETE_DISABLED'] = $content['BASEPATH'] . "images/icons/delete_disabled.png"; $content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png"; $content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png"; @@ -513,7 +516,7 @@ function InitConfigurationValues() LoadSearchesFromDatabase(); // Load Configured Views -// LoadViewsFromDatabase(); + LoadViewsFromDatabase(); // Load Configured Sources // LoadSourcesFromDatabase(); diff --git a/src/include/functions_config.php b/src/include/functions_config.php index 7a308be..e7b2dda 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -209,11 +209,15 @@ function InitViewConfigs() 'ID' => "SYSLOG", 'DisplayName' =>"Syslog Fields", 'Columns' => array ( SYSLOG_DATE, SYSLOG_FACILITY, SYSLOG_SEVERITY, SYSLOG_HOST, SYSLOG_SYSLOGTAG, SYSLOG_PROCESSID, SYSLOG_MESSAGETYPE, SYSLOG_MESSAGE ), + 'userid' => null, + 'groupid' => null, ); $CFG['Views']['EVTRPT']= array( 'ID' => "EVTRPT", 'DisplayName' =>"EventLog Fields", 'Columns' => array ( SYSLOG_DATE, SYSLOG_HOST, SYSLOG_SEVERITY, SYSLOG_EVENT_LOGTYPE, SYSLOG_EVENT_SOURCE, SYSLOG_EVENT_ID, SYSLOG_EVENT_USER, SYSLOG_MESSAGE ), + 'userid' => null, + 'groupid' => null, ); // Set default of 'DefaultViewsID' @@ -303,7 +307,6 @@ function LoadSearchesFromDatabase() global $CFG, $content; // --- Create SQL Query - // Create Where for USERID if ( isset($content['SESSION_LOGGEDIN']) && $content['SESSION_LOGGEDIN'] ) $szWhereUser = " OR " . DB_SEARCHES . ".userid = " . $content['SESSION_USERID'] . " "; @@ -314,14 +317,15 @@ function LoadSearchesFromDatabase() $szGroupWhere = " OR " . DB_SEARCHES . ".groupid IN (" . $content['SESSION_GROUPIDS'] . ")"; else $szGroupWhere = ""; - $sqlquery = " SELECT * " . " FROM " . DB_SEARCHES . " WHERE (" . DB_SEARCHES . ".userid IS NULL AND " . DB_SEARCHES . ".groupid IS NULL) " . $szWhereUser . $szGroupWhere . " ORDER BY " . DB_SEARCHES . ".userid, " . DB_SEARCHES . ".groupid, " . DB_SEARCHES . ".DisplayName"; -// " ORDER BY " . DB_SEARCHES . ".DisplayName"; + // --- + + // Get Searches from DB now! $result = DB_Query($sqlquery); $myrows = DB_GetAllRows($result, true); if ( isset($myrows ) && count($myrows) > 0 ) @@ -329,11 +333,51 @@ function LoadSearchesFromDatabase() // Overwrite Search Array with Database one $CFG['Search'] = $myrows; $content['Search'] = $myrows; - - // Cleanup searches and fill / load from database - - } } +function LoadViewsFromDatabase() +{ + // Needed to make global + global $CFG, $content; + + // --- Create SQL Query + // Create Where for USERID + if ( isset($content['SESSION_LOGGEDIN']) && $content['SESSION_LOGGEDIN'] ) + $szWhereUser = " OR " . DB_VIEWS . ".userid = " . $content['SESSION_USERID'] . " "; + else + $szWhereUser = ""; + + if ( isset($content['SESSION_GROUPIDS']) ) + $szGroupWhere = " OR " . DB_VIEWS . ".groupid IN (" . $content['SESSION_GROUPIDS'] . ")"; + else + $szGroupWhere = ""; + $sqlquery = " SELECT * " . + " FROM " . DB_VIEWS . + " WHERE (" . DB_VIEWS . ".userid IS NULL AND " . DB_VIEWS . ".groupid IS NULL) " . + $szWhereUser . + $szGroupWhere . + " ORDER BY " . DB_VIEWS . ".userid, " . DB_VIEWS . ".groupid, " . DB_VIEWS . ".DisplayName"; + // --- + + // Get Views from DB now! + $result = DB_Query($sqlquery); + $myrows = DB_GetAllRows($result, true); + if ( isset($myrows ) && count($myrows) > 0 ) + { + // Overwrite existing Views array + unset($CFG['Views']); + print_r ( $CFG['Views'] ); + exit; + + // ReINIT Views Array + InitViewConfigs(); + + // Merge into existing Views Array! + $CFG['Views'] = array_merge ( $CFG['Views'], $myrows ); + $content['Views'] = $CFG['Views']; + } + +} + ?> \ No newline at end of file diff --git a/src/include/functions_users.php b/src/include/functions_users.php index 2dc8a1b..081110e 100644 --- a/src/include/functions_users.php +++ b/src/include/functions_users.php @@ -222,4 +222,37 @@ function RedirectToDatabaseUpgrade() // --- END Usermanagement Function --- +/* +* Helper function to obtain a list of groups for display +*/ +function GetGroupsForSelectfield() +{ + global $content; + + $sqlquery = "SELECT " . + DB_GROUPS . ".ID as mygroupid, " . + DB_GROUPS . ".groupname " . + "FROM " . DB_GROUPS . + " ORDER BY " . DB_GROUPS . ".groupname"; + $result = DB_Query($sqlquery); + $mygroups = DB_GetAllRows($result, true); + if ( isset($mygroups) && count($mygroups) > 0 ) + { + // Process All Groups + for($i = 0; $i < count($mygroups); $i++) + $mygroups[$i]['group_selected'] = ""; + + // Enable Group Selection + array_unshift( $mygroups, array ("mygroupid" => -1, "groupname" => $content['LN_SEARCH_SELGROUPENABLE'], "group_selected" => "") ); + + // return result + return $mygroups; + } + else + return false; + // --- +} + + + ?> \ No newline at end of file diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index 38f581e..939464e 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -66,6 +66,10 @@ $content['LN_GEN_IPADRRESOLVE'] = "Resolve IP Addresses using DNS"; $content['LN_GEN_CUSTBTNCAPT'] = "Custom search caption"; $content['LN_GEN_CUSTBTNSRCH'] = "Custom search string"; $content['LN_GEN_SUCCESSFULLYSAVED'] = "The configuration Values have been successfully saved"; +$content['LN_GEN_INTERNAL'] = "Internal"; +$content['LN_GEN_DISABLED'] = "Function disabled"; +$content['LN_GEN_USERONLY'] = "For me only
(Only available to your user)"; +$content['LN_GEN_GROUPONLY'] = "For this group
(Only available to the selected group)"; $content['LN_GEN_'] = ""; // User Center @@ -128,16 +132,14 @@ $content['LN_GROUP_'] = ""; // Custom Searches center $content['LN_SEARCH_CENTER'] = "Custom Searches"; -$content['LN_SEARCH_ADD'] = "Add Custom Search"; +$content['LN_SEARCH_ADD'] = "Add new Custom Search"; $content['LN_SEARCH_ID'] = "ID"; $content['LN_SEARCH_NAME'] = "Search Name"; $content['LN_SEARCH_QUERY'] = "Search Query"; -$content['LN_SEARCH_TYPE'] = "Type of Search"; +$content['LN_SEARCH_TYPE'] = "Assigned to"; $content['LN_SEARCH_EDIT'] = "Edit Custom Search"; $content['LN_SEARCH_DELETE'] = "Delete Custom Search"; $content['LN_SEARCH_ADDEDIT'] = "Add / Edit a Custom Search"; -$content['LN_SEARCH_USERONLY'] = "For me only
(Only available to your user)"; -$content['LN_SEARCH_GROUPONLY'] = "For this group
(Only available to the selected group)"; $content['LN_SEARCH_SELGROUPENABLE'] = ">> Select Group to enable <<"; $content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY'] = "The DisplayName cannot be empty."; $content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY'] = "The SearchQuery cannot be empty."; @@ -151,5 +153,30 @@ $content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been succes $content['LN_SEARCH_'] = ""; $content['LN_SEARCH_'] = ""; +// Custom Searches center +$content['LN_VIEWS_CENTER'] = "Views Options"; +$content['LN_VIEWS_ID'] = "ID"; +$content['LN_VIEWS_NAME'] = "View Name"; +$content['LN_VIEWS_COLUMNS'] = "View Columns"; +$content['LN_VIEWS_TYPE'] = "Assigned to"; +$content['LN_VIEWS_ADD'] = "Add new View"; +$content['LN_VIEWS_EDIT'] = "Edit View"; +$content['LN_VIEWS_ERROR_IDNOTFOUND'] = "A View with ID '%1' could not be found."; +$content['LN_VIEWS_ERROR_INVALIDID'] = "The View with ID '%1' is not a valid View."; +$content['LN_VIEWS_WARNDELETEVIEW'] = "Are you sure that you want to delete the View '%1'? This cannot be undone!"; +$content['LN_VIEWS_ERROR_DELSEARCH'] = "Deleting of the View with id '%1' failed!"; +$content['LN_VIEWS_ERROR_HASBEENDEL'] = "The View '%1' has been successfully deleted!"; +$content['LN_VIEWS_ADDEDIT'] = "Add / Edit a View"; +$content['LN_VIEWS_COLUMNLIST'] = "Configured Columns"; +$content['LN_VIEWS_ADDCOLUMN'] = "Add Column into list"; +$content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY'] = "The DisplayName cannot be empty."; +$content['LN_VIEWS_'] = ""; +$content['LN_VIEWS_'] = ""; +$content['LN_VIEWS_'] = ""; +$content['LN_VIEWS_'] = ""; +$content['LN_VIEWS_'] = ""; +$content['LN_VIEWS_'] = ""; +$content['LN_VIEWS_'] = ""; + ?> \ No newline at end of file diff --git a/src/templates/admin/admin_searches.html b/src/templates/admin/admin_searches.html index 0dd8a72..9abae0c 100644 --- a/src/templates/admin/admin_searches.html +++ b/src/templates/admin/admin_searches.html @@ -54,11 +54,11 @@ - {LN_SEARCH_QUERY} + {LN_GEN_USERONLY} - {LN_SEARCH_USERONLY} + {LN_GEN_USERONLY} diff --git a/src/templates/admin/admin_views.html b/src/templates/admin/admin_views.html new file mode 100644 index 0000000..7d60431 --- /dev/null +++ b/src/templates/admin/admin_views.html @@ -0,0 +1,128 @@ + + + +
+

{ERROR_MSG}

+
+ + + + + + + + + +
{LN_VIEWS_CENTER}
+

+ + + + + + + + + + + + + + + + + + + + + + +
{LN_VIEWS_ID}{LN_VIEWS_NAME}{LN_VIEWS_COLUMNS}{LN_VIEWS_TYPE}{LN_GEN_ACTIONS}
{ID}{DisplayName} + {FieldCaptionSeperator}{FieldCaption} + {SearchTypeText} + +   +   + + +   +   + +
 {LN_VIEWS_ADD}
+ + + +
+ + + + + + + + + + + + + + + + + + +
{LN_VIEWS_ADDEDIT}
{LN_VIEWS_NAME}
{LN_GEN_USERONLY}
{LN_GEN_GROUPONLY} + +
+
+ + + + + + + + + + + + + +
{LN_VIEWS_COLUMNLIST}
+ + {ColFieldID} {ColCaption} + +   +
+ + + +
+
+ + + + +
+
+ + + +

+
+
+ + +

+ +
+ + \ No newline at end of file