Panel
PowerQA is a state of the art discussion software that makes online discussions fun. It's simple, fast, and powerful.
Fighter
webmaster
+1 vote
Notice 236 views

Core functions changed

I changed some core functions. $absolute parameter has been added in below functions. In this change, we can display user's link and avatars in HTML e-mail that is sent from PowerQA. Refer to here in details.

qa-include/qa-app-users.php:

function qa_get_one_user_html($handle, $microformats=false, $favorited=false, $absolute=true)
/*
Return HTML to display for user with username $handle, with microformats if $microformats is true. Set $favorited to true to show the user as favorited.
*** Add $absolute parameter (If you use user's link in HTML emails, you should it true) ***
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

if (!strlen($handle))
return '';

$url = ($absolute ? qa_path_absolute('user/'.$handle) : qa_path_html('user/'.$handle));

$favclass = $favorited ? ' qa-user-favorited' : '';
$mfclass = $microformats ? ' url fn entry-title nickname' : '';

return '<a href="'.$url.'" class="qa-user-link'.$favclass.$mfclass.'">'.qa_html($handle).'</a>';
}
function qa_get_user_avatar_html($flags, $email, $handle, $blobid, $width, $height, $size, $padding=false, $absolute=false)
/*
Return HTML to display for the user's avatar, constrained to $size pixels, with optional $padding to that size
Pass the user's fields $flags, $email, $handle, and avatar $blobid, $width and $height
*** Add $absolute parameter (If you use avatar in HTML emails, you should it true) ***
*/
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

require_once QA_INCLUDE_DIR.'qa-app-format.php';

if (qa_opt('avatar_allow_gravatar') && ($flags & QA_USER_FLAGS_SHOW_GRAVATAR))
$html=qa_get_gravatar_html($email, $size);
elseif (qa_opt('avatar_allow_upload') && (($flags & QA_USER_FLAGS_SHOW_AVATAR)) && isset($blobid))
$html=qa_get_avatar_blob_html($blobid, $width, $height, $size, $padding);
elseif ( (qa_opt('avatar_allow_gravatar')||qa_opt('avatar_allow_upload')) && qa_opt('avatar_default_show') && strlen(qa_opt('avatar_default_blobid')) )
$html=qa_get_avatar_blob_html(qa_opt('avatar_default_blobid'), qa_opt('avatar_default_width'), qa_opt('avatar_default_height'), $size, $padding);
else
$html=null;

return (isset($html) && strlen($handle)) ? ('<a href="'.($absolute ? qa_path_absolute('user/'.$handle) : qa_path_html('user/'.$handle)).'" class="qa-avatar-link" title="'.$handle.'">'.$html.'</a>') : $html;
}

qa-include/qa-app-format.php:

function qa_get_avatar_blob_html($blobid, $width, $height, $size, $padding=false, $absolute=true)
/*
Return the <img...> HTML to display avatar $blobid whose stored size is $width and $height
Constrain the image to $size (width AND height) and pad it to that size if $padding is true
*** Add $absolute parameter (If you use avatar in HTML emails, you should it true) ***
*/
{
    if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }

    require_once QA_INCLUDE_DIR.'qa-util-image.php';

    if (strlen($blobid) && ($size>0)) {
        qa_image_constrain($width, $height, $size);

        $html='<img src="'.qa_path_html('image', array('qa_blobid' => $blobid, 'qa_size' => $size), ($absolute ? qa_opt('site_url') : null), QA_URL_FORMAT_PARAMS).
            '"'.(($width && $height) ? (' width="'.$width.'" height="'.$height.'"') : '').' class="qa-avatar-image" alt=""/>';
            
        if ($padding && $width && $height) {
            $padleft=floor(($size-$width)/2);
            $padright=$size-$width-$padleft;
            $padtop=floor(($size-$height)/2);
            $padbottom=$size-$height-$padtop;
            $html='<span class="qa-inline-block" style="padding:'.$padtop.'px '.$padright.'px '.$padbottom.'px '.$padleft.'px;">'.$html.'</span>';
        }

        return $html;

    } else
        return null;
}

image

by webmaster asked Nov 14, 2015 in Core

Please log in or register to add a comment.

Please log in or register to answer this question.

Welcome to PowerQA. PowerQA is a new discussion software (not OSS). Here is a community for PowerQA developers. Current stable version is V1.9.4. It is enhanced day by day.

Statistics

  • 338 questions
  • 276 answers
  • 480 comments
  • 100 users

Post types

...