XModWorkFlow / module workflow
authorrenaud.zigmann@xsalto.com <renaud.zigmann@xsalto.com>
Sat, 21 Jan 2012 09:27:57 +0000 (10:27 +0100)
committerRenaud Zigmann <renaud.zigmann@xsalto.com>
Sat, 21 Jan 2012 09:30:13 +0000 (10:30 +0100)
* correction sur les evenements de declenchements et divers bugs
* le champ declenchement (trig) devient multivalue

class.kernel.inc
class.xmoddocmgt.inc
class.xmodtable.inc
class.xmodworkflow.inc

index 64bfa30..104d7e8 100644 (file)
@@ -61,9 +61,9 @@ class Kernel {
     return $ok;
   }
 
-  // rend vrai si la donnee d'oid $koid existe dans la langue specifiee
-  // $xx est la connection bd s'il en existe une a utiliser
-  //
+  /** rend vrai si la donnee d'oid $koid existe dans la langue specifiee
+   $xx est la connection bd s'il en existe une a utiliser
+  */
   static function objectExists($koid, $klang='%') {
     $table = Kernel::getTable($koid);
     if (empty($table)) return false;
@@ -76,8 +76,7 @@ class Kernel {
     return selectQueryExists($requete);
   }
 
-  // rend vrai si la donnee d'oid $koid existe dans la langue specifiee
-  //
+  /// rend vrai si la donnee d'oid $koid existe dans la langue specifiee
   static function objectExists2($koid, $klang='%') {
     $table = Kernel::getTable($koid);
     if (empty($table)) return false;
index 3305328..184efbc 100644 (file)
@@ -1540,6 +1540,7 @@ class XModDocMgt extends XModule {
     $p=new XParam($ar,array());
     $doid=$p->get('doid');
     $auth=$this->getTypes($doid);
+    $noworkflow=$p->get('_noworkflow');
     if(empty($auth)){
       XLogs::critical('security',"access type denied |".get_class($this)."|procInput|".$this->_moid."|TYPE ".$doid.
                      "| user ".XUser::get_current_user_uid());
@@ -1557,6 +1558,10 @@ class XModDocMgt extends XModule {
     $this->registerDoc($oidres, $doid);
     $docparent = &XDocumentDT::objectFactory($parentoid, $this);
     $docparent->addChild($oidres);
+    if(XModule::getMoid(XMODWORKFLOW_TOID) && empty($noworkflow)) {
+      $umod=XModule::singletonFactory(XMODWORKFLOW_TOID);
+      $umod->checkAndRun($this, $mod, $oidres, 'new');
+    }
 
     // creation des fils par clone du modele
     if (!empty($d1['opattern']->raw)){
index c869d1f..7f68005 100644 (file)
@@ -1109,6 +1109,7 @@ class XModTable extends XModule implements XModuleContainerInterface, XCalInterf
     $p=new XParam($ar,array('onlyssm'=>false,'ssmnottodel'=>array()));
     $nolog=$p->get('_nolog','local');
     $onlyssm=$p->get('onlyssm');
+    $noworkflow=$p->get('_noworkflow');
     $ssmnottodel=$p->get('ssmnottodel');
     $ar['table']=$this->table;
     $ar['action']='OK';
@@ -2216,6 +2217,7 @@ class XModTable extends XModule implements XModuleContainerInterface, XCalInterf
   function procInsert($ar) {
     $p=new XParam($ar,array('_applyrules'=>true));
     $tplentry=$p->get('tplentry');
+    $noworkflow=$p->get('_noworkflow');
     $applyrules=$p->get('_applyrules');
     if($this->procInsertCtrl($ar)) {
       $ar['table']=$this->table;
@@ -2226,12 +2228,12 @@ class XModTable extends XModule implements XModuleContainerInterface, XCalInterf
       if($submodcontext) $ar['fieldssec'][$submodcontext['_linkedfield']]='rw';
       if(!$p->is_set('PUBLISH')) $ar['PUBLISH']=($this->defaultispublished?1:2);
       $r=$this->xset->procInput($ar);
+      if(empty($noworkflow) && XModule::getMoid(XMODWORKFLOW_TOID)) {
+       $umod=XModule::singletonFactory(XMODWORKFLOW_TOID);
+       $umod->checkAndRun($this, $this, $r['oid'], 'new');
+      }
       if($applyrules) {
        XModRule::applyRules($this,$r['oid']);
-       if(XModule::getMoid(XMODWORKFLOW_TOID)) {
-         $umod=XModule::singletonFactory(XMODWORKFLOW_TOID);
-         $umod->checkAndRun($this, $this, $r['oid'], 'new');
-       }
       }
       if($this->object_sec && $this->owner_sec)
        $GLOBALS['XUSER']->setUserAccess(get_class($this),$this->_moid,XShell::getLangData(),$r['oid'],'admin');
index 990d7f4..e2c27ba 100644 (file)
@@ -80,6 +80,8 @@ class XModWorkFlow extends XModTable {
 
   /// verifie si un workflow s'applique, et si oui cree un cas
   public function checkAndRun(XModule $mod, $interface, $oid, $event) {
+    if(!Kernel::objectExists($oid)) return;
+
     // affichage de l'objet
     $display=$interface->XMCdisplay(array('oid'=>$oid, 'tplentry'=>TZR_RETURN_DATA));
 
@@ -91,7 +93,7 @@ class XModWorkFlow extends XModTable {
 
     // recherche des workflow qui s'appliquent
     $wfs=selectQueryGetAll('SELECT distinct KOID FROM WFWORKFLOW WHERE  (modid= "'.$mod->_moid.
-                          '" OR modid like "%'.$mod->_moid.'%") AND trig like "'.$event.'%"');
+                          '" OR modid like "%'.$mod->_moid.'%") AND trig like "%'.$event.'%"');
     foreach($wfs as $wf) {
       $wfd=$this->xset->rDisplay($wf['KOID']);
       // verification qu'on est dans les groupes qui permettent le lancement