Skip to content
Snippets Groups Projects
Commit fe039182 authored by André Noack's avatar André Noack Committed by Jan-Hendrik Willms
Browse files

add logging for requests, change wrong logging message

parent 02adb942
No related branches found
No related tags found
No related merge requests found
......@@ -539,6 +539,7 @@ class Course_RoomRequestsController extends AuthenticatedController
foreach ($this->selected_properties as $name => $state) {
$result = $this->request->setProperty($name, $state);
}
$this->request->store();
//Delete the session data:
$session_data = [];
PageLayout::postSuccess(_('Die Anfrage wurde gespeichert!'));
......@@ -958,6 +959,7 @@ class Course_RoomRequestsController extends AuthenticatedController
} else {
$result = $this->request->setProperty('seats', $this->seats);
}
$this->request->store();
//Delete the session data:
$session_data = [];
PageLayout::postSuccess(_('Die Anfrage wurde gespeichert!'));
......
<?php
class Biest149 extends Migration
{
public function description()
{
return "change log message for RES_REQUEST_DENY";
}
public function up()
{
DBManager::get()->exec("UPDATE `log_actions` SET `info_template` = '%user lehnt Raumanfrage für %sem(%affected), Raum: %res(%coaffected) ab. %info' WHERE `log_actions`.`action_id` = '9179d3cf4e0353f9874bcde072d12b30'");
}
}
......@@ -133,6 +133,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
}
$config['registered_callbacks']['after_create'][] = 'cbLogNewRequest';
$config['registered_callbacks']['after_store'][] = 'cbAfterStore';
$config['registered_callbacks']['after_delete'][] = 'cbAfterDelete';
parent::configure($config);
......@@ -556,7 +557,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
public function cbLogNewRequest()
{
$this->sendNewRequestMail();
StudipLog::log('RES_REQUEST_NEW', $this->id, $this->resource_id);
StudipLog::log('RES_REQUEST_NEW', $this->course_id, $this->resource_id, $this->getLoggingInfoText());
}
/**
......@@ -565,9 +566,21 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
*/
public function cbAfterStore()
{
if($this->closed == '3') {
if ($this->isFieldDirty('closed')) {
if ($this->closed == 3) {
$this->sendRequestDeniedMail();
StudipLog::log('RES_REQUEST_DENY', $this->course_id, $this->resource_id, $this->getLoggingInfoText());
} elseif ($this->closed == 1 || $this->closed == 2) {
StudipLog::log('RES_REQUEST_RESOLVE', $this->course_id, $this->resource_id, $this->getLoggingInfoText());
}
} else {
StudipLog::log('RES_REQUEST_UPDATE', $this->course_id, $this->resource_id, $this->getLoggingInfoText());
}
}
public function cbAfterDelete()
{
StudipLog::log('RES_REQUEST_DEL', $this->course_id, $this->resource_id, $this->getLoggingInfoText());
}
/**
......@@ -2360,4 +2373,34 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
$diff = round(($first['begin'] - time()) / 86400);
return $diff;
}
public function getLoggingInfoText()
{
$props = '';
foreach ($this->getPropertyData() as $name => $state) {
$props .= $name . '=' . $state . ' ';
}
$info['Anfrage'] = $this->getType();
$info['Status'] = $this->getStatus();
if ($this->category) {
$info['Raumtyp'] = $this->category->name;
}
if ($this->termin_id) {
$info['Termin'] = $this->termin_id;
}
if ($this->metadate_id) {
$info['Metadate'] = $this->metadate_id;
}
if ($props) {
$info['Eigenschaften'] = $props;
}
if ($this->comment) {
$info['Kommentar'] = $this->comment;
}
$txt = '';
foreach ($info as $n => $m) {
$txt .= $n . ': ' . $m . ', ';
}
return trim($txt, ' ,');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment