-
Notifications
You must be signed in to change notification settings - Fork 183
hide delete actions if not authorised, toggle between delete and undelete #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+71
−6
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
undelete actions in routing and controller
updates on twig modified threads_list try to fix the formatting changes try to fix the formatting changes fixed an extra space removed delete method readded docs hmm bad at english cs cs cs lol added new line to end of file updated tabs in threads list updates added function small updates
- Loading branch information
commit bfb64e98c3ccc24e3f8e97a869903faa5d924acd
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -21,3 +21,4 @@ on: On %date% | |
| by: By %sender% | ||
| no_thread: There is no thread to show | ||
| delete: Delete | ||
| undelete: Undelete | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,18 +5,22 @@ | |
| use FOS\MessageBundle\Security\ParticipantProviderInterface; | ||
| use FOS\MessageBundle\Model\ReadableInterface; | ||
| use FOS\MessageBundle\Provider\ProviderInterface; | ||
| use FOS\MessageBundle\Model\ThreadInterface; | ||
| use FOS\MessageBundle\Security\AuthorizerInterface; | ||
|
|
||
| class MessageExtension extends \Twig_Extension | ||
| { | ||
| protected $participantProvider; | ||
| protected $provider; | ||
| protected $authorizer; | ||
|
|
||
| protected $nbUnreadMessagesCache; | ||
|
|
||
| public function __construct(ParticipantProviderInterface $participantProvider, ProviderInterface $provider) | ||
| public function __construct(ParticipantProviderInterface $participantProvider, ProviderInterface $provider, AuthorizerInterface $authorizer) | ||
| { | ||
| $this->participantProvider = $participantProvider; | ||
| $this->provider = $provider; | ||
| $this->authorizer = $authorizer; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -28,7 +32,9 @@ public function getFunctions() | |
| { | ||
| return array( | ||
| 'fos_message_is_read' => new \Twig_Function_Method($this, 'isRead'), | ||
| 'fos_message_nb_unread' => new \Twig_Function_Method($this, 'getNbUnread') | ||
| 'fos_message_nb_unread' => new \Twig_Function_Method($this, 'getNbUnread'), | ||
| 'fos_message_can_delete_thread' => new \Twig_Function_Method($this, 'canDeleteThread'), | ||
| 'fos_message_deleted_by_participant' => new \Twig_Function_Method($this, 'isThreadDeletedByParticipant') | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -41,6 +47,31 @@ public function isRead(ReadableInterface $readable) | |
| { | ||
| return $readable->isReadByParticipant($this->getAuthenticatedParticipant()); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Checks if the participant can mark a thread as deleted | ||
| * | ||
| * @param ThreadInterface $thread | ||
| * | ||
| * @return boolean true if participant can mark a thread as deleted, false otherwise | ||
| */ | ||
| public function canDeleteThread(ThreadInterface $thread) | ||
| { | ||
| return $this->authorizer->canDeleteThread($thread); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the participant has marked the thread as deleted | ||
| * | ||
| * @param ThreadInterface $thread | ||
| * | ||
| * @return boolean true if participant has marked the thread as deleted, false otherwise | ||
| */ | ||
| public function isThreadDeletedByParticipant(ThreadInterface $thread) | ||
| { | ||
| return $thread->isDeletedByParticipant($this->getAuthenticatedParticipant()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect indenting |
||
| } | ||
|
|
||
| /** | ||
| * Gets the number of unread messages for the current user | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably be a Twig test rather than a twig function