function generate(Vtiger_Request $xxx0b) { global $xxx22, $xxx23, $xxx24, $xxx25, $xxx26, $xxx27, $xxx28, $xxx29; $xxx0c = new PDFMaker_PDFMaker_Model(); $xxx0d = $xxx0b->getAll(); $xxx0e = PearDatabase::getInstance(); $xxx0f = "site_URL"; $xxx10 = "vtiger_current_version"; $xxx11 = vglobal($xxx10); $xxx12 = vglobal($xxx0f); $xxx13 = $xxx0b->get('relmodule'); $xxx14 = CRMEntity::getInstance($xxx13); $xxx15 = $xxx0b->get('record'); $xxx16 = $xxx0b->get('mode'); $xxx17 = $xxx0b->get('language'); $xxx18 = $xxx0b->get('type'); $xxx19 = ""; $xxx1a = $xxx0c->GetPreparedMPDF($xxx19, $xxx15, $xxx13, $xxx17); $xxx19->Output('cache/' . $xxx1a . '.pdf'); @$xxx27(); $xxx25('Content-Type: application/pdf'); $xxx25("Content-length: " . $xxx22("./cache/{$xxx1a}.pdf")); $xxx25("Cache-Control: private"); $xxx25("Content-Disposition: attachment; filename={$xxx1a}.pdf"); $xxx25("Content-Description: PHP Generated Data"); echo $xxx23($xxx24("./cache/{$xxx1a}.pdf", "r"), $xxx22("./cache/{$xxx1a}.pdf")); @$xxx29("cache/{$xxx1a}.pdf"); }
/** * function to load the queues * @param integer $iduser * @return array */ public function get_all_queue($iduser = 0) { if ((int) $iduser == 0) { $iduser = $_SESSION['do_user']->iduser; $user_timezone = $_SESSION['do_user']->user_timezone; } else { $do_user = new User(); $do_user->getId($iduser); $user_timezone = $do_user->user_timezone; } $today = TimeZoneUtil::get_user_timezone_date($user_timezone); $security_where = $_SESSION["do_crm_action_permission"]->get_user_where_condition('q', 18, false, $iduser); $qry = "\n\t\tselect \n\t\tq.*,\n\t\tm.name as module_name,\n\t\tm.module_label\n\t\tfrom queue q\n\t\tinner join module m on m.idmodule = q.related_module_id\n\t\twhere \n\t\t1=1\n\t\t" . $security_where . "\n\t\tand q.queue_date >= ?\n\t\torder by q.queue_date,q.related_module_id\n\t\t"; $this->query($qry, array($today)); $return_array = array(); if ($this->getNumRows() > 0) { $todayDateObj = new DateTime($today); $do_crm_entity = new CRMEntity(); while ($this->next()) { $queueDateObj = new DateTime($this->queue_date); $diff = $todayDateObj->diff($queueDateObj); $day_diff = $diff->format('%R%a'); $data = array("idqueue" => $this->idqueue, "sqcrm_record_id" => $this->sqcrm_record_id, "module_name" => $this->module_name, "module_label" => $this->module_label, "idmodule" => $this->related_module_id, "entity_identifier" => $do_crm_entity->get_entity_identifier($this->sqcrm_record_id, $this->module_name)); if ($day_diff == 0) { $return_array["today"][] = $data; } elseif ($day_diff == 1) { $return_array["tomorrow"][] = $data; } elseif ($day_diff > 1) { $return_array["later"][] = $data; } } } return $return_array; }
function handleEvent($eventName, $data) { if ($eventName == 'vtiger.entity.beforesave') { // Entity is about to be saved, take required action } if ($eventName == 'vtiger.entity.aftersave') { $db = PearDatabase::getInstance(); $relatedToId = $data->get('related_to'); if ($relatedToId) { $moduleName = getSalesEntityType($relatedToId); $focus = CRMEntity::getInstance($moduleName); $focus->retrieve_entity_info($relatedToId, $moduleName); $focus->id = $relatedToId; $fromPortal = $data->get('from_portal'); if ($fromPortal) { $focus->column_fields['from_portal'] = $fromPortal; } $entityData = VTEntityData::fromCRMEntity($focus); $wfs = new VTWorkflowManager($db); $relatedToEventHandler = new VTWorkflowEventHandler(); $relatedToEventHandler->workflows = $wfs->getWorkflowsForModuleSupportingComments($entityData->getModuleName()); $wsId = vtws_getWebserviceEntityId($entityData->getModuleName(), $entityData->getId()); $fromPortal = $entityData->get('from_portal'); $util = new VTWorkflowUtils(); $entityCache = new VTEntityCache($util->adminUser()); $entityCacheData = $entityCache->forId($wsId); $entityCacheData->set('from_portal', $fromPortal); $entityCache->cache[$wsId] = $entityCacheData; $relatedToEventHandler->handleEvent($eventName, $entityData, $entityCache); $util->revertUser(); } } }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { $adb = PearDatabase::getInstance(); if ($eventType == 'module.postinstall') { $ModuleInstance = CRMEntity::getInstance('NewOrders'); $ModuleInstance->setModuleSeqNumber("configure", 'NewOrders', 'NO', '1'); $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array('NewOrders')); // TODO Handle actions after this module is installed. } else { if ($eventType == 'module.disabled') { // TODO Handle actions before this module is being uninstalled. } 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. } } } } } }
public static function render($userInputObject, $user) { global $list_max_entries_per_page; $adb = PearDatabase::getInstance(); $viewer = new Import_UI_Viewer(); $ownerId = $userInputObject->get('foruser'); $owner = new Users(); $owner->id = $ownerId; $owner->retrieve_entity_info($ownerId, 'Users'); if (!is_admin($user) && $user->id != $owner->id) { $viewer->display('OperationNotPermitted.tpl', 'Vtiger'); exit; } $userDBTableName = Import_Utils::getDbTableName($owner); $moduleName = $userInputObject->get('module'); $moduleMeta = self::getModuleMeta($moduleName, $user); $result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL'); $noOfRecords = $adb->num_rows($result); $importedRecordIds = array(); for ($i = 0; $i < $noOfRecords; ++$i) { $importedRecordIds[] = $adb->query_result($result, $i, 'recordid'); } if (count($importedRecordIds) == 0) { $importedRecordIds[] = 0; } $focus = CRMEntity::getInstance($moduleName); $queryGenerator = new QueryGenerator($moduleName, $user); $customView = new CustomView($moduleName); $viewId = $customView->getViewIdByName('All', $moduleName); $queryGenerator->initForCustomViewById($viewId); $list_query = $queryGenerator->getQuery(); // Fetch only last imported records $list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')'; if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) { $count_result = $adb->query(mkCountQuery($list_query)); $noofrows = $adb->query_result($count_result, 0, "count"); } else { $noofrows = null; } $start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false); $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limit_start_rec = ($start - 1) * $list_max_entries_per_page; $list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array()); $recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows); $viewer->assign('recordListRange', $recordListRangeMsg); $controller = new ListViewController($adb, $user, $queryGenerator); $listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true); $listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true); $viewer->assign('CURRENT_PAGE', $start); $viewer->assign('LISTHEADER', $listview_header); $viewer->assign('LISTENTITY', $listview_entries); $viewer->assign('FOR_MODULE', $moduleName); $viewer->assign('FOR_USER', $ownerId); $isAjax = $userInputObject->get('ajax'); if (!empty($isAjax)) { echo $viewer->fetch('ListViewEntries.tpl'); } else { $viewer->display('ImportListView.tpl'); } }
/** * Function to get relation query for particular module with function name * @param <record> $recordId * @param <String> $functionName * @param Vtiger_Module_Model $relatedModule * @return <String> */ public function getRelationQuery($recordId, $functionName, $relatedModule) { if ($functionName === 'get_activities') { $focus = CRMEntity::getInstance($this->getName()); $focus->id = $recordId; $entityIds = $focus->getRelatedContactsIds(); $entityIds = implode(',', $entityIds); $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT CASE WHEN (vtiger_users.user_name not like '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name,\n\t\t\t\t\t\tvtiger_crmentity.*, vtiger_activity.activitytype, vtiger_activity.subject, vtiger_activity.date_start, vtiger_activity.time_start,\n\t\t\t\t\t\tvtiger_activity.recurringtype, vtiger_activity.due_date, vtiger_activity.time_end, vtiger_activity.visibility, vtiger_seactivityrel.crmid AS parent_id,\n\t\t\t\t\t\tCASE WHEN (vtiger_activity.activitytype = 'Task') THEN (vtiger_activity.status) ELSE (vtiger_activity.eventstatus) END AS status\n\t\t\t\t\t\tFROM vtiger_activity\n\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\t\t\tLEFT JOIN vtiger_seactivityrel ON vtiger_seactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\t\t\tLEFT JOIN vtiger_cntactivityrel ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid\n\t\t\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\t\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.activitytype <> 'Emails'\n\t\t\t\t\t\t\t\tAND (vtiger_seactivityrel.crmid = " . $recordId; if ($entityIds) { $query .= " OR vtiger_cntactivityrel.contactid IN (" . $entityIds . "))"; } else { $query .= ")"; } $relatedModuleName = $relatedModule->getName(); $query .= $this->getSpecificRelationQuery($relatedModuleName); $nonAdminQuery = $this->getNonAdminAccessControlQueryForRelation($relatedModuleName); if ($nonAdminQuery) { $query = appendFromClauseToQuery($query, $nonAdminQuery); } // There could be more than one contact for an activity. $query .= ' GROUP BY vtiger_activity.activityid'; } else { $query = parent::getRelationQuery($recordId, $functionName, $relatedModule); } return $query; }
/** * 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, $event_type) { global $adb; if ($event_type == 'module.postinstall') { $ModuleInstance = CRMEntity::getInstance($modulename); $ModuleInstance->setModuleSeqNumber("configure", $modulename, '', '1'); $Instance = Vtiger_Module::getInstance($modulename); $nModule = Vtiger_Module::getInstance('Accounts'); if ($nModule) { $nModule->setRelatedList($Instance, $modulename, array('add'), 'get_dependents_list'); } $Instance = Vtiger_Module::getInstance($modulename); $nModule = Vtiger_Module::getInstance('Invoice'); if ($nModule) { $nModule->setRelatedList($Instance, $modulename, array('add'), 'get_dependents_list'); } $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments'); if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) { include_once 'modules/ModComments/ModComments.php'; if (class_exists('ModComments')) { ModComments::addWidgetTo(array('Payments')); } } $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array($modulename)); $tabid = Vtiger_Functions::getModuleId($modulename); include_once 'modules/ModTracker/ModTracker.php'; $moduleModTrackerInstance = new ModTracker(); if (!$moduleModTrackerInstance->isModulePresent($tabid)) { $res = $adb->pquery("INSERT INTO vtiger_modtracker_tabs VALUES(?,?)", array($tabid, 1)); $moduleModTrackerInstance->updateCache($tabid, 1); } else { $updatevisibility = $adb->pquery("UPDATE vtiger_modtracker_tabs SET visible = 1 WHERE tabid = ?", array($tabid)); $moduleModTrackerInstance->updateCache($tabid, 1); } if (!$moduleModTrackerInstance->isModTrackerLinkPresent($tabid)) { $moduleInstance = Vtiger_Module::getInstance($tabid); $moduleInstance->addLink('DETAILVIEWBASIC', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')", '', '', array('path' => 'modules/ModTracker/ModTracker.php', 'class' => 'ModTracker', 'method' => 'isViewPermitted')); } $this->addWorkflow($modulename); } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // TODO Handle actions when this module is enabled. } else { if ($event_type == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { } } } } } } }
public function beforeGetTaskform($viewer) { global $adb; if (!\Workflow\VtUtils::existTable("vtiger_wf_customnumbering")) { echo "Create table vtiger_wf_confirmation_user ... ok<br>"; $adb->query("CREATE TABLE IF NOT EXISTS `vtiger_wf_customnumbering` (\r\n `serie` varchar(24) NOT NULL,\r\n `prefix` varchar(16) NOT NULL,\r\n `current` int(10) unsigned NOT NULL,\r\n `length` tinyint(4) NOT NULL,\r\n PRIMARY KEY (`serie`)\r\n ) ENGINE=InnoDB;"); } $crmidColObj = CRMEntity::getInstance($this->getModuleName()); $viewer->assign('crmidCol', $crmidColObj->table_index); $moduleName = $this->getModuleName(); $fields = VtUtils::getFieldsWithBlocksForModule($moduleName, false); $selectedId = $this->get('field'); if ($selectedId === -1 || empty($selectedId)) { $sql = 'SELECT * FROM vtiger_field WHERE uitype = 4 AND tabid = ' . getTabid($moduleName); $result = $adb->query($sql); $selectedId = $adb->query_result($result, 0, 'fieldname'); $this->set('field', $selectedId); } $sql = 'SELECT * FROM vtiger_wf_customnumbering'; $result = $adb->query($sql); $series = array(); while ($row = $adb->fetchByAssoc($result)) { $series[$row['serie']] = $row; } if (isset($series[$this->get('serie')])) { $viewer->assign('lockFields', true); } $viewer->assign('series', $series); $viewer->assign('fields', $fields); /* Insert here source code to create custom configurations pages */ }
/** * Function returns the Query for the relationhips * @param <Vtiger_Record_Model> $recordModel * @param type $actions * @return <String> */ public function getQuery($recordModel, $actions = false) { $parentModuleModel = $this->getParentModuleModel(); $relatedModuleModel = $this->getRelationModuleModel(); $relatedModuleName = $relatedModuleModel->get('name'); $parentModuleName = $parentModuleModel->get('name'); $functionName = $this->get('name'); $focus = CRMEntity::getInstance($parentModuleName); $focus->id = $recordModel->getId(); if (method_exists($parentModuleModel, $functionName)) { $query = $parentModuleModel->{$functionName}($recordModel, $relatedModuleModel); } else { $result = $focus->{$functionName}($recordModel->getId(), $parentModuleModel->getId(), $relatedModuleModel->getId(), $actions); $query = $result['query']; } //modify query if any module has summary fields, those fields we are displayed in related list of that module $relatedListFields = $relatedModuleModel->getConfigureRelatedListFields(); if (count($relatedListFields) > 0) { $currentUser = Users_Record_Model::getCurrentUserModel(); $queryGenerator = new QueryGenerator($relatedModuleName, $currentUser); $queryGenerator->setFields($relatedListFields); $selectColumnSql = $queryGenerator->getSelectClauseColumnSQL(); $newQuery = spliti('FROM', $query); $selectColumnSql = 'SELECT DISTINCT vtiger_crmentity.crmid,' . $selectColumnSql; } if ($functionName == ('get_pricebook_products' || 'get_pricebook_services')) { $selectColumnSql = $selectColumnSql . ', vtiger_pricebookproductrel.listprice'; } $query = $selectColumnSql . ' FROM ' . $newQuery[1]; return $query; }
/** * 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, $event_type) { global $adb; if ($event_type == 'module.postinstall') { $ModuleInstance = CRMEntity::getInstance($modulename); $ModuleInstance->setModuleSeqNumber("configure", $modulename, 'UO', '1'); include_once 'vtlib/Vtiger/Module.php'; $moduleInstance = Vtiger_Module::getInstance($modulename); $docelowy_Module = Vtiger_Module::getInstance('Accounts'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSOutsourcedServices', array('ADD'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Leads'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSOutsourcedServices', array('ADD'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Potentials'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSOutsourcedServices', array('ADD'), 'get_dependents_list'); } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // TODO Handle actions when this module is enabled. } else { if ($event_type == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { } } } } } } }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { $adb = PearDatabase::getInstance(); if ($eventType == 'module.postinstall') { include_once 'vtlib/Vtiger/Module.php'; $moduleInstance = CRMEntity::getInstance('HolidaysEntitlement'); $moduleInstance->setModuleSeqNumber("configure", 'HolidaysEntitlement', 'HE', '1'); $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array('HolidaysEntitlement')); $moduleInstance = Vtiger_Module::getInstance('HolidaysEntitlement'); $targetModule = Vtiger_Module::getInstance('OSSEmployees'); $targetModule->setRelatedList($moduleInstance, 'HolidaysEntitlement', array('ADD'), 'get_dependents_list'); } else { if ($eventType == 'module.disabled') { // TODO Handle actions before this module is being uninstalled. } 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. } } } } } }
protected function setUp() { global $adb, $phpUnitLeadId; ${"GLOBALS"}["vqinqhvudy"] = "sql"; ${"GLOBALS"}["omirinrsle"] = "sql"; ${${"GLOBALS"}["omirinrsle"]} = "SELECT leadid FROM\n vtiger_leaddetails\n LEFT JOIN vtiger_crmentity ON(vtiger_crmentity.crmid = vtiger_leaddetails.leadid)\n WHERE firstname = 'PHPUNIT' AND lastname = 'PHPUNIT' AND deleted = 0"; ${${"GLOBALS"}["dlfzmzsoafs"]} = $adb->query(${${"GLOBALS"}["vqinqhvudy"]}); if ($adb->num_rows(${${"GLOBALS"}["dlfzmzsoafs"]}) > 0) { $pcbcvlo = "result"; ${${"GLOBALS"}["odcnybklnoz"]} = $adb->query_result(${$pcbcvlo}, 0, "leadid"); } else { $zgdgywgjnie = "document"; ${"GLOBALS"}["fbjylokbk"] = "result"; ${$zgdgywgjnie} = CRMEntity::getInstance("Leads"); $document->column_fields["firstname"] = "PHPUNIT"; $document->column_fields["lastname"] = "PHPUNIT"; $qxhkyg = "sql"; $document->column_fields["annualrevenue"] = "1000"; $document->column_fields["cf_654"] = 1; $document->column_fields["assigned_user_id"] = 1; $elbiflyj = "sql"; $document->save("Leads"); ${$elbiflyj} = "SELECT leadid FROM\n vtiger_leaddetails\n LEFT JOIN vtiger_crmentity ON(vtiger_crmentity.crmid = vtiger_leaddetails.leadid)\n WHERE firstname = 'PHPUNIT' AND lastname = 'PHPUNIT' AND deleted = 0"; $adb->query(${$qxhkyg}); ${${"GLOBALS"}["odcnybklnoz"]} = $adb->query_result(${${"GLOBALS"}["fbjylokbk"]}, 0, "leadid"); } VTEntity::setUser(VtUtils::getAdminUser()); print "\nMySuite::setUp()"; }
public static function showImportStatus($importInfo, $user) { if ($importInfo == null) { Import_Utils_Helper::showErrorPage(vtranslate('ERR_IMPORT_INTERRUPTED', 'Import')); exit; } $importDataController = new Import_Data_Action($importInfo, $user); if ($importInfo['status'] == Import_Queue_Action::$IMPORT_STATUS_HALTED || $importInfo['status'] == Import_Queue_Action::$IMPORT_STATUS_NONE) { $continueImport = true; } else { $continueImport = false; } $focus = CRMEntity::getInstance($importInfo['module']); if (method_exists($focus, 'getImportStatusCount')) { $importStatusCount = $focus->getImportStatusCount($importDataController); } else { $importStatusCount = $importDataController->getImportStatusCount(); } $totalRecords = $importStatusCount['TOTAL']; if ($totalRecords > $importStatusCount['IMPORTED'] + $importStatusCount['FAILED']) { // if($importInfo['status'] == Import_Queue_Action::$IMPORT_STATUS_SCHEDULED) { // self::showScheduledStatus($importInfo); // exit; // } self::showCurrentStatus($importInfo, $importStatusCount, $continueImport); exit; } else { $importDataController->finishImport(); self::showResult($importInfo, $importStatusCount); } }
/** * 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, $event_type) { $registerLink = false; $displayLabel = 'Time Control'; global $adb, $log; if ($event_type == 'module.postinstall') { $tabid = getTabid($modulename); $adb->query("UPDATE `vtiger_field` SET `summaryfield` = '1' WHERE `tabid` = {$tabid} AND `columnname` IN ('name','osstimecontrol_no','osstimecontrol_status','smownerid','date_start','time_start','time_end','due_date','sum_time','platnosc');", true); $ModuleInstance = CRMEntity::getInstance($modulename); $ModuleInstance->setModuleSeqNumber("configure", $modulename, 'TC', '1'); include_once 'vtlib/Vtiger/Module.php'; $moduleInstance = Vtiger_Module::getInstance($modulename); $docelowy_Module = Vtiger_Module::getInstance('Accounts'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('HelpDesk'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Project'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('ProjectTask'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('ServiceContracts'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Assets'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('SalesOrder'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Potentials'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Quotes'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $docelowy_Module = Vtiger_Module::getInstance('Leads'); $docelowy_Module->setRelatedList($moduleInstance, 'OSSTimeControl', array('add'), 'get_dependents_list'); $modcommentsModuleInstance = Vtiger_Module::getInstance('ModComments'); if ($modcommentsModuleInstance && file_exists('modules/ModComments/ModComments.php')) { include_once 'modules/ModComments/ModComments.php'; if (class_exists('ModComments')) { ModComments::addWidgetTo(array('OSSTimeControl')); } } } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // TODO Handle actions when this module is enabled. } else { if ($event_type == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { } } } } } } }
public function getJoinSQLbyFieldRelation(&$join_array, &$columns_array) { $related_focus = CRMEntity::getInstance($this->relModuleName); $params_fieldname = $this->params["fieldname"]; // first join to vtiger module table $this->params["fieldname"] = $related_focus->tab_name_index[$this->params["tablename"]]; $this->getStJoinSQL($join_array, $columns_array); $r_tabid = getTabid($this->relModuleName); $adb = PEARDatabase::getInstance(); $uirel_row = $adb->fetchByAssoc($adb->pquery("SELECT * FROM vtiger_field WHERE tabid = ? AND fieldname = ?", array($r_tabid, $params_fieldname)), 0); $related_table_name = $related_focus->table_name; $related_table_index = $related_focus->table_index; foreach ($related_focus->tab_name as $other_table) { $related_join_array[$other_table] = $related_focus->tab_name_index[$other_table]; } $field_uitype = $uirel_row["uitype"]; $fieldid = $this->params["fieldid"]; $oth_as = ""; if ($uirel_row["tablename"] == "vtiger_crmentity") { $oth_as = $this->oth_as; $related_table_name = $uirel_row["tablename"]; $related_table_index = $uirel_row["columnname"]; } $using_aliastablename = $related_table_name . $oth_as . $fieldid; $using_columnname = $related_table_index; $params = array('fieldid' => $uirel_row["fieldid"], 'fieldtabid' => $uirel_row["tabid"], 'field_uitype' => $field_uitype, 'fieldname' => $uirel_row["fieldname"], 'columnname' => $uirel_row["columnname"], 'tablename' => $uirel_row["tablename"], 'table_index' => $related_join_array, 'report_primary_table' => $this->params["report_primary_table"], 'primary_table_name' => $related_focus->table_name, 'primary_table_index' => $related_focus->table_index, 'primary_tableid' => $r_tabid, 'using_aliastablename' => $using_array["u_tablename"], 'using_columnname' => $using_array["u_tableindex"], 'old_oth_as' => $oth_as, 'old_oth_fieldid' => $fieldid, 'fld_string' => $this->params["fld_string"]); $using_array = getJoinInformation($params); $params["using_array"] = $using_array; $uifactory = new UIFactory($params); //show("<font color='green'>fielduitype".$field_uitype."_IN_P_".$field_uitype,$related_join_array,$params["using_array"],"</font>"); $uifactory->getJoinSQL($field_uitype, $join_array, $columns_array); }
/** * Function to get relation query for particular module with function name * @param <record> $recordId * @param <String> $functionName * @param Vtiger_Module_Model $relatedModule * @return <String> */ public function getRelationQuery($recordId, $functionName, $relatedModule, $relationModel = false) { if ($functionName === 'get_activities') { $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT CASE WHEN (vtiger_users.user_name not like '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name,\n\t\t\t\t\t\tvtiger_crmentity.*, vtiger_activity.activitytype, vtiger_activity.subject, vtiger_activity.date_start, vtiger_activity.time_start,\n\t\t\t\t\t\tvtiger_activity.recurringtype, vtiger_activity.due_date, vtiger_activity.time_end, vtiger_activity.visibility,\n\t\t\t\t\t\tCASE WHEN (vtiger_activity.activitytype = 'Task') THEN (vtiger_activity.status) ELSE (vtiger_activity.eventstatus) END AS status\n\t\t\t\t\t\tFROM vtiger_activity\n\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\t\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.process = " . $recordId; $time = vtlib_purify($_REQUEST['time']); if ($time == 'current') { $query .= " AND ((vtiger_activity.activitytype='Task' and vtiger_activity.status not in ('Completed','Deferred'))\n\t\t\t\tOR (vtiger_activity.activitytype not in ('Emails','Task') and vtiger_activity.eventstatus not in ('','Held')))"; } if ($time == 'history') { $query .= " AND ((vtiger_activity.activitytype='Task' and vtiger_activity.status in ('Completed','Deferred'))\n\t\t\t\tOR (vtiger_activity.activitytype not in ('Emails','Task') and vtiger_activity.eventstatus in ('','Held')))"; } $relatedModuleName = $relatedModule->getName(); $query .= $this->getSpecificRelationQuery($relatedModuleName); $instance = CRMEntity::getInstance($relatedModuleName); $securityParameter = $instance->getUserAccessConditionsQuerySR($relatedModuleName); if ($securityParameter != '') { $sql .= $securityParameter; } } elseif ($functionName === 'get_mails' && $relatedModule->getName() == 'OSSMailView') { $query = OSSMailView_Record_Model::getMailsQuery($recordId, $relatedModule->getName()); } else { $query = parent::getRelationQuery($recordId, $functionName, $relatedModule, $relationModel); } return $query; }
function vtEditExpressions($adb, $appStrings, $current_language, $theme, $formodule = '') { $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $smarty = new vtigerCRM_Smarty(); $smarty->assign('APP', $appStrings); $mod = array_merge(return_module_language($current_language, 'FieldFormulas'), return_module_language($current_language, 'Settings')); $jsStrings = array('NEED_TO_ADD_A' => $mod['NEED_TO_ADD_A'], 'CUSTOM_FIELD' => $mod['LBL_CUSTOM_FIELD'], 'LBL_USE_FUNCTION_DASHDASH' => $mod['LBL_USE_FUNCTION_DASHDASH'], 'LBL_USE_FIELD_VALUE_DASHDASH' => $mod['LBL_USE_FIELD_VALUE_DASHDASH'], 'LBL_DELETE_EXPRESSION_CONFIRM' => $mod['LBL_DELETE_EXPRESSION_CONFIRM']); $smarty->assign("JS_STRINGS", Zend_Json::encode($jsStrings)); $smarty->assign("MOD", $mod); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE_NAME", 'FieldFormulas'); $smarty->assign("PAGE_NAME", 'LBL_FIELDFORMULAS'); $smarty->assign("PAGE_TITLE", 'LBL_FIELDFORMULAS'); $smarty->assign("PAGE_DESC", 'LBL_FIELDFORMULAS_DESCRIPTION'); $smarty->assign("FORMODULE", $formodule); if (file_exists("modules/{$formodule}/{$formodule}.php")) { $focus = CRMEntity::getInstance($formodule); $validationArray = split_validationdataArray(getDBValidationData($focus->tab_name, getTabid($formodule))); $smarty->assign('VALIDATION_DATA_FIELDNAME', $validationArray['fieldname']); $smarty->assign('VALIDATION_DATA_FIELDDATATYPE', $validationArray['datatype']); $smarty->assign('VALIDATION_DATA_FIELDLABEL', $validationArray['fieldlabel']); } $smarty->display(vtlib_getModuleTemplate('FieldFormulas', 'EditExpressions.tpl')); }
/** * 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)); } } }
/** * Function to get focus of this object * @return <type> */ public function getFocus() { if (!$this->focus) { $this->focus = CRMEntity::getInstance($this->getName()); } return $this->focus; }
function process(Mobile_API_Request $request) { $response = new Mobile_API_Response(); $username = $request->get('username'); $password = $request->get('password'); $current_user = CRMEntity::getInstance('Users'); $current_user->column_fields['user_name'] = $username; if (vtlib_isModuleActive('Mobile') === false) { $response->setError(1501, 'Service not available'); return $response; } if (!$current_user->doLogin($password)) { $response->setError(1210, 'Authentication Failed'); } else { // Start session now $sessionid = Mobile_API_Session::init(); if ($sessionid === false) { echo "Session init failed {$sessionid}\n"; } $current_user->id = $current_user->retrieve_user_id($username); $current_user->retrieveCurrentUserInfoFromFile($current_user->id); $this->setActiveUser($current_user); $result = array(); $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'user_currency' => $current_user->currency_code, 'session' => $sessionid, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'date_format' => $current_user->date_format, 'mobile_module_version' => Mobile_WS_Utils::getVersion()); $response->setResult($result); $this->postProcess($response); } return $response; }
/** * Send SMS (Creates SMS Entity record, links it with related CRM record and triggers provider to send sms) * * @param String $message * @param Array $tonumbers * @param Integer $ownerid User id to assign the SMS record * @param mixed $linktoids List of CRM record id to link SMS record * @param String $linktoModule Modulename of CRM record to link with (if not provided lookup it will be calculated) */ static function sendsms($message, $tonumbers, $ownerid = false, $linktoids = false, $linktoModule = false) { global $current_user, $adb; if ($ownerid === false) { if (isset($current_user) && !empty($current_user)) { $ownerid = $current_user->id; } else { $ownerid = 1; } } $moduleName = 'SMSNotifier'; $focus = CRMEntity::getInstance($moduleName); $focus->column_fields['message'] = $message; $focus->column_fields['assigned_user_id'] = $ownerid; $focus->save($moduleName); if ($linktoids !== false) { if ($linktoModule !== false) { $focus->save_related_module($moduleName, $focus->id, $linktoModule, $linktoids); } else { // Link modulename not provided (linktoids can belong to mix of module so determine proper modulename) $linkidsetypes = $adb->pquery("SELECT setype,crmid FROM vtiger_crmentity WHERE crmid IN (" . generateQuestionMarks($linktoids) . ")", array($linktoids)); if ($linkidsetypes && $adb->num_rows($linkidsetypes)) { while ($linkidsetypesrow = $adb->fetch_array($linkidsetypes)) { $focus->save_related_module($moduleName, $focus->id, $linkidsetypesrow['setype'], $linkidsetypesrow['crmid']); } } } } $responses = self::fireSendSMS($message, $tonumbers); $focus->processFireSendSMSResponse($responses); }
function process(Mobile_API_Request $request) { $response = new Mobile_API_Response(); $username = $request->get('username'); $password = $request->get('password'); $current_user = CRMEntity::getInstance('Users'); $current_user->column_fields['user_name'] = $username; if (vtlib_isModuleActive('Mobile') === false) { $response->setError(1501, 'Service not available'); return $response; } if (!$current_user->load_user($password) || !$current_user->authenticated) { global $mod_strings; $response->setError(1210, $mod_strings['ERR_INVALID_PASSWORD']); } else { // Start session now $sessionid = Mobile_API_Session::init(); if ($sessionid === false) { echo "Session init failed {$sessionid}\n"; } include_once 'config.php'; global $application_unique_key; $current_user->id = $current_user->retrieve_user_id($username); $this->setActiveUser($current_user); $_SESSION["authenticated_user_id"] = $current_user->id; $_SESSION["app_unique_key"] = $application_unique_key; $result = array(); $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'session' => $sessionid, 'language' => $current_user->language, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'mobile_module_version' => Mobile_WS_Utils::getVersion()); $response->setResult($result); $this->postProcess($response); } return $response; }
/** * Function to get relation query for particular module with function name * @param <record> $recordId * @param <String> $functionName * @param Vtiger_Module_Model $relatedModule * @return <String> */ public function getRelationQuery($recordId, $functionName, $relatedModule, $relationModel = false) { if ($functionName === 'get_activities') { $focus = CRMEntity::getInstance($this->getName()); $focus->id = $recordId; $entityIds = $focus->getRelatedContactsIds(); $entityIds[] = $recordId; $entityIds = implode(',', $entityIds); $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users'); $query = "SELECT CASE WHEN (vtiger_users.user_name not like '') THEN {$userNameSql} ELSE vtiger_groups.groupname END AS user_name,\n\t\t\t\t\t\tvtiger_crmentity.*, vtiger_activity.activitytype, vtiger_activity.subject, vtiger_activity.date_start, vtiger_activity.time_start,\n\t\t\t\t\t\tvtiger_activity.recurringtype, vtiger_activity.due_date, vtiger_activity.time_end, vtiger_activity.visibility, \n\t\t\t\t\t\tvtiger_activity.status AS status\n\t\t\t\t\t\tFROM vtiger_activity\n\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_activity.activityid\n\t\t\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\t\t\tWHERE vtiger_crmentity.deleted = 0 AND vtiger_activity.link IN (" . $entityIds . ')'; $time = vtlib_purify($_REQUEST['time']); if ($time == 'current') { $stateActivityLabels = Calendar_Module_Model::getComponentActivityStateLabel('current'); $query .= " AND (vtiger_activity.activitytype NOT IN ('Emails') AND vtiger_activity.status IN ('" . implode("','", $stateActivityLabels) . "'))"; } if ($time == 'history') { $stateActivityLabels = Calendar_Module_Model::getComponentActivityStateLabel('history'); $query .= " AND (vtiger_activity.activitytype NOT IN ('Emails') AND vtiger_activity.status IN ('" . implode("','", $stateActivityLabels) . "'))"; } $relatedModuleName = $relatedModule->getName(); $query .= $this->getSpecificRelationQuery($relatedModuleName); $instance = CRMEntity::getInstance($relatedModuleName); $securityParameter = $instance->getUserAccessConditionsQuerySR($relatedModuleName, false, $recordId); if ($securityParameter != '') { $query .= $securityParameter; } // There could be more than one contact for an activity. $query .= ' GROUP BY vtiger_activity.activityid'; } elseif ($functionName === 'get_mails' && $relatedModule->getName() == 'OSSMailView') { $query = OSSMailView_Record_Model::getMailsQuery($recordId, $relatedModule->getName()); } else { $query = parent::getRelationQuery($recordId, $functionName, $relatedModule, $relationModel); } return $query; }
public function updateProgressMilestone($id) { $adb = PearDatabase::getInstance(); //TODO need to handle security if (!isRecordExists($id)) { return; } $focus = CRMEntity::getInstance($this->getName()); $relatedListMileston = $focus->get_dependents_list($id, $this->getId(), getTabid('ProjectTask')); $resultMileston = $adb->query($relatedListMileston['query']); $num = $adb->num_rows($resultMileston); $estimatedWorkTime = 0; $progressInHours = 0; for ($i = 0; $i < $num; $i++) { $row = $adb->query_result_rowdata($resultMileston, $i); $estimatedWorkTime += $row['estimated_work_time']; $recordProgress = $row['estimated_work_time'] * (int) $row['projecttaskprogress'] / 100; $progressInHours += $recordProgress; } if (!$estimatedWorkTime) { return; } $projectMilestoneProgress = round(100 * $progressInHours / $estimatedWorkTime); $focus->retrieve_entity_info($id, $this->getName()); $focus->column_fields['projectmilestone_progress'] = $projectMilestoneProgress . '%'; $focus->column_fields['mode'] = 'edit'; $focus->saveentity($this->getName(), $id); }
protected function getModels($parentRecordId, $criteria) { global $adb, $current_user; $moduleName = 'ModComments'; if (vtlib_isModuleActive($moduleName)) { $entityInstance = CRMEntity::getInstance($moduleName); $queryCriteria = ''; switch ($criteria) { case 'All': $queryCriteria = sprintf(" ORDER BY %s.%s DESC ", $entityInstance->table_name, $entityInstance->table_index); break; case 'Last5': $queryCriteria = sprintf(" ORDER BY %s.%s DESC LIMIT 5", $entityInstance->table_name, $entityInstance->table_index); break; case 'Mine': $queryCriteria = ' AND vtiger_crmentity.smownerid=' . $current_user->id . sprintf(" ORDER BY %s.%s DESC ", $entityInstance->table_name, $entityInstance->table_index); break; } $query = $entityInstance->getListQuery($moduleName, sprintf(" AND %s.related_to=?", $entityInstance->table_name)); $query .= $queryCriteria; $result = $adb->pquery($query, array($parentRecordId)); $instances = array(); if ($adb->num_rows($result)) { while ($resultrow = $adb->fetch_array($result)) { $instances[] = new ModComments_CommentsModel($resultrow); } } } return $instances; }
/** * Function to get the list view entries * @param Vtiger_Paging_Model $pagingModel * @return <Array> - Associative array of record id mapped to Vtiger_Record_Model instance. */ public function getListViewEntries($pagingModel) { $db = PearDatabase::getInstance(); $moduleName = $this->getModule()->get('name'); $moduleFocus = CRMEntity::getInstance($moduleName); $moduleModel = Vtiger_Module_Model::getInstance($moduleName); $queryGenerator = $this->get('query_generator'); $listViewContoller = $this->get('listview_controller'); $listQuery = $queryGenerator->getQuery(); $startIndex = $pagingModel->getStartIndex(); $pageLimit = $pagingModel->getPageLimit(); $importedRecordIds = $this->getLastImportedRecord(); $listViewRecordModels = array(); if (count($importedRecordIds) != 0) { $moduleModel = $this->get('module'); $listQuery .= ' AND ' . $moduleModel->basetable . '.' . $moduleModel->basetableid . ' IN (' . implode(',', $importedRecordIds) . ')'; $listQuery .= " LIMIT {$startIndex}, {$pageLimit}"; $listResult = $db->pquery($listQuery, array()); $listViewEntries = $listViewContoller->getListViewRecords($moduleFocus, $moduleName, $listResult); $pagingModel->calculatePageRange($listViewEntries); foreach ($listViewEntries as $recordId => $record) { $record['id'] = $recordId; $listViewRecordModels[$recordId] = $moduleModel->getRecordFromArray($record); } } return $listViewRecordModels; }
function process(Vtiger_Request $request) { $username = $request->get('username'); $password = $request->get('password'); $user = CRMEntity::getInstance('Users'); $user->column_fields['user_name'] = $username; if ($user->doLogin($password)) { $userid = $user->retrieve_user_id($username); Vtiger_Session::set('AUTHUSERID', $userid); // For Backward compatability // TODO Remove when switch-to-old look is not needed $_SESSION['authenticated_user_id'] = $userid; $_SESSION['app_unique_key'] = vglobal('application_unique_key'); $_SESSION['authenticated_user_language'] = vglobal('default_language'); //Enabled session variable for KCFINDER $_SESSION['KCFINDER'] = array(); $_SESSION['KCFINDER']['disabled'] = false; $_SESSION['KCFINDER']['uploadURL'] = "test/upload"; $_SESSION['KCFINDER']['uploadDir'] = "test/upload"; $deniedExts = implode(" ", vglobal('upload_badext')); $_SESSION['KCFINDER']['deniedExts'] = $deniedExts; // End //Track the login History $moduleModel = Users_Module_Model::getInstance('Users'); $moduleModel->saveLoginHistory($user->column_fields['user_name']); //End header('Location: index.php?module=Users&parent=Settings&view=SystemSetup'); exit; } else { header('Location: index.php?module=Users&parent=Settings&view=Login&error=1'); exit; } }
function handleEvent($eventName, $entityData) { if (in_array($eventName, ['vtiger.entity.link.after', 'vtiger.entity.unlink.after'])) { $fields = Vtiger_MultiReferenceValue_UIType::getFieldsByModules($entityData['sourceModule'], $entityData['destinationModule']); foreach ($fields as $field) { $fieldModel = new Vtiger_Field_Model(); $fieldModel->initialize($field); $UITypeModel = $fieldModel->getUITypeModel(); if ($eventName == 'vtiger.entity.link.after') { $UITypeModel->addValue($entityData['CRMEntity'], $entityData['sourceRecordId'], $entityData['destinationRecordId']); } elseif ($eventName == 'vtiger.entity.unlink.after') { $UITypeModel->removeValue(CRMEntity::getInstance($entityData['sourceModule']), $entityData['sourceRecordId'], $entityData['destinationRecordId']); } } } else { if ($eventName == 'vtiger.entity.aftersave.final') { $db = PearDatabase::getInstance(); $moduleName = $entityData->getModuleName(); $modules = Vtiger_MultiReferenceValue_UIType::getRelatedModules($moduleName); foreach ($modules as $module) { $db->insert('s_yf_multireference', ['source_module' => $module, 'dest_module' => $moduleName, 'lastid' => $entityData->getId(), 'type' => 1]); } } } }
/** * 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, $event_type) { $adb = PearDatabase::getInstance(); if ($event_type == 'module.postinstall') { $ModuleInstance = CRMEntity::getInstance($modulename); $ModuleInstance->setModuleSeqNumber("configure", $modulename, 'US', '1'); } else { if ($event_type == 'module.disabled') { // TODO Handle actions when this module is disabled. } else { if ($event_type == 'module.enabled') { // TODO Handle actions when this module is enabled. } else { if ($event_type == 'module.preuninstall') { // TODO Handle actions when this module is about to be deleted. } else { if ($event_type == 'module.preupdate') { // TODO Handle actions before this module is updated. } else { if ($event_type == 'module.postupdate') { } } } } } } }
function captureNow($request) { $currentLanguage = Vtiger_Language_Handler::getLanguage(); $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage); vglobal('app_strings', $moduleLanguageStrings['languageStrings']); $returnURL = false; try { if (!vtlib_isModuleActive('Webforms')) { throw new Exception('webforms is not active'); } $webform = Webforms_Model::retrieveWithPublicId(vtlib_purify($request['publicid'])); if (empty($webform)) { throw new Exception("Webform not found."); } $returnURL = $webform->getReturnUrl(); $roundrobin = $webform->getRoundrobin(); // Retrieve user information $user = CRMEntity::getInstance('Users'); $user->id = $user->getActiveAdminId(); $user->retrieve_entity_info($user->id, 'Users'); // Prepare the parametets $parameters = array(); $webformFields = $webform->getFields(); foreach ($webformFields as $webformField) { if ($webformField->getDefaultValue() != null) { $parameters[$webformField->getFieldName()] = decode_html($webformField->getDefaultValue()); } else { $webformNeutralizedField = html_entity_decode($webformField->getNeutralizedField(), ENT_COMPAT, "UTF-8"); if (is_array(vtlib_purify($request[$webformNeutralizedField]))) { $fieldData = implode(" |##| ", vtlib_purify($request[$webformNeutralizedField])); } else { $fieldData = vtlib_purify($request[$webformNeutralizedField]); $fieldData = decode_html($fieldData); } $parameters[$webformField->getFieldName()] = stripslashes($fieldData); } if ($webformField->getRequired()) { if (!isset($parameters[$webformField->getFieldName()])) { throw new Exception("Required fields not filled"); } } } if ($roundrobin) { $ownerId = $webform->getRoundrobinOwnerId(); $ownerType = vtws_getOwnerType($ownerId); $parameters['assigned_user_id'] = vtws_getWebserviceEntityId($ownerType, $ownerId); } else { $ownerId = $webform->getOwnerId(); $ownerType = vtws_getOwnerType($ownerId); $parameters['assigned_user_id'] = vtws_getWebserviceEntityId($ownerType, $ownerId); } // Create the record $record = vtws_create($webform->getTargetModule(), $parameters, $user); $this->sendResponse($returnURL, 'ok'); return; } catch (Exception $e) { $this->sendResponse($returnURL, false, $e->getMessage()); return; } }