Skip to content
Snippets Groups Projects
Commit 3823e5d3 authored by Regis Houssin's avatar Regis Houssin
Browse files

New: add possibility to add or force default directories

parent 2aafe5ee
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,7 @@ class modMyModule extends DolibarrModules ...@@ -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 // '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 // '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 // '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 // '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(); $this->module_parts = array();
......
...@@ -52,7 +52,7 @@ class Conf ...@@ -52,7 +52,7 @@ class Conf
public $smart_menu; public $smart_menu;
public $modules = array(); // List of activated modules 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 // TODO Remove thoose arrays with generic module_parts
public $tabs_modules = array(); public $tabs_modules = array();
...@@ -258,6 +258,7 @@ class Conf ...@@ -258,6 +258,7 @@ class Conf
// Define default dir_output and dir_temp for directories of modules // Define default dir_output and dir_temp for directories of modules
foreach($this->modules as $module) foreach($this->modules as $module)
{ {
// For multicompany sharings
$this->$module->multidir_output = array($this->entity => $rootfordata."/".$module); $this->$module->multidir_output = array($this->entity => $rootfordata."/".$module);
$this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp"); $this->$module->multidir_temp = array($this->entity => $rootfordata."/".$module."/temp");
// For backward compatibility // For backward compatibility
...@@ -265,6 +266,24 @@ class Conf ...@@ -265,6 +266,24 @@ class Conf
$this->$module->dir_temp = $rootfordata."/".$module."/temp"; $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 // For mycompany storage
$this->mycompany->dir_output=$rootfordata."/mycompany"; $this->mycompany->dir_output=$rootfordata."/mycompany";
$this->mycompany->dir_temp=$rootfordata."/mycompany/temp"; $this->mycompany->dir_temp=$rootfordata."/mycompany/temp";
......
...@@ -285,16 +285,6 @@ if ($modulepart) ...@@ -285,16 +285,6 @@ if ($modulepart)
$original_file=$conf->contrat->dir_output.'/'.$original_file; $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 // Wrapping pour les dons
else if ($modulepart == 'donation') else if ($modulepart == 'donation')
{ {
...@@ -390,6 +380,12 @@ if ($modulepart) ...@@ -390,6 +380,12 @@ if ($modulepart)
// Generic wrapping // Generic wrapping
else else
{ {
// For dir temp
$dir_temp=false;
if (preg_match('/\_temp$/i', $modulepart)) {
$modulepart = str_replace('_temp', '', $modulepart);
$dir_temp=true;
}
// Define $accessallowed // 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 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 elseif (preg_match('/^specimen/i',$original_file)) $accessallowed=1; // If link to a specimen
...@@ -407,7 +403,9 @@ if ($modulepart) ...@@ -407,7 +403,9 @@ if ($modulepart)
} }
// Define $original_file // 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. // Define $sqlprotectagainstexternals for modules who want to protect access using a SQL query.
$sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS'; $sqlProtectConstName = strtoupper($modulepart).'_SQLPROTECTAGAINSTEXTERNALS_FOR_DOCUMENTS';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment