diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-10-24 14:33:44 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-10-24 22:27:31 +0200 |
commit | 4f04924e29b3fdda53aab431411868dc117607f2 (patch) | |
tree | 07bff8f5d655a66d4936d087c4fa4aeaacc5cfe6 /db/migrations | |
parent | 7762c0eb2bdbe72b081cf6eb0d3e0ade7f25689c (diff) |
Privileges: grant user work log permissions to shikos & cleanup
Closes #478 (Make user work log available)
Diffstat (limited to 'db/migrations')
-rw-r--r-- | db/migrations/2018_01_01_000004_cleanup_group_privileges.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/db/migrations/2018_01_01_000004_cleanup_group_privileges.php b/db/migrations/2018_01_01_000004_cleanup_group_privileges.php new file mode 100644 index 00000000..aead4422 --- /dev/null +++ b/db/migrations/2018_01_01_000004_cleanup_group_privileges.php @@ -0,0 +1,66 @@ +<?php + +namespace Engelsystem\Migrations; + +use Engelsystem\Database\Migration\Migration; + +class CleanupGroupPrivileges extends Migration +{ + /** + * Run the migration + */ + public function up() + { + if (!$this->schema->hasTable('GroupPrivileges')) { + return; + } + + $connection = $this->schema->getConnection(); + + // Add permissions to shikos to assign worklog entries + $connection->insert( + ' + INSERT INTO `GroupPrivileges` (`group_id`, `privilege_id`) + VALUES (?, ?) + ', + [ + -40, // Shift Coordinator + 43, // admin_user_worklog + ] + ); + + // Delete unused privileges + $connection->delete(' + DELETE FROM `Privileges` + WHERE `name` IN( + \'user_wakeup\', + \'faq\', + \'credits\' + ) + '); + } + + /** + * Reverse the migration + */ + public function down() + { + if (!$this->schema->hasTable('GroupPrivileges')) { + return; + } + + // Add permissions to shikos to assign worklog entries + $this->schema->getConnection()->delete( + ' + DELETE FROM `GroupPrivileges` + WHERE + group_id = ? + AND privilege_id = ? + ', + [ + -40, // Shift Coordinator + 43, // admin_user_worklog + ] + ); + } +} |