tsolucio / corebos

core Business Operating System. An OPEN SOURCE business application that helps small and medium business handle all the day to day tasks.
https://corebos.com
151 stars 142 forks source link

__WorkflowFunction__ in template on the same line #341

Open joebordes opened 6 years ago

joebordes commented 6 years ago

If we put two WorkflowFunction directives in the same line in an email they fail. I added a test case that proves this.

We must uncomment the test and modify the regular expressions in the workflow system to accept this case without breaking any of the other cases.

Ideally, I would like to see some additional tests added.

https://discussions.corebos.org/showthread.php?tid=723

joebordes commented 6 years ago

I gave this a shot after adding more supported closing characters and it seems impossible to get it done without breaking some case or another.

This is the state I had it in when I abandoned the idea:

diff --git a/modules/com_vtiger_workflow/VTSimpleTemplate.inc b/modules/com_vtiger_workflow/VTSimpleTemplate.inc
index f2b840d78..dc18889eb 100644
--- a/modules/com_vtiger_workflow/VTSimpleTemplate.inc
+++ b/modules/com_vtiger_workflow/VTSimpleTemplate.inc
@@ -307,10 +307,15 @@ class VTSimpleTemplate {
        $current_user = new Users();
        $current_user->retrieveCurrentUserInfoFromFile($assigned_user_id);
        $return = preg_replace_callback(
-           '/\\$(\w+?|\(general : \(__WorkflowFunction__\) (.+?) \)[ |&._\-\]}<>\/!"%ºª?,;]|\((\w+) : \(([_\w]+)\) (.+)\))/U',
+           '/\\$(\(general : \(__WorkflowFunction__\) (.+) \)[ |&._\-\]}<>\/!"%ºª?,;])/',
            array($this, 'matchHandler'),
            $this->template
        );
+       $return = preg_replace_callback(
+           '/\\$(\w+?|\((\w+) : \(([_\w]+)\) (.+)\))/U',
+           array($this, 'matchHandler'),
+           $return
+       );
        $current_user = $backCurrentUser;
        return $return;
    }

Unless someone can find the right regular expression I am thinking that we should completely change the placeholder to something like:

[__WFF__|workflow expression here|__FFW__]

that would require a changeset to change all existing templates