Skip to content
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

[ticket/649] Use phpbb_get_user_rank() instead of deprecated function #650

Merged
merged 5 commits into from
Sep 13, 2015
Merged
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
14 changes: 14 additions & 0 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static public function getSubscribedEvents()
'core.user_setup' => 'load_portal_language',
'core.viewonline_overwrite_location' => 'viewonline_page',
'core.page_header' => 'add_portal_link',
'core.permissions' => 'load_permissions',
);
}

Expand Down Expand Up @@ -175,4 +176,17 @@ protected function board_disabled()
{
return $this->config['board_disable'] && !defined('SKIP_CHECK_DISABLED') && !$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_');
}

/**
* Load permissions into permissions array
*
* @param array $event Event data
*/
public function load_permissions($event)
{
$permissions = $event['permissions'];
$permissions['a_manage_portal'] = array('lang' => 'ACL_A_MANAGE_PORTAL', 'cat' => 'misc');
$permissions['u_view_portal'] = array('lang' => 'ACL_U_VIEW_PORTAL', 'cat' => 'misc');
$event['permissions'] = $permissions;
}
}
4 changes: 0 additions & 4 deletions language/de/info_acp_portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,4 @@
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Portal-Einstellungen geändert</strong><br />&raquo; Termin geändert: %s ',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Portal-Einstellungen geändert</strong><br />&raquo; Termin gelöscht: %s ',
'LOG_PORTAL_CONFIG' => '<strong>Portal-Einstellungen geändert</strong><br />&raquo; %s',

// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Kann Portal-Einstellungen ändern',
'ACL_U_VIEW_PORTAL' => 'Kann das Portal sehen',
));
39 changes: 39 additions & 0 deletions language/de/permissions_portal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Kann Portal-Einstellungen �ndern',
'ACL_U_VIEW_PORTAL' => 'Kann das Portal sehen',
));
4 changes: 0 additions & 4 deletions language/en/info_acp_portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Altered Portal settings</strong><br />&raquo; Event updated: %s ',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Altered Portal settings</strong><br />&raquo; Event removed: %s ',
'LOG_PORTAL_CONFIG' => '<strong>Altered Portal settings</strong><br />&raquo; %s',

// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Can alter Portal settings',
'ACL_U_VIEW_PORTAL' => 'Can view the Portal',
));
39 changes: 39 additions & 0 deletions language/en/permissions_portal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Can alter Portal settings',
'ACL_U_VIEW_PORTAL' => 'Can view the Portal',
));
4 changes: 0 additions & 4 deletions language/es/info_acp_portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Ajustes del Portal alterados</strong><br />&raquo; Evento actualizado: %s ',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Ajustes del Portal alterados</strong><br />&raquo; Evento eliminado: %s ',
'LOG_PORTAL_CONFIG' => '<strong>Ajustes del Portal alterados</strong><br />&raquo; %s',

// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Puede alterar ajustes del Portal',
'ACL_U_VIEW_PORTAL' => 'Puede ver el Portal',
));
39 changes: 39 additions & 0 deletions language/es/permissions_portal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Puede alterar ajustes del Portal',
'ACL_U_VIEW_PORTAL' => 'Puede ver el Portal',
));
4 changes: 0 additions & 4 deletions language/fr/info_acp_portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,4 @@
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Paramètres du portail modifiés</strong><br />&raquo; Évènement mis à jour : %s ',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Paramètres du portail modifiés</strong><br />&raquo; Évènement retiré : %s ',
'LOG_PORTAL_CONFIG' => '<strong>Paramètres du portail modifiés</strong><br />&raquo; %s',

// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Peut modifier les paramètres du portail',
'ACL_U_VIEW_PORTAL' => 'Peut afficher le portail',
));
39 changes: 39 additions & 0 deletions language/fr/permissions_portal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Peut modifier les param�tres du portail',
'ACL_U_VIEW_PORTAL' => 'Peut afficher le portail',
));
4 changes: 0 additions & 4 deletions language/it/info_acp_portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,4 @@
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Impostazioni portale modificate</strong><br />&raquo; Evento aggiornato: %s ',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Impostazioni portale modificate</strong><br />&raquo; Evento rimosso: %s ',
'LOG_PORTAL_CONFIG' => '<strong>Impostazioni portale modificate</strong><br />&raquo; %s',

// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Può modificare le impostazioni del portale',
'ACL_U_VIEW_PORTAL' => 'Può visualizzare il portale',
));
39 changes: 39 additions & 0 deletions language/it/permissions_portal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Pu� modificare le impostazioni del portale',
'ACL_U_VIEW_PORTAL' => 'Pu� visualizzare il portale',
));
3 changes: 0 additions & 3 deletions language/nl/info_acp_portal.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,4 @@
'LOG_PORTAL_EVENT_UPDATED' => '<strong>Portaalinstellingen veranderd</strong><br />&raquo; Evenement gewijzigd: %s ',
'LOG_PORTAL_EVENT_REMOVED' => '<strong>Portaalinstellingen veranderd</strong><br />&raquo; Evenement verwijderd: %s ',
'LOG_PORTAL_CONFIG' => '<strong>Portaalinstellingen veranderd</strong><br />&raquo; %s',
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Kan portaalinstellingen wijzigen',
'ACL_U_VIEW_PORTAL' => 'Kan portaal bekijken',
));
39 changes: 39 additions & 0 deletions language/nl/permissions_portal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
// Adding the permissions
'ACL_A_MANAGE_PORTAL' => 'Kan portaalinstellingen wijzigen',
'ACL_U_VIEW_PORTAL' => 'Kan portaal bekijken',
));
9 changes: 4 additions & 5 deletions modules/random_member.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ public function get_template_side($module_id)

$avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($row, 'user'), 'USER_AVATAR');

$rank_title = $rank_img = $rank_img_src = '';
get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src);
$rank_data = phpbb_get_user_rank($row, $row['user_posts']);

$username = $row['username'];
$user_id = (int) $row['user_id'];
Expand All @@ -121,9 +120,9 @@ public function get_template_side($module_id)
'USER_COLOR' => get_username_string('colour', $user_id, $username, $colour),
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),

'RANK_TITLE' => $rank_title,
'RANK_IMG' => $rank_img,
'RANK_IMG_SRC' => $rank_img_src,
'RANK_TITLE' => $rank_data['title'],
'RANK_IMG' => $rank_data['img'],
'RANK_IMG_SRC' => $rank_data['img_src'],

'USER_POSTS' => (int) $row['user_posts'],
'AVATAR_IMG' => $avatar_img,
Expand Down
11 changes: 5 additions & 6 deletions modules/user_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function __construct($auth, $config, $controller_helper, $db, $path_helpe
*/
public function get_template_side($module_id)
{
if (!function_exists('get_user_rank'))
if (!function_exists('phpbb_get_user_rank'))
{
include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ext);
}
Expand Down Expand Up @@ -147,8 +147,7 @@ public function get_template_side($module_id)
$username = $this->user->data['username'];
$colour = $this->user->data['user_colour'];
$avatar_img = phpbb_get_avatar(\phpbb\avatar\manager::clean_row($this->user->data, 'user'), 'USER_AVATAR');
$rank_title = $rank_img = $rank_img_src = '';
\get_user_rank($this->user->data['user_rank'], $this->user->data['user_posts'], $rank_title, $rank_img, $rank_img_src);
$rank_data = phpbb_get_user_rank($this->user->data, $this->user->data['user_posts']);

// Assign specific vars
$this->template->assign_vars(array(
Expand All @@ -157,9 +156,9 @@ public function get_template_side($module_id)
'L_UNREAD_POSTS'=> $this->user->lang['SEARCH_UNREAD'] . '&nbsp;(' . $unread_posts_count . ')',

'B3P_AVATAR_IMG' => $avatar_img,
'B3P_RANK_TITLE' => $rank_title,
'B3P_RANK_IMG' => $rank_img,
'RANK_IMG_SRC' => $rank_img_src,
'B3P_RANK_TITLE' => $rank_data['title'],
'B3P_RANK_IMG' => $rank_data['img'],
'RANK_IMG_SRC' => $rank_data['img_src'],

'USERNAME_FULL' => get_username_string('full', $user_id, $username, $colour),
'U_VIEW_PROFILE' => get_username_string('profile', $user_id, $username, $colour),
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/portal_acp_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function test_portal_logs()

public function test_portal_permissions()
{
$this->add_lang_ext('board3/portal', 'info_acp_portal');
$this->add_lang_ext('board3/portal', 'permissions_portal');
$crawler = self::request('GET', 'adm/index.php?i=acp_permissions&mode=setting_group_global&sid=' . $this->sid);
$form = $crawler->selectButton('submit')->form();
$crawler = self::submit($form);
Expand Down
1 change: 1 addition & 0 deletions tests/unit/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function test_getSubscribedEvents()
'core.user_setup',
'core.viewonline_overwrite_location',
'core.page_header',
'core.permissions',
), array_keys(\board3\portal\event\listener::getSubscribedEvents()));
}

Expand Down