Permalink
Browse files

New: add workflow module part for external modules

  • Loading branch information...
1 parent 14b6173 commit c57063878d286c1589edb025ab67cb651bd55b9d Regis Houssin committed Apr 4, 2012
View
1 dev/skeletons/modMyModule.class.php
@@ -81,6 +81,7 @@ function modMyModule($db)
// 'models' => 0, // Set this to 1 if module has its own models directory
// 'css' => '/mymodule/css/mymodule.css.php', // Set this to relative path of css if module has its own css file
// 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module
+ // 'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) // Set here all workflow context managed by module
// );
$this->module_parts = array();
View
34 htdocs/admin/workflow.php
@@ -77,10 +77,36 @@
clearstatcache();
$workflowcodes=array();
-if ($conf->propal->enabled && $conf->commande->enabled) $workflowcodes['WORKFLOW_PROPAL_AUTOCREATE_ORDER']='WORKFLOW_PROPAL_AUTOCREATE_ORDER';
-//if ($conf->propal->enabled && $conf->facture->enabled) $workflowcodes['WORKFLOW_PROPAL_AUTOCREATE_INVOICE']='WORKFLOW_PROPAL_AUTOCREATE_INVOICE';
-//if ($conf->contrat->enabled && $conf->facture->enabled) $workflowcodes['WORKFLOW_CONTRACT_AUTOCREATE_INVOICE']='WORKFLOW_CONTRACT_AUTOCREATE_INVOICE';
-if ($conf->commande->enabled && $conf->facture->enabled) $workflowcodes['WORKFLOW_ORDER_AUTOCREATE_INVOICE']='WORKFLOW_ORDER_AUTOCREATE_INVOICE';
+$workflow=array(
+ 'order' => array(
+ 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_ORDER')
+ ),
+ 'invoice' => array (
+ 'order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')
+ //,'contract' => array('WORKFLOW_CONTRACT_AUTOCREATE_INVOICE')
+ //, 'propal' => array('WORKFLOW_PROPAL_AUTOCREATE_INVOICE')
+ )
+);
+$workflow = array_merge($workflow, $conf->modules_parts['workflow']);
+
+foreach($workflow as $child => $parents)
+{
+ if ($conf->$child->enabled)
+ {
+ $langs->Load($child.'@'.$child);
+
+ foreach($parents as $parent => $actions)
+ {
+ if ($conf->$parent->enabled)
+ {
+ foreach($actions as $action)
+ {
+ $workflowcodes[$action] = $action;
+ }
+ }
+ }
+ }
+}
if (count($workflowcodes) > 0)
{
View
3 htdocs/core/class/conf.class.php
@@ -401,6 +401,9 @@ function setValues($db)
// For backward compatibility
$this->produit=$this->product;
+ $this->invoice=$this->facture;
+ $this->order=$this->commande;
+ $this->contract=$this->contrat;
// Define menu manager in setup
View
2 htdocs/core/modules/modWorkflow.class.php
@@ -69,7 +69,7 @@ function __construct($db)
$this->dirs = array("/workflow/temp");
// Config pages. Put here list of php page names stored in admmin directory used to setup module.
- $this->config_page_url = 'workflow.php';
+ $this->config_page_url = array('workflow.php');
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled

0 comments on commit c570638

Please sign in to comment.