mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Speicheroptimierung bei Berechtigungskonzept
This commit is contained in:
@@ -406,7 +406,7 @@ function js_toggle_container(conid)
|
||||
if(!is_dir($path))
|
||||
{
|
||||
if(!is_dir('../../../documents/'.strtolower($short)))
|
||||
exec('mkdir -m 775 "../../../documents/'.strtolower($short).'"');
|
||||
exec('mkdir -m 755 "../../../documents/'.strtolower($short).'"');
|
||||
exec('mkdir -m 775 "../../../documents/'.strtolower($short).'/download"');
|
||||
exec('chgrp teacher ../../../documents/'.strtolower($short).'/download');
|
||||
}
|
||||
|
||||
@@ -674,7 +674,7 @@ function show(id)
|
||||
if(!is_dir($path))
|
||||
{
|
||||
if(!is_dir('../../../documents/'.strtolower($short)))
|
||||
exec('mkdir -m 775 "../../../documents/'.strtolower($short).'"');
|
||||
exec('mkdir -m 755 "../../../documents/'.strtolower($short).'"');
|
||||
exec('mkdir -m 775 "../../../documents/'.strtolower($short).'/lehrziele"');
|
||||
exec('chgrp teacher ../../../documents/'.strtolower($short).'/lehrziele');
|
||||
}
|
||||
|
||||
@@ -6,12 +6,17 @@ mb_internal_encoding("UTF-8");
|
||||
mb_regex_encoding("UTF-8");
|
||||
setlocale (LC_ALL, 'de_DE.UTF8','de_DE@euro', 'de_DE', 'de','DE', 'ge','German');
|
||||
|
||||
|
||||
// Connection Strings zur Datenbank
|
||||
define("CONN_STRING","host=localhost dbname=bla user=bla password=bla");
|
||||
define("CONN_STRING_MOODLE","host=localhost dbname=bla user=bla password=bla");
|
||||
define('CONN_CLIENT_ENCODING','LATIN9' );
|
||||
define("DB_SYSTEM","pgsql");
|
||||
define("DB_HOST","localhost");
|
||||
define("DB_PORT","5433");
|
||||
define("DB_NAME","fhcomplete");
|
||||
define("DB_USER","bla");
|
||||
define("DB_PASSWORD","bla");
|
||||
define("DB_CONNECT_PERSISTENT",TRUE);
|
||||
define('CONN_CLIENT_ENCODING','UTF-8' );
|
||||
|
||||
define("CONN_STRING_MOODLE","host=localhost dbname=bla user=bla password=bla");
|
||||
|
||||
define('TABLE_ID','_id');
|
||||
define('TABLE_BEGIN','tbl_');
|
||||
|
||||
+125
-1173
File diff suppressed because it is too large
Load Diff
@@ -26,97 +26,7 @@ abstract class db extends basis
|
||||
abstract function db_last_error();
|
||||
abstract function db_free_result($result=null);
|
||||
abstract function db_version();
|
||||
|
||||
|
||||
/**
|
||||
* Erzeugt aus den Funktionsparameter eine SLQ Abfrage
|
||||
* --- Wird in der Art Sonderzeichen gefunden wird dieses als FunktionsParmeter verarbeitet
|
||||
* @param art die SQL Abfrage die erzeugt werden soll Default ist 'select'
|
||||
* @param distinct - nur wenn art ist 'select' ist
|
||||
* @param fields welche Datenbankfelder sind betroffen
|
||||
* @param table Datenbanktabelle die betroffen ist/sind
|
||||
* @param where Bedingung zum lesen in der Datenbank
|
||||
* @param order Sortierung der Anfrage - nur wenn art ist 'select' ist
|
||||
* @param limit Anzahl der Datenmenge die geliefert werden soll - nur wenn art ist 'select' ist
|
||||
* @param sql der Kpl. SQL String zur Datenbearbeitung der DB
|
||||
|
||||
* @return false und errormsg wenn ein Fehler aufgetreten ist, Datenbankobjekt wenn alles OK
|
||||
*/
|
||||
|
||||
public function creatSQL($pArt='select',$pDistinct=false,$pFields='',$pTable='',$pWhere='',$pOrder='',$pLimit='',$pSql='')
|
||||
{
|
||||
// Init
|
||||
$this->errormsg='';
|
||||
## echo "<br>$pArt,$pDistinct,$pFields,$pTable,$pWhere,$pOrder,$pLimit,$pSql";
|
||||
$result=false;
|
||||
// Check Parameter
|
||||
$sql=(!is_null($pSql)?trim($pSql):'');
|
||||
$art=(!is_null($pArt)?trim($pArt):'');
|
||||
$distinct=($pDistinct?true:false);
|
||||
$fields=(!is_null($pFields)?trim($pFields):'');
|
||||
$table=(!is_null($pTable)?trim($pTable):'');
|
||||
$where=(!is_null($pWhere)?trim($pWhere):'');
|
||||
$order=(!is_null($pOrder)?trim($pOrder):'');
|
||||
$limit=(is_numeric($pLimit)?$pLimit:'');
|
||||
|
||||
if (empty($sql) && empty($art))
|
||||
{
|
||||
$this->errormsg='die SQL Art fehlt!';
|
||||
return $result;
|
||||
}
|
||||
else if (empty($sql) && empty($table))
|
||||
{
|
||||
$this->errormsg='die SQL Tabelle fehlt!';
|
||||
return $result;
|
||||
}
|
||||
|
||||
// DB Abfrage zusammenbauen
|
||||
$sql.=$art. ' ';
|
||||
if ($art=='select')
|
||||
$sql.=($distinct?' distinct ':'');
|
||||
$sql.=($fields?$fields:' * ');
|
||||
$sql.=($table?' from '.trim($table).' ':'');
|
||||
if (strstr('where',strtolower($where)))
|
||||
$sql.=($where?' '.trim($where).' ':'');
|
||||
else
|
||||
$sql.=($where?' where '.trim($where).' ':'');
|
||||
|
||||
if ($art=='select')
|
||||
{
|
||||
if (strstr('order',strtolower($where)))
|
||||
$sql.=($order?trim($order).' ':'');
|
||||
else
|
||||
$sql.=($order?' order by '.trim($order).' ':'');
|
||||
}
|
||||
if ($art=='select')
|
||||
{
|
||||
if (strstr('limit',strtolower($where)))
|
||||
$sql.=($limit?trim($limit).' ':'');
|
||||
else
|
||||
$sql.=($limit?' limit '.trim($limit).' ':'');
|
||||
}
|
||||
|
||||
#echo "<br>$sql<br>";
|
||||
if (!$results=$this->db_query($sql))
|
||||
{
|
||||
$this->errormsg=$this->db_last_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($art!='select')
|
||||
return true;
|
||||
|
||||
if (!$num=$this->db_num_rows($results))
|
||||
{
|
||||
$this->errormsg='keine Daten gefunden';
|
||||
return false;
|
||||
}
|
||||
// Lesen aller DB Daten
|
||||
$rows=array();
|
||||
while($row = $this->db_fetch_object($results))
|
||||
$rows[]=$row;
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
||||
require_once(dirname(__FILE__).'/'.DB_SYSTEM.'.class.php');
|
||||
|
||||
@@ -307,6 +307,7 @@ class benutzerberechtigung extends basis_db
|
||||
$this->berechtigungen[] = $obj;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,47 +405,33 @@ class benutzerberechtigung extends basis_db
|
||||
|
||||
while($row=$this->db_fetch_object($result))
|
||||
{
|
||||
//wenn die Berechtigung an einer Organisationseinheit haengt, dann werden
|
||||
//auch die Berechtigungen fuer die darunterliegenden Organisationseinheiten angelegt
|
||||
if($row->oe_kurzbz!='')
|
||||
{
|
||||
$organisationseinheit = new organisationseinheit();
|
||||
$oes = $organisationseinheit->getChilds($row->oe_kurzbz);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oes[]=$row->oe_kurzbz;
|
||||
}
|
||||
$b=new benutzerberechtigung();
|
||||
|
||||
$b->benutzerberechtigung_id = $row->benutzerberechtigung_id;
|
||||
$b->uid=$row->uid;
|
||||
$b->funktion_kurzbz=$row->funktion_kurzbz;
|
||||
$b->rolle_kurzbz = $row->rolle_kurzbz;
|
||||
$b->berechtigung_kurzbz = $row->berechtigung_kurzbz;
|
||||
$b->art=intersect($row->art, $row->art1);
|
||||
$b->oe_kurzbz = $row->oe_kurzbz;
|
||||
$b->studiensemester_kurzbz=$row->studiensemester_kurzbz;
|
||||
$b->start=$row->start;
|
||||
if ($row->start!=null)
|
||||
$b->starttimestamp=mktime(0,0,0,mb_substr($row->start,5,2),mb_substr($row->start,8),mb_substr($row->start,0,4));
|
||||
else
|
||||
$b->starttimestamp=null;
|
||||
$b->ende=$row->ende;
|
||||
if ($row->ende!=null)
|
||||
$b->endetimestamp=mktime(23,59,59,mb_substr($row->ende,5,2),mb_substr($row->ende,8),mb_substr($row->ende,0,4));
|
||||
$b->negativ = ($row->negativ=='t'?true:false);
|
||||
$b->updateamum = $row->updateamum;
|
||||
$b->updatevon = $row->updatevon;
|
||||
$b->insertamum = $row->insertamum;
|
||||
$b->insertvon = $row->insertvon;
|
||||
|
||||
foreach ($oes as $oe_kurzbz)
|
||||
{
|
||||
$b=new benutzerberechtigung();
|
||||
|
||||
$b->benutzerberechtigung_id = $row->benutzerberechtigung_id;
|
||||
$b->uid=$row->uid;
|
||||
$b->funktion_kurzbz=$row->funktion_kurzbz;
|
||||
$b->rolle_kurzbz = $row->rolle_kurzbz;
|
||||
$b->berechtigung_kurzbz = $row->berechtigung_kurzbz;
|
||||
$b->art=intersect($row->art, $row->art1);
|
||||
$b->oe_kurzbz = $oe_kurzbz;
|
||||
$b->studiensemester_kurzbz=$row->studiensemester_kurzbz;
|
||||
$b->start=$row->start;
|
||||
if ($row->start!=null)
|
||||
$b->starttimestamp=mktime(0,0,0,mb_substr($row->start,5,2),mb_substr($row->start,8),mb_substr($row->start,0,4));
|
||||
else
|
||||
$b->starttimestamp=null;
|
||||
$b->ende=$row->ende;
|
||||
if ($row->ende!=null)
|
||||
$b->endetimestamp=mktime(23,59,59,mb_substr($row->ende,5,2),mb_substr($row->ende,8),mb_substr($row->ende,0,4));
|
||||
$b->negativ = ($row->negativ=='t'?true:false);
|
||||
$b->updateamum = $row->updateamum;
|
||||
$b->updatevon = $row->updatevon;
|
||||
$b->insertamum = $row->insertamum;
|
||||
$b->insertvon = $row->insertvon;
|
||||
|
||||
$this->berechtigungen[]=$b;
|
||||
}
|
||||
$this->berechtigungen[]=$b;
|
||||
}
|
||||
|
||||
unset($result);
|
||||
// Attribute des Mitarbeiters holen
|
||||
$sql_query="SELECT fixangestellt, lektor FROM public.tbl_mitarbeiter WHERE mitarbeiter_uid='".addslashes($uid)."'";
|
||||
@@ -498,11 +485,14 @@ class benutzerberechtigung extends basis_db
|
||||
$fb = new fachbereich($fachbereich_kurzbz);
|
||||
$oe_kurzbz = $fb->oe_kurzbz;
|
||||
}
|
||||
$oe = new organisationseinheit();
|
||||
|
||||
foreach ($this->berechtigungen as $b)
|
||||
{
|
||||
//Pruefen ob eine negativ-Berechtigung vorhanden ist
|
||||
if($b->berechtigung_kurzbz==$berechtigung_kurzbz && $b->negativ && $oe_kurzbz==$b->oe_kurzbz)
|
||||
if($b->berechtigung_kurzbz==$berechtigung_kurzbz
|
||||
&& $b->negativ
|
||||
&& (is_null($oe_kurzbz) || $oe_kurzbz==$b->oe_kurzbz || $oe->isChild($b->oe_kurzbz, $oe_kurzbz)))
|
||||
{
|
||||
if (($timestamp>$b->starttimestamp || $b->starttimestamp==null)
|
||||
&& ($timestamp<$b->endetimestamp || $b->endetimestamp==null))
|
||||
@@ -513,7 +503,7 @@ class benutzerberechtigung extends basis_db
|
||||
|
||||
if($b->berechtigung_kurzbz==$berechtigung_kurzbz
|
||||
&& (is_null($art) || mb_strstr($b->art, $art))
|
||||
&& (is_null($oe_kurzbz) || $oe_kurzbz==$b->oe_kurzbz))
|
||||
&& (is_null($oe_kurzbz) || $oe_kurzbz==$b->oe_kurzbz || $oe->isChild($b->oe_kurzbz, $oe_kurzbz)))
|
||||
{
|
||||
if (($timestamp>$b->starttimestamp || $b->starttimestamp==null)
|
||||
&& ($timestamp<$b->endetimestamp || $b->endetimestamp==null))
|
||||
@@ -558,7 +548,8 @@ class benutzerberechtigung extends basis_db
|
||||
$in='';
|
||||
$not='';
|
||||
$all=false;
|
||||
|
||||
$oe = new organisationseinheit();
|
||||
|
||||
foreach ($this->berechtigungen as $b)
|
||||
{
|
||||
if (($berechtigung_kurzbz==$b->berechtigung_kurzbz || $berechtigung_kurzbz==null)
|
||||
@@ -568,14 +559,22 @@ class benutzerberechtigung extends basis_db
|
||||
{
|
||||
//Negativ-Recht
|
||||
if(!is_null($b->oe_kurzbz))
|
||||
$not .="'".addslashes($b->oe_kurzbz)."',";
|
||||
{
|
||||
$childoes = $oe->getChilds($b->oe_kurzbz);
|
||||
foreach($childoes as $row)
|
||||
$not .="'".addslashes($row)."',";
|
||||
}
|
||||
else
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_null($b->oe_kurzbz))
|
||||
$in .= "'".addslashes($b->oe_kurzbz)."',";
|
||||
{
|
||||
$childoes = $oe->getChilds($b->oe_kurzbz);
|
||||
foreach($childoes as $row)
|
||||
$in .= "'".addslashes($row)."',";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Wenn NULL dann berechtigung auf alles
|
||||
@@ -626,6 +625,7 @@ class benutzerberechtigung extends basis_db
|
||||
$in='';
|
||||
$not='';
|
||||
$all=false;
|
||||
$oe = new organisationseinheit();
|
||||
|
||||
foreach ($this->berechtigungen as $b)
|
||||
{
|
||||
@@ -636,14 +636,22 @@ class benutzerberechtigung extends basis_db
|
||||
{
|
||||
//Negativ-Recht
|
||||
if(!is_null($b->oe_kurzbz))
|
||||
$not .="'".addslashes($b->oe_kurzbz)."',";
|
||||
{
|
||||
$childoes = $oe->getChilds($b->oe_kurzbz);
|
||||
foreach($childoes as $row)
|
||||
$not .="'".addslashes($row)."',";
|
||||
}
|
||||
else
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_null($b->oe_kurzbz))
|
||||
$in .= "'".addslashes($b->oe_kurzbz)."',";
|
||||
{
|
||||
$childoes = $oe->getChilds($b->oe_kurzbz);
|
||||
foreach($childoes as $row)
|
||||
$in .= "'".addslashes($row)."',";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Wenn NULL dann berechtigung auf alles
|
||||
@@ -689,10 +697,9 @@ class benutzerberechtigung extends basis_db
|
||||
{
|
||||
$oe_kurzbz=array();
|
||||
$timestamp=time();
|
||||
$in='';
|
||||
$not='';
|
||||
$all=false;
|
||||
|
||||
$oe = new organisationseinheit();
|
||||
foreach ($this->berechtigungen as $b)
|
||||
{
|
||||
if (($berechtigung_kurzbz==$b->berechtigung_kurzbz || $berechtigung_kurzbz==null)
|
||||
@@ -702,18 +709,37 @@ class benutzerberechtigung extends basis_db
|
||||
{
|
||||
//Negativ-Recht
|
||||
if(!is_null($b->oe_kurzbz))
|
||||
$not .="'".addslashes($b->oe_kurzbz)."',";
|
||||
{
|
||||
$childoes = $oe->getChilds($b->oe_kurzbz);
|
||||
foreach($childoes as $row)
|
||||
$not .="'".addslashes($row)."',";
|
||||
}
|
||||
else
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$oe_kurzbz[] = $b->oe_kurzbz;
|
||||
if(!is_null($b->oe_kurzbz))
|
||||
{
|
||||
$childoes = $oe->getChilds($b->oe_kurzbz);
|
||||
foreach($childoes as $row)
|
||||
$oe_kurzbz[] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$all=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$studiengang_kz=array_unique($oe_kurzbz);
|
||||
if($all)
|
||||
{
|
||||
$oe->loadParentsArray();
|
||||
$oe_kurzbz = array_keys(organisationseinheit::$oe_parents_array);
|
||||
}
|
||||
$oe_kurzbz=array_unique($oe_kurzbz);
|
||||
sort($oe_kurzbz);
|
||||
return $oe_kurzbz;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ require_once(dirname(__FILE__).'/basis_db.class.php');
|
||||
|
||||
class organisationseinheit extends basis_db
|
||||
{
|
||||
public static $oe_parents_array=array();
|
||||
public $new; // @var boolean
|
||||
public $errormsg; // @var string
|
||||
public $result;
|
||||
@@ -42,6 +43,7 @@ class organisationseinheit extends basis_db
|
||||
public $oe_kurzbz_orig;
|
||||
public $beschreibung;
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $oe_kurzbz Kurzbz der Organisationseinheit
|
||||
@@ -362,5 +364,56 @@ class organisationseinheit extends basis_db
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt die Organisationseinheiten in ein Array
|
||||
*
|
||||
*/
|
||||
public function loadParentsArray()
|
||||
{
|
||||
$qry = 'SELECT * FROM public.tbl_organisationseinheit';
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
while($row = $this->db_fetch_object())
|
||||
{
|
||||
organisationseinheit::$oe_parents_array[$row->oe_kurzbz]=$row->oe_parent_kurzbz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function isChild($oe_kurzbz, $child)
|
||||
{
|
||||
if(count(organisationseinheit::$oe_parents_array)<=0)
|
||||
{
|
||||
$this->loadParentsArray();
|
||||
}
|
||||
|
||||
if(!isset(organisationseinheit::$oe_parents_array[$child]))
|
||||
{
|
||||
$this->errormsg = 'Organisationseinheit existiert nicht';
|
||||
return false;
|
||||
}
|
||||
|
||||
$childs = array_keys(organisationseinheit::$oe_parents_array, $oe_kurzbz);
|
||||
|
||||
foreach ($childs as $row)
|
||||
{
|
||||
if($row==$child)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->isChild($row, $child))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user