Skip to content

Commit f3788c8

Browse files
authored
Merge pull request #402 from danieltj27/3.3.x
Add link to user customisations page
2 parents d502870 + eae4595 commit f3788c8

File tree

4 files changed

+106
-7
lines changed

4 files changed

+106
-7
lines changed

config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ services:
226226
- '@dbal.conn'
227227
- '@user'
228228
- '@template'
229+
- '@language'
229230
- '@phpbb.titania.controller.helper'
230231
- '@phpbb.titania.access'
231232
- '@phpbb.titania.contribution.type.collection'

event/main_listener.php

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use phpbb\event\data;
1818
use phpbb\auth\auth;
1919
use phpbb\template\template;
20+
use phpbb\language\language;
2021
use phpbb\titania\controller\helper;
2122
use phpbb\titania\ext;
2223
use phpbb\user;
@@ -44,6 +45,9 @@ class main_listener implements EventSubscriberInterface
4445
/** @var \phpbb\template\template */
4546
protected $template;
4647

48+
/** @var \phpbb\language\language */
49+
protected $language;
50+
4751
/** @var \phpbb\titania\controller\helper */
4852
protected $controller_helper;
4953

@@ -79,12 +83,13 @@ class main_listener implements EventSubscriberInterface
7983
* @param string $ext_root_path Titania root path
8084
* @param string $php_ext PHP file extension
8185
*/
82-
public function __construct(request $request, db_driver_interface $db, user $user, template $template, helper $controller_helper, access $access, type_collection $types, $phpbb_root_path, $ext_root_path, $php_ext)
86+
public function __construct(request $request, db_driver_interface $db, user $user, template $template, language $language, helper $controller_helper, access $access, type_collection $types, $phpbb_root_path, $ext_root_path, $php_ext)
8387
{
8488
$this->request = $request;
8589
$this->db = $db;
8690
$this->user = $user;
8791
$this->template = $template;
92+
$this->language = $language;
8893
$this->controller_helper = $controller_helper;
8994
$this->access = $access;
9095
$this->types = $types;
@@ -97,16 +102,18 @@ public function __construct(request $request, db_driver_interface $db, user $use
97102
static public function getSubscribedEvents()
98103
{
99104
return array(
100-
'core.permissions' => 'add_permissions',
101-
'kernel.request' => array(array('startup', -1)),
102-
'core.page_header_after' => 'overwrite_template_vars',
103-
'core.text_formatter_s9e_configure_after' => 'inject_bbcode_code_lang',
105+
'core.permissions' => 'add_permissions',
106+
'kernel.request' => array(array('startup', -1)),
107+
'core.page_header_after' => 'overwrite_template_vars',
108+
'core.text_formatter_s9e_configure_after' => 'inject_bbcode_code_lang',
104109

105110
// Check whether a user is removed from a team
106-
'core.group_delete_user_after' => 'remove_users_from_subscription',
111+
'core.group_delete_user_after' => 'remove_users_from_subscription',
107112

108113
// Include quoted text when private messaging
109-
'core.ucp_pm_compose_predefined_message' => 'quote_text_upon_pm',
114+
'core.ucp_pm_compose_predefined_message' => 'quote_text_upon_pm',
115+
116+
'core.memberlist_view_profile' => 'add_memberlist_template_vars',
110117
);
111118
}
112119

@@ -406,4 +413,40 @@ public function quote_text_upon_pm($event)
406413
}
407414
}
408415
}
416+
417+
/**
418+
* Display contribution count and link to Titania profile in memberlist.php.
419+
* @param $event
420+
*/
421+
public function add_memberlist_template_vars($event)
422+
{
423+
if (!defined('TITANIA_CONTRIBS_TABLE'))
424+
{
425+
// Include Titania so we can access the constants
426+
require($this->ext_root_path . 'common.' . $this->php_ext);
427+
}
428+
429+
$this->language->add_lang(['memberlist'], 'phpbb/titania');
430+
431+
$sql = 'SELECT COUNT(contrib_id) as contribs
432+
FROM ' . TITANIA_CONTRIBS_TABLE . '
433+
WHERE contrib_user_id = ' . (int) $event['member']['user_id'] . '
434+
AND contrib_status = 2';
435+
436+
$result = $this->db->sql_query($sql);
437+
438+
$u_total_contribs = (int) $this->db->sql_fetchfield('contribs');
439+
440+
$this->db->sql_freeresult($result);
441+
442+
$u_user_contribs = $this->controller_helper->route('phpbb.titania.author', array(
443+
'author' => urlencode($event['member']['username_clean']),
444+
'page' => 'contributions',
445+
));
446+
447+
$this->template->assign_vars(array(
448+
'U_USER_CONTRIB_TOTAL' => $u_total_contribs,
449+
'U_USER_CONTRIB_LINK' => $this->controller_helper->get_real_url($u_user_contribs),
450+
));
451+
}
409452
}

language/en/memberlist.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
*
4+
* This file is part of the phpBB Customisation Database package.
5+
*
6+
* @copyright (c) phpBB Limited <https://www.phpbb.com>
7+
* @license GNU General Public License, version 2 (GPL-2.0)
8+
*
9+
* For full copyright and license information, please see
10+
* the docs/CREDITS.txt file.
11+
*
12+
*/
13+
14+
/**
15+
* DO NOT CHANGE
16+
*/
17+
if (!defined('IN_PHPBB'))
18+
{
19+
exit;
20+
}
21+
22+
if (empty($lang) || !is_array($lang))
23+
{
24+
$lang = array();
25+
}
26+
27+
// DEVELOPERS PLEASE NOTE
28+
//
29+
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
30+
//
31+
// Placeholders can now contain order information, e.g. instead of
32+
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
33+
// translators to re-order the output of data while ensuring it remains correct
34+
//
35+
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
36+
// equally where a string contains only two placeholders which are used to wrap text
37+
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
38+
//
39+
// Some characters you may want to copy&paste:
40+
// ’ » “ ” …
41+
//
42+
43+
$lang = array_merge($lang, array(
44+
'USER_TOTAL_CONTRIBUTIONS' => 'Total contributions',
45+
'SEARCH_USER_CONTRIBUTIONS' => 'Search user’s contributions',
46+
));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<dt>{{ lang('USER_TOTAL_CONTRIBUTIONS') ~ lang('COLON') }}</dt>
2+
<dd>
3+
{{ U_USER_CONTRIB_TOTAL }} |
4+
<strong>
5+
<a href="{{ U_USER_CONTRIB_LINK }}">
6+
{{ lang('SEARCH_USER_CONTRIBUTIONS') }}
7+
</a>
8+
</strong>
9+
</dd>

0 commit comments

Comments
 (0)