TinyPortal

Development => Support => Topic started by: [chrisB] on January 03, 2023, 09:05:11 PM

Title: A few questions
Post by: [chrisB] on January 03, 2023, 09:05:11 PM
Link to my forum: https://poetryartonline.com/forum/
SMF version: SMF ver. 2.1.3
TP version: TP ver. 2.2.2
Default Forum Language: English
Theme name and version: Modified Curve2
Browser Name and Version: Chrome/Version 108.0.5359.125 (Official Build) (64-bit)

Is it possible to add CSS to show the roundframe style on the frontpage only?
(https://i.imgur.com/rOhsHlQ.png)

How to redirect after login: Can it be setup to redirect to whatever page you signed in on.

i.e

forum > forum
frontpage > frontpage
topic > topic

Rather than one default location.

The user block:

Could someone code the block to look similar to this?
(https://i.imgur.com/hTq8Rau.png)

With the title changing based on if a user is signed in or not.

I've searched for the answers to my questions, I haven't found anything relating to them.
Title: Re: A few questions
Post by: @rjen on January 03, 2023, 09:47:57 PM
Looks like your forum has some issues with the file paths: the css is not showing...

As for your questions..

Is it possible to add CSS to show the roundframe style on the frontpage only?

No, that is not possible: roundframe option is for the panel, where ever it shows...

How to redirect after login: Can it be setup to redirect to whatever page you signed in on.

Again, no: there is no such option available

The user block:
Could someone code the block to look similar to this?

Probably, but will need to check it.

If you want to make changes to the block layout you may want to check the TPsubs.template.php file,

this bit...

// blocktype 1: User
function TPortal_userbox()
{
global $context, $settings, $scripturl, $txt, $user_info;

$bullet = '<img src="'.$settings['tp_images_url'].'/TPdivider.png" alt="" style="margin:0 4px 0 0;" />';
$bullet2 = '<img src="'.$settings['tp_images_url'].'/TPdivider2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet3 = '<img src="'.$settings['tp_images_url'].'/TPdivider3.png" alt="" style="margin:0 4px 0 0;" />';
$bullet4 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet5 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';

echo'
<div class="tp_userblocknew">';


// If the user is logged in, display stuff like their name, new messages, etc.

if ($context['user']['is_logged'])
{

if (!empty($context['user']['avatar']) &&  isset($context['TPortal']['userbox']['avatar']))
echo '
<span class="tpavatar">', $context['user']['avatar']['image'], '</span>';
echo '
<strong><a class="subject"  href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">', $context['user']['name'], '</a></strong>
<ul class="reset">';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
{
echo '
<li><a href="', $scripturl, '?action=pm">' .$bullet.$txt['tp-pm'].' ',  $context['user']['messages'], '</a></li>';
if($context['user']['unread_messages'] > 0)
echo '
<li style="font-weight: bold; "><a href="', $scripturl, '?action=pm">' . $bullet. $txt['tp-pm2'].' ',$context['user']['unread_messages'] , '</a></li>';
}
// Are there any members waiting for approval?
if (!empty($context['unapproved_members']))
echo '
<li><a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve;' . $context['session_var'] . '=' . $context['session_id'].'">'. $bullet. $txt['tp_unapproved_members'].' '. $context['unapproved_members']  . '</a></li>';
// Are there any moderation reports?
if(!TP_SMF21)
{
if (!empty($context['open_mod_reports']) && $context['show_open_reports'])
echo '
<li><a href="', $scripturl, '?action=moderate;area=reports">'.$bullet.$txt['tp_modreports'].' ' . $context['open_mod_reports']. '</a></li>';
}
else {
if (!empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1' && !empty($context['open_mod_reports']))
echo '
<li><a href="', $scripturl, '?action=moderate;area=reports">'.$bullet.$txt['tp_modreports'].' ' . $context['open_mod_reports']. '</a></li>';
}
if(isset($context['TPortal']['userbox']['unread']))
echo '
<li><hr><a href="', $scripturl, '?action=unread">' .$bullet.$txt['tp-unread'].'</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">'.$bullet.$txt['tp-replies'].'</a></li>
<li><a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';area=showposts">'.$bullet.$txt['tp-showownposts'].'</a></li>
<li><a href="', $scripturl, '?action=tportal;sa=showcomments">'.$bullet.$txt['tp-showcomments'].'</a><hr></li>
';

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<li>' .$bullet2.$txt['tp_maintenace']. '</li>';
// Show the total time logged in?
if (!empty($context['user']['total_time_logged_in']) && isset($context['TPortal']['userbox']['logged']))
{
echo '
<li>' .$bullet2.$txt['tp-loggedintime'] . '</li>
<li>'.$bullet2.$context['user']['total_time_logged_in']['days'] . $txt['tp-acronymdays']. $context['user']['total_time_logged_in']['hours'] . $txt['tp-acronymhours']. $context['user']['total_time_logged_in']['minutes'] .$txt['tp-acronymminutes'].'</li>';
}
if (isset($context['TPortal']['userbox']['time']))
echo '
<li>' . $bullet2.$context['current_time'].' <hr></li>';

// admin parts etc.
         if(!isset($context['TPortal']['can_submit_article']))
            $context['TPortal']['can_submit_article']=0;

// can we submit an article?
        if(allowedTo('tp_submithtml'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_html">' . $bullet3.$txt['tp-submitarticle']. '</a></li>';
        if(allowedTo('tp_submitbbc'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_bbc">' . $bullet3.$txt['tp-submitarticlebbc']. '</a></li>';

if(allowedTo('tp_editownarticle'))
echo '
<li><a href="', $scripturl, '?action=tportal;sa=myarticles">' . $bullet3.$txt['tp-myarticles']. '</a></li>';

// upload a file?
        if(allowedTo('tp_dlupload') || allowedTo('tp_dlmanager'))
             echo '
<li><a href="', $scripturl, '?action=tportal;sa=download;dl=upload">' . $bullet3.$txt['permissionname_tp_dlupload']. '</a></li>';

// tpadmin checks
if (allowedTo('tp_settings'))
echo '
<li><hr><a href="' . $scripturl . '?action=tpadmin;sa=settings">' . $bullet4.$txt['permissionname_tp_settings'] . '</a></li>';
if (allowedTo('tp_blocks'))
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=blocks">' . $bullet4.$txt['permissionname_tp_blocks'] . '</a></li>';
if (allowedTo('tp_articles'))
{
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=articles">' . $bullet4.$txt['permissionname_tp_articles'] . '</a></li>';
// any submissions?
if($context['TPortal']['submitcheck']['articles']>0)
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=submission"><b>' . $bullet4 . ' ' .$txt['tp-articlessubmitted'] . ' ' .$context['TPortal']['submitcheck']['articles'] . '</b></a></li>';
}
if (allowedTo('tp_dlmanager'))
{
echo '
<li><a href="' . $scripturl . '?action=tportal;sa=download;dl=admin">' . $bullet5.$txt['permissionname_tp_dlmanager'] . '</a></li>';
// any submissions?
if($context['TPortal']['submitcheck']['uploads']>0)
echo '
<li><a href="' . $scripturl . '?action=tportal;sa=download;dl=adminsubmission"><b>' . $bullet5.$context['TPortal']['submitcheck']['uploads'] . ' ' .$txt['tp-dluploaded'] . '</b></a></li>';
}

echo '
</ul>';
}
// Otherwise they're a guest - so politely ask them to register or login.
else  {
if(TP_SMF21) {
echo '<div style="line-height: 1.4em;">', sprintf($txt[$context['can_register'] ? 'tp-welcome_guest_register' : 'tp-welcome_guest'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '<br><br>', $context['current_time'], '</div>';
}
else {
echo '<div style="line-height: 1.4em;">', sprintf($txt['welcome_guest'], $txt['guest_title']), '<br><br>', $context['current_time'], '</div>';
}
    echo '
        <form style="margin-top: 5px;" action="', $scripturl, '?action=login2" method="post" >
            <input type="text" class="input_text" name="user" size="10" style="max-width: 45%!important;"/> <input type="password" class="input_password" name="passwrd" size="10" style="max-width: 45%!important;"/><br>
            <select name="cookielength" style="max-width: 45%!important;">
                <option value="-1" selected="selected">', $txt['forever'], '</option>
                <option value="60">', $txt['one_hour'], '</option>
                <option value="1440">', $txt['one_day'], '</option>
                <option value="10080">', $txt['one_week'], '</option>
                <option value="302400">', $txt['one_month'], '</option>
            </select>
            <input type="submit" class="button_submit" value="', $txt['login'], '" />
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />';
if (TP_SMF21) {
echo '
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">';
}
echo '
        </form>
        <div style="line-height: 1.4em;" class="middletext">', $txt['tp-quick_login_dec'], '</div>';
}
echo '
</div>';
}
Title: Re: A few questions
Post by: [chrisB] on January 03, 2023, 10:36:34 PM
I've got a few weird issues going on with my forum right now. I really need to seek someone who can fix it for me as I have no idea what's going on, but I appreciate the heads-up. You have a nice site BTW.

QuoteNo, that is not possible: roundframe option is for the panel, where ever it shows...
Thanks, there's probably some trick to doing it. I'll speak to a skinner. :)

I'll look into the code you mentioned, it should be fairly basic to edit it to show how I'd like. Thanks for taking the time to answer and help.
Title: Re: A few questions
Post by: @rjen on January 04, 2023, 02:59:24 PM
Quote from: [chrisB] on January 03, 2023, 09:05:11 PM

The user block:

Could someone code the block to look similar to this?
(https://i.imgur.com/hTq8Rau.png)


Just to get you started:
create a php block and paste below code in the block..


global $context, $settings, $scripturl, $txt, $user_info;

$bullet = '<img src="'.$settings['tp_images_url'].'/TPdivider.png" alt="" style="margin:0 4px 0 0;" />';
$bullet2 = '<img src="'.$settings['tp_images_url'].'/TPdivider2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet3 = '<img src="'.$settings['tp_images_url'].'/TPdivider3.png" alt="" style="margin:0 4px 0 0;" />';
$bullet4 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet5 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';

// Text strings
$txt['tp-blockinbox'] = 'Inbox:';
$txt['tp-blockposts'] = 'Posts';


echo'

<style>
.tpavatar img {
    width: 80px;
box-shadow: 3px 1px 6px rgb(0 0 0 / 30%);
border-radius: 6px;
}
.floatdiv {
width:50%;
display:inline-block;
float: left;
text-align: center;
}
</style>

<div class="tp_userblocknew">';
// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']) &&  isset($context['TPortal']['userbox']['avatar']))
{
echo '
<span class="tpavatar">', $context['user']['avatar']['image'], '</span>';
}
echo '
      <strong><a class="subject"  href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">', $context['user']['name'], '</a></strong>
      <ul class="reset">';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
{
echo '
<li><a href="', $scripturl, '?action=pm">' .$bullet.$txt['tp-blockinbox'].' ',  $context['user']['messages'], '</a></li>';
}
echo '
<li><a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';area=showposts">'.$bullet3.$txt['tp-blockposts'].'</a></li>
<li><a href="', $scripturl, '?action=unread">' .$bullet3.$txt['tp-unread'].'</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">'.$bullet3.$txt['tp-replies'].'</a></li>
<hr>';

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<li>' .$bullet2.$txt['tp_maintenace']. '</li>';

// admin parts etc.
         if(!isset($context['TPortal']['can_submit_article']))
            $context['TPortal']['can_submit_article']=0;

// can we submit an article?
        if(allowedTo('tp_submithtml'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_html">' . $bullet2.$txt['tp-submitarticle']. '</a></li>';
        if(allowedTo('tp_submitbbc'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_bbc">' . $bullet2.$txt['tp-submitarticlebbc']. '</a></li>';

if(allowedTo('tp_editownarticle'))
echo '
<li><a href="', $scripturl, '?action=tportal;sa=myarticles">' . $bullet2.$txt['tp-myarticles']. '</a></li>';
if (allowedTo('tp_articles'))
{
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=articles">' . $bullet4.$txt['permissionname_tp_articles'] . '</a></li>';
// any submissions?
if($context['TPortal']['submitcheck']['articles']>0)
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=submission"><b>' . $bullet4 . ' ' .$txt['tp-articlessubmitted'] . ' ' .$context['TPortal']['submitcheck']['articles'] . '</b></a></li>';
}

echo '
<hr>
<div class="floatdiv"><a href="', $scripturl, '?action=logout;u='.$context['user']['id'].'"><span class="main_icons logout"></span> Log out</a></div>
<div class="floatdiv"><span class="main_icons members"></span><a href="'.$scripturl.'?action=profile;area=forumprofile;u='.$context['user']['id'].'"> Profile</a></div>';

echo '
</ul>';
}
// Otherwise they're a guest - so politely ask them to register or login.
else  {
if(TP_SMF21) {
echo '
<div style="line-height: 1.4em;">', sprintf($txt[$context['can_register'] ? 'tp-welcome_guest_register' : 'tp-welcome_guest'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '<br><br>', $context['current_time'], '</div>';
}
else {
echo '
<div style="line-height: 1.4em;">', sprintf($txt['welcome_guest'], $txt['guest_title']), '<br><br>', $context['current_time'], '</div>';
}
    echo '
        <form style="margin-top: 5px;" action="', $scripturl, '?action=login2" method="post" >
            <input type="text" class="input_text" name="user" size="10" style="max-width: 45%!important;"/> <input type="password" class="input_password" name="passwrd" size="10" style="max-width: 45%!important;"/><br>
            <select name="cookielength" style="max-width: 45%!important;">
                <option value="-1" selected="selected">', $txt['forever'], '</option>
                <option value="60">', $txt['one_hour'], '</option>
                <option value="1440">', $txt['one_day'], '</option>
                <option value="10080">', $txt['one_week'], '</option>
                <option value="302400">', $txt['one_month'], '</option>
            </select>
            <input type="submit" class="button_submit" value="', $txt['login'], '" />
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />';
if (TP_SMF21) {
echo '
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">';
}
echo '
        </form>
        <div style="line-height: 1.4em;" class="middletext">', $txt['tp-quick_login_dec'], '</div>';
}
echo '
</div>';


It will give you attached block.

not all your questions were clear to me, but you can work from here...it's a start.
Title: Re: A few questions
Post by: [chrisB] on January 04, 2023, 09:50:21 PM
Thank you, it's looking great.

Once the rest is sorted, I'll reshare it.
Title: Re: A few questions
Post by: [chrisB] on January 11, 2023, 09:05:08 PM
Quote from: @rjen on January 04, 2023, 02:59:24 PM
Just to get you started:
create a php block and paste below code in the block..


global $context, $settings, $scripturl, $txt, $user_info;

$bullet = '<img src="'.$settings['tp_images_url'].'/TPdivider.png" alt="" style="margin:0 4px 0 0;" />';
$bullet2 = '<img src="'.$settings['tp_images_url'].'/TPdivider2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet3 = '<img src="'.$settings['tp_images_url'].'/TPdivider3.png" alt="" style="margin:0 4px 0 0;" />';
$bullet4 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet5 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';

// Text strings
$txt['tp-blockinbox'] = 'Inbox:';
$txt['tp-blockposts'] = 'Posts';


echo'

<style>
.tpavatar img {
    width: 80px;
box-shadow: 3px 1px 6px rgb(0 0 0 / 30%);
border-radius: 6px;
}
.floatdiv {
width:50%;
display:inline-block;
float: left;
text-align: center;
}
</style>

<div class="tp_userblocknew">';
// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']) &&  isset($context['TPortal']['userbox']['avatar']))
{
echo '
<span class="tpavatar">', $context['user']['avatar']['image'], '</span>';
}
echo '
      <strong><a class="subject"  href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">', $context['user']['name'], '</a></strong>
      <ul class="reset">';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
{
echo '
<li><a href="', $scripturl, '?action=pm">' .$bullet.$txt['tp-blockinbox'].' ',  $context['user']['messages'], '</a></li>';
}
echo '
<li><a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';area=showposts">'.$bullet3.$txt['tp-blockposts'].'</a></li>
<li><a href="', $scripturl, '?action=unread">' .$bullet3.$txt['tp-unread'].'</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">'.$bullet3.$txt['tp-replies'].'</a></li>
<hr>';

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<li>' .$bullet2.$txt['tp_maintenace']. '</li>';

// admin parts etc.
         if(!isset($context['TPortal']['can_submit_article']))
            $context['TPortal']['can_submit_article']=0;

// can we submit an article?
        if(allowedTo('tp_submithtml'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_html">' . $bullet2.$txt['tp-submitarticle']. '</a></li>';
        if(allowedTo('tp_submitbbc'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_bbc">' . $bullet2.$txt['tp-submitarticlebbc']. '</a></li>';

if(allowedTo('tp_editownarticle'))
echo '
<li><a href="', $scripturl, '?action=tportal;sa=myarticles">' . $bullet2.$txt['tp-myarticles']. '</a></li>';
if (allowedTo('tp_articles'))
{
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=articles">' . $bullet4.$txt['permissionname_tp_articles'] . '</a></li>';
// any submissions?
if($context['TPortal']['submitcheck']['articles']>0)
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=submission"><b>' . $bullet4 . ' ' .$txt['tp-articlessubmitted'] . ' ' .$context['TPortal']['submitcheck']['articles'] . '</b></a></li>';
}

echo '
<hr>
<div class="floatdiv"><a href="', $scripturl, '?action=logout;u='.$context['user']['id'].'"><span class="main_icons logout"></span> Log out</a></div>
<div class="floatdiv"><span class="main_icons members"></span><a href="'.$scripturl.'?action=profile;area=forumprofile;u='.$context['user']['id'].'"> Profile</a></div>';

echo '
</ul>';
}
// Otherwise they're a guest - so politely ask them to register or login.
else  {
if(TP_SMF21) {
echo '
<div style="line-height: 1.4em;">', sprintf($txt[$context['can_register'] ? 'tp-welcome_guest_register' : 'tp-welcome_guest'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '<br><br>', $context['current_time'], '</div>';
}
else {
echo '
<div style="line-height: 1.4em;">', sprintf($txt['welcome_guest'], $txt['guest_title']), '<br><br>', $context['current_time'], '</div>';
}
    echo '
        <form style="margin-top: 5px;" action="', $scripturl, '?action=login2" method="post" >
            <input type="text" class="input_text" name="user" size="10" style="max-width: 45%!important;"/> <input type="password" class="input_password" name="passwrd" size="10" style="max-width: 45%!important;"/><br>
            <select name="cookielength" style="max-width: 45%!important;">
                <option value="-1" selected="selected">', $txt['forever'], '</option>
                <option value="60">', $txt['one_hour'], '</option>
                <option value="1440">', $txt['one_day'], '</option>
                <option value="10080">', $txt['one_week'], '</option>
                <option value="302400">', $txt['one_month'], '</option>
            </select>
            <input type="submit" class="button_submit" value="', $txt['login'], '" />
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />';
if (TP_SMF21) {
echo '
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">';
}
echo '
        </form>
        <div style="line-height: 1.4em;" class="middletext">', $txt['tp-quick_login_dec'], '</div>';
}
echo '
</div>';


It will give you attached block.

not all your questions were clear to me, but you can work from here...it's a start.

If I change the size of the avatar inside the block, it changes the size inside the recent topics. Is it possible to trigger only the user block?

I use the <style><\style> CSS within it, but as I say it interferes.
Title: Re: A few questions
Post by: tino on January 11, 2023, 09:08:58 PM
Target .tp_userclassnew.tpavatar that should only change the one in the block
Title: Re: A few questions
Post by: @rjen on January 11, 2023, 09:11:36 PM
Yep, use a different class...
Title: Re: A few questions
Post by: [chrisB] on January 11, 2023, 10:06:20 PM
Tino, rjen thanks!

I've tried:
.tp_userclassnew.tpavatar img {
    width: 80px;
]


and

.tp_userclassnew.tpavatar {
    width: 80px;
]


It doesn't seem to work, could it be due to me having the code in a custom code block?

I'm not sure how to locate the classes.
Title: Re: A few questions
Post by: tino on January 11, 2023, 10:25:21 PM
Is the other code overwriting it due to inheritance?

If not as @rjen said, call the span class something different. i.e tpavataruserblock
Title: Re: A few questions
Post by: @rjen on January 12, 2023, 05:45:27 PM
check this code. This will leave the other avatars alone and it will also respect the settings from the avatar integration mod.

If you check what I changed you'll get a better understanding how to do this yourself.

global $context, $settings, $scripturl, $txt, $user_info;

$bullet = '<img src="'.$settings['tp_images_url'].'/TPdivider.png" alt="" style="margin:0 4px 0 0;" />';
$bullet2 = '<img src="'.$settings['tp_images_url'].'/TPdivider2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet3 = '<img src="'.$settings['tp_images_url'].'/TPdivider3.png" alt="" style="margin:0 4px 0 0;" />';
$bullet4 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';
$bullet5 = '<img src="'.$settings['tp_images_url'].'/TPmodule2.png" alt="" style="margin:0 4px 0 0;" />';

// Text strings
$txt['tp-blockinbox'] = 'Inbox:';
$txt['tp-blockposts'] = 'Posts';


echo'

<style>
.tp_userblocknew2 .avatar {
   height: auto;
    width: 80px;
}
.floatdiv {
width:50%;
display:inline-block;
float: left;
text-align: center;
}
</style>

<div class="tp_userblocknew2">';
// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']) &&  isset($context['TPortal']['userbox']['avatar']))
{
echo '
<span class="tpavatar">', $context['user']['avatar']['image'], '</span>';
}
echo '
      <strong><a class="subject"  href="'.$scripturl.'?action=profile;u='.$context['user']['id'].'">', $context['user']['name'], '</a></strong>
      <ul class="reset">';

// Only tell them about their messages if they can read their messages!
if ($context['allow_pm'])
{
echo '
<li><a href="', $scripturl, '?action=pm">' .$bullet.$txt['tp-blockinbox'].' ',  $context['user']['messages'], '</a></li>';
}
echo '
<li><a href="', $scripturl, '?action=profile;u='.$context['user']['id'].';area=showposts">'.$bullet3.$txt['tp-blockposts'].'</a></li>
<li><a href="', $scripturl, '?action=unread">' .$bullet3.$txt['tp-unread'].'</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">'.$bullet3.$txt['tp-replies'].'</a></li>
<hr>';

// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<li>' .$bullet2.$txt['tp_maintenace']. '</li>';

// admin parts etc.
         if(!isset($context['TPortal']['can_submit_article']))
            $context['TPortal']['can_submit_article']=0;

// can we submit an article?
        if(allowedTo('tp_submithtml'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_html">' . $bullet2.$txt['tp-submitarticle']. '</a></li>';
        if(allowedTo('tp_submitbbc'))
echo '
<li><a href="', $scripturl, '?action=' . (allowedTo('tp_articles') ? 'tpadmin' : 'tportal') . ';sa=addarticle_bbc">' . $bullet2.$txt['tp-submitarticlebbc']. '</a></li>';

if(allowedTo('tp_editownarticle'))
echo '
<li><a href="', $scripturl, '?action=tportal;sa=myarticles">' . $bullet2.$txt['tp-myarticles']. '</a></li>';
if (allowedTo('tp_articles'))
{
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=articles">' . $bullet4.$txt['permissionname_tp_articles'] . '</a></li>';
// any submissions?
if($context['TPortal']['submitcheck']['articles']>0)
echo '
<li><a href="' . $scripturl . '?action=tpadmin;sa=submission"><b>' . $bullet4 . ' ' .$txt['tp-articlessubmitted'] . ' ' .$context['TPortal']['submitcheck']['articles'] . '</b></a></li>';
}

echo '
<hr>
<div class="floatdiv"><span class="main_icons members"></span><a href="'.$scripturl.'?action=profile;area=forumprofile;u='.$context['user']['id'].'"> Profile</a></div>
<div class="floatdiv"><a href="', $scripturl, '?action=logout;u='.$context['user']['id'].'"><span class="main_icons logout"></span> Log out</a></div>';

echo '
</ul>';
}
// Otherwise they're a guest - so politely ask them to register or login.
else  {
if(TP_SMF21) {
echo '
<div style="line-height: 1.4em;">', sprintf($txt[$context['can_register'] ? 'tp-welcome_guest_register' : 'tp-welcome_guest'], $context['forum_name_html_safe'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=signup'), '<br><br>', $context['current_time'], '</div>';
}
else {
echo '
<div style="line-height: 1.4em;">', sprintf($txt['welcome_guest'], $txt['guest_title']), '<br><br>', $context['current_time'], '</div>';
}
    echo '
        <form style="margin-top: 5px;" action="', $scripturl, '?action=login2" method="post" >
            <input type="text" class="input_text" name="user" size="10" style="max-width: 45%!important;"/> <input type="password" class="input_password" name="passwrd" size="10" style="max-width: 45%!important;"/><br>
            <select name="cookielength" style="max-width: 45%!important;">
                <option value="-1" selected="selected">', $txt['forever'], '</option>
                <option value="60">', $txt['one_hour'], '</option>
                <option value="1440">', $txt['one_day'], '</option>
                <option value="10080">', $txt['one_week'], '</option>
                <option value="302400">', $txt['one_month'], '</option>
            </select>
            <input type="submit" class="button_submit" value="', $txt['login'], '" />
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />';
if (TP_SMF21) {
echo '
<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">';
}
echo '
        </form>
        <div style="line-height: 1.4em;" class="middletext">', $txt['tp-quick_login_dec'], '</div>';
}
echo '
</div>';
Title: Re: A few questions
Post by: [chrisB] on January 13, 2023, 12:16:21 AM
rjen you're awesome! Thank you very much.
Title: Re: A few questions
Post by: [chrisB] on January 21, 2023, 09:40:15 PM
I am using this block to show content from two main sections of my forum on the home page of my site. I would like to include the forum location of where the posts are. Could someone tell me how to make this edit please?

Post Title - By
Forum Location
Time of Post

// blocktype 12: Recent Topics
function TPortal_recentbox()
{
   global $scripturl, $context, $settings, $txt, $modSettings, $user_info;

   // if no guest access to forum, then no recent topics
   if($modSettings['allow_guestAccess'] == '0' && $user_info['is_guest']) {
      echo '' .$txt['tp-noguest_access'] .'';
   }
   else {
   // is it a number?
   if(is_numeric($context['TPortal']['recentlength']))
      $recentlength = $context['TPortal']['recentlength'];
   else
      $recentlength = '25';
   // exclude boards
   if (isset($context['TPortal']['recentboards']) && $context['TPortal']['boardmode'] == 0)
      $exclude_boards = $context['TPortal']['recentboards'];
   else {
   // leave out the recycle board, if any
      if(isset($modSettings['recycle_board']) && $modSettings['recycle_enable'] = 1 )
      $bb = array($modSettings['recycle_board']);
      $exclude_boards = $bb;
   }

   // include boards
   if (isset($context['TPortal']['recentboards']) && !$context['TPortal']['boardmode'] == 0)
      $include_boards = $context['TPortal']['recentboards'];
   else
      $include_boards = null;

   $what = ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'] , $exclude_boards,  $include_boards, $output_method = 'array');
   if($context['TPortal']['useavatar'] == 0)
   {
      // Output the topics
      echo '
      <ul class="recent_topics" style="' , isset($context['TPortal']['recentboxscroll']) && $context['TPortal']['recentboxscroll'] == 1 ? 'overflow: auto; height: 20ex;' : '' , 'margin: 0; padding: 0;">';
      $coun = 1;
      foreach($what as $wi => $w)
      {
         $tpshortsubject = $w['subject'];
         $w['readmore'] = '';
         if(TPUtil::shortenString($tpshortsubject, $recentlength)) {
            $w['readmore'] = '...';
         }
         echo '
         <li' , $coun<count($what) ? '' : ' style="border: none; margin-bottom: 0;padding-bottom: 0;"'  , '>';
         if ((TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow" class="new_posts" style="margin:0px;">' . $txt['new'] . '</a> ';
         echo '
            <a href="' . $w['href'] . '" title="' . $w['subject'] . '">'. $tpshortsubject .''. $w['readmore'] .'</a>
             ', $txt['by'], ' <b>', $w['poster']['link'],'</b> ';
         if (!(TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>';
         echo '<br><span class="smalltext">['.$w['time'].']</span>
         </li>';
         $coun++;
      }
      echo '
      </ul>';
   }
   else
   {
      $member_ids = array();
      foreach($what as $wi => $w)
      {
         $member_ids[] = $w['poster']['id'];
      }

      if(!empty($member_ids))
         $avatars = progetAvatars($member_ids);
      else
         $avatars = array();

      // Output the topics
      $coun = 1;
      echo '
      <ul class="recent_topics" style="' , isset($context['TPortal']['recentboxscroll']) && $context['TPortal']['recentboxscroll']==1 ? 'overflow: auto; height: 20ex;' : '' , 'margin: 0; padding: 0;">';

      foreach($what as $wi => $w)
      {
         $tpshortsubject = $w['subject'];
         $w['readmore'] = '';
         if(TPUtil::shortenString($tpshortsubject, $recentlength)) {
            $w['readmore'] = '...';
         }
         echo '
         <li' , $coun<count($what) ? '' : ' style="border: none; margin-bottom: 0;padding-bottom: 0;"'  , '>';
         if ((TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow" class="new_posts" style="margin:0px;">' . $txt['new'] . '</a> ';
         echo '
               <span class="tpavatar"><a href="' . $scripturl. '?action=profile;u=' . $w['poster']['id'] . '">' , empty($avatars[$w['poster']['id']]) ? '<img src="' . $settings['tp_images_url'] . '/TPguest.png" alt="" />' : $avatars[$w['poster']['id']] , '</a></span><a href="'.$w['href'].'" title="' . $w['subject'] . '">'. $tpshortsubject .''. $w['readmore'] .'</a>
             ', $txt['by'], ' <b>', $w['poster']['link'],'</b> ';
         if (!(TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>';
         echo '<br><span class="smalltext">['.$w['time'].']</span>
         </li>';
         $coun++;
      }
      echo '
      </ul>';
      }
   }
}
Title: Re: A few questions
Post by: @rjen on January 21, 2023, 09:44:17 PM
What do you mean with forum location?

The board?
Title: Re: A few questions
Post by: [chrisB] on January 21, 2023, 10:07:06 PM
Yes, rjen.
Title: Re: A few questions
Post by: @rjen on January 22, 2023, 04:08:28 PM
Quote from: [chrisB] on January 21, 2023, 09:40:15 PM
I am using this block to show content from two main sections of my forum on the home page of my site. I would like to include the forum location of where the posts are. Could someone tell me how to make this edit please?

Post Title - By
Forum Location
Time of Post

// blocktype 12: Recent Topics
function TPortal_recentbox()
{
   global $scripturl, $context, $settings, $txt, $modSettings, $user_info;

   // if no guest access to forum, then no recent topics
   if($modSettings['allow_guestAccess'] == '0' && $user_info['is_guest']) {
      echo '' .$txt['tp-noguest_access'] .'';
   }
   else {
   // is it a number?
   if(is_numeric($context['TPortal']['recentlength']))
      $recentlength = $context['TPortal']['recentlength'];
   else
      $recentlength = '25';
   // exclude boards
   if (isset($context['TPortal']['recentboards']) && $context['TPortal']['boardmode'] == 0)
      $exclude_boards = $context['TPortal']['recentboards'];
   else {
   // leave out the recycle board, if any
      if(isset($modSettings['recycle_board']) && $modSettings['recycle_enable'] = 1 )
      $bb = array($modSettings['recycle_board']);
      $exclude_boards = $bb;
   }

   // include boards
   if (isset($context['TPortal']['recentboards']) && !$context['TPortal']['boardmode'] == 0)
      $include_boards = $context['TPortal']['recentboards'];
   else
      $include_boards = null;

   $what = ssi_recentTopics($num_recent = $context['TPortal']['recentboxnum'] , $exclude_boards,  $include_boards, $output_method = 'array');
   if($context['TPortal']['useavatar'] == 0)
   {
      // Output the topics
      echo '
      <ul class="recent_topics" style="' , isset($context['TPortal']['recentboxscroll']) && $context['TPortal']['recentboxscroll'] == 1 ? 'overflow: auto; height: 20ex;' : '' , 'margin: 0; padding: 0;">';
      $coun = 1;
      foreach($what as $wi => $w)
      {
         $tpshortsubject = $w['subject'];
         $w['readmore'] = '';
         if(TPUtil::shortenString($tpshortsubject, $recentlength)) {
            $w['readmore'] = '...';
         }
         echo '
         <li' , $coun<count($what) ? '' : ' style="border: none; margin-bottom: 0;padding-bottom: 0;"'  , '>';
         if ((TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow" class="new_posts" style="margin:0px;">' . $txt['new'] . '</a> ';
         echo '
            <a href="' . $w['href'] . '" title="' . $w['subject'] . '">'. $tpshortsubject .''. $w['readmore'] .'</a>
             ', $txt['by'], ' <b>', $w['poster']['link'],'</b> ';
         if (!(TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>';
         echo '<br><span class="smalltext">['.$w['time'].']</span>
         </li>';
         $coun++;
      }
      echo '
      </ul>';
   }
   else
   {
      $member_ids = array();
      foreach($what as $wi => $w)
      {
         $member_ids[] = $w['poster']['id'];
      }

      if(!empty($member_ids))
         $avatars = progetAvatars($member_ids);
      else
         $avatars = array();

      // Output the topics
      $coun = 1;
      echo '
      <ul class="recent_topics" style="' , isset($context['TPortal']['recentboxscroll']) && $context['TPortal']['recentboxscroll']==1 ? 'overflow: auto; height: 20ex;' : '' , 'margin: 0; padding: 0;">';

      foreach($what as $wi => $w)
      {
         $tpshortsubject = $w['subject'];
         $w['readmore'] = '';
         if(TPUtil::shortenString($tpshortsubject, $recentlength)) {
            $w['readmore'] = '...';
         }
         echo '
         <li' , $coun<count($what) ? '' : ' style="border: none; margin-bottom: 0;padding-bottom: 0;"'  , '>';
         if ((TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow" class="new_posts" style="margin:0px;">' . $txt['new'] . '</a> ';
         echo '
               <span class="tpavatar"><a href="' . $scripturl. '?action=profile;u=' . $w['poster']['id'] . '">' , empty($avatars[$w['poster']['id']]) ? '<img src="' . $settings['tp_images_url'] . '/TPguest.png" alt="" />' : $avatars[$w['poster']['id']] , '</a></span><a href="'.$w['href'].'" title="' . $w['subject'] . '">'. $tpshortsubject .''. $w['readmore'] .'</a>
             ', $txt['by'], ' <b>', $w['poster']['link'],'</b> ';
         if (!(TP_SMF21) && ($w['is_new']))
            echo ' <a href="' . $scripturl . '?topic=' . $w['topic'] . '.msg' . $w['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" /></a>';
         echo '<br><span class="smalltext">['.$w['time'].']</span>
         </li>';
         $coun++;
      }
      echo '
      </ul>';
      }
   }
}


Maybe it is just me, but when you suggested that you are using this code I expected you to post the actual working code you are using in a php block.

In trying to help you, I copied the exact code you provided to a php block on my test site, just to find that this code is non functional. This leads me to believe that you just copied php code from TPsubs.template.php?

I am sorry, but to help you I need you to put as much effort in the question as you expect us to put into the answer.
Please be as complete as possible in your question and do not expect us to figure it out..

Please be clear: do you have a functioning PHP block code?
If yes, please provide the functioning code, and I can check it

If no, what exactly do you have that you want to adjust?
Please describe how I can reproducte the situation you wish to improve...
Title: Re: A few questions
Post by: [chrisB] on January 22, 2023, 04:57:42 PM
You're correct about where I found the code; I took it from the template.

It's also fair what you wrote; I forgot what was mentioned regarding blocks previously. In previous things I have used the code is exactly the same, so you can copy, and it works [you may have to fill in parts such as amounts etc. I need to remember that Tiny Portal is different. I apologise rjen.

Title: Re: A few questions
Post by: @rjen on January 22, 2023, 05:02:17 PM
Thanks, since I figured as much I had look already. Next time please specify the block type you are using.

You are in luck that the SMF SSI_recenttopics function also delivers the board.

In TPsubs.template.php code

find

echo '<br><span class="smalltext">['.$w['time'].']</span>


and replace by

echo '<br>'. $txt['tp-fromcategory'].'<a href="'.$w['board']['href'].'" title="'.$w['board']['name'].'">'.$w['board']['name'].'</a>
<br><span class="smalltext">['.$w['time'].']</span>


It is in the code twice, make sure to fix both
Title: Re: A few questions
Post by: [chrisB] on January 22, 2023, 05:10:50 PM
QuoteThanks, since I figured as much I had look already. Next time please specify the block type you are using.
Noted. 👍🏻

Thank you rjen.
Title: Re: A few questions
Post by: [chrisB] on January 22, 2023, 06:55:42 PM
Block Type: Code PHP

Can a limit of articles be added to this block?

echo ' <div style="float:left;padding-right: 5px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></div><strong>Articles</strong></br>' ;
echo ' <hr>' ;

// Configuration
// Specify your categories, comma separated if more than one category.
$categories = array(5,2);

// End Config

global $scripturl, $smcFunc;

$request = $smcFunc['db_query']('', '
     SELECT shortname, id, subject, parse
     FROM {db_prefix}tp_articles
     WHERE category IN ({array_int:cats})
          AND approved = {int:approved}
     ORDER BY parse ASC',
     array('cats' => $categories,
          'approved' => 1,
     )
);
echo '
<ul style="list-style-type:disc; margin: 0pt; padding: 0pt 15px;">
';
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['shortname']))
{
     echo '<li><a href="', $scripturl, '?page=', $row['shortname'], '">', $row['subject'], '</a></li>';
}
else
{
     echo '<li><a href="', $scripturl, '?page=', $row['id'], '">', $row['subject'], '</a></li>';
}
}
echo '</ul>';
$smcFunc['db_free_result']($request);


I've done basic tweaks from the source, such as removing empty space and adding the font awesome icon instead of the large article image.

What I would like to do is now limit the amount of articles the block shows to 10.
Title: Re: A few questions
Post by: @rjen on January 22, 2023, 07:13:27 PM
Add a LIMIT is 10 to the query
Title: Re: A few questions
Post by: [chrisB] on January 22, 2023, 07:31:03 PM
Quote from: @rjen on January 22, 2023, 07:13:27 PM
Add a LIMIT is 10 to the query

echo ' <div style="float:left;padding-right: 5px;"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></div><strong>Articles</strong></br>' ;
echo ' <hr>' ;

// Configuration
// Specify your categories, comma separated if more than one category.
$categories = array(5,2);
$limit = 2;

// End Config

global $scripturl, $smcFunc;

$request = $smcFunc['db_query']('', '
     SELECT shortname, id, subject, parse
     FROM {db_prefix}tp_articles
     WHERE category IN ({array_int:cats})
          AND approved = {int:approved}
     ORDER BY parse ASC',
     array('cats' => $categories,
          'approved' => 1,
     )
);
echo '
<ul style="list-style-type:disc; margin: 0pt; padding: 0pt 15px;">
';
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!empty($row['shortname']))
{
     echo '<li><a href="', $scripturl, '?page=', $row['shortname'], '">', $row['subject'], '</a></li>';
}
else
{
     echo '<li><a href="', $scripturl, '?page=', $row['id'], '">', $row['subject'], '</a></li>';
}
}
echo '</ul>';
$smcFunc['db_free_result']($request);


I've tried this, but I'm doing something wrong.
Title: Re: A few questions
Post by: @rjen on January 22, 2023, 07:52:00 PM
You declared a variable, but you are not using it in the query...

add here


     ORDER BY parse ASC
     LIMIT 10',





Title: Re: A few questions
Post by: [chrisB] on January 22, 2023, 08:12:11 PM
Ah, thanks.

I've tried adding the LIMIT 10', - the block seems to break.
$request = $smcFunc['db_query']('', '
     SELECT shortname, id, subject, parse
     FROM {db_prefix}tp_articles
     WHERE category IN ({array_int:cats})
          AND approved = {int:approved}
     ORDER BY parse ASC',
     LIMIT 10',
     array('cats' => $categories,
          'approved' => 1,
     )


(https://i.imgur.com/Ec5kSNJ.png)

Also, would ORDER BY parse DESC', make the newest articles show first?
Title: Re: A few questions
Post by: @rjen on January 22, 2023, 08:26:20 PM
No, parse is the sort field

If you want the newest check for the date field.. check the tp_article tables for the correct field name
Title: Re: A few questions
Post by: [chrisB] on January 27, 2023, 09:24:25 PM
Guest blocks are visible to admins right?

Can the core code be altered, so that this behaviour is changed so that guest viewable blocks are not shown to admins?
Title: Re: A few questions
Post by: @rjen on January 27, 2023, 09:26:03 PM
There is a setting : admin can see all blocks... deactivate it and admins will only see blocks they haver permissions for
Title: Re: A few questions
Post by: [chrisB] on January 27, 2023, 09:30:17 PM
Thanks again, rjen.
Title: Re: A few questions
Post by: [chrisB] on January 27, 2023, 09:33:47 PM
Weird, I can no longer see blocks which I have set admins to be able to see. Only blocks that are viewable are ones in the front panel location.
Title: Re: A few questions
Post by: @rjen on January 27, 2023, 09:39:14 PM
Hmm , I recall it used to work. But tbh it has been ages since I last tried it. I think admins should keep a eye on all blocks.

Otherwise they may easily forget outdated information that is not presented to them
Title: Re: A few questions
Post by: [chrisB] on January 27, 2023, 09:45:22 PM
Could you forward it onto the team to investigate for a fix please?

I get what you're saying, I personally have a chore list I do with all of my sites which includes checking for outdated information. My main site is football related and until the past few seasons, we'd have like 3 managers a season. 😂

But in this user case, I have a simple guest greeting that I want to replace with a version for members who are signed in. Not every admin will understand either, but I would admit that it would annoy me seeing it after a while.
Title: Re: A few questions
Post by: @rjen on January 27, 2023, 10:43:36 PM
Ok, just re-acquainted (is that a word?) my self with the function.

It does work, but needs some explanation.

As you may have noticed 'administrator' is not a membergroup you can pick when assigning permissions for a block. (see attachment).
Basically administrator membergroup sees ALL or NONE of the blocks.

If you want the administrators to see certain blocks, you will need to assign the administrator to one or more additional membergroups in their profile: they will then see the blocks that those membergroups can see... (see second attachment)

It basically means that you can have pure admins show ALL blocks, or the blocks per named membergroup.
Blocks that are only visible to guests or ungrouped members will NOT show to admins if you set the setting 'Show admins all blocks' to OFF. You do not have the option to exclude or include specific guest blocks for admins only.

Title: Re: A few questions
Post by: [chrisB] on January 27, 2023, 11:33:07 PM
I'm looking into what you've mentioned here rjen.

Could you do me one favour though please? Would you compare the panel code/permissions between the 'front panel' and the 'right panel'?

I've just moved the guest block to show inside the front panel, as an admin I cannot see it. To me, it seems that this could explain why admins see all the blocks or none at all. I wished I could compare and understand it, as to me, it seems if the other panels had the same permission code as the front panel - all the other panels would hide guest blocks to admins.

I am looking into the alternative group setup you mentioned though.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:25:39 AM
I am not sure what you want to compare: panels do not have permissions, blocks have.

I tested again this morning and as far as I can see now, it is working as I described for blocks in the front panel, but not for the other panels: the blocks are not showing for an administrator even if he has the additional membergroups, except for the front panel

When I tested yesterday I was using a user that had a regular membergroup as the main group, and the administrator as an extra group: then it works as I decribed

Something is definately off here for user that have admin as main membergroup...
Title: Re: A few questions
Post by: [chrisB] on January 28, 2023, 11:06:13 AM
Ah, I thought each panel might have its own permission.

If the other panels could act as the front panel does, that would eliminate any need for need to play around with the user groups (which I already have to customise the team page mod I use).

Looks like it could be a bug.

Thank you for checking into what I mentioned.
Title: Re: A few questions
Post by: tino on January 28, 2023, 03:13:45 PM
As per our discussion on GitHub, I think it's working as was intended. I didn't implement it initially but logically following it through it works how I would expect.

The front panel block has always been treated differently to others, I don't know why that was, however the setting you are using seems to be functioning as I would expect it to.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 03:25:18 PM
Still, if we can make the front panel follow suit, then it is consistent
Title: Re: A few questions
Post by: tino on January 28, 2023, 03:57:15 PM
Quote from: @rjen on January 28, 2023, 03:25:18 PM
Still, if we can make the front panel follow suit, then it is consistent

Hmm, tested this on elkarte and it doesn't work on the front panel when I correct the check. So I have changed this unintentionally somewhere...

Title: Re: A few questions
Post by: tino on January 28, 2023, 04:04:03 PM
Quote from: tino on January 28, 2023, 03:57:15 PM
Quote from: @rjen on January 28, 2023, 03:25:18 PM
Still, if we can make the front panel follow suit, then it is consistent

Hmm, tested this on elkarte and it doesn't work on the front panel when I correct the check. So I have changed this unintentionally somewhere...

Scrap that, they both work the same way. If you have ungrouped members checked and admin is not part of a group it shows, if you don't it doesn't. That seems logical to me.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 04:06:11 PM
 Not so much to me tbh.
Title: Re: A few questions
Post by: tino on January 28, 2023, 04:45:50 PM
I have changed the block code so the front panel is the same as blocks. That is in this comment https://github.com/Tinyportal/TinyPortal/issues/958#issuecomment-1407431970

It now checks all the groups you are part of to see if you can view the block not just the primary one, this is how I think it should work, as if you are a member of any allowed group you should be able to view it.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 05:20:01 PM
I see the comment, but not sure where to insert this code tbh...
Title: Re: A few questions
Post by: tino on January 28, 2023, 05:24:29 PM
Quote from: @rjen on January 28, 2023, 05:20:01 PM
I see the comment, but not sure where to insert this code tbh...

It's the same as the same function as you had in your earlier comment with changes so it functions the same as the front panel.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 05:38:20 PM
I was on my phone all day, so could not really check the codes..

I feel we are talking about different things though: I was trying to point out that the Frontpanel code should work like the other blocks, and you proposal is to change the other blocks to follow the front panel...

:hmm:

let me test what you propose first.
Title: Re: A few questions
Post by: tino on January 28, 2023, 05:56:52 PM
Indeed, as I think the front panel is working correctly. The other blocks aren't.

By that I mean if you are a member of a group and that can see the block then you should have access. If that's your primary user group or not doesn't matter.
Title: Re: A few questions
Post by: tino on January 28, 2023, 06:08:19 PM
https://github.com/Tinyportal/TinyPortal/pull/765/files

I broke the two acting the same in this change. My latest one should restore what we had before.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 06:31:51 PM
Just tested you latest code, but now as an admin I do not see the blocks, even not when I have an additional member group assigned that should see the blocks...

So it seems that when I am admin as primary member group and I set the admin can see all blocks to OFF I will not seen ANY blocks anymore...
Title: Re: A few questions
Post by: tino on January 28, 2023, 06:47:52 PM
Quote from: @rjen on January 28, 2023, 06:31:51 PM
Just tested you latest code, but now as an admin I do not see the blocks, even not when I have an additional member group assigned that should see the blocks...

So it seems that when I am admin as primary member group and I set the admin can see all blocks to OFF I will not seen ANY blocks anymore...

Hmmm, let me check. It was ok for me.
Title: Re: A few questions
Post by: tino on January 28, 2023, 06:52:06 PM
Quote from: tino on January 28, 2023, 06:47:52 PM
Quote from: @rjen on January 28, 2023, 06:31:51 PM
Just tested you latest code, but now as an admin I do not see the blocks, even not when I have an additional member group assigned that should see the blocks...

So it seems that when I am admin as primary member group and I set the admin can see all blocks to OFF I will not seen ANY blocks anymore...

Hmmm, let me check. It was ok for me.

That's not what I am getting. I have admin see all blocks set to off and display settings set to ungrouped and I can see them, if I uncheck ungrouped, I can't.
Title: Re: A few questions
Post by: [chrisB] on January 28, 2023, 07:01:57 PM
Will a fix be able to be patched to TP 2.2.2? 😇

You all do a great job with TinyPortal. If you ever need help finding bugs, I'm happy to help and have worked with IPS Devs before the release apps/plugins.
Title: Re: A few questions
Post by: tino on January 28, 2023, 07:05:46 PM
Quote from: [chrisB] on January 28, 2023, 07:01:57 PM
Will a fix be able to be patched to TP 2.2.2? 😇

You all do a great job with TinyPortal. If you ever need help finding bugs, I'm happy to help and have worked with IPS Devs before the release apps/plugins.

We're wrapping up the changes for 2.3.0 which will include this change I am sure, so I would wait for that personally.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:12:35 PM
Quote from: tino on January 28, 2023, 06:52:06 PM
That's not what I am getting. I have admin see all blocks set to off and display settings set to ungrouped and I can see them, if I uncheck ungrouped, I can't.

I really wish I could say the same, but no.

I have a user that has 'Administrator' as primary user group, without any other memeergroups and set the 'Admin can see all blocks'  to OFF.

I have multiple blocks
1. blocks that are assigned to all membergroups
2. blocks that are assigned to NO membergroups
3. blocks that are assigned to ungrouped members only

NO blocks are showing at all.
Title: Re: A few questions
Post by: tino on January 28, 2023, 07:14:48 PM
I've put a PR with the changes in, what version of PHP are you using? That's possibly the error.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:20:12 PM
Using your code, PHP Version 8.0.26
Title: Re: A few questions
Post by: tino on January 28, 2023, 07:22:40 PM
That doesn't help as I'm also on PHP 8.0 atm...

What is in the access field in the database for the blocks?

Also what group is your admin user in, that's in the members table.

Also you've not got the language setting checked? As that'll work correctly now..
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:30:43 PM
Quote from: tino on January 28, 2023, 07:22:40 PM
What is in the access field in the database for the blocks?
- Test block NO groups: access is blank
- Test block ALL: access is -1,0,3,11,12,13,14,15,16,17,18,19,20,21,22
- Test block UNgrouped: access is 0

Also what group is your admin user in, that's in the members table.
- as I said: administrator (group 1)

Also you've not got the language setting checked? As that'll work correctly now..
- Use language visibility option for blocks is not active


Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:32:04 PM
@tino, did I formulate this correctly?

QuoteOk, coming back to the original question....

As it seems there is a small bug with the 'Admin can see all blocks' setting in 2.2.2 that we will address in 2.3.0.

BUT, the fix will NOT do what you want exactly: it will make the setting 'Admin can see all bocks' behave consistently for all blocks, the way it was originally designed.

The expected behaviour is this:

If a user has de Administrator as primary membergroup, this user will by default see ALL active TinyPortal blocks. The setting 'Admin can see all blocks' in TinyPortal can be used to suppress ALL blocks completely to Administrators.

If you have the requirement to have an administrator user see only the blocks assigned to a certain membergroup, you will have to maintain the member permissions differently:
1. Assign the user to a primary membergroup that is NOT administrator,
2. Assign the user to the administrator as an additional membergroup, and any additional membergroups that you find applicable
3. Then disable the 'admin can see all blocks' setting

With this setup you will achieve what you desired: a user with administrator priviliges that will not see alle blocks, but only those that are visisible to his own membergroup(s).
Title: Re: A few questions
Post by: tino on January 28, 2023, 07:35:59 PM
Quote from: @rjen on January 28, 2023, 07:30:43 PM
Quote from: tino on January 28, 2023, 07:22:40 PM
What is in the access field in the database for the blocks?
- Test block NO groups: access is blank
- Test block ALL: access is -1,0,3,11,12,13,14,15,16,17,18,19,20,21,22
- Test block UNgrouped: access is 0

Also what group is your admin user in, that's in the members table.
- as I said: administrator (group 1)

Also you've not got the language setting checked? As that'll work correctly now..
- Use language visibility option for blocks is not active



Ok well the first shouldn't show for anyone
Second and third however should show.

Can you add some echo's in the if statements to see which ones are evaluating.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:38:33 PM
Well I am testing with Admin can see all boards set to OFF.

And now I do not see any blocks
Title: Re: A few questions
Post by: tino on January 28, 2023, 07:44:19 PM
Quote from: @rjen on January 28, 2023, 07:38:33 PM
Well I am testing with Admin can see all boards set to OFF.

And now I do not see any blocks

Can you change it to the below and let me know what numbers you see please.

    public function getBlockPermissions( ) {{{
        global $context, $user_info;

        $blocks = array();
        $user   = $user_info['groups'];
        $activeBlocks = $this->getActiveBlocks();
        foreach($activeBlocks as $block) {
            // Check group access
            if(allowedTo('tp_blocks') && (!empty($context['TPortal']['admin_showblocks']) || !isset($context['TPortal']['admin_showblocks']))) {
                echo '1';
            }
            else if(!isset($block['access'])) {
                echo '2';
                continue;
            }
            else if(isset($block['access']) && (strpos($block['access'],',') === false) && (empty(array_intersect(array($block['access']), $user))) ) {
                echo '3';
                continue;
            }
            else if(empty(array_intersect($user, explode(',', $block['access'])))) {
                echo '4';
                continue;
            }

            // check page settings
            $display = explode(',', $block['display']);
            if( $this->checkDisplayBlock( $display ) !== TRUE ) {
                echo '5';
                continue;
            }

            $blocks[] = $block;
        }

        return $blocks;

    }}}
Title: Re: A few questions
Post by: tino on January 28, 2023, 07:54:48 PM
Quote from: @rjen on January 28, 2023, 07:32:04 PM
@tino, did I formulate this correctly?

QuoteOk, coming back to the original question....

As it seems there is a small bug with the 'Admin can see all blocks' setting in 2.2.2 that we will address in 2.3.0.

BUT, the fix will NOT do what you want exactly: it will make the setting 'Admin can see all bocks' behave consistently for all blocks, the way it was originally designed.

The expected behaviour is this:

If a user has de Administrator as primary membergroup, this user will by default see ALL active TinyPortal blocks. The setting 'Admin can see all blocks' in TinyPortal can be used to suppress ALL blocks completely to Administrators.

If you have the requirement to have an administrator user see only the blocks assigned to a certain membergroup, you will have to maintain the member permissions differently:
1. Assign the user to a primary membergroup that is NOT administrator,
2. Assign the user to the administrator as an additional membergroup, and any additional membergroups that you find applicable
3. Then disable the 'admin can see all blocks' setting

With this setup you will achieve what you desired: a user with administrator priviliges that will not see alle blocks, but only those that are visisible to his own membergroup(s).

Expected behaviour is;

Admin can see all blocks (Set) - See All Blocks
Admin can see all blocks (Not-Set) - See Blocks if you are part of another member group which can see the block.

The other change is now if you are part of a member group which can see the block even if your primary membergroup can't you will still see the blocks.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 07:55:06 PM
With this setting I get...

43344444444444444443344444

Mind you: I have many more blocks active, that I was not testing with. Now with only 6 blocks (3 in front panel, and 3 left)

433433
Title: Re: A few questions
Post by: tino on January 28, 2023, 08:12:12 PM
Ok, the output from this please


public function getBlockPermissions( ) {{{
        global $context, $user_info;

        $blocks = array();
        $user   = $user_info['groups'];
        $activeBlocks = $this->getActiveBlocks();
        foreach($activeBlocks as $block) {
            // Check group access
            if(allowedTo('tp_blocks') && (!empty($context['TPortal']['admin_showblocks']) || !isset($context['TPortal']['admin_showblocks']))) {
                echo '1';
            }
            else if(!isset($block['access'])) {
                echo '2';
                continue;
            }
            else if(isset($block['access']) && (strpos($block['access'],',') === false) && (empty(array_intersect(array($block['access']), $user))) ) {
                echo '3';
var_dump($user);
var_dump($block['access']);
                continue;
            }
            else if(empty(array_intersect($user, explode(',', $block['access'])))) {
                echo '4';
var_dump($user);
var_dump($block['access']);
                continue;
            }

            // check page settings
            $display = explode(',', $block['display']);
            if( $this->checkDisplayBlock( $display ) !== TRUE ) {
                echo '5';
                continue;
            }

            $blocks[] = $block;
        }

        return $blocks;

    }}}
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 08:14:15 PM
4 array(2) { [0]=> int(1) [1]=> int(10) } string(42) "-1,0,3,11,12,13,14,15,16,17,18,19,20,21,22"

3 array(2) { [0]=> int(1) [1]=> int(10) } string(1) "0"
3 array(2) { [0]=> int(1) [1]=> int(10) } string(0) ""
4 array(2) { [0]=> int(1) [1]=> int(10) } string(42) "-1,0,3,11,12,13,14,15,16,17,18,19,20,21,22"

3 array(2) { [0]=> int(1) [1]=> int(10) } string(1) "0"
3 array(2) { [0]=> int(1) [1]=> int(10) } string(0) ""

Title: Re: A few questions
Post by: tino on January 28, 2023, 08:18:50 PM
Edited your block so I could see it easier.

That's working correctly as your user isn't part of group 0 for some reason. I don't know what your group 10 is, but that seems to be the secondary group.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 08:20:51 PM
This is the user
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 08:22:49 PM
The primary group is 1 (administrator)

No additional groups..

Title: Re: A few questions
Post by: tino on January 28, 2023, 08:27:57 PM
Quote from: @rjen on January 28, 2023, 08:22:49 PM
The primary group is 1 (administrator)

No additional groups..

You have post ranking set don't you? As I have just changed my post count for my admin user and it's no longer 0 as the secondary group.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 08:29:57 PM
That is active, yes.

10 is the post-based group.

Mind you: the post based groups are not part of the block permissions, so they should not really play a part here, right?
Title: Re: A few questions
Post by: tino on January 28, 2023, 08:31:46 PM
Then this is working as expected. As the primary group is admin 1, the secondary is a post based group, it also mirrors for me how the front panel works.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 08:32:27 PM
You may have expected this, but I did not...

Title: Re: A few questions
Post by: tino on January 28, 2023, 08:34:48 PM
Quote from: @rjen on January 28, 2023, 08:32:27 PM
You may have expected this, but I did not...

Honestly, I forgot post based groups were a thing. Now I have realised they are then it is working how I would expect, as if you add an additional group they will appear again, if that group is set.

This also mean's it does what the OP actually want's providing post based groups are set.
Title: Re: A few questions
Post by: tino on January 28, 2023, 08:40:51 PM
I do however think now we have got them so they are both the same, there is an inherent logic flaw in the code for when you don't have any posts as the check doesn't differentiate between 0 post count and 0 being the user group.

This in practice won't make much difference as you are 0 by default when you sign up. So both being 0 doesn't make any difference, and you are unlikely to have someone in the other groups with 0 posts.
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 08:44:21 PM
Hmm, isn't 0 the value for ungrouped members?

This is actually an issue in my forum: we have a club forum that allows non-members to participate.

Paying members are assigned to the Club membergroup that gives them additional priviliges. It does NOT mean that they have ever posted, though. So they will be in a membergroup and still be in the 0-post group: this is actually a substantial part of the user community!
Title: Re: A few questions
Post by: @rjen on January 28, 2023, 09:21:20 PM
Ok, coming back to the original question....

As it seems there is a small bug with the 'Admin can see all blocks' setting in 2.2.2 that we will address in 2.3.0. The change was just merged in for TinyPortal 2.3.0

This change aligns the behaviour of blocks in Front panel and the other panels, and the other change is now if you are part of a member group which can see the block even if your primary membergroup can't, you will still see the blocks.


The expected behaviour is this:
If a user has thee Administrator as primary membergroup, this user will by default see ALL active TinyPortal blocks. The setting 'Admin can see all blocks' in TinyPortal can be used disable this behaviour for Administrators.

The behaviour is in standard TinyPortal:
Admin can see all blocks (Set) - Admin will see All blocks that are active
Admin can see all blocks (Not-Set) - Admin will see blocks if admin is part of another membergroup which can see the block (additional membergroups).