Restore lost file and better generation of modules
This commit is contained in:
parent
5e29817910
commit
66420d0e80
86
htdocs/core/actions_setmoduleoptions.inc.php
Normal file
86
htdocs/core/actions_setmoduleoptions.inc.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/* Copyright (C) 2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/actions_setnotes.inc.php
|
||||
* \brief Code for actions on setting notes of object page
|
||||
*/
|
||||
|
||||
|
||||
// $action must be defined
|
||||
// $_FILES may be defined
|
||||
// $nomessageinsetmoduleoptions can be set to 1
|
||||
|
||||
// Define constants for submodules that contains parameters (forms with param1, param2, ... and value1, value2, ...)
|
||||
if ($action == 'setModuleOptions')
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
// Process common param fields
|
||||
foreach($_POST as $key => $val)
|
||||
{
|
||||
if (preg_match('/^param(\d*)$/', $key, $reg)) // Works for POST['param'], POST['param1'], POST['param2'], ...
|
||||
{
|
||||
$param=GETPOST("param".$reg[1],'alpha');
|
||||
$value=GETPOST("value".$reg[1],'alpha');
|
||||
if ($param)
|
||||
{
|
||||
$res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
|
||||
if (! $res > 0) $error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Process upload fields
|
||||
if (GETPOST('upload','alpha') && GETPOST('keyforuploaddir','aZ09'))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$keyforuploaddir=GETPOST('keyforuploaddir','aZ09');
|
||||
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->$keyforuploaddir)));
|
||||
foreach($listofdir as $key=>$tmpdir)
|
||||
{
|
||||
$tmpdir=trim($tmpdir);
|
||||
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
|
||||
if (! $tmpdir) {
|
||||
unset($listofdir[$key]); continue;
|
||||
}
|
||||
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
|
||||
else
|
||||
{
|
||||
$upload_dir=$tmpdir;
|
||||
}
|
||||
}
|
||||
if ($upload_dir)
|
||||
{
|
||||
$result = dol_add_file_process($upload_dir, 0, 1, 'uploadfile', '');
|
||||
if ($result <= 0) $error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,10 +133,12 @@ class HookManager
|
||||
if (in_array(
|
||||
$method,
|
||||
array(
|
||||
'addMoreActionsButtons',
|
||||
'addCalendarChoice',
|
||||
'addMoreActionsButtons',
|
||||
'addMoreMassActions',
|
||||
'addSearchEntry',
|
||||
'addStatisticLine',
|
||||
'deleteFile',
|
||||
'deleteFile',
|
||||
'doActions',
|
||||
'formCreateThirdpartyOptions',
|
||||
'formObjectOptions',
|
||||
@ -169,7 +171,6 @@ class HookManager
|
||||
'printSearchForm',
|
||||
'printTabsHead',
|
||||
'formatEvent',
|
||||
'addCalendarChoice',
|
||||
'printObjectLine',
|
||||
'printObjectSubLine',
|
||||
'createDictionaryFieldList',
|
||||
@ -181,14 +182,16 @@ class HookManager
|
||||
|
||||
if ($method == 'insertExtraFields')
|
||||
{
|
||||
$hooktype='returnvalue'; // deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
|
||||
$hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
|
||||
dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING);
|
||||
}
|
||||
|
||||
// Init return properties
|
||||
$this->resPrint=''; $this->resArray=array();
|
||||
|
||||
// Loop on each hook to qualify modules that have declared context
|
||||
$modulealreadyexecuted=array();
|
||||
$resaction=0; $error=0; $result='';
|
||||
$this->resPrint=''; $this->resArray=array();
|
||||
foreach($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context
|
||||
{
|
||||
if (! empty($modules))
|
||||
@ -202,9 +205,9 @@ class HookManager
|
||||
|
||||
// test to avoid running twice a hook, when a module implements several active contexts
|
||||
if (in_array($module,$modulealreadyexecuted)) continue;
|
||||
|
||||
|
||||
dol_syslog(get_class($this).'::executeHooks a qualified hook was found for method='.$method.' module='.$module." action=".$action." context=".$context);
|
||||
|
||||
|
||||
$modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method to avoid running twice
|
||||
|
||||
// Clean class (an error may have been set from a previous call of another method for same module/hook)
|
||||
|
||||
@ -545,11 +545,20 @@ class Form
|
||||
$disabled=0;
|
||||
$ret='<div class="centpercent center">';
|
||||
$ret.='<select data-role="none" class="flat'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionselect" name="massaction"'.($disabled?' disabled="disabled"':'').'>';
|
||||
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
|
||||
foreach($arrayofaction as $code => $label)
|
||||
{
|
||||
$ret.='<option value="'.$code.'"'.($disabled?' disabled="disabled"':'').'>'.$label.'</option>';
|
||||
}
|
||||
|
||||
// Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['context'] completed by executeHooks.
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('addMoreMassActions',$parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook))
|
||||
{
|
||||
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';
|
||||
foreach($arrayofaction as $code => $label)
|
||||
{
|
||||
$ret.='<option value="'.$code.'"'.($disabled?' disabled="disabled"':'').'>'.$label.'</option>';
|
||||
}
|
||||
}
|
||||
$ret.=$hookmanager->resPrint;
|
||||
|
||||
$ret.='</select>';
|
||||
// Warning: if you set submit button to disabled, post using 'Enter' will no more work.
|
||||
$ret.='<input type="submit" data-role="none" name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax)?'':' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
|
||||
|
||||
@ -50,13 +50,13 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public $editor_name;
|
||||
|
||||
|
||||
/**
|
||||
* @var string URL of module at publisher site
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public $editor_url;
|
||||
|
||||
|
||||
/**
|
||||
* @var string Family
|
||||
* @see familyinfo
|
||||
@ -80,13 +80,13 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*
|
||||
*/
|
||||
public $familyinfo;
|
||||
|
||||
|
||||
/**
|
||||
* @var int Module position
|
||||
* @since 3.9.0
|
||||
*/
|
||||
public $module_position=500;
|
||||
|
||||
|
||||
/**
|
||||
* @var string Module name
|
||||
*
|
||||
@ -214,7 +214,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
* HTML content supported.
|
||||
*/
|
||||
public $descriptionlong;
|
||||
|
||||
|
||||
/**
|
||||
* @var string Module export code
|
||||
*/
|
||||
@ -249,7 +249,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
* @var bool Module is enabled globally (Multicompany support)
|
||||
*/
|
||||
public $core_enabled;
|
||||
|
||||
|
||||
/**
|
||||
* @var string Relative path to module style sheet
|
||||
* @deprecated
|
||||
@ -286,7 +286,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*/
|
||||
public $config_page_url;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @var string[] List of module class names that must be enabled if this module is enabled.
|
||||
*
|
||||
@ -309,22 +309,22 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
* @var string[] Module language files
|
||||
*/
|
||||
public $langfiles;
|
||||
|
||||
|
||||
/**
|
||||
* @var string[] Array of warnings to show when we activate the module
|
||||
*
|
||||
*
|
||||
* array('always'='text') or array('FR'='text')
|
||||
*/
|
||||
public $warnings_activation;
|
||||
|
||||
|
||||
/**
|
||||
* @var string[] Array of warnings to show when we activate an external module
|
||||
*
|
||||
*
|
||||
* array('always'='text') or array('FR'='text')
|
||||
*/
|
||||
public $warnings_activation_ext;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @var array() Minimum version of PHP required by module.
|
||||
* e.g.: PHP ≥ 5.3 = array(5, 3)
|
||||
@ -342,7 +342,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
*/
|
||||
public $hidden = false;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
@ -538,8 +538,8 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
return $langs->trans("Module".$this->numero."Name");
|
||||
}
|
||||
else
|
||||
{
|
||||
// If module name translation using it's unique id does not exists, we take use its name to find translation
|
||||
{
|
||||
// If module name translation using it's unique id does not exists, we try to use its name to find translation
|
||||
if (is_array($this->langfiles))
|
||||
{
|
||||
foreach($this->langfiles as $val)
|
||||
@ -547,6 +547,14 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
if ($val) $langs->load($val);
|
||||
}
|
||||
}
|
||||
|
||||
if ($langs->trans("Module".$this->name."Name") != ("Module".$this->name."Name"))
|
||||
{
|
||||
// If module name translation exists
|
||||
return $langs->trans("Module".$this->name."Name");
|
||||
}
|
||||
|
||||
// Last change with simple product label
|
||||
return $langs->trans($this->name);
|
||||
}
|
||||
}
|
||||
@ -591,13 +599,13 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
|
||||
$filefound= false;
|
||||
|
||||
// Define path to file README.md.
|
||||
|
||||
// Define path to file README.md.
|
||||
// First check README-la_LA.md then README.md
|
||||
$pathoffile = dol_buildpath(strtolower($this->name).'/README-'.$langs->defaultlang.'.md', 0);
|
||||
if (dol_is_file($pathoffile))
|
||||
@ -612,11 +620,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$filefound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($filefound) // Mostly for external modules
|
||||
{
|
||||
$content = file_get_contents($pathoffile);
|
||||
|
||||
|
||||
if ((float) DOL_VERSION >= 6.0)
|
||||
{
|
||||
@include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php';
|
||||
@ -638,14 +646,14 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
if ($val) $langs->load($val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$content = $langs->trans($this->descriptionlong);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gives the publisher name
|
||||
*
|
||||
@ -655,7 +663,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
{
|
||||
return $this->editor_name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gives the publisher url
|
||||
*
|
||||
@ -665,7 +673,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
{
|
||||
return $this->editor_url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gives module version (translated if param $translated is on)
|
||||
* For 'experimental' modules, gives 'experimental' translation
|
||||
@ -768,7 +776,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gives the last date of activation
|
||||
*
|
||||
@ -777,11 +785,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
function getLastActivationDate()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";
|
||||
$sql.= " AND entity IN (0, ".$conf->entity.")";
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) $err++;
|
||||
@ -790,11 +798,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$obj=$this->db->fetch_object($resql);
|
||||
if ($obj) return $this->db->jdate($obj->tms);
|
||||
}
|
||||
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gives the last author of activation
|
||||
*
|
||||
@ -803,11 +811,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
function getLastActivationInfo()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
$sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const";
|
||||
$sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'";
|
||||
$sql.= " AND entity IN (0, ".$conf->entity.")";
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) $err++;
|
||||
@ -821,11 +829,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
}
|
||||
if ($obj) return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms));
|
||||
}
|
||||
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Insert constants for module activation
|
||||
*
|
||||
@ -929,7 +937,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$files[] = $file;
|
||||
}
|
||||
sort($files);
|
||||
foreach ($files as $file)
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data')
|
||||
{
|
||||
@ -947,7 +955,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$files[] = $file;
|
||||
}
|
||||
sort($files);
|
||||
foreach ($files as $file)
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'llx_' && substr($file,0,4) != 'data')
|
||||
{
|
||||
@ -965,7 +973,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$files[] = $file;
|
||||
}
|
||||
sort($files);
|
||||
foreach ($files as $file)
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,4) == 'data')
|
||||
{
|
||||
@ -983,7 +991,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$files[] = $file;
|
||||
}
|
||||
sort($files);
|
||||
foreach ($files as $file)
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (preg_match('/\.sql$/i',$file) && ! preg_match('/\.key\.sql$/i',$file) && substr($file,0,6) == 'update')
|
||||
{
|
||||
@ -1123,19 +1131,19 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
//$titre = $this->boxes[$key][0];
|
||||
$file = $this->boxes[$key]['file'];
|
||||
//$note = $this->boxes[$key][2];
|
||||
|
||||
|
||||
// TODO If the box is also included by another module and the other module is still on, we should not remove it.
|
||||
// For the moment, we manage this with hard coded exception
|
||||
//print "Remove box ".$file.'<br>';
|
||||
if ($file == 'box_graph_product_distribution.php')
|
||||
{
|
||||
if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled))
|
||||
if (! empty($conf->produit->enabled) || ! empty($conf->service->enabled))
|
||||
{
|
||||
dol_syslog("We discard disabling of module ".$file." because another module still active require it.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (empty($file)) $file = isset($this->boxes[$key][1])?$this->boxes[$key][1]:''; // For backward compatibility
|
||||
|
||||
if ($this->db->type == 'sqlite3') {
|
||||
@ -1210,7 +1218,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
$status = isset($this->cronjobs[$key]['status'])?$this->cronjobs[$key]['status']:'';
|
||||
$priority = isset($this->cronjobs[$key]['priority'])?$this->cronjobs[$key]['priority']:'';
|
||||
$test = isset($this->cronjobs[$key]['test'])?$this->cronjobs[$key]['test']:''; // Line must be visible
|
||||
|
||||
|
||||
// Search if boxes def already present
|
||||
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob";
|
||||
$sql.= " WHERE module_name = '".$this->db->escape($this->rights_class)."'";
|
||||
@ -1645,7 +1653,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
|
||||
/**
|
||||
* Removes access rights
|
||||
*
|
||||
*
|
||||
* @return int Error count (0 if OK)
|
||||
*/
|
||||
function delete_permissions()
|
||||
@ -1678,7 +1686,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
global $user;
|
||||
|
||||
if (! is_array($this->menu) || empty($this->menu)) return 0;
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php';
|
||||
|
||||
$err=0;
|
||||
|
||||
@ -18,12 +18,10 @@
|
||||
# Generic
|
||||
#
|
||||
|
||||
# Module label 'ModuleXXXName'
|
||||
# (where XXX is value of numeric property 'numero' of module)
|
||||
Module500000Name = My module
|
||||
# Module description 'ModuleXXXDesc'
|
||||
# (where XXX is value of numeric property 'numero' of module)
|
||||
Module500000Desc = My module description
|
||||
# Module label 'ModuleMyModuleName'
|
||||
ModuleMyModuleName = My module
|
||||
# Module description 'ModuleMyModuleDesc'
|
||||
ModuleMyModuleDesc = My module description
|
||||
|
||||
#
|
||||
# Admin page
|
||||
|
||||
@ -18,12 +18,10 @@
|
||||
# Générique
|
||||
#
|
||||
|
||||
# Module label 'ModuleXXXName'
|
||||
# (where XXX is value of numeric property 'numero' of module)
|
||||
Module500000Name = Mon module
|
||||
# Module description 'ModuleXXXDesc'
|
||||
# (where XXX is value of numeric property 'numero' of module)
|
||||
Module500000Desc = Description de mon module
|
||||
# Module label 'ModuleMyModuleName'
|
||||
ModuleMyModuleName = Mon module
|
||||
# Module description 'ModuleMyModuleDesc'
|
||||
ModuleMyModuleDesc = Description de mon module
|
||||
|
||||
#
|
||||
# Page d'administration
|
||||
|
||||
Loading…
Reference in New Issue
Block a user