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))
|
||||
|
||||
@ -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")).'">';
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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