- 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.
329 lines
9.2 KiB
PHP
329 lines
9.2 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_Field_Model extends Vtiger_Field_Model
|
|
{
|
|
public $allowedSteps = [];
|
|
public $updatePickListValues = [
|
|
'emailmarketingmodule',
|
|
'templatelanguage',
|
|
'templatesource',
|
|
'templaterelation',
|
|
];
|
|
|
|
/**
|
|
* @param string $step
|
|
* @return bool
|
|
*/
|
|
public function isAllowedStep($step)
|
|
{
|
|
return in_array($this->name, $this->getAllowedSteps($step));
|
|
}
|
|
|
|
/**
|
|
* @param string $step
|
|
* @return array
|
|
*/
|
|
public function getAllowedSteps($step)
|
|
{
|
|
if (empty($this->allowedSteps)) {
|
|
$this->retrieveAllowedSteps();
|
|
}
|
|
|
|
return $this->allowedSteps[$step];
|
|
}
|
|
|
|
public function retrieveAllowedSteps()
|
|
{
|
|
$this->allowedSteps = [
|
|
'CampaignDetails' => [
|
|
'emailmarketingname',
|
|
'assigned_user_id',
|
|
'fromname',
|
|
'fromemail',
|
|
'replyto',
|
|
'description',
|
|
'emailmarketingmodule',
|
|
],
|
|
'SelectSubscribers' => [
|
|
],
|
|
'SelectTemplate' => [
|
|
'templaterelation',
|
|
'templatelanguage',
|
|
'subject',
|
|
],
|
|
'Schedule' => [
|
|
'emailmarketingsend',
|
|
'deliverydate',
|
|
'deliverytime',
|
|
'sendhourly',
|
|
'email_sending_pause',
|
|
],
|
|
'TemplateRecords' => [
|
|
],
|
|
];
|
|
|
|
if (vtlib_isModuleActive('ITS4YouSMTP')) {
|
|
$this->allowedSteps['CampaignDetails'][] = 'emailmarketingsmtp';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param string $templateSource
|
|
* @return mixed
|
|
* @throws Exception
|
|
*/
|
|
public function getFieldLabel($templateSource = 'Newsletter')
|
|
{
|
|
$content = ITS4YouEmailMarketing_Content_Template::getInstanceById((int)$this->get('fieldvalue'), $templateSource);
|
|
|
|
if ($content) {
|
|
return $content->getName();
|
|
}
|
|
}
|
|
|
|
public function getValidator()
|
|
{
|
|
$validator = array();
|
|
$fieldName = $this->getName();
|
|
|
|
if (!in_array($fieldName, $this->updatePickListValues)) {
|
|
$validator = parent::getValidator();
|
|
}
|
|
|
|
return $validator;
|
|
}
|
|
|
|
public function getTemplatesFromRecord($record)
|
|
{
|
|
$templateSources = $this->getTemplateSource();
|
|
$recordModel = is_object($record) ? $record : Vtiger_Record_Model::getInstanceById($record);
|
|
|
|
if ($recordModel) {
|
|
foreach ($templateSources as $key => $value) {
|
|
$recordModel->set('templatesource', $key);
|
|
$recordModel->set('template', '');
|
|
|
|
$templateSources[$key] = $this->getPicklistFromRecord($recordModel);
|
|
}
|
|
}
|
|
|
|
return $templateSources;
|
|
}
|
|
|
|
public function getTemplateSource()
|
|
{
|
|
return array(
|
|
'Newsletter' => 'Newsletter',
|
|
'EmailMaker' => 'EMAILMaker',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param $record
|
|
* @return array
|
|
*/
|
|
public function getPicklistFromRecord($record)
|
|
{
|
|
$content = ITS4YouEmailMarketing_Content_Template::getInstanceFromMarketing($record);
|
|
|
|
if ($content) {
|
|
return $content->getPickListValues();
|
|
}
|
|
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getPicklistValues()
|
|
{
|
|
switch ($this->getName()) {
|
|
case 'emailmarketingmodule':
|
|
return $this->getEmailMarketingModules();
|
|
case 'templatelanguage':
|
|
return $this->getLanguages();
|
|
case 'templaterelation':
|
|
return $this->getTemplateRelations();
|
|
case 'templatesource':
|
|
return $this->getTemplateSource();
|
|
case 'emailmarketingsmtp':
|
|
return $this->getSMTPServers();
|
|
case 'emailmarketingsend':
|
|
return $this->getSendValues();
|
|
}
|
|
|
|
return parent::getPicklistValues();
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getEmailMarketingModules()
|
|
{
|
|
$modules = array();
|
|
$emailRelated = getEmailRelatedModules();
|
|
|
|
foreach ($emailRelated as $module) {
|
|
if (vtlib_isModuleActive($module)) {
|
|
$modules[$module] = vtranslate($module, $module);
|
|
}
|
|
}
|
|
|
|
return $modules;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getLanguages()
|
|
{
|
|
if (!isset($_SESSION['template_languages']) || empty($_SESSION['template_languages'])) {
|
|
$languages = [];
|
|
$adb = PearDatabase::getInstance();
|
|
$result = $adb->pquery('SELECT label, prefix FROM vtiger_language WHERE active = ?', array('1'));
|
|
|
|
while ($row = $adb->fetchByAssoc($result)) {
|
|
$languages[$row['prefix']] = $row['label'];
|
|
}
|
|
|
|
$_SESSION['template_languages'] = $languages;
|
|
}
|
|
|
|
return $_SESSION['template_languages'];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getTemplateRelations()
|
|
{
|
|
return array();
|
|
}
|
|
|
|
public function getSMTPServers()
|
|
{
|
|
$records = [];
|
|
|
|
if (vtlib_isModuleActive('ITS4YouSMTP')) {
|
|
/**
|
|
* @var ITS4YouSMTP_Module_Model $moduleModel
|
|
* @var ITS4YouSMTP_Record_Model $record
|
|
*/
|
|
$moduleModel = Vtiger_Module_Model::getInstance('ITS4YouSMTP');
|
|
|
|
foreach ($moduleModel->getRecords() as $recordId => $record) {
|
|
$records[$recordId] = $this->getSMTPServerName($record);
|
|
}
|
|
}
|
|
|
|
return $records;
|
|
}
|
|
|
|
public function getSMTPServerName($recordInstance)
|
|
{
|
|
if (!$recordInstance) {
|
|
return '';
|
|
}
|
|
|
|
return $recordInstance->get('server') . ' <' . $recordInstance->get('server_username') . '>';
|
|
}
|
|
|
|
public function getSendValues()
|
|
{
|
|
return [
|
|
'Manual' => vtranslate('Manual', 'ITS4YouEmailMarketing'),
|
|
'Scheduled' => vtranslate('Scheduled', 'ITS4YouEmailMarketing'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getFieldDataType()
|
|
{
|
|
switch ($this->getName()) {
|
|
case 'templaterelation':
|
|
return 'TemplateRelation';
|
|
case 'template':
|
|
case 'templatesource':
|
|
return 'hidden';
|
|
default:
|
|
return parent::getFieldDataType();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return mixed
|
|
*/
|
|
public function getFieldInfo()
|
|
{
|
|
$fieldInfo = parent::getFieldInfo();
|
|
|
|
if (in_array($fieldInfo['name'], $this->updatePickListValues)) {
|
|
$fieldInfo['editablepicklistvalues'] = $fieldInfo['picklistvalues'] = $this->getPicklistValues();
|
|
$this->setFieldInfo($fieldInfo);
|
|
}
|
|
|
|
return $fieldInfo;
|
|
}
|
|
|
|
public function getDisplayValue($value, $record = false, $recordInstance = false)
|
|
{
|
|
if ('emailmarketingsmtp' === $this->getName()) {
|
|
if(vtlib_isModuleActive('ITS4YouSMTP') && getTabid('ITS4YouSMTP')) {
|
|
return $this->getSMTPServerName(ITS4YouSMTP_Record_Model::getInstanceById($value));
|
|
}
|
|
|
|
return '';
|
|
}
|
|
|
|
return parent::getDisplayValue($value, $record, $recordInstance);
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getEditablePicklistValues()
|
|
{
|
|
switch ($this->getName()) {
|
|
case 'emailmarketingmodule':
|
|
return $this->getEmailMarketingModules();
|
|
case 'templatelanguage':
|
|
return $this->getLanguages();
|
|
case 'templaterelation':
|
|
return $this->getTemplateRelations();
|
|
case 'templatesource':
|
|
return $this->getTemplateSource();
|
|
case 'emailmarketingsmtp':
|
|
return $this->getSMTPServers();
|
|
case 'emailmarketingsend':
|
|
return $this->getSendValues();
|
|
}
|
|
|
|
return parent::getEditablePicklistValues();
|
|
}
|
|
|
|
public function getPicklistColors()
|
|
{
|
|
return array();
|
|
}
|
|
|
|
public function isActiveField()
|
|
{
|
|
$active = parent::isActiveField();
|
|
|
|
if ('campaign' === $this->getName() && !vtlib_isModuleActive('Campaigns')) {
|
|
$this->set('presence', 1);
|
|
}
|
|
|
|
return $active;
|
|
}
|
|
} |