[DEV] Introduciator : extension in phpBB 3.2.x

Discussion forum for Extension Writers regarding Extension Development.
User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

[DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Wed Feb 21, 2018 12:02 pm

I work on the MOD Introduciator convertion to extension.

I work fine on it but I have a big problem: the user that introduce himself is able to see / edit it's own introduce while it is always approbation pending : this kind of work is working fine now.
But, it was possible to a moderator to reply to the introduce pending approbation : it cannot do that : into posting.php, there is this code:

Code: Select all

$post_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if (!$post_data)
{
	if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply'))
	{
		$user->setup('posting');
	}
	trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST');
}

// Not able to reply to unapproved posts/topics
// TODO: add more descriptive language key
if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] != ITEM_APPROVED) || ($mode == 'quote' && $post_data['post_visibility'] != ITEM_APPROVED)))
{
	trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED');
}
Here, the last trigger_error is called because the approbation is pending and between the SQL execution code and the error trigger no callback is executed...
Only one callback in the begining of the file is called : core.modify_posting_parameters but I can do nothing with that!

Or ask to phpBB team to add a callback at this point to force a reply that let the right to post into an approval pending message.. Or a workaroud to find to make it possible...

No way, I have no idea...
Last edited by kinerity on Wed Feb 21, 2018 12:58 pm, edited 1 time in total.
Reason: Moved to Extension Writers Discussion

User avatar
fliper4o
Registered User
Posts: 267
Joined: Wed Mar 23, 2011 8:15 pm
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by fliper4o » Wed Feb 21, 2018 12:12 pm

Maybe here?
EXTENSIONS FORUMS > Extension Writers Discussion (Discussion forum for Extension Writers regarding Extension Development.)

User avatar
mrgoldy
Jr. Extension Validator
Posts: 890
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by mrgoldy » Wed Feb 21, 2018 12:53 pm

First of all, you should post in the Extension Writes Discussion.

And secondly, I have no idea what you're asking and what you're trying to achieve.
Could you please provide a link to your code and more clearly explain what you're trying to achieve?
Formerly known as posey.
''Proud member of the Studio"

User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Wed Feb 21, 2018 3:45 pm

Sorry for my bad location posting...

The extension should be able to let the moderator reply to a pending approval topic. And it seems to be not possible.
I will let the source code later, I'm at work right now.

User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Wed Feb 21, 2018 8:46 pm

Feneck91 wrote:
Wed Feb 21, 2018 3:45 pm
Sorry for my bad location posting...

The extension should be able to let the moderator reply to a pending approval topic. And it seems to be not possible.
I will let the source code later, I'm at work right now.
This is the sample :
Image

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

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by 3Di » Fri Feb 23, 2018 9:43 pm

A github repository is better if you want someone to get a look at your code, anyway..

As far as I know is not possible to do what you want with the present core code, possible actions seems to be 'approve' or 'restore' or 'disapprove' if you look at includes/mcp/mcp_queue.php

Perhaps you should move the topic to a forum and there let the moderators have to discuss onto it, once done, split the topic and make it visible in the appropriate forum.

It's just a guess mine, I didn't read your code therefore I don't know exactly what you are about.
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades

👾 º The return of Space Invaders º 👾

User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Wed Jan 16, 2019 2:47 pm

Actually only one event is missing to make it work.
I'll pass to Github in few days.

If you want to see it: Image

A lot of work left...

I need (for the moment) to add one event in posting.php file:
Before : // Not able to reply to unapproved posts/topics
Add :

Code: Select all

// Feneck91 - Patch
$vars = array(
	'post_data',
	'poll',
	'mode',
	'topic_id',
	'forum_id',
	'post_author_name',
);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_databefore_patch', compact($vars)));
I need to ask it to? https://area51.phpbb.com/phpBB/viewtopi ... 26&t=47511

Another question, my language is not working well, how to load language? I use this method:

Code: Select all

	/**
	 * Load language into user if needed.
	 *
	 * @param $user The user informations
	 */
	public function load_language_if_needed($user)
	{
		if (empty($user->lang['RETURN_FORUM']))
		{
			$user->setup(array('feneck91/introduciator' => 'introduciator'));	// Setup & Add lang
		}
		else
		{
			$user->add_lang_ext('feneck91/introduciator', 'introduciator');	// Add lang
		}
	}
Any Idea to how to correctly load the current user language ?

User avatar
Toxyy
Registered User
Posts: 668
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Toxyy » Wed Jan 16, 2019 7:55 pm

Feneck91 wrote:
Wed Jan 16, 2019 2:47 pm
Any Idea to how to correctly load the current user language ?
I do this in my extension with the event core.core_user_setup:

Code: Select all

public function core_user_setup($event)
{
        $lang_set_ext = $event['lang_set_ext'];
        $lang_set_ext[] = [
                'ext_name' => 'toxyy/anonymousposts',
                'lang_set' => 'common',
        ];
        $event['lang_set_ext'] = $lang_set_ext;
}
This is in my listener.php file
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][RC] Show User Activity || [3.2][DEV] User Delete Topics

User avatar
GanstaZ
Jr. Extension Validator
Posts: 804
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by GanstaZ » Wed Jan 16, 2019 8:22 pm

Language file/s should be loaded only on those pages where it's needed/required. It's better to use language service $this->language->lang_add();
"When answer lies in the question,.. question becomes redundant!"

User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Wed Jan 16, 2019 9:00 pm

GanstaZ wrote:
Wed Jan 16, 2019 8:22 pm
Language file/s should be loaded only on those pages where it's needed/required. It's better to use language service $this->language->lang_add();
It's exactly what I'm doing.
But I cann user->setup() , may be it's not needed now, it was in phpBB 3.1.x...

OK. Setup() is always needed.
My error was I use always this->languagage->lang[xxx] and I must use this->languagage->lang(xxx) with parenthesis.
I'll can continue to code.
Last edited by Feneck91 on Wed Jan 16, 2019 9:15 pm, edited 1 time in total.

User avatar
GanstaZ
Jr. Extension Validator
Posts: 804
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by GanstaZ » Wed Jan 16, 2019 9:14 pm

You don't need $user->setup() in extensions, it's only good on external pages like for example index and so on.
"When answer lies in the question,.. question becomes redundant!"

User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Wed Jan 16, 2019 9:19 pm

I'm not so sure. If I remove this line, my page still is in English for my french test forum. If I let the next code, all is working fine.

Code: Select all

	/**
	 * Load language into user if needed.
	 *
	 * @param $user The user informations
	 */
	public function load_language_if_needed($user, $language)
	{
		if (empty($language->lang['RETURN_FORUM']))
		{
			$user->setup(); // Setup
		}

		if (empty($language->lang['INTRODUCIATOR_MOD_INTRODUCE_WAITING_APPROBATION']))
		{
			$language->add_lang('introduciator', 'feneck91/introduciator');	// Add lang
		}
	}
I'm looking for some peaple who can help me to make an asking request to add a new event to make my extension work.

Code: Select all

/* Patch to add to posting.php :
 * Search      : // Not able to reply to unapproved posts/topics
 * Add-Before  :  
// Feneck91 - Patch
$vars = array(
	'post_data',
	'poll',
	'mode',
	'topic_id',
	'forum_id',
	'post_author_name',
);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_databefore_patch', compact($vars)));

User avatar
GanstaZ
Jr. Extension Validator
Posts: 804
Joined: Wed Oct 11, 2017 10:29 pm
Location: Zverse

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by GanstaZ » Wed Jan 16, 2019 9:44 pm

I don't know what are you doing with that function, but this is not how you load language files in extensions. Move your repo to github and then it will be easier for all of use.
Does event already exist or is it a new one?
"When answer lies in the question,.. question becomes redundant!"

User avatar
Feneck91
Registered User
Posts: 92
Joined: Mon May 20, 2013 9:47 am
Name: Stéphane Château
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by Feneck91 » Thu Jan 17, 2019 2:31 am

No it is a new event. This is the problem... I need to ask to community to add this one, else one the best functionality if this extension will not working.

I just migrate my SVN assembla to GitHub : https://github.com/Feneck91/Introduciator

User avatar
david63
Jr. Extension Validator
Posts: 15575
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: [DEV] Introduciator : extension in phpBB 3.2.x

Post by david63 » Thu Jan 17, 2019 7:26 am

I cannot understand why you are having an issue with language files - there is nothing that you need to do within an extension to load a specific language.

You create a language folder for your language in the language folder of your extension and that language will be used if that is the user's language.

Seethis for adding an event. Basically you create a tickey in the tracker and the create a PR with the details that you want - there is ab excellent tutorial as a sticky at the topt of this forum on creating a PR.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests