mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-18 04:29:28 +00:00
Fehler update: enabled updating of fehler columns, added insertaum, insertvon, updateamum, insertvon
This commit is contained in:
@@ -21,7 +21,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
class FehlerUpdateLib
|
||||
{
|
||||
// Who adds phrases into the database
|
||||
//const INSERT_BY = 'FehlerUpdate';
|
||||
const UPSERT_BY = 'FehlerUpdate';
|
||||
|
||||
const CONFIG_DIRECTORY = 'config';
|
||||
const CONFIG_FEHLER_NAME = 'fehler';
|
||||
@@ -43,8 +43,8 @@ class FehlerUpdateLib
|
||||
const FEHLER_ATTRIBUTES = [
|
||||
self::FEHLERCODE => ['required' => true],
|
||||
self::FEHLER_KURZBZ => ['required' => false],
|
||||
self::FEHLERTEXT => ['required' => true],
|
||||
self::FEHLERTYP_KURZBZ => ['required' => false],
|
||||
self::FEHLERTEXT => ['required' => true, 'updateable' => false],
|
||||
self::FEHLERTYP_KURZBZ => ['required' => false, 'updateable' => true],
|
||||
self::APP => ['required' => true, 'types' => [self::TYPE_STRING, self::TYPE_ARRAY]],
|
||||
self::FEHLERCODE_EXTERN => ['required' => false]
|
||||
];
|
||||
@@ -170,7 +170,7 @@ class FehlerUpdateLib
|
||||
elseif (hasData($createFehlerResult))
|
||||
{
|
||||
// add fehler to db
|
||||
$addFehlerResult = $this->_addFehler(getData($createFehlerResult));
|
||||
$addFehlerResult = $this->_updateFehler(getData($createFehlerResult));
|
||||
|
||||
if (isError($addFehlerResult))
|
||||
{
|
||||
@@ -188,10 +188,9 @@ class FehlerUpdateLib
|
||||
/**
|
||||
* Add a new fehler to the database
|
||||
*/
|
||||
private function _addFehler($fehler)
|
||||
private function _updateFehler($fehler)
|
||||
{
|
||||
// Checks if the fehler already exists in the database
|
||||
$this->_ci->FehlerModel->addSelect(self::FEHLERCODE.', '.self::FEHLER_KURZBZ);
|
||||
$this->_ci->FehlerModel->db->where(self::FEHLERCODE.' = ', $fehler[self::FEHLERCODE]);
|
||||
if ($fehler[self::FEHLER_KURZBZ] != null) $this->_ci->FehlerModel->db->or_where(self::FEHLER_KURZBZ.' = ', $fehler[self::FEHLER_KURZBZ]);
|
||||
$fehlerResult = $this->_ci->FehlerModel->load();
|
||||
@@ -216,6 +215,31 @@ class FehlerUpdateLib
|
||||
." already exists in database"
|
||||
);
|
||||
|
||||
$updateArr = [];
|
||||
|
||||
// update fehler, if needed
|
||||
foreach (self::FEHLER_ATTRIBUTES as $attributeName => $attributeInfo)
|
||||
{
|
||||
// set attributes to be updated
|
||||
if (isset($attributeInfo['updateable']) && $attributeInfo['updateable'] && $foundFehler->{$attributeName} != $fehler[$attributeName])
|
||||
{
|
||||
$updateArr[$attributeName] = $fehler[$attributeName];
|
||||
}
|
||||
}
|
||||
|
||||
if (!isEmptyArray($updateArr))
|
||||
{
|
||||
$updateRes = $this->_ci->FehlerModel->update(
|
||||
[self::FEHLERCODE => $foundFehler->{self::FEHLERCODE}],
|
||||
array_merge($updateArr, ['updateamum' => 'NOW()', 'updatevon' => self::UPSERT_BY])
|
||||
);
|
||||
if (isError($updateRes)) return $updateRes;
|
||||
|
||||
$this->_ci->eprintflib->printMessage(
|
||||
"Fehler ".$fehler[self::FEHLERCODE].(isset($fehler[self::FEHLER_KURZBZ]) ? " (".$fehler[self::FEHLER_KURZBZ].")" : "")." updated"
|
||||
);
|
||||
}
|
||||
|
||||
return success($fehler[self::FEHLERCODE]);
|
||||
}
|
||||
|
||||
@@ -242,12 +266,7 @@ class FehlerUpdateLib
|
||||
|
||||
// Then add the fehler to the database
|
||||
$fehlerInsertResult = $this->_ci->FehlerModel->insert(
|
||||
$fehler
|
||||
// TODO: add insertamum?
|
||||
//~ array(
|
||||
//~ 'insertamum' => 'NOW()',
|
||||
//~ 'insertvon' => self::INSERT_BY
|
||||
//~ )
|
||||
array_merge($fehler, ['insertamum' => 'NOW()', 'insertvon' => self::UPSERT_BY])
|
||||
);
|
||||
|
||||
// If an error occurred then return the error itself
|
||||
@@ -274,9 +293,9 @@ class FehlerUpdateLib
|
||||
private function _createFehlerFromEntry($configEntry)
|
||||
{
|
||||
$fehler = [];
|
||||
foreach (self::FEHLER_ATTRIBUTES as $attributeName => $attributeConditions)
|
||||
foreach (self::FEHLER_ATTRIBUTES as $attributeName => $attributeInfo)
|
||||
{
|
||||
$required = isset($attributeConditions['required']) && $attributeConditions['required'];
|
||||
$required = isset($attributeInfo['required']) && $attributeInfo['required'];
|
||||
if ($required && !isset($configEntry[$attributeName]))
|
||||
{
|
||||
return error('attribute'.$attributeName.' is missing');
|
||||
@@ -284,9 +303,9 @@ class FehlerUpdateLib
|
||||
|
||||
$attributeValue = $configEntry[$attributeName];
|
||||
$validType = false;
|
||||
if (isset($attributeConditions['types']) && is_array($attributeConditions['types']))
|
||||
if (isset($attributeInfo['types']) && is_array($attributeInfo['types']))
|
||||
{
|
||||
foreach ($attributeConditions['types'] as $type)
|
||||
foreach ($attributeInfo['types'] as $type)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
|
||||
@@ -87,6 +87,7 @@ require_once('dbupdate_3.4/47972_pruefungsverwaltung_ects_angabe.php');
|
||||
require_once('dbupdate_3.4/67490_studstatus_suche_abort_controller_haengt.php');
|
||||
require_once('dbupdate_3.4/69065_Projektarbeiten_Firmen_verwalten.php');
|
||||
require_once('dbupdate_3.4/68744_StV_settings.php');
|
||||
require_once('dbupdate_3.4/68834_fehlermonitoring_issues_weitere_features.php');
|
||||
|
||||
// *** Pruefung und hinzufuegen der neuen Attribute und Tabellen
|
||||
echo '<H2>Pruefe Tabellen und Attribute!</H2>';
|
||||
@@ -406,7 +407,7 @@ $tabellen=array(
|
||||
"system.tbl_benutzerrolle" => array("benutzerberechtigung_id","rolle_kurzbz","berechtigung_kurzbz","uid","funktion_kurzbz","oe_kurzbz","art","studiensemester_kurzbz","start","ende","negativ","updateamum", "updatevon","insertamum","insertvon","kostenstelle_id","anmerkung"),
|
||||
"system.tbl_berechtigung" => array("berechtigung_kurzbz","beschreibung"),
|
||||
"system.tbl_extensions" => array("extension_id","name","version","description","license","url","core_version","dependencies","enabled"),
|
||||
"system.tbl_fehler" => array("fehlercode","fehler_kurzbz","fehlercode_extern","fehlertext","fehlertyp_kurzbz","app"),
|
||||
"system.tbl_fehler" => array("fehlercode","fehler_kurzbz","fehlercode_extern","fehlertext","fehlertyp_kurzbz","app","insertamum","insertvon","updateamum","updatevon"),
|
||||
"system.tbl_fehlertyp" => array("fehlertyp_kurzbz","bezeichnung_mehrsprachig"),
|
||||
"system.tbl_fehler_konfiguration" => array("konfigurationstyp_kurzbz","fehlercode","konfiguration","insertamum","insertvon","updateamum","updatevon"),
|
||||
"system.tbl_fehler_konfigurationsdatentyp" => array("konfigurationsdatentyp"),
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
if (! defined('DB_NAME')) exit('No direct script access allowed');
|
||||
|
||||
// ADD COLUMNS insertamum, insertvon, updateamum, updatevon to system.tbl_fehler
|
||||
if(!$result = @$db->db_query("SELECT insertamum FROM system.tbl_fehler LIMIT 1"))
|
||||
{
|
||||
$qry = "ALTER TABLE system.tbl_fehler ADD COLUMN insertamum timestamp DEFAULT now();
|
||||
ALTER TABLE system.tbl_fehler ADD COLUMN insertvon varchar(32);
|
||||
ALTER TABLE system.tbl_fehler ADD COLUMN updateamum timestamp DEFAULT now();
|
||||
ALTER TABLE system.tbl_fehler ADD COLUMN updatevon varchar(32);";
|
||||
|
||||
if(!$db->db_query($qry))
|
||||
echo '<strong>system.tbl_fehler '.$db->db_last_error().'</strong><br>';
|
||||
else
|
||||
echo '<br>Spalten insertamum, insertvon, updateamum, updatevon in system.tbl_fehler hinzugefügt';
|
||||
}
|
||||
Reference in New Issue
Block a user