mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
Reimplemented missing modul "Uservorlage"
This commit is contained in:
parent
b4f8b7aaf6
commit
af3efdc0c4
@ -8780,6 +8780,42 @@ a.land as land, p.abkuerzung as projekt, a.zahlungsweise as zahlungsweise,
|
||||
//$groupby=" GROUP by z.adresse_abrechnung ";
|
||||
|
||||
|
||||
// gesamt anzahl
|
||||
|
||||
$count = "SELECT COUNT(id) FROM user";
|
||||
break;
|
||||
case "usertemplatelist":
|
||||
$allowed['user'] = array('list');
|
||||
$allowed['benutzer'] = array('list');
|
||||
|
||||
// START EXTRA checkboxen
|
||||
|
||||
// ENDE EXTRA checkboxen
|
||||
|
||||
|
||||
// headings
|
||||
|
||||
// $heading = array('Login','Bezeichnung', 'Beschreibung', 'Aktiv', 'Extern', 'Anzahl Rechte', 'Hardware', 'Menü');
|
||||
$heading = array('Bezeichnung', 'Beschreibung', 'Menü');
|
||||
$width = array('20%' ,'50%', '10%');
|
||||
// $findcols = array('u.username','u.type' ,'a.name', "if(u.activ,'ja','-')", "if(u.externlogin,'erlaubt','-')", "IF(u.type = 'standard', (SELECT COUNT(ur.id) FROM userrights ur WHERE ur.user = u.id), 'alle')", 'u.hwtoken', 'u.id'); //'a.name','a.kundennummer',"SUM(TIME_TO_SEC(TIMEDIFF(z.bis, z.von)))/3600",'id');
|
||||
$findcols = array('id','bezeichnung' ,'beschreibung');
|
||||
|
||||
$searchsql = array('id','bezeichnung', 'beschreibung');
|
||||
$defaultorder = 1; //Optional wenn andere Reihenfolge gewuenscht
|
||||
|
||||
$defaultorderdesc = 0;
|
||||
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=uservorlage&action=edit&id=%value%\">" . "<img src=\"themes/{$this->app->Conf->WFconf['defaulttheme']}/images/edit.svg\" border=\"0\"></a>" . " " . "<a href=\"index.php?module=uservorlage&action=download&id=%value%\" title=\"Rechte herunterladen\"><img src=\"./themes/{$this->app->Conf->WFconf['defaulttheme']}/images/download.svg\" border=\"0\"></a> <a href=\"#\" onclick=DeleteDialog(\"index.php?module=uservorlage&action=delete&id=%value%\");>" . "<img src=\"themes/{$this->app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . " </td></tr></table>";
|
||||
|
||||
// SQL statement
|
||||
// $sql = "SELECT SQL_CALC_FOUND_ROWS u.id, u.username as login, u.type, a.name as beschreibung, if(u.activ,'ja','-') as aktiv, if(u.externlogin,'erlaubt','-') as extern, IF(u.type = 'standard' OR u.type = 'lightuser', (SELECT COUNT(ur.id) FROM userrights ur WHERE ur.user = u.id), 'alle') as anzahlrechte,
|
||||
$sql = "SELECT SQL_CALC_FOUND_ROWS id, bezeichnung, beschreibung, id FROM uservorlage";
|
||||
$where = ""; // z.abrechnen=1 AND z.abgerechnet!=1 AND a.id > 0 ";
|
||||
|
||||
|
||||
//$groupby=" GROUP by z.adresse_abrechnung ";
|
||||
|
||||
|
||||
// gesamt anzahl
|
||||
|
||||
$count = "SELECT COUNT(id) FROM user";
|
||||
|
257
www/pages/content/uservorlage_edit.tpl
Normal file
257
www/pages/content/uservorlage_edit.tpl
Normal file
@ -0,0 +1,257 @@
|
||||
<!--<table border="0" width="100%">
|
||||
<tr><td><table width="100%"><tr><td>[USER_CREATE]</td></tr></table></td></tr>
|
||||
</table>-->
|
||||
<style>
|
||||
ul.ui-autocomplete {
|
||||
/*padding-top:100px;*/
|
||||
}
|
||||
#trdummy {
|
||||
height:0;
|
||||
width:0;
|
||||
overflow: hidden;
|
||||
display:none;
|
||||
}
|
||||
</style>
|
||||
<!-- gehort zu tabview -->
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tabs-1">{|Benutzervorlage|}</a></li>
|
||||
[VORRECHTE]<li><a href="#tabs-3">{|Rechte|}</a></li>[NACHRECHTE]
|
||||
</ul>
|
||||
<!-- ende gehort zu tabview -->
|
||||
|
||||
<!-- erstes tab -->
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<form enctype="multipart/form-data" action="" method="post" name="eprooform" id="usereditform">
|
||||
[FORMHANDLEREVENT]
|
||||
|
||||
<table class="tableborder" border="0" cellpadding="3" cellspacing="0" width="100%">
|
||||
<tbody>
|
||||
<tr valign="top" colspan="3">
|
||||
<td >
|
||||
<fieldset><legend>{|Benutzervorlage|}</legend>
|
||||
<table width="100%" border="0">
|
||||
<tr><td>{|Bezeichnung|}:*</td><td><input type="text" id="bezeichnung" name="bezeichnung" value="[BEZEICHNUNG]" size="40"></td></tr>
|
||||
<tr><td width="200">{|Interne Beschreibung|}:</td><td><textarea name="beschreibung" rows=6 cols=40>[BESCHREIBUNG]</textarea> <i>{|Dient für Infos oder Notizen.|}</i></td></tr>
|
||||
|
||||
|
||||
</table></fieldset>
|
||||
|
||||
[VORRECHTE]
|
||||
|
||||
<fieldset><legend>{|Rechtedatei heraufladen|}</legend>
|
||||
<table><tr><td width="200">{|Datei auswählen|}:</td><td><input type="hidden"/><input name="jsonvorlage" type="file" />
|
||||
</td></tr></table>
|
||||
</fieldset>
|
||||
|
||||
|
||||
[NACHRECHTE]
|
||||
|
||||
</td></tr>
|
||||
|
||||
<tr valign="" height="" bgcolor="" align="" bordercolor="" class="klein" classname="klein">
|
||||
<td width="" valign="" height="" bgcolor="" align="right" colspan="3" bordercolor="" classname="orange2" class="orange2">
|
||||
<input type="submit" id="submit" name="submituservorlage" value="Speichern" />
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- tab view schließen -->
|
||||
<style>
|
||||
table.module {
|
||||
width: 100%;
|
||||
border-spacing: 1px;
|
||||
}
|
||||
|
||||
table.module td.name {
|
||||
width: 100%;
|
||||
padding: 5px 10px;
|
||||
background:#5CCD00;
|
||||
color: #fff;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
border-radius: 3px;
|
||||
background:-moz-linear-gradient(top,#5CCD00 0%,#4AA400 100%);
|
||||
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#5CCD00),color-stop(100%,#4AA400));
|
||||
background:-webkit-linear-gradient(top,#5CCD00 0%,#4AA400 100%);
|
||||
background:-o-linear-gradient(top,#5CCD00 0%,#4AA400 100%);
|
||||
background:-ms-linear-gradient(top,#5CCD00 0%,#4AA400 100%);
|
||||
background:linear-gradient(top,#5CCD00 0%,#4AA400 100%);
|
||||
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5CCD00',endColorstr='#4AA400',GradientType=0);
|
||||
}
|
||||
|
||||
table.action {
|
||||
width: 100%;
|
||||
margin-bottom: 20px;
|
||||
border-spacing: 2px;
|
||||
}
|
||||
|
||||
table.action td.blue {
|
||||
padding: 3px;
|
||||
background:#25A6E1;
|
||||
color: #fff;
|
||||
border: 1px solid #0D7EE8;
|
||||
border-radius: 2px;
|
||||
background:-moz-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
|
||||
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#25A6E1),color-stop(100%,#188BC0));
|
||||
background:-webkit-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
|
||||
background:-o-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
|
||||
background:-ms-linear-gradient(top,#25A6E1 0%,#188BC0 100%);
|
||||
background:linear-gradient(top,#25A6E1 0%,#188BC0 100%);
|
||||
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#25A6E1',endColorstr='#188BC0',GradientType=0);
|
||||
}
|
||||
|
||||
table.action td.grey {
|
||||
padding: 3px;
|
||||
color: #fff;
|
||||
border-radius: 2px;
|
||||
background: #666666;
|
||||
background: -moz-linear-gradient(top, #666666 0%, #969696 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#666666), color-stop(100%,#969696));
|
||||
background: -webkit-linear-gradient(top, #666666 0%,#969696 100%);
|
||||
background: -o-linear-gradient(top, #666666 0%,#969696 100%);
|
||||
background: -ms-linear-gradient(top, #666666 0%,#969696 100%);
|
||||
background: linear-gradient(to bottom, #666666 0%,#969696 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#666666', endColorstr='#969696',GradientType=0 );
|
||||
}
|
||||
|
||||
table.action td.blue:hover, td.grey:hover {
|
||||
cursor: pointer;
|
||||
text-shadow: 0px 2px 2px #555;
|
||||
}
|
||||
|
||||
.allrightsremove {
|
||||
float: right;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.allrights {
|
||||
float: right;
|
||||
font-weight: normal;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
function ChangeRights(el, vorlage, module, action) {
|
||||
var value = $(el).attr('value');
|
||||
if(value=='1') value = 0; else value = 1;
|
||||
$.ajax({
|
||||
url: './index.php?module=uservorlage&action=chrights&b_vorlage='+vorlage+'&b_module='+module+'&b_action='+action+'&b_value='+value,
|
||||
success: function(r) {
|
||||
if((r+'').substr(0,5) == 'Error')
|
||||
{
|
||||
$('#trerror').remove();
|
||||
$(el).parents('table').first().parents('tr').first().prev().after('<tr id="trerror"><td><div class="error">'+(r+'').substr(5)+'</div></td></tr>');
|
||||
setTimeout(function(){$('#trerror').remove();},3000);
|
||||
}else{
|
||||
if(r==1) {
|
||||
$(el).attr('value', '1')
|
||||
$(el).removeClass('grey');
|
||||
$(el).addClass('blue');
|
||||
}else{
|
||||
$(el).attr('value', '0')
|
||||
$(el).removeClass('blue');
|
||||
$(el).addClass('grey');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
var geladenSoll = 0;
|
||||
var geladenIst = 0;
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#roletext').on('change', function(){
|
||||
$('#role').val($(this).val());
|
||||
});
|
||||
$('#selrole').on('change', function(){
|
||||
if($(this).val()+'' === '' || $(this).val()+'' === 'Sonstiges') {
|
||||
$('#roletext').show();
|
||||
$('#role').val($('#roletext').val());
|
||||
}
|
||||
else {
|
||||
$('#roletext').hide();
|
||||
$('#role').val($(this).val());
|
||||
}
|
||||
});
|
||||
$('#selrole').trigger('change');
|
||||
$('td.name').append('<button class="allrights" onclick="">{|Alle setzen|}</button>');
|
||||
$('td.name').append('<button class="allrightsremove" onclick="">{|Alle entfernen|}</button>');
|
||||
$('.allrightsremove').click(function() {
|
||||
|
||||
geladenSoll = 0;
|
||||
geladenIst = 0;
|
||||
|
||||
// App.loading.open();
|
||||
|
||||
var values = 0;
|
||||
var fields = 0;
|
||||
var rights = $(this).parent().parent().next().find('table.action').find('td');
|
||||
|
||||
|
||||
$.each(rights, function(key,elem) {
|
||||
|
||||
var onclick = $(elem).attr('onclick');
|
||||
if (typeof onclick != 'undefined') {
|
||||
|
||||
$(elem).attr('value', 1);
|
||||
// $(elem).removeClass('blue');
|
||||
// $(elem).addClass('grey');
|
||||
|
||||
eval(onclick);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('.allrights').click(function() {
|
||||
|
||||
geladenSoll = 0;
|
||||
geladenIst = 0;
|
||||
|
||||
// App.loading.open();
|
||||
|
||||
var values = 0;
|
||||
var fields = 0;
|
||||
var rights = $(this).parent().parent().next().find('table.action').find('td');
|
||||
|
||||
|
||||
$.each(rights, function(key,elem) {
|
||||
|
||||
var onclick = $(elem).attr('onclick');
|
||||
if (typeof onclick != 'undefined') {
|
||||
|
||||
$(elem).attr('value', 0);
|
||||
// $(elem).removeClass('grey');
|
||||
// $(elem).addClass('blue');
|
||||
|
||||
|
||||
eval(onclick);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
[VORRECHTE]
|
||||
<div id="tabs-3">
|
||||
[HINWEISADMIN]
|
||||
<br><br>
|
||||
<table class="module">
|
||||
[MODULES]
|
||||
</table>
|
||||
|
||||
</div>
|
||||
[NACHRECHTE]
|
||||
</div>
|
20
www/pages/content/uservorlage_list.tpl
Normal file
20
www/pages/content/uservorlage_list.tpl
Normal file
@ -0,0 +1,20 @@
|
||||
<div id="tabs">
|
||||
<ul><li><a href="#tabs-1"></a></li></ul>
|
||||
<div id="tabs-1">
|
||||
[MESSAGE]
|
||||
<div class="row">
|
||||
<div class="row-height">
|
||||
<div class="col-xs-12 col-sm-12 col-sm-height">
|
||||
<div class="inside inside-full-height">
|
||||
<fieldset>
|
||||
<legend></legend>
|
||||
[USER_TABLE]
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
[POPUP]
|
530
www/pages/uservorlage.php
Normal file
530
www/pages/uservorlage.php
Normal file
@ -0,0 +1,530 @@
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
|
||||
*
|
||||
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
|
||||
*
|
||||
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
|
||||
Copyright (c) 2022 Xenomporio project
|
||||
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
use Xentral\Modules\RoleSurvey\SurveyGateway;
|
||||
use Xentral\Modules\RoleSurvey\SurveyService;
|
||||
|
||||
use Xentral\Components\Database\Exception\QueryFailureException;
|
||||
|
||||
class Uservorlage
|
||||
{
|
||||
function __construct($app, $intern = false)
|
||||
{
|
||||
$this->app=$app;
|
||||
if($intern)return;
|
||||
|
||||
$this->app->ActionHandlerInit($this);
|
||||
|
||||
$this->app->ActionHandler("create","UservorlageCreate");
|
||||
$this->app->ActionHandler("delete","UservorlageDelete");
|
||||
$this->app->ActionHandler("edit","UservorlageEdit");
|
||||
$this->app->ActionHandler("list","UservorlageList");
|
||||
$this->app->ActionHandler("chrights","UservorlageChangeRights");
|
||||
$this->app->ActionHandler("download","UservorlageDownload");
|
||||
|
||||
|
||||
$this->app->DefaultActionHandler("list");
|
||||
|
||||
//$this->Templates = $this->GetTemplates();
|
||||
|
||||
$this->app->ActionHandlerListen($app);
|
||||
}
|
||||
|
||||
public function Install()
|
||||
{
|
||||
}
|
||||
|
||||
function UservorlageDownload()
|
||||
{
|
||||
$id = $this->app->Secure->GetGET("id");
|
||||
if($id > 0)
|
||||
{
|
||||
$result = $this->app->DB->SelectArr("SELECT module,action FROM uservorlagerights WHERE `vorlage`='$id'");
|
||||
|
||||
$tmp['bezeichnung']=$this->app->DB->Select("SELECT bezeichnung FROM `uservorlage` WHERE id='$id' LIMIT 1");
|
||||
$tmp['beschreibung']=$this->app->DB->Select("SELECT beschreibung FROM `uservorlage` WHERE id='$id' LIMIT 1");
|
||||
$tmp['rechte']=$result;
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header('Content-disposition: attachment; filename="'.$tmp['bezeichnung'].'.json"');
|
||||
echo json_encode($tmp);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function UservorlageList()
|
||||
{
|
||||
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=list","Übersicht");
|
||||
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=history","Historie");
|
||||
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=create","Neue Benutzervorlage anlegen");
|
||||
$this->app->erp->MenuEintrag("index.php?module=einstellungen&action=list","Zurück zur Übersicht");
|
||||
|
||||
$this->app->YUI->TableSearch('USER_TABLE',"usertemplatelist");
|
||||
$this->app->Tpl->Parse('PAGE', "uservorlage_list.tpl");
|
||||
|
||||
}
|
||||
|
||||
public function UservorlageDelete(): void
|
||||
{
|
||||
$id = (int)$this->app->Secure->GetGET('id');
|
||||
|
||||
$benutzervorlage = $this->app->DB->Select("SELECT bezeichnung FROM `uservorlage` WHERE id='$id' LIMIT 1");
|
||||
$users = $this->app->DB->Select("SELECT `username` FROM `user` WHERE `vorlage` = '$benutzervorlage'");
|
||||
$prefix = "\"";
|
||||
if (!empty($users)) {
|
||||
$usernames = "";
|
||||
if (is_array($users)) {
|
||||
foreach ($users as $user) {
|
||||
$usernames = $usernames.$prefix.$user[0]."\"";
|
||||
$prefix = ", \"";
|
||||
}
|
||||
} else {
|
||||
$usernames = $users;
|
||||
}
|
||||
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">{|Benutzervorlage \"$benutzervorlage\" ist in Benutzung durch ".$usernames.".|}</div>");
|
||||
} else {
|
||||
$this->app->DB->Delete("DELETE FROM `uservorlage` WHERE `id` = '{$id}'");
|
||||
$this->app->DB->Delete("DELETE FROM `uservorlagerights` WHERE `vorlage` = '{$id}'");
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Die Benutzervorlage \"$benutzervorlage\" wurde gelöscht.</div>");
|
||||
}
|
||||
|
||||
$this->UservorlageList();
|
||||
}
|
||||
|
||||
function UservorlageCreate()
|
||||
{
|
||||
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=list","Zurück zur Übersicht");
|
||||
|
||||
$input = $this->GetInput();
|
||||
$submit = $this->app->Secure->GetPOST('submituservorlage');
|
||||
|
||||
$error = '';
|
||||
$maxlightuser = 0;
|
||||
|
||||
if($submit!='') {
|
||||
|
||||
if($input['bezeichnung']=='') {
|
||||
$error .= 'Geben Sie bitte einen Vorlagennamen ein.<br>';
|
||||
}
|
||||
if($this->app->DB->Select("SELECT '1' FROM `uservorlage` WHERE bezeichnung='{$input['bezeichnung']}' LIMIT 1")=='1') {
|
||||
$error .= "Es existiert bereits eine Vorlage mit diesem Namen";
|
||||
}
|
||||
|
||||
if($error!=='')
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">$error</div>");
|
||||
else {
|
||||
|
||||
$id = $this->app->erp->CreateBenutzerVorlage($input);
|
||||
|
||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Die Benutzervorlage wurde erfolgreich angelegt.</div>");
|
||||
header("Location: index.php?module=uservorlage&action=edit&id=$id&msg=$msg");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->SetInput($input);
|
||||
|
||||
$this->app->Tpl->Set('ACTIVCHECKED',"checked");
|
||||
$this->app->Tpl->Set('VORRECHTE',"<!--");
|
||||
$this->app->Tpl->Set('NACHRECHTE',"-->");
|
||||
$extra = '
|
||||
if($(\'#hwtoken\').val() == \'4\' || $(\'#hwtoken\').val() == \'5\')
|
||||
{
|
||||
message = \'\';
|
||||
}
|
||||
';
|
||||
$this->app->YUI->PasswordCheck('password', 'repassword', 'username', 'submit', $extra);
|
||||
$this->app->Tpl->Parse('PAGE', "uservorlage_edit.tpl");
|
||||
}
|
||||
|
||||
function UservorlageEdit()
|
||||
{
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$this->app->Tpl->Set('ID', $id);
|
||||
|
||||
// JSON Upload
|
||||
$jsonvorlage = $_FILES['jsonvorlage']['tmp_name'];
|
||||
if($jsonvorlage!="")
|
||||
{
|
||||
$content = file_get_contents($jsonvorlage);
|
||||
$tmp = json_decode($content);
|
||||
$neuerechte=0;
|
||||
|
||||
$anzahl = count($tmp->{'rechte'});
|
||||
for($i=0;$i<=$anzahl;$i++)
|
||||
{
|
||||
$tmpmodule = $this->app->DB->real_escape_string($tmp->{'rechte'}[$i]->{'module'});
|
||||
$tmpaction = $this->app->DB->real_escape_string($tmp->{'rechte'}[$i]->{'action'});
|
||||
|
||||
if($tmpmodule!="" && $tmpaction!="")
|
||||
{
|
||||
$check = $this->app->DB->Select("SELECT id FROM uservorlagerights WHERE module='".$tmpmodule."' AND action='".$tmpaction."' AND vorlage='".$id."' LIMIT 1");
|
||||
|
||||
if($check > 0)
|
||||
$this->app->DB->Update("UPDATE uservorlagerights SET permission=1 WHERE module='".$tmpmodule."' AND action='".$tmpaction."' AND vorlage='".$id."' LIMIT 1");
|
||||
else {
|
||||
$neuerechte++;
|
||||
$this->app->DB->Insert("INSERT INTO uservorlagerights (id,module,action,vorlage,permission) VALUES ('','".$tmpmodule."','".$tmpaction."','$id','1')");
|
||||
}
|
||||
}
|
||||
}
|
||||
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Es wurden $neuerechte neue Rechte der Vorlage hinzugefügt!</div>");
|
||||
header("Location: index.php?module=uservorlage&action=edit&id=$id&msg=$msg");
|
||||
exit;
|
||||
}
|
||||
// END JSON Upload
|
||||
|
||||
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=edit&id=$id","Details");
|
||||
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=list","Zurück zur Übersicht");
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$input = $this->GetInput();
|
||||
$submit = $this->app->Secure->GetPOST('submituservorlage');
|
||||
|
||||
// Input GET
|
||||
if(is_numeric($id) && $submit!='') {
|
||||
$error = '';
|
||||
if ($input['bezeichnung']=='') {
|
||||
$error .= 'Geben Sie bitte eine Bezeichnung ein.<br>';
|
||||
}
|
||||
else {
|
||||
|
||||
$this->app->DB->Update(
|
||||
sprintf(
|
||||
"UPDATE `uservorlage`
|
||||
SET bezeichnung='%s',
|
||||
beschreibung='%s'
|
||||
WHERE id=%d
|
||||
LIMIT 1",
|
||||
$input['bezeichnung'],
|
||||
$input['beschreibung'],
|
||||
$id
|
||||
)
|
||||
);
|
||||
|
||||
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich übernommen.</div>");
|
||||
|
||||
$this->app->erp->AbgleichBenutzerVorlagen($id);
|
||||
}
|
||||
} // END Input Get
|
||||
|
||||
$benutzervorlage = $this->app->DB->Select("SELECT bezeichnung FROM `uservorlage` WHERE id='$id' LIMIT 1");
|
||||
$beschreibung = $this->app->DB->Select("SELECT beschreibung FROM `uservorlage` WHERE id='$id' LIMIT 1");
|
||||
$this->app->Tpl->Add('KURZUEBERSCHRIFT2',$benutzervorlage);
|
||||
$this->app->Tpl->Add('BEZEICHNUNG',$benutzervorlage);
|
||||
$this->app->Tpl->Add('BESCHREIBUNG',$beschreibung);
|
||||
|
||||
$this->UserRights();
|
||||
$this->app->Tpl->Parse('PAGE', "uservorlage_edit.tpl");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetInput(): array
|
||||
{
|
||||
$input = array();
|
||||
$input['bezeichnung'] = $this->app->Secure->GetPOST('bezeichnung');
|
||||
$input['beschreibung'] = $this->app->Secure->GetPOST('beschreibung');
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
function SetInput($input)
|
||||
{
|
||||
$this->app->Tpl->Set('BEZEICHNUNG', $input['bezeichnung']);
|
||||
$this->app->Tpl->Set('BESCHREIBUNG', $input['beschreibung']);
|
||||
}
|
||||
|
||||
function UserRights()
|
||||
{
|
||||
$id = $this->app->Secure->GetGET('id');
|
||||
$template = $this->app->Secure->GetPOST('bezeichnung');
|
||||
$copytemplate = $this->app->Secure->GetPOST('copyusertemplate');
|
||||
|
||||
$modules = $this->ScanModules();
|
||||
|
||||
{
|
||||
|
||||
if($template!='') {
|
||||
$mytemplate = $this->app->Conf->WFconf['permissions'][$template];
|
||||
$permissions = $this->app->DB->SelectArr("SELECT module,action FROM uservorlagerights WHERE `vorlage`=$id");
|
||||
$this->app->DB->Delete("DELETE FROM uservorlagerights WHERE `vorlage`='$id'");
|
||||
|
||||
$modulecount = (!empty($modules)?count($modules):0);
|
||||
$curModule = 0;
|
||||
|
||||
foreach($modules as $module=>$actions) {
|
||||
$lower_m = strtolower($module);
|
||||
$curModule++;
|
||||
$actioncount = (!empty($actions)?count($actions):0);
|
||||
for($i=0;$i<$actioncount;$i++) {
|
||||
$delimiter = (($curModule<$modulecount || $i+1<$actioncount) ? ', ' : ';');
|
||||
$active = ((isset($mytemplate[$lower_m]) && in_array($actions[$i], $mytemplate[$lower_m])) ? '1' : '0');
|
||||
if($active==1){
|
||||
$this->app->DB->Insert("INSERT INTO uservorlagerights (`vorlage`, module, action, permission) VALUES ('$id', '$lower_m', '{$actions[$i]}', '$active')");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($copytemplate!='') {
|
||||
$ok = true;
|
||||
if($ok)
|
||||
{
|
||||
$permissions = $this->app->DB->SelectArr("SELECT module,action FROM uservorlagerights WHERE `vorlage`=$id");
|
||||
$this->app->DB->Delete("DELETE FROM uservorlagerights WHERE `vorlage`='$id'");
|
||||
$permissions = $this->app->DB->SelectArr("SELECT module,action FROM userrights WHERE vorlage=$copytemplate");
|
||||
$this->app->DB->Update("INSERT INTO uservorlagerights (`vorlage`, module,action,permission) (SELECT '$id',module, action,permission FROM uservorlagerights WHERE vorlage='".$copytemplate."')");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dbrights = $this->app->DB->SelectArr("SELECT module, action, permission FROM uservorlagerights WHERE `vorlage`='$id' ORDER BY module");
|
||||
|
||||
$rights = $this->app->Conf->WFconf['permissions'][$group];
|
||||
if ((!empty($dbrights)?count($dbrights):0)>0) {
|
||||
$rights = $this->AdaptRights($dbrights, $rights, $group);
|
||||
}
|
||||
|
||||
$modules = $this->ScanModules();
|
||||
$table = $this->CreateTable($id, $modules, $rights);
|
||||
|
||||
$this->app->Tpl->Set('MODULES', $table);
|
||||
}
|
||||
|
||||
/*
|
||||
Ajax handler
|
||||
*/
|
||||
function UservorlageChangeRights()
|
||||
{
|
||||
$vorlage = $this->app->Secure->GetGET('b_vorlage');
|
||||
$module = $this->app->Secure->GetGET('b_module');
|
||||
$action = $this->app->Secure->GetGET('b_action');
|
||||
$value = $this->app->Secure->GetGET('b_value');
|
||||
|
||||
if(is_numeric($vorlage) && $module!='' && $action!='' && $value!='') {
|
||||
|
||||
$id = $this->app->DB->Select("SELECT id FROM uservorlagerights WHERE vorlage='$vorlage' AND module='$module' AND action='$action' LIMIT 1");
|
||||
|
||||
if(is_numeric($id) && $id>0)
|
||||
{
|
||||
if($value=="1")
|
||||
{
|
||||
$this->app->DB->Update("UPDATE uservorlagerights SET permission=1 WHERE id='$id' LIMIT 1");
|
||||
}
|
||||
else {
|
||||
$this->app->DB->Delete("DELETE FROM uservorlagerights WHERE vorlage='$vorlage' AND module='$module' AND action='$action'");
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->app->DB->Insert("INSERT INTO uservorlagerights (vorlage, module, action, permission) VALUES ('$vorlage', '$module', '$action', '$value')");
|
||||
}
|
||||
|
||||
echo $this->app->DB->Select("SELECT permission FROM uservorlagerights WHERE vorlage='$vorlage' AND module='$module' AND action='$action' LIMIT 1");
|
||||
exit;
|
||||
}
|
||||
|
||||
function AdaptRights($dbarr, $rights)
|
||||
{
|
||||
$cnt = (!empty($dbarr)?count($dbarr):0);
|
||||
for($i=0;$i<$cnt;$i++) {
|
||||
$module = $dbarr[$i]['module'];
|
||||
$action = $dbarr[$i]['action'];
|
||||
$perm = $dbarr[$i]['permission'];
|
||||
|
||||
if(isset($rights[$module])) {
|
||||
if($perm=='1' && !in_array($action, $rights[$module]))
|
||||
$rights[$module][] = $action;
|
||||
|
||||
if($perm=='0' && in_array($action, $rights[$module])) {
|
||||
$index = array_search($action, $rights[$module]);
|
||||
unset($rights[$module][$index]);
|
||||
$rights[$module] = array_values($rights[$module]);
|
||||
}
|
||||
}else if($perm=='1') $rights[$module][] = $action;
|
||||
}
|
||||
return $rights;
|
||||
}
|
||||
|
||||
function CreateTable($user, $modules, $rights)
|
||||
{
|
||||
$maxcols = 6;
|
||||
$width = 100 / $maxcols;
|
||||
$out = '';
|
||||
foreach($modules as $key=>$value) {
|
||||
if(strtolower($key) == 'api' || strtolower($key) == 'ajax')continue;
|
||||
$out .= "<tr><td class=\"name\">$key</td></tr>";
|
||||
|
||||
$out .= "<tr><td><table class=\"action\">";
|
||||
$module = strtolower($key);
|
||||
for($i=0;$i<$maxcols || $i<(!empty($value)?count($value):0);$i++) {
|
||||
if($i%$maxcols==0) $out .= "<tr>";
|
||||
|
||||
if (gettype($rights[$module]) == 'array') {
|
||||
|
||||
if(isset($value[$i]) && in_array($value[$i], $rights[$module])) {
|
||||
$class = 'class="blue"';
|
||||
$active = '1';
|
||||
}else{
|
||||
$class = 'class="grey"';
|
||||
$active = 0;
|
||||
}
|
||||
} else {
|
||||
$class = 'class="grey"';
|
||||
$active = 0;
|
||||
}
|
||||
|
||||
$class = ((isset($value[$i])) ? $class : '');
|
||||
|
||||
$action = ((isset($value[$i])) ? strtolower($value[$i]) : '');
|
||||
$onclick = ((isset($value[$i])) ? "onclick=\"ChangeRights(this, '$user','$module','$action')\"" : '');
|
||||
$out .= "<td width=\"$width%\" $class value=\"$active\" $onclick>{$action}</td>";
|
||||
|
||||
if($i%$maxcols==($maxcols-1)) $out .= "</tr>";
|
||||
}
|
||||
$out .= "</table></td></tr>";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $page
|
||||
* @param array $actions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getActionsFromFile($page, $actions = [])
|
||||
{
|
||||
if(substr($page,-8) === '.src.php') {
|
||||
return $actions;
|
||||
}
|
||||
$content = file_get_contents($page);
|
||||
$foundItems = preg_match_all('/ActionHandler\([\"|\\\'][[:alnum:]].*[\"|\\\'],/', $content, $matches);
|
||||
if($foundItems <= 0) {
|
||||
return $actions;
|
||||
}
|
||||
$action = str_replace(array('ActionHandler("','ActionHandler(\'','",' , '\',' ),'', $matches[0]);
|
||||
if(empty($action) || !is_array($action)) {
|
||||
return $actions;
|
||||
}
|
||||
if(isset($actions)) {
|
||||
$actionsCount = $action ? count($action) : 0;
|
||||
for ($i = 0; $i < $actionsCount; $i++) {
|
||||
if(empty($action[$i])) {
|
||||
continue;
|
||||
}
|
||||
$found = false;
|
||||
foreach ($actions as $v) {
|
||||
if($v == $action[$i]){
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$found){
|
||||
$actions[] = $action[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$actionsCount = $action ? count($action) : 0;
|
||||
for ($i = 0; $i < $actionsCount; $i++) {
|
||||
$actions[] = $action[$i];
|
||||
}
|
||||
}
|
||||
sort($actions);
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function ScanModules()
|
||||
{
|
||||
//$files = glob('./pages/*.php');
|
||||
$files = glob(__DIR__.'/*.php');
|
||||
$encodedActions = [];
|
||||
if(method_exists($this->app->erp,'getEncModullist')) {
|
||||
$encodedActions = $this->app->erp->getEncModullist();
|
||||
}
|
||||
if(empty($encodedActions)) {
|
||||
$encodedActions = [];
|
||||
}
|
||||
$modules = array();
|
||||
if(empty($files)) {
|
||||
return $encodedActions;
|
||||
}
|
||||
foreach($files as $page) {
|
||||
$name = ucfirst(str_replace('_custom','',basename($page,'.php')));
|
||||
if(substr($page,-8) === '.src.php') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$modules[$name] = $this->getActionsFromFile($page, isset($modules[$name]) ? $modules[$name]: []);
|
||||
|
||||
if(!empty($encodedActions[$name]) && is_array($encodedActions[$name]) && count($encodedActions[$name]) > 0) {
|
||||
if(isset($modules[$name])) {
|
||||
$encodedActionsCount = $encodedActions[$name]?count($encodedActions[$name]):0;
|
||||
for($i=0;$i<$encodedActionsCount;$i++) {
|
||||
$found = false;
|
||||
foreach($modules[$name] as $moduleAction) {
|
||||
if($moduleAction == $encodedActions[$name][$i]) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$found) {
|
||||
$modules[$name][] = $encodedActions[$name][$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$modules[$name] = $encodedActions[$name];
|
||||
}
|
||||
sort($modules[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($modules as $name => $actions) {
|
||||
if(empty($actions)) {
|
||||
unset($modules[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
function TemplateSelect()
|
||||
{
|
||||
$options = "<option value=\"\">-- Bitte auswählen --</option>";
|
||||
foreach($this->Templates as $key=>$value) {
|
||||
if($key!="web")
|
||||
$options .= "<option value=\"$key\">".ucfirst($key)."</option>";
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function GetTemplates()
|
||||
{
|
||||
return $this->app->Conf->WFconf['permissions'];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user