Execute code upon content-changes in TYPO3 - typo3

Is it possible to notice if the content changed in the Backend and then, for example, to send a mail?
In other words, can I somehow notice who modified the contents in the backend and then automatically send an email?

Yes. When content is changed in the backend, several hooks are called before and after the database operations. You can register for each of those hooks. The class you want to have a look at for the right hook is \TYPO3\CMS\Core\DataHandling\DataHandler.
You can e.g. register a class for the processDatamap_afterDatabaseOperations hook by adding the class name to the array
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']
in your ext_localconf.php.
You can find more about hooks in TYPO3 here: https://usetypo3.com/signals-and-hooks-in-typo3.html

Related

Attachments are not updated asynchronously in Fiori MyInbox app?

I use SAP standard library: Inbox.
in library class S3.controller by tap on attachments icon is onTabSelect event executed, witch makes
this.fnDelegateAttachmentsCreation();
this.fnFetchDataOnTabSelect("Attachments");
this.fnHandleAttachmentsCountText("Attachments");
this.fnHandleNoTextCreation("Attachments");
break;
fnFetchDataOnTabSelect makes an asynchronous call. During this call is fnHandleAttachmentsCountText already executed, so the update of attachments count occurs before the request for attachments is ready. As far the request for attachments is ready, there is no update for title executed.
On screenshot is AttachmentCountText „Attachnents (1/1)“, that comes from previously selected item.
It should be „Attachements (2/2)".
Also if response comes too quick, then view changes to loading view after it received the answer from request.
If list of attachments was updated from request callback, then it should not be updated second time.
Here it seems, that there is something on loading, but request is already finished.
How could be Inbox extended, to update the attachment header and content after request is ready?
used SAPUI5-Version: 1.71.4
You are using the standard bsp-application ca_fiori_inbox?
You didn't create an extension project of the application ca_fiori_inbox with custom coding?
If that's the case, it's a bug in an standard application delivered by the SAP. SAP releases so called notes to fix bugs in their standard applications.
You can import notes in your system via the transaction SNOTE. May ask a SAP Basis Administrator from your company for help.
The following notes exactly describe your problem
2873960
2823664
2916255
2901520
If you already extended the SAP standard application(MyInbox) without using ExtensionPoints codechanges in the standard application will not affect your custom extension.
When overriding a controller method, any functionality that was previously provided by it is no longer available. Likewise, any future changes made to the original controller method implementation will not be reflected in the custom controller.
In this case you could still implement the note and check the changes in the standard controller vs. your custom controller on your system and change the respective lines in your custom coding.
Don't fix SAP coding. Report it and get a fix.
The Note 2873960 corrects coding in an abap class, not in the bsp-application(ca_fiori_inbox). So definitly import the note and check if it's fixing your problem.
I actually do not know, how the app works, but I want to give it a try.
Since it is an asynchronous function, you can always also wait for the function until it is done. So in your case, you could try to set an await keyword in front of the function.
await fnFetchDataOnTabSelect("Attachments");
This will now wait on this position until it has finished the function call before it will call the next functions. In addition to that you also need to set the upper function onTabSelect to async. So in the end it should look something like this.
onTabSelect: async function() {
// ...
this.fnDelegateAttachmentsCreation();
await this.fnFetchDataOnTabSelect("Attachments");
this.fnHandleAttachmentsCountText("Attachments");
this.fnHandleNoTextCreation("Attachments");
// ...
}
Although the Web IDE maybe shows you errors, it does work, since it is an official JavaScript API.

Create new work item type using VSTS Extension

Based on the documentation https://learn.microsoft.com/en-us/vsts/extend/overview?view=vsts#what-makes-up-an-extension, a VSTS extension can be used to extend the work item form.
However, I would like my extension to automatically create a new work item type once it is installed. Is this something that is possible? I can't find any documentation online that suggests how to do it.
Theoretically this is possible, the extension has a "first load" call which you can use to use the rest api to create a custom process or update the existing custom process. The REST Api to change processes isn't public yet, so you'll have to work from using fiddler to watch how the web ui does it.
Due to the way processes are linked to projects, all projects with that process will get the new work item type.
I could not find a lot of documentation online for this, but the VSS web extensions SDK(https://www.npmjs.com/package/vss-web-extension-sdk) has a REST client called 'ProcessDefinitionsRestClient' declared in the typings/tfs.d.ts file. This client has a createWorkItemType method available that looks like this:
createWorkItemType(workItemType: ProcessDefinitionsContracts.WorkItemTypeModel, processId: string): IPromise<ProcessDefinitionsContracts.WorkItemTypeModel>;.
The 'ProcessRestClient' client has methods to create a new/inherited process to which the new WIT can be added.
I have not tried it out yet, and these APIs are still in preview, but maybe they can get you started on the right path.

Typo3 6.2 Module: How to add an action to an existing module

I need your help!
Goal:
A Typo3 6.2 module should be extended with a button to delete all user data inserted. By default it is only possible to delete data one-by-one.
Conditions:
no changes in the core data of the original module allowed
I tried the following:
1. Extending the controller with XClasses & adding a new method cleanupAction
Problems with that:
cleanupAction is not allowed
Action would have to be added to ext_tables.php of the original module. But this is not allowed.
2. An own backend module:
Problem with that:
An entry in main nav in backend is generated, which is not desired and not needed.
Do you have any ideas how to tackle the problem? I only want to have an action, which can be called in the backend, without having a main-nav entry.
Thanks for your help!
Set up your own extension, containing a controller, some typoscript setup and a template.
The typoscript is used to change the template of the original backend module to your own version of the template:
module.tx_originalextension.view.templateRootPath = EXT:my_new_extension/Resources/Private/Templates/
Copy all templates from the original extension to your new extension. Add the new "delete all" button where you need it and link it with your new extension controller -> deleteAllAction. Of course, you need to implement the deleteAllAction in your controller.
In your controller, inject the original repository from the original extension, and use it to delete the data.
Remember to check the links in the copied templates. They need to point to the original extension, so add "extensionName" to any f:link.action calls expect the new "deleteAll" link.

How to set SwifMailer plugins when using the Laravel mail class?

Laravel does not return any useful information to show the reason that email fails. The SwifMailer Logger plugins helps with debugging during the process of sending. What is the correct way to set this plugin (and other swifmailer plugins) when emails are sent through Laravel's Mail class?
Use
Mail::getSwiftMailer()->registerPlugin();
You can place this code into some service provider for example to be executed on application startup. Or you can override Illuminate\Mail\Mailer entirely if you want.

How to get request properties in routeStartup plugin method?

I'm developing a multilanguage application, and use routes with translated segments. For multilingual support I created special Multilingual plugin.
To use translated segments I need set translator for Zend_Controller_Router_Route before routes init. So only possible place for this in my plugin is routeStartup method, but there is one problem here - for determine right locale I need to use properties of request (Zend_Controller_Request_Abstract), like module, controller and action names, but they are not defined yet here in routeStartup method. They are already defined, for example, in routeShutdown - but I can't set translator for route there, because it have to be done before routes init.
So what can I do:
can I get request properties somehow in routeStartup
or can I re-setup translator later in routeShutdown
P.S: there is a question with exactly the same problem Zend_Controller_Router_Route: Could not find a translator, but proposed answers is not the option for me, because I can't just retrieve language code from url with Regex, I have much more complicated code to define right language code.
Thanks.
What about putting your code in preDispatch? That's what I personally do when I need to check if the person is logged in. Maybe you can move your code there too?