Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
- '%core.root_path%'
- '%core.php_ext%'
- '@controller.helper'
- '@dispatcher'
- '%tables.thanks%'
- '%tables.users%'
- '%tables.posts%'
Expand Down
44 changes: 40 additions & 4 deletions controller/thanks_ajax_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ class thanks_ajax_handler

/** @var string phpEx */
protected $php_ext;

/** @var \phpbb\controller\helper */
protected $controller_helper;

/** @var \phpbb\event\dispatcher_interface */
protected $phpbb_dispatcher;

/** @var string */
protected $thanks_table;

Expand Down Expand Up @@ -58,6 +62,7 @@ class thanks_ajax_handler
* @param string $phpbb_root_path phpbb_root_path
* @param string $php_ext phpEx
* @param \phpbb\controller\helper $controller_helper Controller helper object
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object
* @param string $thanks_table ThanksForPost table name
* @param string $users_table Users table name
* @param string $posts_table Posts table name
Expand All @@ -68,7 +73,13 @@ class thanks_ajax_handler
* @access public
*/

public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\auth\auth $auth, \phpbb\user $user, $phpbb_root_path, $php_ext, \phpbb\controller\helper $controller_helper, $thanks_table, $users_table, $posts_table, \phpbb\path_helper $path_helper, \phpbb\extension\manager $phpbb_extension_manager, \gfksx\thanksforposts\core\helper $gfksx_helper = null)
public function __construct(\phpbb\config\config $config, \phpbb\db\driver\driver_interface $db,
\phpbb\auth\auth $auth, \phpbb\user $user, $phpbb_root_path, $php_ext,
\phpbb\controller\helper $controller_helper,
\phpbb\event\dispatcher_interface $phpbb_dispatcher,
$thanks_table, $users_table, $posts_table,
\phpbb\path_helper $path_helper, \phpbb\extension\manager $phpbb_extension_manager,
\gfksx\thanksforposts\core\helper $gfksx_helper = null)
{
$this->config = $config;
$this->db = $db;
Expand All @@ -77,6 +88,7 @@ public function __construct(\phpbb\config\config $config, \phpbb\db\driver\drive
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->controller_helper = $controller_helper;
$this->phpbb_dispatcher = $phpbb_dispatcher;
$this->thanks_table = $thanks_table;
$this->users_table = $users_table;
$this->posts_table = $posts_table;
Expand Down Expand Up @@ -146,6 +158,21 @@ public function main($action, $poster, $forum, $topic, $post)
private function thanks_for_post($action, $poster_id, $forum_id, $topic_id, $post_id)
{
$user_id = (int) $this->user->data['user_id'];

/**
*
*
* @event alg.addonforthanksforposts.thanks_for_posts_before
* @var string action
* @var int poster_id
* @var int forum_id
* @var int topic_id
* @var int post_id
* @var int user_id
*/
$vars = ['action', 'poster_id', 'forum_id', 'topic_id', 'post_id', 'user_id'];
extract($this->phpbb_dispatcher->trigger_event('alg.addonforthanksforposts.thanks_for_posts_before', compact($vars)));

if ($this->user->data['user_type'] != USER_IGNORE && !empty($poster_id))
{
switch ($action)
Expand Down Expand Up @@ -285,6 +312,8 @@ private function thanks_for_post($action, $poster_id, $forum_id, $topic_id, $pos
'S_THANKS_REPUT_GRAPHIC' => isset($this->config['thanks_reput_graphic']) ? (bool) $this->config['thanks_reput_graphic'] : false,
'THANKS_REPUT_GRAPHIC_WIDTH' => isset($this->config['thanks_reput_level']) ? (isset($this->config['thanks_reput_height']) ? sprintf('%dpx', $this->config['thanks_reput_level']*$this->config['thanks_reput_height']) : false) : false,
'THANKS_REPUT_HEIGHT' => isset($this->config['thanks_reput_height']) ? sprintf('%dpx', $this->config['thanks_reput_height']) : false,
'THANKS_REPUT_IMAGE' => $this->config['thanks_reput_image'] ? generate_board_url() . '/' . $this->config['thanks_reput_image'] : '',
'THANKS_REPUT_IMAGE_BACK' => $this->config['thanks_reput_image_back'] ? generate_board_url() . '/' . $this->config['thanks_reput_image_back'] : '',
'THANKS' => $thanks_list,
'THANKS_POSTLIST_VIEW' => isset($this->config['thanks_postlist_view']) ? (bool) $this->config['thanks_postlist_view'] : false,
'S_MOD_THANKS' => $this->auth->acl_get('m_thanks') ? true :false,
Expand All @@ -303,6 +332,7 @@ private function thanks_for_post($action, $poster_id, $forum_id, $topic_id, $pos
'IS_ALLOW_REMOVE_THANKS' => isset($this->config['remove_thanks']) ? (bool) $this->config['remove_thanks'] : true,
'CORRETED_TEXT_BBCODE' => $this-> correctedTextHideBbcode,
'IS_CHANGE_TEXT' => $this-> b_changeText,
'THANKS_COUNT' => $thanks_number,
);
}

Expand Down Expand Up @@ -395,12 +425,18 @@ private function get_thanks($post_id, &$count)
else
{
$return .= $comma;
$return .= get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
$nickname = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
if (isset($this->config['thanks_time_view']) ? $this->config['thanks_time_view'] : false)
{
$return .= ($row['thanks_time']) ? ' ('.$this->user->format_date($row['thanks_time'], false, ($view == 'print') ? true : false) . ')' : '';
$return .= ($row['thanks_time']) ? '<span title="'.$this->user->format_date($row['thanks_time'], false, ($view == 'print') ? true : false) . '">' : '';
$return .= $nickname;
$return .= '</span>';
}
else
{
$return .= $nickname;
}
$comma = ' &bull; ';
$comma = ', ';
}
$count++;
}
Expand Down
Loading