00001 <?php
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once ('./general.php');
00026 require_once ('./lib/group.php');
00027
00028
00029 $oStyle->setTemplate ( 'group.html' );
00030
00031 $oGroup = new Group ( $oMysql, $oLog, $aAdmin, $aAdminArrays, $aRightNames );
00032
00033
00034 if(isset($_POST['action'])) $action = $_POST['action'];
00035 elseif(isset($_GET['action'])) $action = $_GET['action'];
00036 else $action = 'list';
00037
00038
00039 if ($action == 'edit' && $oUser->isAdmin ( 'group_edit' ) )
00040 {
00041 if ( !isset ( $_POST['newrights'] ) || !is_array ( $_POST['newrights'] ) )
00042 {
00043 die();
00044 }
00045 $aNew =& $_POST['newrights'];
00046 $aGroups = $oGroup->getAll();
00047 foreach ( $aGroups AS $aData )
00048 {
00049 if ( isset ( $aNew[$aData['usergroup_id']] ) )
00050 {
00051
00052 unset ( $aNew[$aData['usergroup_id']]['set'] );
00053 $oGroup->set ( $aData['usergroup_id'], $aData['name'], $aNew[$aData['usergroup_id']] );
00054 }
00055 }
00056 $oStyle->addReplacements ( array ( 'REFRESH_URL' => 'group.php',
00057 'REFRESH_MSG' => 'Rechte erfolgreich geändert.' ) );
00058 echo trim ( $oStyle->get_area('Refresh') );
00059 die();
00060 }
00061
00062 elseif ( $action=='add' && $oUser->isAdmin ( 'group_add' ) )
00063 {
00064 if ( isset ( $_POST['newrights'] ) && is_array ( $_POST['newrights'] ) )
00065 {
00066
00067 $strName = $_POST['newrights'][0]['name'];
00068 unset ( $_POST['newrights'][0]['name'] );
00069 $booSuccess = $oGroup->add ( $strName, $_POST['newrights'][0] );
00070 $strMsg = $booSuccess ? 'Gruppe erfolgreich angelegt.' : 'Eine Gruppe mit diesem Namen existiert bereits';
00071 $oStyle->addReplacements ( array ( 'REFRESH_URL' => 'group.php',
00072 'REFRESH_MSG' => $strMsg ) );
00073 echo trim ( $oStyle->get_area('Refresh') );
00074 die();
00075 }
00076
00077 $i = 1;
00078 $strHead = '';
00079 $strInfo = '';
00080 $strNewGroup = '';
00081 foreach ( $aRightNames AS $strRight => $aRightInfo )
00082 {
00083 $strHead .= '<td>'.$aRightInfo[0].'</td>';
00084 $strInfo .= '<tr id="ar_'.$strRight.'"><td>'.$aRightInfo[0].'</td><td>'.$aRightInfo[1].'</td></tr>';
00085 $oStyle->addReplacements ( array ( 'RIGHT' => $strRight, 'CHECKED' => '', 'GROUP_ID' => '0' ) );
00086 $strNewGroup .= $oStyle->get_area('GroupChk');
00087 $i++;
00088 }
00089
00090 $oStyle->addReplacements ( array ( 'GROUP_HEAD' => $strHead,
00091 'GROUP_COLSPAN' => $i,
00092 'GROUP_INFO' => $strInfo,
00093 'GROUP_NEW' => $strNewGroup ) );
00094 }
00095
00096 if ( $action == 'list' && $oUser->isAdmin ( 'group_list' ) )
00097 {
00098 $aGroups = $oGroup->getAll();
00099 $i = 0;
00100 $strGroupList = '';
00101 foreach ( $aGroups AS $aData )
00102 {
00103 $oStyle->addReplacements ( array ( 'GROUP_NAME' => $aData['name'],
00104 'GROUP_ID' => $aData['usergroup_id'],
00105 'GROUP_ROW' => intval(($i++ % 2) == 0)
00106 ) );
00107 $strTest = '';
00108
00109 foreach ( $aRightNames AS $strRight => $aRightInfo )
00110 {
00111 $strChecked = '';
00112 foreach ( $aAdminArrays AS $intKey => $strField )
00113 {
00114 if ( isset ( $aAdmin[$intKey][$strRight] ) && ( ( $aAdmin[$intKey][$strRight] & $aData[$strField] ) > 0 ) )
00115 {
00116 $strChecked = ' checked="checked"';
00117 }
00118 }
00119 $oStyle->addReplacements ( array ( 'RIGHT' => $strRight,
00120 'CHECKED' => $strChecked
00121 ) );
00122 $strTest .= $oStyle->get_area('GroupChk');
00123 }
00124
00125 $oStyle->addReplacements ( array ( 'RIGHTS' => $strTest ) );
00126 $strGroupList .= $oStyle->get_area( 'GroupRow' );
00127 }
00128
00129 $i = 1;
00130 $strHead = '';
00131 $strInfo = '';
00132 $aInfo = array();
00133 $intNames = ceil( count( $aRightNames ) / 2 );
00134 $intNamesF = floor( count( $aRightNames ) / 2 );
00135 foreach ( $aRightNames AS $strRight => $aRightInfo )
00136 {
00137 $strHead .= '<td>'.$aRightInfo[0].'</td>';
00138 $aInfo[$i] = array( $aRightInfo[0], $strRight, $aRightInfo[1] );
00139 $i++;
00140 }
00141 for( $j=1; $j<=$intNames; ++$j )
00142 {
00143 $strInfo .= '<tr><td>'.$aInfo[$j][0].'</td><td id="ar_'.$aInfo[$j][1].'">'.$aInfo[$j][2].'</td>';
00144 if( isset( $aInfo[$j+$intNamesF] ) )
00145 {
00146 $strInfo .= '<td>'.$aInfo[$j+$intNamesF][0].'</td><td id="ar_'.$aInfo[$j+$intNamesF][1].'">'.$aInfo[$j+$intNamesF][2].'</td></tr>';
00147 }
00148 else
00149 {
00150 $strInfo .= '<td colspan="2"></td></tr>';
00151 }
00152 }
00153
00154 $oStyle->addReplacements ( array ( 'GROUP_HEAD' => $strHead,
00155 'GROUP_COLSPAN' => $i,
00156 'GROUP_INFO' => $strInfo,
00157 'GROUP_RESULT' => $strGroupList ) );
00158 }
00159
00160
00161 $strTmpl_inhalt = $oStyle->get_area( ucfirst($action) );
00162 output();