diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 3f48539c8c55499023bc622fba884d9a38da0a3a..6107560d65672707b95108e48cf60bc971b5cd92 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -84,6 +84,7 @@ class modMyModule extends DolibarrModules // 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file // 'js' => array('/mymodule/js/mymodule.js'), // Set this to relative path of js file if module must load a js on all pages // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module + // 'dir' => array('output' => 'othermodulename'), // To force the default directories names // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@mymodule')) // Set here all workflow context managed by module // ); $this->module_parts = array(); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 514d6e06cad822cd79a9137cccb793c8427aeea4..2485e26e15de957f189461637f6b157136341013 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -52,7 +52,7 @@ class Conf public $smart_menu; public $modules = array(); // List of activated modules - public $modules_parts = array('css'=>array(), 'js'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'hooks'=>array()); // List of modules parts + public $modules_parts = array('css'=>array(), 'js'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'hooks'=>array(),'dir'=>array()); // List of modules parts // TODO Remove thoose arrays with generic module_parts public $tabs_modules = array(); @@ -258,6 +258,7 @@ class Conf // Define default dir_output and dir_temp for directories of modules foreach($this->modules as $module) { + // For multicompany sharings $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp"); // For backward compatibility @@ -265,6 +266,24 @@ class Conf $this->$module->dir_temp = $rootfordata."/".$module."/temp"; } + // External modules storage + if (! empty($this->modules_parts['dir'])) + { + foreach($this->modules_parts['dir'] as $module => $dirs) + { + foreach($dirs as $type => $name) + { + $subdir=($type=='temp'?'/temp':''); + // For multicompany sharings + $varname = 'multidir_'.$type; + $this->$module->$varname = array($this->entity => $rootfordata."/".$name.$subdir); + // For backward compatibility + $varname = 'dir_'.$type; + $this->$module->$varname = $rootfordata."/".$name.$subdir; + } + } + } + // For mycompany storage $this->mycompany->dir_output=$rootfordata."/mycompany"; $this->mycompany->dir_temp=$rootfordata."/mycompany/temp"; diff --git a/htdocs/document.php b/htdocs/document.php index 0fa3f3d4d8f63a8ef9fec4afb7965496fa1a59d0..910456aca7e9e774be55832ce2cf84604d389727 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -285,16 +285,6 @@ if ($modulepart) $original_file=$conf->contrat->dir_output.'/'.$original_file; } - // Wrapping pour les documents generaux - else if ($modulepart == 'ged') - { - if ($user->rights->document->lire) - { - $accessallowed=1; - } - $original_file= $conf->ged->dir_output.'/'.$original_file; - } - // Wrapping pour les dons else if ($modulepart == 'donation') { @@ -390,6 +380,12 @@ if ($modulepart) // Generic wrapping else { + // For dir temp + $dir_temp=false; + if (preg_match('/\_temp$/i', $modulepart)) { + $modulepart = str_replace('_temp', '', $modulepart); + $dir_temp=true; + } // Define $accessallowed if (($user->rights->$modulepart->lire) || ($user->rights->$modulepart->read) || ($user->rights->$modulepart->download)) $accessallowed=1; // No subpermission, we have checked on main permission elseif (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a specimen @@ -407,7 +403,9 @@ if ($modulepart) } // Define $original_file - $original_file=$conf->$modulepart->dir_output.'/'.$original_file; + $dir = $conf->$modulepart->dir_output; + if ($dir_temp) $dir = $conf->$modulepart->dir_temp; + $original_file = $dir.'/'.$original_file; // Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query. $sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS';