/** * Check if vtiger CRM support Events */ static function hasSupport() { if (self::$is_supported === '') { self::$is_supported = Vtiger_Utils::checkTable('vtiger_eventhandlers'); } return self::$is_supported; }
/** * Import Event of the module * @access private */ function import_Event($modulenode, $moduleInstance, $eventnode) { $event_condition = ''; $event_dependent = '[]'; if (!empty($eventnode->condition)) { $event_condition = "{$eventnode->condition}"; } if (!empty($eventnode->dependent)) { $event_dependent = "{$eventnode->dependent}"; } Vtiger_Event::register($moduleInstance, (string) $eventnode->eventname, (string) $eventnode->classname, (string) $eventnode->filename, (string) $event_condition, (string) $event_dependent); }
/** * Update Events of the module * @access private */ function update_Events($modulenode, $moduleInstance) { if (empty($modulenode->events) || empty($modulenode->events->event)) { return; } if (Vtiger_Event::hasSupport()) { foreach ($modulenode->events->event as $eventnode) { $this->update_Event($modulenode, $moduleInstance, $eventnode); } } }
/** * Export Events of the module * @access private */ function export_Events($moduleInstance) { $events = Vtiger_Event::getAll($moduleInstance); if (!$events) { return; } $this->openNode('events'); foreach ($events as $event) { $this->openNode('event'); $this->outputNode($event->eventname, 'eventname'); $this->outputNode('<![CDATA[' . $event->classname . ']]>', 'classname'); $this->outputNode('<![CDATA[' . $event->filename . ']]>', 'filename'); $this->outputNode('<![CDATA[' . $event->condition . ']]>', 'condition'); $this->closeNode('event'); } $this->closeNode('events'); }
/** * Update Event of the module * @access private */ function update_Event($modulenode, $moduleInstance, $eventnode) { Vtiger_Event::register($moduleInstance, $eventnode->eventname, $eventnode->classname, $eventnode->filename); // TODO Handle event property update }
} else { $labelInfo = getEntityName($row['setype'], array(intval($row['crmid']))); } if ($labelInfo) { $label = html_entity_decode($labelInfo[$row['crmid']], ENT_QUOTES); Migration_Index_View::ExecuteQuery('UPDATE vtiger_crmentity SET label=? WHERE crmid=? AND setype=?', array($label, $row['crmid'], $row['setype'])); } if (intval($row['crmid']) > $lastMaxCRMId) { $lastMaxCRMId = intval($row['crmid']); } } $rs = null; unset($rs); } while (true); $homeModule = Vtiger_Module::getInstance('Home'); Vtiger_Event::register($homeModule, 'vtiger.entity.aftersave', 'Vtiger_RecordLabelUpdater_Handler', 'modules/Vtiger/handlers/RecordLabelUpdater.php'); echo "Record Update Handler was updated successfully"; } // To update the Campaign related status value in database as in language file $updateQuery = "update vtiger_campaignrelstatus set campaignrelstatus=? where campaignrelstatus=?"; Migration_Index_View::ExecuteQuery($updateQuery, array('Contacted - Unsuccessful', 'Contacted - Unsuccessful')); echo 'Campaign related status value is updated'; //92 ends //93 starts //93 ends //94 starts $result = $adb->pquery('SELECT 1 FROM vtiger_currencies WHERE currency_name = ?', array('Libya, Dinar')); if (!$adb->num_rows($result)) { Migration_Index_View::ExecuteQuery('INSERT INTO vtiger_currencies (currencyid, currency_name, currency_code, currency_symbol) VALUES(?, ?, ?, ?)', array($adb->getUniqueID('vtiger_currencies'), 'Libya, Dinar', 'LYD', 'LYD')); } //Start: Customer - Feature #17656 Allow users to add/remove date format with the date fields in workflow send mail task.
/** * Dispatch (send) email that was queued. */ static function dispatchQueue(Vtiger_Mailer_Listener $listener = null) { global $adb; if (!Vtiger_Utils::CheckTable('vtiger_mailer_queue')) { return; } $mailer = new self(); $queue = $adb->pquery('SELECT * FROM vtiger_mailer_queue WHERE failed != ?', array(1)); if ($adb->num_rows($queue)) { for ($index = 0; $index < $adb->num_rows($queue); ++$index) { $mailer->reinitialize(); $queue_record = $adb->fetch_array($queue, $index); $queueid = $queue_record['id']; $relcrmid = $queue_record['relcrmid']; $mailer->From = $queue_record['fromemail']; $mailer->From = $queue_record['fromname']; $mailer->Subject = $queue_record['subject']; $mailer->Body = decode_html($queue_record['body']); $mailer->Mailer = $queue_record['mailer']; $mailer->ContentType = $queue_record['content_type']; $emails = $adb->pquery('SELECT * FROM vtiger_mailer_queueinfo WHERE id=?', array($queueid)); for ($eidx = 0; $eidx < $adb->num_rows($emails); ++$eidx) { $email_record = $adb->fetch_array($emails, $eidx); if ($email_record[type] == 'TO') { $mailer->AddAddress($email_record[email], $email_record[name]); } else { if ($email_record[type] == 'CC') { $mailer->AddCC($email_record[email], $email_record[name]); } else { if ($email_record[type] == 'BCC') { $mailer->AddBCC($email_record[email], $email_record[name]); } else { if ($email_record[type] == 'RPLYTO') { $mailer->AddReplyTo($email_record[email], $email_record[name]); } } } } } $attachments = $adb->pquery('SELECT * FROM vtiger_mailer_queueattachments WHERE id=?', array($queueid)); for ($aidx = 0; $aidx < $adb->num_rows($attachments); ++$aidx) { $attachment_record = $adb->fetch_array($attachments, $aidx); if ($attachment_record['path'] != '') { $mailer->AddAttachment($attachment_record['path'], $attachment_record['name'], $attachment_record['encoding'], $attachment_record['type']); } } $sent = $mailer->Send(true); if ($sent) { Vtiger_Event::trigger('vtiger.mailer.mailsent', $relcrmid); if ($listener) { $listener->mailsent($queueid); } $adb->pquery('DELETE FROM vtiger_mailer_queue WHERE id=?', array($queueid)); $adb->pquery('DELETE FROM vtiger_mailer_queueinfo WHERE id=?', array($queueid)); $adb->pquery('DELETE FROM vtiger_mailer_queueattachments WHERE id=?', array($queueid)); } else { if ($listener) { $listener->mailerror($queueid); } $adb->pquery('UPDATE vtiger_mailer_queue SET failed=?, failreason=? WHERE id=?', array(1, $mailer->ErrorInfo, $queueid)); } } } }
$viewField = new Vtiger_Field(); $viewField->name = 'default_record_view'; $viewField->label = 'Default Record View'; $viewField->table = 'vtiger_users'; $viewField->column = 'default_record_view'; $viewField->columntype = 'VARCHAR(10)'; $viewField->typeofdata = 'V~O'; $viewField->uitype = 16; $viewField->defaultvalue = 'Summary'; $moreInfoBlock->addField($viewField); $viewField->setPicklistValues(array('Summary', 'Detail')); Migration_Index_View::ExecuteQuery('UPDATE vtiger_users SET default_record_view = ?', array('Summary')); $InvoiceInstance = Vtiger_Module::getInstance('Invoice'); Vtiger_Event::register($InvoiceInstance, 'vtiger.entity.aftersave', 'InvoiceHandler', 'modules/Invoice/InvoiceHandler.php'); $POInstance = Vtiger_Module::getInstance('PurchaseOrder'); Vtiger_Event::register($POInstance, 'vtiger.entity.aftersave', 'PurchaseOrderHandler', 'modules/PurchaseOrder/PurchaseOrderHandler.php'); $InvoiceBlockInstance = Vtiger_Block::getInstance('LBL_INVOICE_INFORMATION', $InvoiceInstance); $field1 = Vtiger_Field::getInstance('received', $InvoiceInstance); if (!$field1) { $field1 = new Vtiger_Field(); $field1->name = 'received'; $field1->label = 'Received'; $field1->table = 'vtiger_invoice'; $field1->uitype = 72; $field1->displaytype = 3; $field1->typeofdata = 'N~O'; $field1->defaultvalue = 0; $InvoiceBlockInstance->addField($field1); } $field2 = Vtiger_Field::getInstance('balance', $InvoiceInstance); if (!$field2) {
function actualizeRegister() { Vtiger_Event::register('Calendar4You', 'vtiger.entity.aftersave', 'GoogleSync4YouHandler', 'modules/Calendar4You/GoogleSync4YouHandler.php'); Vtiger_Event::register('Calendar4You', 'vtiger.entity.beforedelete', 'GoogleSync4YouHandler', 'modules/Calendar4You/GoogleSync4YouHandler.php'); }