| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/vtigerversion80/modules/CTFacebookLeadIntegration/ |
Upload File : |
<?php
/* * *******************************************************************************
* The content of this file is subject to the CRMTiger Pro license.
* ("License"); You may not use this file except in compliance with the License
* The Initial Developer of the Original Code is https://crmtiger.com/
* Portions created by CRMTiger.com are Copyright(C) CRMTiger.com
* All Rights Reserved.
* ****************************************************************************** */
class CTFacebookLeadIntegration {
function vtlib_handler($moduleName, $eventType) {
$adb = PearDatabase::getInstance();
if ($eventType == 'module.postinstall') {
self::updateSettings();
self::generateWebhookFile();
self::addCustomLeadFieldFile();
} else if ($eventType == 'module.disabled') {
self::updateSettings();
$adb->pquery('UPDATE vtiger_settings_field SET active= 1 WHERE name= ?', array('CTFacebookLeadIntegration'));
} else if ($eventType == 'module.enabled') {
$adb->pquery('UPDATE vtiger_settings_field SET active= 0 WHERE name= ?', array('CTFacebookLeadIntegration'));
} else if ($eventType == 'module.preuninstall') {
self::generateWebhookFile();
} else if ($eventType == 'module.preupdate') {
self::generateWebhookFile();
// TODO Handle actions before this module is updated.
} else if ($eventType == 'module.postupdate') {
self::updateSettings();
self::generateWebhookFile();
}
}
static function generateWebhookFile() {
$fileArr = array('getFacebookLeadData');
foreach ($fileArr as $key => $filename) {
$dest1 = $filename.".php";
$source1 = "modules/CTFacebookLeadIntegration/".$filename.".php";
chmod($source1, 0777);
if (file_exists($source1)) {
copy($source1, $dest1);
chmod($dest1, 0777);
}
}
}
static function addCustomLeadFieldFile(){
require_once("modules/CTFacebookLeadIntegration/Add_Facebook_FormSync.php");
}//end of if
private function updateSettings() {
$adb = PearDatabase::getInstance();
$linkto = 'index.php?parent=Settings&module=CTFacebookLeadIntegration&view=CTFacebookConfigurationList';
$result=$adb->pquery('SELECT 1 FROM vtiger_settings_field WHERE name=?',array('CTFacebookLeadIntegration'));
if($adb->num_rows($result)){
$adb->pquery('UPDATE vtiger_settings_field SET name=?, iconpath=?, description=?, linkto=? WHERE name=?',array('CTFacebookLeadIntegration', '', '', $linkto, 'CTFacebookLeadIntegration'));
}else{
$fieldid = $adb->getUniqueID('vtiger_settings_field');
$blockid = getSettingsBlockId('LBL_OTHER_SETTINGS');
$seq_res = $adb->pquery("SELECT max(sequence) AS max_seq FROM vtiger_settings_field WHERE blockid = ?", array($blockid));
if ($adb->num_rows($seq_res) > 0) {
$cur_seq = $adb->query_result($seq_res, 0, 'max_seq');
if ($cur_seq != null) $seq = $cur_seq + 1;
}
$adb->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence, active, pinned) VALUES (?,?,?,?,?,?,?,?,?)', array($fieldid, $blockid, 'CTFacebookLeadIntegration' , '', '', $linkto, $seq,0, 0));
}
}
}
?>