function vt530_registerVTEntityDeltaApi() { $db = PearDatabase::getInstance(); $em = new VTEventsManager($db); $em->registerHandler('vtiger.entity.beforesave', 'data/VTEntityDelta.php', 'VTEntityDelta'); $em->registerHandler('vtiger.entity.aftersave', 'data/VTEntityDelta.php', 'VTEntityDelta'); }
function registerEvent($event) { global $adb; $em = new VTEventsManager($adb); $em->registerHandler($event, 'build/HelperScripts/coreBOSEventsExample.php', 'coreBOSEventsExample'); echo "<h4>Event {$event} registered.</h4>"; }
function applyChange() { if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; if (vtlib_isModuleActive("Timecontrol") && !vtlib_isModuleActive("Task")) { $result = $adb->pquery("SELECT eventhandler_id FROM vtiger_eventhandlers WHERE handler_path = 'modules/Timecontrol/convertTZListView.php'", array()); if ($adb->num_rows($result) == 0) { $result = $adb->pquery("SELECT eventhandler_id FROM vtiger_eventhandlers WHERE handler_path = 'modules/Task/convertTZListView.php'", array()); if ($adb->num_rows($result) == 1) { $handler_id = $adb->query_result($result, 0, 'eventhandler_id'); $this->ExecuteQuery("UPDATE vtiger_eventhandlers SET handler_path = 'modules/Timecontrol/convertTZListView.php', handler_class = 'convertTZListViewOnTimecontrol' WHERE eventhandler_id = ?", array($handler_id)); } else { $em = new VTEventsManager($adb); $em->registerHandler('corebos.filter.listview.render', 'modules/Timecontrol/convertTZListView.php', 'convertTZListViewOnTimecontrol'); } } } elseif (vtlib_isModuleActive("Timecontrol") && vtlib_isModuleActive("Task")) { $result = $adb->pquery("SELECT eventhandler_id FROM vtiger_eventhandlers WHERE handler_path = 'modules/Timecontrol/convertTZListView.php'", array()); if ($adb->num_rows($result) == 0) { $em = new VTEventsManager($adb); $em->registerHandler('corebos.filter.listview.render', 'modules/Timecontrol/convertTZListView.php', 'convertTZListViewOnTimecontrol'); } } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(false); } $this->finishExecution(); }
public function process(Vtiger_Request $request) { $adb = \PearDatabase::getInstance(); switch ($request->get('option')) { case 'recreateUserPrivilegs': $sql = 'SELECT id FROM vtiger_users WHERE status = "Active"'; $result = $adb->query($sql); require_once 'modules/Users/CreateUserPrivilegeFile.php'; while ($row = $adb->fetchByAssoc($result)) { createUserPrivilegesfile($row['id']); createUserSharingPrivilegesfile($row['id']); ini_set('display_errors', 1); global $root_directory; require_once $root_directory . 'user_privileges/user_privileges_' . $row['id'] . '.php'; require_once $root_directory . 'user_privileges/sharing_privileges_' . $row['id'] . '.php'; } break; case 'enableModComments': $commentsModuleModel = Vtiger_Module_Model::getInstance('ModComments'); if ($commentsModuleModel && $commentsModuleModel->isActive()) { $relatedToFieldResult = $adb->pquery('SELECT fieldid FROM vtiger_field WHERE fieldname = ? AND tabid = ?', array('related_to', $commentsModuleModel->getId())); $fieldId = $adb->query_result($relatedToFieldResult, 0, 'fieldid'); $sql = 'SELECT * FROM vtiger_tab WHERE (isentitytype = 1 AND presence = 0) OR name = "Events"'; $result = $adb->query($sql); while ($row = $adb->fetchByAssoc($result)) { $sql = 'SELECT fieldid FROM vtiger_fieldmodulerel WHERE fieldid = ? AND module = "ModComments" AND relmodule = ?'; $check = $adb->pquery($sql, array($fieldId, $row['name'])); if ($adb->num_rows($check) == 0) { $sql = 'INSERT INTO vtiger_fieldmodulerel SET fieldid = ?, module = "ModComments", relmodule = ?'; $adb->pquery($sql, array($fieldId, $row['name'])); } } } break; case 'initFilterSortOrder': \SwVtTools\DbCheck::checkColumn('vtiger_customview', 'order_col', 'VARCHAR(255)'); \SwVtTools\DbCheck::checkColumn('vtiger_customview', 'order_dir', 'VARCHAR(4)'); \SwVtTools\DbCheck::checkColumn('vtiger_customview', 'order_numeric_check', 'TINYINT'); \SwVtTools\DbCheck::checkColumn('vtiger_customview', 'order_numeric', 'VARCHAR(10)'); $adb = PearDatabase::getInstance(); $em = new VTEventsManager($adb); // Registering event for Recurring Invoices $em->registerHandler('vtiger.filter.process.customview.editajax.view.before', 'modules/SwVtTools/EventHandler.php', 'SwVtToolsEventHandler', ""); $em->registerHandler('vtiger.process.customview.editajax.view.finish', 'modules/SwVtTools/EventHandler.php', 'SwVtToolsEventHandler', ""); $em->registerHandler('vtiger.filter.process.customview.save.action.before', 'modules/SwVtTools/EventHandler.php', 'SwVtToolsEventHandler', ""); $em->registerHandler('vtiger.filter.listview.orderby', 'modules/SwVtTools/EventHandler.php', 'SwVtToolsEventHandler', ""); break; } }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { $em = new VTEventsManager($adb); $em->registerHandler('vtiger.entity.aftersave', 'modules/PBXManager/PBXManagerHandler.php', 'PBXManagerAfterSaveCreateActivity'); $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { require_once 'include/utils/utils.php'; global $adb; if ($eventType == 'module.postinstall') { $fieldid = $adb->getUniqueID('vtiger_settings_field'); $blockid = getSettingsBlockId('LBL_MODULE_MANAGER'); $seq_res = $adb->query("SELECT max(sequence) AS max_seq FROM vtiger_settings_field"); $seq = 1; if ($adb->num_rows($seq_res) > 0) { $cur_seq = $adb->query_result($seq_res, 0, 'max_seq'); if ($cur_seq != null) { $seq = $cur_seq + 1; } } $adb->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence) VALUES (?,?,?,?,?,?,?)', array($fieldid, $blockid, 'LBL_FIELDFORMULAS', 'modules/FieldFormulas/resources/FieldFormulas.png', 'LBL_FIELDFORMULAS_DESCRIPTION', 'index.php?module=FieldFormulas&action=index&parenttab=Settings', $seq)); $tabid = getTabid('FieldFormulas'); if (isset($tabid) && $tabid != '') { $adb->pquery('DELETE FROM vtiger_profile2tab WHERE tabid = ?', array($tabid)); } // Mark the module as Standard module $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName)); } else { if ($eventType == 'module.disabled') { $em = new VTEventsManager($adb); $em->setHandlerInActive('VTFieldFormulasEventHandler'); } else { if ($eventType == 'module.enabled') { $em = new VTEventsManager($adb); $em->setHandlerActive('VTFieldFormulasEventHandler'); } else { if ($eventType == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($eventType == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($eventType == 'module.postupdate') { // TODO Handle actions after this module is updated. } } } } } } }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { global $adb, $currentModule; $modtrackerModule = Vtiger_Module::getInstance($currentModule); $otherModuleNames = $this->getModTrackerEnabledModules(); if ($eventType == 'module.postinstall') { $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName)); $fieldid = $adb->getUniqueID('vtiger_settings_field'); $blockid = getSettingsBlockId('LBL_OTHER_SETTINGS'); $seq_res = $adb->pquery("SELECT max(sequence) AS max_seq FROM vtiger_settings_field WHERE blockid = ?", array($blockid)); if ($adb->num_rows($seq_res) > 0) { $cur_seq = $adb->query_result($seq_res, 0, 'max_seq'); if ($cur_seq != null) { $seq = $cur_seq + 1; } } $adb->pquery('INSERT INTO vtiger_settings_field(fieldid, blockid, name, iconpath, description, linkto, sequence) VALUES (?,?,?,?,?,?,?)', array($fieldid, $blockid, 'ModTracker', 'set-IcoLoginHistory.gif', 'LBL_MODTRACKER_DESCRIPTION', 'index.php?module=ModTracker&action=BasicSettings&parenttab=Settings&formodule=ModTracker', $seq)); } else { if ($eventType == 'module.disabled') { $em = new VTEventsManager($adb); $em->setHandlerInActive('ModTrackerHandler'); // De-register Common Javascript $modtrackerModule->deleteLink('HEADERSCRIPT', 'ModTrackerCommon_JS'); } else { if ($eventType == 'module.enabled') { $em = new VTEventsManager($adb); $em->setHandlerActive('ModTrackerHandler'); // Register Common Javascript $modtrackerModule->addLink('HEADERSCRIPT', 'ModTrackerCommon_JS', 'modules/ModTracker/ModTrackerCommon.js'); } else { if ($eventType == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($eventType == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($eventType == 'module.postupdate') { // TODO Handle actions after this module is updated. } } } } } } }
function process(Vtiger_Request $request) { vimport('~include/events/include.inc'); $db = PearDatabase::getInstance(); $em = new VTEventsManager($db); $em->initTriggerCache(); $em->triggerEvent('user.logout.before', []); Vtiger_Session::regenerateId(true); // to overcome session id reuse. Vtiger_Session::destroy(); //Track the logout History $moduleName = $request->getModule(); $moduleModel = Users_Module_Model::getInstance($moduleName); $moduleModel->saveLogoutHistory(); //End header('Location: index.php'); }
public function addHandler($addHandler = []) { $log = vglobal('log'); $adb = PearDatabase::getInstance(); $log->debug('Entering ' . __CLASS__ . '::' . __METHOD__ . ' method ...'); if ($addHandler) { $em = new VTEventsManager($adb); foreach ($addHandler as $handler) { $result = $adb->pquery('SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;', [$handler[0], $handler[2]]); if ($result->rowCount() == 0) { $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]); } } } $log->debug('Exiting ' . __CLASS__ . '::' . __METHOD__ . ' method ...'); }
<?php require_once 'include/utils/utils.php'; require 'include/events/include.inc'; $em = new VTEventsManager($adb); $em->registerHandler("vtiger.entity.beforesave", "modules/Contacts/ContactosHandler.php", "ContactosHandler", "ModuleName in ['Contacts']"); echo 'Custom Handler Registered !';
/** * Function to related two records of different entity types */ function relateEntities($focus, $sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $log->debug("Entering relateEntities method ({$sourceModule}, {$sourceRecordId}, {$destinationModule}, {$destinationRecordIds})"); require_once 'include/events/include.inc'; //require_once('modules/com_vtiger_workflow/VTWorkflowManager.inc'); //require_once('modules/com_vtiger_workflow/VTEntityCache.inc'); $em = new VTEventsManager($adb); $em->initTriggerCache(); if (!is_array($destinationRecordIds)) { $destinationRecordIds = [$destinationRecordIds]; } $data = []; $data['CRMEntity'] = $focus; $data['entityData'] = VTEntityData::fromEntityId($adb, $sourceRecordId); $data['sourceModule'] = $sourceModule; $data['sourceRecordId'] = $sourceRecordId; $data['destinationModule'] = $destinationModule; foreach ($destinationRecordIds as $destinationRecordId) { $data['destinationRecordId'] = $destinationRecordId; $em->triggerEvent('vtiger.entity.link.before', $data); $focus->save_related_module($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordId); $focus->trackLinkedInfo($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordId); /* $wfs = new VTWorkflowManager($adb); $workflows = $wfs->getWorkflowsForModule($sourceModule, VTWorkflowManager::$ON_RELATED); $entityCache = new VTEntityCache(Users_Record_Model::getCurrentUserModel()); $entityData = VTEntityData::fromCRMEntity($focus); $entityData->eventType = VTWorkflowManager::$ON_RELATED; $entityData->relatedInfo = [ 'destId' => $destinationRecordId, 'destModule' => $destinationModule, ]; foreach ($workflows as $id => $workflow) { if ($workflow->evaluate($entityCache, $entityData->getId())) { $workflow->performTasks($entityData); } } */ $em->triggerEvent('vtiger.entity.link.after', $data); } $log->debug("Exiting relateEntities method ..."); }
//Avoid premature deletion of activity related records $relatedToQuery = "SELECT fieldid FROM vtiger_field WHERE tabid=? AND fieldname=?"; $calendarInstance = Vtiger_Module::getInstance('Calendar'); $tabId = $calendarInstance->id; $result = $adb->pquery($relatedToQuery, array($tabId, 'parent_id')); $fieldId = $adb->query_result($result, 0, 'fieldid'); $insertQuery = "DELETE FROM vtiger_fieldmodulerel where fieldid=?"; $adb->pquery($insertQuery, array($fieldId)); //For contacts the fieldname is contact_id $contactsRelatedToQuery = "SELECT fieldid FROM vtiger_field WHERE tabid=? AND fieldname=?"; $contactsResult = $adb->pquery($contactsRelatedToQuery, array($tabId, 'contact_id')); $contactsFieldId = $adb->query_result($contactsResult, 0, 'fieldid'); $insertQuery = "DELETE FROM vtiger_fieldmodulerel where fieldid=?"; $adb->pquery($insertQuery, array($contactsFieldId)); $module = Vtiger_Module::getInstance('PBXManager'); $ev = new VTEventsManager($adb); $ev->unregisterHandler('PBXManagerHandler'); $ev->unregisterHandler('PBXManagerBatchHandler'); if ($module) { $module->deleteRelatedLists(); $module->deleteLinks(); $module->delete(); ExecuteQuery("DELETE FROM vtiger_def_org_share WHERE tabid=?", array($module->id)); } ExecuteQuery("delete from vtiger_asterisk"); ExecuteQuery("DROP TABLE vtiger_pbxmanager"); ExecuteQuery("DROP TABLE vtiger_pbxmanager_phonelookup"); ExecuteQuery("DELETE FROM vtiger_links WHERE linktype=? AND linklabel=? AND linkurl=?", array('HEADERSCRIPT', 'Incoming Calls', 'modules/PBXManager/resources/PBXManagerJS.js')); ExecuteQuery("DELETE FROM vtiger_relatedlists WHERE name=? and label=?", array('get_dependents_list', "PBXManager")); vtws_deleteWebserviceEntity('PBXManager'); ExecuteQuery('DELETE FROM vtiger_settings_blocks WHERE label=?', array('LBL_INTEGRATION'));
public function createRecords() { $adb = PearDatabase::getInstance(); $moduleName = $this->module; $focus = CRMEntity::getInstance($moduleName); $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user); $moduleMeta = $moduleHandler->getMeta(); $moduleObjectId = $moduleMeta->getEntityId(); $moduleFields = $moduleMeta->getModuleFields(); $entityData = array(); $tableName = Import_Utils_Helper::getDbTableName($this->user); $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Action::$IMPORT_RECORD_NONE; if ($this->batchImport) { $configReader = new Import_Config_Model(); $importBatchLimit = $configReader->get('importBatchLimit'); $sql .= ' LIMIT ' . $importBatchLimit; } $result = $adb->query($sql); $numberOfRecords = $adb->num_rows($result); if ($numberOfRecords <= 0) { return; } $fieldMapping = $this->fieldMapping; $fieldColumnMapping = $moduleMeta->getFieldColumnMapping(); for ($i = 0; $i < $numberOfRecords; ++$i) { $row = $adb->raw_query_result_rowdata($result, $i); $rowId = $row['id']; $entityInfo = null; $fieldData = array(); foreach ($fieldMapping as $fieldName => $index) { $fieldData[$fieldName] = $row[$fieldName]; } $mergeType = $this->mergeType; $createRecord = false; if (method_exists($focus, 'importRecord')) { $entityInfo = $focus->importRecord($this, $fieldData); } else { if (!empty($mergeType) && $mergeType != Import_Utils_Helper::$AUTO_MERGE_NONE) { $queryGenerator = new QueryGenerator($moduleName, $this->user); $customView = new CustomView($moduleName); $viewId = $customView->getViewIdByName('All', $moduleName); if (!empty($viewId)) { $queryGenerator->initForCustomViewById($viewId); } else { $queryGenerator->initForDefaultCustomView(); } $fieldsList = array('id'); $queryGenerator->setFields($fieldsList); $mergeFields = $this->mergeFields; if ($queryGenerator->getWhereFields() && $mergeFields) { $queryGenerator->addConditionGlue(QueryGenerator::$AND); } foreach ($mergeFields as $index => $mergeField) { if ($index != 0) { $queryGenerator->addConditionGlue(QueryGenerator::$AND); } $comparisonValue = $fieldData[$mergeField]; $fieldInstance = $moduleFields[$mergeField]; if ($fieldInstance->getFieldDataType() == 'owner') { $userId = getUserId_Ol($comparisonValue); $comparisonValue = getUserFullName($userId); } if ($fieldInstance->getFieldDataType() == 'reference') { if (strpos($comparisonValue, '::::') > 0) { $referenceFileValueComponents = explode('::::', $comparisonValue); } else { $referenceFileValueComponents = explode(':::', $comparisonValue); } if (count($referenceFileValueComponents) > 1) { $comparisonValue = trim($referenceFileValueComponents[1]); } } $queryGenerator->addCondition($mergeField, $comparisonValue, 'e', '', '', '', true); } $query = $queryGenerator->getQuery(); $duplicatesResult = $adb->query($query); $noOfDuplicates = $adb->num_rows($duplicatesResult); if ($noOfDuplicates > 0) { if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_IGNORE) { $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED; } elseif ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) { for ($index = 0; $index < $noOfDuplicates - 1; ++$index) { $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']); $entityId = vtws_getId($moduleObjectId, $duplicateRecordId); vtws_delete($entityId, $this->user); } $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']); $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId); if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE) { $fieldData = $this->transformForImport($fieldData, $moduleMeta); $fieldData['id'] = $baseEntityId; $entityInfo = vtws_update($fieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED; } if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) { $filteredFieldData = array(); foreach ($fieldData as $fieldName => $fieldValue) { // empty will give false for value = 0 if (!empty($fieldValue) || $fieldValue != "") { $filteredFieldData[$fieldName] = $fieldValue; } } // Custom handling for default values & mandatory fields // need to be taken care than normal import as we merge // existing record values with newer values. $fillDefault = false; $mandatoryValueChecks = false; $existingFieldValues = vtws_retrieve($baseEntityId, $this->user); $defaultFieldValues = $this->getDefaultFieldValues($moduleMeta); foreach ($existingFieldValues as $fieldName => $fieldValue) { if (empty($fieldValue) && empty($filteredFieldData[$fieldName]) && !empty($defaultFieldValues[$fieldName])) { $filteredFieldData[$fieldName] = $defaultFieldValues[$fieldName]; } } $filteredFieldData = $this->transformForImport($filteredFieldData, $moduleMeta, $fillDefault, $mandatoryValueChecks); $filteredFieldData['id'] = $baseEntityId; $entityInfo = vtws_revise($filteredFieldData, $this->user); $entityInfo['status'] = self::$IMPORT_RECORD_MERGED; $fieldData = $filteredFieldData; } } else { $createRecord = true; } } else { $createRecord = true; } } else { $createRecord = true; } if ($createRecord) { $fieldData = $this->transformForImport($fieldData, $moduleMeta); if ($fieldData == null) { $entityInfo = null; } else { try { $entityInfo = vtws_create($moduleName, $fieldData, $this->user); } catch (Exception $e) { } } } } if ($entityInfo == null) { $entityInfo = array('id' => null, 'status' => self::$IMPORT_RECORD_FAILED); } else { if ($createRecord) { $entityInfo['status'] = self::$IMPORT_RECORD_CREATED; } } if ($createRecord || $mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS || $mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE) { $entityIdComponents = vtws_getIdComponents($entityInfo['id']); $recordId = $entityIdComponents[1]; $entityfields = getEntityFieldNames($this->module); switch ($this->module) { case 'HelpDesk': $entityfields['fieldname'] = array('ticket_title'); break; case 'Documents': $entityfields['fieldname'] = array('notes_title'); break; case 'Documents': $entityfields['fieldname'] = array('notes_title'); break; } $label = ''; if (is_array($entityfields['fieldname'])) { foreach ($entityfields['fieldname'] as $field) { $label .= $fieldData[$field] . " "; } } else { $label = $fieldData[$entityfields['fieldname']]; } $label = trim($label); $adb->pquery('UPDATE vtiger_crmentity SET label=? WHERE crmid=?', array($label, $recordId)); } $this->importedRecordInfo[$rowId] = $entityInfo; $this->updateImportStatus($rowId, $entityInfo); } if ($this->entityData) { $entity = new VTEventsManager($adb); $entity->triggerEvent('vtiger.batchevent.save', $this->entityData); } $this->entityData = null; $result = null; return true; }
/** Function to restore a deleted record of specified module with given crmid * @param $module -- module name:: Type varchar * @param $entity_ids -- list of crmids :: Array */ function restore($module, $id) { global $current_user, $adb; $this->db->println("TRANS restore starts {$module}"); $this->db->startTransaction(); $date_var = date("Y-m-d H:i:s"); $query = 'UPDATE vtiger_crmentity SET deleted=0,modifiedtime=?,modifiedby=? WHERE crmid = ?'; $this->db->pquery($query, array($this->db->formatDate($date_var, true), $current_user->id, $id), true, "Error restoring records :"); //Restore related entities/records $this->restoreRelatedRecords($module, $id); //Event triggering code require_once "include/events/include.inc"; global $adb; $em = new VTEventsManager($adb); // Initialize Event trigger cache $em->initTriggerCache(); $this->id = $id; $entityData = VTEntityData::fromCRMEntity($this); //Event triggering code $em->triggerEvent("vtiger.entity.afterrestore", $entityData); //Event triggering code ends $this->db->completeTransaction(); $this->db->println("TRANS restore ends"); }
function applyChange() { global $adb; if ($this->hasError()) { $this->sendError(); } if ($this->isApplied()) { $this->sendMsg('Changeset ' . get_class($this) . ' already applied!'); } else { global $adb; $em = new VTEventsManager($adb); $em->registerHandler('vtiger.entity.aftersave', 'modules/Emails/evcbrcHandler.php', 'evcbrcHandler'); $modPrj = Vtiger_Module::getInstance('Project'); $modPrjTsk = Vtiger_Module::getInstance('ProjectTask'); $modPot = Vtiger_Module::getInstance('Potentials'); $modHD = Vtiger_Module::getInstance('HelpDesk'); $modEmail = Vtiger_Module::getInstance('Emails'); $modPrj->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails'); $modPrjTsk->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails'); $modPot->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails'); $modHD->setRelatedList($modEmail, 'Emails', array('add'), 'get_emails'); $block = VTiger_Block::getInstance('LBL_PROJECT_INFORMATION', $modPrj); $field = Vtiger_Field::getInstance('email', $modPrj); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'email'; $field->uitype = 13; $field->label = 'Email'; $field->columntype = 'VARCHAR(150)'; $field->typeofdata = 'E~O'; $field->displaytype = 2; $block->addField($field); } $block = VTiger_Block::getInstance('LBL_PROJECT_TASK_INFORMATION', $modPrjTsk); $field = Vtiger_Field::getInstance('email', $modPrjTsk); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'email'; $field->uitype = 13; $field->label = 'Email'; $field->columntype = 'VARCHAR(150)'; $field->typeofdata = 'E~O'; $field->displaytype = 2; $block->addField($field); } $block = VTiger_Block::getInstance('LBL_OPPORTUNITY_INFORMATION', $modPot); $field = Vtiger_Field::getInstance('email', $modPot); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'email'; $field->uitype = 13; $field->label = 'Email'; $field->columntype = 'VARCHAR(150)'; $field->typeofdata = 'E~O'; $field->displaytype = 2; $block->addField($field); } $block = VTiger_Block::getInstance('LBL_TICKET_INFORMATION', $modHD); $field = Vtiger_Field::getInstance('email', $modHD); if ($field) { $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id); } else { $field = new Vtiger_Field(); $field->name = 'email'; $field->uitype = 13; $field->label = 'Email'; $field->columntype = 'VARCHAR(150)'; $field->typeofdata = 'E~O'; $field->displaytype = 2; $block->addField($field); } $this->sendMsg('Changeset ' . get_class($this) . ' applied!'); $this->markApplied(); } $this->finishExecution(); }
public function triggerAfterSaveEventHandlers() { $adb = PearDatabase::getInstance(); require_once "include/events/include.inc"; //In Bulk mode stop triggering events if (!self::isBulkSaveMode()) { $em = new VTEventsManager($adb); // Initialize Event trigger cache $em->initTriggerCache(); $entityData = VTEntityData::fromCRMEntity($this); } //Event triggering code ends if ($em) { //Event triggering code $em->triggerEvent("vtiger.entity.aftersave", $entityData); $em->triggerEvent("vtiger.entity.aftersave.final", $entityData); } }
public function databaseData() { global $log, $adb; $log->debug("Entering YetiForceUpdate::databaseData() method ..."); $this->addFields(); $adb->query("UPDATE vtiger_eventhandlers_seq SET `id` = (SELECT MAX(eventhandler_id) FROM `vtiger_eventhandlers`);"); $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", array('vtiger.entity.link.after', 'HelpDeskHandler')); if ($adb->num_rows($result) == 0) { $addHandler = array(); $addHandler[] = array('vtiger.entity.link.after', 'modules/HelpDesk/handlers/HelpDeskHandler.php', 'HelpDeskHandler', '', '1', '[]'); $em = new VTEventsManager($adb); foreach ($addHandler as $handler) { $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]); } } $template[] = array('Notify Owner On Ticket Change', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Account On Ticket Change', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Contact On Ticket Closed', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Account On Ticket Closed', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Contact On Ticket Create', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Account On Ticket Create', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Contact On Ticket Change', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Owner On Ticket Closed', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Notify Owner On Ticket Create', 'HelpDesk', 'PLL_RECORD'); $template[] = array('Customer Portal Login Details', 'Contacts', 'PLL_RECORD'); $template[] = array('Send invitations', 'Events', 'PLL_RECORD'); $template[] = array('Send Notification Email to Record Owner', 'Calendar', 'PLL_RECORD'); $template[] = array('Activity Reminder Notification', 'Calendar', 'PLL_RECORD'); $template[] = array('Activity Reminder Notification', 'Events', 'PLL_RECORD'); $template[] = array('Test mail about the mail server configuration.', 'Users', 'PLL_RECORD'); $template[] = array('ForgotPassword', 'Users', 'PLL_RECORD'); $template[] = array('Customer Portal - ForgotPassword', 'Contacts', 'PLL_RECORD'); $template[] = array('New comment added to ticket from portal', 'ModComments', 'PLL_RECORD'); $template[] = array('New comment added to ticket', 'ModComments', 'PLL_RECORD'); $template[] = array('Security risk has been detected - Brute Force', 'Contacts', 'PLL_MODULE'); $template[] = array('Backup has been made', 'Contacts', 'PLL_MODULE'); $result = $adb->query("SHOW COLUMNS FROM `vtiger_ossmailtemplates` LIKE 'ossmailtemplates_type';"); if ($adb->num_rows($result) == 1) { foreach ($template as $temp) { $adb->pquery("UPDATE `vtiger_ossmailtemplates` set ossmailtemplates_type = ? WHERE `name` = ? AND oss_module_list = ? ", array($temp[2], $temp[0], $temp[1])); } } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('OSSMailTemplates'), getTabid('Documents'), 'get_attachments', 'Documents')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Documents'); $target_Module = Vtiger_Module::getInstance('OSSMailTemplates'); $target_Module->setRelatedList($moduleInstance, 'Documents', array('add,select'), 'get_attachments'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('HelpDesk'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('HelpDesk'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('SELECT'), 'get_related_list'); } $adb->pquery("UPDATE `vtiger_field` set displaytype = ? WHERE `columnname` = ?;", array(2, 'was_read')); $adb->pquery("UPDATE `vtiger_field` set uitype = ? WHERE `columnname` = ? AND tablename = ?;", array(15, 'industry', 'vtiger_leaddetails')); $adb->pquery("UPDATE `vtiger_calendar_default_activitytypes` set active = ? ;", array(1)); $adb->pquery("UPDATE `com_vtiger_workflows` SET `type` = ? WHERE `summary` = ? AND module_name = ? ;", array('[]', 'Ticket Creation: Send Email to Record Contact', 'HelpDesk')); $result = $adb->pquery("SELECT workflow_id FROM `com_vtiger_workflows` WHERE summary = ? AND module_name =? ", array('Send Customer Login Details', 'Contacts')); if ($adb->num_rows($result) == 1) { $workflow_id = $adb->query_result_raw($result, 0, 'workflow_id'); $workflowTaskAdd = array(128, 53, 'Mark portal users password as sent.', 'O:18:"VTEntityMethodTask":7:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"53";s:7:"summary";s:35:"Mark portal users password as sent.";s:6:"active";b:0;s:7:"trigger";N;s:10:"methodName";s:16:"MarkPasswordSent";s:2:"id";i:128;}'); $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? AND workflow_id =? ", array($workflowTaskAdd[2], $workflow_id)); if ($adb->num_rows($result) == 0) { $taskManager = new VTTaskManager($adb); $task = $taskManager->unserializeTask($workflowTaskAdd[3]); $task->id = ''; $task->workflowId = $workflow_id; $taskManager->saveTask($task); } } $adb->pquery('UPDATE com_vtiger_workflows SET defaultworkflow = "0" WHERE `summary` = ? AND module_name = ?;', array('Ticket Creation: Send Email to Record Contact', 'HelpDesk')); $result = $adb->pquery('SELECT * FROM com_vtiger_workflows WHERE `summary` = ? AND module_name = ?;', array('Ticket Creation: Send Email to Record Contact', 'HelpDesk')); for ($i = 0; $i < $adb->num_rows($result); $i++) { $recordId = $adb->query_result($result, $i, 'workflow_id'); $adb->pquery("DELETE FROM com_vtiger_workflowtasks WHERE workflow_id IN\n\t\t\t\t\t\t\t(SELECT workflow_id FROM com_vtiger_workflows WHERE workflow_id=? AND (defaultworkflow IS NULL OR defaultworkflow != 1))", array($recordId)); $adb->pquery("DELETE FROM com_vtiger_workflows WHERE workflow_id=? AND (defaultworkflow IS NULL OR defaultworkflow != 1)", array($recordId)); } $result = $adb->pquery('SELECT * FROM com_vtiger_workflowtasks WHERE `summary` IN (?,?);', array('Notify Contact On Ticket Closed', 'Notify Contact On Ticket Change')); for ($i = 0; $i < $adb->num_rows($result); $i++) { $recordId = $adb->query_result($result, $i, 'task_id'); $adb->pquery("delete from com_vtiger_workflowtasks where task_id=?", array($recordId)); } $task_entity_method[] = array('HelpDesk', 'HeldDeskChangeNotifyContacts', 'modules/HelpDesk/workflows/HelpDeskWorkflow.php', 'HeldDeskChangeNotifyContacts'); $task_entity_method[] = array('HelpDesk', 'HeldDeskClosedNotifyContacts', 'modules/HelpDesk/workflows/HelpDeskWorkflow.php', 'HeldDeskClosedNotifyContacts'); $emm = new VTEntityMethodManager($adb); foreach ($task_entity_method as $method) { $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks_entitymethod` WHERE method_name = ? ", array($method[1])); if ($adb->num_rows($result) == 0) { $emm->addEntityMethod($method[0], $method[1], $method[2], $method[3]); } } $adb->pquery('UPDATE com_vtiger_workflows SET test = ? WHERE `summary` = ? AND module_name = ?;', array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is","value":"Closed","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket Closed: Send Email to Record Contact', 'HelpDesk')); $adb->pquery('UPDATE com_vtiger_workflows SET test = ? WHERE `summary` = ? AND module_name = ?;', array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is not","value":"Closed","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket change: Send Email to Record Contact', 'HelpDesk')); $result = $adb->pquery("SELECT workflow_id FROM `com_vtiger_workflows` WHERE summary = ? AND module_name =? ", array('Ticket change: Send Email to Record Contact', 'HelpDesk')); if ($adb->num_rows($result) == 1) { $workflow_id = $adb->query_result_raw($result, 0, 'workflow_id'); $workflowTaskAdd = array(133, 26, 'Notify Contact On Ticket Change', 'O:18:"VTEntityMethodTask":7:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"26";s:7:"summary";s:31:"Notify Contact On Ticket Change";s:6:"active";b:0;s:7:"trigger";N;s:10:"methodName";s:28:"HeldDeskChangeNotifyContacts";s:2:"id";i:133;}'); $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? AND workflow_id =? ", array($workflowTaskAdd[2], $workflow_id)); if ($adb->num_rows($result) == 0) { $taskManager = new VTTaskManager($adb); $task = $taskManager->unserializeTask($workflowTaskAdd[3]); $task->id = ''; $task->workflowId = $workflow_id; $taskManager->saveTask($task); } } $result = $adb->pquery("SELECT workflow_id FROM `com_vtiger_workflows` WHERE summary = ? AND module_name =? ", array('Ticket Closed: Send Email to Record Contact', 'HelpDesk')); if ($adb->num_rows($result) == 1) { $workflow_id = $adb->query_result_raw($result, 0, 'workflow_id'); $workflowTaskAdd = array(134, 29, 'Notify contacts about closing of ticket.', 'O:18:"VTEntityMethodTask":7:{s:18:"executeImmediately";b:1;s:10:"workflowId";s:2:"29";s:7:"summary";s:40:"Notify contacts about closing of ticket.";s:6:"active";b:0;s:7:"trigger";N;s:10:"methodName";s:28:"HeldDeskClosedNotifyContacts";s:2:"id";i:134;}'); $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? AND workflow_id =? ", array($workflowTaskAdd[2], $workflow_id)); if ($adb->num_rows($result) == 0) { $taskManager = new VTTaskManager($adb); $task = $taskManager->unserializeTask($workflowTaskAdd[3]); $task->id = ''; $task->workflowId = $workflow_id; $taskManager->saveTask($task); } } $this->settingsReplace(); $this->picklists(); $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('showMailAccounts')); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','showMailAccounts','false');"); } $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('showNumberUnreadEmails')); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','showNumberUnreadEmails','false');"); } $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('showMailIcon')); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','showMailIcon','true');"); } $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('timeCheckingMail')); if ($adb->num_rows($result) == 0) { $result = $adb->pquery("SELECT * FROM `vtiger_ossmailscanner_config` WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'time_checking_mail')); $value = $adb->query_result($result, 0, 'value'); if (!$value) { $value = 30; } $adb->pquery("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('mailIcon','timeCheckingMail',?);", array($value)); } $result = $adb->pquery("SELECT * FROM `yetiforce_mail_config` WHERE name = ? ", array('autologinActive')); if ($adb->num_rows($result) == 0) { $result = $adb->pquery("SELECT * FROM `vtiger_ossmailscanner_config` WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'autologon')); $value = $adb->query_result($result, 0, 'value'); if (!$value) { $value = 'false'; } $adb->pquery("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('autologin','autologinActive',?);", array('false')); } $result = $adb->pquery('SELECT * FROM `yetiforce_mail_config` WHERE type = ? AND name = ?;', array('signature', 'signature')); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('signature','signature','');"); } $result = $adb->pquery('SELECT * FROM `yetiforce_mail_config` WHERE type = ? AND name = ?;', array('signature', 'addSignature')); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_mail_config`(`type`,`name`,`value`) values ('signature','addSignature','false');"); } $adb->pquery("DELETE FROM vtiger_ossmailscanner_config WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'autologon')); $adb->pquery("DELETE FROM vtiger_ossmailscanner_config WHERE conf_type = ? AND `parameter` = ? ;", array('email_list', 'time_checking_mail')); $adb->pquery("UPDATE `com_vtiger_workflows` SET `test` = ? WHERE `summary` = ? ;", array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is not","value":"Closed","valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"(assigned_user_id : (Users) emailoptout)","operation":"is","value":"1","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket change: Send Email to Record Owner')); $adb->pquery("UPDATE `com_vtiger_workflows` SET `test` = ? WHERE `summary` = ? ;", array('[{"fieldname":"ticketstatus","operation":"has changed","value":null,"valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"ticketstatus","operation":"is","value":"Closed","valuetype":"rawtext","joincondition":"and","groupjoin":"and","groupid":"0"},{"fieldname":"(assigned_user_id : (Users) emailoptout)","operation":"is","value":"1","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'Ticket Closed: Send Email to Record Owner')); $result = $adb->pquery("SELECT * FROM `com_vtiger_workflowtasks` WHERE summary = ? ", array('Update Closed Time')); if ($adb->num_rows($result) == 1) { $task_id = $adb->query_result($result, 0, 'task_id'); $taskRecordModel = Settings_Workflows_TaskRecord_Model::getInstance($task_id); $taskObject = $taskRecordModel->getTaskObject(); $taskObject->active = false; $taskRecordModel->save(); } $adb->pquery('UPDATE `vtiger_field` SET uitype = ? WHERE tabid = ? AND columnname = ? ;', array(19, getTabid('Emails'), 'description')); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid =?;', [3, 'vtiger_activity', 'date_start', getTabid('Calendar')]); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid =?;', [10, 'vtiger_activity', 'date_start', getTabid('Events')]); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid =?;', [4, 'vtiger_activity', 'due_date', getTabid('Calendar')]); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid =?;', [11, 'vtiger_activity', 'due_date', getTabid('Events')]); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_contactdetails', 'firstname']); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_contactdetails', 'parentid']); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_contactdetails', 'email']); $adb->pquery('UPDATE `vtiger_field` SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_contactdetails', 'smownerid']); $result = $adb->pquery("SELECT * FROM `vtiger_support_processes`;"); if ($adb->num_rows($result) == 0) { $adb->query("insert into `vtiger_support_processes`(`id`,`ticket_status_indicate_closing`) values (1,'');"); } $result = $adb->pquery('SELECT quickcreatesequence FROM `vtiger_field` WHERE tablename = ? AND columnname = ? AND tabid =?;', array('vtiger_seactivityrel', 'crmid', getTabid('Calendar'))); $result2 = $adb->pquery('SELECT quickcreatesequence FROM `vtiger_field` WHERE tablename = ? AND columnname = ? AND tabid =?;', array('vtiger_seactivityrel', 'crmid', getTabid('Events'))); if ($adb->num_rows($result) == 1) { $quickcreatesequence = $adb->query_result($result, 0, 'quickcreatesequence'); $adb->pquery('UPDATE `vtiger_field` SET columnname=?,tablename=?,fieldname=?,fieldlabel=?, quickcreate=? WHERE tablename = ? AND columnname = ? ;', ['process', 'vtiger_activity', 'process', 'Process', '1', 'vtiger_seactivityrel', 'crmid']); $adb->pquery('UPDATE `vtiger_field` SET columnname=?,tablename=?,fieldname=?,fieldlabel=?, quickcreate=?, uitype=?, quickcreatesequence=?, summaryfield=? WHERE tablename = ? AND columnname = ? AND tabid = ?;', ['link', 'vtiger_activity', 'link', 'Relation', '2', '67', $quickcreatesequence, '1', 'vtiger_cntactivityrel', 'contactid', getTabid('Calendar')]); $quickcreatesequence = $adb->query_result($result2, 0, 'quickcreatesequence'); $adb->pquery('UPDATE `vtiger_field` SET columnname=?,tablename=?,fieldname=?,fieldlabel=?, quickcreate=?, uitype=?, quickcreatesequence=?, summaryfield=? WHERE tablename = ? AND columnname = ? AND tabid = ?;', ['link', 'vtiger_activity', 'link', 'Relation', '2', '67', $quickcreatesequence, '1', 'vtiger_cntactivityrel', 'contactid', getTabid('Events')]); } $result = $adb->pquery("SELECT * FROM `vtiger_realization_process`;"); if ($adb->num_rows($result) == 0) { $adb->pquery("INSERT INTO vtiger_realization_process(module_id, status_indicate_closing) VALUES(?,?)", array(getTabid('Project'), '')); } $adb->pquery("DELETE FROM vtiger_settings_field WHERE name = ?;", array('LBL_CONVERSION_TO_ACCOUNT')); $adb->pquery('UPDATE `vtiger_settings_field` SET `name` = ?, `description` = ?, `linkto` = ? WHERE `name` = ? AND `description` = ? ;', ['LBL_MENU_BUILDER', 'LBL_MENU_BUILDER_DESCRIPTION', 'index.php?module=Menu&view=Index&parent=Settings', 'Menu Manager', 'LBL_MENU_DESC']); $result = $adb->query("SELECT * FROM `yetiforce_auth`;"); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_auth`(`type`,`param`,`value`) values ('ldap','active','false');"); $adb->query("insert into `yetiforce_auth`(`type`,`param`,`value`) values ('ldap','server','testlab.local');"); $adb->query("insert into `yetiforce_auth`(`type`,`param`,`value`) values ('ldap','port','389');"); $adb->pquery("insert into `yetiforce_auth`(`type`,`param`,`value`) values (?,?,?);", ['ldap', 'users', NULL]); } $result = $adb->pquery("SELECT * FROM `yetiforce_auth` WHERE `param` = ?;", ['domain']); if ($adb->num_rows($result) == 0) { $adb->pquery("insert into `yetiforce_auth`(`type`,`param`,`value`) values (?,?,?);", ['ldap', 'domain', NULL]); } $result = $adb->pquery("SELECT * FROM `yetiforce_menu`;"); if ($adb->num_rows($result) == 0) { $menu[] = array(44, 0, 0, 2, 1, NULL, 'MEN_VIRTUAL_DESK', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(45, 0, 44, 0, 0, getTabid('Home'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(46, 0, 44, 0, 1, getTabid('Calendar'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(47, 0, 0, 2, 2, NULL, 'MEN_LEADS', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(48, 0, 47, 0, 0, getTabid('Leads'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(49, 0, 47, 0, 1, getTabid('Contacts'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(50, 0, 47, 0, 2, getTabid('Vendors'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(51, 0, 47, 0, 3, getTabid('Accounts'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(52, 0, 0, 2, 3, NULL, 'MEN_SALES', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(54, 0, 52, 0, 0, getTabid('Campaigns'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(55, 0, 52, 0, 1, getTabid('Potentials'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(56, 0, 52, 0, 2, getTabid('QuotesEnquires'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(57, 0, 52, 0, 3, getTabid('RequirementCards'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(58, 0, 52, 0, 4, getTabid('Calculations'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(59, 0, 52, 0, 5, getTabid('Quotes'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(60, 0, 52, 0, 6, getTabid('SalesOrder'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(61, 0, 52, 0, 7, getTabid('PurchaseOrder'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(62, 0, 52, 0, 8, getTabid('PriceBooks'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(63, 0, 0, 2, 5, NULL, 'MEN_SUPPORT', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(64, 0, 63, 0, 0, getTabid('HelpDesk'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(65, 0, 63, 0, 1, getTabid('ServiceContracts'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(66, 0, 63, 0, 2, getTabid('Faq'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(67, 0, 0, 2, 4, NULL, 'MEN_PROJECTS', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(68, 0, 67, 0, 0, getTabid('Project'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(69, 0, 67, 0, 1, getTabid('ProjectMilestone'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(70, 0, 67, 0, 2, getTabid('ProjectTask'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(71, 0, 0, 2, 6, NULL, 'MEN_BOOKKEEPING', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(72, 0, 71, 0, 3, getTabid('PaymentsIn'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(73, 0, 71, 0, 2, getTabid('PaymentsOut'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(74, 0, 71, 0, 1, getTabid('Invoice'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(75, 0, 71, 0, 0, getTabid('OSSCosts'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(76, 0, 0, 2, 7, NULL, 'MEN_HUMAN_RESOURCES', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(77, 0, 76, 0, 0, getTabid('OSSEmployees'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(78, 0, 76, 0, 1, getTabid('OSSTimeControl'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(79, 0, 76, 0, 2, getTabid('HolidaysEntitlement'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(80, 0, 0, 2, 8, NULL, 'MEN_SECRETARY', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(81, 0, 80, 0, 0, getTabid('LettersIn'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(82, 0, 80, 0, 1, getTabid('LettersOut'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(83, 0, 80, 0, 2, getTabid('Reservations'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(84, 0, 0, 2, 9, NULL, 'MEN_DATABESES', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(85, 0, 84, 2, 0, NULL, 'MEN_PRODUCTBASE', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(86, 0, 84, 0, 1, getTabid('Products'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(87, 0, 84, 0, 2, getTabid('OutsourcedProducts'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(88, 0, 84, 0, 3, getTabid('Assets'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(89, 0, 84, 3, 4, NULL, NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(90, 0, 84, 2, 5, NULL, 'MEN_SERVICESBASE', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(91, 0, 84, 0, 6, getTabid('Services'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(92, 0, 84, 0, 7, getTabid('OSSOutsourcedServices'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(93, 0, 84, 0, 8, getTabid('OSSSoldServices'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(94, 0, 84, 3, 9, NULL, NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(95, 0, 84, 2, 10, NULL, 'MEN_LISTS', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(96, 0, 84, 0, 11, getTabid('OSSMailView'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(97, 0, 84, 0, 12, getTabid('SMSNotifier'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(98, 0, 84, 0, 13, getTabid('PBXManager'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(99, 0, 84, 0, 14, getTabid('OSSMailTemplates'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(100, 0, 84, 0, 15, getTabid('Documents'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(102, 0, 84, 0, 16, getTabid('OSSPdf'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(106, 0, 84, 0, 18, getTabid('CallHistory'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(107, 0, 84, 3, 19, NULL, NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(108, 0, 84, 0, 21, getTabid('NewOrders'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(109, 0, 84, 0, 17, getTabid('OSSPasswords'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(110, 0, 0, 2, 10, NULL, 'MEN_TEAMWORK', 0, NULL, 0, NULL, NULL, ""); $menu[] = array(111, 0, 110, 0, 0, getTabid('Ideas'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(112, 0, 0, 6, 0, getTabid('Home'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(113, 0, 44, 0, 2, getTabid('OSSMail'), NULL, 0, NULL, 0, NULL, NULL, ""); $menu[] = array(114, 0, 84, 0, 20, getTabid('Reports'), NULL, 0, NULL, 0, NULL, NULL, ""); foreach ($menu as $m) { $adb->pquery("insert into `yetiforce_menu`(`id`,`role`,`parentid`,`type`,`sequence`,`module`,`label`,`newwindow`,`dataurl`,`showicon`,`icon`,`sizeicon`,`hotkey`) values (" . generateQuestionMarks($m) . ");", array($m)); } } $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linktype = ? AND linklabel = ? AND tabid = ? ;", ['DASHBOARDWIDGET', 'Calendar', getTabid('Home')]); if ($adb->num_rows($result) == 0) { $instanceModule = Vtiger_Module::getInstance('Home'); $instanceModule->addLink('DASHBOARDWIDGET', 'Calendar', 'index.php?module=Home&view=ShowWidget&name=Calendar'); } $adb->query('DROP TABLE IF EXISTS vtiger_converttoaccount_settings;'); $adb->query('DROP TABLE IF EXISTS vtiger_marketing_processes;'); $adb->query('DROP TABLE IF EXISTS vtiger_proc_marketing;'); $adb->query('DROP TABLE IF EXISTS vtiger_salesprocesses_settings;'); $adb->pquery('DELETE FROM vtiger_settings_field WHERE name = ?;', array('LBL_MDULES_COLOR_EDITOR')); $adb->query("CREATE TABLE IF NOT EXISTS `yetiforce_proc_marketing` (\n `type` varchar(30) DEFAULT NULL,\n `param` varchar(30) DEFAULT NULL,\n `value` varchar(200) DEFAULT NULL,\n KEY `type` (`type`,`param`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $adb->query("CREATE TABLE IF NOT EXISTS `yetiforce_proc_sales` (\n `type` varchar(30) DEFAULT NULL,\n `param` varchar(30) DEFAULT NULL,\n `value` varchar(200) DEFAULT NULL,\n KEY `type` (`type`,`param`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $result = $adb->pquery("SELECT * FROM `yetiforce_proc_marketing` WHERE type = ? AND param = ?;", ['conversion', 'change_owner']); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('conversion','change_owner','false');"); $adb->query("insert into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','groups','');"); $adb->query("insert into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','status','');"); $adb->query("insert into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('lead','currentuser_status','false');"); } $result = $adb->pquery("SELECT * FROM `yetiforce_proc_sales` WHERE type = ? AND param = ?;", ['popup', 'limit_product_service']); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('popup','limit_product_service','false');"); $adb->query("insert into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('popup','update_shared_permissions','false');"); } $result = $adb->pquery("SELECT * FROM `yetiforce_proc_sales` WHERE type = ? AND param = ?;", ['calculation', 'calculationsstatus']); if ($adb->num_rows($result) == 0) { $adb->query("insert into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('calculation','calculationsstatus','');"); $adb->query("insert into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('potential','salesstage','');"); $adb->query("insert into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('asset','assetstatus','');"); $adb->query("insert into `yetiforce_proc_sales`(`type`,`param`,`value`) values ('potential','add_potential','false');"); } $adb->pquery('UPDATE `vtiger_settings_field` SET linkto = ? WHERE name = ?;', ['index.php?module=SalesProcesses&view=Index&parent=Settings', 'LBL_SALES_PROCESSES']); $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", ['vtiger.entity.link.after', 'Vtiger_SharingPrivileges_Handler']); if ($adb->num_rows($result) == 0) { $em = new VTEventsManager($adb); $em->registerHandler('vtiger.entity.link.after', 'modules/Vtiger/handlers/SharingPrivileges.php', 'Vtiger_SharingPrivileges_Handler'); } $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [2, 'vtiger_projecttask', 'projectid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_projecttask', 'startdate']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [6, getTabid('ProjectTask'), 'smownerid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_projecttask', 'projecttaskstatus']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [2, 'vtiger_projecttask', 'projectmilestoneid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_projecttask', 'targetenddate']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_requirementcards', 'subject']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_requirementcards', 'requirementcards_status']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_requirementcards', 'potentialid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [2, getTabid('RequirementCards'), 'smownerid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_requirementcards', 'quotesenquiresid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [9, 'vtiger_leadaddress', 'phone']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_leaddetails', 'lastname']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_leaddetails', 'company']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [8, 'vtiger_leaddetails', 'email']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_leaddetails', 'leadstatus']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [2, getTabid('Leads'), 'smownerid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_leaddetails', 'vat_id']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_leaddetails', 'leads_relation']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_leaddetails', 'legal_form']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_reservations', 'reservations_status']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [4, getTabid('Reservations'), 'smownerid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_reservations', 'date_start']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_reservations', 'time_start']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_reservations', 'time_end']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [8, 'vtiger_reservations', 'due_date']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [2, 'vtiger_reservations', 'type']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [9, getTabid('Reservations'), 'description']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [1, 'vtiger_osspdf', 'title']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [2, getTabid('OSSPdf'), 'smownerid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [10, 'vtiger_osspdf', 'osspdf_pdf_format']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [11, 'vtiger_osspdf', 'osspdf_pdf_orientation']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [8, 'vtiger_osspdf', 'osspdf_enable_footer']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_osspdf', 'osspdf_enable_header']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_osspdf', 'height_header']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [9, 'vtiger_osspdf', 'height_footer']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_osspdf', 'selected']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [7, 'vtiger_osspdf', 'osspdf_view']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [6, 'vtiger_osspdf', 'moduleid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tabid = ? AND columnname = ? ;', [6, getTabid('Contacts'), 'smownerid']); $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE handler_class = ?;", array('ProjectTaskHandler')); if ($adb->num_rows($result) == 0) { $em = new VTEventsManager($adb); $em->registerHandler('vtiger.entity.aftersave.final', 'modules/ProjectTask/handlers/ProjectTaskHandler.php', 'ProjectTaskHandler'); $em->registerHandler('vtiger.entity.afterdelete', 'modules/ProjectTask/handlers/ProjectTaskHandler.php', 'ProjectTaskHandler'); $em->registerHandler('vtiger.entity.afterrestore', 'modules/ProjectTask/handlers/ProjectTaskHandler.php', 'ProjectTaskHandler'); } $adb->pquery('UPDATE vtiger_relatedlists SET label = ? WHERE label = ?;', ['Activities', 'Upcoming Activities']); $adb->pquery('DELETE FROM vtiger_relatedlists WHERE `tabid` IN (?,?,?,?,?,?,?,?) AND `label` = ?;', [getTabid('Accounts'), getTabid('Leads'), getTabid('Contacts'), getTabid('Potentials'), getTabid('HelpDesk'), getTabid('Campaigns'), getTabid('ServiceContracts'), getTabid('Project'), 'Activity History']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [4, 'vtiger_potential', 'related_to']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [5, 'vtiger_potential', 'closingdate']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? ;', [3, 'vtiger_potential', 'sales_stage']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', 2]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [7, 'vtiger_osssoldservices', 'ssservicesstatus']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [9, 'vtiger_osssoldservices', 'pscategory']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_osssoldservices', 'datesold']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('OSSSoldServices')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_osssoldservices', 'invoiceid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [6, 'vtiger_osssoldservices', 'parent_id']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_osssoldservices', 'serviceid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_paymentsin', 'paymentsname']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('PaymentsIn')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [8, 'vtiger_paymentsin', 'paymentsin_status']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [7, 'vtiger_paymentsin', 'relatedid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [6, 'vtiger_paymentsin', 'salesid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_paymentsin', 'paymentsvalue']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_paymentsin', 'paymentstitle']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_paymentsin', 'bank_account']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_lettersin', 'title']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('LettersIn')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_lettersout', 'title']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('LettersOut')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_quotesenquires', 'subject']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_quotesenquires', 'potentialid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('QuotesEnquires')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_quotesenquires', 'quotesenquires_stage']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_account', 'phone']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_account', 'website']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('Accounts')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_vendor', 'phone']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [4, 'vtiger_vendor', 'email']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('Vendors')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [2, 'vtiger_osstimecontrol', 'osstimecontrol_status']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [6, 'vtiger_osstimecontrol', 'date_start']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_osstimecontrol', 'time_start']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [7, 'vtiger_osstimecontrol', 'time_end']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [8, 'vtiger_osstimecontrol', 'due_date']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_osstimecontrol', 'timecontrol_type']); $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_ossemployees', 'private_phone']); $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [2, 'vtiger_ossemployees', 'business_mail']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_crmentity', 'description', getTabid('OSSTimeControl')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [2, 'vtiger_holidaysentitlement', 'holidaysentitlement_year']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ?, quickcreate = ?, masseditable = ? WHERE tablename = ? AND columnname = ?;', [3, 2, 2, 'vtiger_holidaysentitlement', 'days']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [1, 'vtiger_holidaysentitlement', 'ossemployeesid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_crmentity', 'smownerid', getTabid('HolidaysEntitlement')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_account', 'legal_form']); $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [5, 'vtiger_leaddetails', 'industry']); $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [8, 'vtiger_leaddetails', 'subindustry']); $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_crmentity', 'was_read', getTabid('Leads')]); $adb->pquery('UPDATE vtiger_field SET sequence = ? WHERE tablename = ? AND columnname = ?;', [10, 'vtiger_leaddetails', 'leads_relation']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_crmentity', 'smownerid', getTabid('Calendar')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_activity', 'due_date', getTabid('Calendar')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ?, quickcreate = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [6, 2, 'vtiger_activity', 'process', getTabid('Calendar')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_activity', 'link', getTabid('Calendar')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [1, 'vtiger_activity', 'subject', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_crmentity', 'smownerid', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_activity', 'date_start', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_activity', 'due_date', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ?, quickcreate = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [6, 2, 'vtiger_activity', 'process', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_activity', 'eventstatus', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_activity', 'activitytype', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_activity', 'link', getTabid('Events')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [7, 'vtiger_activity', 'allday', getTabid('Events')]); $adb->pquery('UPDATE vtiger_homestuff SET `visible` = ? WHERE `stufftype` = ? ;', [1, 'Tag Cloud']); $adb->pquery('UPDATE vtiger_field SET typeofdata = ? WHERE tablename = ? AND columnname = ?;', ['D~M', 'vtiger_projectmilestone', 'projectmilestonedate']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_notes', 'filename', getTabid('Documents')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_crmentity', 'smownerid', getTabid('Documents')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_notes', 'filelocationtype', getTabid('Documents')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_notes', 'folderid', getTabid('Documents')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [1, 'vtiger_modcomments', 'commentcontent', getTabid('ModComments')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_crmentity', 'smownerid', getTabid('ModComments')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_modcomments', 'related_to', getTabid('ModComments')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [7, 'vtiger_projecttask', 'projectid', getTabid('ProjectTask')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_crmentity', 'smownerid', getTabid('ProjectTask')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_projecttask', 'startdate', getTabid('ProjectTask')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_projecttask', 'projecttaskstatus', getTabid('ProjectTask')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [1, 'vtiger_osspasswords', 'passwordname', getTabid('OSSPasswords')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_osspasswords', 'username', getTabid('OSSPasswords')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_osspasswords', 'password', getTabid('OSSPasswords')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_osspasswords', 'link_adres', getTabid('OSSPasswords')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_crmentity', 'smownerid', getTabid('OSSPasswords')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [4, 'vtiger_ossemployees', 'employee_status', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [3, 'vtiger_crmentity', 'smownerid', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [2, 'vtiger_ossemployees', 'last_name', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [17, 'vtiger_ossemployees', 'pesel', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [18, 'vtiger_ossemployees', 'id_card', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [5, 'vtiger_ossemployees', 'employee_education', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [6, 'vtiger_ossemployees', 'birth_date', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [19, 'vtiger_ossemployees', 'business_phone', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [16, 'vtiger_ossemployees', 'private_phone', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [21, 'vtiger_ossemployees', 'business_mail', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [20, 'vtiger_ossemployees', 'private_mail', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [22, 'vtiger_ossemployees', 'street', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [13, 'vtiger_ossemployees', 'code', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [9, 'vtiger_ossemployees', 'city', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [8, 'vtiger_ossemployees', 'state', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [10, 'vtiger_ossemployees', 'country', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [11, 'vtiger_ossemployees', 'ship_street', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [15, 'vtiger_ossemployees', 'ship_code', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [12, 'vtiger_ossemployees', 'ship_city', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [14, 'vtiger_ossemployees', 'ship_state', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ? AND tabid = ? ;', [7, 'vtiger_ossemployees', 'ship_country', getTabid('OSSEmployees')]); $adb->pquery('UPDATE vtiger_field SET defaultvalue = ?, summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['PLL_WAITING_FOR_VERIFICATION', 1, 'vtiger_calculations', 'calculationsstatus']); $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'name']); $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'relatedid']); $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'potentialid']); $adb->pquery('UPDATE vtiger_field SET summaryfield = ? WHERE tablename = ? AND columnname = ?;', ['1', 'vtiger_calculations', 'requirementcardsid']); $adb->pquery('UPDATE vtiger_field SET summaryfield = ?, displaytype = ? WHERE tablename = ? AND columnname = ?;', ['1', 1, 'vtiger_calculations', 'quotesenquiresid']); $adb->pquery('UPDATE vtiger_field SET quickcreatesequence = ? WHERE tablename = ? AND columnname = ?;', [3, 'vtiger_projecttask', 'estimated_work_time']); $widgets[] = array(53, 'Calculations', 'Summary', NULL, 1, 0, NULL, '[]'); $widgets[] = array(54, 'Calculations', 'RelatedModule', '', 2, 1, NULL, '{"limit":"5","relatedmodule":"8","columns":"3","action":"1","filter":"-"}'); foreach ($widgets as $widget) { if (self::checkModuleExists($widget[1])) { $result = $adb->pquery('SELECT * FROM vtiger_widgets WHERE tabid = ? AND `type` = ?', array(getTabid($widget[1]), $widget[2])); if (!$adb->num_rows($result)) { $sql = "INSERT INTO vtiger_widgets (tabid, type, label, wcol, sequence, nomargin, data) VALUES (?, ?, ?, ?, ?, ?, ?);"; $adb->pquery($sql, array(getTabid($widget[1]), $widget[2], $widget[3], $widget[4], $widget[5], $widget[6], $widget[7])); } } } $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linktype = ? AND linklabel = ? AND tabid = ? ;", ['DASHBOARDWIDGET', 'Calculations', getTabid('Home')]); if ($adb->num_rows($result) == 0) { $instanceModule = Vtiger_Module::getInstance('Home'); $instanceModule->addLink('DASHBOARDWIDGET', 'Calculations', 'index.php?module=Calculations&view=ShowWidget&name=Calculations'); } $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linktype = ? AND linklabel = ? AND tabid = ? ;", ['DASHBOARDWIDGET', 'PotentialsList', getTabid('Home')]); if ($adb->num_rows($result) == 0) { $instanceModule = Vtiger_Module::getInstance('Home'); $instanceModule->addLink('DASHBOARDWIDGET', 'PotentialsList', 'index.php?module=Potentials&view=ShowWidget&name=PotentialsList'); } // copy values from_portal in HelpDesk $result = $adb->query("SHOW COLUMNS FROM `vtiger_troubletickets` LIKE 'from_portal';"); if ($adb->num_rows($result) == 0) { $adb->query("ALTER TABLE `vtiger_troubletickets` ADD COLUMN `from_portal` varchar(3) NULL after `ordertime` ;"); $adb->query('UPDATE vtiger_troubletickets LEFT JOIN vtiger_ticketcf ON vtiger_troubletickets.ticketid = vtiger_ticketcf.ticketid SET vtiger_troubletickets.from_portal=vtiger_ticketcf.from_portal;'); $adb->pquery('UPDATE `vtiger_field` SET tablename=? WHERE tablename = ? AND columnname = ? AND tabid = ?;', ['vtiger_troubletickets', 'vtiger_ticketcf', 'from_portal', getTabid('HelpDesk')]); $adb->pquery('alter table vtiger_ticketcf drop column from_portal'); } $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE `type` = ? AND `name` = ? ;", ['info', 'notworkingdays']); if ($adb->num_rows($result) == 0) { $adb->query("insert into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values ('info','notworkingdays ','LBL_NOTWORKING_DAYS',NULL);"); } $result = $adb->pquery("SELECT * FROM `vtiger_links` WHERE linklabel = ? AND linkicon = ? ; ", array('LBL_SHOW_ACCOUNT_HIERARCHY', 'icon-align-justify')); if ($adb->num_rows($result) == 0) { //$mods = Vtiger_Module::getInstance( "Accounts" ); // $mods->deleteLink('DETAILVIEWBASIC', 'LBL_SHOW_ACCOUNT_HIERARCHY', 'index.php?module=Accounts&action=AccountHierarchy&accountid=$RECORD$'); $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = ? WHERE `linklabel`= ? ;", array('icon-align-justify', 'LBL_SHOW_ACCOUNT_HIERARCHY')); $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = ? WHERE `linklabel`= ? ;", array('icon-file', 'LBL_ADD_NOTE')); $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = 'icon-file' WHERE `linklabel` = ?;", array('Add Note')); $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = 'icon-tasks' WHERE `linklabel` = ?;", array('Add Project Task')); $adb->pquery("UPDATE `vtiger_links` SET `linkicon` = 'icon-user' WHERE `linklabel` = ?;", array('LBL_SHOW_EMPLOYEES_HIERARCHY')); } $result = $adb->query("SELECT * FROM `vtiger_backup_settings`;"); if ($adb->num_rows($result) == 0) { $adb->query("insert into `vtiger_backup_settings`(`type`,`param`,`value`) values ('folder','storage_folder','false');"); $adb->query("insert into `vtiger_backup_settings`(`type`,`param`,`value`) values ('folder','storage_folder','false');"); } // change related list $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Accounts'), 'change' => array('name' => 'get_accounts_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Contacts'), 'change' => array('name' => 'get_contacts_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Leads'), 'change' => array('name' => 'get_leads_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Potentials'), 'change' => array('name' => 'get_potentials_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('HelpDesk'), 'change' => array('name' => 'get_helpdesk_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Project'), 'change' => array('name' => 'get_project_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('ServiceContracts'), 'change' => array('name' => 'get_servicecontracts_mail')); $update[] = array('tabid' => getTabid('OSSMailView'), 'related_tabid' => getTabid('Campaigns'), 'change' => array('name' => 'get_campaigns_mail')); $update[] = array('tabid' => getTabid('Contacts'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails')); $update[] = array('tabid' => getTabid('Leads'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails')); $update[] = array('tabid' => getTabid('Accounts'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails')); $update[] = array('tabid' => getTabid('Vendors'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails')); $update[] = array('tabid' => getTabid('ServiceContracts'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => '')); $update[] = array('tabid' => getTabid('HelpDesk'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => '')); $update[] = array('tabid' => getTabid('Potentials'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => '')); $update[] = array('tabid' => getTabid('Campaigns'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => '')); $update[] = array('tabid' => getTabid('Project'), 'related_tabid' => getTabid('OSSMailView'), 'change' => array('name' => 'get_emails', 'actions' => '')); foreach ($update as $presents) { $sql1 = 'UPDATE `vtiger_relatedlists` SET '; foreach ($presents['change'] as $column => $value) { $sql = $sql1 . $column . ' = ? '; $sql .= 'WHERE `tabid` = ? AND `related_tabid` = ? ;'; $adb->pquery($sql, array($value, $presents['tabid'], $presents['related_tabid']), true); } } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('OSSMailView'), getTabid('Vendors'), 'get_vendor_mail', 'Vendors')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Vendors'); $target_Module = Vtiger_Module::getInstance('OSSMailView'); $target_Module->setRelatedList($moduleInstance, 'Vendors', array('ADD,SELECT'), 'get_vendor_mail'); } //mailview relation $module = 'OSSMailView'; $sql = 'SELECT * FROM vtiger_crmentityrel WHERE module = ? OR relmodule = ?'; $result1 = $adb->pquery($sql, [$module, $module]); for ($i = 0; $i < $adb->num_rows($result1); $i++) { $row = $adb->raw_query_result_rowdata($result1, $i); $id = $row['module'] == $module ? $row['relcrmid'] : $row['crmid']; $mailID = $row['module'] != $module ? $row['relcrmid'] : $row['crmid']; $sql = 'SELECT createdtime FROM vtiger_crmentity WHERE crmid = ?'; $result2 = $adb->pquery($sql, [$mailID]); if ($adb->num_rows($result2) > 0) { $createdtime = $adb->query_result($result2, 0, 'createdtime'); $adb->pquery('INSERT INTO vtiger_ossmailview_relation VALUES(?,?,?,?)', [$mailID, $id, $createdtime, 0]); $adb->pquery('DELETE FROM vtiger_crmentityrel WHERE crmid = ? AND relcrmid = ?; ', [$row['crmid'], $row['relcrmid']]); } } $adb->pquery('UPDATE `vtiger_ossmailview` LEFT JOIN `vtiger_crmentity` ON `vtiger_ossmailview`.`ossmailviewid` = `vtiger_crmentity`.`crmid` SET `vtiger_ossmailview`.`date` = vtiger_crmentity.`modifiedtime` WHERE `vtiger_ossmailview`.`date` IS NULL OR `vtiger_ossmailview`.`date` = ?', ['0000-00-00 00:00:00']); $result = $adb->pquery('SELECT * FROM `roundcube_system` WHERE name = ?;', array('roundcube-version')); if ($adb->num_rows($result) == 1) { $adb->pquery('UPDATE `roundcube_system` SET `value` = ? WHERE `name` = ?;', ['2015030800', 'roundcube-version']); } else { $adb->pquery('INSERT INTO `roundcube_system`(`name`,`value`) values (?,?);', ['2015030800', 'roundcube-version']); } // $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Project'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('Project'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Project'), 'get_related_list', 'Project')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Project'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'Project', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Quotes'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('Quotes'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Quotes'), 'get_related_list', 'Quotes')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Quotes'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'Quotes', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Calculations'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('Calculations'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Calculations'), 'get_related_list', 'Calculations')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Calculations'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'Calculations', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('QuotesEnquires'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('QuotesEnquires'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('QuotesEnquires'), 'get_related_list', 'QuotesEnquires')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('QuotesEnquires'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'QuotesEnquires', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('SalesOrder'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('SalesOrder'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('SalesOrder'), 'get_related_list', 'SalesOrder')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('SalesOrder'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'SalesOrder', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('PurchaseOrder'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('PurchaseOrder'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('PurchaseOrder'), 'get_related_list', 'PurchaseOrder')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('PurchaseOrder'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'PurchaseOrder', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Invoice'), getTabid('Contacts'), 'get_related_list', 'Contacts')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Contacts'); $target_Module = Vtiger_Module::getInstance('Invoice'); $target_Module->setRelatedList($moduleInstance, 'Contacts', array('ADD,SELECT'), 'get_related_list'); } $result = $adb->pquery("SELECT * FROM `vtiger_relatedlists` WHERE tabid = ? AND related_tabid = ? AND name = ? AND label = ?;", array(getTabid('Contacts'), getTabid('Invoice'), 'get_related_list', 'Invoice')); if ($adb->num_rows($result) == 0) { $moduleInstance = Vtiger_Module::getInstance('Invoice'); $target_Module = Vtiger_Module::getInstance('Contacts'); $target_Module->setRelatedList($moduleInstance, 'Invoice', array('ADD,SELECT'), 'get_related_list'); } $adb->pquery('UPDATE vtiger_field SET typeofdata = ? WHERE tablename = ? AND columnname = ?;', ['D~M', 'vtiger_calculations', 'date']); $result = $adb->pquery("SELECT * FROM `vtiger_dataaccess` WHERE module_name = ? AND `summary` = ?;", ['Events', 'Adding time period to status change']); if ($adb->num_rows($result) == 0) { $adb->pquery('insert into `vtiger_dataaccess`(`module_name`,`summary`,`data`) values (?,?,?)', ['Events', 'Adding time period to status change', 'a:1:{i:0;a:3:{s:2:"an";s:25:"Vtiger!!show_quick_create";s:7:"modules";s:14:"OSSTimeControl";s:2:"cf";b:1;}}']); $recordId = $adb->getLastInsertID(); $adb->pquery('insert into `vtiger_dataaccess_cnd`(`dataaccessid`,`fieldname`,`comparator`,`val`,`required`,`field_type`) values (?,?,?,?,?,?);', [$recordId, 'eventstatus', 'has changed', 'Held', 1, 'picklist']); } $adb->pquery('UPDATE vtiger_links SET linkurl = ? WHERE linklabel = ?;', ['index.php?module=OSSTimeControl&view=ShowWidget&name=TimeControl', 'Employees Time Control']); $adb->pquery('DELETE FROM `vtiger_ws_entity` WHERE `name` = ? LIMIT 1;', ['OSSDocumentControl']); $adb->pquery("UPDATE vtiger_widgets SET data = ? WHERE type = 'RelatedModule' AND label = 'ProjectTask';", ['{"limit":"5","relatedmodule":"' . getTabid('ProjectTask') . '","columns":"3","action":"1","filter":"-","checkbox_selected":"","checkbox":"-"}']); $adb->pquery("UPDATE vtiger_widgets SET data = ? WHERE type = 'RelatedModule' AND label = 'ProjectMilestone';", ['{"limit":"5","relatedmodule":"' . getTabid('ProjectMilestone') . '","columns":"3","action":"1","filter":"-","checkbox_selected":"","checkbox":"-"}']); $adb->query("UPDATE vtiger_widgets SET label = 'Documents' WHERE type = 'RelatedModule' AND tabid = '" . getTabid('Calculations') . "';"); $log->debug("Exiting YetiForceUpdate::databaseData() method ..."); }
<?php require_once 'include/utils/utils.php'; require 'include/events/include.inc'; $em = new VTEventsManager($adb); $em->registerHandler("vtiger.entity.aftersave", "modules/RegistroDeVentas/RegistroDeVentasHandler.php", "RegistroDeVentasHandler"); echo 'Custom Handler Registered !';
public function remove($pickListFieldName, $valueToDeleteId, $replaceValueId, $moduleName) { $db = PearDatabase::getInstance(); if (!is_array($valueToDeleteId)) { $valueToDeleteId = array($valueToDeleteId); } $primaryKey = Vtiger_Util_Helper::getPickListId($pickListFieldName); $pickListValues = array(); $valuesOfDeleteIds = "SELECT {$pickListFieldName} FROM " . $this->getPickListTableName($pickListFieldName) . " WHERE {$primaryKey} IN (" . generateQuestionMarks($valueToDeleteId) . ")"; $pickListValuesResult = $db->pquery($valuesOfDeleteIds, array($valueToDeleteId)); $num_rows = $db->num_rows($pickListValuesResult); for ($i = 0; $i < $num_rows; $i++) { $pickListValues[] = decode_html($db->query_result($pickListValuesResult, $i, $pickListFieldName)); } $replaceValueQuery = $db->pquery("SELECT {$pickListFieldName} FROM " . $this->getPickListTableName($pickListFieldName) . " WHERE {$primaryKey} IN (" . generateQuestionMarks($replaceValueId) . ")", array($replaceValueId)); $replaceValue = decode_html($db->query_result($replaceValueQuery, 0, $pickListFieldName)); //As older look utf8 characters are pushed as html-entities,and in new utf8 characters are pushed to database //so we are checking for both the values $encodedValueToDelete = array(); foreach ($pickListValues as $key => $value) { $encodedValueToDelete[$key] = Vtiger_Util_Helper::toSafeHTML($value); } $mergedValuesToDelete = array_merge($pickListValues, $encodedValueToDelete); $fieldModel = Settings_Picklist_Field_Model::getInstance($pickListFieldName, $this); //if role based then we need to delete all the values in role based picklist if ($fieldModel->isRoleBased()) { $picklistValueIdToDelete = array(); $query = 'SELECT picklist_valueid FROM ' . $this->getPickListTableName($pickListFieldName) . ' WHERE ' . $primaryKey . ' IN (' . generateQuestionMarks($valueToDeleteId) . ')'; $result = $db->pquery($query, $valueToDeleteId); $num_rows = $db->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $picklistValueIdToDelete[] = $db->query_result($result, $i, 'picklist_valueid'); } $query = 'DELETE FROM vtiger_role2picklist WHERE picklistvalueid IN (' . generateQuestionMarks($picklistValueIdToDelete) . ')'; $db->pquery($query, $picklistValueIdToDelete); } $query = 'DELETE FROM ' . $this->getPickListTableName($pickListFieldName) . ' WHERE ' . $primaryKey . ' IN (' . generateQuestionMarks($valueToDeleteId) . ')'; $db->pquery($query, $valueToDeleteId); vimport('include/utils/CommonUtils.php'); $tabId = getTabId($moduleName); $query = 'DELETE FROM vtiger_picklist_dependency WHERE sourcevalue IN (' . generateQuestionMarks($pickListValues) . ')' . ' AND sourcefield=?'; $params = array(); array_push($params, $pickListValues); array_push($params, $pickListFieldName); $db->pquery($query, $params); $query = 'SELECT tablename,columnname FROM vtiger_field WHERE fieldname=? AND presence in (0,2)'; $result = $db->pquery($query, array($pickListFieldName)); $num_row = $db->num_rows($result); for ($i = 0; $i < $num_row; $i++) { $row = $db->query_result_rowdata($result, $i); $tableName = $row['tablename']; $columnName = $row['columnname']; $query = 'UPDATE ' . $tableName . ' SET ' . $columnName . '=? WHERE ' . $columnName . ' IN (' . generateQuestionMarks($pickListValues) . ')'; $params = array($replaceValue); array_push($params, $pickListValues); $db->pquery($query, $params); } $query = 'UPDATE vtiger_field SET defaultvalue=? WHERE defaultvalue IN (' . generateQuestionMarks($pickListValues) . ') AND columnname=?'; $params = array($replaceValue); array_push($params, $pickListValues); array_push($params, $columnName); $db->pquery($query, $params); $em = new VTEventsManager($db); $data = array(); $data['fieldname'] = $pickListFieldName; $data['valuetodelete'] = $pickListValues; $data['replacevalue'] = $replaceValue; $data['module'] = $moduleName; $em->triggerEvent('vtiger.picklist.afterdelete', $data); return true; }
(SELECT workflow_id FROM com_vtiger_workflows WHERE module_name IN (?, ?)) AND task LIKE ?', array('Calendar', 'Events', '%$(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname)%')); $numOfRows = $adb->num_rows($result); for ($i = 0; $i < $numOfRows; $i++) { $tm = new VTTaskManager($adb); $task = $tm->retrieveTask($adb->query_result($result, $i, 'task_id')); $emailTask = new VTEmailTask(); $properties = get_object_vars($task); foreach ($properties as $propertyName => $propertyValue) { $propertyValue = str_replace('$date_start $time_start ( $(general : (__VtigerMeta__) usertimezone) ) ', '$date_start', $propertyValue); $propertyValue = str_replace('$due_date $time_end ( $(general : (__VtigerMeta__) usertimezone) )', '$due_date', $propertyValue); $propertyValue = str_replace('$due_date ( $(general : (__VtigerMeta__) usertimezone) )', '$due_date', $propertyValue); $propertyValue = str_replace('$(contact_id : (Contacts) lastname) $(contact_id : (Contacts) firstname)', '$contact_id', $propertyValue); $emailTask->{$propertyName} = $propertyValue; } $tm->saveTask($emailTask); } $result = $adb->pquery('SELECT 1 FROM vtiger_currencies WHERE currency_name = ?', array('Ugandan Shilling')); if (!$adb->num_rows($result)) { Migration_Index_View::ExecuteQuery('INSERT INTO vtiger_currencies (currencyid, currency_name, currency_code, currency_symbol) VALUES(?, ?, ?, ?)', array($adb->getUniqueID('vtiger_currencies'), 'Ugandan Shilling', 'UGX', 'Sh')); } $em = new VTEventsManager($adb); $em->registerHandler('vtiger.picklist.afterrename', 'modules/Settings/Picklist/handlers/PickListHandler.php', 'PickListHandler'); $em->registerHandler('vtiger.picklist.afterdelete', 'modules/Settings/Picklist/handlers/PickListHandler.php', 'PickListHandler'); Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_inventoryproductrel MODIFY comment varchar(500)', array()); $module = Vtiger_Module::getInstance('Accounts'); $module->addLink('DETAILVIEWSIDEBARWIDGET', 'Google Map', 'module=Google&view=Map&mode=showMap&viewtype=detail', '', '', ''); // Changes as on 2013.11.29 Migration_Index_View::ExecuteQuery('DELETE FROM vtiger_settings_field WHERE name=?', array('LBL_BACKUP_SERVER_SETTINGS')); // Changes ends as on 2013.11.29 Migration_Index_View::ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_faqcf ( \r\n faqid int(19), \r\n PRIMARY KEY (faqid), \r\n CONSTRAINT fk_1_vtiger_faqcf FOREIGN KEY (faqid) REFERENCES vtiger_faq(id) ON DELETE CASCADE \r\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8", array());
function transformOwnerShipAndDelete($userId, $transformToUserId) { $adb = PearDatabase::getInstance(); $em = new VTEventsManager($adb); // Initialize Event trigger cache $em->initTriggerCache(); $entityData = VTEntityData::fromUserId($adb, $userId); //set transform user id $entityData->set('transformtouserid', $transformToUserId); $em->triggerEvent("vtiger.entity.beforedelete", $entityData); vtws_transferOwnership($userId, $transformToUserId); //delete from user vtiger_table; $sql = "delete from vtiger_users where id=?"; $adb->pquery($sql, array($userId)); //Delete user extension in asterisk. $sql = "delete from vtiger_asteriskextensions where userid=?"; $adb->pquery($sql, array($userId)); }
function vtws_convertlead($entityvalues, $user) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $log->debug('Start ' . __CLASS__ . ':' . __FUNCTION__); if (empty($entityvalues['assignedTo'])) { $entityvalues['assignedTo'] = vtws_getWebserviceEntityId('Users', $user->id); } if (empty($entityvalues['transferRelatedRecordsTo'])) { $entityvalues['transferRelatedRecordsTo'] = 'Accounts'; } $leadObject = VtigerWebserviceObject::fromName($adb, 'Leads'); $handlerPath = $leadObject->getHandlerPath(); $handlerClass = $leadObject->getHandlerClass(); require_once $handlerPath; $leadHandler = new $handlerClass($leadObject, $user, $adb, $log); $leadInfo = vtws_retrieve($entityvalues['leadId'], $user); $sql = "select converted from vtiger_leaddetails where converted = 1 and leadid=?"; $leadIdComponents = vtws_getIdComponents($entityvalues['leadId']); $result = $adb->pquery($sql, array($leadIdComponents[1])); if ($result === false) { $log->error('Error converting a lead: ' . vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR)); throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_' . WebServiceErrorCode::$DATABASEQUERYERROR)); } $rowCount = $adb->num_rows($result); if ($rowCount > 0) { $log->error('Error converting a lead: Lead is already converted'); throw new WebServiceException(WebServiceErrorCode::$LEAD_ALREADY_CONVERTED, "Lead is already converted"); } require_once "include/events/include.inc"; $em = new VTEventsManager($adb); // Initialize Event trigger cache $em->initTriggerCache(); $entityData = VTEntityData::fromEntityId($adb, $leadIdComponents[1]); $em->triggerEvent('entity.convertlead.before', [$entityvalues, $user, $leadInfo]); $entityIds = []; $availableModules = ['Accounts', 'Contacts', 'Potentials']; if (!($entityvalues['entities']['Accounts']['create'] || $entityvalues['entities']['Contacts']['create'])) { return null; } foreach ($availableModules as $entityName) { if ($entityvalues['entities'][$entityName]['create']) { $entityvalue = $entityvalues['entities'][$entityName]; $entityObject = VtigerWebserviceObject::fromName($adb, $entityvalue['name']); $handlerPath = $entityObject->getHandlerPath(); $handlerClass = $entityObject->getHandlerClass(); require_once $handlerPath; $entityHandler = new $handlerClass($entityObject, $user, $adb, $log); $entityObjectValues = array(); $entityObjectValues['assigned_user_id'] = $entityvalues['assignedTo']; $entityObjectValues = vtws_populateConvertLeadEntities($entityvalue, $entityObjectValues, $entityHandler, $leadHandler, $leadInfo); //update potential related to property if ($entityvalue['name'] == 'Potentials') { if (!empty($entityIds['Accounts'])) { $entityObjectValues['related_to'] = $entityIds['Accounts']; } if (!empty($entityIds['Contacts'])) { $entityObjectValues['contact_id'] = $entityIds['Contacts']; } } //update the contacts relation if ($entityvalue['name'] == 'Contacts') { if (!empty($entityIds['Accounts'])) { $entityObjectValues['parent_id'] = $entityIds['Accounts']; } } try { $create = true; if ($entityvalue['name'] == 'Accounts' && $entityvalue['convert_to_id'] && is_int($entityvalue['convert_to_id'])) { $entityIds[$entityName] = vtws_getWebserviceEntityId('Accounts', $entityvalue['convert_to_id']); $create = false; } if ($create) { $entityRecord = vtws_create($entityvalue['name'], $entityObjectValues, $user); $entityIds[$entityName] = $entityRecord['id']; } } catch (Exception $e) { $log->error('Error converting a lead: ' . $e->getMessage()); throw new WebServiceException(WebServiceErrorCode::$UNKNOWNOPERATION, $e->getMessage() . ' : ' . $entityvalue['name']); } } } try { $accountIdComponents = vtws_getIdComponents($entityIds['Accounts']); $accountId = $accountIdComponents[1]; $contactIdComponents = vtws_getIdComponents($entityIds['Contacts']); $contactId = $contactIdComponents[1]; if (!empty($accountId) && !empty($contactId) && !empty($entityIds['Potentials'])) { $potentialIdComponents = vtws_getIdComponents($entityIds['Potentials']); $potentialId = $potentialIdComponents[1]; $sql = "insert into vtiger_contpotentialrel values(?,?)"; $result = $adb->pquery($sql, array($contactId, $potentialIdComponents[1])); if ($result === false) { throw new WebServiceException(WebServiceErrorCode::$FAILED_TO_CREATE_RELATION, "Failed to related Contact with the Potential"); } } $transfered = vtws_convertLeadTransferHandler($leadIdComponents, $entityIds, $entityvalues); $relatedIdComponents = vtws_getIdComponents($entityIds[$entityvalues['transferRelatedRecordsTo']]); vtws_getRelatedActivities($leadIdComponents[1], $accountId, $contactId, $relatedIdComponents[1]); vtws_updateConvertLeadStatus($entityIds, $entityvalues['leadId'], $user); if ($em) { $em->triggerEvent('entity.convertlead.after', [$entityvalues, $user, $leadInfo, $entityIds]); } } catch (Exception $e) { $log->error('Error converting a lead: ' . $e->getMessage()); foreach ($entityIds as $entity => $id) { vtws_delete($id, $user); } return null; } $log->debug('End ' . __CLASS__ . ':' . __FUNCTION__); return $entityIds; }
/** * Trigger event based on CRM Record * @param String Name of the Event to trigger * @param Integer CRM record id on which event needs to be triggered. */ static function trigger($eventname, $crmid) { if (!self::hasSupport()) { return; } $adb = PearDatabase::getInstance(); $checkres = $adb->pquery("SELECT setype, crmid, deleted FROM vtiger_crmentity WHERE crmid=?", array($crmid)); if ($adb->num_rows($checkres)) { $result = $adb->fetch_array($checkres, 0); if ($result['deleted'] == '0') { $module = $result['setype']; $moduleInstance = CRMEntity::getInstance($module); $moduleInstance->retrieve_entity_info($result['crmid'], $module); $moduleInstance->id = $result['crmid']; $current_user = vglobal('current_user'); if (!$current_user) { $current_user = new Users(); $current_user->id = $moduleInstance->column_fields['assigned_user_id']; } // Trigger the event $em = new VTEventsManager($adb); $em->triggerEvent($eventname, VTEntityData::fromCRMEntity($moduleInstance)); } } }
/*+******************************************************************************** * 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. *********************************************************************************/ //5.0.4 to 5.1.0 RC database changes //we have to use the current object (stored in PatchApply.php) to execute the queries $adb = $_SESSION['adodb_current_object']; $conn = $_SESSION['adodb_current_object']; $migrationlog->debug("\n\nDB Changes from 5.0.4 to 5.1.0 RC -------- Starts \n\n"); require_once 'include/events/include.inc'; $em = new VTEventsManager($adb); /* For the event api */ ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_eventhandlers (eventhandler_id int, event_name varchar(100), handler_path varchar(400), handler_class varchar(100), cond text, is_active boolean, primary key(eventhandler_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_eventhandler_module(eventhandler_module_id int, module_name VARCHAR(100), handler_class VARCHAR(100), PRIMARY KEY(eventhandler_module_id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); /* Added new column actions to vtiger_relatedlists which tracks the type of actions allowed for that related list */ if (!in_array('actions', $adb->getColumnNames('vtiger_relatedlists'))) { ExecuteQuery("alter table vtiger_relatedlists add column actions VARCHAR(50) default ''"); } $accounts_tab_id = getTabid('Accounts'); $contacts_tab_id = getTabid('Contacts'); $notes_tab_id = getTabid('Documents'); $products_tab_id = getTabid('Products'); $leads_tab_id = getTabid('Leads'); $campaigns_tab_id = getTabid('Campaigns'); $potentials_tab_id = getTabid('Potentials'); $emails_tab_id = getTabid('Emails');
/** Function to delete the specified group * @param $groupId -- Group Id :: Type integer * @param $transferId -- Id of the group/user to which record ownership is to be transferred:: Type integer * @param $transferType -- It can have only two values namely 'Groups' or 'Users'. This determines whether the owneship is to be transferred to a group or user :: Type varchar */ function deleteGroup($groupId, $transferId) { global $log; $log->debug("Entering deleteGroup(" . $groupId . ") method ..."); global $adb; $em = new VTEventsManager($adb); // Initialize Event trigger cache $em->initTriggerCache(); $entityData = array(); $entityData['groupid'] = $groupId; $entityData['transferToId'] = $transferId; $em->triggerEvent("vtiger.entity.beforegroupdelete", $entityData); tranferGroupOwnership($groupId, $transferId); deleteGroupRelatedSharingRules($groupId); $query = "delete from vtiger_groups where groupid=?"; $adb->pquery($query, array($groupId)); deleteGroupRelatedGroups($groupId); deleteGroupRelatedRoles($groupId); deleteGroupReportRelations($groupId); deleteGroupRelatedRolesAndSubordinates($groupId); deleteGroupRelatedUsers($groupId); $log->debug("Exiting deleteGroup method ..."); }
function registerEvents($adb) { require_once 'include/events/include.inc'; $em = new VTEventsManager($adb); // Registering event for Recurring Invoices $em->registerHandler('vtiger.entity.aftersave', 'modules/SalesOrder/RecurringInvoiceHandler.php', 'RecurringInvoiceHandler'); //Registering Entity Delta handler for before save and after save events of the record to track the field value changes $em->registerHandler('vtiger.entity.beforesave', 'data/VTEntityDelta.php', 'VTEntityDelta'); $em->registerHandler('vtiger.entity.aftersave', 'data/VTEntityDelta.php', 'VTEntityDelta'); // Workflow manager $dependentEventHandlers = array('VTEntityDelta'); $dependentEventHandlersJson = Zend_Json::encode($dependentEventHandlers); $em->registerHandler('vtiger.entity.aftersave', 'modules/com_vtiger_workflow/VTEventHandler.inc', 'VTWorkflowEventHandler', '', $dependentEventHandlersJson); //Registering events for On modify $em->registerHandler('vtiger.entity.afterrestore', 'modules/com_vtiger_workflow/VTEventHandler.inc', 'VTWorkflowEventHandler'); // Registering event for HelpDesk - To reset from_portal value $em->registerHandler('vtiger.entity.aftersave.final', 'modules/HelpDesk/HelpDeskHandler.php', 'HelpDeskHandler'); }
<?php require_once 'include/utils/utils.php'; require 'include/events/include.inc'; $em = new VTEventsManager($adb); $em->registerHandler("vtiger.entity.aftersave", "modules/Boletos/BoletosHandler.php", "BoletosHandler"); echo 'Custom Handler Registered !';
} $adb->pquery('INSERT INTO vtiger_actionmapping (actionid, actionname, securitycheck) VALUES(?,?,?)', array($actionId, 'ReceiveIncomingCalls', 0)); $moduleInstance->enableTools('ReceiveIncomingcalls'); //To add actionname as MakeOutgoingCalls $maxActionIdresult = $adb->pquery('SELECT max(actionid+1) AS actionid FROM vtiger_actionmapping', array()); if ($adb->num_rows($maxActionIdresult)) { $actionId = $adb->query_result($maxActionIdresult, 0, 'actionid'); } $adb->pquery('INSERT INTO vtiger_actionmapping (actionid, actionname, securitycheck) VALUES(?,?,?)', array($actionId, 'MakeOutgoingCalls', 0)); $moduleInstance->enableTools('MakeOutgoingCalls'); echo '<br>Added PBXManager action mapping<br>'; //Add lookup events $adb = PearDatabase::getInstance(); $EventManager = new VTEventsManager($adb); $createEvent = 'vtiger.entity.aftersave'; $deleteEVent = 'vtiger.entity.afterdelete'; $restoreEvent = 'vtiger.entity.afterrestore'; $batchSaveEvent = 'vtiger.batchevent.save'; $batchDeleteEvent = 'vtiger.batchevent.delete'; $handler_path = 'modules/PBXManager/PBXManagerHandler.php'; $className = 'PBXManagerHandler'; $batchEventClassName = 'PBXManagerBatchHandler'; $EventManager->registerHandler($createEvent, $handler_path, $className, '', '["VTEntityDelta"]'); $EventManager->registerHandler($deleteEVent, $handler_path, $className); $EventManager->registerHandler($restoreEvent, $handler_path, $className); $EventManager->registerHandler($batchSaveEvent, $handler_path, $batchEventClassName); $EventManager->registerHandler($batchDeleteEvent, $handler_path, $batchEventClassName); echo 'Added PBXManager lookup events'; //Existing Asterisk extension block removed from vtiger_users if exist
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type (module.postinstall, module.disabled, module.enabled, module.preuninstall) */ function vtlib_handler($moduleName, $eventType) { require_once 'include/utils/utils.php'; global $adb; if ($eventType == 'module.postinstall') { require_once 'vtlib/Vtiger/Module.php'; $this->setModuleSeqNumber('configure', $modulename, 'srvcto-', '0000001'); $moduleInstance = Vtiger_Module::getInstance($moduleName); $accModuleInstance = Vtiger_Module::getInstance('Accounts'); $accModuleInstance->setRelatedList($moduleInstance, 'Service Contracts', array('add'), 'get_dependents_list'); $conModuleInstance = Vtiger_Module::getInstance('Contacts'); $conModuleInstance->setRelatedList($moduleInstance, 'Service Contracts', array('add'), 'get_dependents_list'); $helpDeskInstance = Vtiger_Module::getInstance("HelpDesk"); $helpDeskInstance->setRelatedList($moduleInstance, "Service Contracts", array('ADD', 'SELECT')); // Initialize module sequence for the module $adb->pquery("INSERT into vtiger_modentity_num values(?,?,?,?,?,?)", array($adb->getUniqueId("vtiger_modentity_num"), $moduleName, 'SERCON', 1, 1, 1)); // Make the picklist value 'Complete' for status as non-editable $adb->query("UPDATE vtiger_contract_status SET presence=0 WHERE contract_status='Complete'"); // Mark the module as Standard module $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($moduleName)); } else { if ($eventType == 'module.disabled') { $em = new VTEventsManager($adb); $em->setHandlerInActive('ServiceContractsHandler'); } else { if ($eventType == 'module.enabled') { $em = new VTEventsManager($adb); $em->setHandlerActive('ServiceContractsHandler'); } else { if ($eventType == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($eventType == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($eventType == 'module.postupdate') { // TODO Handle actions after this module is updated. } } } } } } }
function registerWsappWorkflowhandler() { $db = PearDatabase::getInstance(); $em = new VTEventsManager($db); $dependentEventHandlers = array('VTEntityDelta'); $dependentEventHandlersJson = Zend_Json::encode($dependentEventHandlers); $em->registerHandler('vtiger.entity.aftersave', 'modules/WSAPP/WorkFlowHandlers/WSAPPAssignToTracker.php', 'WSAPPAssignToTracker', '', $dependentEventHandlersJson); }