-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4452 from ushahidi/feat/permissions
feat: add "Delete Posts" and "Delete Own Posts" permissions
- Loading branch information
Showing
7 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class AddDeletePostsPermission extends AbstractMigration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
$this->execute("INSERT INTO permissions (name, description) | ||
VALUES ('Delete Posts', 'Delete Posts')"); | ||
|
||
$this->execute("INSERT INTO roles_permissions(`role`,`permission`) | ||
SELECT `role`,'Delete Posts' FROM roles_permissions WHERE `permission` = 'Manage Posts' | ||
"); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
|
||
$this->execute("DELETE FROM permissions WHERE name = 'Delete Posts'"); | ||
|
||
$this->execute("DELETE FROM roles_permissions WHERE permission = 'Delete Posts'"); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
migrations/20220721100747__add_delete_own_posts_permission.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
class AddDeleteOwnPostsPermission extends AbstractMigration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
$this->execute("INSERT INTO permissions (name, description) | ||
VALUES ('Delete Their Own Posts', 'Delete Their Own Posts')"); | ||
|
||
$this->execute("INSERT INTO roles_permissions(`role`,`permission`) | ||
SELECT `role`,'Delete Their Own Posts' FROM roles_permissions WHERE `permission` = 'Edit their own posts' | ||
"); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
$this->execute("DELETE FROM permissions WHERE name = 'Delete Their Own Posts'"); | ||
|
||
$this->execute("DELETE FROM roles_permissions WHERE permission = 'Delete Their Own Posts'"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters