noalyss Version-9
Public Member Functions
Sendmail Class Reference

Send email for Noalyss after checking if it is possible : if cannot be sent if the limit of max email is reached,. More...

+ Inheritance diagram for Sendmail:
+ Collaboration diagram for Sendmail:

Public Member Functions

 can_send ()
 Check if email can be sent from a folder. More...
 
 get_email_sent (Database $p_repo, $p_dossier_id, $p_date)
 Return the amount of send emails for the date (YYYYMMDD) More...
 
 get_max_email (Database $p_repo, $p_dossier_id)
 return max email the folder can send More...
 
 increment_mail (Database $p_repo, $p_dossier, $p_date)
 Add $p_amount_email to email sent. More...
 
 send ()
 Send the message. More...
 
 verify ()
 check if there is a mandatory domain, if yes More...
 
- Public Member Functions inherited from Sendmail_Core
 __construct ()
 
 add_file (FileToSend $file)
 Add file to the message. More...
 
 add_supplemental_header ()
 Function to override if supplemental header are needed. More...
 
 compose ()
 create the message before sending More...
 
 mailto ($p_mailto)
 set the recipient More...
 
 send ()
 Send email. More...
 
 set_from ($p_from)
 set the from More...
 
 set_message ($p_message)
 body of the message (utf8) More...
 
 set_subject ($p_subject)
 
 verify ()
 verify that the message is ready to go More...
 

Additional Inherited Members

- Protected Attributes inherited from Sendmail_Core
 $afile
 
 $content
 
 $from
 
 $header
 
 $mailto
 
 $message
 
 $subject
 

Detailed Description

Send email for Noalyss after checking if it is possible : if cannot be sent if the limit of max email is reached,.

See also
sendmail_core

Definition at line 35 of file sendmail.class.php.

Member Function Documentation

◆ can_send()

Sendmail::can_send ( )

Check if email can be sent from a folder.

Returns
boolean

if send from a dossier , then check limit of this dossier otherwise send true

Compare max value in repo

Definition at line 60 of file sendmail.class.php.

60 {
61 /**
62 * if send from a dossier , then check limit of this dossier
63 * otherwise send true
64 */
65 $http=new HttpInput();
66 $dossier=$http->request("gDossier","string", -1);
67 if ($dossier == -1 ) return true;
68
69 /**
70 * Compare max value in repo
71 */
72 $repo =new Database();
73 $date=date('Ymd');
74 // get max email
75 $max_email = $this->get_max_email($repo,$dossier);
76 //
77 // This folder cannot send email
78 if ($max_email == 0 ) return false;
79 //
80 // This folder has unlimited email
81 if ($max_email == -1 ) return true;
82
83 // get email sent today from account_repository
84 $email_sent = $this->get_email_sent($repo,$dossier , $date);
85 //
86 if ( $email_sent >= $max_email) return false;
87
88 return true;
89 }
if(isset($_REQUEST['gDossier']) && $http->request("gDossier","number", 0) !=0) $repo
$dossier
contains the class for connecting to Noalyss
manage the http input (get , post, request) and extract from an array
get_email_sent(Database $p_repo, $p_dossier_id, $p_date)
Return the amount of send emails for the date (YYYYMMDD)
get_max_email(Database $p_repo, $p_dossier_id)
return max email the folder can send

References $date, $dossier, $http, $repo, get_email_sent(), and get_max_email().

Referenced by send().

+ Here is the call graph for this function:

◆ get_email_sent()

Sendmail::get_email_sent ( Database  $p_repo,
  $p_dossier_id,
  $p_date 
)

Return the amount of send emails for the date (YYYYMMDD)

Parameters
Database$p_repo
$p_dossier_idint
$p_datestring YYYYMMDD

Definition at line 108 of file sendmail.class.php.

109 {
110
111 $email_sent = $p_repo->get_value ('select de_sent_email from dossier_sent_email where dos_id = $1 and de_date=$2',
112 array($p_dossier_id,$p_date));
113 if ($email_sent == "") return 0;
114 return $email_sent;
115
116
117 }
get_value($p_sql, $p_array=null)
return the value of the sql, the sql will return only one value with the value

References $p_date, and DatabaseCore\get_value().

Referenced by can_send(), and increment_mail().

+ Here is the call graph for this function:

◆ get_max_email()

Sendmail::get_max_email ( Database  $p_repo,
  $p_dossier_id 
)

return max email the folder can send

Parameters
$p_repoDatabase
$p_dossier_idint

Definition at line 95 of file sendmail.class.php.

96 {
97 $max_email = $p_repo->get_value("select dos_email from ac_dossier where dos_id=$1",
98 array($p_dossier_id));
99 if ($max_email == "") return 0;
100 return $max_email;
101 }

References DatabaseCore\get_value().

Referenced by can_send().

+ Here is the call graph for this function:

◆ increment_mail()

Sendmail::increment_mail ( Database  $p_repo,
  $p_dossier,
  $p_date 
)

Add $p_amount_email to email sent.

Parameters
$p_repoDatabase
$p_dossierint id of the folder (dossier.dos_id)
$p_datestring (YYYYMMDD)

Definition at line 161 of file sendmail.class.php.

162 {
163 if ( $p_dossier == -1) return ;
164 $email_sent = $this->get_email_sent($p_repo,$p_dossier,$p_date);
165 if ( $email_sent == 0 ){
166 $p_repo->exec_sql("insert into public.dossier_sent_email(de_sent_email,dos_id,de_date) values($1,$2,$3)",
167 array(1,$p_dossier,$p_date));
168 return;
169 } else {
170 // update + sp_emaoun_email
171 $p_repo->exec_sql("update dossier_sent_email set de_sent_email=de_sent_email+1 where dos_id=$1 and de_date=$2",
172 array($p_dossier,$p_date));
173 }
174 }
exec_sql($p_string, $p_array=null)
send a sql string to the database

References $p_date, DatabaseCore\exec_sql(), get_email_sent(), and return.

Referenced by send().

+ Here is the call graph for this function:

◆ send()

Sendmail::send ( )

Send the message.

Exceptions
Exception

Reimplemented from Sendmail_Core.

Definition at line 41 of file sendmail.class.php.

42 {
43 if ( $this->can_send() == false ) throw new Exception(_('Email non envoyé'),EMAIL_LIMIT);
44
45 if (!mail($this->mailto, $this->subject, $this->content,$this->header))
46 {
47 throw new Exception('send failed');
48 }
49 // Increment email amount
50 $repo =new Database();
51 $date=date('Ymd');
52 $http=new HttpInput();
53 $dossier=$http->request("gDossier","string", -1);
55 }
else $card content[$j]['j_montant']
mailto($p_mailto)
set the recipient
increment_mail(Database $p_repo, $p_dossier, $p_date)
Add $p_amount_email to email sent.
can_send()
Check if email can be sent from a folder.
const EMAIL_LIMIT
Exception.
Definition: constant.php:342

References $date, $dossier, $http, $repo, can_send(), content, EMAIL_LIMIT, increment_mail(), and Sendmail_Core\mailto().

+ Here is the call graph for this function:

◆ verify()

Sendmail::verify ( )

check if there is a mandatory domain, if yes

Returns
void
Exceptions
Exception

Reimplemented from Sendmail_Core.

Definition at line 124 of file sendmail.class.php.

125 {
126 try {
127 parent::verify();
128 } catch (\Exception $e) {
129 throw $e;
130 }
131 if ( defined('ALLOWED_EMAIL_DOMAIN') )
132 {
133 if ( ALLOWED_EMAIL_DOMAIN != "")
134 {
135 $as_domain=explode(",", ALLOWED_EMAIL_DOMAIN);
136 $valid=0;
137 foreach ($as_domain as $domain) {
138 $domain="@$domain";
139 if (strpos($this->from,$domain) != 0 ) {
140 $valid=1;
141 break;
142 }
143 }
144 if ( $valid == 0) {
145 throw new Exception("Domaine email {$this->from} interdit",EXC_INVALID);
146
147 }
148
149 }
150
151 }
152
153 }
$anc_grandlivre from
const EXC_INVALID
Definition: constant.php:346
$valid
Definition: recover.php:57

References $e, $valid, EXC_INVALID, and from.


The documentation for this class was generated from the following file: