Skip to content
Snippets Groups Projects
Commit 1e701953 authored by Peter Thienel's avatar Peter Thienel
Browse files

Resolve "MVV: Logging von Personen und Dateizuordnungen"

Closes #3384

Merge request studip/studip!2302
parent c3d34bc3
No related branches found
No related tags found
No related merge requests found
<?php
class Tic3384AddMvvLogActions extends Migration
{
public function description()
{
return 'Adds new log actions to mvv for contacts and files.';
}
public function up() {
StudipLog::registerAction(
'MVV_CONTACT_NEW',
'MVV: Kontaktperson erstellen',
'%user erstellt neue Kontaktperson %contact(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_CONTACT_UPDATE',
'MVV: Kontaktperson ändern',
'%user ändert Kontaktperson %contact(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_CONTACT_DELETE',
'MVV: Kontaktperson löschen',
'%user löscht Kontaktperson %contact(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_EXTERN_CONTACT_NEW',
'MVV: Externe Kontaktperson erstellen',
'%user erstellt neue externe Kontaktperson %contact(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_EXTERN_CONTACT_UPDATE',
'MVV: Externe Kontaktperson ändern',
'%user ändert externe Kontaktperson %contact(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_EXTERN_CONTACT_DELETE',
'MVV: Externe Kontaktperson löschen',
'%user löscht externe Kontaktperson %contact(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_CONTACT_RANGE_NEW',
'MVV: Kontaktperson zuordnen',
'%user ordnet die Kontaktperson %contact(%affected) dem Bereich %range(%coaffected) zu.',
'MVV'
);
StudipLog::registerAction(
'MVV_CONTACT_RANGE_DELETE',
'MVV: Zuordnung der Kontaktperson löschen',
'%user löscht die Zuordnung der Kontaktperson %contact(%affected) zum Bereich %range(%coaffected).',
'MVV'
);
StudipLog::registerAction(
'MVV_CONTACT_RANGE_UPDATE',
'MVV: Zuordnung der Kontaktperson ändern',
'%user ändert die Zuordnung der Kontaktperson %contact(%affected) zum Bereich %range(%coaffected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_NEW',
'MVV: Material/Dokument erstellen',
'%user erstellt neues Material/Dokument %file(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_UPDATE',
'MVV: Material/Dokument ändern',
'%user ändert Material/Dokument %file(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_DELETE',
'MVV: Material/Dokument löschen',
'%user löscht Material/Dokument %file(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_FILEREF_NEW',
'MVV: Datei erstellen',
'%user erstellt neue Datei %fileref(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_FILEREF_UPDATE',
'MVV: Datei ändern',
'%user ändert Datei %fileref(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_FILEREF_DELETE',
'MVV: Datei löschen',
'%user löscht Datei %fileref(%affected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_RANGE_NEW',
'MVV: Material/Dokument zuordnen',
'%user ordnet Material/Dokument %fileref(%affected) zum Bereich %range(%coaffected) zu.',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_RANGE_UPDATE',
'MVV: Zuordnung von Material/Dokument zu Bereich ändern.',
'%user ändert Zuordnung von Material/Dokument %fileref(%affected) zu Bereich %range(%coaffected).',
'MVV'
);
StudipLog::registerAction(
'MVV_FILE_RANGE_DELETE',
'MVV: Zuordnung von Material/Dokument zu Bereich löschen',
'%user löscht Zuordnung von Material/Dokument %fileref(%affected) von Bereich %range/%coaffected).',
'MVV'
);
}
public function down() {
StudipLog::unregisterAction('MVV_CONTACT_NEW');
StudipLog::unregisterAction('MVV_CONTACT_UPDATE');
StudipLog::unregisterAction('MVV_CONTACT_DELETE');
StudipLog::unregisterAction('MVV_EXTERN_CONTACT_NEW');
StudipLog::unregisterAction('MVV_EXTERN_CONTACT_UPDATE');
StudipLog::unregisterAction('MVV_EXTERN_CONTACT_DELETE');
StudipLog::unregisterAction('MVV_CONTACT_RANGE_NEW');
StudipLog::unregisterAction('MVV_CONTACT_RANGE_UPDATE');
StudipLog::unregisterAction('MVV_CONTACT_RANGE_DELETE');
StudipLog::unregisterAction('MVV_FILE_NEW');
StudipLog::unregisterAction('MVV_FILE_UPDATE');
StudipLog::unregisterAction('MVV_FILE_DELETE');
StudipLog::unregisterAction('MVV_FILE_FILEREF_NEW');
StudipLog::unregisterAction('MVV_FILE_FILEREF_UPDATE');
StudipLog::unregisterAction('MVV_FILE_FILEREF_DELETE');
StudipLog::unregisterAction('MVV_FILE_RANGE_NEW');
StudipLog::unregisterAction('MVV_FILE_RANGE_UPDATE');
StudipLog::unregisterAction('MVV_FILE_RANGE_DELETE');
}
}
This diff is collapsed.
...@@ -452,4 +452,26 @@ class MvvContact extends ModuleManagementModel ...@@ -452,4 +452,26 @@ class MvvContact extends ModuleManagementModel
]; ];
} }
protected function logChanges($action = null)
{
$log_action = 'MVV_CONTACT_' . mb_strtoupper($action);
$affected = $this->id;
$info = ['mvv_contacts.*'];
$debug_info = $this->getDisplayName();
if ($action === 'update') {
if ($this->isFieldDirty('contact_status')) {
$info[] = 'contatct_status: '
. ($this->contact_status ?? '-')
. ' (' . ($this->getPristineValue('contact_status') ?? '-')
. ')';
}
if ($this->isFieldDirty('alt_mail')) {
$info[] = 'alt_mail: '
. ($this->alt_mail ?? '-')
. ' (' . ($this->getPristineValue('alt_mail') ?? '-')
. ')';
}
}
StudipLog::log($log_action, $affected, '', implode(' | ', $info), $debug_info);
}
} }
...@@ -182,7 +182,7 @@ class MvvContactRange extends ModuleManagementModel ...@@ -182,7 +182,7 @@ class MvvContactRange extends ModuleManagementModel
/** /**
* Returns the 'PERSONEN_GRUPPEN' from mvv config of given range type. * Returns the 'PERSONEN_GRUPPEN' from mvv config of given range type.
* *
* @param sting $range_type type of the mvv object. * @param string $range_type type of the mvv object.
* @return array PERSONEN_GRUPPEN * @return array PERSONEN_GRUPPEN
*/ */
public static function getCategoriesByRangetype($range_type) public static function getCategoriesByRangetype($range_type)
...@@ -214,4 +214,30 @@ class MvvContactRange extends ModuleManagementModel ...@@ -214,4 +214,30 @@ class MvvContactRange extends ModuleManagementModel
return $cats[$this->category]['name']; return $cats[$this->category]['name'];
} }
protected function logChanges($action = null)
{
$log_action = 'MVV_CONTACT_RANGE_' . mb_strtoupper($action);
$affected = $this->contact_id;
$co_affected = $this->range_id;
$info = ['mvv_contacts_ranges.*'];
$debug_info = $this->id;
if ($action === 'update') {
$logged_fields = [
'range_type',
'type',
'category',
'position',
];
foreach ($logged_fields as $logged_field) {
if ($this->isFieldDirty($logged_field)) {
$info[] = $logged_field
. ': ' . ($this->getValue($logged_field) ?? '-')
. ' (' . ($this->getPristineValue($logged_field) ?? '-')
. ')';
}
}
}
StudipLog::log($log_action, $affected, $co_affected, implode(' | ', $info), $debug_info);
}
} }
...@@ -43,4 +43,30 @@ class MvvExternContact extends ModuleManagementModel ...@@ -43,4 +43,30 @@ class MvvExternContact extends ModuleManagementModel
parent::configure($config); parent::configure($config);
} }
protected function logChanges($action = null)
{
$log_action = 'MVV_EXTERN_CONTACT_' . mb_strtoupper($action);
$affected = $this->id;
$info = ['mvv_extern_contacts.*'];
$debug_info = $this->getDisplayName();
if ($action === 'update') {
$logged_fields = [
'name',
'vorname',
'homepage',
'mail',
'tel',
];
foreach ($logged_fields as $logged_field) {
if ($this->isFieldDirty($logged_field)) {
$info[] = $logged_field
. ': ' . ($this->getValue($logged_field) ?? '-')
. ' (' . ($this->getPristineValue($logged_field) ?? '-')
. ')';
}
}
}
StudipLog::log($log_action, $affected, null, implode(' | ', $info), $debug_info);
}
} }
...@@ -369,7 +369,7 @@ class MvvFile extends ModuleManagementModel ...@@ -369,7 +369,7 @@ class MvvFile extends ModuleManagementModel
/** /**
* Adds this mvvfile to given range. * Adds this mvvfile to given range.
* *
* @param sting $range_id Id of the mvv object. * @param string $range_id Id of the mvv object.
*/ */
public function addToRange($range_id, $range_type) public function addToRange($range_id, $range_type)
{ {
...@@ -489,4 +489,30 @@ class MvvFile extends ModuleManagementModel ...@@ -489,4 +489,30 @@ class MvvFile extends ModuleManagementModel
return $stm->fetchAll(PDO::FETCH_COLUMN, 0); return $stm->fetchAll(PDO::FETCH_COLUMN, 0);
} }
protected function logChanges($action = null)
{
$log_action = 'MVV_FILE_' . mb_strtoupper($action);
$affected = $this->id;
$info = ['mvv_files.*'];
$debug_info = $this->getDisplayName();
if ($action === 'update') {
$logged_fields = [
'year',
'type',
'category',
'tags',
'extern_visible',
];
foreach ($logged_fields as $logged_field) {
if ($this->isFieldDirty($logged_field)) {
$info[] = $logged_field
. ': ' . ($this->getValue($logged_field) ?? '-')
. ' (' . ($this->getPristineValue($logged_field) ?? '-')
. ')';
}
}
}
StudipLog::log($log_action, $affected, null, implode(' | ', $info), $debug_info);
}
} }
...@@ -111,4 +111,27 @@ class MvvFileFileref extends ModuleManagementModel ...@@ -111,4 +111,27 @@ class MvvFileFileref extends ModuleManagementModel
return false; return false;
} }
protected function logChanges($action = null)
{
$log_action = 'MVV_FILEREF_' . mb_strtoupper($action);
$affected = $this->id;
$info = ['mvv_files_filerefs.*'];
$debug_info = $this->getDisplayName();
if ($action === 'update') {
$logged_fields = [
'file_language',
'name',
];
foreach ($logged_fields as $logged_field) {
if ($this->isFieldDirty($logged_field)) {
$info[] = $logged_field
. ': ' . ($this->getValue($logged_field) ?? '-')
. ' (' . ($this->getPristineValue($logged_field) ?? '-')
. ')';
}
}
}
StudipLog::log($log_action, $affected, null, implode(' | ', $info), $debug_info);
}
} }
...@@ -55,4 +55,28 @@ class MvvFileRange extends ModuleManagementModel ...@@ -55,4 +55,28 @@ class MvvFileRange extends ModuleManagementModel
return $this->range_type; return $this->range_type;
} }
protected function logChanges($action = null)
{
$log_action = 'MVV_FILE_RANGE_' . mb_strtoupper($action);
$affected = $this->mvvfile_id;
$co_affected = $this->range_id;
$info = ['mvv_files_ranges.*'];
$debug_info = $this->id;
if ($action === 'update') {
$logged_fields = [
'range_type',
'position',
];
foreach ($logged_fields as $logged_field) {
if ($this->isFieldDirty($logged_field)) {
$info[] = $logged_field
. ': ' . ($this->getValue($logged_field) ?? '-')
. ' (' . ($this->getPristineValue($logged_field) ?? '-')
. ')';
}
}
}
StudipLog::log($log_action, $affected, $co_affected, implode(' | ', $info), $debug_info);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment