[DEV] Introduciator : extension in phpBB 3.2.x

Discussion forum for Extension Writers regarding Extension Development.
User avatar
Feneck91
Registered User
Posts: 115
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 »

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 Kailey on Wed Feb 21, 2018 12:58 pm, edited 1 time in total.
Reason: Moved to Extension Writers Discussion
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 »

Maybe here?
EXTENSIONS FORUMS > Extension Writers Discussion (Discussion forum for Extension Writers regarding Extension Development.)
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

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

Post by mrgoldy »

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?
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
Feneck91
Registered User
Posts: 115
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 »

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: 115
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 »

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
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

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

Post by 3Di »

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.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Feneck91
Registered User
Posts: 115
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 »

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: 944
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

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

Post by Toxyy »

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!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
User avatar
GanstaZ
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

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

Post by GanstaZ »

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();
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Feneck91
Registered User
Posts: 115
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 »

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
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

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

Post by GanstaZ »

You don't need $user->setup() in extensions, it's only good on external pages like for example index and so on.
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Feneck91
Registered User
Posts: 115
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 »

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
Registered User
Posts: 1187
Joined: Wed Oct 11, 2017 10:29 pm
Location: GZOverse

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

Post by GanstaZ »

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?
Usus est magister optimus! phpBB pre-Triton & latest php environment.
When answer lies in the question, question becomes redundant!
User avatar
Feneck91
Registered User
Posts: 115
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 »

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
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

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

Post by david63 »

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!

I now no longer support any of my extensions but they will start to become available here
Post Reply

Return to “Extension Writers Discussion”