ElkArte Community

Project Support => General ElkArte discussions => Topic started by: Twissell on March 25, 2021, 07:13:40 am

Title: New question about links (developer's perspective)
Post by: Twissell on March 25, 2021, 07:13:40 am
Hi everybody!

I wonder: from developer's point of view can I create a module, which make weblinks visible only for topic starter and moderations for specified topics?

I prefer to make a workaround and use nginx webserver secure link module in order to make a temp weblinks, but want to know more about ElkArter internals either  :D
Title: Re: New question about links (developer's perspective)
Post by: tino on March 25, 2021, 08:13:51 am
You can create a module which hooks in to the bbcode parser. Then have a permission which allows what you want and check on that or return an empty string if no permission.
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 25, 2021, 03:53:37 pm
Where in the sources can I get example of BBCodes parser? Point me the right way, please.
Title: Re: New question about links (developer's perspective)
Post by: tino on March 25, 2021, 04:10:18 pm
Quote from: Twissell – Where in the sources can I get example of BBCodes parser? Point me the right way, please.

Probably better looking at an addon. https://addons.elkarte.net/bbc/BBC-Move.html

That one is a simple example.
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 28, 2021, 04:38:07 am
Hi @tino!

Is there a function to check that some user is topicstarter of topic?
The topic ID might be passed as an argument to that function for example.
The last is just my suggestion. Would you like to advice me?
Title: Re: New question about links (developer's perspective)
Post by: tino on March 28, 2021, 05:45:39 am
You can run a sql query and get the data. That’s probably the most reliable way. The topic id should be available on the bbc parser section either in the $topic global or in context
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 28, 2021, 07:25:00 am
Make raw SQL requests inside the modules considered a good practice in ElkArte or you've SQL-wrappers for that?
Unfortunately, I don't see much in the dev documentation.
Title: Re: New question about links (developer's perspective)
Post by: tino on March 28, 2021, 07:52:51 am
Quote from: Twissell – Make raw SQL requests inside the modules considered a good practice in ElkArte or you've SQL-wrappers for that?
Unfortunately, I don't see much in the dev documentation.

You generally put them in the subs files and use the database() instance. Or you can just use the database() instance in the controller if you’re lazy.
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 28, 2021, 12:45:18 pm
Allow me first of all, @tino, to express heartfelt thanks about your  willingness to help and pretty quick replies :-)

Although all seems to be doable, but I've already changed my approach to the problem.
Details placed below.

Give me please starting point how to implement following idea: I want to attach viewing post content capability of certain post to user speficified in the post's properties or list of users.
I need RTFM-kick.
Title: Re: New question about links (developer's perspective)
Post by: tino on March 28, 2021, 12:51:08 pm
I’m not sure I follow?

You can use the permissions to only allow people to view certain boards, is this what you’re looking to do?
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 28, 2021, 01:41:18 pm
Quote from: tino – I’m not sure I follow?

You can use the permissions to only allow people to view certain boards, is this what you’re looking to do?
Yep, closely to what I want to achieve. Is it possible to implement "view post content" capability to single user or list of them?
And this "viewable" capability links the users to selected post.
Or it's not allowed due to DB schema?
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 28, 2021, 01:42:22 pm
Could I rewrite the permissions system to get wanted result, couldn't I ?
Title: Re: New question about links (developer's perspective)
Post by: Twissell on March 28, 2021, 01:55:21 pm
I've sent an example in PM, tino