- Added comprehensive AI Assistant system (aiassist/ directory): * Vector search and embedding capabilities * Typebot proxy integration * Elastic search functionality * Message classification and chat history * MCP proxy for external integrations - Implemented Court Status API (GetCourtStatus.php): * Real-time court document status checking * Integration with external court systems * Comprehensive error handling and logging - Enhanced S3 integration: * Improved file backup system with metadata * Batch processing capabilities * Enhanced error logging and recovery * Copy operations with URL fixing - Added Telegram contact creation API - Improved error logging across all modules - Enhanced callback system for AI responses - Extensive backup file storage with timestamps - Updated documentation and README files - File storage improvements: * Thousands of backup files with proper metadata * Fix operations for broken file references * Project-specific backup and recovery systems * Comprehensive file integrity checking Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
131 lines
5.7 KiB
PHP
131 lines
5.7 KiB
PHP
<?php
|
|
/* * *******************************************************************************
|
|
* The content of this file is subject to the ITS4YouEmailMarketing license.
|
|
* ("License"); You may not use this file except in compliance with the License
|
|
* The Initial Developer of the Original Code is IT-Solutions4You s.r.o.
|
|
* Portions created by IT-Solutions4You s.r.o. are Copyright(C) IT-Solutions4You s.r.o.
|
|
* All Rights Reserved.
|
|
* ****************************************************************************** */
|
|
|
|
class ITS4YouEmailMarketing_EmailsV6_Model extends Emails_Record_Model
|
|
{
|
|
|
|
public static function getCleanInstance($moduleName)
|
|
{
|
|
$focus = CRMEntity::getInstance($moduleName);
|
|
$instance = new self();
|
|
|
|
return $instance->setData($focus->column_fields)->setModule($moduleName)->setEntity($focus);
|
|
}
|
|
|
|
public function send($addToQueue = false)
|
|
{
|
|
$userId = $this->get('assigned_user_id');
|
|
$currentUserModel = Users_Record_Model::getInstanceById($userId, 'Users');
|
|
$rootDirectory = vglobal('root_directory');
|
|
|
|
$mailer = Emails_Mailer_Model::getInstance();
|
|
$mailer->IsHTML(true);
|
|
|
|
$logo = '';
|
|
$emailMarketingId = $this->get('emailmarketingid');
|
|
$fromEmail = $this->get('from_email');
|
|
$replyTo = $this->get('reply_to');
|
|
$userName = $this->get('from_name');
|
|
$toEmailInfo = $this->get('toemailinfo');
|
|
$attachments = $this->getAttachmentDetails();
|
|
|
|
// Merge Users module merge tags based on current user.
|
|
$mergedDescription = getMergedDescription($this->get('description'), $currentUserModel->getId(), 'Users');
|
|
$mergedSubject = getMergedDescription($this->get('subject'), $currentUserModel->getId(), 'Users');
|
|
|
|
foreach ($toEmailInfo as $id => $emails) {
|
|
$mailer->reinitialize();
|
|
$mailer->ConfigSenderInfo($fromEmail, $userName, $replyTo);
|
|
$old_mod_strings = vglobal('mod_strings');
|
|
$description = $this->get('description');
|
|
$subject = $this->get('subject');
|
|
$parentModule = $this->getEntityType($id);
|
|
if ($parentModule) {
|
|
$currentLanguage = Vtiger_Language_Handler::getLanguage();
|
|
$moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $parentModule);
|
|
vglobal('mod_strings', $moduleLanguageStrings['languageStrings']);
|
|
|
|
if ($parentModule != 'Users') {
|
|
// Apply merge for non-Users module merge tags.
|
|
$description = getMergedDescription($mergedDescription, $id, $parentModule);
|
|
$subject = getMergedDescription($mergedSubject, $id, $parentModule);
|
|
} else {
|
|
// Re-merge the description for user tags based on actual user.
|
|
$description = getMergedDescription($description, $id, 'Users');
|
|
$subject = getMergedDescription($mergedSubject, $id, 'Users');
|
|
vglobal('mod_strings', $old_mod_strings);
|
|
}
|
|
}
|
|
|
|
if (strpos($description, '$logo$')) {
|
|
$description = str_replace('$logo$', "<img src='cid:logo' />", $description);
|
|
$logo = true;
|
|
}
|
|
|
|
foreach ($emails as $email) {
|
|
$mailer->Body = '';
|
|
if ($parentModule) {
|
|
$mailer->Body = $this->getTrackImageDetails($emailMarketingId, true);
|
|
}
|
|
|
|
$mailer->Body .= $description;
|
|
$mailer->Body = ITS4YouEmailMarketing_Module_Model::convertCustomVariables($mailer->Body, $this->get('customer_id'));
|
|
|
|
$this->saveDescription($mailer->Body);
|
|
|
|
$mailer->Subject = $subject;
|
|
$mailer->AddAddress($email);
|
|
|
|
if (is_array($attachments)) {
|
|
foreach ($attachments as $attachment) {
|
|
$fileNameWithPath = $rootDirectory . $attachment['path'] . $attachment['fileid'] . "_" . $attachment['attachment'];
|
|
if (is_file($fileNameWithPath)) {
|
|
$mailer->AddAttachment($fileNameWithPath, $attachment['attachment']);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$images = (array) $this->get('images');
|
|
|
|
if (count($images) > 0) {
|
|
foreach ($images as $cid => $cdata) {
|
|
$mailer->AddEmbeddedImage($cdata["path"], $cid, $cdata["name"]);
|
|
}
|
|
}
|
|
|
|
$status = $mailer->Send(true);
|
|
|
|
if (!$status) {
|
|
$status = $mailer->getError();
|
|
} else {
|
|
$mailString = $mailer->getMailString();
|
|
$mailBoxModel = MailManager_Mailbox_Model::activeInstance();
|
|
$folderName = $mailBoxModel->folder();
|
|
if (!empty($folderName) && !empty($mailString)) {
|
|
$connector = MailManager_Connector_Connector::connectorWithModel($mailBoxModel, '');
|
|
imap_append($connector->mBox, $connector->mBoxUrl . $folderName, $mailString, "\\Seen");
|
|
}
|
|
}
|
|
}
|
|
|
|
return $status;
|
|
}
|
|
|
|
public function saveDescription($description)
|
|
{
|
|
$emailmarketingid = $this->get('emailmarketingid');
|
|
$emailsid = $this->getId();
|
|
|
|
$adb = PearDatabase::getInstance();
|
|
$adb->pquery('INSERT INTO its4you_emailmarketing_emails(emailmarketingid, emailsid, description) VALUES (?,?,?)', array($emailmarketingid, $emailsid, $description));
|
|
|
|
return true;
|
|
}
|
|
} |