';
// Ref
- print ''.$langs->trans("Ref").' '.$object->id.' ';
+ print ''.$langs->trans("Ref").' '.$object->ref.' ';
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php
index b62f58117a2..ca194f8d51d 100644
--- a/htdocs/adherents/cartes/carte.php
+++ b/htdocs/adherents/cartes/carte.php
@@ -63,19 +63,24 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
$arrayofmembers = array();
// request taking into account member with up to date subscriptions
- $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
+ $sql = "SELECT d.rowid, d.ref, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
$sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
$sql .= " t.libelle as type,";
$sql .= " c.code as country_code, c.label as country";
// Add fields from extrafields
- if (!empty($extrafields->attributes[$object->table_element]['label']))
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
+ if (!empty($extrafields->attributes[$object->table_element]['label'])) {
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
+ }
+ }
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
- if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
+ if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
+ }
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
$sql .= " AND d.entity IN (".getEntity('adherent').")";
- if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid;
+ if (is_numeric($foruserid)) $sql .= " AND d.rowid=".(int) $foruserid;
if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
$sql .= " ORDER BY d.rowid ASC";
@@ -90,6 +95,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
if ($objp->country == '-') $objp->country = '';
$adherentstatic->id = $objp->rowid;
+ $adherentstatic->ref = $objp->ref;
$adherentstatic->lastname = $objp->lastname;
$adherentstatic->firstname = $objp->firstname;
@@ -110,6 +116,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
// List of values to scan for a replacement
$substitutionarray = array(
'__ID__'=>$objp->rowid,
+ '__REF__'=>$objp->ref,
'__LOGIN__'=>$objp->login,
'__FIRSTNAME__'=>$objp->firstname,
'__LASTNAME__'=>$objp->lastname,
@@ -149,6 +156,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
'textfooter'=>$textfooter,
'textright'=>$textright,
'id'=>$objp->rowid,
+ 'ref'=>$objp->ref,
'photo'=>$objp->photo
);
}
@@ -159,6 +167,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
'textfooter'=>$textfooter,
'textright'=>$textright,
'id'=>$objp->rowid,
+ 'ref'=>$objp->ref,
'photo'=>$objp->photo
);
}
@@ -172,12 +181,15 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
$textfooter = '';
$textright = '';
- $arrayofmembers[] = array('textleft'=>$textleft,
- 'textheader'=>$textheader,
- 'textfooter'=>$textfooter,
- 'textright'=>$textright,
- 'id'=>$objp->rowid,
- 'photo'=>$objp->photo);
+ $arrayofmembers[] = array(
+ 'textleft'=>$textleft,
+ 'textheader'=>$textheader,
+ 'textfooter'=>$textfooter,
+ 'textright'=>$textright,
+ 'id'=>$objp->rowid,
+ 'ref'=>$objp->ref,
+ 'photo'=>$objp->photo,
+ );
}
$i++;
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index b26d45c34e2..c87c1d90b0d 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -288,6 +288,7 @@ class Adherent extends CommonObject
*/
public $fields = array(
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10),
+ 'ref' => array('type' => 'varchar(30)', 'label' => 'Ref', 'default' => 1, 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 12, 'index' => 1),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20),
'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25),
@@ -417,6 +418,7 @@ class Adherent extends CommonObject
$infos = '';
if ($this->civility_id) $infos .= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel()."\n";
$infos .= $langs->transnoentities("id").": ".$this->id."\n";
+ $infos .= $langs->transnoentities("ref").": ".$this->ref."\n";
$infos .= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
$infos .= $langs->transnoentities("Firstname").": ".$this->firstname."\n";
$infos .= $langs->transnoentities("Company").": ".$this->company."\n";
@@ -438,15 +440,20 @@ class Adherent extends CommonObject
// Substitutions
$substitutionarray = array(
- '__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(),
+ '__ID__' => $this->id,
+ '__REF__' => $this->ref,
+ '__MEMBER_ID__' => $this->id,
+ '__CIVILITY__' => $this->getCivilityLabel(),
'__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''),
'__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''),
'__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs),
'__COMPANY__' => $msgishtml ? dol_htmlentitiesbr($this->company) : ($this->company ? $this->company : ''),
'__ADDRESS__' => $msgishtml ? dol_htmlentitiesbr($this->address) : ($this->address ? $this->address : ''),
- '__ZIP__' => $msgishtml ? dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''), '__TOWN__' => $msgishtml ? dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''),
+ '__ZIP__' => $msgishtml ? dol_htmlentitiesbr($this->zip) : ($this->zip ? $this->zip : ''),
+ '__TOWN__' => $msgishtml ? dol_htmlentitiesbr($this->town) : ($this->town ? $this->town : ''),
'__COUNTRY__' => $msgishtml ? dol_htmlentitiesbr($this->country) : ($this->country ? $this->country : ''),
- '__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''), '__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''),
+ '__EMAIL__' => $msgishtml ? dol_htmlentitiesbr($this->email) : ($this->email ? $this->email : ''),
+ '__BIRTH__' => $msgishtml ? dol_htmlentitiesbr($birthday) : ($birthday ? $birthday : ''),
'__PHOTO__' => $msgishtml ? dol_htmlentitiesbr($this->photo) : ($this->photo ? $this->photo : ''),
'__LOGIN__' => $msgishtml ? dol_htmlentitiesbr($this->login) : ($this->login ? $this->login : ''),
'__PASSWORD__' => $msgishtml ? dol_htmlentitiesbr($this->pass) : ($this->pass ? $this->pass : ''),
@@ -519,9 +526,10 @@ class Adherent extends CommonObject
// Insert member
$sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent";
- $sql .= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)";
+ $sql .= " (ref, datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity,import_key)";
$sql .= " VALUES (";
- $sql .= " '".$this->db->idate($this->datec)."'";
+ $sql .= " '(PROV)'";
+ $sql .= ", '".$this->db->idate($this->datec)."'";
$sql .= ", ".($this->login ? "'".$this->db->escape($this->login)."'" : "null");
$sql .= ", ".($user->id > 0 ? $user->id : "null"); // Can be null because member can be created by a guest or a script
$sql .= ", null, null, '".$this->db->escape($this->morphy)."'";
@@ -635,7 +643,8 @@ class Adherent extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
- $sql .= " civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null");
+ $sql .= " ref = '".$this->db->escape($this->ref)."'";
+ $sql .= ", civility = ".($this->civility_id ? "'".$this->db->escape($this->civility_id)."'" : "null");
$sql .= ", firstname = ".($this->firstname ? "'".$this->db->escape($this->firstname)."'" : "null");
$sql .= ", lastname = ".($this->lastname ? "'".$this->db->escape($this->lastname)."'" : "null");
$sql .= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
@@ -752,6 +761,7 @@ class Adherent extends CommonObject
// If option ADHERENT_LOGIN_NOT_REQUIRED is on, there is no login of member, so we do not overwrite user login to keep existing one.
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $luser->login = $this->login;
+ $luser->ref = $this->ref;
$luser->civility_id = $this->civility_id;
$luser->firstname = $this->firstname;
$luser->lastname = $this->lastname;
@@ -1242,7 +1252,8 @@ class Adherent extends CommonObject
{
global $langs;
- $sql = "SELECT d.rowid, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname, d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
+ $sql = "SELECT d.rowid, d.ref, d.ref_ext, d.civility as civility_code, d.gender, d.firstname, d.lastname,";
+ $sql .= " d.societe as company, d.fk_soc, d.statut, d.public, d.address, d.zip, d.town, d.note_private,";
$sql .= " d.note_public,";
$sql .= " d.email, d.socialnetworks, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass, d.pass_crypted,";
$sql .= " d.photo, d.fk_adherent_type, d.morphy, d.entity,";
@@ -1268,7 +1279,7 @@ class Adherent extends CommonObject
} elseif ($ref || $fk_soc) {
$sql .= " AND d.entity IN (".getEntity('adherent').")";
if ($ref) {
- $sql .= " AND d.rowid='".$this->db->escape($ref)."'";
+ $sql .= " AND d.ref='".$this->db->escape($ref)."'";
} elseif ($fk_soc > 0) {
$sql .= " AND d.fk_soc=".((int) $fk_soc);
}
@@ -1283,8 +1294,8 @@ class Adherent extends CommonObject
$obj = $this->db->fetch_object($resql);
$this->entity = $obj->entity;
- $this->ref = $obj->rowid;
$this->id = $obj->rowid;
+ $this->ref = $obj->ref;
$this->ref_ext = $obj->ref_ext;
$this->civility_id = $obj->civility_code; // Bad. Kept for backard compatibility
@@ -2072,7 +2083,7 @@ class Adherent extends CommonObject
if ($mode == 'login') {
$result .= dol_trunc($this->login, $maxlen);
} elseif ($mode == 'ref') {
- $result .= $this->id;
+ $result .= $this->ref;
} else {
$result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen);
}
@@ -2317,6 +2328,7 @@ class Adherent extends CommonObject
// Initialise parametres
$this->id = 0;
+ $this->ref = 'ABC001';
$this->entity = 1;
$this->specimen = 1;
$this->civility_id = 0;
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index ac9260d091e..87eec3676f8 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -101,7 +101,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
- 'd.rowid'=>'Ref',
+ 'd.ref'=>'Ref',
'd.login'=>'Login',
'd.lastname'=>'Lastname',
'd.firstname'=>'Firstname',
@@ -247,7 +247,7 @@ $memberstatic = new Adherent($db);
$now = dol_now();
-$sql = "SELECT d.rowid, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
+$sql = "SELECT d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe as company, d.fk_soc,";
$sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,";
$sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.public, d.photo,";
$sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
@@ -264,8 +264,13 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
-if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
-if (!empty($search_categ) || !empty($catid)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member"; // We need this table joined to the select in order to filter by categ
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (d.rowid = ef.fk_object)";
+}
+if (!empty($search_categ) || !empty($catid)) {
+ // We need this table joined to the select in order to filter by categ
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member";
+}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
@@ -281,10 +286,12 @@ if ($search_type > 0) $sql .= " AND t.rowid=".$db->escape($search_type);
if ($search_filter == 'withoutsubscription') $sql .= " AND (datefin IS NULL OR t.subscription = 0)";
if ($search_filter == 'uptodate') $sql .= " AND (datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
if ($search_filter == 'outofdate') $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
-if ($search_status != '') $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
+if ($search_status != '') {
+ // Peut valoir un nombre ou liste de nombre separes par virgules
+ $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
+}
if ($search_ref) {
- if (is_numeric($search_ref)) $sql .= " AND (d.rowid = ".$db->escape($search_ref).")";
- else $sql .= " AND 1 = 2"; // Always wrong
+ $sql .= natural_search("d.ref", $search_ref);
}
if ($search_civility) $sql .= natural_search("d.civility", $search_civility);
if ($search_firstname) $sql .= natural_search("d.firstname", $search_firstname);
@@ -604,7 +611,7 @@ print "\n";
print '';
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder);
-if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.rowid', '', $param, '', $sortfield, $sortorder);
+if (!empty($arrayfields['d.ref']['checked'])) print_liste_field_titre($arrayfields['d.ref']['label'], $_SERVER["PHP_SELF"], 'd.ref', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['d.civility']['checked'])) print_liste_field_titre($arrayfields['d.civility']['label'], $_SERVER["PHP_SELF"], 'd.civility', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['d.firstname']['checked'])) print_liste_field_titre($arrayfields['d.firstname']['label'], $_SERVER["PHP_SELF"], 'd.firstname', '', $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['d.lastname']['checked'])) print_liste_field_titre($arrayfields['d.lastname']['label'], $_SERVER["PHP_SELF"], 'd.lastname', '', $param, '', $sortfield, $sortorder);
@@ -644,7 +651,7 @@ while ($i < min($num, $limit)) {
$datefin = $db->jdate($obj->datefin);
$memberstatic->id = $obj->rowid;
- $memberstatic->ref = $obj->rowid;
+ $memberstatic->ref = $obj->ref;
$memberstatic->civility_id = $obj->civility;
$memberstatic->lastname = $obj->lastname;
$memberstatic->firstname = $obj->firstname;
diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php
index bc6b0dc33ac..6523ec833b3 100644
--- a/htdocs/admin/fckeditor.php
+++ b/htdocs/admin/fckeditor.php
@@ -21,7 +21,7 @@
/**
* \file htdocs/admin/fckeditor.php
* \ingroup fckeditor
- * \brief Page d'activation du module FCKeditor dans les autres modules
+ * \brief Activation page for the FCKeditor module in the other modules
*/
require '../main.inc.php';
@@ -43,35 +43,41 @@ $mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes';
if (!$user->admin) accessforbidden();
-// Constante et traduction de la description du module
+// Constant and translation of the module description
$modules = array(
-'SOCIETE' => 'FCKeditorForCompany',
-'PRODUCTDESC' => 'FCKeditorForProduct',
-'DETAILS' => 'FCKeditorForProductDetails',
-'USERSIGN' => 'FCKeditorForUserSignature',
-'MAILING' => 'FCKeditorForMailing',
-'MAIL' => 'FCKeditorForMail',
-'TICKET' => 'FCKeditorForTicket'
+ 'SOCIETE' => 'FCKeditorForCompany',
+ 'PRODUCTDESC' => 'FCKeditorForProduct',
+ 'DETAILS' => 'FCKeditorForProductDetails',
+ 'USERSIGN' => 'FCKeditorForUserSignature',
+ 'MAILING' => 'FCKeditorForMailing',
+ 'MAIL' => 'FCKeditorForMail',
+ 'TICKET' => 'FCKeditorForTicket',
+ 'NOTE_PUBLIC' => 'FCKeditorForNotePublic',
+ 'NOTE_PRIVATE' => 'FCKeditorForNotePrivate',
);
-// Conditions pour que l'option soit proposee
+// Conditions for the option to be offered
$conditions = array(
-'SOCIETE' => 1,
-'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)),
-'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
-'USERSIGN' => 1,
-'MAILING' => !empty($conf->mailing->enabled),
-'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)),
-'TICKET' => !empty($conf->ticket->enabled)
+ 'SOCIETE' => 1,
+ 'PRODUCTDESC' => (!empty($conf->product->enabled) || !empty($conf->service->enabled)),
+ 'DETAILS' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->supplier_proposal->enabled) || !empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)),
+ 'USERSIGN' => 1,
+ 'MAILING' => !empty($conf->mailing->enabled),
+ 'MAIL' => (!empty($conf->facture->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)),
+ 'TICKET' => !empty($conf->ticket->enabled),
+ 'NOTE_PUBLIC' => 1,
+ 'NOTE_PRIVATE' => 1,
);
// Picto
$picto = array(
-'SOCIETE' => 'generic',
-'PRODUCTDESC' => 'product',
-'DETAILS' => 'product',
-'USERSIGN' => 'user',
-'MAILING' => 'email',
-'MAIL' => 'email',
-'TICKET' => 'ticket'
+ 'SOCIETE' => 'generic',
+ 'PRODUCTDESC' => 'product',
+ 'DETAILS' => 'product',
+ 'USERSIGN' => 'user',
+ 'MAILING' => 'email',
+ 'MAIL' => 'email',
+ 'TICKET' => 'ticket',
+ 'NOTE_PUBLIC' => 'generic',
+ 'NOTE_PRIVATE' => 'generic',
);
@@ -85,7 +91,7 @@ foreach ($modules as $const => $desc)
if ($action == 'activate_'.strtolower($const))
{
dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity);
- // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires
+ // If fckeditor is active in the product/service description, it is activated in the forms
if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM))
{
dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity);
@@ -154,7 +160,7 @@ if (empty($conf->use_javascript_ajax))
// Modules
foreach ($modules as $const => $desc)
{
- // Si condition non remplie, on ne propose pas l'option
+ // If this condition is not met, the option is not offered
if (!$conditions[$const]) continue;
print ' ';
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index f4b7e12cc30..a5578032a3d 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -35,10 +35,10 @@ $langs->load("categories");
$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alphanohtml');
-$type = GETPOST('type', 'aZ09'); // Can be int or string
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
$confirm = GETPOST('confirm');
$cancel = GETPOST('cancel', 'alpha');
+$backtopage = GETPOST('backtopage', 'alpha');
$socid = (int) GETPOST('socid', 'int');
$label = (string) GETPOST('label', 'alphanohtml');
@@ -56,10 +56,14 @@ if ($id == "") {
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
-if ($id > 0) {
- $result = $object->fetch($id);
+$result = $object->fetch($id, $label);
+if ($result <= 0) {
+ dol_print_error($db, $object->error); exit;
}
+$type = $object->type;
+if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
+
$extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element);
@@ -74,8 +78,13 @@ $error = 0;
*/
if ($cancel) {
- header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
- exit;
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ } else {
+ header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
+ exit;
+ }
}
// Action mise a jour d'une categorie
@@ -98,9 +107,15 @@ if ($action == 'update' && $user->rights->categorie->creer) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
- if (!$error && $object->update($user) > 0) {
- header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
- exit;
+ if (!$error && $object->update($user) > 0)
+ {
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ } else {
+ header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
+ exit;
+ }
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
@@ -131,6 +146,7 @@ print ' ';
print ' ';
print ' ';
print ' ';
+print ' ';
print dol_get_fiche_head('');
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index 5adc7bbb17b..ff897db86a7 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -109,7 +109,7 @@ if (empty($nosearch)) {
foreach ($cats as $cat)
{
- $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #bbb"';
+ $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
print "\t".' '."\n";
print "\t\t";
@@ -160,26 +160,45 @@ foreach ($fulltree as $key => $val)
$categstatic->ref = $val['label'];
$categstatic->color = $val['color'];
$categstatic->type = $type;
- $li = $categstatic->getNomUrl(1, '', 60, $moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
$desc = dol_htmlcleanlastbr($val['description']);
$counter = '';
-
if ($conf->global->CATEGORY_SHOW_COUNTS)
{
// we need only a count of the elements, so it is enough to consume only the id's from the database
- $elements = $categstatic->getObjectsInCateg($type, 1);
+ $elements = $type == Categorie::TYPE_ACCOUNT
+ ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
+ : $categstatic->getObjectsInCateg($type, 1);
+
$counter = " ".(is_countable($elements) ? count($elements) : '0')." ";
}
$color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
+ $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
- $data[] = array(
- 'rowid'=>$val['rowid'],
- 'fk_menu'=>$val['fk_parent'],
- 'entry'=>''
- );
+ $entry = '';
+ $entry .= '';
+
+ $entry .= '';
+ $entry .= ''.$li.' ';
+ $entry .= ' ';
+
+ $entry .= $counter;
+
+ $entry .= '';
+ $entry .= ''.img_view().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_edit().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_delete().' ';
+ $entry .= ' ';
+
+ $entry .= ' ';
+ $entry .= '
';
+
+ $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
}
@@ -194,7 +213,6 @@ if (!empty($conf->use_javascript_ajax))
print ' ';
$nbofentries = (count($data) - 1);
-
if ($nbofentries > 0)
{
print '';
diff --git a/htdocs/categories/info.php b/htdocs/categories/info.php
index f64f3be8f9e..536b0c20a2c 100644
--- a/htdocs/categories/info.php
+++ b/htdocs/categories/info.php
@@ -37,16 +37,18 @@ $langs->loadLangs(array('categories', 'sendings'));
$socid = 0;
$id = GETPOST('id', 'int');
+$label = GETPOST('label', 'alpha');
// Security check
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
-if (!$object->fetch($id) > 0) {
- dol_print_error($db);
- exit;
+$result = $object->fetch($id, $label);
+if ($result <= 0) {
+ dol_print_error($db, $object->error); exit;
}
+
$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
@@ -63,11 +65,11 @@ llxHeader('', $langs->trans('Categories'), '');
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
$head = categories_prepare_head($object, $type);
-
print dol_get_fiche_head($head, 'info', $langs->trans($title), -1, 'category');
+
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
$linkback = ''.$langs->trans("BackToList").' ';
-$object->next_prev_filter = ' type = '.$type;
+$object->next_prev_filter = ' type = '.$object->type;
$object->ref = $object->label;
$morehtmlref = ''.$langs->trans("Root").' >> ';
$ways = $object->print_all_ways(" >> ", '', 1);
diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php
index 73c7664f6c2..6bb5d79980c 100644
--- a/htdocs/categories/photos.php
+++ b/htdocs/categories/photos.php
@@ -38,7 +38,6 @@ $langs->loadlangs(array('categories', 'bills'));
$id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha');
-$type = GETPOST('type');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm');
@@ -52,18 +51,16 @@ if ($id == '' && $label == '')
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
-$result = $object->fetch($id, $label, $type);
+$result = $object->fetch($id, $label);
if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
-$object->fetch_optionals();
-if ($result <= 0) {
- dol_print_error($db, $object->error); exit;
-}
-$upload_dir = $conf->categorie->multidir_output[$object->entity];
+$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
+$upload_dir = $conf->categorie->multidir_output[$object->entity];
+
/*
* Actions
*/
@@ -115,8 +112,6 @@ if ($object->id)
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
$head = categories_prepare_head($object, $type);
-
-
print dol_get_fiche_head($head, 'photos', $langs->trans($title), -1, 'category');
$linkback = '
'.$langs->trans("BackToList").' ';
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index 423819c49ac..898484d0d51 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -39,7 +39,6 @@ $id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
-$type = GETPOST('type', 'aZ09');
if ($id == '' && $label == '')
{
@@ -51,15 +50,12 @@ if ($id == '' && $label == '')
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
-$result = $object->fetch($id, $label, $type);
-if ($result <= 0) {
- dol_print_error($db, $object->error); exit;
-}
-$object->fetch_optionals();
+$result = $object->fetch($id, $label);
if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
+$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
/*
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 864de6e2e98..93b162e4f28 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -38,7 +38,6 @@ $langs->load("categories");
$id = GETPOST('id', 'int');
$label = GETPOST('label', 'alpha');
-$type = GETPOST('type', 'aZ09');
$removeelem = GETPOST('removeelem', 'int');
$elemid = GETPOST('elemid', 'int');
@@ -73,19 +72,12 @@ if ($id == "" && $label == "")
$result = restrictedArea($user, 'categorie', $id, '&category');
$object = new Categorie($db);
-$result = $object->fetch($id, $label, $type);
-if ($result <= 0) {
- dol_print_error($db, $object->error); exit;
-}
-$object->fetch_optionals();
+$result = $object->fetch($id, $label);
if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
-$objecttype = $object->type;
-if (is_numeric($objecttype)) $objecttype = Categorie::$MAP_ID_TO_CODE[$objecttype];
-if ($type === '') $type = $objecttype;
-
+$type = $object->type;
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
$extrafields = new ExtraFields($db);
@@ -94,16 +86,18 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard', 'globalcard'));
-// Protection when type provided is not similare to type of category
-if ($objecttype != $type) {
- print 'Error: Value for type parameter does not match value of the type of the category with id='.$id;
- exit;
-}
-
/*
* Actions
*/
+if ($confirm == 'no')
+{
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ }
+}
+
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Remove element from category
@@ -164,8 +158,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
{
if ($object->delete($user) >= 0)
{
- header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
- exit;
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ } else {
+ header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
+ exit;
+ }
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
@@ -226,9 +225,8 @@ llxHeader("", $langs->trans("Categories"), $helpurl, '', 0, 0, $arrayofjs, $arra
$title = Categorie::$MAP_TYPE_TITLE_AREA[$type];
$head = categories_prepare_head($object, $type);
-
-
print dol_get_fiche_head($head, 'card', $langs->trans($title), -1, 'category');
+
$backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type);
$linkback = '
'.$langs->trans("BackToList").' ';
$object->next_prev_filter = ' type = '.$object->type;
@@ -250,7 +248,11 @@ dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'la
if ($action == 'delete')
{
- print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
+ if ($backtopage) {
+ print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
+ } else {
+ print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
+ }
}
print '
';
@@ -294,7 +296,7 @@ if ($user->rights->categorie->creer)
if ($user->rights->categorie->supprimer)
{
- print '
id.'&type='.$type.'">'.$langs->trans("Delete").' ';
+ print '
id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").' ';
}
print "
";
@@ -376,8 +378,7 @@ if ($cats < 0)
$categstatic->type = $type;
$desc = dol_htmlcleanlastbr($val['description']);
- $counter = 0;
-
+ $counter = '';
if ($conf->global->CATEGORY_SHOW_COUNTS)
{
// we need only a count of the elements, so it is enough to consume only the id's from the database
@@ -385,22 +386,29 @@ if ($cats < 0)
? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
: $categstatic->getObjectsInCateg($type, 1);
- $counter = is_countable($elements) ? count($elements) : 0;
+ $counter = " ".(is_countable($elements) ? count($elements) : '0')." ";
}
- $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"';
+ $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
+ $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type));
$entry = '';
$entry .= '';
$entry .= '';
- $entry .= ''.$categstatic->getNomUrl(1, '', 60).' ';
+ $entry .= ''.$li.' ';
$entry .= ' ';
- $entry .= ''.$counter.' ';
+ $entry .= $counter;
$entry .= '';
- $entry .= ''.img_view().' ';
+ $entry .= ''.img_view().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_edit().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_delete().' ';
$entry .= ' ';
$entry .= ' ';
@@ -409,7 +417,8 @@ if ($cats < 0)
$data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
}
- if ((count($data) - 1))
+ $nbofentries = (count($data) - 1);
+ if ($nbofentries > 0)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
print '';
diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php
index d5187bb2ab8..e045401bef4 100644
--- a/htdocs/comm/mailing/card.php
+++ b/htdocs/comm/mailing/card.php
@@ -23,7 +23,9 @@
* \brief Fiche mailing, onglet general
*/
-if (!defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1');
+if (!defined('NOSTYLECHECK')) {
+ define('NOSTYLECHECK', '1');
+}
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php';
@@ -38,7 +40,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
// Load translation files required by the page
$langs->load("mails");
-if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) accessforbidden();
+if (!$user->rights->mailing->lire || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) {
+ accessforbidden();
+}
$id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int'));
$action = GETPOST('action', 'aZ09');
@@ -83,20 +87,18 @@ $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
$parameters = array();
$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)) {
// Action clone object
- if ($action == 'confirm_clone' && $confirm == 'yes')
- {
- if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha'))
- {
+ if ($action == 'confirm_clone' && $confirm == 'yes') {
+ if (!GETPOST("clone_content", 'alpha') && !GETPOST("clone_receivers", 'alpha')) {
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
} else {
$result = $object->createFromClone($user, $object->id, GETPOST("clone_content", 'alpha'), GETPOST("clone_receivers", 'alpha'));
- if ($result > 0)
- {
+ if ($result > 0) {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
exit;
} else {
@@ -107,24 +109,20 @@ if (empty($reshook))
}
// Action send emailing for everybody
- if ($action == 'sendallconfirmed' && $confirm == 'yes')
- {
- if (empty($conf->global->MAILING_LIMIT_SENDBYWEB))
- {
+ if ($action == 'sendallconfirmed' && $confirm == 'yes') {
+ if (empty($conf->global->MAILING_LIMIT_SENDBYWEB)) {
// As security measure, we don't allow send from the GUI
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessages('', null, 'warnings');
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings');
$action = '';
- } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
- {
+ } elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings');
$action = '';
} else {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
- if ($object->statut == 0)
- {
+ if ($object->statut == 0) {
dol_print_error('', 'ErrorMailIsNotValidated');
exit;
}
@@ -137,7 +135,9 @@ if (empty($reshook))
$errorsto = $object->email_errorsto;
// Is the message in html
$msgishtml = -1; // Unknown by default
- if (preg_match('/[\s\t]*/i', $message)) $msgishtml = 1;
+ if (preg_match('/[\s\t]*/i', $message)) {
+ $msgishtml = 1;
+ }
// Warning, we must not use begin-commit transaction here
// because we want to save update for each mail sent.
@@ -153,12 +153,10 @@ if (empty($reshook))
dol_syslog("card.php: select targets", LOG_DEBUG);
$resql = $db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $db->num_rows($resql); // Number of possible recipients
- if ($num)
- {
+ if ($num) {
dol_syslog("comm/mailing/card.php: nb of targets = ".$num, LOG_DEBUG);
$now = dol_now();
@@ -166,16 +164,14 @@ if (empty($reshook))
// Positioning date of start sending
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET date_envoi='".$db->idate($now)."' WHERE rowid=".$object->id;
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
dol_print_error($db);
}
// Loop on each email and send it
$i = 0;
- while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB)
- {
+ while ($i < $num && $i < $conf->global->MAILING_LIMIT_SENDBYWEB) {
// Here code is common with same loop ino mailing-send.php
$res = 1;
$now = dol_now();
@@ -215,14 +211,18 @@ if (empty($reshook))
$substitutionarray['__UNSUBSCRIBE__'] = ''.$langs->trans("MailUnsubcribe").' ';
$onlinepaymentenabled = 0;
- if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++;
- if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++;
- if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++;
- if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
+ if (!empty($conf->paypal->enabled)) {
+ $onlinepaymentenabled++;
+ }
+ if (!empty($conf->paybox->enabled)) {
+ $onlinepaymentenabled++;
+ }
+ if (!empty($conf->stripe->enabled)) {
+ $onlinepaymentenabled++;
+ }
+ if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
$substitutionarray['__SECUREKEYPAYMENT__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
- if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
- {
+ if (empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
$substitutionarray['__SECUREKEYPAYMENT_MEMBER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
$substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2);
@@ -235,21 +235,32 @@ if (empty($reshook))
}
}
/* For backward compatibility, deprecated */
- if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN))
- {
+ if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
$substitutionarray['__SECUREKEYPAYPAL__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
- if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
+ if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
+ $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
+ } else {
+ $substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'membersubscription'.$obj->source_id, 2);
+ }
- if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2);
+ if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
+ $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
+ } else {
+ $substitutionarray['__SECUREKEYPAYPAL_ORDER__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'order'.$obj->source_id, 2);
+ }
- if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
+ if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
+ $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
+ } else {
+ $substitutionarray['__SECUREKEYPAYPAL_INVOICE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'invoice'.$obj->source_id, 2);
+ }
- if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
- else $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
+ if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
+ $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2);
+ } else {
+ $substitutionarray['__SECUREKEYPAYPAL_CONTRACTLINE__'] = dol_hash($conf->global->PAYPAL_SECURITY_TOKEN.'contractline'.$obj->source_id, 2);
+ }
}
//$substitutionisok=true;
@@ -263,10 +274,8 @@ if (empty($reshook))
$arr_css = array();
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
- if (count($listofpaths))
- {
- foreach ($listofpaths as $key => $val)
- {
+ if (count($listofpaths)) {
+ foreach ($listofpaths as $key => $val) {
$arr_file[] = $listofpaths[$key]['fullname'];
$arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
$arr_name[] = $listofpaths[$key]['name'];
@@ -277,8 +286,7 @@ if (empty($reshook))
$trackid = 'emailing-'.$obj->fk_mailing.'-'.$obj->rowid;
$mail = new CMailFile($newsubject, $sendto, $from, $newmessage, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $errorsto, $arr_css, $trackid, '', 'emailing');
- if ($mail->error)
- {
+ if ($mail->error) {
$res = 0;
}
/*if (! $substitutionisok)
@@ -288,13 +296,11 @@ if (empty($reshook))
}*/
// Send mail
- if ($res)
- {
+ if ($res) {
$res = $mail->sendfile();
}
- if ($res)
- {
+ if ($res) {
// Mail successful
$nbok++;
@@ -303,19 +309,16 @@ if (empty($reshook))
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " SET statut=1, date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid;
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
dol_print_error($db);
} else {
//if cheack read is use then update prospect contact status
- if (strpos($message, '__CHECK_READ__') !== false)
- {
+ if (strpos($message, '__CHECK_READ__') !== false) {
//Update status communication of thirdparty prospect
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=2 WHERE rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE rowid=".$obj->rowid.")";
dol_syslog("card.php: set prospect thirdparty status", LOG_DEBUG);
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
dol_print_error($db);
}
@@ -324,17 +327,16 @@ if (empty($reshook))
dol_syslog("card.php: set prospect contact status", LOG_DEBUG);
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
dol_print_error($db);
}
}
}
- if (!empty($conf->global->MAILING_DELAY)) {
- dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
- usleep((float) $conf->global->MAILING_DELAY * 1000000);
- }
+ if (!empty($conf->global->MAILING_DELAY)) {
+ dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
+ usleep((float) $conf->global->MAILING_DELAY * 1000000);
+ }
//test if CHECK READ change statut prospect contact
} else {
@@ -346,8 +348,7 @@ if (empty($reshook))
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles";
$sql .= " SET statut=-1, error_text='".$db->escape($mail->error)."', date_envoi='".$db->idate($now)."' WHERE rowid=".$obj->rowid;
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
dol_print_error($db);
}
}
@@ -359,14 +360,15 @@ if (empty($reshook))
}
// Loop finished, set global statut of mail
- if ($nbko > 0)
- {
+ if ($nbko > 0) {
$statut = 2; // Status 'sent partially' (because at least one error)
- if ($nbok > 0) setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
- else setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
+ if ($nbok > 0) {
+ setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
+ } else {
+ setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
+ }
} else {
- if ($nbok >= $num)
- {
+ if ($nbok >= $num) {
$statut = 3; // Send to everybody
setEventMessages($langs->transnoentitiesnoconv("EMailSentToNRecipients", $nbok), null, 'mesgs');
} else {
@@ -378,8 +380,7 @@ if (empty($reshook))
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing SET statut=".$statut." WHERE rowid=".$object->id;
dol_syslog("comm/mailing/card.php: update global status", LOG_DEBUG);
$resql2 = $db->query($sql);
- if (!$resql2)
- {
+ if (!$resql2) {
dol_print_error($db);
}
} else {
@@ -392,24 +393,23 @@ if (empty($reshook))
}
// Action send test emailing
- if ($action == 'send' && empty($_POST["cancel"]))
- {
+ if ($action == 'send' && empty($_POST["cancel"])) {
$error = 0;
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
$object->sendto = $_POST["sendto"];
- if (!$object->sendto)
- {
+ if (!$object->sendto) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MailTo")), null, 'errors');
$error++;
}
- if (!$error)
- {
+ if (!$error) {
// Is the message in html
$msgishtml = -1; // Unknow by default
- if (preg_match('/[\s\t]*/i', $object->body)) $msgishtml = 1;
+ if (preg_match('/[\s\t]*/i', $object->body)) {
+ $msgishtml = 1;
+ }
// other are set at begin of page
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto;
@@ -426,15 +426,17 @@ if (empty($reshook))
$arr_css = array();
// Add CSS
- if (!empty($object->bgcolor)) $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor;
- if (!empty($object->bgimage)) $arr_css['bgimage'] = $object->bgimage;
+ if (!empty($object->bgcolor)) {
+ $arr_css['bgcolor'] = (preg_match('/^#/', $object->bgcolor) ? '' : '#').$object->bgcolor;
+ }
+ if (!empty($object->bgimage)) {
+ $arr_css['bgimage'] = $object->bgimage;
+ }
// Attached files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
- if (count($listofpaths))
- {
- foreach ($listofpaths as $key => $val)
- {
+ if (count($listofpaths)) {
+ foreach ($listofpaths as $key => $val) {
$arr_file[] = $listofpaths[$key]['fullname'];
$arr_mime[] = dol_mimetype($listofpaths[$key]['name']);
$arr_name[] = $listofpaths[$key]['name'];
@@ -445,8 +447,7 @@ if (empty($reshook))
$mailfile = new CMailFile($tmpsujet, $object->sendto, $object->email_from, $tmpbody, $arr_file, $arr_mime, $arr_name, '', '', 0, $msgishtml, $object->email_errorsto, $arr_css, $trackid, '', 'emailing');
$result = $mailfile->sendfile();
- if ($result)
- {
+ if ($result) {
setEventMessages($langs->trans("MailSuccessfulySent", $mailfile->getValidAddress($object->email_from, 2), $mailfile->getValidAddress($object->sendto, 2)), null, 'mesgs');
$action = '';
} else {
@@ -457,18 +458,17 @@ if (empty($reshook))
}
// Action add emailing
- if ($action == 'add')
- {
+ if ($action == 'add') {
$mesgs = array();
- $object->email_from = GETPOST("from", "none"); // Must allow 'name '
- $object->email_replyto = GETPOST("replyto", "none"); // Must allow 'name '
- $object->email_errorsto = GETPOST("errorsto", "none"); // Must allow 'name '
- $object->title = GETPOST("title");
- $object->sujet = GETPOST("sujet");
- $object->body = GETPOST("bodyemail", 'restricthtml');
- $object->bgcolor = GETPOST("bgcolor");
- $object->bgimage = GETPOST("bgimage");
+ $object->email_from = (string) GETPOST("from", "none"); // Must allow 'name '
+ $object->email_replyto = (string) GETPOST("replyto", "none"); // Must allow 'name '
+ $object->email_errorsto = (string) GETPOST("errorsto", "none"); // Must allow 'name '
+ $object->title = (string) GETPOST("title");
+ $object->sujet = (string) GETPOST("sujet");
+ $object->body = (string) GETPOST("bodyemail", 'restricthtml');
+ $object->bgcolor = (string) GETPOST("bgcolor");
+ $object->bgimage = (string) GETPOST("bgimage");
if (!$object->title) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
@@ -480,10 +480,8 @@ if (empty($reshook))
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage"));
}
- if (!count($mesgs))
- {
- if ($object->create($user) >= 0)
- {
+ if (!count($mesgs)) {
+ if ($object->create($user) >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@@ -495,24 +493,25 @@ if (empty($reshook))
}
// Action update description of emailing
- if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto')
- {
+ if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
- if ($action == 'settitle') $object->title = trim(GETPOST('title', 'alpha'));
- elseif ($action == 'setemail_from') $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name '
- elseif ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name '
- elseif ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name '
- elseif ($action == 'settitle' && empty($object->title)) {
+ if ($action == 'settitle') {
+ $object->title = trim(GETPOST('title', 'alpha'));
+ } elseif ($action == 'setemail_from') {
+ $object->email_from = trim(GETPOST('email_from', 'none')); // Must allow 'name '
+ } elseif ($action == 'setemail_replyto') {
+ $object->email_replyto = trim(GETPOST('email_replyto', 'none')); // Must allow 'name '
+ } elseif ($action == 'setemail_errorsto') {
+ $object->email_errorsto = trim(GETPOST('email_errorsto', 'none')); // Must allow 'name '
+ } elseif ($action == 'settitle' && empty($object->title)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle"));
} elseif ($action == 'setfrom' && empty($object->email_from)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom"));
}
- if (!$mesg)
- {
- if ($object->update($user) >= 0)
- {
+ if (!$mesg) {
+ if ($object->update($user) >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@@ -526,8 +525,7 @@ if (empty($reshook))
/*
* Add file in email form
*/
- if (!empty($_POST['addfile']))
- {
+ if (!empty($_POST['addfile'])) {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -539,8 +537,7 @@ if (empty($reshook))
}
// Action of file remove
- if (!empty($_POST["removedfile"]))
- {
+ if (!empty($_POST["removedfile"])) {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -551,20 +548,18 @@ if (empty($reshook))
}
// Action of emailing update
- if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"]))
- {
+ if ($action == 'update' && empty($_POST["removedfile"]) && empty($_POST["cancel"])) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$isupload = 0;
- if (!$isupload)
- {
+ if (!$isupload) {
$mesgs = array();
- $object->sujet = GETPOST("sujet");
- $object->body = GETPOST("bodyemail", 'restricthtml');
- $object->bgcolor = GETPOST("bgcolor");
- $object->bgimage = GETPOST("bgimage");
+ $object->sujet = (string) GETPOST("sujet");
+ $object->body = (string) GETPOST("bodyemail", 'restricthtml');
+ $object->bgcolor = (string) GETPOST("bgcolor");
+ $object->bgimage = (string) GETPOST("bgimage");
if (!$object->sujet) {
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic"));
@@ -573,10 +568,8 @@ if (empty($reshook))
$mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailMessage"));
}
- if (!count($mesgs))
- {
- if ($object->update($user) >= 0)
- {
+ if (!count($mesgs)) {
+ if ($object->update($user) >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
@@ -591,10 +584,8 @@ if (empty($reshook))
}
// Action of validation confirmation
- if ($action == 'confirm_valid' && $confirm == 'yes')
- {
- if ($object->id > 0)
- {
+ if ($action == 'confirm_valid' && $confirm == 'yes') {
+ if ($object->id > 0) {
$object->valid($user);
setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@@ -605,13 +596,10 @@ if (empty($reshook))
}
// Action of validation confirmation
- if ($action == 'confirm_settodraft' && $confirm == 'yes')
- {
- if ($object->id > 0)
- {
+ if ($action == 'confirm_settodraft' && $confirm == 'yes') {
+ if ($object->id > 0) {
$result = $object->setStatut(0);
- if ($result > 0)
- {
+ if ($result > 0) {
//setEventMessages($langs->trans("MailingSuccessfullyValidated"), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
@@ -624,20 +612,16 @@ if (empty($reshook))
}
// Resend
- if ($action == 'confirm_reset' && $confirm == 'yes')
- {
- if ($object->id > 0)
- {
+ if ($action == 'confirm_reset' && $confirm == 'yes') {
+ if ($object->id > 0) {
$db->begin();
$result = $object->valid($user);
- if ($result > 0)
- {
+ if ($result > 0) {
$result = $object->reset_targets_status($user);
}
- if ($result > 0)
- {
+ if ($result > 0) {
$db->commit();
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
@@ -651,18 +635,15 @@ if (empty($reshook))
}
// Action of delete confirmation
- if ($action == 'confirm_delete' && $confirm == 'yes')
- {
- if ($object->delete($object->id))
- {
+ if ($action == 'confirm_delete' && $confirm == 'yes') {
+ if ($object->delete($object->id)) {
$url = (!empty($urlfrom) ? $urlfrom : 'list.php');
header("Location: ".$url);
exit;
}
}
- if (!empty($_POST["cancel"]))
- {
+ if (!empty($_POST["cancel"])) {
$action = '';
}
}
@@ -676,24 +657,30 @@ $form = new Form($db);
$htmlother = new FormOther($db);
$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing';
-llxHeader('', $langs->trans("Mailing"), $help_url, '', 0, 0,
+llxHeader(
+ '',
+ $langs->trans("Mailing"),
+ $help_url,
+ '',
+ 0,
+ 0,
array(
- '/includes/ace/src/ace.js',
- '/includes/ace/src/ext-statusbar.js',
- '/includes/ace/src/ext-language_tools.js',
- //'/includes/ace/src/ext-chromevox.js'
- ), array());
+ '/includes/ace/src/ace.js',
+ '/includes/ace/src/ext-statusbar.js',
+ '/includes/ace/src/ext-language_tools.js',
+ //'/includes/ace/src/ext-chromevox.js'
+ ),
+ array()
+);
-if ($action == 'create')
-{
+if ($action == 'create') {
// EMailing in creation mode
print '';
} else {
- if ($object->id > 0)
- {
+ if ($object->id > 0) {
$upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing');
$head = emailing_prepare_head($object);
- // Confirmation back to draft
- if ($action == 'settodraft')
- {
+ if ($action == 'settodraft') {
+ // Confirmation back to draft
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("SetToDraft"), $langs->trans("ConfirmUnvalidateEmailing"), "confirm_settodraft", '', '', 1);
- }
- // Confirmation of mailing validation
- if ($action == 'valid')
- {
+ } elseif ($action == 'valid') {
+ // Confirmation of mailing validation
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ValidMailing"), $langs->trans("ConfirmValidMailing"), "confirm_valid", '', '', 1);
- } // Confirm reset
- elseif ($action == 'reset')
- {
+ } elseif ($action == 'reset') {
+ // Confirm reset
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("ResetMailing"), $langs->trans("ConfirmResetMailing", $object->ref), "confirm_reset", '', '', 2);
- } // Confirm delete
- elseif ($action == 'delete')
- {
+ } elseif ($action == 'delete') {
+ // Confirm delete
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1);
}
-
- if ($action != 'edit' && $action != 'edithtml')
- {
+ if ($action != 'edit' && $action != 'edithtml') {
print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email');
/*
* View mode mailing
*/
- if ($action == 'sendall')
- {
+ if ($action == 'sendall') {
// Define message to recommand from command line
$sendingmode = $conf->global->EMAILING_MAIL_SENDMODE;
- if (empty($sendingmode)) $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
- if (empty($sendingmode)) $sendingmode = 'mail'; // If not defined, we use php mail function
+ if (empty($sendingmode)) {
+ $sendingmode = $conf->global->MAIN_MAIL_SENDMODE;
+ }
+ if (empty($sendingmode)) {
+ $sendingmode = 'mail'; // If not defined, we use php mail function
+ }
// MAILING_NO_USING_PHPMAIL may be defined or not.
// MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden).
// MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0 or undefined=no limit).
- if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
- {
+ if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') {
// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
// You ensure that every user is using its own SMTP server when using the mass emailing module.
$linktoadminemailbefore = '';
$linktoadminemailend = ' ';
setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings');
setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings');
- if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings');
+ if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) {
+ setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings');
+ }
$_GET["action"] = '';
} elseif ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
- if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings');
- if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings');
+ if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') {
+ setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings');
+ }
+ if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') {
+ setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings');
+ }
// The feature is forbidden from GUI, we show just message to use from command line.
setEventMessages($langs->trans("MailingNeedCommand"), null, 'warnings');
setEventMessages('', null, 'warnings');
- if ($conf->file->mailing_limit_sendbyweb != '-1') // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it.
- {
+ if ($conf->file->mailing_limit_sendbyweb != '-1') { // MAILING_LIMIT_SENDBYWEB was set to -1 in database, but it is allowed ot increase it.
setEventMessages($langs->trans("MailingNeedCommand2"), null, 'warnings'); // You can send online with constant...
}
$_GET["action"] = '';
} else {
- if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings');
- if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings');
+ if (!empty($conf->global->MAILING_LIMIT_WARNING_PHPMAIL) && $sendingmode == 'mail') {
+ setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_PHPMAIL), null, 'warnings');
+ }
+ if (!empty($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL) && $sendingmode != 'mail') {
+ setEventMessages($langs->transnoentitiesnoconv($conf->global->MAILING_LIMIT_WARNING_NOPHPMAIL), null, 'warnings');
+ }
$text = '';
- if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0)
- {
+ if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) {
$text .= $langs->trans("MailingNeedCommand");
$text .= ' ';
$text .= ' ';
@@ -832,13 +820,14 @@ if ($action == 'create')
$morehtmlright = '';
$nbtry = $nbok = 0;
- if ($object->statut == 2 || $object->statut == 3)
- {
+ if ($object->statut == 2 || $object->statut == 3) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
- if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
+ if ($nbko) {
+ $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
+ }
$morehtmlright .= ') ';
}
@@ -892,21 +881,19 @@ if ($action == 'create')
print $langs->trans("TotalNbOfDistinctRecipients");
print '';
$nbemail = ($object->nbemail ? $object->nbemail : 0);
- if (is_numeric($nbemail))
- {
+ if (is_numeric($nbemail)) {
$text = '';
- if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail)))
- {
- if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
- {
+ if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) {
+ if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
$text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
} else {
$text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
}
}
- if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").' ';
- if ($text)
- {
+ if (empty($nbemail)) {
+ $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").' ';
+ }
+ if ($text) {
print $form->textwithpicto($nbemail, $text, 1, 'warning');
} else {
print $nbemail;
@@ -925,8 +912,7 @@ if ($action == 'create')
// Clone confirmation
- if ($action == 'clone')
- {
+ if ($action == 'clone') {
// Create an array for form
$formquestion = array(
'text' => $langs->trans("ConfirmClone"),
@@ -941,81 +927,67 @@ if ($action == 'create')
* Actions Buttons
*/
- if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test')))
- {
+ if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) {
print "\n\n\n";
- if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id))
- {
+ if (($object->statut == 1) && ($user->rights->mailing->valider || $object->fk_user_valid == $user->id)) {
print '
'.$langs->trans("SetToDraft").' ';
}
- if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer)
- {
- if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING))
- {
+ if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) {
+ if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) {
print '
'.$langs->trans("EditWithEditor").' ';
} else {
print '
'.$langs->trans("EditWithTextEditor").' ';
}
- if (!empty($conf->use_javascript_ajax)) print '
'.$langs->trans("EditHTMLSource").' ';
+ if (!empty($conf->use_javascript_ajax)) {
+ print '
'.$langs->trans("EditHTMLSource").' ';
+ }
}
//print '
'.$langs->trans("PreviewMailing").' ';
- if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
- {
+ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
print '
'.$langs->trans("TestMailing").' ';
} else {
print '
'.$langs->trans("TestMailing").' ';
}
- if ($object->statut == 0)
- {
- if ($object->nbemail <= 0)
- {
+ if ($object->statut == 0) {
+ if ($object->nbemail <= 0) {
print '
'.$langs->trans("ValidMailing").' ';
- } elseif (empty($user->rights->mailing->valider))
- {
+ } elseif (empty($user->rights->mailing->valider)) {
print '
'.$langs->trans("ValidMailing").' ';
} else {
print '
'.$langs->trans("ValidMailing").' ';
}
}
- if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider)
- {
- if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
- {
+ if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->rights->mailing->valider) {
+ if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0) {
print '
'.$langs->trans("SendMailing").' ';
- } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
- {
+ } elseif (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
print '
'.$langs->trans("SendMailing").' ';
} else {
print '
'.$langs->trans("SendMailing").' ';
}
}
- if ($user->rights->mailing->creer)
- {
+ if ($user->rights->mailing->creer) {
print '
'.$langs->trans("ToClone").' ';
}
- if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider)
- {
- if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send)
- {
+ if (($object->statut == 2 || $object->statut == 3) && $user->rights->mailing->valider) {
+ if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->send) {
print '
'.$langs->trans("ResetMailing").' ';
} else {
print '
'.$langs->trans("ResetMailing").' ';
}
}
- if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
- {
- if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete))
- {
+ if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer) {
+ if ($object->statut > 0 && (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !$user->rights->mailing->mailing_advance->delete)) {
print '
'.$langs->trans("DeleteMailing").' ';
} else {
print '
'.$langs->trans("DeleteMailing").' ';
@@ -1026,8 +998,7 @@ if ($action == 'create')
}
// Display of the TEST form
- if ($action == 'test')
- {
+ if ($action == 'test') {
print '
';
print load_fiche_titre($langs->trans("TestMailing"));
@@ -1069,8 +1040,7 @@ if ($action == 'create')
$htmltext = '
'.$langs->trans("FollowingConstantsWillBeSubstituted").': ';
- foreach ($object->substitutionarray as $key => $val)
- {
+ foreach ($object->substitutionarray as $key => $val) {
$htmltext .= $key.' = '.$langs->trans($val).' ';
}
$htmltext .= ' ';
@@ -1089,10 +1059,8 @@ if ($action == 'create')
print '
'.$langs->trans("MailFile").' ';
// List of files
$listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0);
- if (count($listofpaths))
- {
- foreach ($listofpaths as $key => $val)
- {
+ if (count($listofpaths)) {
+ foreach ($listofpaths as $key => $val) {
print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
print ' ';
}
@@ -1103,21 +1071,22 @@ if ($action == 'create')
// Background color
/*print ' '.$langs->trans("BackgroundColorByDefault").' ';
- print $htmlother->selectColor($object->bgcolor,'bgcolor','',0);
- print ' ';*/
+ print $htmlother->selectColor($object->bgcolor,'bgcolor','',0);
+ print '
';*/
print '
';
// Message
print '';
- if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') // CKEditor does not apply the color of the div into its content area
- {
+ if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') { // CKEditor does not apply the color of the div into its content area
$readonly = 1;
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', false, true, empty($conf->global->FCKEDITOR_ENABLE_MAILING) ? 0 : 1, 20, '90%', $readonly);
$doleditor->Create();
- } else print dol_htmlentitiesbr($object->body);
+ } else {
+ print dol_htmlentitiesbr($object->body);
+ }
print '
';
print dol_get_fiche_end();
@@ -1131,7 +1100,9 @@ if ($action == 'create')
$linkback = ''.$langs->trans("BackToList").' ';
$morehtmlright = '';
- if ($object->statut == 2) $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
+ if ($object->statut == 2) {
+ $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') ';
+ }
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright);
@@ -1159,21 +1130,19 @@ if ($action == 'create')
print $langs->trans("TotalNbOfDistinctRecipients");
print '';
$nbemail = ($object->nbemail ? $object->nbemail : 0);
- if (is_numeric($nbemail))
- {
+ if (is_numeric($nbemail)) {
$text = '';
- if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2))
- {
- if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0)
- {
+ if ((!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) {
+ if ($conf->global->MAILING_LIMIT_SENDBYWEB > 0) {
$text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB);
} else {
$text .= $langs->trans('SendingFromWebInterfaceIsNotAllowed');
}
}
- if (empty($nbemail)) $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").' ';
- if ($text)
- {
+ if (empty($nbemail)) {
+ $nbemail .= ' '.img_warning('').' '.$langs->trans("NoTargetYet").' ';
+ }
+ if ($text) {
print $form->textwithpicto($nbemail, $text, 1, 'warning');
} else {
print $nbemail;
@@ -1185,8 +1154,7 @@ if ($action == 'create')
$parameters = array();
$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 (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit', $parameters);
}
@@ -1205,8 +1173,7 @@ if ($action == 'create')
print ' ';
$htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").': ';
- foreach ($object->substitutionarray as $key => $val)
- {
+ foreach ($object->substitutionarray as $key => $val) {
$htmltext .= $key.' = '.$langs->trans($val).' ';
}
$htmltext .= ' ';
@@ -1240,10 +1207,8 @@ if ($action == 'create')
$out .= ' });';
$out .= '})';
$out .= ''."\n";
- if (count($listofpaths))
- {
- foreach ($listofpaths as $key => $val)
- {
+ if (count($listofpaths)) {
+ foreach ($listofpaths as $key => $val) {
$out .= '';
$out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name'];
$out .= '
';
@@ -1269,15 +1234,13 @@ if ($action == 'create')
// Message
print '
';
- if ($action == 'edit')
- {
+ if ($action == 'edit') {
// wysiwyg editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, $conf->global->FCKEDITOR_ENABLE_MAILING, 20, '90%');
$doleditor->Create();
}
- if ($action == 'edithtml')
- {
+ if ($action == 'edithtml') {
// HTML source editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 'ace', 20, '90%');
diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index 17b5a779617..2961218f148 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -118,36 +118,48 @@ class Mailing extends CommonObject
/**
* @var int id of user create
- * @deprecated
*/
public $user_creation;
/**
* @var int id of user create
+ * @deprecated
*/
public $user_creat;
/**
* @var int id of user validate
- * @deprecated
*/
public $user_validation;
/**
* @var int id of user validate
+ * @deprecated
*/
public $user_valid;
/**
* @var integer|string date_creation
+ * @deprecated
*/
public $date_creat;
+ /**
+ * @var integer|string date_creation
+ */
+ public $date_creation;
+
/**
* @var int date validate
+ * @deprecated
*/
public $date_valid;
+ /**
+ * @var int date validate
+ */
+ public $date_validation;
+
/**
* @var array extraparams
*/
@@ -314,10 +326,14 @@ class Mailing extends CommonObject
$this->email_errorsto = $obj->email_errorsto;
$this->user_creat = $obj->fk_user_creat;
+ $this->user_creation = $obj->fk_user_creat;
$this->user_valid = $obj->fk_user_valid;
+ $this->user_validation = $obj->fk_user_valid;
$this->date_creat = $this->db->jdate($obj->date_creat);
+ $this->date_creation = $this->db->jdate($obj->date_creat);
$this->date_valid = $this->db->jdate($obj->date_valid);
+ $this->date_validation = $this->db->jdate($obj->date_valid);
$this->date_envoi = $this->db->jdate($obj->date_envoi);
$this->extraparams = (array) json_decode($obj->extraparams, true);
diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php
index 199a5caad8b..4bd39309701 100644
--- a/htdocs/comm/mailing/info.php
+++ b/htdocs/comm/mailing/info.php
@@ -33,8 +33,9 @@ $id = GETPOST('id', 'int');
$langs->load("mails");
// Security check
-if (!$user->rights->mailing->lire || $user->socid > 0)
-accessforbidden();
+if (!$user->rights->mailing->lire || $user->socid > 0) {
+ accessforbidden();
+}
@@ -48,8 +49,7 @@ $form = new Form($db);
$object = new Mailing($db);
-if ($object->fetch($id) >= 0)
-{
+if ($object->fetch($id) >= 0) {
$head = emailing_prepare_head($object);
print dol_get_fiche_head($head, 'info', $langs->trans("Mailing"), -1, 'email');
@@ -58,13 +58,14 @@ if ($object->fetch($id) >= 0)
$morehtmlright = '';
$nbtry = $nbok = 0;
- if ($object->statut == 2 || $object->statut == 3)
- {
+ if ($object->statut == 2 || $object->statut == 3) {
$nbtry = $object->countNbOfTargets('alreadysent');
$nbko = $object->countNbOfTargets('alreadysentko');
$morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail;
- if ($nbko) $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
+ if ($nbko) {
+ $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error");
+ }
$morehtmlright .= ') ';
}
@@ -73,10 +74,6 @@ if ($object->fetch($id) >= 0)
print '
';
//print '
';
- $object->user_creation = $object->user_creat;
- $object->date_creation = $object->date_creat;
- $object->user_validation = $object->user_valid;
- $object->date_validation = $object->date_valid;
dol_print_object_info($object, 0);
//print '
';
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 12146179db0..f6a63ba9a48 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -1660,7 +1660,7 @@ if ($action == 'create')
print '
'.$langs->trans('NotePublic').' ';
print '
';
$note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc) ? $objectsrc->note_public : null));
- $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
@@ -1670,7 +1670,7 @@ if ($action == 'create')
print ' '.$langs->trans('NotePrivate').' ';
print '
';
$note_private = $object->getDefaultCreateValueFor('note_private', ((!empty($origin) && !empty($originid) && is_object($objectsrc)) ? $objectsrc->note_private : null));
- $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// print '
print ' ';
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 213819b0915..3a4cfde8057 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1736,7 +1736,7 @@ if ($action == 'create' && $usercancreate)
print ''.$langs->trans('NotePublic').' ';
print '';
- $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// print '';
print ' ';
@@ -1747,7 +1747,7 @@ if ($action == 'create' && $usercancreate)
print ''.$langs->trans('NotePrivate').' ';
print '';
- $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// print '';
print ' ';
diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php
index 0a18d68b5db..f1e34e99985 100644
--- a/htdocs/compta/deplacement/card.php
+++ b/htdocs/compta/deplacement/card.php
@@ -252,7 +252,7 @@ if ($action == 'create')
print ''.$langs->trans('NotePublic').' ';
print '';
- $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
+ $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1);
print ' ';
@@ -264,7 +264,7 @@ if ($action == 'create')
print ''.$langs->trans('NotePrivate').' ';
print '';
- $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
+ $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1);
print ' ';
@@ -349,7 +349,7 @@ if ($action == 'create')
print ''.$langs->trans("NotePublic").' ';
print '';
- $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
+ $doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1);
print " ";
@@ -360,7 +360,7 @@ if ($action == 'create')
print ''.$langs->trans("NotePrivate").' ';
print '';
- $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%');
+ $doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_8, '90%');
print $doleditor->Create(1);
print " ";
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index b978de677a9..d0089b0323e 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -1008,7 +1008,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext, 1, 'help', '', 0, 2, 'notepublic');
print '';
print '';
- $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
@@ -1019,7 +1019,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext, 1, 'help', '', 0, 2, 'noteprivate');
print ' ';
print '';
- $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// print '
print ' ';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 733325f901b..e16d07f084f 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -3534,7 +3534,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePublic'), $htmltext);
print '';
print '';
- $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// Private note
@@ -3545,7 +3545,7 @@ if ($action == 'create')
print $form->textwithpicto($langs->trans('NotePrivate'), $htmltext);
print ' ';
print '';
- $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
// print '
print ' ';
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 752bdc4d642..23297438e19 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -1129,13 +1129,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
// Note Public
print ''.$langs->trans("NotePublic").' ';
- $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print ' ';
// Note Private
print ''.$langs->trans("NotePrivate").' ';
- $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $object->note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print ' ';
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 2e692dc25c4..3ed21f03873 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1174,14 +1174,14 @@ if ($action == 'create')
}
print ''.$langs->trans("NotePublic").' ';
- $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print ' ';
if (empty($user->socid))
{
print ''.$langs->trans("NotePrivate").' ';
- $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print ' ';
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 01ed58e84ac..95af26992cb 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -2954,18 +2954,25 @@ abstract class CommonObject
// Special cas
if ($this->table_element == 'product' && $newsuffix == '_private') $newsuffix = '';
-
+ if (in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) {
+ $fieldusermod = "fk_user_mod";
+ } elseif ($this->table_element == 'ecm_files') {
+ $fieldusermod = "fk_user_m";
+ } else {
+ $fieldusermod = "fk_user_modif";
+ }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET note".$newsuffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL");
- $sql .= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment')) ? "fk_user_mod" : "fk_user_modif")." = ".$user->id;
+ $sql .= " ,".$fieldusermod." = ".$user->id;
$sql .= " WHERE rowid =".$this->id;
dol_syslog(get_class($this)."::update_note", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- if ($suffix == '_public') $this->note_public = $note;
- elseif ($suffix == '_private') $this->note_private = $note;
- else {
+ if ($this->db->query($sql)) {
+ if ($suffix == '_public') {
+ $this->note_public = $note;
+ } elseif ($suffix == '_private') {
+ $this->note_private = $note;
+ } else {
$this->note = $note; // deprecated
$this->note_private = $note;
}
diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php
index e900e6ff424..f6942cb5265 100644
--- a/htdocs/core/lib/categories.lib.php
+++ b/htdocs/core/lib/categories.lib.php
@@ -57,7 +57,7 @@ function categories_prepare_head(Categorie $object, $type)
$h++;
}
- $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id;
+ $head[$h][0] = DOL_URL_ROOT.'/categories/info.php?id='.$object->id.'&type='.$type;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
diff --git a/htdocs/core/lib/ecm.lib.php b/htdocs/core/lib/ecm.lib.php
index 1f22e464358..2c1edc5e675 100644
--- a/htdocs/core/lib/ecm.lib.php
+++ b/htdocs/core/lib/ecm.lib.php
@@ -111,6 +111,16 @@ function ecm_file_prepare_head($object)
$head[$h][2] = 'card';
$h++;
+ // Notes
+ $head[$h][0] = DOL_URL_ROOT.'/ecm/file_note.php?section='.$object->section_id.'&urlfile='.urlencode($object->label);
+ $head[$h][1] = $langs->trans("Notes");
+ $nbNote = 0;
+ if (!empty($object->note_private)) $nbNote++;
+ if (!empty($object->note_public)) $nbNote++;
+ if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.' ';
+ $head[$h][2] = 'note';
+ $h++;
+
return $head;
}
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index 84a46c49d63..ac4d26725bc 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -263,6 +263,7 @@ class modCommande extends DolibarrModules
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_commande';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('commande').')';
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
+
// Imports
//--------
$r = 0;
diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php
index 54fecd1a5af..c42cbeb0f8c 100644
--- a/htdocs/core/modules/modExpedition.class.php
+++ b/htdocs/core/modules/modExpedition.class.php
@@ -306,7 +306,7 @@ class modExpedition extends DolibarrModules
}
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')';
- if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php
index 8f4172112b5..9212fa1f7ce 100644
--- a/htdocs/core/modules/modFacture.class.php
+++ b/htdocs/core/modules/modFacture.class.php
@@ -291,7 +291,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
- if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
$r++;
@@ -371,7 +371,7 @@ class modFacture extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON ba.rowid = b.fk_account';
$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' AND f.entity IN ('.getEntity('invoice').')';
- if (isset($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
$r++;
}
diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php
index f1de32bd1a9..c0ffa6f0811 100644
--- a/htdocs/core/modules/modPropale.class.php
+++ b/htdocs/core/modules/modPropale.class.php
@@ -254,7 +254,7 @@ class modPropale extends DolibarrModules
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra3 on p.rowid = extra3.fk_object';
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = cd.fk_propal';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('propal').')';
- if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
// Imports
//--------
diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php
index f784d88a3da..8bebf949b6f 100644
--- a/htdocs/core/modules/modReception.class.php
+++ b/htdocs/core/modules/modReception.class.php
@@ -231,7 +231,7 @@ class modReception extends DolibarrModules
}
$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_reception AND ed.fk_commandefourndet = cd.rowid';
$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('reception').')';
- if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
+ if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.(empty($user) ? 0 : $user->id);
}
diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php
index 283f9eeb873..ec098be9db7 100644
--- a/htdocs/core/tpl/notes.tpl.php
+++ b/htdocs/core/tpl/notes.tpl.php
@@ -79,11 +79,16 @@ if ($module == 'propal') {
$permission = $user->rights->expedition->creer;
} elseif ($module == 'product') {
$permission = $user->rights->produit->creer;
+} elseif ($module == 'ecmfiles') {
+ $permission = $user->rights->ecm->setup;
}
//else dol_print_error('','Bad value '.$module.' for param module');
-if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
-else $typeofdata = 'textarea:12:95%';
+if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) {
+ $typeofdata = 'ckeditor:dolibarr_notes:100%:200::1:12:95%:0'; // Rem: This var is for all notes, not only thirdparties note.
+} else {
+ $typeofdata = 'textarea:12:95%';
+}
print ''."\n";
print ''."\n";
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index c55751e913f..cd3175cdce0 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -443,7 +443,7 @@ if ($action == 'create')
print '
'.$langs->trans('NotePublic').' ';
print '
';
- $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print ' ';
@@ -453,7 +453,7 @@ if ($action == 'create')
print '
'.$langs->trans('NotePrivate').' ';
print '
';
- $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
+ $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
print $doleditor->Create(1);
print ' ';
}
diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index c096bc27869..6392d6f162e 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -150,6 +150,12 @@ class EcmFiles extends CommonObject
*/
public $src_object_id;
+ /**
+ * @var int section_id ID of section = ID of EcmDirectory, directory of manual ECM (not stored into database)
+ */
+ public $section_id;
+
+
/**
* Constructor
@@ -389,6 +395,8 @@ class EcmFiles extends CommonObject
$sql .= " t.tms as date_m,";
$sql .= " t.fk_user_c,";
$sql .= " t.fk_user_m,";
+ $sql .= ' t.note_private,';
+ $sql .= ' t.note_public,';
$sql .= " t.acl,";
$sql .= " t.src_object_type,";
$sql .= " t.src_object_id";
@@ -450,6 +458,8 @@ class EcmFiles extends CommonObject
$this->date_m = $this->db->jdate($obj->date_m);
$this->fk_user_c = $obj->fk_user_c;
$this->fk_user_m = $obj->fk_user_m;
+ $this->note_private = $obj->note_private;
+ $this->note_public = $obj->note_public;
$this->acl = $obj->acl;
$this->src_object_type = $obj->src_object_type;
$this->src_object_id = $obj->src_object_id;
diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php
index 496afbf8568..b1c7eb0ec28 100644
--- a/htdocs/ecm/file_card.php
+++ b/htdocs/ecm/file_card.php
@@ -36,14 +36,15 @@ $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
-if (!$user->rights->ecm->setup) accessforbidden();
+if (!$user->rights->ecm->setup) {
+ accessforbidden();
+}
// Get parameters
$socid = GETPOST("socid", "int");
// Security check
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@@ -52,22 +53,26 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortorder) $sortorder = "ASC";
-if (!$sortfield) $sortfield = "label";
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "label";
+}
$section = GETPOST("section", 'alpha');
-if (!$section)
-{
+if (!$section) {
dol_print_error('', 'Error, section parameter missing');
exit;
}
-$urlfile = GETPOST("urlfile");
-if (!$urlfile)
-{
+$urlfile = (string) dol_sanitizePathName(GETPOST("urlfile"));
+if (!$urlfile) {
dol_print_error('', "ErrorParamNotDefined");
exit;
}
@@ -75,8 +80,7 @@ if (!$urlfile)
// Load ecm object
$ecmdir = new EcmDirectory($db);
$result = $ecmdir->fetch(GETPOST("section", 'alpha'));
-if (!$result > 0)
-{
+if (!$result > 0) {
dol_print_error($db, $ecmdir->error);
exit;
}
@@ -85,13 +89,9 @@ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
$fullpath = $conf->ecm->dir_output.'/'.$relativepath.$urlfile;
-$file = new stdClass();
-$file->section_id = $ecmdir->id;
-$file->label = $urlfile;
-
$relativetodocument = 'ecm/'.$relativepath; // $relativepath is relative to ECM dir, we need relative to document
-$filepath = $relativepath.$file->label;
-$filepathtodocument = $relativetodocument.$file->label;
+$filepath = $relativepath.$urlfile;
+$filepathtodocument = $relativetodocument.$urlfile;
// Try to load object from index
$object = new ECMFiles($db);
@@ -100,8 +100,7 @@ $extrafields = new ExtraFields($db);
$extrafields->fetch_name_optionals_label($object->table_element);
$result = $object->fetch(0, '', $filepathtodocument);
-if ($result < 0)
-{
+if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
exit;
}
@@ -112,11 +111,9 @@ if ($result < 0)
* Actions
*/
-if ($cancel)
-{
+if ($cancel) {
$action = '';
- if ($backtopage)
- {
+ if ($backtopage) {
header("Location: ".$backtopage);
exit;
} else {
@@ -126,8 +123,7 @@ if ($cancel)
}
// Rename file
-if ($action == 'update')
-{
+if ($action == 'update') {
$error = 0;
$oldlabel = GETPOST('urlfile', 'alpha');
@@ -154,11 +150,9 @@ if ($action == 'update')
// Now we update index of file
$db->begin();
//print $oldfile.' - '.$newfile;
- if ($newlabel != $oldlabel)
- {
+ if ($newlabel != $oldlabel) {
$result = dol_move($oldfile, $newfileformove); // This include update of database
- if (!$result)
- {
+ if (!$result) {
$langs->load('errors');
setEventMessages($langs->trans('ErrorFailToRenameFile', $oldfile, $newfile), null, 'errors');
$error++;
@@ -166,27 +160,25 @@ if ($action == 'update')
// Reload object after the move
$result = $object->fetch(0, '', $newdirrelativetodocument.$newlabel);
- if ($result < 0)
- {
+ if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
exit;
}
}
- if (!$error)
- {
- if ($shareenabled)
- {
+ if (!$error) {
+ if ($shareenabled) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$object->share = getRandomPassword(true);
} else {
$object->share = '';
}
- if ($object->id > 0)
- {
+ if ($object->id > 0) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
if (!$error) {
// Actions on extra fields
$result = $object->insertExtraFields();
@@ -197,8 +189,7 @@ if ($action == 'update')
}
// Call update to set the share key
$result = $object->update($user);
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'warnings');
}
} else {
@@ -212,15 +203,13 @@ if ($action == 'update')
$object->description = ''; // indexed content
$object->keyword = ''; // keyword content
$result = $object->create($user);
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($object->error, $object->errors, 'warnings');
}
}
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
$urlfile = $newlabel;
@@ -246,10 +235,11 @@ $form = new Form($db);
llxHeader();
-$head = ecm_file_prepare_head($file);
+$object->section_id = $ecmdir->id;
+$object->label = $urlfile;
+$head = ecm_file_prepare_head($object);
-if ($action == 'edit')
-{
+if ($action == 'edit') {
print '
';
} elseif (!empty($module)) {
// Tabs for module
@@ -2309,7 +2316,7 @@ if ($module == 'initmodule')
print $langs->trans("EnterNameOfObjectToDeleteDesc").'
';
print '
';
- print '
';
+ print '
';
print '';
} else {
// tabobj = module
@@ -2336,6 +2343,7 @@ if ($module == 'initmodule')
$pathtodocument = strtolower($module).'/'.strtolower($tabobj).'_document.php';
$pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.php';
$pathtonote = strtolower($module).'/'.strtolower($tabobj).'_note.php';
+ $pathtocontact = strtolower($module).'/'.strtolower($tabobj).'_contact.php';
$pathtophpunit = strtolower($module).'/test/phpunit/'.strtolower($tabobj).'Test.php';
$pathtosql = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'.sql';
$pathtosqlextra = strtolower($module).'/sql/llx_'.strtolower($module).'_'.strtolower($tabobj).'_extrafields.sql';
@@ -2354,6 +2362,7 @@ if ($module == 'initmodule')
$realpathtodocument = $dirread.'/'.$pathtodocument;
$realpathtolist = $dirread.'/'.$pathtolist;
$realpathtonote = $dirread.'/'.$pathtonote;
+ $realpathtocontact = $dirread.'/'.$pathtocontact;
$realpathtophpunit = $dirread.'/'.$pathtophpunit;
$realpathtosql = $dirread.'/'.$pathtosql;
$realpathtosqlextra = $dirread.'/'.$pathtosqlextra;
@@ -2377,34 +2386,31 @@ if ($module == 'initmodule')
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
print '
'.$langs->trans("ApiClassFile").' :
'.($realpathtoapi ? '' : '').$pathtoapi.($realpathtoapi ? '' : ' ').' ';
- if ($realpathtoapi)
- {
+ if (dol_is_file($realpathtoapi)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
if (empty($conf->global->$const_name)) // If module is not activated
{
- print '
'.$langs->trans("GoToApiExplorer").' ';
+ print '
'.$langs->trans("GoToApiExplorer").' ';
} else {
print '
'.$langs->trans("GoToApiExplorer").' ';
}
} else {
//print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
}
// PHPUnit
print '
';
print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit ? '' : '').$pathtophpunit.($realpathtophpunit ? '' : ' ').' ';
-
- if ($realpathtophpunit)
- {
+ if (dol_is_file($realpathtophpunit)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
} else {
//print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
}
print '
';
@@ -2431,24 +2437,24 @@ if ($module == 'initmodule')
//print '
'.$langs->trans("RunSql").' ';
print '
';
print '
'.$langs->trans("SqlFileExtraFields").' :
'.($realpathtosqlextra ? '' : '').$pathtosqlextra.($realpathtosqlextra ? '' : ' ').' ';
- if ($realpathtosqlextra)
- {
+ if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
print ' ';
print '
'.$langs->trans("DropTableIfEmpty").' ';
} else {
- print '
';
+ print '
';
}
//print '
'.$langs->trans("RunSql").' ';
print '
';
print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey ? '' : '').$pathtosqlextrakey.($realpathtosqlextrakey ? '' : ' ').' ';
- if ($realpathtosqlextrakey)
- {
+ if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ } else {
+ print '
';
}
//print '
'.$langs->trans("RunSql").' ';
print '
';
@@ -2463,30 +2469,34 @@ if ($module == 'initmodule')
print '
'.$langs->trans("PageForCreateEditView").' :
'.($realpathtocard ? '' : '').$pathtocard.($realpathtocard ? '' : ' ').'?action=create ';
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
print '
';
- print '
'.$langs->trans("PageForAgendaTab").' :
'.($realpathtoagenda ? '' : '').$pathtoagenda.($realpathtoagenda ? '' : ' ').' ';
- print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
- if ($realpathtoagenda)
- {
+ print '
'.$langs->trans("PageForContactTab").' :
'.($realpathtocontact ? '' : '').$pathtocontact.($realpathtocontact ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ if (dol_is_file($realpathtocontact)) {
print ' ';
- print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
print '
';
print '
'.$langs->trans("PageForDocumentTab").' :
'.($realpathtodocument ? '' : '').$pathtodocument.($realpathtodocument ? '' : ' ').' ';
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
- if ($realpathtodocument)
- {
+ if (dol_is_file($realpathtodocument)) {
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
print '
';
print '
'.$langs->trans("PageForNoteTab").' :
'.($realpathtonote ? '' : '').$pathtonote.($realpathtonote ? '' : ' ').' ';
print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
- if ($realpathtonote)
- {
+ if (dol_is_file($realpathtonote)) {
print ' ';
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
}
print '
';
+ print '
'.$langs->trans("PageForAgendaTab").' :
'.($realpathtoagenda ? '' : '').$pathtoagenda.($realpathtoagenda ? '' : ' ').' ';
+ print '
'.img_picto($langs->trans("Edit"), 'edit').' ';
+ if (dol_is_file($realpathtoagenda)) {
+ print ' ';
+ print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
+ }
+ print '
';
/* This is already on Tab CLI
print '
';
@@ -2533,8 +2543,7 @@ if ($module == 'initmodule')
print '
';
print '
';
- print '
';
- //print '
';
+ print '
';
print '
';
print load_fiche_titre($langs->trans("ObjectProperties"), '', '');
@@ -3073,7 +3082,7 @@ if ($module == 'initmodule')
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
} else {
print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
print '
';
}
print '';
@@ -3139,7 +3148,7 @@ if ($module == 'initmodule')
} else {
print '
';
print ' '.$langs->trans("NoTrigger");
- print ' ';
+ print ' ';
print ' ';
print '';
}
@@ -3190,7 +3199,7 @@ if ($module == 'initmodule')
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
} else {
print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
}
print '';
} else {
@@ -3238,7 +3247,7 @@ if ($module == 'initmodule')
print '
'.img_picto($langs->trans("Delete"), 'delete').' ';
} else {
print '
'.$langs->trans("FileNotYetGenerated").' ';
- print '
';
+ print '
';
}
print '';
} else {
@@ -3292,7 +3301,7 @@ if ($module == 'initmodule')
}
} else {
print '
'.$langs->trans("NoWidget");
- print ' ';
+ print ' ';
print '';
}
print '
';
@@ -3374,7 +3383,7 @@ if ($module == 'initmodule')
}
} else {
print '