function VT520GA_webserviceMigrate() { require_once 'include/Webservices/Utils.php'; $customWebserviceDetails = array("name" => "revise", "include" => "include/Webservices/Revise.php", "handler" => "vtws_revise", "prelogin" => 0, "type" => "POST"); $customWebserviceParams = array(array("name" => 'element', "type" => 'Encoded')); echo 'INITIALIZING WEBSERVICE...'; $operationId = vtws_addWebserviceOperation($customWebserviceDetails['name'], $customWebserviceDetails['include'], $customWebserviceDetails['handler'], $customWebserviceDetails['type']); if ($operationId === null && $operationId > 0) { echo 'FAILED TO SETUP ' . $customWebserviceDetails['name'] . ' WEBSERVICE'; die; } $sequence = 1; foreach ($customWebserviceParams as $param) { $status = vtws_addWebserviceOperationParam($operationId, $param['name'], $param['type'], $sequence++); if ($status === false) { echo 'FAILED TO SETUP ' . $customWebserviceDetails['name'] . ' WEBSERVICE HALFWAY THOURGH'; die; } } $moduleList = vtws_getModuleNameList(); foreach ($moduleList as $moduleName) { vtws_addDefaultModuleTypeEntity($moduleName); } ExecuteQuery("delete from vtiger_ws_fieldtype where uitype=116;"); ExecuteQuery("update vtiger_field set uitype=117 where tabid=29 and fieldname='currency_id';"); }
/** * Given the details of a webservices definition, it creates it if it doesn't exist already * @param $operationInfo array with the new web service method definition. Like this: $operationInfo = array( 'name' => 'getRelatedRecords', 'include' => 'include/Webservices/GetRelatedRecords.php', 'handler' => 'getRelatedRecords', 'prelogin'=> 0, 'type' => 'POST', 'parameters' => array( array('name' => 'id','type' => 'String'), array('name' => 'module','type' => 'String'), array('name' => 'relatedModule','type' => 'String'), array('name' => 'queryParameters','type' => 'encoded') ) ); * @return false if already registered, true if registered correctly * @errors Failed to create webservice and Failed to setup parameters */ function registerWSAPI($operationInfo) { global $adb; if (!isset($operationInfo['prelogin'])) { $operationInfo['prelogin'] = 0; } $check = $adb->pquery('SELECT 1 FROM vtiger_ws_operation WHERE name=?', array($operationInfo['name'])); if ($check && $adb->num_rows($check)) { return false; // it exists > we leave } $operationId = vtws_addWebserviceOperation($operationInfo['name'], $operationInfo['include'], $operationInfo['handler'], $operationInfo['type'], $operationInfo['prelogin']); if (empty($operationId)) { throw new Exception('FAILED TO SETUP ' . $operationInfo['name'] . ' WEBSERVICE'); } $sequence = 1; foreach ($operationInfo['parameters'] as $parameters) { $status = vtws_addWebserviceOperationParam($operationId, $parameters['name'], $parameters['type'], $sequence++); if ($status === false) { throw new Exception('FAILED TO SETUP ' . $parameters['name'] . ' WEBSERVICE HALFWAY THOURGH'); } } return true; }
function vtws_addOperationInfo() { $operationMeta = array("login" => array("include" => array("include/Webservices/Login.php"), "handler" => "vtws_login", "params" => array("username" => "String", "accessKey" => "String"), "prelogin" => 1, "type" => "POST"), "retrieve" => array("include" => array("include/Webservices/Retrieve.php"), "handler" => "vtws_retrieve", "params" => array("id" => "String"), "prelogin" => 0, "type" => "GET"), "create" => array("include" => array("include/Webservices/Create.php"), "handler" => "vtws_create", "params" => array("elementType" => "String", "element" => "encoded"), "prelogin" => 0, "type" => "POST"), "update" => array("include" => array("include/Webservices/Update.php"), "handler" => "vtws_update", "params" => array("element" => "encoded"), "prelogin" => 0, "type" => "POST"), "delete" => array("include" => array("include/Webservices/Delete.php"), "handler" => "vtws_delete", "params" => array("id" => "String"), "prelogin" => 0, "type" => "POST"), "sync" => array("include" => array("include/Webservices/GetUpdates.php"), "handler" => "vtws_sync", "params" => array("modifiedTime" => "DateTime", "elementType" => "String"), "prelogin" => 0, "type" => "GET"), "query" => array("include" => array("include/Webservices/Query.php"), "handler" => "vtws_query", "params" => array("query" => "String"), "prelogin" => 0, "type" => "GET"), "logout" => array("include" => array("include/Webservices/Logout.php"), "handler" => "vtws_logout", "params" => array("sessionName" => "String"), "prelogin" => 0, "type" => "POST"), "listtypes" => array("include" => array("include/Webservices/ModuleTypes.php"), "handler" => "vtws_listtypes", "params" => array("fieldTypeList" => "encoded"), "prelogin" => 0, "type" => "GET"), "getchallenge" => array("include" => array("include/Webservices/AuthToken.php"), "handler" => "vtws_getchallenge", "params" => array("username" => "String"), "prelogin" => 1, "type" => "GET"), "describe" => array("include" => array("include/Webservices/DescribeObject.php"), "handler" => "vtws_describe", "params" => array("elementType" => "String"), "prelogin" => 0, "type" => "GET"), "extendsession" => array("include" => array("include/Webservices/ExtendSession.php"), "handler" => "vtws_extendSession", 'params' => array(), "prelogin" => 1, "type" => "POST"), 'convertlead' => array("include" => array("include/Webservices/ConvertLead.php"), "handler" => "vtws_convertlead", "prelogin" => 0, "type" => "POST", 'params' => array('leadId' => 'String', 'assignedTo' => 'String', 'accountName' => 'String', 'avoidPotential' => 'Boolean', 'potential' => 'Encoded')), "revise" => array("include" => array("include/Webservices/Revise.php"), "handler" => "vtws_revise", "params" => array("element" => "Encoded"), "prelogin" => 0, "type" => "POST"), "changePassword" => array("include" => array("include/Webservices/ChangePassword.php"), "handler" => "vtws_changePassword", "params" => array("id" => "String", "oldPassword" => "String", "newPassword" => "String", 'confirmPassword' => 'String'), "prelogin" => 0, "type" => "POST"), "deleteUser" => array("include" => array("include/Webservices/DeleteUser.php"), "handler" => "vtws_deleteUser", "params" => array("id" => "String", "newOwnerId" => "String"), "prelogin" => 0, "type" => "POST")); foreach ($operationMeta as $operationName => $operationDetails) { $operationId = vtws_addWebserviceOperation($operationName, $operationDetails['include'], $operationDetails['handler'], $operationDetails['type'], $operationDetails['prelogin']); $params = $operationDetails['params']; $sequence = 1; foreach ($params as $paramName => $paramType) { vtws_addWebserviceOperationParam($operationId, $paramName, $paramType, $sequence++); } } }
function VT520_webserviceMigrate() { require_once 'include/Webservices/Utils.php'; $customWebserviceDetails = array("name" => "convertlead", "include" => "include/Webservices/ConvertLead.php", "handler" => "vtws_convertlead", "prelogin" => 0, "type" => "POST"); $customWebserviceParams = array(array("name" => 'leadId', "type" => 'String'), array("name" => 'assignedTo', 'type' => 'String'), array("name" => 'accountName', 'type' => 'String'), array("name" => 'avoidPotential', 'type' => 'Boolean'), array("name" => 'potential', 'type' => 'Encoded')); echo 'INITIALIZING WEBSERVICE...'; $operationId = vtws_addWebserviceOperation($customWebserviceDetails['name'], $customWebserviceDetails['include'], $customWebserviceDetails['handler'], $customWebserviceDetails['type']); if ($operationId === null && $operationId > 0) { echo 'FAILED TO SETUP ' . $customWebserviceDetails['name'] . ' WEBSERVICE'; die; } $sequence = 1; foreach ($customWebserviceParams as $param) { $status = vtws_addWebserviceOperationParam($operationId, $param['name'], $param['type'], $sequence++); if ($status === false) { echo 'FAILED TO SETUP ' . $customWebserviceDetails['name'] . ' WEBSERVICE HALFWAY THOURGH'; die; } } }
$cur_id = $adb->query_result($cur_result, $i, "id"); $currency_exists = $adb->pquery("SELECT * from vtiger_currencies WHERE currency_code=?", array($cur_code)); if ($adb->num_rows($currency_exists) > 0) { $currency_name = $adb->query_result($currency_exists, 0, "currency_name"); ExecuteQuery("UPDATE vtiger_currency_info SET vtiger_currency_info.currency_name='{$currency_name}' WHERE id={$cur_id}"); } else { $currencyId = $adb->getUniqueID("vtiger_currencies"); ExecuteQuery("INSERT INTO vtiger_currencies VALUES ({$currencyId}, '{$cur_name}', '{$cur_code}', '{$cur_symbol}')"); } } } vt530_updateCurrencyInfo(); // Change Password & Delete User Webservice apis $operationMeta = array("changePassword" => array("include" => array("include/Webservices/ChangePassword.php"), "handler" => "vtws_changePassword", "params" => array("id" => "String", "oldPassword" => "String", "newPassword" => "String", 'confirmPassword' => 'String'), "prelogin" => 0, "type" => "POST"), "deleteUser" => array("include" => array("include/Webservices/DeleteUser.php"), "handler" => "vtws_deleteUser", "params" => array("id" => "String", "newOwnerId" => "String"), "prelogin" => 0, "type" => "POST")); foreach ($operationMeta as $operationName => $operationDetails) { $operationId = vtws_addWebserviceOperation($operationName, $operationDetails['include'], $operationDetails['handler'], $operationDetails['type'], $operationDetails['prelogin']); $params = $operationDetails['params']; $sequence = 1; foreach ($params as $paramName => $paramType) { vtws_addWebserviceOperationParam($operationId, $paramName, $paramType, $sequence++); } } $usersModuleInstance = Vtiger_Module::getInstance('Users'); $blockInstance = Vtiger_Block::getInstance('LBL_MORE_INFORMATION', $usersModuleInstance); $fieldInstance = new Vtiger_Field(); $fieldInstance->name = 'theme'; $fieldInstance->label = 'Theme'; $fieldInstance->table = 'vtiger_users'; $fieldInstance->column = 'theme'; $fieldInstance->columntype = 'VARCHAR(100)'; $fieldInstance->uitype = 31;
function register() { $adb = PearDatabase::getInstance(); $checkresult = $adb->pquery("SELECT 1 FROM vtiger_ws_operation WHERE name = ?", array($this->opName)); if ($adb->num_rows($checkresult)) { return; } Vtiger_Utils::Log("Enabling webservice operation {$this->opName}", true); $operationid = vtws_addWebserviceOperation($this->opName, $this->opFile, $this->opClass, $this->opType); for ($index = 0; $index < count($this->parameters); ++$index) { vtws_addWebserviceOperationParam($operationid, $this->parameters[$index]['name'], $this->parameters[$index]['type'], $index + 1); } }
$customer->setRelatedModules(array('Contacts')); } $moduleInstance = Vtiger_Module::getInstance('Potentials'); $filter = Vtiger_Filter::getInstance('All', $moduleInstance); $fieldInstance = Vtiger_Field::getInstance('amount', $moduleInstance); $filter->addField($fieldInstance, 6); if (file_exists('modules/ModTracker/ModTrackerUtils.php')) { require_once 'modules/ModTracker/ModTrackerUtils.php'; $modules = $adb->pquery('SELECT * FROM vtiger_tab WHERE isentitytype = 1', array()); $rows = $adb->num_rows($modules); for ($i = 0; $i < $rows; $i++) { $tabid = $adb->query_result($modules, $i, 'tabid'); ModTrackerUtils::modTrac_changeModuleVisibility($tabid, 'module_enable'); } } $operationId = vtws_addWebserviceOperation('retrieve_inventory', 'include/Webservices/LineItem/RetrieveInventory.php', 'vtws_retrieve_inventory', 'GET'); vtws_addWebserviceOperationParam($operationId, 'id', 'String', 1); $moduleInstance = Vtiger_Module::getInstance('Events'); $tabId = getTabid('Events'); // Update/Increment the sequence for the succeeding blocks of Events module, with starting sequence 3 Migration_Index_View::ExecuteQuery('UPDATE vtiger_blocks SET sequence = sequence+1 WHERE tabid=? AND sequence >= 3', array($tabId)); // Create Recurrence Information block $recurrenceBlock = new Vtiger_Block(); $recurrenceBlock->label = 'LBL_RECURRENCE_INFORMATION'; $recurrenceBlock->sequence = 3; $moduleInstance->addBlock($recurrenceBlock); $blockId = getBlockId($tabId, 'LBL_RECURRENCE_INFORMATION'); Migration_Index_View::ExecuteQuery('UPDATE vtiger_field SET block=? WHERE fieldname=? and tabid=?', array($blockId, 'recurringtype', $tabId)); // Update/Increment the sequence for the succeeding blocks of Users module, with starting sequence 2 $moduleInstance = Vtiger_Module::getInstance('Users'); $tabId = getTabid('Users');
<?php /*+********************************************************************************** * The contents of this file are subject to the vtiger CRM Public License Version 1.0 * ("License"); You may not use this file except in compliance with the License * The Original Code is: vtiger CRM Open Source * The Initial Developer of the Original Code is vtiger. * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. ************************************************************************************/ /*********************************************************** danzi.tn@20150427 template per la creazione di un modulo da utilizzare dopo aver creato il modulo con la console **/ chdir(dirname(__FILE__) . '/../..'); include_once 'vtlib/Vtiger/Module.php'; include_once 'vtlib/Vtiger/Package.php'; include_once 'includes/main/WebUI.php'; include_once 'include/Webservices/Utils.php'; $Vtiger_Utils_Log = true; $SINGLE_MODULENAME = 'Rumor'; $MODULENAME = $SINGLE_MODULENAME . 's'; $operationId = vtws_addWebserviceOperation('process_email', 'include/Webservices/danzi.tn/ProcessEmail.php', 'vtws_process_email', 'POST'); vtws_addWebserviceOperationParam($operationId, 'email', 'String', 1); vtws_addWebserviceOperationParam($operationId, 'element', 'encoded', 2);