New: Check if there is external models to do asked by plugins

This commit is contained in:
Regis Houssin 2012-03-01 00:28:18 +08:00
parent 74935b3551
commit 45ff7bddb3
5 changed files with 46 additions and 13 deletions

View File

@ -78,6 +78,7 @@ class modMyModule extends DolibarrModules
// 'substitutions' => 0, // Set this to 1 if module has its own substitution function file // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file
// 'menus' => 0, // Set this to 1 if module has its own menus handler directory // 'menus' => 0, // Set this to 1 if module has its own menus handler directory
// 'barcode' => 0, // Set this to 1 if module has its own barcode directory // 'barcode' => 0, // Set this to 1 if module has its own barcode directory
// '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 // '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 // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module
// ); // );

View File

@ -38,8 +38,8 @@ $langs->load("errors");
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
$action = GETPOST("action"); $action = GETPOST('action','alpha');
$value = GETPOST("value"); $value = GETPOST('value','alpha');
/* /*
* Actions * Actions
@ -242,6 +242,11 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
// Check if there is external models to do asked by plugins
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
}
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir = $dirroot . "/core/modules/commande/"; $dir = $dirroot . "/core/modules/commande/";
@ -373,6 +378,11 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
// Check if there is external models to do asked by plugins
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
}
$var=true; $var=true;
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -34,8 +34,8 @@ $langs->load("errors");
if (! $user->admin) accessforbidden(); if (! $user->admin) accessforbidden();
$action = GETPOST("action"); $action = GETPOST('action','alpha');
$value = GETPOST("value"); $value = GETPOST('value','alpha');
/* /*
@ -308,6 +308,11 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
// Check if there is external models to do asked by plugins
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
}
$var=true; $var=true;
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
@ -473,6 +478,11 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
// Check if there is external models to do asked by plugins
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
}
$var=true; $var=true;
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* *
@ -35,11 +35,10 @@ require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("errors"); $langs->load("errors");
if (!$user->admin) if (! $user->admin) accessforbidden();
accessforbidden();
$action =GETPOST("action"); $action =GETPOST('action','alpha');
$value = GETPOST("value"); $value = GETPOST('value','alpha');
/* /*
* Actions * Actions
@ -186,7 +185,8 @@ if ($action == 'set')
$sql.= ")"; $sql.= ")";
$resql=$db->query($sql); $resql=$db->query($sql);
} }
if ($action == 'del')
else if ($action == 'del')
{ {
$type='propal'; $type='propal';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
@ -199,7 +199,7 @@ if ($action == 'del')
} }
} }
if ($action == 'setdoc') else if ($action == 'setdoc')
{ {
$label = GETPOST("label"); $label = GETPOST("label");
$scandir = GETPOST("scandir"); $scandir = GETPOST("scandir");
@ -235,7 +235,7 @@ if ($action == 'setdoc')
} }
} }
if ($action == 'setmod') else if ($action == 'setmod')
{ {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // par appel methode canBeActivated
@ -274,6 +274,11 @@ print '</tr>'."\n";
clearstatcache(); clearstatcache();
// Check if there is external models to do asked by plugins
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
}
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {
$dir = $dirroot . "/core/modules/propale/"; $dir = $dirroot . "/core/modules/propale/";
@ -405,6 +410,11 @@ print "</tr>\n";
clearstatcache(); clearstatcache();
// Check if there is external models to do asked by plugins
if (is_array($conf->models_modules) && ! empty($conf->models_modules)) {
$conf->file->dol_document_root = array_merge($conf->file->dol_document_root,$conf->models_modules);
}
$var=true; $var=true;
foreach ($conf->file->dol_document_root as $dirroot) foreach ($conf->file->dol_document_root as $dirroot)
{ {

View File

@ -58,6 +58,7 @@ class Conf
public $triggers_modules = array(); public $triggers_modules = array();
public $menus_modules = array(); public $menus_modules = array();
public $hooks_modules = array(); public $hooks_modules = array();
public $models_modules = array();
public $login_modules = array(); public $login_modules = array();
public $sms_engine_modules = array(); public $sms_engine_modules = array();
public $barcode_modules = array(); public $barcode_modules = array();
@ -163,6 +164,7 @@ class Conf
if (! is_array($this->$varname)) { $this->$varname = array(); } if (! is_array($this->$varname)) { $this->$varname = array(); }
$arrValue = @unserialize($value); $arrValue = @unserialize($value);
if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue; if (is_array($arrValue) && ! empty($arrValue)) $value = $arrValue;
else if ($partname == 'models' && $value == 1) $value = dol_buildpath('/'.$modulename);
else $value = ($value == 1 ? '/'.$modulename.'/core/'.$partname.'/' : $value); else $value = ($value == 1 ? '/'.$modulename.'/core/'.$partname.'/' : $value);
$this->$varname = array_merge($this->$varname, array($modulename => $value)); $this->$varname = array_merge($this->$varname, array($modulename => $value));
} }