[SOLVED] Edit signature

Discussion forum for MOD Writers regarding MOD Development.
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

[SOLVED] Edit signature

Post by all4phone »

UCP->Profile->Edit signature (This "link" is hidden when signatures are not allowed.)

Whether it is template file which contains this link or I'm wrong?

Any help will be greatly appreciated.
Last edited by all4phone on Sat Jul 05, 2014 12:52 pm, edited 2 times in total.
User avatar
AmigoJack
Registered User
Posts: 5903
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Edit signature

Post by AmigoJack »

It's one single module; displaying it as a "link" is rendered dynamically.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

Thanks for your quick reply.
AmigoJack wrote:It's one single module; displaying it as a "link" is rendered dynamically.
depends on the permissions ->Post->Can use signature ?

Image

Is there a possibility to use this link elsewhere?
For example on the custom page (I have a page very similar to memberlist.php).
User avatar
AmigoJack
Registered User
Posts: 5903
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Edit signature

Post by AmigoJack »

all4phone wrote:depends on the permissions ->Post->Can use signature ?
Depends on multiple things: is module available, is module enabled, and the user permission.
all4phone wrote:use this link elsewhere?
Of course, why not? ucp.php?i=profile&mode=signature
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

AmigoJack, thanks for your reply.
AmigoJack wrote:Depends on multiple things: is module available,
ACP->General->Board features->Allow signatures: Yes
AmigoJack wrote:is module enabled,
ACP->General->Signature settings->Allow signatures: Yes
AmigoJack wrote:and the user permission.
ACP->Permissions->User permissions->Post->Can use signature: Yes

In this case link Edit signature is visible.
AmigoJack wrote:Depends on multiple things: is module available,
ACP->General->Board features->Allow signatures: No
or
AmigoJack wrote:is module enabled,
ACP->General->Signature settings->Allow signatures: No
or
AmigoJack wrote:and the user permission.
ACP->Permissions->User permissions->Post->Can use signature: Never

And in this case link Edit signature is not visible.

Correct me please if I understood it wrong.

-------------------------------
AmigoJack wrote:Of course, why not?

Code: Select all

https://www.phpbb.com/community/ucp.php?i=profile&mode=signature
I'm afraid it is not so simple :(

I'm looking for solutions that will allow me display link "Edit signature" on this custom page, to get the same effect as in the UCP.
For example, a user who has permission (to edit signature) sees this link and who doesn't have can not see it.
How can I achieve the same effect (such as in the UCP) on custom page?
Thanks for any assistance.
User avatar
AmigoJack
Registered User
Posts: 5903
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Edit signature

Post by AmigoJack »

all4phone wrote:ACP->General->Board features->Allow signatures: Yes
ACP->General->Signature settings->Allow signatures: Yes
Those are the same. It's even the same file: /includes/acp/acp_board.php containing the mod(ul)es features and signature - and both are setting $config['allow_sig']. This is meant for posts, while there is a separate setting for PMs: $config['allow_sig_pm'].
all4phone wrote:ACP->Permissions->User permissions->Post->Can use signature: Yes
The permission 'u_sig'.

Now we have both things to check if the user is allowed to use his signature. What remains is to check if the user is able to edit his signature: we have to try to load the module.

So the overall code should be:

Code: Select all

require( $phpbb_root_path. 'includes/functions_module.'. $phpEx );
$oModule= new p_master();
$oModule-> list_modules( 'ucp' );

if( $user-> data['is_registered']  // No guest?
 && $config['allow_sig']  // Board setting
 && $auth-> acl_get( 'u_sig' )  // User permission
 && $oModule-> loaded( 'profile', 'signature' )  // Module exists, enabled and accessible?
  ) {
  die( 'print edit sig link' );
}
Untested.
Last edited by AmigoJack on Fri Jul 04, 2014 12:49 pm, edited 1 time in total.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

Thank you for Your excellent explanation. Now almost all is clear for me ;) .

I tried to insert all Your code to my custom page and ... sorry, I didn't know what to do with it further :) .

Then I tried to add this two smippets of Your code only:

Code: Select all

require( $phpbb_root_path. 'includes/functions_module.'. $phpEx );
$oModule= new p_master();
$oModule-> list_modules( 'ucp' );

Code: Select all

if (!$auth->acl_get('u_sig') && !$oModule-> loaded( 'ucp', 'signature' ))
                {
                    trigger_error('<img class="mess" src="styles/' . rawurlencode($user->theme['imageset_path']) . '/imageset/' . $user->lang_name . '/sign_icons/message.png" />' .$user->lang['NO_AUTH_SIGNATURE']);
                } 
There was such a situation:
- if user has no permission to have signature, custom page is not displayed, message 'NO_AUTH_SIGNATURE' is displayed.
So, it's half the battle ;).
It would be more comfortable leave access to a custom page where the link "Edit signature" is displayed (for users who are authorized) or not displayed (for those who don't have permission).

Previously, without Your code, I had an ugly message:
General Error
Module not accessible
so, thank you very much.

I wrote "almost all is clear", becouse I still don't know how to display link "Edit signatiure" in the specyfic place of my custom page. Should I add something to the style file (of my custom page) :? ?
However, I think that's still a lot of stuff I don't understand :( .
User avatar
AmigoJack
Registered User
Posts: 5903
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Edit signature

Post by AmigoJack »

I don't understand the problem - if you use templates then it's obvious: either you show the link or not:

Code: Select all

$bShowLink= $user-> data['is_registered']  // No guest?
 && $config['allow_sig']  // Board setting
 && $auth-> acl_get( 'u_sig' )  // User permission
 && $oModule-> loaded( 'profile', 'signature' )  // Module exists, enabled and accessible?
;

$template-> assign_var
( 'U_EDIT_SIG'
, $bShowLink? append_sid( "{$phpbb_root_path}ucp.$phpEx", "i=profile&mode=signature" ): ''
); 
...and in your template you just check for it:

Code: Select all

<!-- IF U_EDIT_SIG --><a href="{U_EDIT_SIG}">Edit signature<!-- ENDIF -->
If you don't use templates it's just a matter of PHP/HTML logic and only you yourself know when to output it.
Last edited by AmigoJack on Fri Jul 04, 2014 12:49 pm, edited 1 time in total.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

Let me explain again.

php file:

Code: Select all

<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
require( $phpbb_root_path. 'includes/functions_module.'. $phpEx );
$oModule= new p_master();
$oModule-> list_modules( 'ucp' );

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('signatures');
    if ($user->data['user_id'] == ANONYMOUS)
    {
        login_box('', $user->lang['LOGIN']);
    }

// Permissions to use signature
if ( !$auth->acl_get('u_sig') && !$oModule-> loaded( 'ucp', 'signature' ))
    {
        trigger_error('<img class="mess" src="styles/' . rawurlencode($user->theme['imageset_path']) . '/imageset/' . $user->lang_name . '/sign_icons/message.png" />' .$user->lang['NO_AUTH_SIGNATURE']);
    }

$page_title = $user->lang['SIGN_INFO_TITLE'];
page_header($page_title);

$template->set_filenames(array(
        'body' => 'signatures_info.html',
));

make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"));
page_footer();
?>
html file:

Code: Select all

<!-- INCLUDE simple_header.html -->

        <h2>{PAGE_TITLE}</h2>

        <div class="panel">
           <div class="inner"><span class="corners-top"><span></span></span>

           <div class="content2">
                <!-- some content, table with users signatures for example -->
           </div>

           <span class="corners-bottom"><span></span></span></div>
        </div>

<!-- INCLUDE simple_footer.html -->
And it's works as intended, namely no access to this page for users, who has no permission to have signature.

But I would like to have access to this page for users who has no permission.
I just want to hide the link "Edit signature" when user has no permission.

Code: Select all

<!-- IF U_EDIT_SIG --><a href="{U_EDIT_SIG}">Edit signature</a><!-- ELSE -->You have no permission to edit signature<!-- ENDIF --> 
I have prepared a page with a table of signatures, something like that:

Code: Select all

user1 | signature | edit/no edit
user2 | signature | edit/no edit
...
The last column will contain a link which will be available or not, depending on user permissions.
Therefore I was thinking about using the UCP link (Edit signature) but I just couldn' t handle it.
AmogoJack wrote: if you use templates then it's obvious: either you show the link or not:

Code: Select all

$bShowLink= $user-> data['is_registered']  // No guest?
     && $config['allow_sig']  // Board setting
     && $auth-> acl_get( 'u_sig' )  // User permission
     && $oModule-> loaded( 'ucp', 'signature' )  // Module exists, enabled and accessible?
    ;

    $template-> assign_var
    ( 'U_EDIT_SIG'
    , $bShowLink? append_sid( "{$phpbb_root_path}ucp.$phpEx", "i=profile&mode=signature" ): ''
    ); 
...and in your template you just check for it:

Code: Select all

<!-- IF U_EDIT_SIG --><a href="{U_EDIT_SIG}">Edit signature<!-- ENDIF --> 
Sorry, I tried this but unsuccessfully.
User avatar
AmigoJack
Registered User
Posts: 5903
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Edit signature

Post by AmigoJack »

  1. You have a list of users?
  2. On each user you want to check if he'd be able to edit his signature?
  3. Do you want links at all? Because that makes little sense, as only the current user (the one who is viewing the site) would then have such a link.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

a. Yes, memberlist.php and memberlist_body.html a little modiefied.
b. Only the one who is browsing the list of signatures.
c. Exactly as you write - only the current user, the one who is viewing the site (if have permission - can see the link, if haven't - can't see link).

This is a mod I am currently working on, this may will explain much more.
User avatar
AmigoJack
Registered User
Posts: 5903
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Edit signature

Post by AmigoJack »

Now this makes much more sense. I'm unable to download your code now (security restrictions), but considering an unmodified /memberlist.php go find:

Code: Select all

$template->assign_block_vars('memberrow', $memberrow);
Before, add:

Code: Select all

/*** 2014-07-04 BEGIN AmigoJack
    https://www.phpbb.com/community/viewtopic.php?f=71&t=2249646 ***/
if( $user-> data['user_id']== $user_id  // Viewer equals member?
 && $config['allow_sig']  // Board setting
 && $auth-> acl_get( 'u_sig' )  // User permission
  ) {
    require( $phpbb_root_path. 'includes/functions_module.'. $phpEx );
    $oModule= new p_master();
    $oModule-> list_modules( 'ucp' );

    if( $oModule-> loaded( 'profile', 'signature' ) ) {  // Module exists, enabled and accessible?
        $user-> add_lang( 'ucp' );
        $memberrow['U_EDIT_SIG']= append_sid( "{$phpbb_root_path}ucp.$phpEx", "i=profile&mode=signature" );
    }
}
/*** 2014-07-04 END ***/ 
Now you can use in your template

Code: Select all

<!-- IF memberrow.U_EDIT_SIG --><a href="{memberrow.U_EDIT_SIG}">{L_UCP_PROFILE_SIGNATURE}</a><!-- ENDIF -->
Last edited by AmigoJack on Fri Jul 04, 2014 12:49 pm, edited 2 times in total.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

Thank you, but after editing I received Parse error:

Code: Select all

Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in C:\xampp\htdocs\phpbb3\signatures.php on line 1612
line 1612:

Code: Select all

$memberrow['U_EDIT_SIG']=> append_sid( "{$phpbb_root_path}ucp.$phpEx", "i=profile&mode=signature" ); 
Btw, signatures list 0.0.7
(I'm already working on version 0.0.8, so the line 1612 will be different for version 0.0.7)
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 27451
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Edit signature

Post by Paul »

Try this:

Code: Select all

/*** 2014-07-04 BEGIN AmigoJack
    https://www.phpbb.com/community/viewtopic.php?f=71&t=2249646 ***/
if($user->data['user_id'] == $user_id && $config['allow_sig'] && $auth->acl_get('u_sig') && $oModule->loaded('ucp', 'signature'))
{
    $user->add_lang('ucp');
    $memberrow['U_EDIT_SIG'] = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=profile&mode=signature");
}
/*** 2014-07-04 END ***/
User avatar
all4phone
Registered User
Posts: 593
Joined: Fri Mar 18, 2011 11:56 am
Location: Poland
Name: Piotr
Contact:

Re: Edit signature

Post by all4phone »

@Paul thanks, bug is gone.
But I see no link in the table of signatures, only space before <br />:
Image
In template file, inside column named "Action", I have this code:

Code: Select all

<!-- IF memberrow.U_EDIT_SIG --><a href="{memberrow.U_EDIT_SIG}">{L_UCP_PROFILE_SIGNATURE}</a><!-- ENDIF --><br />

                            <a href="{U_UCP_PROFILE_SIGNITURE}" onclick="<!-- IF S_SIGN_POPUP -->popup(this.href, 780, 610); return false;<!-- ENDIF -->">
                                <img style="margin:-3px 0 -4px 0" src="{T_IMAGE_SIGN_LANG_PATH}{L_SIGN_ICON_EDIT}" title="{L_SIGN_EDIT_UCP}" />
                            </a>
// edit:
Permissions checked.
Display is the same for two users.
User tester_01: Can use signature -> Never
user tester_02: Can use signature -> Yes
Image
Locked

Return to “[3.0.x] MOD Writers Discussion”