Merge pull request #15927 from frederic34/patch-8

code syntax
This commit is contained in:
Laurent Destailleur 2021-01-11 16:00:34 +01:00 committed by GitHub
commit f9c6d512cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 29 deletions

View File

@ -145,7 +145,9 @@ if ($action == 'updateMask') {
$tmpobjectkey = GETPOST('object'); $tmpobjectkey = GETPOST('object');
if (!empty($tmpobjectkey)) { if (!empty($tmpobjectkey)) {
$constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF'; $constforval = 'MYMODULE_'.strtoupper($tmpobjectkey).'_ADDON_PDF';
if ($conf->global->$constforval == "$value") dolibarr_del_const($db, $constforval, $conf->entity); if ($conf->global->$constforval == "$value") {
dolibarr_del_const($db, $constforval, $conf->entity);
}
} }
} }
} elseif ($action == 'setdoc') { } elseif ($action == 'setdoc') {
@ -338,9 +340,10 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= ''.$langs->trans("NextValue").': '; $htmltooltip .= ''.$langs->trans("NextValue").': ';
if ($nextval) { if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') {
$nextval = $langs->trans($nextval); $nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>'; }
$htmltooltip .= $nextval.'<br>';
} else { } else {
$htmltooltip .= $langs->trans($module->error).'<br>'; $htmltooltip .= $langs->trans($module->error).'<br>';
} }

View File

@ -53,8 +53,11 @@ if (!$res) die("Include of main fails");
header('Content-Type: application/javascript'); header('Content-Type: application/javascript');
// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access. // Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
// You can use CTRL+F5 to refresh your browser cache. // You can use CTRL+F5 to refresh your browser cache.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); if (empty($dolibarr_nocache)) {
else header('Cache-Control: no-cache'); header('Cache-Control: max-age=3600, public, must-revalidate');
} else {
header('Cache-Control: no-cache');
}
?> ?>
/* Javascript library of module MyModule */ /* Javascript library of module MyModule */

View File

@ -81,7 +81,7 @@ if (GETPOST('actioncode', 'array')) {
$actioncode = '0'; $actioncode = '0';
} }
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
$search_agenda_label = GETPOST('search_agenda_label'); $search_agenda_label = GETPOST('search_agenda_label');

View File

@ -128,7 +128,9 @@ $upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object-
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) { if (empty($reshook)) {
$error = 0; $error = 0;
@ -137,8 +139,11 @@ if (empty($reshook)) {
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
else $backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); $backtopage = $backurlforlist;
} else {
$backtopage = dol_buildpath('/mymodule/myobject_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
}
} }
} }
@ -476,7 +481,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Validate // Validate
if ($object->status == $object::STATUS_DRAFT) { if ($object->status == $object::STATUS_DRAFT) {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd); print dolGetButtonAction($langs->trans('Validate'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes', '', $permissiontoadd);
} else { } else {
$langs->load("errors"); $langs->load("errors");

View File

@ -73,36 +73,30 @@ $permission = $user->rights->mymodule->myobject->write;
* Add a new contact * Add a new contact
*/ */
if ($action == 'addcontact' && $permission) if ($action == 'addcontact' && $permission) {
{
$contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
{
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} // Toggle the status of a contact } elseif ($action == 'swapstatut' && $permission) {
elseif ($action == 'swapstatut' && $permission) // Toggle the status of a contact
{
$result = $object->swapContactStatus(GETPOST('ligne')); $result = $object->swapContactStatus(GETPOST('ligne'));
} // Deletes a contact } elseif ($action == 'deletecontact' && $permission) {
elseif ($action == 'deletecontact' && $permission) // Deletes a contact
{
$result = $object->delete_contact($lineid); $result = $object->delete_contact($lineid);
if ($result >= 0) if ($result >= 0) {
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit; exit;
} else { } else {
@ -132,8 +126,7 @@ $userstatic = new User($db);
/* */ /* */
/* *************************************************************************** */ /* *************************************************************************** */
if ($object->id) if ($object->id) {
{
/* /*
* Show tabs * Show tabs
*/ */
@ -191,10 +184,11 @@ if ($object->id)
// Contacts lines (modules that overwrite templates must declare this into descriptor) // Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
foreach ($dirtpls as $reldir) foreach ($dirtpls as $reldir) {
{
$res = @include dol_buildpath($reldir.'/contacts.tpl.php'); $res = @include dol_buildpath($reldir.'/contacts.tpl.php');
if ($res) break; if ($res) {
break;
}
} }
} }