';
}
}
@@ -509,11 +517,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
if (empty($obj)) break; // Should not happen
// Store properties in $object
- $object->id = $obj->rowid;
- foreach ($object->fields as $key => $val)
- {
- if (property_exists($obj, $key)) $object->$key = $obj->$key;
- }
+ $object->setVarsFromFetchObj($obj);
// Show here line of result
print '
';
if (!$i) $totalarray['nbfield']++;
if (!empty($val['isameasure']))
{
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
- $totalarray['val']['t.'.$key] += $obj->$key;
+ $totalarray['val']['t.'.$key] += $object->$key;
}
}
}
// Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
// Fields from hook
- $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+ $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
@@ -562,8 +565,8 @@ while ($i < ($limit ? min($num, $limit) : $num))
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0;
- if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
- print '';
+ if (in_array($object->id, $arrayofselected)) $selected = 1;
+ print '';
}
print '';
if (!$i) $totalarray['nbfield']++;
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 37f2dd62fa3..4a00412f800 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -352,6 +352,7 @@ if (!$error && $massaction == 'confirm_presend')
{
$langs->load("commercial");
+ $reg = array();
$fromtype = GETPOST('fromtype');
if ($fromtype === 'user') {
$from = $user->getFullName($langs).' <'.$user->email.'>';
diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php
index 2cd713a5654..0a8ed21da14 100644
--- a/htdocs/core/actions_sendmails.inc.php
+++ b/htdocs/core/actions_sendmails.inc.php
@@ -273,6 +273,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$langs->load("commercial");
+ $reg = array();
$fromtype = GETPOST('fromtype', 'alpha');
if ($fromtype === 'robot') {
$from = dol_string_nospecial($conf->global->MAIN_MAIL_EMAIL_FROM, ' ', array(",")).' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>';
@@ -292,7 +293,8 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$from = trim($tmp[($reg[1] - 1)]);
}
elseif (preg_match('/senderprofile_(\d+)_(\d+)/', $fromtype, $reg)) {
- $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE rowid = '.(int) $reg[1];
+ $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
+ $sql .= ' WHERE rowid = '.(int) $reg[1];
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 2d3678e9e3a..990bfded07f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -7524,7 +7524,10 @@ abstract class CommonObject
}
// If field is an implicit foreign key field
- if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key] = 'null';
+ if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) {
+ if (isset($this->fields[$key]['default'])) $values[$key] = $this->fields[$key]['default'];
+ else $values[$key] = 'null';
+ }
if (!empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key] = 'null';
}
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index 9fbf98fc19c..22a93ab2bbc 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -20,8 +20,8 @@
*/
/**
- * \file class/emailsenderprofile.class.php
- * \ingroup monmodule
+ * \file core/class/emailsenderprofile.class.php
+ * \ingroup core
* \brief This file is a CRUD class file for EmailSenderProfile (Create/Read/Update/Delete)
*/
@@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
+
/**
* Class for EmailSenderProfile
*/
@@ -60,24 +61,29 @@ class EmailSenderProfile extends CommonObject
const STATUS_ENABLED = 1;
+
/**
- * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float')
+ * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
+ * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
* 'label' the translation key.
* 'enabled' is a condition when the field must be managed.
- * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing)
- * 'noteditable' says if field is not editable (1 or 0)
+ * 'position' is the sort order of field.
* 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
- * 'default' is a default value for creation (can still be replaced by the global setup of default values)
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
* 'index' if we want an index in database.
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
- * 'position' is the sort order of field.
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
* 'css' is the CSS style to use on field. For example: 'maxwidth200'
* 'help' is a string visible as a tooltip on field
- * 'comment' is not used. You can store here any text of your choice. It is not used by application.
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
* 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
*/
// BEGIN MODULEBUILDER PROPERTIES
@@ -90,8 +96,8 @@ class EmailSenderProfile extends CommonObject
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1),
'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1),
//'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
- //'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,),
- 'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>-1, 'enabled'=>1, 'position'=>400, 'notnull'=>-1, 'index'=>1,),
+ 'private' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>50, 'default'=>'0', 'notnull'=>1),
+ 'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>3, 'enabled'=>1, 'position'=>400, 'notnull'=>-1, 'index'=>1,),
'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,),
'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,),
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 2fd1b409ed7..abad66c8a73 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -569,7 +569,9 @@ class FormMail extends Form
}
// Add also email aliases from the c_email_senderprofile table
- $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1 ORDER BY position';
+ $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile';
+ $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')';
+ $sql .= ' ORDER BY position';
$resql = $this->db->query($sql);
if ($resql)
{
diff --git a/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql b/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql
index 3bc69695f5d..cd81eb4c42a 100644
--- a/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql
+++ b/htdocs/install/mysql/tables/llx_c_email_senderprofile.sql
@@ -1,5 +1,5 @@
-- ===================================================================
--- Copyright (C) 2001-2017 Laurent Destailleur
+-- Copyright (C) 2001-2019 Laurent Destailleur
--
-- 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
@@ -21,7 +21,7 @@ create table llx_c_email_senderprofile
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
entity integer DEFAULT 1 NOT NULL, -- multi company id
- private smallint DEFAULT 0 NOT NULL, -- Template public or private
+ private smallint DEFAULT 0 NOT NULL, -- Template public (0) or private (id of user)
date_creation datetime,
tms timestamp,
label varchar(255), -- Label of predefined email
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 09c90aba987..13f359f43cc 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -82,7 +82,7 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '
$id = GETPOST('id', 'int');
// Load variable for pagination
-$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@@ -137,7 +137,7 @@ $arrayfields=array();
foreach($object->fields as $key => $val)
{
// If $val['visible']==0, then we never show the field
- if (!empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
+ if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
}
// Extra fields
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0)