noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Noalyss\Mail_Parameter Class Reference

configuration email and test PHPMAILER. More...

+ Collaboration diagram for Noalyss\Mail_Parameter:

Public Member Functions

 __construct (protected \Database $cn, protected $name)
 
 __get ($key)
 get the value in the array $a_value thkx the key
 
 __set ($key, $value)
 set the value in the array $a_value thkx the key
 
 from_get ()
 retrieve information from GET
 
 from_post ()
 retrieve information from POST
 
 get ($key)
 
 input ()
 display a form to input the parameter
 
 load ()
 load from the database
 
 save ()
 save into the database
 
 set ($key, $value)
 

Static Public Member Functions

static Factory (\Database $cnx, $reply_to="", $blind_copy="")
 

Data Fields

const PARAMETER
 

Protected Attributes

 $a_value
 $a_value array of PARAMETER=>Value
 

Detailed Description

configuration email and test PHPMAILER.

Property :

  • $cn Database conx
  • $name name of the SMTP conx
  • $a_value array
    • smtp_user' username

'smtp_password' password

  • 'smtp_host' host
  • 'smtp_port' port
  • 'smtp_replyto' email address to reply
  • 'smtp_from' email address sender
  • 'smtp_auth' smtp authorisation (always 1)
  • 'smtp_type' smtp
  • 'smtp_secure' kind of encryption PHPMailer::ENCRYPTION_STARTTLS, or PHPMailer::ENCRYPTION_SMTPS.
  • 'smtp_auth_type'SMTP authentication type. Options are CRAM-MD5, LOGIN, PLAIN, XOAUTH2.

Definition at line 69 of file mail_parameter.class.php.

Constructor & Destructor Documentation

◆ __construct()

Noalyss\Mail_Parameter::__construct ( protected \Database $cn,
protected $name )

Definition at line 89 of file mail_parameter.class.php.

93 {
94
95 $this->load();
96 }

References $cn, $name, and load().

+ Here is the call graph for this function:

Member Function Documentation

◆ __get()

Noalyss\Mail_Parameter::__get ( $key)

get the value in the array $a_value thkx the key

Parameters
$key(string) key must be in Mail_Parameter::PARAMETER
$value(string) value
Returns
a string or null if not found
Exceptions

Exception if the key doesn't exist

Definition at line 122 of file mail_parameter.class.php.

123 {
124 if (in_array($key, Mail_Parameter::PARAMETER) == false)
125 {
126 throw new \Exception("MP79 : unknown $key");
127 }
128 if (isset($this->a_value[$key]))
129 {
130 return $this->a_value[$key];
131 }
132 return null;
133 }

References PARAMETER.

◆ __set()

Noalyss\Mail_Parameter::__set ( $key,
$value )

set the value in the array $a_value thkx the key

Parameters
$key(string) key must be in Mail_Parameter::PARAMETER
$value(string) value
Returns
Mail_Parameter
Exceptions

Exception if the key doesn't exist

Definition at line 105 of file mail_parameter.class.php.

106 {
107 if (in_array($key, Mail_Parameter::PARAMETER) == false)
108 {
109 throw new \Exception("MP72 : unknown $key");
110 }
111 $this->a_value[$key] = $value;
112 return $this;
113 }

References $value, and PARAMETER.

◆ Factory()

static Noalyss\Mail_Parameter::Factory ( \Database $cnx,
$reply_to = "",
$blind_copy = "" )
static

Definition at line 238 of file mail_parameter.class.php.

239 {
240 $mail_parameter=new Mail_Parameter($cnx,MAIL_SETTING_NOALYSS);
241 if ( $mail_parameter->smtp_type=="sendmail") {
242 return new \Sendmail($mail_parameter->smtp_replyto,$mail_parameter->smtp_replyto);
243 } elseif ($mail_parameter->smtp_type=="smtp") {
244 $phpmail= new SMTPMail($mail_parameter);
245 return $phpmail;
246 }
247
248 throw new \Exception("MP212 MAIL NOT CONFIGURED",212);
249
250 }
const MAIL_SETTING_NOALYSS
Definition constant.php:393
if( $delta< 0) elseif( $delta==0)

References elseif, and MAIL_SETTING_NOALYSS.

◆ from_get()

Noalyss\Mail_Parameter::from_get ( )

retrieve information from GET

Definition at line 205 of file mail_parameter.class.php.

206 {
207 $http = new \HttpInput();
208 $this->smtp_user = $http->get('smtp_user');
209 $this->smtp_password = $http->get('smtp_password');
210 $this->smtp_host = $http->get('smtp_host');
211 $this->smtp_port = $http->get('smtp_port');
212 $this->smtp_replyto = $http->get('smtp_replyto');
213 $this->smtp_from = $http->get('smtp_from');
214 $this->smtp_type= $http->get('smtp_type');
215 $this->smtp_secure = $http->get('smtp_secure');
216 $this->smtp_auth_type = $http->get('smtp_auth_type');
217 $this->smtp_auth=1;
218
219 }

References $http.

◆ from_post()

Noalyss\Mail_Parameter::from_post ( )

retrieve information from POST

Definition at line 223 of file mail_parameter.class.php.

224 {
225 $http = new \HttpInput();
226 $this->smtp_user = $http->post('smtp_user');
227 $this->smtp_password = $http->post('smtp_password');
228 $this->smtp_host = $http->post('smtp_host');
229 $this->smtp_port = $http->post('smtp_port');
230 $this->smtp_replyto = $http->post('smtp_replyto');
231 $this->smtp_from = $http->post('smtp_from');
232 $this->smtp_type= $http->post('smtp_type');
233 $this->smtp_secure = $http->post('smtp_secure');
234 $this->smtp_auth_type = $http->post('smtp_auth_type');
235 $this->smtp_auth=1;
236
237 }

References $http.

◆ get()

Noalyss\Mail_Parameter::get ( $key)

Definition at line 182 of file mail_parameter.class.php.

183 {
184 return $this->$key;
185 }

◆ input()

Noalyss\Mail_Parameter::input ( )

display a form to input the parameter

Definition at line 197 of file mail_parameter.class.php.

198 {
199
200 include NOALYSS_TEMPLATE . "/mail_parameter-input.php";
201 }

◆ load()

Noalyss\Mail_Parameter::load ( )

load from the database

Definition at line 165 of file mail_parameter.class.php.

166 {
167 $a_value = array_column(
168 $this->cn->get_array("select pe_parameter , pe_value from
169 public.parm_mail_server
170 where
171 pe_name=$1"
172 , [$this->name])
173 , "pe_value","pe_parameter"
174 );
175
176 foreach (self::PARAMETER as $key)
177 {
178 $this->a_value[$key] = $a_value[$key] ?? "";
179 }
180 }
$input_from cn

References $a_value, and cn.

Referenced by __construct().

◆ save()

Noalyss\Mail_Parameter::save ( )

save into the database

Definition at line 138 of file mail_parameter.class.php.

139 {
140 foreach (self::PARAMETER as $key)
141 {
142 $id = $this->cn->get_value("select pe_id from parm_mail_server
143 where pe_parameter=$1
144 and pe_name=$2",
145 [$key, $this->name]);
146 if ($id == "")
147 {
148 $record = new \Parm_Mail_Server_SQL($this->cn);
149 $record->set("pe_name", $this->name);
150 $record->set("pe_parameter", $key);
151 $record->set("pe_value", $this->a_value[$key]);
152 $record->insert();
153 } else
154 {
155 $record = new \Parm_Mail_Server_SQL($this->cn, $id);
156 $record->set("pe_value", $this->a_value[$key]);
157 $record->update();
158 }
159 }
160 }
$from_poste name

References $id, cn, and name.

◆ set()

Noalyss\Mail_Parameter::set ( $key,
$value )

Definition at line 187 of file mail_parameter.class.php.

187 : Mail_Parameter
188 {
189 $this->$key = $value;
190 return $this;
191 }

References $value.

Field Documentation

◆ $a_value

Noalyss\Mail_Parameter::$a_value
protected

$a_value array of PARAMETER=>Value

Definition at line 85 of file mail_parameter.class.php.

Referenced by load().

◆ PARAMETER

const Noalyss\Mail_Parameter::PARAMETER
Initial value:
= [
'smtp_user'
, 'smtp_password'
, 'smtp_host'
, 'smtp_port'
, 'smtp_replyto'
, 'smtp_from'
, 'smtp_auth'
, 'smtp_type'
, 'smtp_secure'
, 'smtp_auth_type'
]

Definition at line 72 of file mail_parameter.class.php.

Referenced by __get(), and __set().


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