diff --git a/app/controllers/course/room_requests.php b/app/controllers/course/room_requests.php index edf76b7037f54f30da090e5dc8d51ba5608c8e1a..100dad5cdb3a6d1845d1bc4114e39f501fa3dea9 100644 --- a/app/controllers/course/room_requests.php +++ b/app/controllers/course/room_requests.php @@ -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!')); diff --git a/db/migrations/1.328_biest_149.php b/db/migrations/1.328_biest_149.php new file mode 100644 index 0000000000000000000000000000000000000000..48b0cbf3a147e104b1850825edfe8c0d881f4d53 --- /dev/null +++ b/db/migrations/1.328_biest_149.php @@ -0,0 +1,15 @@ +<?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'"); + } + +} + diff --git a/lib/models/resources/ResourceRequest.class.php b/lib/models/resources/ResourceRequest.class.php index 037419a78e20a5be253b9af4feb3ad8fc8ac6a3b..9782b59636ac4fc620d0ecef89ac161c26395626 100644 --- a/lib/models/resources/ResourceRequest.class.php +++ b/lib/models/resources/ResourceRequest.class.php @@ -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,11 +566,23 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen */ public function cbAfterStore() { - if($this->closed == '3') { - $this->sendRequestDeniedMail(); + 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()); + } + /** * This validation method is called before storing an object. */ @@ -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, ' ,'); + } }