function handleEvent($eventName, $entityData)
 {
     global $current_user;
     $db = PearDatabase::getInstance();
     $moduleName = $entityData->getModuleName();
     //Specific to VAS
     if ($moduleName == 'Users') {
         return;
     }
     //END
     $recordId = $entityData->getId();
     $vtEntityDelta = new VTEntityDelta();
     $newEntityData = $vtEntityDelta->getNewEntity($moduleName, $recordId);
     $recordValues = $newEntityData->getData();
     $isAssignToModified = $this->isAssignToChanged($moduleName, $recordId, $current_user);
     if (!$isAssignToModified) {
         return;
     }
     $wsModuleName = $this->getWsModuleName($moduleName);
     if ($wsModuleName == "Calendar") {
         $wsModuleName = vtws_getCalendarEntityType($recordId);
     }
     $handler = vtws_getModuleHandlerFromName($wsModuleName, $current_user);
     $meta = $handler->getMeta();
     $recordWsValues = DataTransform::sanitizeData($recordValues, $meta);
     $syncServer = new SyncServer();
     $syncServer->markRecordAsDeleteForAllCleints($recordWsValues);
 }
Exemplo n.º 2
0
function getRelatedRecords($id, $module, $relatedModule, $queryParameters, $user)
{
    global $adb, $currentModule, $log, $current_user;
    // TODO To be integrated with PearDatabase
    $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    // END
    // pickup meta data of related module
    $webserviceObject = VtigerWebserviceObject::fromName($adb, $relatedModule);
    $handlerPath = $webserviceObject->getHandlerPath();
    $handlerClass = $webserviceObject->getHandlerClass();
    if ($relatedModule == 'Products' and $module != 'Products') {
        $srvwebserviceObject = VtigerWebserviceObject::fromName($adb, 'Services');
        $srvhandlerPath = $srvwebserviceObject->getHandlerPath();
        $srvhandlerClass = $srvwebserviceObject->getHandlerClass();
        require_once $srvhandlerPath;
        $srvhandler = new $srvhandlerClass($srvwebserviceObject, $user, $adb, $log);
        $srvmeta = $srvhandler->getMeta();
    }
    require_once $handlerPath;
    $handler = new $handlerClass($webserviceObject, $user, $adb, $log);
    $meta = $handler->getMeta();
    $query = __getRLQuery($id, $module, $relatedModule, $queryParameters, $user);
    $result = $adb->pquery($query, array());
    $records = array();
    // Return results
    while ($row = $adb->fetch_array($result)) {
        if (($module == 'HelpDesk' or $module == 'Faq') and $relatedModule == 'ModComments') {
            $records[] = $row;
        } else {
            if (isset($row['id']) and getSalesEntityType($row['id']) == 'Services') {
                $records[] = DataTransform::sanitizeData($row, $srvmeta);
            } else {
                $records[] = DataTransform::sanitizeData($row, $meta);
            }
        }
    }
    return array('records' => $records);
}
 public function createEntityRecord($moduleName, $entityLabel)
 {
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleFields = $moduleMeta->getModuleFields();
     $mandatoryFields = $moduleMeta->getMandatoryFields();
     $entityNameFieldsString = $moduleMeta->getNameFields();
     $entityNameFields = explode(',', $entityNameFieldsString);
     $fieldData = array();
     foreach ($entityNameFields as $entityNameField) {
         $entityNameField = trim($entityNameField);
         if (in_array($entityNameField, $mandatoryFields)) {
             $fieldData[$entityNameField] = $entityLabel;
         }
     }
     foreach ($mandatoryFields as $mandatoryField) {
         if (empty($fieldData[$mandatoryField])) {
             $fieldInstance = $moduleFields[$mandatoryField];
             if ($fieldInstance->getFieldDataType() == 'owner') {
                 $fieldData[$mandatoryField] = $this->user->id;
             } else {
                 $defaultValue = $fieldInstance->getDefault();
                 if (!empty($defaultValue)) {
                     $fieldData[$mandatoryField] = $defaultValue;
                 } else {
                     $fieldData[$mandatoryField] = '????';
                 }
             }
         }
     }
     $fieldData = DataTransform::sanitizeData($fieldData, $moduleMeta);
     $entityIdInfo = vtws_create($moduleName, $fieldData, $this->user);
     $focus = CRMEntity::getInstance($moduleName);
     $focus->updateMissingSeqNumber($moduleName);
     return $entityIdInfo;
 }
Exemplo n.º 4
0
 public function createEntityRecord($moduleName, $entityLabel)
 {
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleFields = $moduleMeta->getModuleFields();
     $mandatoryFields = $moduleMeta->getMandatoryFields();
     $entityNameFieldsString = $moduleMeta->getNameFields();
     $entityNameFields = explode(',', $entityNameFieldsString);
     $fieldData = array();
     foreach ($entityNameFields as $entityNameField) {
         $entityNameField = trim($entityNameField);
         if (in_array($entityNameField, $mandatoryFields)) {
             $fieldData[$entityNameField] = $entityLabel;
         }
     }
     foreach ($mandatoryFields as $mandatoryField) {
         if (empty($fieldData[$mandatoryField])) {
             $fieldInstance = $moduleFields[$mandatoryField];
             if ($fieldInstance->getFieldDataType() == 'owner') {
                 $fieldData[$mandatoryField] = $this->user->id;
             } else {
                 if (!in_array($mandatoryField, $entityNameFields) && $fieldInstance->getFieldDataType() != 'reference') {
                     $fieldData[$mandatoryField] = '????';
                 }
             }
         }
     }
     $fieldData = DataTransform::sanitizeData($fieldData, $moduleMeta);
     $entityIdInfo = vtws_create($moduleName, $fieldData, $this->user);
     $adb = PearDatabase::getInstance();
     $entityIdComponents = vtws_getIdComponents($entityIdInfo['id']);
     $recordId = $entityIdComponents[1];
     $entityfields = getEntityFieldNames($moduleName);
     switch ($moduleName) {
         case 'HelpDesk':
             $entityfields['fieldname'] = array('ticket_title');
             break;
         case 'Documents':
             $entityfields['fieldname'] = array('notes_title');
             break;
         case 'Documents':
             $entityfields['fieldname'] = array('notes_title');
             break;
     }
     $label = '';
     if (is_array($entityfields['fieldname'])) {
         foreach ($entityfields['fieldname'] as $field) {
             $label .= $fieldData[$field] . " ";
         }
     } else {
         $label = $fieldData[$entityfields['fieldname']];
     }
     $label = trim($label);
     $adb->pquery('UPDATE vtiger_crmentity SET label=? WHERE crmid=?', array($label, $recordId));
     $recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
     $focus = $recordModel->getEntity();
     $focus->id = $recordId;
     $focus->column_fields = $fieldData;
     $this->entityData[] = VTEntityData::fromCRMEntity($focus);
     $focus->updateMissingSeqNumber($moduleName);
     return $entityIdInfo;
 }
Exemplo n.º 5
0
 function filterAndSanitize($row, $meta)
 {
     $row = DataTransform::filterAllColumns($row, $meta);
     $row = DataTransform::sanitizeData($row, $meta);
     return $row;
 }