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 ...@@ -539,6 +539,7 @@ class Course_RoomRequestsController extends AuthenticatedController
foreach ($this->selected_properties as $name => $state) { foreach ($this->selected_properties as $name => $state) {
$result = $this->request->setProperty($name, $state); $result = $this->request->setProperty($name, $state);
} }
$this->request->store();
//Delete the session data: //Delete the session data:
$session_data = []; $session_data = [];
PageLayout::postSuccess(_('Die Anfrage wurde gespeichert!')); PageLayout::postSuccess(_('Die Anfrage wurde gespeichert!'));
...@@ -958,6 +959,7 @@ class Course_RoomRequestsController extends AuthenticatedController ...@@ -958,6 +959,7 @@ class Course_RoomRequestsController extends AuthenticatedController
} else { } else {
$result = $this->request->setProperty('seats', $this->seats); $result = $this->request->setProperty('seats', $this->seats);
} }
$this->request->store();
//Delete the session data: //Delete the session data:
$session_data = []; $session_data = [];
PageLayout::postSuccess(_('Die Anfrage wurde gespeichert!')); 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 ...@@ -133,6 +133,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
} }
$config['registered_callbacks']['after_create'][] = 'cbLogNewRequest'; $config['registered_callbacks']['after_create'][] = 'cbLogNewRequest';
$config['registered_callbacks']['after_store'][] = 'cbAfterStore'; $config['registered_callbacks']['after_store'][] = 'cbAfterStore';
$config['registered_callbacks']['after_delete'][] = 'cbAfterDelete';
parent::configure($config); parent::configure($config);
...@@ -556,7 +557,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -556,7 +557,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
public function cbLogNewRequest() public function cbLogNewRequest()
{ {
$this->sendNewRequestMail(); $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,11 +566,23 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -565,11 +566,23 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
*/ */
public function cbAfterStore() public function cbAfterStore()
{ {
if($this->closed == '3') { if ($this->isFieldDirty('closed')) {
$this->sendRequestDeniedMail(); 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());
}
/** /**
* This validation method is called before storing an object. * This validation method is called before storing an object.
*/ */
...@@ -2360,4 +2373,34 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen ...@@ -2360,4 +2373,34 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen
$diff = round(($first['begin'] - time()) / 86400); $diff = round(($first['begin'] - time()) / 86400);
return $diff; 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