-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix comment in ThreadAuthorRatedFormatter * Add public poll vote alert type * Fix instances, add check for public polls
- Loading branch information
1 parent
0a80cf5
commit 06bb7ba
Showing
4 changed files
with
154 additions
and
5 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
2 changes: 1 addition & 1 deletion
2
inc/plugins/MybbStuff/MyAlerts/src/Formatter/ThreadAuthorRatedFormatter.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
73 changes: 73 additions & 0 deletions
73
inc/plugins/MybbStuff/MyAlerts/src/Formatter/ThreadAuthorVotedFormatter.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,73 @@ | ||
<?php | ||
|
||
/** | ||
* Alert formatter for private thread author vote alerts. | ||
*/ | ||
class MybbStuff_MyAlerts_Formatter_ThreadAuthorVotedFormatter | ||
extends MybbStuff_MyAlerts_Formatter_AbstractFormatter | ||
{ | ||
/** | ||
* @var postParser $parser | ||
*/ | ||
private $parser; | ||
|
||
/** | ||
* Format an alert into it's output string to be used in both the main | ||
* alerts listing page and the popup. | ||
* | ||
* @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to format. | ||
* | ||
* @return string The formatted alert string. | ||
*/ | ||
public function formatAlert( | ||
MybbStuff_MyAlerts_Entity_Alert $alert, | ||
array $outputAlert | ||
) { | ||
$alertContent = $alert->getExtraDetails(); | ||
$threadLink = $this->buildShowLink($alert); | ||
|
||
return $this->lang->sprintf( | ||
$this->lang->myalerts_voted_threadauthor, | ||
$outputAlert['from_user'], | ||
htmlspecialchars_uni( | ||
$this->parser->parse_badwords($alertContent['t_subject']) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Init function called before running formatAlert(). Used to load language | ||
* files and initialize other required resources. | ||
* | ||
* @return void | ||
*/ | ||
public function init() | ||
{ | ||
if (!$this->lang->myalerts) { | ||
$this->lang->load('myalerts'); | ||
} | ||
|
||
require_once MYBB_ROOT . 'inc/class_parser.php'; | ||
$this->parser = new postParser; | ||
} | ||
|
||
/** | ||
* Build a link to an alert's content so that the system can redirect to | ||
* it. | ||
* | ||
* @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the | ||
* link for. | ||
* | ||
* @return string The built alert, preferably an absolute link. | ||
*/ | ||
public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert) | ||
{ | ||
$alertContent = $alert->getExtraDetails(); | ||
|
||
$threadLink = $this->mybb->settings['bburl'] . '/' . get_thread_link( | ||
(int) $alertContent['tid'] | ||
); | ||
|
||
return $threadLink; | ||
} | ||
} |
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