Merge branch '11.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/core/tpl/extrafields_add.tpl.php
	htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php
This commit is contained in:
Laurent Destailleur 2020-04-05 04:03:53 +02:00
commit b1c5490a74
13 changed files with 167 additions and 99 deletions

View File

@ -99,6 +99,7 @@ $triggersendname = ''; // Disable triggers
$paramname = 'id';
$mode = 'emailfortest';
$trackid = (($action == 'testhtml') ? "testhtml" : "test");
$sendcontext='';
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action = 'test';
@ -791,7 +792,7 @@ else
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CMailFile('', '', '', '');
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
$result = $mail->check_server_port($server, $port);
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
else

View File

@ -535,8 +535,9 @@ else
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$mail = new CMailFile('', '', '', '');
$result=$mail->check_server_port($server, $port);
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
$result = $mail->check_server_port($server, $port);
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
else
{

View File

@ -1002,6 +1002,7 @@ class Categorie extends CommonObject
// phpcs:enable
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
$sql .= " WHERE fk_parent = ".$this->id;
$sql .= " AND entity IN (".getEntity('category').")";
$res = $this->db->query($sql);
if ($res)

View File

@ -6962,7 +6962,7 @@ abstract class CommonObject
* This function is responsible to output the <tr> and <td> according to correct number of columns received into $params['colspan']
*
* @param Extrafields $extrafields Extrafield Object
* @param string $mode Show output (view) or input (edit) for extrafield
* @param string $mode Show output ('view') or input ('create' or 'edit') for extrafield
* @param array $params Optional parameters. Example: array('style'=>'class="oddeven"', 'colspan'=>$colspan)
* @param string $keysuffix Suffix string to add after name and id of field (can be used to avoid duplicate names)
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
@ -7010,7 +7010,8 @@ abstract class CommonObject
$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
}
if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation
elseif ($mode == 'view' && empty($visibility)) continue;
if (empty($perms)) continue;
// Load language if required
@ -7038,9 +7039,10 @@ abstract class CommonObject
case "view":
$value = $this->array_options["options_".$key.$keysuffix];
break;
case "edit":
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
case "create":
case "edit":
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
{
if (is_array($getposttemp)) {
@ -7144,7 +7146,8 @@ abstract class CommonObject
case "view":
$out .= $extrafields->showOutputField($key, $value);
break;
case "edit":
case "create":
case "edit":
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element);
break;
}

View File

@ -1508,10 +1508,10 @@ class FormFile
if (!empty($addfilterfields))
{
print '<tr class="liste_titre nodrag nodrop">';
print '<td></td>';
print '<td><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
print '<td></td>';
print '<td></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
print '<td class="liste_titre"></td>';
print '<td class="liste_titre"></td>';
// Action column
print '<td class="liste_titre center">';
$searchpicto = $form->showFilterButtons();

View File

@ -127,7 +127,7 @@ class FormTicket
* @param int $withdolfichehead With dol_fiche_head
* @return void
*/
public function showForm($withdolfichehead = 0)
public function showForm($withdolfichehead = 0, $mode = 'edit')
{
global $conf, $langs, $user, $hookmanager;
@ -414,7 +414,7 @@ class FormTicket
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
print $ticketstat->showOptionals($extrafields, 'edit');
print $ticketstat->showOptionals($extrafields, 'create');
}
print '</table>';

View File

@ -45,7 +45,7 @@ if (empty($reshook)) {
$params = array();
if (isset($tpl_context)) $params['tpl_context'] = $tpl_context;
$params['cols'] = $parameters['colspanvalue'];
print $object->showOptionals($extrafields, 'edit', $params); // BUG #11554 : Add context in params
print $object->showOptionals($extrafields, 'create', $params);
}
?>

View File

@ -73,7 +73,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
//print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'<br>'."\n";
if (empty($enabled)) continue; // 0 = Never visible field
if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation
if (empty($perms)) continue; // 0 = Not visible
// Load language if required

View File

@ -98,10 +98,10 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
*/
public function getExample()
{
global $conf, $langs, $mysoc;
global $conf, $db, $langs, $mysoc;
$object = new MyObject($this->db);
$object->initAsSpecimen();
$object = new MyObject($db);
$object->initAsSpecimen();
/*$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code;

View File

@ -1280,7 +1280,13 @@ else
// Accountancy_code_buy
print '<tr><td>'.$langs->trans("ProductAccountancyBuyCode").'</td>';
print '<td>';
print $formaccounting->select_account(GETPOST('accountancy_code_buy', 'alpha'), 'accountancy_code_buy', 1, null, 1, 1, '');
if($type == 0)
{
$accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha')?(GETPOST('accountancy_code_buy', 'alpha')):$conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT);
} else {
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
}
print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, null, 1, 1, '');
print '</td></tr>';
// Accountancy_code_buy_intra

View File

@ -637,7 +637,7 @@ if ($action == 'create' || $action == 'presend')
$defaultref = '';
}
$formticket->showForm(1);
$formticket->showForm(1, 'create');
}
if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'

View File

@ -1240,13 +1240,8 @@ if ($action == 'create' || $action == 'adduserldap')
}
// Other attributes
$parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"');
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
print $object->showOptionals($extrafields, 'edit');
}
$parameters = array('colspan' => ' colspan="3"');
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
// Note
print '<tr><td class="tdtop">';
@ -2512,74 +2507,6 @@ else
}
}
// // Skype
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("Skype").'</td>';
// print '<td>';
// if ($caneditfield && empty($object->ldap_sid))
// {
// print '<input size="40" type="text" name="skype" class="flat" value="'.$object->skype.'">';
// }
// else
// {
// print '<input type="hidden" name="skype" value="'.$object->skype.'">';
// print $object->skype;
// }
// print '</td></tr>';
// }
// // Twitter
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("Twitter").'</td>';
// print '<td>';
// if ($caneditfield && empty($object->ldap_sid))
// {
// print '<input size="40" type="text" name="twitter" class="flat" value="'.$object->twitter.'">';
// }
// else
// {
// print '<input type="hidden" name="twitter" value="'.$object->twitter.'">';
// print $object->twitter;
// }
// print '</td></tr>';
// }
// // Facebook
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("Facebook").'</td>';
// print '<td>';
// if ($caneditfield && empty($object->ldap_sid))
// {
// print '<input size="40" type="text" name="facebook" class="flat" value="'.$object->facebook.'">';
// }
// else
// {
// print '<input type="hidden" name="facebook" value="'.$object->facebook.'">';
// print $object->facebook;
// }
// print '</td></tr>';
// }
// // LinkedIn
// if (! empty($conf->socialnetworks->enabled))
// {
// print '<tr><td>'.$langs->trans("LinkedIn").'</td>';
// print '<td>';
// if ($caneditfield && empty($object->ldap_sid))
// {
// print '<input size="40" type="text" name="linkedin" class="flat" value="'.$object->linkedin.'">';
// }
// else
// {
// print '<input type="hidden" name="linkedin" value="'.$object->linkedin.'">';
// print $object->linkedin;
// }
// print '</td></tr>';
// }
// OpenID url
if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication) && !empty($conf->global->MAIN_OPENIDURL_PERUSER))
{
@ -2735,12 +2662,12 @@ else
// Other attributes
$parameters = array('colspan' => ' colspan="2"');
//include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; // We do not use common tpl here because we need a special test on $caneditfield
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
if ($caneditfield)
{
if ($caneditfield) {
print $object->showOptionals($extrafields, 'edit');
} else {
print $object->showOptionals($extrafields, 'view');

View File

@ -0,0 +1,129 @@
#!/usr/bin/env php
<?php
/*
* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Jean Heimburger <http://tiaris.eu>
*
* 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/>.
*/
/**
* \file scripts/product/migrate_picture_path.php
* \ingroup scripts
* \brief Migrate pictures from old system prior to 3.7 to new path for 3.7+
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path = __DIR__ . '/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You are using PHP for CGI. To execute " . $script_file . " from command line, you must use PHP for CLI mode.\n";
exit(- 1);
}
@set_time_limit(0); // No timeout for this script
define('EVEN_IF_ONLY_LOGIN_ALLOWED', 1); // Set this define to 0 if you want to lock your script when dolibarr setup is "locked to admin user only".
// Include and load Dolibarr environment variables
require_once $path . "../../htdocs/master.inc.php";
require_once DOL_DOCUMENT_ROOT . "/user/class/user.class.php";
require_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
// After this $db, $mysoc, $langs, $conf and $hookmanager are defined (Opened $db handler to database will be closed at end of file).
// $user is created but empty.
// $langs->setDefaultLang('en_US'); // To change default language of $langs
$langs->load("main"); // To load language file for default language
// Global variables
$version = DOL_VERSION;
$error = 0;
$forcecommit = 0;
print "***** " . $script_file . " (" . $version . ") pid=" . dol_getmypid() . " *****\n";
dol_syslog($script_file . " launched with arg " . join(',', $argv));
if (! isset($argv[1]) || $argv[1] != 'user') {
print "Usage: $script_file user\n";
exit(- 1);
}
print '--- start' . "\n";
// Case to migrate products path
if ($argv[1] == 'user') {
$u = new User($db);
$sql = "SELECT rowid as uid from " . MAIN_DB_PREFIX . "user"; // Get list of all products
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
$u->fetch($obj->uid);
print " migrating user id=" . $u->id . " ref=" . $u->ref . "\n";
migrate_user_filespath($u);
}
} else {
print "\n sql error " . $sql;
exit();
}
}
$db->close(); // Close $db database opened handler
exit($error);
/**
* Migrate file from old path to new one for user $u
*
* @param User $u Object user
* @return void
*/
function migrate_user_filespath($u)
{
global $conf;
// Les fichiers joints des users sont toujours sur l'entité 1
$dir = $conf->user->dir_output;
$origin = $dir . '/' . get_exdir($u->id, 2, 0, 0, $u, 'user');
$destin = $dir . '/' . $u->id;
$error = 0;
$origin_osencoded = dol_osencode($origin);
$destin_osencoded = dol_osencode($destin);
dol_mkdir($destin);
if (dol_is_dir($origin)) {
$handle = opendir($origin_osencoded);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
if ($file != '.' && $file != '..' && is_dir($origin_osencoded . '/' . $file)) {
$thumbs = opendir($origin_osencoded . '/' . $file);
if (is_resource($thumbs)) {
dol_mkdir($destin . '/' . $file);
while (($thumb = readdir($thumbs)) !== false) {
dol_move($origin . '/' . $file . '/' . $thumb, $destin . '/' . $file . '/' . $thumb);
}
// dol_delete_dir($origin.'/'.$file);
}
} else {
if (dol_is_file($origin . '/' . $file)) {
dol_move($origin . '/' . $file, $destin . '/' . $file);
}
}
}
}
}
}