forked from Wavyzz/dolibarr
Fix: validate of object is ok even if some fields are missing
This commit is contained in:
@@ -127,10 +127,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
|
||||
{
|
||||
$i++;
|
||||
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
|
||||
$texttoinsert .= " 'enabled'=>".($val['enabled'] != '' ? $val['enabled'] : 1).",";
|
||||
$texttoinsert .= " 'position'=>".($val['position'] != '' ? $val['position'] : 50).",";
|
||||
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
|
||||
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
|
||||
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
|
||||
$texttoinsert .= " 'visible'=>".($val['visible'] != '' ? $val['visible'] : -1).",";
|
||||
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
|
||||
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
|
||||
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
|
||||
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
|
||||
|
||||
@@ -92,6 +92,7 @@ if (empty($newmask)) // This should no happen
|
||||
|
||||
$result = restrictedArea($user, 'modulebuilder', null);
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
@@ -782,6 +783,8 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray',
|
||||
|
||||
if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
{
|
||||
$objectname = ucfirst($objectname);
|
||||
|
||||
if (preg_match('/[^a-z0-9_]/i', $objectname))
|
||||
{
|
||||
$error++;
|
||||
@@ -890,7 +893,6 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
// Replace '$includedocgeneration = 0;' into '$includedocgeneration = 1;' into files
|
||||
$arrayreplacement = array('$includedocgeneration = 0;', '$includedocgeneration = 1;');
|
||||
dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1);
|
||||
|
||||
}
|
||||
|
||||
// Scan for object class files
|
||||
@@ -1711,6 +1713,44 @@ elseif (! empty($module))
|
||||
$linktoenabledisable.='<a class="reposition asetresetmodule" href="'.$_SERVER["PHP_SELF"].'?id='.$moduleobj->numero.'&action=reset&value=mod' . $module . $param . '">';
|
||||
$linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1);
|
||||
$linktoenabledisable.='</a>';
|
||||
|
||||
$objMod = $moduleobj;
|
||||
$backtourlparam = '';
|
||||
$backtourlparam .= ($backtourlparam ? '&' : '?').'module='.$module; // No urlencode here, done later
|
||||
if ($tab) $backtourlparam .= ($backtourlparam ? '&' : '?').'tab='.$tab; // No urlencode here, done later
|
||||
$backtourl = $_SERVER["PHP_SELF"].$backtourlparam;
|
||||
|
||||
$regs = array();
|
||||
if (is_array($objMod->config_page_url))
|
||||
{
|
||||
$i = 0;
|
||||
foreach ($objMod->config_page_url as $page)
|
||||
{
|
||||
$urlpage = $page;
|
||||
if ($i++)
|
||||
{
|
||||
$linktoenabledisable .= ' <a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page), "setup").'</a>';
|
||||
// print '<a href="'.$page.'">'.ucfirst($page).'</a> ';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (preg_match('/^([^@]+)@([^@]+)$/i', $urlpage, $regs))
|
||||
{
|
||||
$urltouse = dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1);
|
||||
$linktoenabledisable .= ' <a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$urltouse = $urlpage;
|
||||
$linktoenabledisable .= ' <a href="'.$urltouse.(preg_match('/\?/', $urltouse) ? '&' : '?').'save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs))
|
||||
{
|
||||
$linktoenabledisable .= ' <a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1], 1).'?save_lastsearch_values=1&backtopage='.urlencode($backtourl).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"').'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1718,6 +1758,7 @@ elseif (! empty($module))
|
||||
$linktoenabledisable.=img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', 1);
|
||||
$linktoenabledisable.="</a>\n";
|
||||
}
|
||||
|
||||
if (empty($conf->$modulelowercase->enabled))
|
||||
{
|
||||
$modulestatusinfo=$form->textwithpicto($langs->trans("ModuleIsNotActive", $urltomodulesetup), '', -1, 'help');
|
||||
@@ -1747,16 +1788,16 @@ elseif (! empty($module))
|
||||
$head2[$h][2] = 'objects';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:'');
|
||||
$head2[$h][1] = $langs->trans("Menus");
|
||||
$head2[$h][2] = 'menus';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:'');
|
||||
$head2[$h][1] = $langs->trans("Permissions");
|
||||
$head2[$h][2] = 'permissions';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:'');
|
||||
$head2[$h][1] = $langs->trans("Menus");
|
||||
$head2[$h][2] = 'menus';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:'');
|
||||
$head2[$h][1] = $langs->trans("Hooks");
|
||||
$head2[$h][2] = 'hooks';
|
||||
|
||||
@@ -554,9 +554,9 @@ class MyObject extends CommonObject
|
||||
// Validate
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||
$sql .= " SET ref = '".$this->db->escape($num)."',";
|
||||
$sql .= " status = ".self::STATUS_VALIDATED.",";
|
||||
$sql .= " date_validation = '".$this->db->idate($now)."',";
|
||||
$sql .= " fk_user_valid = ".$user->id;
|
||||
$sql .= " status = ".self::STATUS_VALIDATED;
|
||||
if (! empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',";
|
||||
if (! empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id;
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
|
||||
|
||||
@@ -581,7 +581,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
|
||||
//Select mail models is same action as presend
|
||||
/*
|
||||
if (GETPOST('modelselected')) $action = 'presend';
|
||||
|
||||
// Presend form
|
||||
@@ -591,7 +590,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
$trackid = 'myobject'.$object->id;
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
||||
*/
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
Reference in New Issue
Block a user