Skip to content

Commit

Permalink
Fix for broken avatar links
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusWME committed Dec 7, 2016
1 parent 7012d71 commit 5dd0dcb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
3 changes: 2 additions & 1 deletion pcgf/pmnamesuggestions/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ services:
- @request
- @dbal.conn
- @auth
- @user
- @user
- %core.root_path%
24 changes: 16 additions & 8 deletions pcgf/pmnamesuggestions/controller/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,30 @@ class controller
/** @var \phpbb\user $user User object */
protected $user;

/** @var string $phpbb_root_path The forum root path */
protected $phpbb_root_path;

/**
* Constructor
*
* @access public
* @since 1.0.0
*
* @param \phpbb\request\request\ $request Request object
* @param \phpbb\db\driver\factory $db Database object
* @param \phpbb\auth\auth $auth Authenticator object
* @param \phpbb\user $user User object
* @param \phpbb\request\request\ $request Request object
* @param \phpbb\db\driver\factory $db Database object
* @param \phpbb\auth\auth $auth Authenticator object
* @param \phpbb\user $user User object
* @param string $phpbb_root_path The forum root path
*
* @return \pcgf\pmnamesuggestions\controller\controller The controller object of the extension
*/
public function __construct(\phpbb\request\request $request, \phpbb\db\driver\factory $db, \phpbb\auth\auth $auth, \phpbb\user $user)
public function __construct(\phpbb\request\request $request, \phpbb\db\driver\factory $db, \phpbb\auth\auth $auth, \phpbb\user $user, $phpbb_root_path)
{
$this->request = $request;
$this->db = $db;
$this->auth = $auth;
$this->user = $user;
$this->phpbb_root_path = $phpbb_root_path;
}

/**
Expand Down Expand Up @@ -75,11 +80,14 @@ public function getNameSuggestions()
AND username_clean ' . $this->db->sql_like_expression($this->db->get_any_char() . $search . $this->db->get_any_char()) . '
ORDER BY username_clean ' . $this->db->sql_like_expression($search . $this->db->get_any_char()) . ' DESC, username DESC';
$result = $this->db->sql_query($query);
$phpbb_root_path = defined('PHPBB_ROOT_PATH') ? PHPBB_ROOT_PATH : './';
$default_avatar_url = $phpbb_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/no_avatar.gif';
$default_avatar_url = $this->phpbb_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/no_avatar.gif';
if (!file_exists($default_avatar_url))
{
$default_avatar_url = $phpbb_root_path . 'ext/pcgf/pmnamesuggestions/styles/all/theme/images/no-avatar.gif';
$default_avatar_url = $this->phpbb_root_path . 'ext/pcgf/pmnamesuggestions/styles/all/theme/images/no-avatar.gif';
}
if (!defined('PHPBB_USE_BOARD_URL_PATH'))
{
define('PHPBB_USE_BOARD_URL_PATH', true);
}
// Get all users with pm read permission
while ($user = $this->db->sql_fetchrow($result))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ function hideSuggestions() {
}

function setSuggestionPosition() {
// Position the suggestion list under the current line of the user list
var userListPosition = pcgfUserList.position();
var currentLine = pcgfUserList.val();
currentLine = currentLine.substr(0, pcgfUserList.prop('selectionStart')).split('\n').length;
pcgfSuggestionList.css({
display: 'inline-block',
left: userListPosition.left,
top: userListPosition.top + (currentLine * parseInt(pcgfUserList.css('line-height'))) + 5
});
if (pcgfResultCount > 0) {
// Position the suggestion list under the current line of the user list
var userListPosition = pcgfUserList.position();
var currentLine = pcgfUserList.val();
currentLine = currentLine.substr(0, pcgfUserList.prop('selectionStart')).split('\n').length;
pcgfSuggestionList.css({
display: 'inline-block',
left: userListPosition.left,
top: userListPosition.top + (currentLine * parseInt(pcgfUserList.css('line-height'))) + 5
});
}
}

function setPMName(name) {
Expand Down Expand Up @@ -138,6 +140,7 @@ pcgfUserList.on('keyup', function(e) {
searchValue = searchValue.substr(startIndex, endIndex - startIndex);
if (searchValue !== pcgfLastSearchValue) {
pcgfLastSearchValue = searchValue;
//noinspection JSUnusedGlobalSymbols
$.ajax({
url: pcgfPMNameSuggestionURL, type: 'POST', data: {search: searchValue}, success: function(result) {
if (searchValue === pcgfLastSearchValue) {
Expand Down

0 comments on commit 5dd0dcb

Please sign in to comment.