Skip to content

Commit

Permalink
Merge branch 'develop' into patch-92
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 15, 2018
2 parents 71b4233 + 85cdc44 commit 6e2bbba
Show file tree
Hide file tree
Showing 16 changed files with 457 additions and 109 deletions.
2 changes: 1 addition & 1 deletion htdocs/admin/emailcollector_card.php
Expand Up @@ -466,7 +466,7 @@ function init_myfunc()
print '<td>';
$arrayoftypes=array('recordevent'=>'RecordEvent');
if ($conf->projet->enabled) $arrayoftypes['project']='CreateLeadAndThirdParty';
print $form->selectarray('operationtype', $arrayoftypes, '', 0, 0, 0, '', 1);
print $form->selectarray('operationtype', $arrayoftypes, '', 1, 0, 0, '', 1);
print '</td><td>';
print '<input type="text" name="operationparam">';
print '</td>';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/admin/prelevement.php
Expand Up @@ -232,13 +232,13 @@
print '</tr>';

//EntToEnd
print '<tr class="pair"><td class="fieldrequired">'.$langs->trans("END_TO_END").'</td>';
print '<tr class="pair"><td>'.$langs->trans("END_TO_END").'</td>';
print '<td align="left">';
print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->END_TO_END.'" size="15" ></td>';
print '</td></tr>';

//USTRD
print '<tr class="pair"><td class="fieldrequired">'.$langs->trans("USTRD").'</td>';
print '<tr class="pair"><td>'.$langs->trans("USTRD").'</td>';
print '<td align="left">';
print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->USTRD.'" size="15" ></td>';
print '</td></tr>';
Expand Down
27 changes: 17 additions & 10 deletions htdocs/contact/class/contact.class.php
Expand Up @@ -87,17 +87,17 @@ class Contact extends CommonObject

/**
* @deprecated
* @see state_id
* @see $state_id
*/
public $fk_departement;
/**
* @deprecated
* @see state_code
* @see $state_code
*/
public $departement_code;
/**
* @deprecated
* @see state
* @see $state
*/
public $departement;
public $state_id; // Id of department
Expand Down Expand Up @@ -682,12 +682,13 @@ function update_perso($id, $user=null, $notrigger=0)
/**
* Load object contact
*
* @param int $id id du contact
* @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
* @param string $ref_ext External reference, not given by Dolibarr
* @return int -1 if KO, 0 if OK but not found, 1 if OK
* @param int $id id du contact
* @param User $user Utilisateur (abonnes aux alertes) qui veut les alertes de ce contact
* @param string $ref_ext External reference, not given by Dolibarr
* @param string $email Email
* @return int -1 if KO, 0 if OK but not found, 1 if OK
*/
function fetch($id, $user=0, $ref_ext='')
function fetch($id, $user=null, $ref_ext='', $email='')
{
global $langs;

Expand Down Expand Up @@ -721,9 +722,15 @@ function fetch($id, $user=0, $ref_ext='')
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
if ($id) $sql.= " WHERE c.rowid = ". $id;
elseif ($ref_ext) {
else
{
$sql .= " WHERE c.entity IN (".getEntity($this->element).")";
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
if ($ref_ext) {
$sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'";
}
if ($email) {
$sql .= " AND c.email = '".$this->db->escape($email)."'";
}
}

$resql=$this->db->query($sql);
Expand Down
14 changes: 10 additions & 4 deletions htdocs/core/actions_sendmails.inc.php
Expand Up @@ -427,8 +427,9 @@
$object->socid = $sendtosocid; // To link to a company
$object->sendtoid = $sendtoid; // To link to contact addresses. This is an array.
$object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
$object->actionmsg = $actionmsg; // Long text
$object->actionmsg2 = $actionmsg2; // Short text
$object->actionmsg = $actionmsg; // Long text (@TODO Replace this with $message, we already have details of email in dedicated properties)
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);

$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
Expand All @@ -439,9 +440,14 @@
$object->sendtouserid = $sendtouserid;
}

// TODO Set object->email_xxx properties
$object->email_msgid = $mailfile->msgid; // @TODO Set msgid into $mailfile after sending
$object->email_from = $from;
$object->email_subject = $subject;
$object->email_to = $sendto;
$object->email_tocc = $sendtocc;
$object->email_tobcc = $sendtobcc;
$object->email_subject = $subject;
$object->email_msgid = $mailfile->msgid;
//...

// Call of triggers
if (! empty($trigger_name))
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/lib/admin.lib.php
Expand Up @@ -1731,7 +1731,7 @@ function email_admin_prepare_head()
$h = 0;
$head = array();

if ($user->admin && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates'))
if (! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates'))
{
$head[$h][0] = DOL_URL_ROOT."/admin/mails.php";
$head[$h][1] = $langs->trans("OutGoingEmailSetup");
Expand All @@ -1752,7 +1752,7 @@ function email_admin_prepare_head()
$head[$h][2] = 'templates';
$h++;

if ($conf->global->MAIN_FEATURES_LEVEL >= 1)
if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && ! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates'))
{
$head[$h][0] = DOL_URL_ROOT."/admin/mails_senderprofile_list.php";
$head[$h][1] = $langs->trans("EmailSenderProfiles");
Expand Down
49 changes: 33 additions & 16 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -2837,35 +2837,50 @@ function isValidPhone($phone)
* @param string $stringencoding Encoding of string
* @return int Length of string
*/
function dol_strlen($string,$stringencoding='UTF-8')
function dol_strlen($string, $stringencoding='UTF-8')
{
if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding);
else return strlen($string);
}

/**
* Make a substring. Works even in mbstring module is not enabled.
* Make a substring. Works even if mbstring module is not enabled for better compatibility.
*
* @param string $string String to scan
* @param string $start Start position
* @param int $length Length
* @param int $length Length (in nb of characters or nb of bytes depending on trunconbytes param)
* @param string $stringencoding Page code used for input string encoding
* @param int $trunconbytes 1=Length is max of bytes instead of max of characters
* @return string substring
*/
function dol_substr($string,$start,$length,$stringencoding='')
function dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0)
{
global $langs;

if (empty($stringencoding)) $stringencoding=$langs->charset_output;

$ret='';
if (function_exists('mb_substr'))
if (empty($trunconbytes))
{
$ret=mb_substr($string,$start,$length,$stringencoding);
if (function_exists('mb_substr'))
{
$ret=mb_substr($string, $start, $length, $stringencoding);
}
else
{
$ret=substr($string, $start, $length);
}
}
else
{
$ret=substr($string,$start,$length);
if (function_exists('mb_strcut'))
{
$ret=mb_strcut($string, $start, $length, $stringencoding);
}
else
{
$ret=substr($string, $start, $length);
}
}
return $ret;
}
Expand Down Expand Up @@ -3063,7 +3078,7 @@ function plotWithOptions() {
* @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap
* @param string $stringencoding Tell what is source string encoding
* @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation.
* @param int $display Trunc is use to display and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
* @param int $display Trunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS)
* @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise.
*/
function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0)
Expand Down Expand Up @@ -6782,26 +6797,27 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id
if ($key == '') return '';

// Check in cache
if (isset($cache_codes[$tablename][$key])) // Can be defined to 0 or ''
if (isset($cache_codes[$tablename][$key][$fieldid])) // Can be defined to 0 or ''
{
return $cache_codes[$tablename][$key]; // Found in cache
return $cache_codes[$tablename][$key][$fieldid]; // Found in cache
}

dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG);

$sql = "SELECT ".$fieldid." as valuetoget";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'";
if (! empty($entityfilter))
$sql.= " AND entity IN (" . getEntity($tablename) . ")";

dol_syslog('dol_getIdFromCode', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $cache_codes[$tablename][$key]=$obj->valuetoget;
else $cache_codes[$tablename][$key]='';
if ($obj) $cache_codes[$tablename][$key][$fieldid]=$obj->valuetoget;
else $cache_codes[$tablename][$key][$fieldid]='';
$db->free($resql);
return $cache_codes[$tablename][$key];
return $cache_codes[$tablename][$key][$fieldid];
}
else
{
Expand Down Expand Up @@ -6889,8 +6905,6 @@ function picto_from_langcode($codelang, $moreatt = '')

if (empty($codelang)) return '';

if (empty($codelang)) return '';

if ($codelang == 'auto')
{
return '<span class="fa fa-globe"></span>';
Expand Down Expand Up @@ -7061,6 +7075,7 @@ function printCommonFooter($zone='private')
if (! empty($conf->use_javascript_ajax))
{
print '<script type="text/javascript" language="javascript">'."\n";
print 'jQuery(document).ready(function() {'."\n";

if ($zone == 'private' && empty($conf->dol_use_jmobile))
{
Expand Down Expand Up @@ -7143,6 +7158,8 @@ function printCommonFooter($zone='private')
}
}

print '});'."\n";

// Google Analytics
// TODO Add a hook here
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/modules/modAgenda.class.php
Expand Up @@ -244,7 +244,7 @@ function __construct($db)
// Calendar
$this->menu[$r]=array('fk_menu'=>'r=1',
'type'=>'left',
'titre'=>'Agenda',
'titre'=>'Calendar',
'mainmenu'=>'agenda',
'url'=>'/comm/action/index.php?action=default&amp;mainmenu=agenda&amp;leftmenu=agenda',
'langs'=>'agenda',
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/modules/project/mod_project_simple.php
Expand Up @@ -122,7 +122,7 @@ function canBeActivated()
* @param Project $project Object project
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$project)
function getNextValue($objsoc, $project)
{
global $db,$conf;

Expand Down Expand Up @@ -167,9 +167,9 @@ function getNextValue($objsoc,$project)
* @param Project $project Object project
* @return string Next not used reference
*/
function project_get_num($objsoc=0,$project='')
function project_get_num($objsoc=0, $project='')
{
// phpcs:enable
return $this->getNextValue($objsoc,$project);
return $this->getNextValue($objsoc, $project);
}
}
8 changes: 4 additions & 4 deletions htdocs/core/modules/project/mod_project_universal.php
Expand Up @@ -123,7 +123,7 @@ function getExample()
* @param Project $project Object project
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$project)
function getNextValue($objsoc, $project)
{
global $db,$conf;

Expand All @@ -139,7 +139,7 @@ function getNextValue($objsoc,$project)
}

$date=empty($project->date_c)?dol_now():$project->date_c;
$numFinal=get_next_value($db,$mask,'projet','ref','',$objsoc->code_client,$date);
$numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date);

return $numFinal;
}
Expand All @@ -153,9 +153,9 @@ function getNextValue($objsoc,$project)
* @param Project $project Object project
* @return string Next not used reference
*/
function project_get_num($objsoc=0,$project='')
function project_get_num($objsoc=0, $project='')
{
// phpcs:enable
return $this->getNextValue($objsoc,$project);
return $this->getNextValue($objsoc, $project);
}
}

0 comments on commit 6e2bbba

Please sign in to comment.