Event for posting attachments

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
mael
Registered User
Posts: 76
Joined: Wed Jan 11, 2017 1:21 am
Name: DANY

Event for posting attachments

Post by mael » Wed Jul 11, 2018 8:52 pm

Hello folks! i wonder if anyone knows how modify the attachments list showing on posting page when you "edit" a postn i have been checking around all the core but nothing useful to get this. In viewtopics i can easily check which attachments will be show through core.viewtopic_modify_post_data event and "attachments" argument but in posting (edit) there is nothing. i would like to do something like this

Code: Select all

//Example from  core.viewtopic_modify_post_data event

$attachments = $event['attachments'];

if($event['has_approved_attachments'])
{
	$attachments_parse = $elements = array();
	if(!empty($rowset[$topic_data['topic_first_post_id']]))
	{
		foreach ($attachments as $key => $attachment)
		{
			foreach ($attachment as $id => $item)
			{
				if(!$item['attach_class']) //Here i filter the attachments by a custom field, to show or not the item
				{
					$elements[] = $item;
				}
			}
			$attachments_parse[$key] = $elements;
		}
		$event['topic_data'] = $topic_data;
		$event['attachments'] = $attachments_parse;
	}
}


Thanks in advance! :D

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

Re: Event for posting attachments

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

core.posting_modify_template_vars, mode 'edit'. ?

https://github.com/3D-I/qaip/blob/bb33e ... r.php#L124

Code: Select all

/**
* This event allows you to modify template variables for the posting screen
*
* @event core.posting_modify_template_vars
* @var	array	post_data	Array with post data
* @var	array	moderators	Array with forum moderators
* @var	string	mode		What action to take if the form is submitted
*				post|reply|quote|edit|delete|bump|smilies|popup
* @var	string	page_title	Title of the mode page
* @var	bool	s_topic_icons	Whether or not to show the topic icons
* @var	string	form_enctype	If attachments are allowed for this form
*				"multipart/form-data" or empty string
* @var	string	s_action	The URL to submit the POST data to
* @var	string	s_hidden_fields	Concatenated hidden input tags of posting form
* @var	int	post_id		ID of the post
* @var	int	topic_id	ID of the topic
* @var	int	forum_id	ID of the forum
* @var	int	draft_id	ID of the draft
* @var	bool	submit		Whether or not the form has been submitted
* @var	bool	preview		Whether or not the post is being previewed
* @var	bool	save		Whether or not a draft is being saved
* @var	bool	load		Whether or not a draft is being loaded
* @var	bool	cancel		Whether or not to cancel the form (returns to
*				viewtopic or viewforum depending on if the user
*				is posting a new topic or editing a post)
* @var	array	error		Any error strings; a non-empty array aborts
*				form submission.
*				NOTE: Should be actual language strings, NOT
*				language keys.
* @var	bool	refresh		Whether or not to retain previously submitted data
* @var	array	page_data	Posting page data that should be passed to the
*				posting page via $template->assign_vars()
* @var	object	message_parser	The message parser object
* @since 3.1.0-a1
* @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
*		s_topic_icons, form_enctype, s_action, s_hidden_fields,
*		post_id, topic_id, forum_id, submit, preview, save, load,
*		delete, cancel, refresh, error, page_data, message_parser
* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist
* @changed 3.1.5-RC1 Added poll variables to the page_data array
* @changed 3.1.6-RC1 Added 'draft_id' var
*/
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
mael
Registered User
Posts: 76
Joined: Wed Jan 11, 2017 1:21 am
Name: DANY

Re: Event for posting attachments

Post by mael » Wed Jul 11, 2018 9:30 pm

core.posting_modify_template_vars just show you the attachments data but you cant modify the attachment list that will be show in attachments section. in fact ,below this event is the function which makes a block vars to show the attachments in posting.

Code: Select all

posting_gen_attachment_entry($attachment_data, $filename_data, $allowed);
As you can see there is an argument called "$attachment_data" and i cant modify this because there is no event for this :( or at least thats what i know at the moment

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

Re: Event for posting attachments

Post by 3Di » Wed Jul 11, 2018 9:35 pm

Code: Select all

		/**
		* Modify inline attachments template vars
		*
		* @event core.modify_inline_attachments_template_vars
		* @var	array	attachment_data				Array containing attachments data
		* @var	array	attachrow_template_vars		Array containing attachments template vars
		* @since 3.2.2-RC1
		*/
includes/functions_posting.php
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
mael
Registered User
Posts: 76
Joined: Wed Jan 11, 2017 1:21 am
Name: DANY

Re: Event for posting attachments

Post by mael » Wed Jul 11, 2018 9:44 pm

ahhh that what i need :D , its seems is a new core event for 3.2.2. I didn´t know this because im working on 3.2.1 xD Many thanks :D

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 14 guests