Example #1
1
 function applyChange()
 {
     if ($this->isBlocked()) {
         return true;
     }
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         Vtiger_Cron::register('cronWatcherService', 'modules/CronTasks/cronWatcher.service', 1800, 'CronTasks', Vtiger_Cron::$STATUS_ENABLED, 0, 'Send out warning email for long running cron tasks');
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
         // this should not be done if changeset is Continuous
     }
     $this->finishExecution();
 }
Example #2
0
function vtDisplayWorkflowList($adb, $request, $requestUrl, $app_strings, $current_language)
{
    global $theme;
    $image_path = "themes/{$theme}/images/";
    $module = new VTWorkflowApplication("workflowlist");
    $util = new VTWorkflowUtils();
    $mod = return_module_language($current_language, $module->name);
    if (!$util->checkAdminAccess()) {
        $errorUrl = $module->errorPageUrl($mod['LBL_ERROR_NOT_ADMIN']);
        $util->redirectTo($errorUrl, $mod['LBL_ERROR_NOT_ADMIN']);
        return;
    }
    $smarty = new vtigerCRM_Smarty();
    $wfs = new VTWorkflowManager($adb);
    $smarty->assign("moduleNames", $util->vtGetModules($adb));
    $smarty->assign("returnUrl", $requestUrl);
    $listModule = $request['list_module'];
    $smarty->assign("listModule", $listModule);
    if ($listModule == null || strtolower($listModule) == "all") {
        $smarty->assign("workflows", $wfs->getWorkflows());
    } else {
        $smarty->assign("workflows", $wfs->getWorkflowsForModule($listModule));
    }
    $smarty->assign("MOD", array_merge(return_module_language($current_language, 'Settings'), return_module_language($current_language, $module->name)));
    $smarty->assign("APP", $app_strings);
    $smarty->assign("THEME", $theme);
    $smarty->assign("IMAGE_PATH", $image_path);
    $smarty->assign("MODULE_NAME", $module->label);
    $smarty->assign("PAGE_NAME", $mod['LBL_WORKFLOW_LIST']);
    $smarty->assign("PAGE_TITLE", $mod['LBL_AVAILABLE_WORKLIST_LIST']);
    $smarty->assign("module", $module);
    $smarty->assign('MODULE', $module->name);
    $smarty->assign("CRON_TASK", Vtiger_Cron::getInstance('Workflow'));
    $smarty->display("{$module->name}/ListWorkflows.tpl");
}
 function applyChange()
 {
     if ($this->isBlocked()) {
         return true;
     }
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         Vtiger_Cron::register('ExpirePasswordAfterDays', 'cron/ExpirePasswordAfterDays.service', 86400, 'Home', Vtiger_Cron::$STATUS_DISABLED, 0, 'Expire users passwords after Application_ExpirePasswordAfterDays days.');
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
         // this should not be done if changeset is Continuous
     }
     $this->finishExecution();
 }
 public function process(Vtiger_Request $request)
 {
     $adb = PearDatabase::getInstance();
     //$params = $request->getAll();
     $value = $request->get('value');
     $cron = array('name' => 'SWVTTool GoogleCalSync', 'handler_file' => 'modules/SwVtTools/cron/gcal_sync.service.php', 'frequency' => '600', 'module' => 'SwVtTools', 'desc' => 'Check every 10 minutes if Calendar needs to be synced');
     if ($value == 'false') {
         Vtiger_Cron::deregister($cron['name']);
     } else {
         $sql = 'SELECT * FROM vtiger_cron_task WHERE name = ?';
         $result = $adb->pquery($sql, array($cron['name']));
         if ($adb->num_rows($result) > 0) {
             $sql = 'UPDATE vtiger_cron_task SET status = 1, handler_file = "' . $cron['handler_file'] . '" WHERE id = ' . $adb->query_result($result, 0, 'id');
             $adb->query($sql);
         } else {
             Vtiger_Cron::register($cron['name'], $cron['handler_file'], $cron['frequency'], $cron['module'], 1, Vtiger_Cron::nextSequence(), $cron['desc']);
         }
     }
 }
 function undoChange()
 {
     if ($this->isBlocked()) {
         return true;
     }
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isSystemUpdate()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' is a system update, it cannot be undone!');
     } else {
         if ($this->isApplied()) {
             Vtiger_Cron::deregister('UpdateExchangeRate');
             $this->sendMsg('Changeset ' . get_class($this) . ' undone!');
             $this->markUndone();
             // this should not be done if changeset is Continuous
         } else {
             $this->sendMsg('Changeset ' . get_class($this) . ' not applied!');
         }
     }
     $this->finishExecution();
 }
    }
}
$dropflds = array('com_vtiger_workflows.schtypeid', 'com_vtiger_workflows.schtime', 'com_vtiger_workflows.schdayofmonth', 'com_vtiger_workflows.schdayofweek', 'com_vtiger_workflows.schannualdates', 'com_vtiger_workflows.nexttrigger_time', 'vtiger_mailmanager_mailattachments.cid', 'vtiger_mailscanner_rules.assigned_to', 'vtiger_mailscanner_rules.cc', 'vtiger_mailscanner_rules.bcc', 'vtiger_recurringevents.recurringenddate', 'vtiger_mailscanner.time_zone', 'vtiger_portal.createdtime', 'vtiger_mail_accounts.sent_folder', 'vtiger_organizationdetails.vatid', 'vtiger_tab.trial');
foreach ($dropflds as $fqfn) {
    list($table, $field) = explode('.', $fqfn);
    ExecuteQuery("ALTER TABLE {$table} DROP {$field}");
}
$droptable = array('vtiger_feedback', 'vtiger_shareduserinfo', 'vtiger_schedulereports', 'vtiger_calendar_default_activitytypes', 'vtiger_calendar_user_activitytypes', 'vtiger_reporttype');
foreach ($droptable as $table) {
    ExecuteQuery("DROP TABLE {$table}");
}
//Schema changes for vtiger_troubletickets hours & days column
ExecuteQuery('ALTER TABLE vtiger_troubletickets MODIFY hours varchar(200)', array());
ExecuteQuery('ALTER TABLE vtiger_troubletickets MODIFY days varchar(200)', array());
ExecuteQuery('UPDATE vtiger_field set typeofdata=? WHERE fieldname IN(?,?) AND tablename = ?', array('I~O', 'hours', 'days', 'vtiger_troubletickets'));
Vtiger_Cron::deregister('ScheduleReports');
//Updating actions for PriceBooks related list in Products and Services
$productsTabId = getTabId('Products');
ExecuteQuery('UPDATE vtiger_relatedlists SET actions=? WHERE label=? and tabid=?', array('ADD', 'PriceBooks', $productsTabId));
$eventsManager = new VTEventsManager($adb);
$eventsManager->unregisterHandler('Vtiger_RecordLabelUpdater_Handler');
//Start: Customer - Feature #17656 Allow users to add/remove date format with the date fields in workflow send mail task.
$fieldResult = $adb->pquery('SELECT fieldname, name, typeofdata FROM vtiger_field
  INNER JOIN vtiger_tab ON vtiger_tab.tabid = vtiger_field.tabid WHERE typeofdata LIKE ?', array('D%'));
$dateFieldsList = $dateTimeFieldsList = array();
while ($rowData = $adb->fetch_array($fieldResult)) {
    $moduleName = $rowData['name'];
    $fieldName = $rowData['fieldname'];
    $pos = stripos($rowData['typeofdata'], 'DT');
    if ($pos !== false) {
        $dateTimeFieldsList[$moduleName][$fieldName] = $fieldName;
Example #7
0
                                        vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid INNER JOIN vtiger_contactdetails ON
                                        vtiger_contactdetails.contactid = vtiger_seattachmentsrel.crmid';
$contactIds = $adb->pquery($ContactIdSql, array());
$numOfRows = $adb->num_rows($contactIds);
for ($i = 0; $i < $numOfRows; $i++) {
    $contactId = $adb->query_result($contactIds, $i, "contactid");
    $imageName = decode_html($adb->query_result($contactIds, $i, "name"));
    Migration_Index_View::ExecuteQuery('UPDATE vtiger_contactdetails SET imagename = ? WHERE contactid = ?', array($imageName, $contactId));
}
echo 'updating image information for contacts table is completed';
//Updating actions for PriceBooks related list in Products and Services
$productsTabId = getTabId('Products');
Migration_Index_View::ExecuteQuery("UPDATE vtiger_relatedlists SET actions=? WHERE label=? and tabid=? ", array('ADD,SELECT', 'PriceBooks', $productsTabId));
echo '<br>Updated PriceBooks related list actions for products and services';
$adb->pquery("CREATE TABLE IF NOT EXISTS vtiger_schedulereports(\n            reportid INT(10),\n            scheduleid INT(3),\n            recipients TEXT,\n            schdate VARCHAR(20),\n            schtime TIME,\n            schdayoftheweek VARCHAR(100),\n            schdayofthemonth VARCHAR(100),\n            schannualdates VARCHAR(500),\n            specificemails VARCHAR(500),\n            next_trigger_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP)\n            ENGINE=InnoDB DEFAULT CHARSET=utf8;", array());
Vtiger_Cron::register('ScheduleReports', 'cron/modules/Reports/ScheduleReports.service', 900);
Migration_Index_View::ExecuteQuery('UPDATE vtiger_cron_task set description = ?  where name = "ScheduleReports" ', array("Recommended frequency for ScheduleReports is 15 mins"));
Migration_Index_View::ExecuteQuery('UPDATE vtiger_cron_task set module = ? where name = "ScheduleReports" ', array("Reports"));
echo '<br>Enabled Scheduled reports feature';
/**
* To add defaulteventstatus and defaultactivitytype fields to Users Module
* Save 2 clicks usability feature
*/
require_once 'vtlib/Vtiger/Module.php';
$module = Vtiger_Module::getInstance('Users');
if ($module) {
    $blockInstance = Vtiger_Block::getInstance('LBL_CALENDAR_SETTINGS', $module);
    if ($blockInstance) {
        $desField = Vtiger_Field::getInstance('defaulteventstatus', $module);
        if (!$desField) {
            $fieldInstance = new Vtiger_Field();
Example #8
0
    /**
     * Initialize the schema.
     */
    protected static function initializeSchema()
    {
        if (!self::$schemaInitialized) {
            if (!Vtiger_Utils::CheckTable('vtiger_cron_task')) {
                Vtiger_Utils::CreateTable('vtiger_cron_task', '(id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
					name VARCHAR(100) UNIQUE KEY, handler_file VARCHAR(100) UNIQUE KEY,
					frequency int, laststart int(11) unsigned, lastend int(11) unsigned, status int,module VARCHAR(100),
                                        sequence int,description TEXT )', true);
            }
            self::$schemaInitialized = true;
        }
    }
Example #9
0
 function update_CronTasks($modulenode)
 {
     if (empty($modulenode->crons) || empty($modulenode->crons->cron)) {
         return;
     }
     $cronTasks = Vtiger_Cron::listAllInstancesByModule($modulenode->name);
     foreach ($modulenode->crons->cron as $importCronTask) {
         foreach ($cronTasks as $cronTask) {
             if ($cronTask->getName() == $importCronTask->name && $importCronTask->handler == $cronTask->getHandlerFile()) {
                 Vtiger_Cron::deregister($importCronTask->name);
             }
         }
         if (empty($importCronTask->status)) {
             $cronTask->status = Vtiger_Cron::$STATUS_DISABLED;
         } else {
             $cronTask->status = Vtiger_Cron::$STATUS_ENABLED;
         }
         if (empty($importCronTask->sequence)) {
             $importCronTask->sequence = Vtiger_Cron::nextSequence();
         }
         // SalesPlatform.ru begin added support laststart/lastend
         Vtiger_Cron::register("{$importCronTask->name}", "{$importCronTask->handler}", "{$importCronTask->frequency}", "{$modulenode->name}", "{$importCronTask->status}", "{$importCronTask->sequence}", "{$cronTask->description}", "{$importCronTask->laststart}", "{$importCronTask->lastend}");
         //Vtiger_Cron::register("$importCronTask->name","$importCronTask->handler", "$importCronTask->frequency", "$modulenode->name","$importCronTask->status","$importCronTask->sequence","$cronTask->description");
         // SalesPlatform.ru end
     }
 }
Example #10
0
function registerCronTasks()
{
    include_once 'vtlib/Vtiger/Cron.php';
    Vtiger_Cron::register('Workflow', 'cron/modules/com_vtiger_workflow/com_vtiger_workflow.service', 900, 'com_vtiger_workflow', 1, 1, 'Recommended frequency for Workflow is 15 mins');
    Vtiger_Cron::register('RecurringInvoice', 'cron/modules/SalesOrder/RecurringInvoice.service', 43200, 'SalesOrder', 1, 2, 'Recommended frequency for RecurringInvoice is 12 hours');
    Vtiger_Cron::register('SendReminder', 'cron/SendReminder.service', 900, 'Calendar', 1, 3, 'Recommended frequency for SendReminder is 15 mins');
    Vtiger_Cron::register('ScheduleReports', 'cron/modules/Reports/ScheduleReports.service', 900, 'Reports', 1, 4, 'Recommended frequency for ScheduleReports is 15 mins');
    Vtiger_Cron::register('MailScanner', 'cron/MailScanner.service', 900, 'Settings', 1, 5, 'Recommended frequency for MailScanner is 15 mins');
}
Example #11
0
 /**
  * Export cron tasks for the module.
  * @access private
  */
 function export_CronTasks($moduleInstance)
 {
     $cronTasks = Vtiger_Cron::listAllInstancesByModule($moduleInstance->name);
     $this->openNode('crons');
     foreach ($cronTasks as $cronTask) {
         $this->openNode('cron');
         $this->outputNode($cronTask->getName(), 'name');
         $this->outputNode($cronTask->getFrequency(), 'frequency');
         $this->outputNode($cronTask->getStatus(), 'status');
         $this->outputNode($cronTask->getHandlerFile(), 'handler');
         $this->outputNode($cronTask->getSequence(), 'sequence');
         $this->outputNode($cronTask->getDescription(), 'description');
         $this->closeNode('cron');
     }
     $this->closeNode('crons');
 }
 /**
  * Import cron jobs of the module.
  * @access private
  */
 function import_CronTasks($modulenode)
 {
     if (empty($modulenode->crons) || empty($modulenode->crons->cron)) {
         return;
     }
     foreach ($modulenode->crons->cron as $cronTask) {
         if (empty($cronTask->status)) {
             $cronTask->status = Vtiger_Cron::$STATUS_DISABLED;
         } else {
             $cronTask->status = Vtiger_Cron::$STATUS_ENABLED;
         }
         if (empty($cronTask->sequence)) {
             $cronTask->sequence = Vtiger_Cron::nextSequence();
         }
         // SalesPlatform.ru begin added support laststart/lastend
         Vtiger_Cron::register("{$cronTask->name}", "{$cronTask->handler}", "{$cronTask->frequency}", "{$modulenode->name}", "{$cronTask->status}", "{$cronTask->sequence}", "{$cronTask->description}", "{$cronTask->laststart}", "{$cronTask->lastend}");
         //Vtiger_Cron::register("$cronTask->name","$cronTask->handler", "$cronTask->frequency", "$modulenode->name","$cronTask->status","$cronTask->sequence","$cronTask->description");
         // SalesPlatform.ru end
     }
 }
<?php

/*********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *
 ********************************************************************************/
require_once 'modules/Settings/MailScanner/core/MailScannerInfo.php';
require_once 'Smarty_setup.php';
require_once 'vtlib/Vtiger/Cron.php';
global $app_strings, $mod_strings, $currentModule, $theme, $current_language;
global $application_unique_key;
// defined in config.inc.php
$smarty = new vtigerCRM_Smarty();
$smarty->assign("MOD", return_module_language($current_language, 'Settings'));
$smarty->assign("CMOD", $mod_strings);
$smarty->assign("APP", $app_strings);
$smarty->assign("THEME", $theme);
$smarty->assign("IMAGE_PATH", "themes/{$theme}/images/");
$scanners = Vtiger_MailScannerInfo::listAll();
$smarty->assign("SCANNERS", $scanners);
$smarty->assign("APP_KEY", $application_unique_key);
$smarty->assign("CRON_TASK", Vtiger_Cron::getInstance('MailScanner'));
$smarty->display('MailScanner/MailScannerInfo.tpl');
Example #14
0
    function databaseData()
    {
        global $log, $adb;
        $log->debug("Entering YetiForceUpdate::databaseData() method ...");
        $result = $adb->pquery("SELECT * FROM `vtiger_blocks` WHERE `blocklabel` = ? AND `tabid` = ?;", ['Oryginalna wiadomość', getTabid('OSSMailView')]);
        if ($adb->num_rows($result)) {
            $adb->pquery("UPDATE `vtiger_blocks` SET `blocklabel` = ? WHERE `blocklabel` = ? AND `tabid` = ?;", ['LBL_ORIGN_MESSAGE', 'Oryginalna wiadomość', getTabid('OSSMailView')]);
        }
        $result = $adb->query("SELECT * FROM `vtiger_field` WHERE `fieldlabel` = 'Treść' AND `columnname` = 'orginal_mail';");
        if ($adb->num_rows($result)) {
            $adb->pquery("UPDATE `vtiger_field` SET `fieldlabel` = ? WHERE `fieldlabel` = ? AND `columnname` = ?;", ['Content', 'Treść', 'orginal_mail']);
        }
        $this->relatedList();
        $result = $adb->query("SELECT * FROM `yetiforce_proc_marketing` WHERE `type` = 'lead' AND `param` = 'convert_status';");
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','convert_status','LBL_LEAD_ACQUIRED');");
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_settings_field` WHERE `name` = ? ", ['LBL_CUSTOM_FIELD_MAPPING']);
        if (!$adb->num_rows($result)) {
            $blockid = $adb->query_result($adb->pquery("SELECT blockid FROM vtiger_settings_blocks WHERE label='LBL_STUDIO'", []), 0, 'blockid');
            $sequence = (int) $adb->query_result($adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_field WHERE blockid=?", [$blockid]), 0, 'sequence') + 1;
            $fieldid = $adb->getUniqueId('vtiger_settings_field');
            $adb->pquery("INSERT INTO vtiger_settings_field (fieldid,blockid,sequence,name,iconpath,description,linkto)\n\t\t\tVALUES (?,?,?,?,?,?,?)", array($fieldid, $blockid, $sequence, 'LBL_CUSTOM_FIELD_MAPPING', '', 'LBL_CUSTOM_FIELD_MAPPING_DESCRIPTION', 'index.php?parent=Settings&module=Leads&view=MappingDetail'));
        }
        $mailTemplates = ['Notify Owner On Ticket Change', 'Notify Account On Ticket Change', 'Notify Contact On Ticket Closed', 'Notify Account On Ticket Closed', 'Notify Contact On Ticket Create', 'Notify Account On Ticket Create', 'Notify Contact On Ticket Change', 'Notify Owner On Ticket Closed', 'Notify Owner On Ticket Create'];
        $result = $adb->pquery("SELECT `content`,`name` FROM `vtiger_ossmailtemplates` WHERE `name` IN (" . generateQuestionMarks($mailTemplates) . ") AND `oss_module_list` = ?;", [$mailTemplates, 'HelpDesk']);
        while ($row = $adb->fetch_array($result)) {
            $content = str_replace('
	<li>#b#718#bEnd#: #a#718#aEnd#</li>', '', $row['content']);
            $adb->pquery("UPDATE `vtiger_ossmailtemplates` SET `content` = ? WHERE `name` = ? AND `oss_module_list` = ?;", [$content, $row['name'], 'HelpDesk']);
        }
        $result = $adb->query("SELECT * FROM `vtiger_entityname` WHERE `fieldname` = 'holidaysentitlement_year' AND `modulename` = 'HolidaysEntitlement';");
        if ($adb->num_rows($result)) {
            $adb->pquery("UPDATE `vtiger_entityname` SET `fieldname` = ?, `searchcolumn` = ? WHERE `modulename` = ?;", ['ossemployeesid,days', 'ossemployeesid', 'HolidaysEntitlement']);
            Settings_Search_Module_Model::UpdateLabels(['tabid' => getTabid('HolidaysEntitlement')]);
        }
        $result = $adb->query("SELECT * FROM `vtiger_links` WHERE `linklabel` = 'LBL_CREATED_BY_ME_BUT_NOT_MINE_ACTIVITIES' AND `linktype` = 'DASHBOARDWIDGET';");
        if (!$adb->num_rows($result)) {
            $linkModule = Vtiger_Module::getInstance('Home');
            $linkModule->addLink('DASHBOARDWIDGET', "LBL_CREATED_BY_ME_BUT_NOT_MINE_ACTIVITIES", 'index.php?module=Home&view=ShowWidget&name=CreatedNotMineActivities');
        }
        $result = $adb->query("SELECT * FROM `vtiger_cron_task` WHERE `module` = 'CurrencyUpdate';");
        if (!$adb->num_rows($result)) {
            $cron = ['LBL_CURRENCY_UPDATE', 'modules/Settings/CurrencyUpdate/cron/CurrencyUpdateCron.php', 86400, NULL, NULL, 1, 'CurrencyUpdate', 4, 'Recommended frequency for Currency Update is 24 hours'];
            Vtiger_Cron::register($cron[0], $cron[1], $cron[2], $cron[6], $cron[5], 0, $cron[8]);
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_settings_field` WHERE `name` = ? ", ['LBL_CURRENCY_UPDATE']);
        if (!$adb->num_rows($result)) {
            $blockid = $adb->query_result($adb->pquery("SELECT blockid FROM vtiger_settings_blocks WHERE label='LBL_OTHER_SETTINGS'", []), 0, 'blockid');
            $sequence = (int) $adb->query_result($adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_field WHERE blockid=?", [$blockid]), 0, 'sequence') + 1;
            $fieldid = $adb->getUniqueId('vtiger_settings_field');
            $adb->pquery("INSERT INTO vtiger_settings_field (fieldid,blockid,sequence,name,iconpath,description,linkto)\n\t\t\tVALUES (?,?,?,?,?,?,?)", [$fieldid, $blockid, $sequence, 'LBL_CURRENCY_UPDATE', '', 'LBL_CURRENCY_UPDATE_DESCRIPTION', 'index.php?module=CurrencyUpdate&view=Index&parent=Settings']);
        }
        $result = $adb->query("SELECT * FROM `vtiger_ossmailscanner_config` WHERE `conf_type` = 'exceptions';");
        if (!$adb->num_rows($result)) {
            $adb->pquery('insert  into `vtiger_ossmailscanner_config`(`conf_type`,`parameter`,`value`) values (?,?,?);', ['exceptions', 'crating_mails', NULL]);
            $adb->pquery('insert  into `vtiger_ossmailscanner_config`(`conf_type`,`parameter`,`value`) values (?,?,?);', ['exceptions', 'crating_mails', NULL]);
        }
        $adb->pquery("UPDATE `vtiger_settings_field` SET `linkto` = ? WHERE `linkto` = ?;", ['index.php?module=OSSMailScanner&parent=Settings&view=Index', 'index.php?module=OSSMailScanner&parent=Settings&view=index']);
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ?", ['parent_id', 'vtiger_troubletickets']);
        $result2 = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE fieldid = ? AND relmodule = ?", [$adb->query_result($result1, 0, 'fieldid'), 'Vendors']);
        if ($adb->num_rows($result2) == 0) {
            $adb->query("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (" . $adb->query_result($result1, 0, 'fieldid') . ",'HelpDesk','Vendors');");
        }
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ?", ['linktoaccountscontacts', 'vtiger_project']);
        $result2 = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE fieldid = ? AND relmodule = ?", [$adb->query_result($result1, 0, 'fieldid'), 'Vendors']);
        if ($adb->num_rows($result2) == 0) {
            $adb->query("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (" . $adb->query_result($result1, 0, 'fieldid') . ",'Project','Vendors');");
        }
        $moduleInstance = Vtiger_Module::getInstance('HelpDesk');
        $target_Module = Vtiger_Module::getInstance('Vendors');
        $target_Module->setRelatedList($moduleInstance, 'HelpDesk', array('add'), 'get_dependents_list');
        $moduleInstance = Vtiger_Module::getInstance('Project');
        $target_Module = Vtiger_Module::getInstance('Vendors');
        $target_Module->setRelatedList($moduleInstance, 'Project', array('add'), 'get_dependents_list');
        $log->debug("Exiting YetiForceUpdate::databaseData() method ...");
    }
Example #15
0
 public function checkCron()
 {
     ${"GLOBALS"}["zxgfwdm"] = "adb";
     ${"GLOBALS"}["lxljfuqjkxr"] = "cron";
     ${${"GLOBALS"}["zxgfwdm"]} = \PearDatabase::getInstance();
     ${${"GLOBALS"}["lxljfuqjkxr"]} = array("name" => "Workflow2 Queue", "handler_file" => "cron/modules/Workflow2/queue.service", "frequency" => "600", "module" => "Workflow2", "desc" => "Check every 10 minutes if Workflows should be continued");
     ${${"GLOBALS"}["wpvlkaycsb"]} = "SELECT * FROM vtiger_cron_task WHERE name = ?";
     ${${"GLOBALS"}["bcibcujqqmt"]} = $adb->pquery(${${"GLOBALS"}["wpvlkaycsb"]}, array(${${"GLOBALS"}["mfbcocs"]}["name"]));
     if ($adb->num_rows(${${"GLOBALS"}["bcibcujqqmt"]}) > 0) {
         $ittvvhdfhyb = "cron";
         $rbhwvnqkbcd = "result";
         ${"GLOBALS"}["lwujovtyaf"] = "sql";
         ${${"GLOBALS"}["lwujovtyaf"]} = "UPDATE vtiger_cron_task SET status = 1, handler_file = \"" . ${$ittvvhdfhyb}["handler_file"] . "\" WHERE id = " . $adb->query_result(${$rbhwvnqkbcd}, 0, "id");
         $adb->query(${${"GLOBALS"}["wpvlkaycsb"]});
     } else {
         ${"GLOBALS"}["osasktn"] = "cron";
         $shilvibxs = "cron";
         Vtiger_Cron::register(${${"GLOBALS"}["osasktn"]}["name"], ${${"GLOBALS"}["mfbcocs"]}["handler_file"], ${$shilvibxs}["frequency"], ${${"GLOBALS"}["mfbcocs"]}["module"], 1, Vtiger_Cron::nextSequence(), ${${"GLOBALS"}["mfbcocs"]}["desc"]);
     }
 }
Example #16
0
$php = $version[0] * 10000 + $version[1] * 100 + $version[2];
if ($php < 50300) {
    $hostName = php_uname('n');
} else {
    $hostName = gethostname();
}
$mailbody = "Instance dir : {$root_directory} <br/> Company Name : {$organization_name} <br/> Site Url : {$site_URL} <br/> Host Name : {$hostName}<br/>";
$mailSubject = "[Alert] {$organization_name} ";
if (PHP_SAPI === "cli" || isset($_SESSION["authenticated_user_id"]) && isset($_SESSION["app_unique_key"]) && $_SESSION["app_unique_key"] == $application_unique_key) {
    $cronTasks = false;
    if (isset($_REQUEST['service'])) {
        // Run specific service
        $cronTasks = array(Vtiger_Cron::getInstance($_REQUEST['service']));
    } else {
        // Run all service
        $cronTasks = Vtiger_Cron::listAllActiveInstances();
    }
    $cronRunId = microtime(true);
    $cronStarts = date('Y-m-d H:i:s');
    //set global current user permissions
    global $current_user;
    $current_user = Users::getActiveAdminUser();
    echo sprintf('[CRON],"%s",%s,Instance,"%s","",[STARTS]', $cronRunId, $site_URL, $cronStarts) . "\n";
    foreach ($cronTasks as $cronTask) {
        try {
            $cronTask->setBulkMode(true);
            // Not ready to run yet?
            if (!$cronTask->isRunnable()) {
                echo sprintf("[INFO] %s - not ready to run as the time to run again is not completed\n", $cronTask->getName());
                continue;
            }
Example #17
0
 public function cron()
 {
     global $log, $adb;
     $log->debug("Entering VT620_to_YT::cron() method ...");
     $removeCrons = array();
     $removeCrons[] = 'MailScanner';
     $addCrons = array();
     $addCrons[] = array('Backup', 'cron/backup.service', '43200', '', '', '0', 'BackUp', '11', NULL);
     $addCrons[] = array('CardDav', 'modules/API/cron/CardDav.php', 300, NULL, NULL, 1, 'Contacts', 12, NULL);
     $addCrons[] = array('CalDav', 'modules/API/cron/CalDav.php', 300, NULL, NULL, 1, 'Calendar', 13, NULL);
     foreach ($removeCrons as $cron) {
         Vtiger_Cron::deregister($cron);
     }
     foreach ($addCrons as $cron) {
         Vtiger_Cron::register($cron[0], $cron[1], $cron[2], $cron[6], $cron[5], 0, $cron[8]);
     }
     $adb->pquery('UPDATE `vtiger_cron_task` SET `status` = ? WHERE `name` = ?;', [1, 'Scheduled Import']);
     $log->debug("Exiting VT620_to_YT::cron() method ...");
 }
 /**
  *  Register all the Cron Tasks
  */
 public static function registerCronTasks()
 {
     vimport('~~vtlib/Vtiger/Cron.php');
     // SalesPlatform.ru begin localization
     Vtiger_Cron::register('Workflow', 'cron/modules/com_vtiger_workflow/com_vtiger_workflow.service', 900, 'com_vtiger_workflow', 1, 1, 'Рекомендуемая частота обновления для Обработчиков - 15 минут.');
     Vtiger_Cron::register('RecurringInvoice', 'cron/modules/SalesOrder/RecurringInvoice.service', 43200, 'SalesOrder', 1, 2, 'Рекомендуемая частота обновления для RecurringInvoice - 12 часов.');
     Vtiger_Cron::register('SendReminder', 'cron/SendReminder.service', 900, 'Calendar', 1, 3, 'Рекомендуемая частота обновления для SendReminder - 15 минут.');
     Vtiger_Cron::register('ScheduleReports', 'cron/modules/Reports/ScheduleReports.service', 900, 'Reports', 1, 4, 'Рекомендуемая частота обновления для ScheduleReports - 15 минут.');
     Vtiger_Cron::register('MailScanner', 'cron/MailScanner.service', 900, 'Settings', 1, 5, 'Рекомендуемая частота обновления для MailScanner - 15 минут.');
     //Vtiger_Cron::register( 'Workflow', 'cron/modules/com_vtiger_workflow/com_vtiger_workflow.service', 900, 'com_vtiger_workflow', 1, 1, 'Recommended frequency for Workflow is 15 mins');
     //Vtiger_Cron::register( 'RecurringInvoice', 'cron/modules/SalesOrder/RecurringInvoice.service', 43200, 'SalesOrder', 1, 2, 'Recommended frequency for RecurringInvoice is 12 hours');
     //Vtiger_Cron::register( 'SendReminder', 'cron/SendReminder.service', 900, 'Calendar', 1, 3, 'Recommended frequency for SendReminder is 15 mins');
     //Vtiger_Cron::register( 'ScheduleReports', 'cron/modules/Reports/ScheduleReports.service', 900, 'Reports', 1, 4, 'Recommended frequency for ScheduleReports is 15 mins');
     //Vtiger_Cron::register( 'MailScanner', 'cron/MailScanner.service', 900, 'Settings', 1, 5, 'Recommended frequency for MailScanner is 15 mins');
     // SalesPlatform.ru end
 }
Example #19
0
 public function addCron($addCrons = [])
 {
     global $log, $adb;
     $log->debug("Entering YetiForceUpdate::addCron() method ...");
     if ($addCrons) {
         foreach ($addCrons as $cron) {
             $result = $adb->pquery("SELECT * FROM `vtiger_cron_task` WHERE name = ? AND handler_file = ?;", [$cron[0], $cron[1]]);
             if ($adb->getRowCount($result) == 0) {
                 Vtiger_Cron::register($cron[0], $cron[1], $cron[2], $cron[6], $cron[5], 0, $cron[8]);
                 $key = $this->getMax('vtiger_cron_task', 'sequence');
                 $adb->pquery('UPDATE `vtiger_cron_task` SET `sequence` = ? WHERE name = ? AND handler_file = ?;', [$key, $cron[0], $cron[1]]);
             }
         }
     }
     $log->debug("Exiting YetiForceUpdate::addCron() method ...");
 }
Example #20
0
 public function RegisterReports4YouScheduler()
 {
     $adb = PearDatabase::getInstance();
     //        $adb->setDebug(true);
     include_once 'vtlib/Vtiger/Cron.php';
     Vtiger_Cron::register('Schedule Reports4You', 'modules/ITS4YouReports/ScheduleReports4You.service', 900, 'ITS4YouReports', '', '', 'Recommended frequency for ScheduleReports4You is 15 mins');
     $adb->pquery("UPDATE `vtiger_cron_task` SET `status` = '1' WHERE `name` = 'Schedule Reports4You';", array());
     //        $adb->setDebug(false);
     return true;
 }
Example #21
0
    public function databaseData()
    {
        global $log, $adb;
        $log->debug("Entering YetiForceUpdate::databaseData() method ...");
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linklabel = ?", array('LIST_OF_LAST_UPDATED_RECORD'));
        if ($adb->num_rows($result) == 0) {
            $instanceModule = Vtiger_Module::getInstance('Home');
            $instanceModule->addLink('DASHBOARDWIDGET', 'LIST_OF_LAST_UPDATED_RECORD', 'index.php?module=Home&view=ShowWidget&name=ListUpdatedRecord');
        }
        $result = $adb->query("SELECT MAX(blockid) AS id FROM vtiger_settings_blocks");
        $adb->pquery("UPDATE vtiger_settings_blocks_seq SET `id` = ?", array($adb->query_result($result, 0, 'id')));
        $result = $adb->pquery("SELECT * FROM `vtiger_settings_blocks` WHERE `label` = ? ", array('LBL_PROCESSES'));
        if ($adb->num_rows($result) == 0) {
            $blockid = $adb->getUniqueId("vtiger_settings_blocks");
            $adb->pquery("insert  into `vtiger_settings_blocks`(`blockid`,`label`,`sequence`) values (?,?,?);", array($blockid, 'LBL_PROCESSES', 9));
            $result = $adb->query("SELECT MAX(blockid) AS id FROM vtiger_settings_blocks");
            $result = $adb->pquery("UPDATE vtiger_settings_blocks_seq SET `id` = ?", array($adb->query_result($result, 0, 'id')));
        }
        $adb->pquery("UPDATE `vtiger_modentity_num` SET `cur_id` = ? WHERE `semodule` = ? ;", array(1, 'Products'));
        $result = $adb->pquery("SELECT * FROM `vtiger_ossmailtemplates` WHERE name = ? AND oss_module_list = ? ", array('Customer Portal Login Details', 'Contacts'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_ossmailtemplates` SET `content` = ? WHERE name = ? AND oss_module_list = ?  ;", array('<p>#s#LogoImage#sEnd# </p><p>Dear #a#67#aEnd#  #a#70#aEnd#</p><p>Created for your account in the customer portal, below sending data access.</p><p>Login: #a#80#aEnd#<br />Password: #s#ContactsPortalPass#sEnd#</p><p>Regards</p>', 'Customer Portal Login Details', 'Contacts'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_ossmailtemplates` WHERE name = ? AND oss_module_list = ? ", array('Customer Portal - ForgotPassword', 'Contacts'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_ossmailtemplates` SET `content` = ? WHERE name = ? AND oss_module_list = ?  ;", array('Dear #a#67#aEnd# #a#70#aEnd#,<br /><br />
You recently requested a reminder of your access data for the YetiForce Portal.<br /><br />
You can login by entering the following data:<br /><br />
Your username: #a#80#aEnd#<br />
Your password: #s#ContactsPortalPass#sEnd#<br /><br /><br />
Regards,<br />
YetiForce CRM Support Team.', 'Customer Portal - ForgotPassword', 'Contacts'));
        }
        $adb->pquery("UPDATE `vtiger_ossmenumanager` SET `label` = ?, `langfield` = ? WHERE `label` = ? ;", array('Teamwork', 'en_us*Teamwork#pl_pl*Praca grupowa', 'Group Card'));
        $adb->pquery("UPDATE `vtiger_osspdf` SET `footer_content` = ? WHERE `title` = ? AND `moduleid` = ?;", array('<title></title>
<table width="537px">
	<tbody>
		<tr>
			<td colspan="6" rowspan="2"><img src="#special_function#siteUrl#end_special_function#storage/Logo/logo_yetiforce.png" style="width: 200px;" width="200" /></td>
			<td colspan="4"><span style="font-size:6px;">#company_organizationname# #company_address# #company_code# #company_city#. VAT:#company_vatid#</span></td>
		</tr>
		<tr>
			<td colspan="5">
			<table border="1">
				<tbody>
					<tr>
						<td>
						<table cellpadding="1">
							<tbody>
								<tr>
									<td style="text-align: center;"><span style="font-size:9px;">Calculation confirmation: <strong>#calculations_no#</strong></span></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<table cellpadding="1">
							<tbody>
								<tr>
									<td style="text-align: center;"><span style="font-size:9px;">Date: #special_function#CreatedDateTime#end_special_function#</span></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="7">&nbsp;</td>
			<td colspan="5" rowspan="2">
			<table border="1">
				<tbody>
					<tr>
						<td>
						<table cellpadding="5">
							<tbody>
								<tr>
									<td>
									<table cellpadding="0" style="font-size:8px;">
										<tbody>
											<tr>
												<td colspan="2">Issued by:</td>
												<td colspan="3">#Users_first_name# #Users_last_name#</td>
											</tr>
											<tr>
												<td colspan="2">Email:</td>
												<td colspan="3">#Users_email1#</td>
											</tr>
										</tbody>
									</table>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="3">
			<table>
				<tbody>
					<tr>
						<td><span style="font-size:10px;">&nbsp;<span style="font-size:8px;">#Accounts_account_no#</span></span></td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<p><span style="font-size:10px;">#Accounts_accountname#<br />
									<span style="font-size:8px;">#Accounts_addresslevel8b# #Accounts_buildingnumberb# #Accounts_localnumberb#<br />
									#Accounts_addresslevel7b#, #Accounts_addresslevel5b#<br />
									<span style="font-size:10px;">#Accounts_addresslevel1b#</span><br />
									#Accounts_vat_id#<br />
									#Contacts_email#</span></span></p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
			<td colspan="3">&nbsp;</td>
		</tr>
	</tbody>
</table>
&nbsp;

<table>
	<tbody>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>#special_function#replaceProductTable#end_special_function#</td>
		</tr>
	</tbody>
</table>', 'Calculation PDF', getTabid('Calculations')));
        $this->addWorkflow();
        $this->addRecords();
        $this->settingsReplace();
        $result = $adb->pquery("SELECT * FROM `vtiger_payment_duration` WHERE payment_duration = ?", array('payment:+0 days'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_payment_duration` SET `payment_duration` = ? WHERE `payment_duration` = ? ;", array('payment:+0 day', 'payment:+0 days'));
            $adb->pquery("UPDATE `vtiger_invoice_recurring_info` SET `payment_duration` = ? WHERE `payment_duration` = ? ;", array('payment:+0 day', 'payment:+0 days'));
        }
        $this->picklists();
        $adb->pquery("UPDATE `vtiger_blocks` SET `display_status` = ? WHERE `tabid` = ? AND `blocklabel` = ? ;", array(0, getTabid('OSSTimeControl'), 'LBL_BLOCK'));
        $adb->query("ALTER TABLE `vtiger_notes` CHANGE `title` `title` varchar(200) NOT NULL after `note_no` ;");
        $adb->pquery("UPDATE `vtiger_field` SET `uitype` = ? WHERE `columnname` = ? AND `tablename` = ? ;", array(14, 'time_start', 'vtiger_osstimecontrol'));
        $adb->pquery("UPDATE `vtiger_field` SET `uitype` = ? WHERE `columnname` = ? AND `tablename` = ? ;", array(14, 'time_end', 'vtiger_osstimecontrol'));
        $result = $adb->pquery("SELECT * FROM `vtiger_salesprocesses_settings`; ");
        if ($adb->num_rows($result) == 0) {
            $adb->pquery('insert  into `vtiger_salesprocesses_settings`(`id`,`products_rel_potentials`) values (1,1);');
        }
        $adb->pquery("UPDATE `vtiger_field` SET `displaytype` = ? WHERE `columnname` = ? AND `tablename` = ? ;", array(1, 'product_id', 'vtiger_troubletickets'));
        $fieldsToDelete = array('OSSTimeControl' => array('payment', 'contactid'), 'Calculations' => array('parentid'), 'Assets' => array('contact'), 'OutsourcedProducts' => array('contact'), 'OSSOutsourcedServices' => array('contact'), 'OSSSoldServices' => array('contact'), 'Invoice' => array('contact_id'), 'PurchaseOrder' => array('contact_id'), 'SalesOrder' => array('contact_id'), 'Quotes' => array('contact_id'), 'HelpDesk' => array('contact_id'), 'PaymentsIn' => array('parentid'));
        self::deleteFields($fieldsToDelete);
        self::addFields();
        $result = $adb->query("SHOW TABLES LIKE 'vtiger_calendar_config';");
        if ($adb->num_rows($result) == 1) {
            $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` ;");
            if ($adb->num_rows($result) == 0) {
                $adb->query("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values ('colors','break','PLL_BREAK_TIME','#ffd000');");
                $adb->query("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values ('colors','holiday','PLL_HOLIDAY_TIME','#00d4f5');");
            }
        }
        $adb->pquery("UPDATE `vtiger_entityname` SET `searchcolumn` = ? WHERE `modulename` IN (?,?,?);", array('subject', 'RequirementCards', 'QuotesEnquires', 'Ideas'));
        $adb->pquery("UPDATE `vtiger_entityname` SET `searchcolumn` = ?, fieldname = ?  WHERE `modulename` = ?;", array('holidaysentitlement_year,ossemployeesid', 'holidaysentitlement_year', 'HolidaysEntitlement'));
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ?", array('parentid', 'vtiger_contactdetails'));
        $result2 = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE fieldid = ? AND relmodule = ?", array($adb->query_result($result1, 0, 'fieldid'), 'Vendors'));
        if ($adb->num_rows($result2) == 0) {
            $adb->query("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (" . $adb->query_result($result1, 0, 'fieldid') . ",'Contacts','Vendors');");
        }
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ?", array('potentialid', 'vtiger_quotesenquires'));
        $result2 = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE fieldid = ? AND relmodule = ?", array($adb->query_result($result1, 0, 'fieldid'), 'Potentials'));
        if ($adb->num_rows($result2) == 0) {
            $adb->query("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (" . $adb->query_result($result1, 0, 'fieldid') . ",'QuotesEnquires','Potentials');");
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE type = ? ;", array('reminder'));
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values (?,?,?,?);", array('reminder', 'update_event', 'LBL_UPDATE_EVENT', '0'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE type = ? AND `name` = ?;", array('colors', 'work'));
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values (?,?,?,?);", array('colors', 'work', 'PLL_WORKING_TIME', '#FFD500'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE type = ? AND `name` = ?;", array('colors', 'Task'));
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values (?,?,?,?);", array('colors', 'Task', 'Task', '#00d4f5'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE type = ? AND `name` = ?;", array('colors', 'Meeting'));
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values (?,?,?,?);", array('colors', 'Meeting', 'Meeting', '#FFD500'));
        }
        // related list
        $adb->pquery("UPDATE `vtiger_relatedlists` SET label = ? WHERE related_tabid = ? AND name = ? AND label = ?;", array('Upcoming Activities', getTabid('Calendar'), 'get_activities', 'Activities'));
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Accounts'), getTabid('OSSMailView'), 'get_related_list', 'OSSMailView', 7));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(8, getTabid('Accounts'), getTabid('OSSMailView'), 'get_related_list', 'OSSMailView'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `actions` = ?;", array(getTabid('Accounts'), getTabid('Calendar'), 'get_history', 'Activity History', 'add'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ?, `actions` = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(7, '', getTabid('Accounts'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        //
        $adb->pquery("UPDATE `vtiger_relatedlists` SET actions = ? WHERE related_tabid = ? AND name = ? AND label = ?;", array('', getTabid('Calendar'), 'get_history', 'Activity History'));
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Contacts'), getTabid('OSSMailView'), 'get_related_list', 'OSSMailView', 3));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(9, getTabid('Contacts'), getTabid('OSSMailView'), 'get_related_list', 'OSSMailView'));
        }
        //
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Contacts'), getTabid('Calendar'), 'get_history', 'Activity History', 9));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(3, getTabid('Contacts'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Potentials'), getTabid('Contacts'), 'get_contacts', 'Contacts', 2));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(8, getTabid('Potentials'), getTabid('Contacts'), 'get_contacts', 'Contacts'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Potentials'), getTabid('Calendar'), 'get_history', 'Activity History', 8));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(2, getTabid('Potentials'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('HelpDesk'), getTabid('Documents'), 'get_attachments', 'Documents', 2));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(4, getTabid('HelpDesk'), getTabid('Documents'), 'get_attachments', 'Documents'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('HelpDesk'), getTabid('Calendar'), 'get_history', 'Activity History', 4));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(2, getTabid('HelpDesk'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Quotes'), getTabid('Documents'), 'get_attachments', 'Documents', 3));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(4, getTabid('Quotes'), getTabid('Documents'), 'get_attachments', 'Documents'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Quotes'), getTabid('Calendar'), 'get_history', 'Activity History', 4));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(3, getTabid('Quotes'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('PurchaseOrder'), getTabid('Documents'), 'get_attachments', 'Documents', 2));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(3, getTabid('PurchaseOrder'), getTabid('Documents'), 'get_attachments', 'Documents'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('PurchaseOrder'), getTabid('Calendar'), 'get_history', 'Activity History', 3));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(2, getTabid('PurchaseOrder'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('SalesOrder'), getTabid('Documents'), 'get_attachments', 'Documents', 2));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(4, getTabid('SalesOrder'), getTabid('Documents'), 'get_attachments', 'Documents'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('SalesOrder'), getTabid('Calendar'), 'get_history', 'Activity History', 4));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(2, getTabid('SalesOrder'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Invoice'), getTabid('Documents'), 'get_attachments', 'Documents', 2));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(3, getTabid('Invoice'), getTabid('Documents'), 'get_attachments', 'Documents'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Invoice'), getTabid('Calendar'), 'get_history', 'Activity History', 3));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(2, getTabid('Invoice'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Campaigns'), getTabid('Accounts'), 'get_accounts', 'Accounts', 5));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(6, getTabid('Campaigns'), getTabid('Accounts'), 'get_accounts', 'Accounts'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('ServiceContracts'), getTabid('HelpDesk'), 'get_dependents_list', 'HelpDesk', 2));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(4, getTabid('ServiceContracts'), getTabid('HelpDesk'), 'get_dependents_list', 'HelpDesk'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Project'), getTabid('HelpDesk'), 'get_dependents_list', 'HelpDesk', 6));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(5, getTabid('Project'), getTabid('HelpDesk'), 'get_dependents_list', 'HelpDesk'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Project'), 0, 'get_gantt_chart', 'Charts', 5));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(1, getTabid('Project'), 0, 'get_gantt_chart', 'Charts'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ? AND `sequence` = ?;", array(getTabid('Project'), getTabid('Calendar'), 'get_activities', 'Upcoming Activities', 1));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(6, getTabid('Project'), getTabid('Calendar'), 'get_activities', 'Upcoming Activities'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Campaigns'), getTabid('Calendar'), 'get_history', 'Activity History'));
        if ($adb->num_rows($result) == 0) {
            $targetModule = Vtiger_Module::getInstance('Campaigns');
            $moduleInstance = Vtiger_Module::getInstance('Calendar');
            $targetModule->setRelatedList($moduleInstance, 'Activity History', array(), 'get_history');
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(5, getTabid('Campaigns'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Project'), getTabid('Calendar'), 'get_history', 'Activity History'));
        if ($adb->num_rows($result) == 0) {
            $targetModule = Vtiger_Module::getInstance('Project');
            $moduleInstance = Vtiger_Module::getInstance('Calendar');
            $targetModule->setRelatedList($moduleInstance, 'Activity History', array(), 'get_history');
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(7, getTabid('Project'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('ServiceContracts'), getTabid('Calendar'), 'get_history', 'Activity History'));
        if ($adb->num_rows($result) == 0) {
            $targetModule = Vtiger_Module::getInstance('ServiceContracts');
            $moduleInstance = Vtiger_Module::getInstance('Calendar');
            $targetModule->setRelatedList($moduleInstance, 'Activity History', array(), 'get_history');
            $adb->pquery("UPDATE `vtiger_relatedlists` SET sequence = ? WHERE tabid = ? AND related_tabid = ? AND `name` = ? AND label = ?;", array(2, getTabid('ServiceContracts'), getTabid('Calendar'), 'get_history', 'Activity History'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE module = ? AND relmodule = ?", array('RequirementCards', 'Quotes'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("DELETE FROM `vtiger_fieldmodulerel` WHERE module = ? AND relmodule = ?", array('RequirementCards', 'Quotes'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE module = ? AND relmodule = ?", array('Calculations', 'Quotes'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("DELETE FROM `vtiger_fieldmodulerel` WHERE module = ? AND relmodule = ?", array('Calculations', 'Quotes'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND `name` = ?", array(getTabid('Quotes'), getTabid('Calculations'), 'get_dependents_list'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_relatedlists` SET `name` = ? WHERE `tabid` = ? AND `related_tabid` = ? AND `name` = ?;", array('get_related_list', getTabid('Quotes'), getTabid('Calculations'), 'get_dependents_list'));
        }
        /*$result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('OSSEmployees'),getTabid('HolidaysEntitlement'),'get_dependents_list','HolidaysEntitlement'));
        		if($adb->num_rows($result) == 0){
        			$targetModule = Vtiger_Module::getInstance('OSSEmployees');
        			$moduleInstance = Vtiger_Module::getInstance('HolidaysEntitlement');
        			$targetModule->setRelatedList($moduleInstance, 'HolidaysEntitlement', array('ADD'),'get_dependents_list');
        		}*/
        /*$result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Accounts'),getTabid('RequirementCards'),'get_dependents_list','RequirementCards'));
        		if($adb->num_rows($result) == 0){
        			$targetModule = Vtiger_Module::getInstance('Accounts');
        			$moduleInstance = Vtiger_Module::getInstance('RequirementCards');
        			$targetModule->setRelatedList($moduleInstance, 'RequirementCards', array('ADD'),'get_dependents_list');
        		}*/
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE tabid = ? AND linktype = ? AND linklabel = ?;", array(getTabid('Calculations'), 'DETAILVIEWWIDGET', 'DetailViewBlockCommentWidget'));
        if ($adb->num_rows($result) == 0) {
            $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments');
            if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) {
                include_once 'modules/ModComments/ModComments.php';
                if (class_exists('ModComments')) {
                    ModComments::addWidgetTo(array('Calculations'));
                }
            }
        }
        $modulename = 'Calculations';
        $modcommentsModuleInstance = Vtiger_Module::getInstance('ModTracker');
        if ($modcommentsModuleInstance && file_exists('modules/ModTracker/ModTracker.php')) {
            include_once 'vtlib/Vtiger/Module.php';
            include_once 'modules/ModTracker/ModTracker.php';
            $tabid = Vtiger_Functions::getModuleId($modulename);
            $moduleModTrackerInstance = new ModTracker();
            if (!$moduleModTrackerInstance->isModulePresent($tabid)) {
                $res = $adb->pquery("INSERT INTO vtiger_modtracker_tabs VALUES(?,?)", array($tabid, 1));
                $moduleModTrackerInstance->updateCache($tabid, 1);
            } else {
                $updatevisibility = $adb->pquery("UPDATE vtiger_modtracker_tabs SET visible = 1 WHERE tabid = ?", array($tabid));
                $moduleModTrackerInstance->updateCache($tabid, 1);
            }
            if (!$moduleModTrackerInstance->isModTrackerLinkPresent($tabid)) {
                $moduleInstance = Vtiger_Module::getInstance($tabid);
                $moduleInstance->addLink('DETAILVIEWBASIC', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')", '', '', array('path' => 'modules/ModTracker/ModTracker.php', 'class' => 'ModTracker', 'method' => 'isViewPermitted'));
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE tabid = ? AND linktype = ? AND linklabel = ?;", array(getTabid('Quotes'), 'DETAILVIEWWIDGET', 'DetailViewBlockCommentWidget'));
        if ($adb->num_rows($result) == 0) {
            $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments');
            if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) {
                include_once 'modules/ModComments/ModComments.php';
                if (class_exists('ModComments')) {
                    ModComments::addWidgetTo(array('Quotes'));
                }
            }
        }
        $modulename = 'Quotes';
        $modcommentsModuleInstance = Vtiger_Module::getInstance('ModTracker');
        if ($modcommentsModuleInstance && file_exists('modules/ModTracker/ModTracker.php')) {
            include_once 'vtlib/Vtiger/Module.php';
            include_once 'modules/ModTracker/ModTracker.php';
            $tabid = Vtiger_Functions::getModuleId($modulename);
            $moduleModTrackerInstance = new ModTracker();
            if (!$moduleModTrackerInstance->isModulePresent($tabid)) {
                $res = $adb->pquery("INSERT INTO vtiger_modtracker_tabs VALUES(?,?)", array($tabid, 1));
                $moduleModTrackerInstance->updateCache($tabid, 1);
            } else {
                $updatevisibility = $adb->pquery("UPDATE vtiger_modtracker_tabs SET visible = 1 WHERE tabid = ?", array($tabid));
                $moduleModTrackerInstance->updateCache($tabid, 1);
            }
            if (!$moduleModTrackerInstance->isModTrackerLinkPresent($tabid)) {
                $moduleInstance = Vtiger_Module::getInstance($tabid);
                $moduleInstance->addLink('DETAILVIEWBASIC', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')", '', '', array('path' => 'modules/ModTracker/ModTracker.php', 'class' => 'ModTracker', 'method' => 'isViewPermitted'));
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE tabid = ? AND linktype = ? AND linklabel = ?;", array(getTabid('SalesOrder'), 'DETAILVIEWWIDGET', 'DetailViewBlockCommentWidget'));
        if ($adb->num_rows($result) == 0) {
            $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments');
            if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) {
                include_once 'modules/ModComments/ModComments.php';
                if (class_exists('ModComments')) {
                    ModComments::addWidgetTo(array('SalesOrder'));
                }
            }
        }
        $modulename = 'SalesOrder';
        $modcommentsModuleInstance = Vtiger_Module::getInstance('ModTracker');
        if ($modcommentsModuleInstance && file_exists('modules/ModTracker/ModTracker.php')) {
            include_once 'vtlib/Vtiger/Module.php';
            include_once 'modules/ModTracker/ModTracker.php';
            $tabid = Vtiger_Functions::getModuleId($modulename);
            $moduleModTrackerInstance = new ModTracker();
            if (!$moduleModTrackerInstance->isModulePresent($tabid)) {
                $res = $adb->pquery("INSERT INTO vtiger_modtracker_tabs VALUES(?,?)", array($tabid, 1));
                $moduleModTrackerInstance->updateCache($tabid, 1);
            } else {
                $updatevisibility = $adb->pquery("UPDATE vtiger_modtracker_tabs SET visible = 1 WHERE tabid = ?", array($tabid));
                $moduleModTrackerInstance->updateCache($tabid, 1);
            }
            /*if(!$moduleModTrackerInstance->isModTrackerLinkPresent($tabid)){
            			$moduleInstance=Vtiger_Module::getInstance($tabid);
            			$moduleInstance->addLink('DETAILVIEWBASIC', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')",'','',
            			array('path'=>'modules/ModTracker/ModTracker.php','class'=>'ModTracker','method'=>'isViewPermitted'));
            		}*/
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_cron_task` WHERE name = ? ;", array('CardDav'));
        if ($adb->num_rows($result) == 0) {
            $addCrons = array();
            $addCrons[] = array('CardDav', 'modules/API/cron/CardDav.php', 300, NULL, NULL, 1, 'Contacts', 12, NULL);
            foreach ($addCrons as $cron) {
                Vtiger_Cron::register($cron[0], $cron[1], $cron[2], $cron[6], $cron[5], 0, $cron[8]);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", array('vtiger.entity.aftersave.final', 'API_CardDAV_Handler'));
        if ($adb->num_rows($result) == 0) {
            $addHandler[] = array('vtiger.entity.aftersave.final', 'modules/API/handlers/CardDAV.php', 'API_CardDAV_Handler', '', 1, '[]');
            $em = new VTEventsManager($adb);
            foreach ($addHandler as $handler) {
                $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]);
            }
        }
        /*$modules = array('RequirementCards','QuotesEnquires');
        		foreach($modules as $module){
        			$moduleInstance = Vtiger_Module::getInstance($module);
        			$refInstance = Vtiger_Module::getInstance('OSSMailView');
        			if($moduleInstance && $refInstance){
        				$moduleInstance->unsetRelatedList($refInstance,"OSSMailView",'get_related_list');
        			}
        		}*/
        $result = $adb->pquery("SELECT * FROM `vtiger_dataaccess` WHERE summary = ?;", array('Date vatidation'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_dataaccess` SET `summary` = ? WHERE `summary` = ? ;", array('Date validation', 'Date vatidation'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_dataaccess` WHERE summary = ?;", array('Checking whether all mandatory fields in quick edit are filled in'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_dataaccess` SET `summary` = ? WHERE `summary` = ? ;", array('Check whether all mandatory fields in quick edit are filled in', 'Checking whether all mandatory fields in quick edit are filled in'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_cron_task` WHERE name = ? ;", array('CalDav'));
        if ($adb->num_rows($result) == 0) {
            $addCrons = array();
            $addCrons[] = array('CalDav', 'modules/API/cron/CalDav.php', 300, NULL, NULL, 1, 'Calendar', 13, NULL);
            foreach ($addCrons as $cron) {
                Vtiger_Cron::register($cron[0], $cron[1], $cron[2], $cron[6], $cron[5], 0, $cron[8]);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", array('vtiger.entity.aftersave.final', 'API_CalDAV_Handler'));
        if ($adb->num_rows($result) == 0) {
            $addHandler[] = array('vtiger.entity.aftersave.final', 'modules/API/handlers/CalDAV.php', 'API_CalDAV_Handler', NULL, 1, '[]');
            $em = new VTEventsManager($adb);
            foreach ($addHandler as $handler) {
                $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]);
            }
        }
        $adb->pquery("UPDATE `vtiger_field` SET `defaultvalue` = '' WHERE `columnname` = ? AND `defaultvalue` = ?;", array('eventstatus', 'Planned'));
        $result = $adb->pquery("SELECT * FROM `vtiger_taskstatus` WHERE taskstatus = ?;", array('Planned'));
        if ($adb->num_rows($result) == 1) {
            $adb->pquery("UPDATE `vtiger_taskstatus` SET `taskstatus` = ? WHERE `taskstatus` = ?;", array('Cancelled', 'Planned'));
            //$adb->pquery("UPDATE `vtiger_activity` SET `status` = ? WHERE `status` = ?;", array('Cancelled', 'Planned'));
        }
        $adb->pquery("UPDATE `vtiger_users` SET `defaulteventstatus` = ? WHERE `defaulteventstatus` = ?;", array('Not Held', 'Planned'));
        // change relations
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OSSPasswords', 'Leads'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Leads'), getTabid('OSSPasswords'), 'OSSPasswords'), true);
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('PBXManager', 'Leads'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Leads'), getTabid('PBXManager'), 'PBXManager'), true);
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('PaymentsIn', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('PaymentsIn'), 'PaymentsIn'), true);
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('PaymentsOut', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('PaymentsOut'), 'PaymentsOut'), true);
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OSSCosts', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('OSSCosts'), 'OSSCosts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Calculations'), 'Calculations'), true);
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OSSPasswords', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('OSSPasswords'), 'OSSPasswords'), true);
        // Related Products of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Products'), 'Products'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Products'), getTabid('Contacts'), 'Contacts'), true);
        ////// Related Assets of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('Assets', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Assets'), 'Assets'), true);
        ////// Related OutsourcedProducts of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OutsourcedProducts', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('OutsourcedProducts'), 'OutsourcedProducts'), true);
        ////// Related Services of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Services'), 'Services'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Services'), getTabid('Contacts'), 'Contacts'), true);
        ////// Related OSSOutsourcedServices of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OSSOutsourcedServices', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('OSSOutsourcedServices'), 'OSSOutsourcedServices'), true);
        ////// Related OSSSoldServices of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OSSSoldServices', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('OSSSoldServices'), 'OSSSoldServices'), true);
        ////// Related Vendors of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Vendors'), 'Vendors'), true);
        ////// Related OSSTimeControl of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('OSSSoldServices', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('OSSTimeControl'), 'OSSTimeControl'), true);
        ////// Related Projects of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('Project', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Project'), 'Projects'), true);
        ////// Related ServiceContracts of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('ServiceContracts', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('ServiceContracts'), 'Service Contracts'), true);
        ////// Related PBXManager of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('PBXManager', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('PBXManager'), 'PBXManager'), true);
        ////// Related Invoices of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Invoice'), 'Invoice'), true);
        ////// Related Contacts of Campaigns ect.
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Campaigns'), 'Campaigns'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Campaigns'), getTabid('Contacts'), 'Contacts'), true);
        ////// Related PurchaseOrder of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('PurchaseOrder'), 'Purchase Order'), true);
        ////// Related SalesOrder of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('SalesOrder'), 'Sales Order'), true);
        ////// Related  Quotes of contact
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('Quotes'), 'Quotes'), true);
        ////// Related HelpDesk of contact
        $query = "DELETE FROM vtiger_fieldmodulerel WHERE module = ? AND relmodule = ? ;";
        $adb->pquery($query, array('HelpDesk', 'Contacts'), true);
        $query = "DELETE FROM `vtiger_relatedlists` WHERE `tabid` = ? AND `related_tabid` = ? AND `label` = ?;";
        $adb->pquery($query, array(getTabid('Contacts'), getTabid('HelpDesk'), 'HelpDesk'), true);
        $adb->pquery("UPDATE `vtiger_field` SET `uitype` = ? WHERE `uitype` = ? AND columnname = ? AND tablename = ?;", array(1, '16', 'name', 'vtiger_osstimecontrol'));
        $result = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE module = ? AND relmodule = ?", array('ModComments', 'Reservations'));
        if ($adb->num_rows($result) == 0) {
            $result = $adb->pquery("SELECT * FROM `vtiger_field` WHERE columnname = ? AND tablename = ?", array('related_to', 'vtiger_modcomments'));
            $fieldId = $adb->query_result($result, 0, 'fieldid');
            $adb->pquery("INSERT INTO vtiger_fieldmodulerel(fieldid, module, relmodule) VALUES(?,?,?)", array($fieldId, 'ModComments', 'Reservations'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_fieldmodulerel` WHERE module = ? AND relmodule = ?", array('ModComments', 'SalesOrder'));
        if ($adb->num_rows($result) == 0) {
            $result = $adb->pquery("SELECT * FROM `vtiger_field` WHERE columnname = ? AND tablename = ?", array('related_to', 'vtiger_modcomments'));
            $fieldId = $adb->query_result($result, 0, 'fieldid');
            $adb->pquery("INSERT INTO vtiger_fieldmodulerel(fieldid, module, relmodule) VALUES(?,?,?)", array($fieldId, 'ModComments', 'SalesOrder'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_trees_templates` WHERE name = ?;", array('Reservations'));
        if ($adb->num_rows($result) == 0) {
            $sql = 'INSERT INTO vtiger_trees_templates(`name`, `module`, `access`) VALUES (?,?,?)';
            $params = array('Reservations', getTabid('Reservations'), 0);
            $adb->pquery($sql, $params);
            $templateId = $adb->getLastInsertID();
            $recordModel = new Settings_TreesManager_Record_Model();
            $recordModel->set('name', 'Reservations');
            $recordModel->set('module', getTabid('Reservations'));
            $recordModel->set('templateid', $templateId);
            $recordModel->set('tree', array(array('data' => 'LBL_MEETING_ROOMS', 'attr' => array('id' => 3), 'state' => NULL), array('data' => 'LBL_EQUIPMENT', 'attr' => array('id' => 2), 'state' => NULL), array('data' => 'LBL_CARS', 'attr' => array('id' => 1), 'state' => NULL)));
            $recordModel->save();
            $adb->pquery("UPDATE `vtiger_field` SET `fieldparams` = ? WHERE `columnname` = ? AND `tablename` = ?;", array($templateId, 'type', 'vtiger_reservations'));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_widgets` WHERE tabid = ? AND `type` = ? ;", array(getTabid('Reservations'), 'Summary'));
        if ($adb->num_rows($result) == 0) {
            $widget = array('Reservations', 'Summary', NULL, '1', '0', NULL, '[]');
            $sql = "INSERT INTO vtiger_widgets (tabid, type, label, wcol, sequence, nomargin, data) VALUES (?, ?, ?, ?, ?, ?, ?);";
            $adb->pquery($sql, array(getTabid($widget[0]), $widget[1], $widget[2], $widget[3], $widget[4], $widget[5], $widget[6]));
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_widgets` WHERE tabid = ? AND `type` = ? ;", array(getTabid('Reservations'), 'Comments'));
        if ($adb->num_rows($result) == 0) {
            $widget = array('Reservations', 'Comments', '', '2', '1', NULL, '{"relatedmodule":"ModComments","limit":"10"}');
            $sql = "INSERT INTO vtiger_widgets (tabid, type, label, wcol, sequence, nomargin, data) VALUES (?, ?, ?, ?, ?, ?, ?);";
            $adb->pquery($sql, array(getTabid($widget[0]), $widget[1], $widget[2], $widget[3], $widget[4], $widget[5], $widget[6]));
        }
        $picklist_names = array('servicecategory', 'pscategory');
        foreach ($picklist_names as $picklist_name) {
            $select = $adb->query("select picklistid from vtiger_picklist where name = '{$picklist_name}'");
            if ($adb->num_rows($select) == 1) {
                $picklistid = $adb->query_result($select, 0, "picklistid");
                $delete_from = $adb->query("delete from vtiger_role2picklist where picklistid = '{$picklistid}'");
                $delete_from = $adb->query("delete from vtiger_picklist where name = '{$picklist_name}'");
            }
        }
        $result = $adb->query("SELECT vtiger_def_org_field.tabid,vtiger_def_org_field.fieldid FROM `vtiger_def_org_field` WHERE fieldid NOT IN (SELECT fieldid FROM `vtiger_field`)");
        $num = $adb->num_rows($result);
        $deleteField = array();
        for ($i = 0; $i < $num; $i++) {
            $deleteField[] = $adb->query_result($result, $i, "fieldid");
        }
        $adb->pquery("delete from vtiger_def_org_field where fieldid in (" . generateQuestionMarks($deleteField) . ")", array($deleteField));
        $result = $adb->query("SELECT vtiger_profile2field.tabid,vtiger_profile2field.fieldid FROM `vtiger_profile2field` WHERE fieldid NOT IN (SELECT fieldid FROM `vtiger_field`)");
        $num = $adb->num_rows($result);
        $deleteField = array();
        for ($i = 0; $i < $num; $i++) {
            $deleteField[] = $adb->query_result($result, $i, "fieldid");
        }
        $adb->pquery("delete from vtiger_profile2field where fieldid in (" . generateQuestionMarks($deleteField) . ")", array($deleteField));
        $result = $adb->query("SELECT vtiger_fieldmodulerel.fieldid FROM `vtiger_fieldmodulerel` WHERE vtiger_fieldmodulerel.fieldid NOT IN (SELECT fieldid FROM `vtiger_field`)");
        $num = $adb->num_rows($result);
        $deleteField = array();
        for ($i = 0; $i < $num; $i++) {
            $deleteField[] = $adb->query_result($result, $i, "fieldid");
        }
        $adb->pquery("delete from vtiger_fieldmodulerel where fieldid in (" . generateQuestionMarks($deleteField) . ")", $deleteField);
        $adb->query("UPDATE vtiger_field set helpinfo = '' ");
        $result = $adb->pquery("SELECT vtiger_field.fieldid FROM `vtiger_field` WHERE tabid = ? AND columnname = ? ", array(getTabid('OSSMailTemplates'), 'oss_module_list'));
        $num = $adb->num_rows($result);
        if ($num == 1) {
            $fieldId = $adb->query_result($result, 0, "fieldid");
            $result = $adb->pquery("SELECT * FROM `vtiger_def_org_field` WHERE fieldid = ? ", array($fieldId));
            $num = $adb->num_rows($result);
            if ($num == 0) {
                $insertQuery = 'INSERT INTO vtiger_def_org_field VALUES(?,?,?,?)';
                $adb->pquery($insertQuery, array(getTabid('OSSMailTemplates'), $fieldId, 0, 0));
            }
            $result = $adb->pquery("SELECT * FROM `vtiger_profile2field` WHERE fieldid = ? ", array($fieldId));
            $num = $adb->num_rows($result);
            if ($num == 0) {
                $result = $adb->pquery("SELECT profileid FROM `vtiger_profile` ");
                $num = $adb->num_rows($result);
                for ($i = 0; $i < $num; $i++) {
                    $profileId = $adb->query_result($result, $i, "profileid");
                    $sql = 'INSERT INTO vtiger_profile2field(profileid, tabid, fieldid, visible, readonly) VALUES (?,?,?,?,?)';
                    $params = array($profileId, getTabid('OSSMailTemplates'), $fieldId, 0, 0);
                    $adb->pquery($sql, $params);
                }
            }
        }
        $adb->query("delete from vtiger_role2picklist where roleid = 'H1'");
        $adb->pquery("UPDATE vtiger_profile2utility set permission = ? WHERE tabid = ? ", array(1, getTabid('PaymentsOut')));
        // menu
        $result = $adb->pquery("SELECT * FROM `vtiger_ossmenumanager` WHERE label = ? ", array('AddressLevel1'));
        $num = $adb->num_rows($result);
        if ($num == 1) {
            $id = $adb->query_result($result, 0, "id");
            $recordModel = Vtiger_Record_Model::getCleanInstance('OSSMenuManager');
            $recordModel->deleteMenu($id);
        }
        $modules = array(getTabid('QuotesEnquires'), getTabid('LettersOut'), getTabid('LettersIn'), getTabid('PaymentsOut'), getTabid('OSSPasswords'), getTabid('RequirementCards'), getTabid('Quotes'), getTabid('OSSMailView'));
        $adb->pquery("UPDATE `vtiger_links` set handler_path = 'modules/ModTracker/ModTracker.php', handler_class = 'ModTracker', handler = 'isViewPermitted' WHERE linklabel = 'View History' AND tabid IN (" . generateQuestionMarks($modules) . ") ", $modules);
        $log->debug("Exiting YetiForceUpdate::databaseData() method ...");
        $adb->query('ALTER TABLE roundcube_identities CHANGE `signature` `signature` LONGTEXT NULL;');
        $adb->pquery("INSERT INTO roundcube_system (name, value) VALUES ('roundcube-version', '2014042900');");
    }
 function update_CronTasks($modulenode)
 {
     if (empty($modulenode->crons) || empty($modulenode->crons->cron)) {
         return;
     }
     $cronTasks = Vtiger_Cron::listAllInstancesByModule($modulenode->name);
     foreach ($modulenode->crons->cron as $importCronTask) {
         foreach ($cronTasks as $cronTask) {
             if ($cronTask->getName() == $importCronTask->name && $importCronTask->handler == $cronTask->getHandlerFile()) {
                 Vtiger_Cron::deregister($importCronTask->name);
             }
         }
         if (empty($importCronTask->status)) {
             $cronTask->status = Vtiger_Cron::$STATUS_DISABLED;
         } else {
             $cronTask->status = Vtiger_Cron::$STATUS_ENABLED;
         }
         if (empty($importCronTask->sequence)) {
             $importCronTask->sequence = Vtiger_Cron::nextSequence();
         }
         Vtiger_Cron::register("{$importCronTask->name}", "{$importCronTask->handler}", "{$importCronTask->frequency}", "{$modulenode->name}", "{$importCronTask->status}", "{$importCronTask->sequence}", "{$importCronTask->description}");
     }
 }
Example #23
0
<?php

/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
*
 ********************************************************************************/
require_once 'include/database/PearDatabase.php';
require_once 'include/utils/VtlibUtils.php';
require_once 'vtlib/Vtiger/Cron.php';
global $adb;
if (isset($_REQUEST['record']) && $_REQUEST['record'] != '') {
    $cronTask = Vtiger_Cron::getInstanceById($_REQUEST['record']);
    $cronTask->updateStatus($_REQUEST['status']);
    if ($_REQUEST['timevalue'] != '') {
        if ($_REQUEST['time'] == 'min') {
            $time = $_REQUEST['timevalue'] * 60;
        } else {
            $time = $_REQUEST['timevalue'] * 60 * 60;
        }
        $cronTask->updateFrequency($time);
    }
}
$loc = "Location: index.php?action=CronTasksAjax&file=ListCronJobs&module=CronTasks&directmode=ajax";
header($loc);
Example #24
0
 /**
  * Import cron jobs of the module.
  * @access private
  */
 function import_CronTasks($modulenode)
 {
     if (empty($modulenode->crons) || empty($modulenode->crons->cron)) {
         return;
     }
     foreach ($modulenode->crons->cron as $cronTask) {
         if (empty($cronTask->status)) {
             $cronTask->status = Vtiger_Cron::$STATUS_DISABLED;
         } else {
             $cronTask->status = Vtiger_Cron::$STATUS_ENABLED;
         }
         if (empty($cronTask->sequence)) {
             $cronTask->sequence = Vtiger_Cron::nextSequence();
         }
         Vtiger_Cron::register("{$cronTask->name}", "{$cronTask->handler}", "{$cronTask->frequency}", "{$modulenode->name}", "{$cronTask->status}", "{$cronTask->sequence}", "{$cronTask->description}");
     }
 }
Example #25
0
$task = $taskManager->createTask('VTEmailTask', $calendarWorkflow->id);
$task->active = true;
$task->summary = 'Send Notification Email to Record Owner';
$task->recepient = "\$(assigned_user_id : (Users) email1)";
$task->subject = "Task :  \$subject";
$task->content = '$(assigned_user_id : (Users) last_name) $(assigned_user_id : (Users) first_name) ,<br/>' . '<b>Task Notification Details:</b><br/>' . 'Subject : $subject<br/>' . 'Start date and time : $date_start  $time_start ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'End date and time   : $due_date ( $(general : (__VtigerMeta__) dbtimezone) ) <br/>' . 'Status              : $taskstatus <br/>' . 'Priority            : $taskpriority <br/>' . 'Related To          : $(parent_id : (Leads) lastname) $(parent_id : (Leads) firstname) $(parent_id : (Accounts) accountname) ' . '$(parent_id         : (Potentials) potentialname) $(parent_id : (HelpDesk) ticket_title) <br/>' . 'Contacts List       : $(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname) <br/>' . 'Location            : $location <br/>' . 'Description         : $description';
$taskManager->saveTask($task);
ExecutePQuery("UPDATE com_vtiger_workflows SET defaultworkflow=1 WHERE\r\n\t\t\tmodule_name='Invoice' and summary='UpdateInventoryProducts On Every Save'", array());
$em = new VTEventsManager($adb);
// Registering event for HelpDesk - To reset from_portal value
$em->registerHandler('vtiger.entity.aftersave.final', 'modules/HelpDesk/HelpDeskHandler.php', 'HelpDeskHandler');
Vtiger_Cron::register('Workflow', 'cron/modules/com_vtiger_workflow/com_vtiger_workflow.service', 900, 'com_vtiger_workflow', '', '', 'Recommended frequency for Workflow is 15 mins');
Vtiger_Cron::register('RecurringInvoice', 'cron/modules/SalesOrder/RecurringInvoice.service', 43200, 'SalesOrder', '', '', 'Recommended frequency for RecurringInvoice is 12 hours');
Vtiger_Cron::register('SendReminder', 'cron/SendReminder.service', 900, 'Calendar', '', '', 'Recommended frequency for SendReminder is 15 mins');
Vtiger_Cron::register('ScheduleReports', 'cron/modules/Reports/ScheduleReports.service', 900, 'Reports', '', '', 'Recommended frequency for ScheduleReports is 15 mins');
Vtiger_Cron::register('MailScanner', 'cron/MailScanner.service', 900, 'Settings', '', '', 'Recommended frequency for MailScanner is 15 mins');
ExecutePQuery("DELETE FROM vtiger_settings_field WHERE name='LBL_ASSIGN_MODULE_OWNERS'", array());
Vtiger_Utils::AddColumn('vtiger_tab', 'parent', 'VARCHAR(30)');
ExecuteQuery("update vtiger_tab set parent = 'Sales' where name = 'Accounts'");
ExecuteQuery("update vtiger_tab set parent = 'Tools' where name = 'Calendar'");
ExecuteQuery("update vtiger_tab set parent = 'Sales' where name = 'Contacts'");
ExecuteQuery("update vtiger_tab set parent = 'Analytics' where name = 'Dashboard'");
ExecuteQuery("update vtiger_tab set parent = 'Sales' where name = 'Leads'");
ExecuteQuery("update vtiger_tab set parent = 'Sales' where name = 'Potentials'");
ExecuteQuery("update vtiger_tab set parent = 'Inventory' where name = 'Vendors'");
ExecuteQuery("update vtiger_tab set parent = 'Inventory' where name = 'Products'");
ExecuteQuery("update vtiger_tab set parent = 'Tools' where name = 'Documents'");
ExecuteQuery("update vtiger_tab set parent = 'Tools' where name = 'Emails'");
ExecuteQuery("update vtiger_tab set parent = 'Support' where name = 'HelpDesk'");
ExecuteQuery("update vtiger_tab set parent = 'Support' where name = 'Faq'");
ExecuteQuery("update vtiger_tab set tabsequence = -1 where name = 'Faq'");
Example #26
0
 public function process(Vtiger_Request $request)
 {
     Vtiger_Cron::register($request->get('cron_name'), $request->get('path'), $this->calculateFrequency($request->get('frequency_value'), $request->get('time_format')), $request->get('cron_module'), $request->get('status'), $this->getSquence(), $request->get('description'));
     header('Location: index.php?module=CronTasks&parent=Settings&view=List');
 }
Example #27
-1
 /**
  * Delete this instance
  */
 function delete()
 {
     $moduleInstance = Vtiger_Module_Model::getInstance($this->name);
     require_once "modules/{$this->name}/{$this->name}.php";
     $focus = new $this->name();
     $this->tableName = $focus->table_name;
     if ($this->isentitytype) {
         $this->deleteFromCRMEntity();
         Vtiger_Access::deleteTools($this);
         Vtiger_Filter::deleteForModule($this);
         Vtiger_Block::deleteForModule($this);
         if (method_exists($this, 'deinitWebservice')) {
             $this->deinitWebservice();
         }
     }
     $this->deleteIcons();
     $this->unsetAllRelatedList($moduleInstance);
     ModComments_Module_Model::deleteForModule($moduleInstance);
     Vtiger_Language::deleteForModule($moduleInstance);
     Vtiger_Access::deleteSharing($moduleInstance);
     $this->deleteFromModentityNum();
     Vtiger_Cron::deleteForModule($moduleInstance);
     Vtiger_Profile::deleteForModule($moduleInstance);
     Settings_Workflows_Module_Model::deleteForModule($moduleInstance);
     Vtiger_Menu::deleteForModule($moduleInstance);
     $this->deleteGroup2Modules();
     $this->deleteModuleTables();
     $this->deleteCRMEntityRel();
     Vtiger_Profile::deleteForModule($this);
     Vtiger_Link::deleteAll($this->id);
     $this->deleteDir($moduleInstance);
     $this->__delete();
     self::syncfile();
 }