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

Conflicts:
	htdocs/core/class/extrafields.class.php
	htdocs/product/price.php
	htdocs/user/perms.php
This commit is contained in:
Laurent Destailleur 2019-03-21 12:20:24 +01:00
commit 5d21547854
9 changed files with 58 additions and 21 deletions

View File

@ -1219,8 +1219,12 @@ class Commande extends CommonOrder
$this->fk_delivery_address = $object->fk_delivery_address;
$this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client;
$this->note_private = $object->note_private;
$this->note_public = $object->note_public;
if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN))
{
$this->note_private = $object->note_private;
$this->note_public = $object->note_public;
}
$this->origin = $object->element;
$this->origin_id = $object->id;

View File

@ -1081,7 +1081,7 @@ class Facture extends CommonInvoice
*/
public function createFromOrder($object, User $user)
{
global $hookmanager;
global $conf, $hookmanager;
$error=0;
@ -1142,8 +1142,12 @@ class Facture extends CommonInvoice
$this->fk_delivery_address = $object->fk_delivery_address;
$this->contact_id = $object->contactid;
$this->ref_client = $object->ref_client;
$this->note_private = $object->note_private;
$this->note_public = $object->note_public;
if (empty($conf->global->MAIN_DISABLE_PROPAGATE_NOTES_FROM_ORIGIN))
{
$this->note_private = $object->note_private;
$this->note_public = $object->note_public;
}
$this->module_source = $object->module_source;
$this->pos_source = $object->pos_source;
@ -4382,10 +4386,6 @@ class FactureLigne extends CommonInvoiceLine
public $date_start;
public $date_end;
// Ne plus utiliser
//var $price; // P.U. HT apres remise % de ligne (exemple 80)
//var $remise; // Montant calcule de la remise % sur PU HT (exemple 20)
// From llx_product
/**
* @deprecated

View File

@ -5169,8 +5169,9 @@ abstract class CommonObject
$table_element = $this->table_element;
if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility
dol_syslog(get_class($this)."::insertExtraFields delete then insert", LOG_DEBUG);
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
dol_syslog(get_class($this)."::insertExtraFields delete", LOG_DEBUG);
$this->db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object";
@ -5181,6 +5182,14 @@ abstract class CommonObject
if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator
$sql.=",".$attributeKey;
}
// We must insert a default value for fields for other entities that are mandatory to avoid not null error
if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']))
{
foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
{
$sql.=",".$tmpkey;
}
}
$sql .= ") VALUES (".$this->id;
foreach($new_array_options as $key => $value)
@ -5199,10 +5208,20 @@ abstract class CommonObject
}
}
}
// We must insert a default value for fields for other entities that are mandatory to avoid not null error
if (is_array($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities']))
{
foreach($extrafields->attributes[$this->table_element]['mandatoryfieldsofotherentities'] as $tmpkey => $tmpval)
{
if (in_array($tmpval, array('int', 'double'))) $sql.=", 0";
else $sql.=", ''";
}
}
$sql.=")";
dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror();

View File

@ -864,8 +864,8 @@ class ExtraFields
$sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,totalizable,fielddefault,fieldcomputed,entity,enabled,help";
$sql.= " FROM ".MAIN_DB_PREFIX."extrafields";
$sql.= " WHERE entity IN (0,".$conf->entity.")";
if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element
//$sql.= " WHERE entity IN (0,".$conf->entity.")"; // Filter is done later
if ($elementtype) $sql.= " WHERE elementtype = '".$elementtype."'"; // Filed with object->table_element
$sql.= " ORDER BY pos";
$resql=$this->db->query($sql);
@ -875,6 +875,16 @@ class ExtraFields
{
while ($tab = $this->db->fetch_object($resql))
{
if ($tab->entity != 0 && $tab->entity != $conf->entity)
{
// This field is not in current entity. We discard but before we save it into the array of mandatory fields if it is a mandatory field
if ($tab->fieldrequired && is_null($tab->fielddefault))
{
$this->attributes[$tab->elementtype]['mandatoryfieldsofotherentities'][$tab->name]=$tab->type;
}
continue;
}
// We can add this attribute to object. TODO Remove this and return $this->attributes[$elementtype]['label']
if ($tab->type != 'separate')
{

View File

@ -868,7 +868,7 @@ class DoliDBMysqli extends DoliDB
if ($field_desc['default'] != '')
{
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
elseif ($field_desc['type'] != 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
}
dol_syslog(get_class($this)."::DDLUpdateField ".$sql, LOG_DEBUG);

View File

@ -1176,7 +1176,7 @@ class DoliDBPgsql extends DoliDB
if ($field_desc['default'] != '')
{
if ($field_desc['type'] == 'double' || $field_desc['type'] == 'tinyint' || $field_desc['type'] == 'int') $sql.=" DEFAULT ".$this->escape($field_desc['default']);
elseif ($field_desc['type'] == 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
elseif ($field_desc['type'] != 'text') $sql.=" DEFAULT '".$this->escape($field_desc['default'])."'"; // Default not supported on text fields
}
dol_syslog($sql, LOG_DEBUG);

View File

@ -1280,9 +1280,6 @@ if ($action == 'edit_price' && $object->getRights()->creer)
$parameters=array('colspan' => 2);
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$parameters=array('colspan' => 2);
$reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print '</table>';
dol_fiche_end();

View File

@ -754,6 +754,7 @@ class User extends CommonObject
{
dol_syslog(get_class($this)."::clearrights reset user->rights");
$this->rights='';
$this->nb_rights=0;
$this->all_permissions_are_loaded=false;
$this->_tab_loaded=array();
}
@ -2303,7 +2304,7 @@ class User extends CommonObject
if ($infologin > 0)
{
$label.= '<br>';
$label.= '<br><u>'.$langs->trans("Connection").'</u>';
$label.= '<br><u>'.$langs->trans("Session").'</u>';
$label.= '<br><b>'.$langs->trans("IPAddress").'</b>: '.$_SERVER["REMOTE_ADDR"];
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $label.= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (user entity '.$this->entity.')';
$label.= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)');

View File

@ -96,6 +96,9 @@ if (empty($reshook)) {
$user->getrights();
$menumanager->loadMenu();
}
$object->clearrights();
$object->getrights();
}
if ($action == 'delrights' && $caneditperms) {
@ -109,6 +112,9 @@ if (empty($reshook)) {
$user->getrights();
$menumanager->loadMenu();
}
$object->clearrights();
$object->getrights();
}
}
@ -265,9 +271,9 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad
if ($caneditperms)
{
print '<td class="center nowrap">';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("All")).'" alt="'.dol_escape_htmltag($langs->trans("All")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=addrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("All")."</a>";
print '/';
print '<a class="reposition" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '<a class="reposition commonlink" title="'.dol_escape_htmltag($langs->trans("None")).'" alt="'.dol_escape_htmltag($langs->trans("None")).'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delrights&amp;entity='.$entity.'&amp;module=allmodules">'.$langs->trans("None")."</a>";
print '</td>';
}
print '<td class="center" width="24">&nbsp;</td>';