public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $source = $request->get('source'); $sourceModule = $request->get('sourceModule'); if ($sourceModule != '') { $source = Vtiger_Functions::getModuleId($sourceModule); } if ($source == '') { $source = 6; } $moduleModel = Settings_Widgets_Module_Model::getInstance($qualifiedModuleName); $RelatedModule = $moduleModel->getRelatedModule($source); $viewer = $this->getViewer($request); $viewer->assign('MODULE_MODEL', $moduleModel); $viewer->assign('SOURCE', $source); $viewer->assign('SOURCEMODULE', Vtiger_Functions::getModuleName($source)); $viewer->assign('WIDGETS', $moduleModel->getWidgets($source)); $viewer->assign('RELATEDMODULES', $RelatedModule); $viewer->assign('FILTERS', json_encode($moduleModel->getFiletrs($RelatedModule))); $viewer->assign('CHECKBOXS', json_encode($moduleModel->getCheckboxs($RelatedModule))); //$viewer->assign('EXCLUDEDTYPES', $moduleModel->excludedTypes($source) ); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->assign('MODULE', $moduleName); $viewer->view('Index.tpl', $qualifiedModuleName); }
public function process(Vtiger_Request $request) { $adb = PearDatabase::getInstance(); $metod = $request->get('metod'); $params = $request->get('params'); $params['folder'] = urldecode($params['folder']); $return = false; if (Vtiger_Functions::getModuleId('OSSMailView') && Vtiger_Functions::getModuleId('OSSMailScanner')) { $return = 0; $account = OSSMail_Record_Model::get_account_detail_by_name($params['username']); $result = $adb->pquery("SELECT ossmailviewid FROM vtiger_ossmailview WHERE id = ? AND mbox = ? AND rc_user = ?", array($params['uid'], $params['folder'], $account[0]['user_id']), true); if ($adb->num_rows($result) > 0) { $return = $adb->query_result($result, 0, 'ossmailviewid'); } else { $scannerModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner'); $params['actions'] = '0_created_Email'; $mail_Scan_mail = $scannerModel->manualScanMail($params); if ($mail_Scan_mail['0_created_Email']) { $return = $mail_Scan_mail['0_created_Email']['created_Email']; } } } $response = new Vtiger_Response(); $response->setResult($return); $response->emit(); }
function getListFiledOfRelatedModule($moduleName) { $db = PearDatabase::getInstance(); $tabid = getTabid($moduleName); $sourceModule = $moduleName; $sql = "select vtiger_field.fieldid, fieldlabel, uitype, vtiger_fieldmodulerel.relmodule from vtiger_field \n\t\t\t\tleft JOIN vtiger_fieldmodulerel ON vtiger_fieldmodulerel.fieldid = vtiger_field.fieldid where tabid = ? AND (uitype = '10' OR uitype = '59' OR uitype = '53' OR uitype = '51')"; $resultModuleList = $db->pquery($sql, array($tabid), true); $moduleList = array(); for ($i = 0; $i < $db->num_rows($resultModuleList); $i++) { $uitype = $db->query_result($resultModuleList, $i, 'uitype'); $fieldid = $db->query_result($resultModuleList, $i, 'fieldid'); $fieldlabel = $db->query_result($resultModuleList, $i, 'fieldlabel'); if ($uitype == 10) { $moduleList[] = array(Vtiger_Functions::getModuleId($db->query_result($resultModuleList, $i, 'relmodule')), $fieldlabel, $fieldid); } elseif ($uitype == 51) { $moduleList[] = array(Vtiger_Functions::getModuleId('Accounts'), $fieldlabel, $fieldid); } elseif ($uitype == 59) { $moduleList[] = array(Vtiger_Functions::getModuleId('Products'), $fieldlabel, $fieldid); } elseif ($uitype == 53) { $moduleList[] = array(Vtiger_Functions::getModuleId('Users'), $fieldlabel, $fieldid); } } $output = array(); for ($i = 0; $i < count($moduleList); $i++) { $moduleInfoSql = "SELECT * FROM vtiger_tab WHERE tabid = ?"; $moduleInfoResult = $db->pquery($moduleInfoSql, array($moduleList[$i][0]), true); $moduleName = $db->query_result($moduleInfoResult, 0, 'name'); $moduleTrLabal = vtranslate($moduleList[$i][1], $sourceModule); $output[$moduleTrLabal] = array(); $output[$moduleTrLabal] = $this->getListFiledOfModule($moduleName, $moduleList[$i][2]); } return $output; }
/** * 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(); $module = $this->getModule(); $moduleName = $module->getName(); $parentModuleName = $module->getParentName(); $qualifiedModuleName = $moduleName; if (!empty($parentModuleName)) { $qualifiedModuleName = $parentModuleName . ':' . $qualifiedModuleName; } $recordModelClass = Vtiger_Loader::getComponentClassName('Model', 'Record', $qualifiedModuleName); $listQuery = $this->getBasicListQuery(); $startIndex = $pagingModel->getStartIndex(); $pageLimit = $pagingModel->getPageLimit(); $orderBy = $this->getForSql('orderby'); if (!empty($orderBy) && $orderBy === 'smownerid') { $fieldModel = Vtiger_Field_Model::getInstance('assigned_user_id', $moduleModel); if ($fieldModel->getFieldDataType() == 'owner') { $orderBy = 'COALESCE(CONCAT(vtiger_users.first_name,vtiger_users.last_name),vtiger_groups.groupname)'; } } if (!empty($orderBy)) { $listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder'); } $sourceModule = $this->get('sourceModule'); if (!empty($sourceModule)) { $tabId = Vtiger_Functions::getModuleId($sourceModule); $listQuery .= " WHERE `module` = '{$tabId}' "; } if ($module->isPagingSupported()) { $nextListQuery = $listQuery . ' LIMIT ' . ($startIndex + $pageLimit) . ',1'; $listQuery .= " LIMIT {$startIndex}, {$pageLimit}"; } $listResult = $db->pquery($listQuery, array()); $noOfRecords = $db->num_rows($listResult); $listViewRecordModels = array(); for ($i = 0; $i < $noOfRecords; ++$i) { $row = $db->query_result_rowdata($listResult, $i); $record = new $recordModelClass(); $record->setData($row); $recordModule = Vtiger_Functions::getModuleName($row['module']); $record->set('module', vtranslate($recordModule, $recordModule)); if (method_exists($record, 'getModule') && method_exists($record, 'setModule')) { $moduleModel = Settings_Vtiger_Module_Model::getInstance($qualifiedModuleName); $record->setModule($moduleModel); } $listViewRecordModels[$record->getId()] = $record; } if ($module->isPagingSupported()) { $pagingModel->calculatePageRange($listViewRecordModels); $nextPageResult = $db->pquery($nextListQuery, array()); $nextPageNumRows = $db->num_rows($nextPageResult); if ($nextPageNumRows <= 0) { $pagingModel->set('nextPageExists', false); } } return $listViewRecordModels; }
/** * Invoked when special actions are performed on the module. * @param String Module name * @param String Event Type */ function vtlib_handler($moduleName, $eventType) { global $adb; if ($eventType == 'module.postinstall') { include_once 'vtlib/Vtiger/Module.php'; $moduleInstance = CRMEntity::getInstance('RequirementCards'); $moduleInstance->setModuleSeqNumber("configure", 'RequirementCards', 'RC', '1'); $adb->pquery('UPDATE vtiger_tab SET customized=0 WHERE name=?', array('RequirementCards')); $moduleInstance = Vtiger_Module::getInstance('RequirementCards'); $targetModule = Vtiger_Module::getInstance('Accounts'); $targetModule->setRelatedList($moduleInstance, 'RequirementCards', 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('RequirementCards')); } } $modcommentsModuleInstance = Vtiger_Module::getInstance('ModTracker'); if ($modcommentsModuleInstance && file_exists('modules/ModTracker/ModTracker.php')) { include_once 'vtlib/Vtiger/Module.php'; include_once 'modules/ModTracker/ModTracker.php'; $tabid = Vtiger_Functions::getModuleId('RequirementCards'); $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')); } } } 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. } } } } } }
/** * Load tree field info * @return array */ public function getTreeField() { if ($this->has('fieldTemp')) { return $this->get('fieldTemp'); } $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT tablename,columnname,fieldname,fieldlabel,fieldparams FROM vtiger_field WHERE uitype = ? AND tabid = ?', [302, Vtiger_Functions::getModuleId($this->getModuleName())]); $fieldTemp = $db->getRow($result); $this->set('fieldTemp', $fieldTemp); return $fieldTemp; }
public function save($comment) { $db = PearDatabase::getInstance(); if (substr($this->get('relatedRecord'), 0, 1) == 'T') { $db->update('u_yf_crmentity_rel_tree', ['rel_comment' => $comment], 'crmid = ? AND tree = ? AND relmodule = ?', [$this->get('record'), $this->get('relatedRecord'), Vtiger_Functions::getModuleId($this->get('relatedModuleName'))]); } else { $relationTable = $this->getRelationTable(); $table = key($relationTable); $db->update($table, ['rel_comment' => $comment], $relationTable[$table][0] . ' = ? AND ' . $relationTable[$table][1] . ' = ?', [$this->get('record'), $this->get('relatedRecord')]); } }
/** * 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, '', '1'); $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') { } } } } } } }
/** * Load tree field info * @return array */ public function getTreeField() { if ($this->has('fieldTemp')) { return $this->get('fieldTemp'); } $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT tablename,columnname,fieldname,fieldparams FROM vtiger_field WHERE uitype = ? AND tabid = ?', [302, Vtiger_Functions::getModuleId($this->getModuleName())]); if ($db->getRowCount($result) == 0) { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $this->getModuleName())); } $fieldTemp = $db->getRow($result); $this->set('fieldTemp', $fieldTemp); return $fieldTemp; }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $viewer = $this->getViewer($request); $OSSMail_Record_Model = Vtiger_Record_Model::getCleanInstance('OSSMail'); if (Vtiger_Functions::getModuleId('OSSMailScanner')) { $OSSMailScanner_Record_Model = Vtiger_Record_Model::getCleanInstance('OSSMailScanner'); $WidgetCfg = $OSSMailScanner_Record_Model->getConfig(false); } $viewer->assign('RecordModel', $OSSMail_Record_Model); $viewer->assign('WIDGET_CFG', $WidgetCfg); $viewer->assign('MODULENAME', $moduleName); echo $viewer->view('config.tpl', $moduleName, true); }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $OSSMail_active = Vtiger_Functions::getModuleId('OSSMail'); if ($OSSMail_active) { $mailRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMail'); $accountsList = $mailRecordModel->getAccountsList(); $mailboxes = $mailRecordModel->get_default_mailboxes(); } $mailScannerRecordModel = Vtiger_Record_Model::getCleanInstance('OSSMailScanner'); $identityList = []; if ($accountsList) { foreach ($accountsList as $key => $account) { $identityList[$account['user_id']] = $mailScannerRecordModel->getIdentities($account['user_id']); $mbox = $mailRecordModel->imapConnect($account['username'], $account['password'], $account['mail_host'], 'INBOX', false); $accountsList[$key]['status'] = $mbox ? 'LBL_ACTIVE_MAIL' : 'LBL_INACTIVE_MAIL'; } } $EmailActionsList = $mailScannerRecordModel->getEmailActionsList(); $EmailActionsListName = $mailScannerRecordModel->getEmailActionsListName($EmailActionsList); $ConfigFolderList = $mailScannerRecordModel->getConfigFolderList(); $EmailSearch = $mailScannerRecordModel->getEmailSearch(); $EmailSearchList = $mailScannerRecordModel->getEmailSearchList(); $widgetCfg = $mailScannerRecordModel->getConfig(false); $supportedModules = Settings_Vtiger_CustomRecordNumberingModule_Model::getSupportedModules(); foreach ($supportedModules as $supportedModule) { if (in_array($supportedModule->name, $this->prefixesForModules)) { $moduleModel = Settings_Vtiger_CustomRecordNumberingModule_Model::getInstance($supportedModule->name); $moduleData = $moduleModel->getModuleCustomNumberingData(); $RecordNumbering[$supportedModule->name] = $moduleData; } } $check_cron = $mailScannerRecordModel->get_cron(); $viewer = $this->getViewer($request); $viewer->assign('RECORD_MODEL', $mailScannerRecordModel); $viewer->assign('ACCOUNTLIST', $accountsList); $viewer->assign('EMAILACTIONSLIST', $EmailActionsList); $viewer->assign('EMAILACTIONSLISTNAME', $EmailActionsListName); $viewer->assign('FOLDERMAILBOXES', $mailboxes); $viewer->assign('CONFIGFOLDERLIST', $ConfigFolderList); $viewer->assign('WIDGET_CFG', $widgetCfg); $viewer->assign('EMAILSEARCH', $EmailSearch); $viewer->assign('EMAILSEARCHLIST', $EmailSearchList); $viewer->assign('RECORDNUMBERING', $RecordNumbering); $viewer->assign('ERRORNOMODULE', !$OSSMail_active); $viewer->assign('MODULENAME', $moduleName); $viewer->assign('IDENTITYLIST', $identityList); $viewer->assign('CHECKCRON', $check_cron); echo $viewer->view('Index.tpl', $request->getModule(false), true); }
/** * Loading the list of multireference fields * @param string $sourceModule Source module name * @param string $destinationModule Destination module name * @return array */ public function getMultiReferenceValueFields($sourceModule, $destinationModule) { $return = Vtiger_Cache::get('mrvf-' . $sourceModule, $destinationModule); if (!$return) { $db = PearDatabase::getInstance(); $query = 'SELECT * FROM vtiger_field WHERE tabid = ? AND presence <> ? AND fieldparams LIKE \'{"module":"' . $destinationModule . '"%\';'; $result = $db->pquery($query, [Vtiger_Functions::getModuleId($sourceModule), 1]); $return = []; while ($field = $db->fetch_array($result)) { $return[] = $field; } Vtiger_Cache::set('mrvf-' . $sourceModule, $destinationModule, $return); } return $return; }
public function process(Vtiger_Request $request) { $metod = $request->get('metod'); $params = $request->get('params'); $result = false; if (Vtiger_Functions::getModuleId('OSSMailView')) { $params['folder'] = urldecode($params['folder']); $account = OSSMail_Record_Model::get_account_detail_by_name($params['username']); $params['user_id'] = $account['user_id']; $OSSMailModel = Vtiger_Record_Model::getCleanInstance('OSSMail'); $result = $OSSMailModel->findCrmDetail($params, $metod); } $response = new Vtiger_Response(); $response->setResult($result); $response->emit(); }
function process(Vtiger_Request $request) { $branches = $request->get('branches'); $filter = $request->get('filter'); $category = $request->get('category'); if (empty($branches) && empty($category)) { return; } $moduleName = $request->getModule(); $viewer = $this->getViewer($request); $baseModuleName = 'Accounts'; $multiReferenceFirld = Vtiger_MultiReferenceValue_UIType::getFieldsByModules($baseModuleName, $moduleName); $multiReferenceFirld = reset($multiReferenceFirld); if (count($multiReferenceFirld) === 0) { return; } $pagingModel = new Vtiger_Paging_Model(); $pagingModel->set('limit', 'no_limit'); $listViewModel = Vtiger_ListView_Model::getInstance($baseModuleName, $filter); $queryGenerator = $listViewModel->get('query_generator'); $glue = ''; if (!empty($branches)) { if (count($queryGenerator->getWhereFields()) > 0 && count($searchParams) > 0) { $glue = QueryGenerator::$AND; } $queryGenerator->addCondition($multiReferenceFirld['columnname'], implode(',', $branches), 'c'); } if (!empty($category)) { $baseModuleId = Vtiger_Functions::getModuleId($baseModuleName); $moduleId = Vtiger_Functions::getModuleId($moduleName); $query = 'SELECT crmid FROM u_yf_crmentity_rel_tree WHERE module = ' . $baseModuleId . ' AND relmodule = ' . $moduleId . ' AND tree IN (\'' . implode("','", $category) . '\')'; if (count($queryGenerator->getWhereFields()) > 0 && count($searchParams) > 0) { $glue = QueryGenerator::$AND; } $queryGenerator->addCondition($multiReferenceFirld['columnname'], $query, 'subQuery', 'OR', true); } $listViewModel->set('query_generator', $queryGenerator); $listEntries = $listViewModel->getListViewEntries($pagingModel, true); if (count($listEntries) === 0) { return; } $listHeaders = $listViewModel->getListViewHeaders(); $viewer->assign('ENTRIES', $listEntries); $viewer->assign('HEADERS', $listHeaders); $viewer->assign('MODULE', $baseModuleName); $viewer->view('TreeRecords.tpl', $moduleName); }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $OSSMail_active = Vtiger_Functions::getModuleId('OSSMail'); if ($OSSMail_active) { $OSSMail_Record_Model = Vtiger_Record_Model::getCleanInstance('OSSMail'); $AccountsList = $OSSMail_Record_Model->getAccountsList(); $mailboxes = $OSSMail_Record_Model->get_default_mailboxes(); } $OSSMailScanner_Record_Model = Vtiger_Record_Model::getCleanInstance('OSSMailScanner'); $identityList = array(); for ($i = 0; $i < count($AccountsList); $i++) { $identityList[$AccountsList[$i]['user_id']] = $OSSMailScanner_Record_Model->getIdentities($AccountsList[$i]['user_id']); } $EmailActionsList = $OSSMailScanner_Record_Model->getEmailActionsList(); $EmailActionsListName = $OSSMailScanner_Record_Model->getEmailActionsListName($EmailActionsList); $ConfigFolderList = $OSSMailScanner_Record_Model->getConfigFolderList(); $EmailSearch = $OSSMailScanner_Record_Model->getEmailSearch(); $EmailSearchList = $OSSMailScanner_Record_Model->getEmailSearchList(); $WidgetCfg = $OSSMailScanner_Record_Model->getConfig(false); $supportedModules = Settings_Vtiger_CustomRecordNumberingModule_Model::getSupportedModules(); foreach ($supportedModules as $supportedModule) { if (in_array($supportedModule->name, $this->prefixesForModules)) { $moduleModel = Settings_Vtiger_CustomRecordNumberingModule_Model::getInstance($supportedModule->name); $moduleData = $moduleModel->getModuleCustomNumberingData(); $RecordNumbering[$supportedModule->name] = $moduleData; } } $check_cron = $OSSMailScanner_Record_Model->get_cron(); $viewer = $this->getViewer($request); $viewer->assign('RecordModel', $OSSMailScanner_Record_Model); $viewer->assign('ACCOUNTLIST', $AccountsList); $viewer->assign('EMAILACTIONSLIST', $EmailActionsList); $viewer->assign('EMAILACTIONSLISTNAME', $EmailActionsListName); $viewer->assign('FOLDERMAILBOXES', $mailboxes); $viewer->assign('CONFIGFOLDERLIST', $ConfigFolderList); $viewer->assign('WIDGET_CFG', $WidgetCfg); $viewer->assign('EMAILSEARCH', $EmailSearch); $viewer->assign('EMAILSEARCHLIST', $EmailSearchList); $viewer->assign('RECORDNUMBERING', $RecordNumbering); $viewer->assign('ERRORNOMODULE', !$OSSMail_active); $viewer->assign('MODULENAME', $moduleName); $viewer->assign('IDENTITYLIST', $identityList); $viewer->assign('CHECKCRON', $check_cron); echo $viewer->view('index.tpl', $moduleName, true); }
public static function getWidgets($module = false, $record = false) { $db = PearDatabase::getInstance(); $sql = 'SELECT * FROM vtiger_widgets'; $params = []; if ($module) { if (!is_numeric($module)) { $module = Vtiger_Functions::getModuleId($module); } $sql .= ' WHERE tabid = ? '; $params[] = $module; } $sql .= ' ORDER BY tabid,sequence ASC'; $result = $db->pquery($sql, $params, true); $widgets = array(1 => array(), 2 => array(), 3 => array()); while ($row = $db->getRow($result)) { $row['data'] = Zend_Json::decode($row['data']); $widgets[$row["wcol"]][$row["id"]] = $row; } return $widgets; }
public function getTreeTemplates($sourceModule) { $adb = PearDatabase::getInstance(); $sourceModule = Vtiger_Functions::getModuleId($sourceModule); $query = 'SELECT templateid,name FROM vtiger_trees_templates WHERE module = ?'; $result = $adb->pquery($query, array($sourceModule)); $numOfRows = $adb->num_rows($result); $treeList = array(); for ($i = 0; $i < $numOfRows; $i++) { $treeList[$adb->query_result($result, $i, 'templateid')] = $adb->query_result($result, $i, 'name'); } return $treeList; }
public function import(Vtiger_Request $request) { $qualifiedModuleName = $request->getModule(false); $id = ''; if (is_array($_FILES) && $_FILES['imported_xml']['name'] != '') { $xmlName = $_FILES['imported_xml']['name']; $uploadedXml = $_FILES['imported_xml']['tmp_name']; $xmlError = $_FILES['imported_xml']['error']; $extension = end(explode('.', $xmlName)); $message = false; $moduleInstance = Settings_MappedFields_Module_Model::getCleanInstance(); $mapping = []; $combine = ['tabid' => 'source', 'reltabid' => 'target']; if ($xmlError == UPLOAD_ERR_OK && $extension === 'xml') { $xml = simplexml_load_file($uploadedXml); $i = 0; $instances = []; foreach ($xml as $fieldsKey => $fieldsValue) { if (array_key_exists($fieldsKey, $combine)) { $value = (int) Vtiger_Functions::getModuleId((string) $fieldsValue); if (empty($value)) { break; } $instances[$combine[$fieldsKey]] = Vtiger_Module_Model::getInstance((string) $fieldsValue); } elseif ($fieldsKey == 'fields') { foreach ($fieldsValue as $fieldKey => $fieldValue) { foreach ($fieldValue as $columnKey => $columnValue) { settype($columnKey, 'string'); settype($columnValue, 'string'); if (in_array($columnKey, ['default', 'type'])) { $mapping[$i][$columnKey] = $columnValue; continue; } $fieldObject = Settings_MappedFields_Field_Model::getInstance($columnValue, $instances[$columnKey], $mapping[$i]['type']); if (!$fieldObject) { continue; } $mapping[$i][$columnKey] = $fieldObject->getId(); } $i++; } continue; } else { $value = (string) $fieldsValue; } $moduleInstance->getRecord()->set($fieldsKey, $value); } $tabid = $moduleInstance->getRecord()->get('tabid'); $reltabid = $moduleInstance->getRecord()->get('reltabid'); if (empty($tabid) || empty($reltabid)) { $message = 'LBL_MODULE_NOT_EXIST'; } elseif (!$moduleInstance->importsAllowed()) { $moduleInstance->setMapping($mapping); $moduleInstance->save(true); $message = 'LBL_IMPORT_OK'; $id = $moduleInstance->getRecordId(); } else { $message = 'LBL_NO_PERMISSION_TO_IMPORT'; } } else { $message = 'LBL_UPLOAD_ERROR'; } } $response = new Vtiger_Response(); $response->setResult(['id' => $id, 'message' => vtranslate($message, $qualifiedModuleName)]); $response->emit(); }
/** * Function to get visibilty permissions of a Field * @param <String> $accessmode * @return <Boolean> */ public function getPermissions($accessmode = 'readonly') { $user = Users_Record_Model::getCurrentUserModel(); $privileges = $user->getPrivileges(); if ($privileges->hasGlobalReadPermission()) { return true; } else { $modulePermission = Vtiger_Cache::get('modulePermission-' . $accessmode, $this->getModuleId()); if (!$modulePermission) { $modulePermissionCalendar = self::preFetchModuleFieldPermission(Vtiger_Functions::getModuleId('Calendar'), $accessmode); $modulePermissionEvents = self::preFetchModuleFieldPermission(Vtiger_Functions::getModuleId('Events'), $accessmode); $modulePermission = $modulePermissionCalendar + $modulePermissionEvents; Vtiger_Cache::set('modulePermission-' . $accessmode, $this->getModuleId(), $modulePermission); } if (array_key_exists($this->getId(), $modulePermission)) { return true; } else { return false; } } }
function process(Vtiger_Request $request) { error_reporting(false); $language = $request->get('Language'); $module = $request->get('Module'); require_once 'modules/ITS4YouLabels/resources/MyFunctions.php'; require_once 'languages/' . $language . "/" . $module . ".php"; $filename_module = "languages/" . $language . "/" . $module . ".php"; $filename_vtiger = "languages/" . $language . "/Vtiger.php"; $module_id = Vtiger_Functions::getModuleId($module); $adb = PearDatabase::getInstance(); $query1 = "select * from its4you_labels where tabid= ? and lang= ?"; $result = $adb->pquery($query1, array($module_id, $language)); while ($row = $adb->fetchByAssoc($result)) { $array_from_its4you_labels_table[$row['id']] = $row; } $Post_Data = $request->getAll(); foreach ($Post_Data as $key => $value) { $rest = trim(substr($key, 0, 5)); if ($rest === "field") { $substring = explode("_", $key); $field_id = $substring[1]; $query = "select fieldlabel from vtiger_field where fieldid = ?"; $result = $adb->pquery($query, array($field_id)); while ($row = $adb->fetchByAssoc($result)) { $fieldlabel = $row['fieldlabel']; } $translated_label = vtranslate($fieldlabel, $module, $language); } else { if ($key == "Language" || $key == "Module" || $key == "settings_block" || $key == "settings_fieldid") { break; } } $fieldlabel_from_post = $value; if ($fieldlabel_from_post != $translated_label) { if (!empty($array_from_its4you_labels_table)) { foreach ($array_from_its4you_labels_table as $array_key => $array_value) { $fieldid_from_its4you_labels = $array_from_its4you_labels_table[$array_key]['fieldid']; $sql = "select count(id) from its4you_labels where tabid=? and fieldid=? and lang=?"; $result = $adb->pquery($sql, array($module_id, $field_id, $language)); while ($row = $adb->fetchByAssoc($result)) { $count = $row['count(id)']; } if ($count > 0) { if ($field_id == $fieldid_from_its4you_labels) { $sql = "update its4you_labels set translate_label=? where id=? and lang=?"; $adb->pquery($sql, array($fieldlabel_from_post, $array_key, $language)); unset($array_from_its4you_labels_table[$array_key]); break; } } if ($count < 1) { $is_in_vtiger = ITS4YouLabels_MyFunctions_Resources::its4You_is_in_vtiger_php($language, $fieldlabel, $module); $query = "insert into its4you_labels values (?, ?, ?, ?,?, ?)"; $adb->pquery($query, array(NULL, $module_id, $field_id, $language, $fieldlabel_from_post, $is_in_vtiger)); } } } else { $is_in_vtiger = ITS4YouLabels_MyFunctions_Resources::its4You_is_in_vtiger_php($language, $fieldlabel, $module); $query = "insert into its4you_labels values (?, ?, ?, ?, ?, ?)"; $adb->pquery($query, array(NULL, $module_id, $field_id, $language, $fieldlabel_from_post, $is_in_vtiger)); } } } $filename_module = "languages/" . $language . "/" . $module . ".php"; $filename_vtiger = "languages/" . $language . "/Vtiger.php"; $filename_help = "languages/" . $language . "/my_help.php"; $filename_new_module = "languages/" . $language . "/new_module.php"; $help = fopen($filename_help, "a"); $new_module = fopen($filename_new_module, "a"); ftruncate($help, 0); ftruncate($new_module, 0); $moduleModel = Settings_LayoutEditor_Module_Model::getInstanceByName($module); $Fields = $moduleModel->getFields(); foreach ($Post_Data as $key => $value) { $rest = trim(substr($key, 0, 5)); if ($rest === "field") { $substring = explode("_", $key); $field_id = $substring[1]; foreach ($Fields as $field) { $id = $field->get('id'); if ($field_id == $id) { $fieldlabel = $field->get('label'); } } $translate_label = vtranslate($fieldlabel, $module, $language); $fieldlabel_from_post = $value; if ($translate_label == $fieldlabel_from_post) { } else { $new_array_for_module[trim($fieldlabel)] = trim($fieldlabel_from_post); } } else { if ($key == "Language" || $key == "Module" || $key == "settings_block" || $key == "settings_fieldid") { } } } foreach ($new_array_for_module as $key => $value) { foreach ($languageStrings as $keyword => $translateString) { if (trim($keyword) === trim($key)) { $languageStrings[trim($keyword)] = trim($value); unset($new_array_for_module[$key]); } } } $file = fopen($filename_module, "r"); while (!feof($file)) { $contents = fgets($file); if (strpos($contents, 'languageStrings')) { break; } fwrite($help, $contents); } $Comments = file($filename_help); foreach ($Comments as $comment) { fwrite($new_module, $comment); } fwrite($new_module, '$languageStrings = array(' . PHP_EOL); foreach ($languageStrings as $keyword => $translateString) { $line = '"' . trim($keyword) . '"' . ' => ' . '"' . trim($translateString) . '",' . PHP_EOL; fwrite($new_module, $line); } if (!empty($new_array_for_module)) { foreach ($new_array_for_module as $key => $value) { $line = '"' . trim($key) . '"' . ' => ' . '"' . trim($value) . '",' . PHP_EOL; fwrite($new_module, $line); } } fwrite($new_module, ");"); fwrite($new_module, PHP_EOL . PHP_EOL . '$jsLanguageStrings = array(' . PHP_EOL); foreach ($jsLanguageStrings as $key => $value) { $string = '"' . $key . '"' . ' => ' . '"' . $value . '",' . PHP_EOL; fwrite($new_module, $string); } fwrite($new_module, ");"); unlink($filename_module); rename($filename_new_module, $filename_module); $result = array('success' => true, 'message' => 'Data has been successfully saved. If you refresh the page you will see changes.'); $response = new Vtiger_Response(); $response->setResult($result); $response->emit(); }
/** * 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'; $adb = PearDatabase::getInstance(); if ($eventType == 'module.postinstall') { include_once 'vtlib/Vtiger/Module.php'; $myCustomEntity = CRMEntity::getInstance($moduleName); $myCustomEntity->setModuleSeqNumber("configure", $moduleName, '', '1'); $adb->query("UPDATE vtiger_tab SET customized=0 WHERE name='{$moduleName}'"); $modcommentsModuleInstance = Vtiger_Module::getInstance('ModTracker'); if ($modcommentsModuleInstance && file_exists('modules/ModTracker/ModTracker.php')) { include_once 'vtlib/Vtiger/Module.php'; include_once 'modules/ModTracker/ModTracker.php'; $tabid = Vtiger_Functions::getModuleId($moduleName); $moduleModTrackerInstance = new ModTracker(); if (!$moduleModTrackerInstance->isModulePresent($tabid)) { $res = $adb->pquery("INSERT INTO vtiger_modtracker_tabs VALUES(?,?)", array($tabid, 1)); $moduleModTrackerInstance->updateCache($tabid, 1); } else { $updatevisibility = $adb->pquery("UPDATE vtiger_modtracker_tabs SET visible = 1 WHERE tabid = ?", array($tabid)); $moduleModTrackerInstance->updateCache($tabid, 1); } } } else { if ($eventType == 'module.readonly="readonly"') { // TODO Handle actions when this module is readonly="readonly". } else { if ($eventType == 'module.enabled') { // TODO Handle actions when this module is enabled. } 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') { } } } } } } }
function turn_off($moduleName) { global $adb; $adb->pquery("UPDATE vtiger_relatedlists SET related_tabid = ?,name = ?,actions = 'add',label = 'Emails' WHERE related_tabid = ? ", array(Vtiger_Functions::getModuleId('Emails'), 'get_emails', Vtiger_Functions::getModuleId('OSSMailView'))); $user_id = Users_Record_Model::getCurrentUserModel()->get('user_name'); $adb->pquery("INSERT INTO vtiger_ossmails_logs (`action`, `info`, `user`) VALUES (?, ?, ?);", array('Action_DisabledModule', $moduleName, $user_id), false); }
/** * 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, '', '1'); $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')); } vimport('~~vtlib/Vtiger/Module.php'); $moduleInstance = Vtiger_Module::getInstance('Invoice'); $blockInstance = Vtiger_Block::getInstance('LBL_INVOICE_INFORMATION', $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'payment_balance'; $fieldInstance->table = 'vtiger_invoice'; $fieldInstance->label = 'Payment balance'; $fieldInstance->column = 'payment_balance'; $fieldInstance->columntype = 'decimal(25,8)'; $fieldInstance->uitype = 7; $fieldInstance->typeofdata = 'NN~O'; $fieldInstance->displaytype = 2; $blockInstance->addField($fieldInstance); $moduleInstance = Vtiger_Module::getInstance('Accounts'); $blockInstance = Vtiger_Block::getInstance('LBL_ACCOUNT_INFORMATION', $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'payment_balance'; $fieldInstance->table = 'vtiger_account'; $fieldInstance->label = 'Payment balance'; $fieldInstance->column = 'payment_balance'; $fieldInstance->columntype = 'decimal(25,8)'; $fieldInstance->uitype = 7; $fieldInstance->typeofdata = 'NN~O'; $fieldInstance->displaytype = 2; $blockInstance->addField($fieldInstance); $moduleInstance = Vtiger_Module::getInstance('Potentials'); $blockInstance = Vtiger_Block::getInstance('LBL_OPPORTUNITY_INFORMATION', $moduleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'payment_balance'; $fieldInstance->table = 'vtiger_potential'; $fieldInstance->label = 'Payment balance'; $fieldInstance->column = 'payment_balance'; $fieldInstance->columntype = 'decimal(25,8)'; $fieldInstance->uitype = 7; $fieldInstance->typeofdata = 'NN~O'; $fieldInstance->displaytype = 2; $blockInstance->addField($fieldInstance); $this->addWorkflow($modulename); $this->addWorkflow('Invoice'); } 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 getTabid($module) { return Vtiger_Functions::getModuleId($module); }
/** * Funkcja link do tablicy vtiger_links * * @param string $type typ linku * @param string $moduleName nazwa modułu * @param string $widgetName nazwa widgetu * @param string $link link */ private static function addLink($type, $moduleName, $widgetName, $link) { vglobal('Vtiger_Utils_Log', TRUE); $tabId = Vtiger_Functions::getModuleId($moduleName); if ($tabId) { Vtiger_Link::addLink($tabId, $type, $widgetName, $link); } else { Vtiger_Utils::Log('tabid module not found - check if module name is correct'); } }
public function process($ModuleName, $ID, $record_form, $config) { $db = PearDatabase::getInstance(); $ModuleNameID = Vtiger_Functions::getModuleId($ModuleName); $fieldlabel = $sql_ext = ''; $save_record1 = true; $save_record2 = true; $save_record = true; $type = 0; $typeInfo = 'info'; $info = false; if ($ID != 0 && $ID != '' && !array_key_exists($config['what1'], $record_form)) { $Record_Model = Vtiger_Record_Model::getInstanceById($ID, $ModuleName); $value1 = $Record_Model->get($config['what1']); } else { if (array_key_exists($config['what1'], $record_form)) { $value1 = $record_form[$config['what1']]; } } if ($ID != 0 && $ID != '' && !array_key_exists($config['what2'], $record_form)) { $Record_Model = Vtiger_Record_Model::getInstanceById($ID, $ModuleName); $value2 = $Record_Model->get($config['what2']); } else { if (array_key_exists($config['what2'], $record_form)) { $value2 = $record_form[$config['what2']]; } } if (!is_array($config['where1'])) { $wheres1[] = $config['where1']; } else { $wheres1 = $config['where1']; } if (!is_array($config['where2'])) { $wheres2[] = $config['where2']; } else { $wheres2 = $config['where2']; } if ($value1 != '') { foreach ($wheres1 as $where) { $where = explode('=', $where); $DestModuleName = Vtiger_Functions::getModuleName($where[2]); $ModuleInstance = CRMEntity::getInstance($DestModuleName); $tab_name_index = $ModuleInstance->tab_name_index; $index = $tab_name_index[$where[0]]; $sql_param = array($value1); $sql_ext = ''; $spacialCondition = ''; $sqlSpecial = ''; if ($ModuleNameID == $where[2] && $ID != 0 && $ID != '') { $sql_param[] = $ID; $sql_ext = 'AND ' . $index . ' <> ?'; } if ($DestModuleName == 'Leads') { $spacialCondition = ' AND `converted` = 0'; if ('vtiger_crmentity' == $where[0]) { $sqlSpecial = 'INNER JOIN vtiger_leaddetails ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid '; } } $result = $db->pquery("SELECT {$index} FROM {$where[0]} {$sqlSpecial} WHERE {$where[1]} = ? {$sql_ext} {$spacialCondition};", $sql_param, true); $num = $db->num_rows($result); for ($i = 0; $i < $num; $i++) { $id = $db->query_result_raw($result, $i, $index); $metadata = Vtiger_Functions::getCRMRecordMetadata($id); if ($metadata['setype'] == $DestModuleName) { $save_record1 = false; $deletedLabel = $metadata['deleted'] ? ' - ' . vtranslate('LBL_RECORD_DELETED', 'DataAccess') : ''; $fieldlabel .= '<a target="_blank" href="index.php?module=' . $DestModuleName . '&view=Detail&record=' . $id . '">• ' . Vtiger_Functions::getCRMRecordLabel($id) . '</a> (' . Vtiger_Functions::getOwnerRecordLabel($metadata['smownerid']) . ')' . $deletedLabel . ',<br/>'; } } } } if ($value2 != '') { foreach ($wheres2 as $where) { $where = explode('=', $where); $DestModuleName = Vtiger_Functions::getModuleName($where[2]); $ModuleInstance = CRMEntity::getInstance($DestModuleName); $tab_name_index = $ModuleInstance->tab_name_index; $index = $tab_name_index[$where[0]]; $sql_param = array($value2); $sql_ext = ''; $spacialCondition = ''; $sqlSpecial = ''; if ($ModuleNameID == $where[2] && $ID != 0 && $ID != '') { $sql_param[] = $ID; $sql_ext = 'AND ' . $index . ' <> ?'; } if ($DestModuleName == 'Leads') { $spacialCondition = ' AND `converted` = 0'; if ('vtiger_crmentity' == $where[0]) { $sqlSpecial = 'INNER JOIN vtiger_leaddetails ON vtiger_crmentity.crmid = vtiger_leaddetails.leadid '; } } $result = $db->pquery("SELECT {$index} FROM {$where[0]} WHERE {$where[1]} = ? {$sql_ext};", $sql_param, true); $num = $db->num_rows($result); for ($i = 0; $i < $num; $i++) { $id = $db->query_result_raw($result, $i, $index); $metadata = Vtiger_Functions::getCRMRecordMetadata($id); if ($metadata['setype'] == $DestModuleName) { $save_record2 = false; $deletedLabel = $metadata['deleted'] ? ' - ' . vtranslate('LBL_RECORD_DELETED', 'DataAccess') : ''; $fieldlabel .= '<a target="_blank" href="index.php?module=' . $DestModuleName . '&view=Detail&record=' . $id . '">• ' . Vtiger_Functions::getCRMRecordLabel($id) . '</a> (' . Vtiger_Functions::getOwnerRecordLabel($metadata['smownerid']) . ')' . $deletedLabel . ',<br/>'; } } } } if ($config['locksave'] == 0) { $info = $config['info0']; $type = 2; $save_record = !$save_record1 || !$save_record2 ? false : true; } elseif (!$save_record1 && !$save_record2) { $typeInfo = 'error'; $save_record = false; $info = $config['info2']; } elseif (!$save_record1 || !$save_record2) { $typeInfo = 'error'; $save_record = false; $info = $config['info1']; } if (!$save_record || $info) { return array('save_record' => $save_record, 'type' => $type, 'info' => ['text' => vtranslate($info, 'DataAccess') . ' <br/ >' . trim($fieldlabel, ','), 'ntype' => $typeInfo, 'hide' => false]); } else { return array('save_record' => true); } }
public function addWidget($data, $moduleName, $addToUser = false) { $log = vglobal('log'); $log->debug("Entering Settings_WidgetsManagement_Module_Model::addWidget(" . $data . ", " . $moduleName . ") method ..."); $adb = PearDatabase::getInstance(); $status = false; $widgetWithLimit = self::getWidgetsWithLimit(); if (in_array($data['name'], $widgetWithLimit)) $status = true; if ($status && !$data['limit']) $data['limit'] = 10; $query = 'INSERT INTO vtiger_module_dashboard(`linkid`, `blockid`, `filterid`, `title`, `data`, `size`, `limit`, `owners`,`isdefault`) VALUES(?,?,?,?,?,?,?,?,?);'; if ($data['isdefault'] != 1 || $data['isdefault'] != '1') $data['isdefault'] = 0; $size = Zend_Json::encode(array('width' => $data['width'], 'height' => $data['height'])); $owners = Zend_Json::encode(array('default' => $data['default_owner'], 'available' => $data['owners_all'])); $params = array($data['linkid'], $data['blockid'], $data['filterid'], $data['title'], $data['data'], $size, $data['limit'], $owners, $data['isdefault']); $adb->pquery($query, $params); $templateId = $adb->getLastInsertID(); if ($addToUser) { $currentUser = Users_Record_Model::getCurrentUserModel(); $module = Vtiger_Functions::getModuleId($moduleName); $active = 0; if ($data['isdefault']) $active = 1; $insert = [ 'linkid' => $data['linkid'], 'userid' => $currentUser->getId(), 'templateid' => $templateId, 'filterid' => $data['filterid'], 'title' => $data['title'], 'data' => $data['data'], 'size' => $size, 'limit' => $data['limit'], 'owners' => $owners, 'isdefault' => $data['isdefault'], 'active' => $active, 'module' => $module ]; $adb->insert('vtiger_module_dashboard_widgets', $insert); $widgetId = $adb->getLastInsertID(); } $text = vtranslate('LBL_WIDGET_ADDED', 'Settings::WidgetsManagement'); $log->debug("Exiting Settings_WidgetsManagement_Module_Model::addWidget() method ..."); return array('success' => true, 'id' => $templateId, 'wid' => $widgetId, 'status' => $status, 'text' => $text); }
public function getDisplayValueByField($tree, $field, $module) { $adb = PearDatabase::getInstance(); $result = $adb->pquery('SELECT fieldparams FROM vtiger_field WHERE tabid = ? AND fieldname = ?', array(Vtiger_Functions::getModuleId($module), $field)); if ($adb->num_rows($result) == 0) { return false; } $template = $adb->query_result_raw($result, 0, 'fieldparams'); $result = $adb->pquery('SELECT * FROM vtiger_trees_templates_data WHERE templateid = ? AND tree = ?', array($template, $tree)); if ($adb->num_rows($result)) { return vtranslate($adb->query_result_raw($result, 0, 'name'), $module); } return false; }
private function getTemplate() { $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT fieldparams FROM vtiger_field WHERE uitype = ? AND tabid = ?', [302, Vtiger_Functions::getModuleId($this->moduleName)]); return $db->getSingleValue($result); }
public static function findEmail($emails, $searchModule = false, $returnArray = true) { $adb = PearDatabase::getInstance(); if ($returnArray) { $return = []; } else { $return = ''; } $EmailSearchList = self::getEmailSearchList(); if (strpos($emails, ',')) { $emailsArray = explode(',', $emails); } else { $emailsArray[0] = $emails; } if ($EmailSearchList != null && $emails != '' && !empty($EmailSearchList['fields'])) { if (strpos($EmailSearchList['fields'], ',')) { $fields = explode(',', $EmailSearchList['fields']); } else { $fields[0] = $EmailSearchList['fields']; } foreach ($fields as $field) { $enableFind = true; $row = explode('=', $field); if ($searchModule) { $moduleId = Vtiger_Functions::getModuleId($searchModule); if ($moduleId != $row[2]) { $enableFind = false; } } if ($enableFind) { $module = Vtiger_Functions::getModuleName($row[2]); require_once "modules/{$module}/{$module}.php"; $ModuleObject = new $module(); $table_index = $ModuleObject->table_index; foreach ($emailsArray as $email) { $result = $adb->pquery("SELECT {$table_index} FROM " . $row[0] . ' INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = ' . $row[0] . ".{$table_index} WHERE vtiger_crmentity.deleted = 0 AND " . $row[1] . ' = ? ', [$email]); while ($crmid = $adb->getSingleValue($result)) { if ($returnArray) { $return[] = $crmid; } else { if ($return != '') { $return .= ','; } $return .= $crmid; } } } } } } return $return; }