Merge branch 'master' into feature-29133/einzelne_studiengaenge_aus_issues_check_ausnehmen

This commit is contained in:
KarpAlex
2023-05-21 17:38:49 +02:00
31 changed files with 1057 additions and 642 deletions
-165
View File
@@ -7,9 +7,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class PersonLogLib
{
const PARKED_LOGNAME = 'Parked';
const ONHOLD_LOGNAME = 'Onhold';
/**
* Constructor
*/
@@ -78,168 +75,6 @@ class PersonLogLib
else
show_error(getError($result));
}
/**
* Parks a person, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent)
* Done by adding a logentry in the future
* @param $person_id
* @param $date
* @param $taetigkeit_kurzbz
* @param string $app
* @param null $oe_kurzbz
* @param null $user
* @return insert object
*/
public function park($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null)
{
$onhold = $this->getOnHoldDate($person_id);
if (hasData($onhold))
return error("Person already on hold");
$logjson = array(
'name' => self::PARKED_LOGNAME
);
return $this->_savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user);
}
/**
* Unparks a person, i.e. removes all log entries in the future with logname for parking
* @param $person_id
* @return array with deleted logids
*/
public function unPark($person_id)
{
$deleted = array();
$result = $this->ci->PersonLogModel->getLogsInFuture($person_id);
if (hasData($result))
{
foreach ($result->retval as $log)
{
$logdata = json_decode($log->logdata);
if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME)
{
$delresult = $this->ci->PersonLogModel->deleteLog($log->log_id);
if (isSuccess($delresult))
{
$deleted[] = $log->log_id;
}
}
}
}
return success($deleted);
}
/**
* Gets date until which a person is parked
* @param $person_id
* @return the date if person is parked, null otherwise
*/
public function getParkedDate($person_id)
{
$result = $this->ci->PersonLogModel->getLogsInFuture($person_id);
$parkeddate = null;
if (hasData($result))
{
foreach ($result->retval as $log)
{
$logdata = json_decode($log->logdata);
if (isset($logdata->name) && $logdata->name === self::PARKED_LOGNAME)
{
$parkeddate = $log->zeitpunkt;
break;
}
}
}
return $parkeddate;
}
/**
* Sets person on hold, i.e. marks a person so no actions are expected for the person (e.g. as a prestudent).
* Done by adding a logentry with a special name. can be undone only manually by clicking button.
* @param $person_id
* @param $date
* @param $taetigkeit_kurzbz
* @param string $app
* @param null $oe_kurzbz
* @param null $user
* @return array
*/
public function setOnHold($person_id, $date, $taetigkeit_kurzbz, $app = 'core', $oe_kurzbz = null, $user = null)
{
$parked = $this->getParkedDate($person_id);
if (hasData($parked))
return error("Person already parked");
$logjson = array(
'name' => self::ONHOLD_LOGNAME
);
return $this->_savePsLog($person_id, $date, $taetigkeit_kurzbz, $logjson, $app, $oe_kurzbz, $user);
}
/**
* Removes on hold status, i.e. removes all log entries with logname for on hold
* @param $person_id
* @return array
*/
public function removeOnHold($person_id)
{
$deleted = array();
$result = $this->ci->PersonLogModel->filterLog($person_id);
if (hasData($result))
{
foreach ($result->retval as $log)
{
$logdata = json_decode($log->logdata);
if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME)
{
$delresult = $this->ci->PersonLogModel->deleteLog($log->log_id);
if (isSuccess($delresult))
{
$deleted[] = $log->log_id;
}
}
}
}
return success($deleted);
}
/**
* Gets date until which a person is on hold
* @param $person_id
* @return the date if person is on hold, null otherwise
*/
public function getOnHoldDate($person_id)
{
$result = $this->ci->PersonLogModel->filterLog($person_id);
$onholddate = null;
if (hasData($result))
{
foreach ($result->retval as $log)
{
$logdata = json_decode($log->logdata);
if (isset($logdata->name) && $logdata->name === self::ONHOLD_LOGNAME)
{
$onholddate = $log->zeitpunkt;
break;
}
}
}
return $onholddate;
}
/**
* Saves a processstate log with specified parameters, including a specified log date.
* @param $person_id
+75
View File
@@ -0,0 +1,75 @@
<?php
/**
* Copyright (C) 2022 fhcomplete.net
*
* This program 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 2 of the
* License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
*/
require_once(dirname(__FILE__).'/../../vendor/nategood/httpful/bootstrap.php');
/**
* Simple client to call the signature server
*/
class SignatureLib
{
// -------------------------------------------------------------------------------------------------
// Public static methods
/**
* Returns the list of signature inside the given file
*/
public static function list($inputFileName)
{
try
{
// Get the content of the given file
$inputFileContent = file_get_contents($inputFileName);
if ($inputFileContent === false) // if failed
{
error_log('An error occurred while getting the content from: '.$inputFileName);
}
else
{
// Posts the given file content + file name and expects a response in JSON format
$resultPost = \Httpful\Request::post(SIGNATUR_URL.'/'.SIGNATUR_LIST_API)
->sendsJson()
->authenticateWith(SIGNATUR_USER, SIGNATUR_PASSWORD)
->body('{"filename": "'.basename($inputFileName).'", "content": "'.base64_encode($inputFileContent).'"}')
->expectsJson()
->send();
}
}
catch(\Httpful\Exception\ConnectionErrorException $cee) // Httpful exception
{
error_log($cee->getMessage());
}
catch (Exception $e) // any other exception
{
error_log($e->getMessage());
}
// If the response is fine
if (isset($resultPost->body) && is_object($resultPost->body)
&& isset($resultPost->body->retval) && is_array($resultPost->body->retval))
{
return $resultPost->body->retval;
}
// Otherwise return a null as error
return null;
}
}