本文整理汇总了PHP中Vtiger_Field_Model类的典型用法代码示例。如果您正苦于以下问题:PHP Vtiger_Field_Model类的具体用法?PHP Vtiger_Field_Model怎么用?PHP Vtiger_Field_Model使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vtiger_Field_Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleEvent
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]);
}
}
}
}
示例2: getInstanceFromField
/**
* Static function to get the UIType object from Vtiger Field Model
* @param Vtiger_Field_Model $fieldModel
* @return Vtiger_Base_UIType or UIType specific object instance
*/
public static function getInstanceFromField($fieldModel)
{
$fieldDataType = $fieldModel->getFieldDataType();
$uiTypeClassSuffix = ucfirst($fieldDataType);
$moduleName = $fieldModel->getModuleName();
$moduleSpecificUiTypeClassName = $moduleName . '_' . $uiTypeClassSuffix . '_UIType';
$uiTypeClassName = 'Vtiger_' . $uiTypeClassSuffix . '_UIType';
$fallBackClassName = 'Vtiger_Base_UIType';
$moduleSpecificFileName = 'modules.' . $moduleName . '.uitypes.' . $uiTypeClassSuffix;
$uiTypeClassFileName = 'modules.Vtiger.uitypes.' . $uiTypeClassSuffix;
$moduleSpecificFilePath = Vtiger_Loader::resolveNameToPath($moduleSpecificFileName);
$completeFilePath = Vtiger_Loader::resolveNameToPath($uiTypeClassFileName);
if (file_exists($moduleSpecificFilePath)) {
$instance = new $moduleSpecificUiTypeClassName();
} else if (file_exists($completeFilePath)) {
$instance = new $uiTypeClassName();
} else {
$instance = new $fallBackClassName();
}
$instance->set('field', $fieldModel);
return $instance;
}
示例3: getHeaders
public function getHeaders()
{
$headerFields = parent::getHeaders();
//Added to support List Price
$field = new Vtiger_Field_Model();
$field->set('name', 'listprice');
$field->set('column', 'listprice');
$field->set('label', 'List Price');
$headerFields['listprice'] = $field;
return $headerFields;
}
示例4: getCommentFieldsListForTasks
/**
* Function to get comment fields list which are useful in tasks
* @param <Vtiger_Module_Model> $moduleModel
* @return <Array> list of Field models <Vtiger_Field_Model>
*/
public static function getCommentFieldsListForTasks($moduleModel)
{
$commentsFieldsInfo = array('lastComment' => 'Last Comment', 'last5Comments' => 'Last 5 Comments', 'allComments' => 'All Comments');
$commentFieldModelsList = array();
foreach ($commentsFieldsInfo as $fieldName => $fieldLabel) {
$commentField = new Vtiger_Field_Model();
$commentField->setModule($moduleModel);
$commentField->set('name', $fieldName);
$commentField->set('label', $fieldLabel);
$commentFieldModelsList[$fieldName] = $commentField;
}
return $commentFieldModelsList;
}
示例5: process
public function process(Vtiger_Request $request)
{
$moduleName = $request->getModule();
$recordId = $request->get('record');
$recordModel = $this->record;
if (!$recordModel) {
if (!empty($recordId)) {
$recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
} else {
$recordModel = Vtiger_Record_Model::getCleanInstance($moduleName);
}
$this->record = $recordModel;
}
$viewer = $this->getViewer($request);
$viewer->assign('IMAGE_DETAILS', $recordModel->getImageDetails());
$salutationFieldModel = Vtiger_Field_Model::getInstance('salutationtype', $recordModel->getModule());
// Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7851
$salutationType = $request->get('salutationtype');
if (!empty($salutationType)) {
$salutationFieldModel->set('fieldvalue', $request->get('salutationtype'));
} else {
$salutationFieldModel->set('fieldvalue', $recordModel->get('salutationtype'));
}
$viewer->assign('SALUTATION_FIELD_MODEL', $salutationFieldModel);
parent::process($request);
}
示例6: save
public function save(Vtiger_Request $request)
{
$fieldId = $request->get('fieldid');
$fieldInstance = Vtiger_Field_Model::getInstance($fieldId);
$fields = ['presence', 'quickcreate', 'summaryfield', 'helpinfo', 'generatedtype', 'masseditable', 'displaytype'];
foreach ($request->getAll() as $key => $value) {
if ($key == 'mandatory') {
$fieldInstance->updateTypeofDataFromMandatory($value);
}
if (in_array($key, $fields)) {
$fieldInstance->set($key, $value);
}
}
$defaultValue = $request->get('fieldDefaultValue');
if ($fieldInstance->getFieldDataType() == 'date') {
$dateInstance = new Vtiger_Date_UIType();
$defaultValue = $dateInstance->getDBInsertedValue($defaultValue);
}
if ($request->has('fieldMask')) {
$fieldInstance->set('fieldparams', $request->get('fieldMask'));
}
if (is_array($defaultValue)) {
$defaultValue = implode(' |##| ', $defaultValue);
}
$fieldInstance->set('defaultvalue', $defaultValue);
$response = new Vtiger_Response();
try {
$fieldInstance->save();
$response->setResult(array('success' => true, 'presence' => $request->get('presence'), 'mandatory' => $fieldInstance->isMandatory(), 'label' => vtranslate($fieldInstance->get('label'), $request->get('sourceModule'))));
} catch (Exception $e) {
$response->setError($e->getCode(), $e->getMessage());
}
$response->emit();
}
示例7: process
public function process(Vtiger_Request $request)
{
$qualifiedModuleName = $request->getModule(false);
$moduleName = $request->getModule();
$baseModule = $request->get('base_module');
$idTpl = $request->get('tpl_id');
$viewer = $this->getViewer($request);
if ($idTpl && $baseModule != 'All') {
$docInfo = Settings_DataAccess_Module_Model::getDataAccessInfo($idTpl);
$viewer->assign('BASE_INFO', $docInfo['basic_info']);
for ($i = 0; $i < count($docInfo['required_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['required_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['required_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('REQUIRED_CONDITIONS', $docInfo['required_conditions']);
for ($i = 0; $i < count($docInfo['optional_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['optional_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['optional_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('OPTIONAL_CONDITIONS', $docInfo['optional_conditions']);
$viewer->assign('TPL_ID', $idTpl);
}
$viewer->assign('STEP', 2);
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('REQUEST', $request);
$viewer->assign('SUMMARY', $request->get('summary'));
$viewer->assign('BASE_MODULE', $baseModule);
$viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
$viewer->assign('FIELD_LIST', Settings_DataAccess_Module_Model::getListBaseModuleField($baseModule));
$viewer->assign('CONDITION_BY_TYPE', Settings_DataAccess_Module_Model::getConditionByType());
echo $viewer->view('Step2.tpl', $qualifiedModuleName, true);
}
示例8: process
public function process(Vtiger_Request $request)
{
$moduleSettingsName = $request->getModule(false);
$moduleName = $request->getModule();
$baseModule = $request->get('module_name');
$idTpl = $request->get('tpl_id');
$viewer = $this->getViewer($request);
if ($idTpl) {
$docInfo = Settings_OSSDocumentControl_Module_Model::getDocInfo($idTpl);
$viewer->assign('BASE_INFO', $docInfo['basic_info']);
//var_dump($docInfo['required_conditions']);
for ($i = 0; $i < count($docInfo['required_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['required_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['required_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('REQUIRED_CONDITIONS', $docInfo['required_conditions']);
for ($i = 0; $i < count($docInfo['optional_conditions']); $i++) {
$fieldModel = Vtiger_Field_Model::getInstance($docInfo['optional_conditions'][$i]['fieldname'], Vtiger_Module_Model::getInstance($baseModule));
$docInfo['optional_conditions'][$i]['info'] = $fieldModel->getFieldInfo();
}
$viewer->assign('OPTIONAL_CONDITIONS', $docInfo['optional_conditions']);
$viewer->assign('TPL_ID', $idTpl);
//$fieldModel = Vtiger_Field_Model::getInstance($value->get('name'), $baseModuleModel);
}
$viewer->assign('MODULE_NAME', $moduleName);
$viewer->assign('SUMMARY', $request->get('summary'));
$viewer->assign('BASE_MODULE', $baseModule);
$viewer->assign('QUALIFIED_MODULE', $moduleSettingsName);
$viewer->assign('FIELD_LIST', Settings_OSSDocumentControl_Module_Model::getListBaseModuleField($baseModule));
//$viewer->assign('FOLDER_LIST', Documents_Module_Model::getAllFolders());
$viewer->assign('CONDITION_BY_TYPE', Settings_OSSDocumentControl_Module_Model::getConditionByType());
echo $viewer->view('Edit2.tpl', $moduleSettingsName, true);
}
示例9: process
function process(Vtiger_Request $request)
{
$currentUserPriviligeModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
$viewer = $this->getViewer($request);
$recordId = $request->get('record');
$moduleName = $request->getModule();
$recordModel = Vtiger_Record_Model::getInstanceById($recordId);
$moduleModel = $recordModel->getModule();
$viewer->assign('MODULE', $moduleName);
$viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
$viewer->assign('CURRENT_USER_PRIVILEGE', $currentUserPriviligeModel);
$viewer->assign('RECORD', $recordModel);
$viewer->assign('CONVERT_LEAD_FIELDS', $recordModel->getConvertLeadFields());
$assignedToFieldModel = $moduleModel->getField('assigned_user_id');
$assignedToFieldModel->set('fieldvalue', $recordModel->get('assigned_user_id'));
$viewer->assign('ASSIGN_TO', $assignedToFieldModel);
$potentialModuleModel = Vtiger_Module_Model::getInstance('Potentials');
$accountField = Vtiger_Field_Model::getInstance('related_to', $potentialModuleModel);
$contactField = Vtiger_Field_Model::getInstance('contact_id', $potentialModuleModel);
$viewer->assign('ACCOUNT_FIELD_MODEL', $accountField);
$viewer->assign('CONTACT_FIELD_MODEL', $contactField);
$contactsModuleModel = Vtiger_Module_Model::getInstance('Contacts');
$accountField = Vtiger_Field_Model::getInstance('parent_id', $contactsModuleModel);
$viewer->assign('CONTACT_ACCOUNT_FIELD_MODEL', $accountField);
$state = Settings_Leads_ConvertToAccount_Model::getState();
$viewer->assign('STATE', $state);
$viewer->view('ConvertLead.tpl', $moduleName);
}
示例10: getPopupViewFieldsList
/**
* Funtion that returns fields that will be showed in the record selection popup
* @return <Array of fields>
*/
public function getPopupViewFieldsList($sourceModule = false)
{
if (!empty($sourceModule)) {
$parentRecordModel = Vtiger_Module_Model::getInstance($sourceModule);
$relationModel = Vtiger_Relation_Model::getInstance($parentRecordModel, $this);
}
$popupFields = array();
if ($relationModel) {
$popupFields = $relationModel->getRelationFields(true);
}
if (count($popupFields) == 0) {
$popupFileds = $this->getSummaryViewFieldsList();
foreach ($popupFileds as $fieldName => $fieldModel) {
if ($fieldName === 'folderid' || $fieldName === 'modifiedtime') {
unset($popupFileds[$fieldName]);
}
}
$reqPopUpFields = array('File Status' => 'filestatus', 'File Size' => 'filesize', 'File Location Type' => 'filelocationtype');
foreach ($reqPopUpFields as $fieldLabel => $fieldName) {
$fieldModel = Vtiger_Field_Model::getInstance($fieldName, $this);
if ($fieldModel->getPermissions('readwrite')) {
$popupFileds[$fieldName] = $fieldModel;
}
}
$popupFields = array_keys($popupFileds);
}
return $popupFields;
}
示例11: getListViewEntries
/**
* 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(' . getSqlForNameInDisplayFormat(['first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'], 'Users') . ',vtiger_groups.groupname)';
}
}
if (!empty($orderBy)) {
$listQuery .= ' ORDER BY ' . $orderBy . ' ' . $this->getForSql('sortorder');
}
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);
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;
}
示例12: preProcess
function preProcess(Vtiger_Request $request)
{
parent::preProcess($request);
$viewer = $this->getViewer($request);
$moduleName = $request->getModule();
$recordId = $request->get('record');
$page = $request->get('page');
$detailViewModel = Reports_DetailView_Model::getInstance($moduleName, $recordId);
$reportModel = $detailViewModel->getRecord();
$reportModel->setModule('Reports');
$pagingModel = new Vtiger_Paging_Model();
$pagingModel->set('page', $page);
$pagingModel->set('limit', self::REPORT_LIMIT);
$this->reportData = $reportModel->getReportData($pagingModel);
$this->calculationFields = $reportModel->getReportCalulationData();
$primaryModule = $reportModel->getPrimaryModule();
$secondaryModules = $reportModel->getSecondaryModules();
$primaryModuleModel = Vtiger_Module_Model::getInstance($primaryModule);
$currentUser = Users_Record_Model::getCurrentUserModel();
$userPrivilegesModel = Users_Privileges_Model::getInstanceById($currentUser->getId());
$permission = $userPrivilegesModel->hasModulePermission($primaryModuleModel->getId());
if (!$permission) {
$viewer->assign('MODULE', $primaryModule);
$viewer->assign('MESSAGE', 'LBL_PERMISSION_DENIED');
$viewer->view('OperationNotPermitted.tpl', $primaryModule);
exit;
}
$detailViewLinks = $detailViewModel->getDetailViewLinks();
// Advanced filter conditions
$viewer->assign('SELECTED_ADVANCED_FILTER_FIELDS', $reportModel->transformToNewAdvancedFilter());
$viewer->assign('PRIMARY_MODULE', $primaryModule);
$recordStructureInstance = Vtiger_RecordStructure_Model::getInstanceFromRecordModel($reportModel);
$primaryModuleRecordStructure = $recordStructureInstance->getPrimaryModuleRecordStructure();
$secondaryModuleRecordStructures = $recordStructureInstance->getSecondaryModuleRecordStructure();
$viewer->assign('PRIMARY_MODULE_RECORD_STRUCTURE', $primaryModuleRecordStructure);
$viewer->assign('SECONDARY_MODULE_RECORD_STRUCTURES', $secondaryModuleRecordStructures);
$secondaryModuleIsCalendar = strpos($secondaryModules, 'Calendar');
if ($primaryModule == 'Calendar' || $secondaryModuleIsCalendar !== FALSE) {
$advanceFilterOpsByFieldType = Calendar_Field_Model::getAdvancedFilterOpsByFieldType();
} else {
$advanceFilterOpsByFieldType = Vtiger_Field_Model::getAdvancedFilterOpsByFieldType();
}
$viewer->assign('ADVANCED_FILTER_OPTIONS', Vtiger_Field_Model::getAdvancedFilterOptions());
$viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', $advanceFilterOpsByFieldType);
$dateFilters = Vtiger_Field_Model::getDateFilterTypes();
foreach ($dateFilters as $comparatorKey => $comparatorInfo) {
$comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']);
$comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']);
$comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $module);
$dateFilters[$comparatorKey] = $comparatorInfo;
}
$viewer->assign('DATE_FILTERS', $dateFilters);
$viewer->assign('LINEITEM_FIELD_IN_CALCULATION', $reportModel->showLineItemFieldsInFilter(false));
$viewer->assign('DETAILVIEW_LINKS', $detailViewLinks);
$viewer->assign('REPORT_MODEL', $reportModel);
$viewer->assign('RECORD_ID', $recordId);
$viewer->assign('COUNT', count($this->reportData));
$viewer->assign('MODULE', $moduleName);
$viewer->view('ReportHeader.tpl', $moduleName);
}
示例13: handleEvent
function handleEvent($eventName, $entityData)
{
if (!in_array($eventName, ['vtiger.entity.link.after', 'vtiger.entity.unlink.after'])) {
return;
}
$fields = Vtiger_MultiReferenceValue_UIType::getMultiReferenceValueFields($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']);
}
}
}
示例14: getInstance
/**
* Function to get instance
* @param <String> $value - fieldname or fieldid
* @param <type> $module - optional - module instance
* @return <Vtiger_Field_Model>
*/
public static function getInstance($value, $module = false)
{
$fieldObject = parent::getInstance($value, $module);
if ($fieldObject) {
return self::getInstanceFromFieldObject($fieldObject);
}
return false;
}
示例15: getHeaders
public function getHeaders()
{
$relationModel = $this->getRelationModel();
$relatedModuleModel = $relationModel->getRelationModuleModel();
$headerFieldNames = $relatedModuleModel->getRelatedListFields();
$headerFields = array();
foreach ($headerFieldNames as $fieldName) {
$headerFields[$fieldName] = $relatedModuleModel->getField($fieldName);
}
//Added to support List Price
$field = new Vtiger_Field_Model();
$field->set('name', 'listprice');
$field->set('column', 'listprice');
$field->set('label', 'List Price');
array_push($headerFields, $field);
return $headerFields;
}