Checking auth of poster

Discussion forum for Extension Writers regarding Extension Development.
User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Checking auth of poster

Post by kinerity » Wed Jul 11, 2018 12:17 pm

I'm stumped on this one. I need to check (in viewtopic) if the poster as a specific permission. I know $this->auth->acl_get('my_permission') checks if the current user has it, but can't wrap my head around checking other users. Can someone provide documentation or an example?
Last edited by kinerity on Fri Jul 13, 2018 2:26 am, edited 1 time in total.
Reason: Topic icon changed
Kailey Truscott - Community Team

User avatar
3Di
Registered User
Posts: 12945
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Checking auth of poster

Post by 3Di » Wed Jul 11, 2018 12:32 pm

What am I missing?
That's a bool, check if does not ! $this->auth->acl_get('my_permission').

if / else otherwise ?
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Checking auth of poster

Post by kinerity » Wed Jul 11, 2018 12:35 pm

That checks the current user. I need to check the auth of the poster. For example, viewing this topic, $this->auth->acl_get('my_permission') and !$this->auth->acl_get('my_permission') check if I have the permission. How do I check if you have the permission.
Kailey Truscott - Community Team

User avatar
3Di
Registered User
Posts: 12945
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Checking auth of poster

Post by 3Di » Wed Jul 11, 2018 12:45 pm

You might need to create an array of poster's IDs and traverse it then. ( in_array() or for each etc.. )

Some events in viewtopic hold arrays of topic data, which contain those ids.

Code: Select all

	* @var	array	row				Array with post data
	* @var	array	topic_data			Array with topic data
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 3210
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Checking auth of poster

Post by kasimi » Wed Jul 11, 2018 12:52 pm

You need to create a new instance of auth: https://github.com/phpbb/phpbb/blob/rel ... #L250-L252

User avatar
Ger
Recognised Extension Developer
Posts: 1737
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: Checking auth of poster

Post by Ger » Wed Jul 11, 2018 12:54 pm

I think you need to use \phpbb\auth->acl(&$userdata); first and use the userdata from given user there. Make sure to reset it to the current session user afterwards since acl is cached.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Checking auth of poster

Post by kinerity » Wed Jul 11, 2018 12:55 pm

kasimi wrote:
Wed Jul 11, 2018 12:52 pm
You need to create a new instance of auth
That's it! Thanks everyone. :)
Kailey Truscott - Community Team

User avatar
3Di
Registered User
Posts: 12945
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Checking auth of poster

Post by 3Di » Wed Jul 11, 2018 1:13 pm

Code: Select all

	/**
	* Get permission listing based on user_id/options/forum_ids
	*
	* Be careful when using this function with permissions a_, m_, u_ and f_ !
	* It may not work correctly. When a user group grants an a_* permission,
	* e.g. a_foo, but the user's a_foo permission is set to "Never", then
	* the user does not in fact have the a_ permission.
	* But the user will still be listed as having the a_ permission.
	*
	* For more information see: http://tracker.phpbb.com/browse/PHPBB3-10252
	*/
	function acl_get_list($user_id = false, $opts = false, $forum_id = false)
Could be used I think to check for a single user which can be not the current user, if you are bound to check an array of posters instead - like all of the posters in a topic - then the approach I above suggested should be taken into consideration.
I need to check the auth of the poster.
I am considering the word "poster(s)" as it should be, whose they posted in the topic. Not users online.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Checking auth of poster

Post by kinerity » Wed Jul 11, 2018 6:04 pm

One more thing, how do I pass postrow template vars to CSS? This doesn't work.

Code: Select all

.post-border {
	border-right: 5px solid {postrow.GROUP_COLOR};
}
Kailey Truscott - Community Team

User avatar
canonknipser
Registered User
Posts: 1623
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Checking auth of poster

Post by canonknipser » Wed Jul 11, 2018 7:30 pm

Afaik, templating doesn't work on css files, only on template files. So you need inline css styling in your template.
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB

User avatar
3Di
Registered User
Posts: 12945
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Checking auth of poster

Post by 3Di » Wed Jul 11, 2018 8:17 pm

Use overall_header_head_append.html

Code: Select all

{% if not INCLUDED_HLPOSTS_CSS %}
	{% INCLUDECSS '@threedi_hlposts/hlposts.css' %}
	{% set INCLUDED_HLPOSTS_CSS = true %}
{% endif %}
together with

overall_header_stylesheets_after.html

Code: Select all

<style>

/* Items color */
.hlposts-panel {
	background-color: {{ HLPOSTS_BCKG }};
	color: {{ HLPOSTS_TEXT }};
	box-shadow: 1px 2px 3px {{ HLPOSTS_BORD }};
}

</style>
events.

Look at "Steam Group Suite" and "Highlight Posts" extensions.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Checking auth of poster

Post by kinerity » Wed Jul 11, 2018 9:51 pm

canonknipser wrote:
Wed Jul 11, 2018 7:30 pm
Afaik, templating doesn't work on css files, only on template files. So you need inline css styling in your template.
I figured. I tried the inline styling and for whatever reason it would not show. I'll play with it more.
3Di wrote:
Wed Jul 11, 2018 8:17 pm
Use overall_header_head_append.html together with overall_header_stylesheets_after.html
Those events are not located in the postrow loop. I need to be able to pass GROUP_COLOR for each post.
Kailey Truscott - Community Team

User avatar
3Di
Registered User
Posts: 12945
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Checking auth of poster

Post by 3Di » Wed Jul 11, 2018 10:03 pm

Those events are the only two you can use to achieve your result afaik, else inline styling or some JS magic I guess.

Are available everywhere, not only in viewtopic.
I do store my values in the DB, using config_text and Json. Then I pass them.

Your CSS

Code: Select all

.post-border {
	border-right: 5px solid #fff; // a fake color which will be overriden 
}
overall_header_stylesheets_after.html

Code: Select all

.post-border {
	border-right: 5px solid {postrow.GROUP_COLOR};
}
Obviously I assume you should do a bit of experiments.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Checking auth of poster

Post by kinerity » Wed Jul 11, 2018 10:16 pm

3Di wrote:
Wed Jul 11, 2018 10:03 pm
overall_header_stylesheets_after.html

Code: Select all

.post-border {
	border-right: 5px solid {postrow.GROUP_COLOR};
}
Just for completeness, I did this. As I suspected, you can not use a postrow variable outside of the postrow loop.
Kailey Truscott - Community Team

User avatar
3Di
Registered User
Posts: 12945
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Checking auth of poster

Post by 3Di » Wed Jul 11, 2018 10:44 pm

kinerity wrote:
Wed Jul 11, 2018 10:16 pm
you can not use a postrow variable outside of the postrow loop.
Are you looking for something like this http://prntscr.com/k5dnec ? http://prntscr.com/k5doqu ?
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: canonknipser and 7 guests