Preventing item to publish

4 years 8 months ago #38665 by rubenreyes
Hello,

I am looking for comments on a mechanism a want to implement that automatically prevents an item to become published when certain conditions occur.

Here is the situation:

We are developing a custom field that allows the user to upload a video to a 3rd party video streaming service.

Once the video is uploaded it needs to be transcoded. This process can take several minutes. After the video is transcoded, we receive the video ID number via an API.

I want to prevent the item from been published during the period while the video is transcoded. Even if the user changes the status to Published, it will be automatically changed to Unpublished or Draft.

So this is what we were thinking, and wanted to hear your opinion:

Option 1: As part of our custom field we would include some logic in the onAfterSaveField function that would change the item status.

Option 2: Create a plugin that would be triggered with onAfterContentSave event that takes care of changing the status (does Flexicontent trigger this event?)

Let me know your thoughts.

Thank you

Please Log in or Create an account to join the conversation.

4 years 8 months ago #38666 by ggppdk
Hello,
FLEXIcontent triggers:
a. onAfterSaveField for plugins of type:
flexicontent fields

b. onAfterContentSave for plugins of type:
content
(the content of triggering this is 'com_content.article' and not 'com_flexicontent.item' for compatibility reasons)

c. onAfterSaveItem and onCompleteSaveItem for plugins of type:
flexicontent


-- NOTE: the user may change the item state without editing a content via the "state toggler" icon, but you can catch this because FLEXIcontent triggers the onContentChangeState

... but because the state is overwritten after calling the event, please add this fix:

in file: administrator/components/com_flexicontent/models/parentitemclass.php
change line:
JRequest::setVar('view', $fc_itemview);	  JRequest::setVar('option', 'com_flexicontent');		$item->state = $fc_state;
to:
JRequest::setVar('view', $fc_itemview);	  JRequest::setVar('option', 'com_flexicontent');		if ($item->state == $jm_state) $item->state = $fc_state;


-- FLEXIcontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.