Skip to content

Commit aef9166

Browse files
committed
Improve sql query in total contribs method and format template
1 parent e4a8a0e commit aef9166

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,4 +380,4 @@ public function get_configurables()
380380
// 'repack_diff_extensions'
381381
);
382382
}
383-
}
383+
}

event/main_listener.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public function quote_text_upon_pm($event)
415415
}
416416

417417
/**
418-
* @todo
418+
* Display contribution count and link to Titania profile in memberlist.php.
419419
* @param $event
420420
*/
421421
public function add_memberlist_template_vars($event)
@@ -428,19 +428,16 @@ public function add_memberlist_template_vars($event)
428428

429429
$this->language->add_lang(['memberlist'], 'phpbb/titania');
430430

431-
$sql_ary = array(
432-
'SELECT' => 'COUNT(*)',
433-
'FROM' => [
434-
TITANIA_CONTRIBS_TABLE => 'c',
435-
],
436-
'WHERE' => 'c.contrib_user_id = ' . $event['member']['user_id'] . ' AND c.contrib_status = 2',
437-
);
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';
438435

439-
$sql = $this->db->sql_build_query('SELECT', $sql_ary);
440436
$result = $this->db->sql_query($sql);
441-
$contribs = $this->db->sql_fetchrow($result);
442437

443-
$u_total_contribs = intval($contribs['COUNT(*)']);
438+
$u_total_contribs = (int) $this->db->sql_fetchfield('contribs');
439+
440+
$db->sql_freeresult($result);
444441

445442
$u_user_contribs = $this->controller_helper->route('phpbb.titania.author', array(
446443
'author' => urlencode($event['member']['username_clean']),
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
<dt>{{ lang('USER_TOTAL_CONTRIBUTIONS') }}{{ lang('COLON') }}</dt> <dd>{{ U_USER_CONTRIB_TOTAL }} | <strong><a href="{{ U_USER_CONTRIB_LINK }}">{{ lang('SEARCH_USER_CONTRIBUTIONS') }}</a></strong></dd>
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)