diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index 4bc9639ffa3..0fd8d7d3785 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -57,6 +57,8 @@ class Mailing extends CommonObject
var $date_creat;
var $date_valid;
+
+ var $extraparams=array();
/**
@@ -64,7 +66,7 @@ class Mailing extends CommonObject
*
* @param DoliDb $db Database handler
*/
- function Mailing($db)
+ function __construct($db)
{
$this->db = $db;
@@ -176,14 +178,15 @@ class Mailing extends CommonObject
function fetch($rowid)
{
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body, m.bgcolor, m.bgimage";
- $sql .= ", m.email_from, m.email_replyto, m.email_errorsto";
- $sql .= ", m.statut, m.nbemail";
- $sql .= ", m.fk_user_creat, m.fk_user_valid";
- $sql .= ", m.date_creat";
- $sql .= ", m.date_valid";
- $sql .= ", m.date_envoi";
- $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m";
- $sql .= " WHERE m.rowid = ".$rowid;
+ $sql.= ", m.email_from, m.email_replyto, m.email_errorsto";
+ $sql.= ", m.statut, m.nbemail";
+ $sql.= ", m.fk_user_creat, m.fk_user_valid";
+ $sql.= ", m.date_creat";
+ $sql.= ", m.date_valid";
+ $sql.= ", m.date_envoi";
+ $sql.= ", m.extraparams";
+ $sql.= " FROM ".MAIN_DB_PREFIX."mailing as m";
+ $sql.= " WHERE m.rowid = ".$rowid;
dol_syslog(get_class($this)."::fetch sql=".$sql);
$result=$this->db->query($sql);
@@ -193,26 +196,28 @@ class Mailing extends CommonObject
{
$obj = $this->db->fetch_object($result);
- $this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->statut = $obj->statut;
- $this->nbemail = $obj->nbemail;
- $this->titre = $obj->titre;
- $this->sujet = $obj->sujet;
- $this->body = $obj->body;
- $this->bgcolor = $obj->bgcolor;
- $this->bgimage = $obj->bgimage;
+ $this->id = $obj->rowid;
+ $this->ref = $obj->rowid;
+ $this->statut = $obj->statut;
+ $this->nbemail = $obj->nbemail;
+ $this->titre = $obj->titre;
+ $this->sujet = $obj->sujet;
+ $this->body = $obj->body;
+ $this->bgcolor = $obj->bgcolor;
+ $this->bgimage = $obj->bgimage;
- $this->email_from = $obj->email_from;
- $this->email_replyto = $obj->email_replyto;
- $this->email_errorsto = $obj->email_errorsto;
+ $this->email_from = $obj->email_from;
+ $this->email_replyto = $obj->email_replyto;
+ $this->email_errorsto = $obj->email_errorsto;
- $this->user_creat = $obj->fk_user_creat;
- $this->user_valid = $obj->fk_user_valid;
+ $this->user_creat = $obj->fk_user_creat;
+ $this->user_valid = $obj->fk_user_valid;
- $this->date_creat = $this->db->jdate($obj->date_creat);
- $this->date_valid = $this->db->jdate($obj->date_valid);
- $this->date_envoi = $this->db->jdate($obj->date_envoi);
+ $this->date_creat = $this->db->jdate($obj->date_creat);
+ $this->date_valid = $this->db->jdate($obj->date_valid);
+ $this->date_envoi = $this->db->jdate($obj->date_envoi);
+
+ $this->extraparams = (array) json_decode($obj->extraparams, true);
return 1;
}
diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php
index 858396d9f36..1f9ba3a9e2d 100644
--- a/htdocs/comm/mailing/fiche.php
+++ b/htdocs/comm/mailing/fiche.php
@@ -30,6 +30,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/comm/mailing/class/mailing.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
$langs->load("mails");
@@ -41,10 +42,17 @@ $confirm=GETPOST('confirm','alpha');
$message = '';
$object=new Mailing($db);
+$result=$object->fetch($id);
+$extrafields = new ExtraFields($db);
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
+$hookmanager=new HookManager($db);
+$hookmanager->initHooks(array('mailingcard'));
// Tableau des substitutions possibles
-$substitutionarray=array(
+$object->substitutionarray=array(
'__ID__' => 'IdRecord',
'__EMAIL__' => 'EMail',
'__LASTNAME__' => 'Lastname',
@@ -60,8 +68,8 @@ $substitutionarray=array(
);
if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE)
{
- $substitutionarray=array_merge(
- $substitutionarray,
+ $object->substitutionarray=array_merge(
+ $object->substitutionarray,
array(
'__CHECK_READ__' => 'CheckMail',
'__UNSUSCRIBE__' => 'Unsubscribe'
@@ -69,7 +77,7 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE)
);
}
-$substitutionarrayfortest=array(
+$object->substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord',
'__EMAIL__' => 'TESTEMail',
'__LASTNAME__' => 'TESTLastname',
@@ -85,8 +93,8 @@ $substitutionarrayfortest=array(
);
if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE)
{
- $substitutionarrayfortest=array_merge(
- $substitutionarrayfortest,
+ $object->substitutionarrayfortest=array_merge(
+ $object->substitutionarrayfortest,
array(
'__CHECK_READ__' => 'TESTCheckMail',
'__UNSUSCRIBE__' => 'TESTUnsubscribe'
@@ -94,6 +102,13 @@ if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE)
);
}
+/*
+ * Actions
+ */
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+
// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes')
{
@@ -103,7 +118,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
}
else
{
- $result=$object->createFromClone($id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]);
+ $result=$object->createFromClone($object->id,$_REQUEST["clone_content"],$_REQUEST["clone_receivers"]);
if ($result > 0)
{
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@@ -125,7 +140,7 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes')
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message
$message='
'.$langs->trans("MailingNeedCommand").'
';
- $message.=' ';
+ $message.=' ';
$message.=''.$langs->trans("MailingNeedCommand2").'
';
$action='';
}
@@ -136,8 +151,6 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes')
}
else
{
- $result=$object->fetch($id);
-
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
if ($object->statut == 0)
@@ -358,8 +371,6 @@ if ($action == 'sendallconfirmed' && $confirm == 'yes')
// Action send test emailing
if ($action == 'send' && empty($_POST["cancel"]))
{
- $result=$object->fetch($id);
-
$error=0;
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
@@ -378,8 +389,8 @@ if ($action == 'send' && empty($_POST["cancel"]))
if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1;
// Pratique les substitutions sur le sujet et message
- $object->sujet=make_substitutions($object->sujet,$substitutionarrayfortest,$langs);
- $object->body=make_substitutions($object->body,$substitutionarrayfortest,$langs);
+ $object->sujet=make_substitutions($object->sujet,$object->substitutionarrayfortest,$langs);
+ $object->body=make_substitutions($object->body,$object->substitutionarrayfortest,$langs);
$arr_file = array();
$arr_mime = array();
@@ -453,8 +464,6 @@ if ($action == 'add')
// Action update description of emailing
if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyto' || $action == 'setemail_errorsto')
{
- $object->fetch($id);
-
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
if ($action == 'settitre') $object->titre = trim(GETPOST('titre','alpha'));
@@ -484,8 +493,6 @@ if ($action == 'settitre' || $action == 'setemail_from' || $actino == 'setreplyt
*/
if (! empty($_POST['addfile']))
{
- $object->fetch($id);
-
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@@ -499,8 +506,6 @@ if (! empty($_POST['addfile']))
// Action update emailing
if (! empty($_POST["removedfile"]))
{
- $object->fetch($id);
-
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@@ -515,8 +520,6 @@ if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
- $object->fetch($id);
-
$isupload=0;
if (! $isupload)
@@ -551,7 +554,7 @@ if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"
// Action confirmation validation
if ($action == 'confirm_valid' && $confirm == 'yes')
{
- if ($object->fetch($id) >= 0)
+ if ($object->id > 0)
{
$object->valid($user);
@@ -567,7 +570,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes')
// Resend
if ($action == 'confirm_reset' && $confirm == 'yes')
{
- if ($object->fetch($id) >= 0)
+ if ($object->id > 0)
{
$db->begin();
@@ -598,8 +601,6 @@ if ($action == 'confirm_reset' && $confirm == 'yes')
// Action confirmation suppression
if ($action == 'confirm_delete' && $confirm == 'yes')
{
- $object->fetch($id);
-
if ($object->delete($object->id))
{
Header("Location: liste.php");
@@ -618,6 +619,9 @@ if (! empty($_POST["cancel"]))
* View
*/
+// fetch optionals attributes and labels
+$extralabels=$extrafields->fetch_name_optionals_label('mailing');
+
$help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
llxHeader('',$langs->trans("Mailing"),$help_url);
@@ -639,6 +643,21 @@ if ($action == 'create')
print ''.$langs->trans("MailTitle").' ';
print ''.$langs->trans("MailFrom").' ';
print ''.$langs->trans("MailErrorsTo").' ';
+
+ // Other attributes
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook) && ! empty($extrafields->attribute_label))
+ {
+ foreach($extrafields->attribute_label as $key=>$label)
+ {
+ $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
+ print ''.$label.' ';
+ print $extrafields->showInputField($key,$value);
+ print ' '."\n";
+ }
+ }
+
print '';
print ' ';
@@ -649,7 +668,7 @@ if ($action == 'create')
print '';
print ''.$langs->trans("MailMessage").' ';
print ''.$langs->trans("CommonSubstitutions").': ';
- foreach($substitutionarray as $key => $val)
+ foreach($object->substitutionarray as $key => $val)
{
print $key.' = '.$langs->trans($val).' ';
}
@@ -668,7 +687,7 @@ if ($action == 'create')
}
else
{
- if ($object->fetch($id) >= 0)
+ if ($object->id > 0)
{
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
@@ -784,6 +803,20 @@ else
print $nbemail;
}
print ' ';
+
+ // Other attributes
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook) && ! empty($extrafields->attribute_label))
+ {
+ foreach($extrafields->attribute_label as $key=>$label)
+ {
+ $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
+ print ''.$label.' ';
+ print $extrafields->showInputField($key,$value);
+ print " \n";
+ }
+ }
print '';
@@ -894,7 +927,7 @@ else
$formmail->withcancel=1;
$formmail->withdeliveryreceipt=0;
// Tableau des substitutions
- $formmail->substit=$substitutionarrayfortest;
+ $formmail->substit=$object->substitutionarrayfortest;
// Tableau des parametres complementaires du post
$formmail->param["action"]="send";
$formmail->param["models"]="body";
@@ -986,6 +1019,20 @@ else
print $nbemail;
}
print '';
+
+ // Other attributes
+ $parameters=array();
+ $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
+ if (empty($reshook) && ! empty($extrafields->attribute_label))
+ {
+ foreach($extrafields->attribute_label as $key=>$label)
+ {
+ $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
+ print ''.$label.' ';
+ print $extrafields->showInputField($key,$value);
+ print " \n";
+ }
+ }
print '';
print "";
@@ -1049,21 +1096,10 @@ else
// Message
print ''.$langs->trans("MailMessage").' ';
print ''.$langs->trans("CommonSubstitutions").': ';
- print '__ID__ = '.$langs->trans("IdRecord").' ';
- print '__EMAIL__ = '.$langs->trans("EMail").' ';
- if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE)
- {
- print '__CHECK_READ__ = '.$langs->trans("CheckRead").' ';
- print '__UNSUSCRIBE__ = '.$langs->trans("MailUnsubcribe").' ';
- }
- print '__MAILTOEMAIL__ = '.$langs->trans("MailtoEMail").' ';
- print '__LASTNAME__ = '.$langs->trans("Lastname").' ';
- print '__FIRSTNAME__ = '.$langs->trans("Firstname").' ';
- print '__OTHER1__ = '.$langs->trans("Other").'1 ';
- print '__OTHER2__ = '.$langs->trans("Other").'2 ';
- print '__OTHER3__ = '.$langs->trans("Other").'3 ';
- print '__OTHER4__ = '.$langs->trans("Other").'4 ';
- print '__OTHER5__ = '.$langs->trans("Other").'5 ';
+ foreach($object->substitutionarray as $key => $val)
+ {
+ print $key.' = '.$langs->trans($val).' ';
+ }
print ' ';
print '';
// Editeur wysiwyg
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 2914a1aecd1..32f4634e40e 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -52,13 +52,11 @@ class Conf
public $smart_menu;
public $modules = array(); // List of activated modules
- public $modules_parts = array('js'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array()); // List of modules parts
+ public $modules_parts = array('js'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'hooks'=>array()); // List of modules parts
// TODO Remove thoose arrays with generic module_parts
public $tabs_modules = array();
public $sms_engine_modules = array();
- // TODO Remove thoose arrays with generic module_parts
- public $hooks_modules = array();
public $societe_modules = array();
var $logbuffer = array();
@@ -202,7 +200,7 @@ class Conf
}
$i++;
}
-
+
$db->free($resql);
}
//var_dump($this->modules);
diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php
index 4f16862c82e..d6d1bd86539 100644
--- a/htdocs/core/class/doleditor.class.php
+++ b/htdocs/core/class/doleditor.class.php
@@ -176,7 +176,7 @@ class DolEditor
/* should be editor=CKEDITOR.replace but what if serveral editors ? */
CKEDITOR.replace(\''.$this->htmlname.'\',
{
- customConfig : \''.dol_buildpath('/theme/'.$conf->theme.'/ckeditor/config.js',1).'\',
+ customConfig : ckeditorConfig,
toolbar: \''.$this->toolbarname.'\',
toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').',
width: '.($this->width ? '\''.$this->width.'\'' : '\'\'').',
@@ -201,8 +201,8 @@ class DolEditor
{
$out.= ','."\n";
// To use filemanager with old fckeditor (GPL)
- $out.= ' filebrowserBrowseUrl : \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\',';
- $out.= ' filebrowserImageBrowseUrl : \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\',';
+ $out.= ' filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,';
+ $out.= ' filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,';
//$out.= ' filebrowserUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=File\',';
//$out.= ' filebrowserImageUploadUrl : \''.DOL_URL_ROOT.'/includes/fckeditor/editor/filemanagerdol/connectors/php/upload.php?Type=Image\',';
$out.= "\n";
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index a7f0edd173f..46230d678b2 100755
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -70,14 +70,14 @@ class HookManager
global $conf;
// Test if there is hooks to manage
- if (! is_array($conf->hooks_modules) || empty($conf->hooks_modules)) return;
+ if (! is_array($conf->modules_parts['hooks']) || empty($conf->modules_parts['hooks'])) return;
// For backward compatibility
if (! is_array($arraycontext)) $arraycontext=array($arraycontext);
$this->contextarray=array_unique(array_merge($arraycontext,$this->contextarray)); // All contexts are concatenated
- foreach($conf->hooks_modules as $module => $hooks)
+ foreach($conf->modules_parts['hooks'] as $module => $hooks)
{
if ($conf->$module->enabled)
{
diff --git a/htdocs/core/js/editinplace.js b/htdocs/core/js/editinplace.js
index 7748b73fce6..bf94a47749a 100644
--- a/htdocs/core/js/editinplace.js
+++ b/htdocs/core/js/editinplace.js
@@ -80,7 +80,13 @@ $(document).ready(function() {
indicator : indicatorInPlace,
ckeditor : {
customConfig: ckeditorConfig,
- toolbar: $('#ckeditor_toolbar').val()
+ toolbar: $('#ckeditor_toolbar').val(),
+ filebrowserBrowseUrl : ckeditorFilebrowserBrowseUrl,
+ filebrowserImageBrowseUrl : ckeditorFilebrowserImageBrowseUrl,
+ filebrowserWindowWidth : '900',
+ filebrowserWindowHeight : '500',
+ filebrowserImageWindowWidth : '900',
+ filebrowserImageWindowHeight : '500'
},
submitdata : function(result, settings) {
return getParameters(this, 'ckeditor');
diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
index a67d2bcf9e7..a6790fd7106 100755
--- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
+++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
@@ -34,4 +34,5 @@ INSERT INTO llx_c_input_reason (rowid,code,label,active) VALUES (10, 'SRC_EMPLOY
ALTER TABLE llx_commande_fournisseur CHANGE COLUMN date_cloture date_approve datetime;
ALTER TABLE llx_commande_fournisseur CHANGE COLUMN fk_user_cloture fk_user_approve integer;
-ALTER TABLE llx_mailing MODIFY COLUMN body mediumtext;
\ No newline at end of file
+ALTER TABLE llx_mailing MODIFY COLUMN body mediumtext;
+ALTER TABLE llx_mailing ADD COLUMN extraparams varchar(255);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_mailing.sql b/htdocs/install/mysql/tables/llx_mailing.sql
index aad9949d2d9..0656a1e83aa 100644
--- a/htdocs/install/mysql/tables/llx_mailing.sql
+++ b/htdocs/install/mysql/tables/llx_mailing.sql
@@ -46,6 +46,7 @@ create table llx_mailing
fk_user_creat integer, -- user creator
fk_user_valid integer, -- user validator
fk_user_appro integer, -- not used
+ extraparams varchar(255), -- for stock other parameters with json format
joined_file1 varchar(255),
joined_file2 varchar(255),
joined_file3 varchar(255),
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 0678797c8aa..4e1e373782e 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -978,7 +978,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
print 'var cancelInPlace = \''.$langs->trans('Cancel').'\';'."\n";
print 'var submitInPlace = \''.$langs->trans('Ok').'\';'."\n";
print 'var indicatorInPlace = \' theme."/img/working.gif".'">\';'."\n";
- print 'var ckeditorConfig = \''.dol_buildpath('/theme/'.$conf->theme.'/ckeditor/config.js',1).'\';'."\n";
print ''."\n";
print ''."\n";
print ''."\n";
@@ -1019,7 +1018,12 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
}
else
{
- print ''."\n";
+ print ''."\n";
print ''."\n";
}
}