114
$_SESSION["WorkSpace"]->MainForm, $this->Edit_BODY->Value);
$save_template->SetCenterPosition();
$save_template->ShowModal();
}
protected function ButtonSend_OnClick()
{
$files=array();
$files_list=$this->Files->GetFiles();
$files_cnt=$files_list->Count();
for($i=0; $i<$files_cnt; $i++)
{
$files[]=$files_list->Item($i);
}
$files=implode(",", $files);
$_str=$this->Edit_TO->Value;
$mails=explode(",", $_str);
$cnt=count($mails);
GetConnection("MainDBConnection")->sql_query(
"INSERT INTO table_mailer_history (MAILS, NAME, BODY, FILES,
CNT)
VALUES
('".$this->Edit_TO->Value."', '".$this->Edit_SUBJECT->Value."',
'".$this->Edit_BODY->Value."', '$files', $cnt)");
$history_id=GetConnection("MainDBConnection")->sql_insert_id();
for($i=0; $i<$cnt; $i++)
{
if(strpos($mails[$i], "<")===false)
{
$mails[$i]="<".$mails[$i].">";
}
$mail=new OString($this, trim($mails[$i]));
$address=trim($mail->CutTextBetween("<", ">"));
$mail->Replace("<", "");
$mail->Replace(">", "");
if($this->is_email($address))
{
$name=trim($mail->Text);
$body=$this->SetTags($this->Edit_BODY->Value,
$this->RecipientsForm->CurrentRecipients[$address]);
$subject=$this->SetTags($this->Edit_SUBJECT->Value,
$this->RecipientsForm->CurrentRecipients[$address]);
$this->AddToQueue($address, $subject, $name, $body, $files, $history_id);
}
}
$this->SendGlobalEvent("database_data_changed", "table_mailer_history");
$this->Close();
}
public function AddToQueue($_address, $_subject, $_name, $_body,