From 446997d0baa2f472a0fba99e162aa2708decd87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 27 Nov 2020 00:15:07 +0100 Subject: [PATCH] doxygen --- htdocs/comm/mailing/class/mailing.class.php | 216 ++++++++++++++------ 1 file changed, 154 insertions(+), 62 deletions(-) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 48c00c697a1..2f2b16bd119 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -46,25 +46,96 @@ class Mailing extends CommonObject */ public $picto = 'email'; + /** + * @var string title + */ public $title; + + /** + * @var string subject + */ public $sujet; + + /** + * @var string body + */ public $body; + + /** + * @var int number of email + */ public $nbemail; + + /** + * @var string background color + */ public $bgcolor; + + /** + * @var string background image + */ public $bgimage; + /** + * @var int status + */ public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely + /** + * @var string email from + */ public $email_from; + + /** + * @var string email reply to + */ public $email_replyto; + + /** + * @var string email errors to + */ public $email_errorsto; + /** + * @var string first joined file + */ public $joined_file1; + + /** + * @var string second joined file + */ public $joined_file2; + + /** + * @var string third joined file + */ public $joined_file3; + + /** + * @var string fourth joined file + */ public $joined_file4; + /** + * @var int id of user create + * @deprecated + */ + public $user_creation; + + /** + * @var int id of user create + */ public $user_creat; + + /** + * @var int id of user validate + * @deprecated + */ + public $user_validation; + + /** + * @var int id of user validate + */ public $user_valid; /** @@ -72,12 +143,24 @@ class Mailing extends CommonObject */ public $date_creat; - + /** + * @var int date validate + */ public $date_valid; + /** + * @var array extraparams + */ public $extraparams = array(); + /** + * @var array statut dest + */ public $statut_dest = array(); + + /** + * @var array statuts + */ public $statuts = array(); @@ -118,8 +201,7 @@ class Mailing extends CommonObject $this->title = trim($this->title); $this->email_from = trim($this->email_from); - if (!$this->email_from) - { + if (!$this->email_from) { $this->error = $langs->trans("ErrorMailFromRequired"); return -1; } @@ -130,19 +212,16 @@ class Mailing extends CommonObject $sql .= " (date_creat, fk_user_creat, entity)"; $sql .= " VALUES ('".$this->db->idate($now)."', ".$user->id.", ".$conf->entity.")"; - if (!$this->title) - { + if (!$this->title) { $this->title = $langs->trans("NoTitle"); } dol_syslog("Mailing::Create", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing"); - if ($this->update($user) > 0) - { + if ($this->update($user) > 0) { $this->db->commit(); } else { $this->error = $this->db->lasterror(); @@ -175,12 +254,11 @@ class Mailing extends CommonObject $sql .= ", email_errorsto = '".$this->db->escape($this->email_errorsto)."'"; $sql .= ", bgcolor = '".($this->bgcolor ? $this->db->escape($this->bgcolor) : null)."'"; $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'"; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " WHERE rowid = ".(int) $this->id; dol_syslog("Mailing::Update", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else { $this->error = $this->db->lasterror(); @@ -211,10 +289,8 @@ class Mailing extends CommonObject dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; @@ -286,8 +362,7 @@ class Mailing extends CommonObject $object->title = $langs->trans("CopyOf").' '.$object->title.' '.dol_print_date(dol_now()); // If no option copy content - if (empty($option1)) - { + if (empty($option1)) { // Clear values $object->nbemail = 0; $object->sujet = ''; @@ -312,15 +387,13 @@ class Mailing extends CommonObject $result = $object->create($user); // Other options - if ($result < 0) - { + if ($result < 0) { $this->error = $object->error; $this->errors = array_merge($this->errors, $object->errors); $error++; } - if (!$error) - { + if (!$error) { // Clone recipient targets if (!empty($option2)) { require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; @@ -341,10 +414,8 @@ class Mailing extends CommonObject $sql .= " WHERE fk_mailing = ".$fromid; $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { while ($obj = $this->db->fetch_object($result)) { $target_array[] = array( 'fk_contact'=>$obj->fk_contact, @@ -370,8 +441,7 @@ class Mailing extends CommonObject unset($object->context['createfromclone']); // End - if (!$error) - { + if (!$error) { $this->db->commit(); return $object->id; } else { @@ -395,8 +465,7 @@ class Mailing extends CommonObject $sql .= " WHERE rowid = ".$this->id; dol_syslog("Mailing::valid", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { return 1; } else { $this->error = $this->db->lasterror(); @@ -418,8 +487,7 @@ class Mailing extends CommonObject dol_syslog("Mailing::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { return $this->delete_targets(); } else { $this->error = $this->db->lasterror(); @@ -441,8 +509,7 @@ class Mailing extends CommonObject dol_syslog("Mailing::delete_targets", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { return 1; } else { $this->error = $this->db->lasterror(); @@ -467,8 +534,7 @@ class Mailing extends CommonObject dol_syslog("Mailing::reset_targets_status", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { return 1; } else { $this->error = $this->db->lasterror(); @@ -487,19 +553,23 @@ class Mailing extends CommonObject { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " WHERE fk_mailing = ".$this->id; - if ($mode == 'alreadysent') $sql .= " AND statut <> 0"; - elseif ($mode == 'alreadysentok') $sql .= " AND statut > 0"; - elseif ($mode == 'alreadysentko') $sql .= " AND statut = -1"; - else { + if ($mode == 'alreadysent') { + $sql .= " AND statut <> 0"; + } elseif ($mode == 'alreadysentok') { + $sql .= " AND statut > 0"; + } elseif ($mode == 'alreadysentko') { + $sql .= " AND statut = -1"; + } else { $this->error = 'BadValueForParameterMode'; return -2; } $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); - if ($obj) return $obj->nb; + if ($obj) { + return $obj->nb; + } } else { $this->error = $this->db->lasterror(); return -1; @@ -524,7 +594,9 @@ class Mailing extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } $result = ''; $companylink = ''; @@ -535,19 +607,20 @@ class Mailing extends CommonObject $url = DOL_URL_ROOT.'/comm/mailing/card.php?id='.$this->id; - if ($option != 'nolink') - { + if ($option != 'nolink') { // Add param to save lastsearch_values or not $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; - if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } } $linkclose = ''; - if (empty($notooltip)) - { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $label = $langs->trans("ShowEMailing"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } @@ -560,15 +633,21 @@ class Mailing extends CommonObject $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) $linkclose = $hookmanager->resPrint; */ - } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } $linkstart = ''; $linkend = ''; $result .= $linkstart; - if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); - if ($withpicto != 2) $result .= $this->ref; + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + if ($withpicto != 2) { + $result .= $this->ref; + } $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); @@ -576,8 +655,11 @@ class Mailing extends CommonObject $hookmanager->initHooks(array('emailingdao')); $parameters = array('id'=>$this->id, 'getnomurl'=>$result); $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } return $result; } @@ -611,8 +693,12 @@ class Mailing extends CommonObject $labelStatusShort = $langs->trans($this->statuts[$status]); $statusType = 'status'.$status; - if ($status == 2) $statusType = 'status3'; - if ($status == 3) $statusType = 'status6'; + if ($status == 2) { + $statusType = 'status3'; + } + if ($status == 3) { + $statusType = 'status6'; + } return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } @@ -647,9 +733,15 @@ class Mailing extends CommonObject $labelStatusShort[3] = $langs->trans('MailingStatusNotContact'); $statusType = 'status'.$status; - if ($status == -1) $statusType = 'status8'; - if ($status == 1) $statusType = 'status6'; - if ($status == 2) $statusType = 'status4'; + if ($status == -1) { + $statusType = 'status8'; + } + if ($status == 1) { + $statusType = 'status6'; + } + if ($status == 2) { + $statusType = 'status4'; + } $param = array(); if ($status == - 1) {