Exemplo n.º 1
0
 public function getFieldUI(Vtiger_Request $request)
 {
     $fieldsList = $request->get('fieldIdList');
     $module = $request->get('sourceModule');
     $fieldModelList = Settings_LayoutEditor_Field_Model::getInstanceFromFieldId($fieldsList, getTabId($module));
     $viewer = $this->getViewer($request);
     $qualifiedModuleName = $request->getModule(false);
     $viewer->assign('SELECTED_MODULE_NAME', $module);
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('FIELD_MODELS_LIST', $fieldModelList);
     $viewer->view('FieldUi.tpl', $qualifiedModuleName);
 }
Exemplo n.º 2
0
 public function addField($fieldType, $blockId, $params)
 {
     $db = PearDatabase::getInstance();
     $label = $params['fieldLabel'];
     $type = $params['fieldTypeList'];
     $name = strtolower($params['fieldName']);
     $fieldparams = '';
     if ($this->checkFieldLableExists($label)) {
         throw new Exception(vtranslate('LBL_DUPLICATE_FIELD_EXISTS', 'Settings::LayoutEditor'), 513);
     }
     if ($this->checkFieldNameCharacters($name)) {
         throw new Exception(vtranslate('LBL_INVALIDCHARACTER', 'Settings::LayoutEditor'), 512);
     }
     if ($this->checkFieldNameExists($name)) {
         throw new Exception(vtranslate('LBL_DUPLICATE_FIELD_EXISTS', 'Settings::LayoutEditor'), 512);
     }
     $supportedFieldTypes = $this->getAddSupportedFieldTypes();
     if (!in_array($fieldType, $supportedFieldTypes)) {
         throw new Exception(vtranslate('LBL_WRONG_FIELD_TYPE', 'Settings::LayoutEditor'), 513);
     }
     $moduleName = $this->getName();
     $focus = CRMEntity::getInstance($moduleName);
     if ($type == 0) {
         $columnName = $name;
         $tableName = $focus->table_name;
     } elseif ($type == 1) {
         $max_fieldid = $db->getUniqueID("vtiger_field");
         $columnName = 'cf_' . $max_fieldid;
         $custfld_fieldid = $max_fieldid;
         if (isset($focus->customFieldTable)) {
             $tableName = $focus->customFieldTable[0];
         } else {
             $tableName = 'vtiger_' . strtolower($moduleName) . 'cf';
         }
     }
     if ($fieldType == 'Tree') {
         $fieldparams = (int) $params['tree'];
     } elseif ($fieldType == 'MultiReferenceValue') {
         $fieldparams['module'] = $params['MRVModule'];
         $fieldparams['field'] = $params['MRVField'];
         $fieldparams['filterField'] = $params['MRVFilterField'];
         $fieldparams['filterValue'] = $params['MRVFilterValue'];
     }
     $details = $this->getTypeDetailsForAddField($fieldType, $params);
     $uitype = $details['uitype'];
     $typeofdata = $details['typeofdata'];
     $dbType = $details['dbType'];
     $quickCreate = in_array($moduleName, getInventoryModules()) ? 3 : 1;
     $fieldModel = new Settings_LayoutEditor_Field_Model();
     $fieldModel->set('name', $columnName)->set('table', $tableName)->set('generatedtype', 2)->set('uitype', $uitype)->set('label', $label)->set('typeofdata', $typeofdata)->set('quickcreate', $quickCreate)->set('fieldparams', Zend_Json::encode($fieldparams))->set('columntype', $dbType);
     if (isset($details['displayType'])) {
         $fieldModel->set('displaytype', $details['displayType']);
     }
     $blockModel = Vtiger_Block_Model::getInstance($blockId, $this);
     $blockModel->addField($fieldModel);
     if ($fieldType == 'Picklist' || $fieldType == 'MultiSelectCombo') {
         $pickListValues = $params['pickListValues'];
         if (is_string($pickListValues)) {
             $pickListValues = [$pickListValues];
         }
         $fieldModel->setPicklistValues($pickListValues);
     }
     if ($fieldType == 'Related1M') {
         if (!is_array($params['referenceModule'])) {
             $moduleList[] = $params['referenceModule'];
         } else {
             $moduleList = $params['referenceModule'];
         }
         $fieldModel->setRelatedModules($moduleList);
         foreach ($moduleList as $module) {
             $targetModule = Vtiger_Module::getInstance($module);
             $targetModule->setRelatedList($this, $moduleName, array('Add'), 'get_dependents_list');
         }
     }
     return $fieldModel;
 }
Exemplo n.º 3
0
 public function unHide(Vtiger_Request $request)
 {
     $response = new Vtiger_Response();
     try {
         $fieldIds = $request->get('fieldIdList');
         Settings_LayoutEditor_Field_Model::makeFieldActive($fieldIds, $request->get('blockId'));
         $responseData = array();
         foreach ($fieldIds as $fieldId) {
             $fieldModel = Settings_LayoutEditor_Field_Model::getInstance($fieldId);
             $fieldInfo = $fieldModel->getFieldInfo();
             $responseData[] = array_merge(array('id' => $fieldModel->getId(), 'blockid' => $fieldModel->get('block')->id, 'customField' => $fieldModel->isCustomField()), $fieldInfo);
         }
         $response->setResult($responseData);
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     $response->emit();
 }
Exemplo n.º 4
0
 public function addField($fieldType, $blockId, $params)
 {
     $db = PearDatabase::getInstance();
     $label = $params['fieldLabel'];
     if ($this->checkFIeldExists($label)) {
         throw new Exception(vtranslate('LBL_DUPLICATE_FIELD_EXISTS', 'Settings::LayoutEditor'), 513);
     }
     $supportedFieldTypes = $this->getAddSupportedFieldTypes();
     if (!in_array($fieldType, $supportedFieldTypes)) {
         throw new Exception(vtranslate('LBL_WRONG_FIELD_TYPE', 'Settings::LayoutEditor'), 513);
     }
     $max_fieldid = $db->getUniqueID("vtiger_field");
     $columnName = 'cf_' . $max_fieldid;
     $custfld_fieldid = $max_fieldid;
     $moduleName = $this->getName();
     $focus = CRMEntity::getInstance($moduleName);
     if (isset($focus->customFieldTable)) {
         $tableName = $focus->customFieldTable[0];
     } else {
         $tableName = 'vtiger_' . strtolower($moduleName) . 'cf';
     }
     $details = $this->getTypeDetailsForAddField($fieldType, $params);
     $uitype = $details['uitype'];
     $typeofdata = $details['typeofdata'];
     $dbType = $details['dbType'];
     $quickCreate = in_array($moduleName, getInventoryModules()) ? 3 : 1;
     $fieldModel = new Settings_LayoutEditor_Field_Model();
     $fieldModel->set('name', $columnName)->set('table', $tableName)->set('generatedtype', 2)->set('uitype', $uitype)->set('label', $label)->set('typeofdata', $typeofdata)->set('quickcreate', $quickCreate)->set('columntype', $dbType);
     $blockModel = Vtiger_Block_Model::getInstance($blockId, $this);
     $blockModel->addField($fieldModel);
     if ($fieldType == 'Picklist' || $fieldType == 'MultiSelectCombo') {
         $pickListValues = explode(',', $params['pickListValues']);
         $fieldModel->setPicklistValues($pickListValues);
     }
     return $fieldModel;
 }
Exemplo n.º 5
0
    public function addField($fieldType, $blockId, $params) {

        $db = PearDatabase::getInstance();

        $label = $params['fieldLabel'];
        if($this->checkFIeldExists($label)){
            throw new Exception(vtranslate('LBL_DUPLICATE_FIELD_EXISTS', 'Settings::LayoutEditor'), 513);
        }
        $supportedFieldTypes = $this->getAddSupportedFieldTypes();
        if(!in_array($fieldType, $supportedFieldTypes)) {
            throw new Exception(vtranslate('LBL_WRONG_FIELD_TYPE', 'Settings::LayoutEditor'), 513);
        }

		$columnName = $params['ColumnName'];
        $moduleName = $this->getName();

        $focus = CRMEntity::getInstance($moduleName);
        if ($params['fieldTableName'] !== '') {
            $tableName= $params['fieldTableName'];
        } elseif (isset($focus->customFieldTable)) {
            $tableName=$focus->customFieldTable[0];
        } else {
            $tableName= 'vtiger_'.strtolower($moduleName).'cf';
        }

        $details = $this->getTypeDetailsForAddField($fieldType, $params);
        $uitype = $details['uitype'];
        $typeofdata = $details['typeofdata'];
        $dbType = $details['dbType'];

        $quickCreate = in_array($moduleName,  getInventoryModules()) ? 3 : 1;

        $fieldModel = new Settings_LayoutEditor_Field_Model();
        $fieldModel->set('name', $columnName)
                   ->set('table', $tableName)
                   ->set('generatedtype',2)
                   ->set('uitype', $uitype)
                   ->set('label', $label)
                   ->set('typeofdata',$typeofdata)
                   ->set('quickcreate',$quickCreate)
                   ->set('columntype', $dbType);

        $blockModel = Vtiger_Block_Model::getInstance($blockId, $this);
        $blockModel->addField($fieldModel);
		
		if($fieldType == 'ModuleLinked') {
            $moduleListNames = explode(',',$params['pickListValues']);
			foreach ($moduleListNames as $key => $modname) {				// проверяем все имена модулей
				$rmoduleInstance = Vtiger_Module::getInstance($modname);
				if (!$rmoduleInstance) unset($moduleListNames[$key]);		// И удаляем если такого модуля нет
			}
			$fieldModel->setRelatedModules($moduleListNames);
		}

        if($fieldType == 'Picklist' || $fieldType == 'MultiSelectCombo') {
            $pickListValues = explode(',',$params['pickListValues']);
			// можно присоединиться к готовому списку с таким же columnname
            if ($pickListValues[0] != 'null') $fieldModel->setPicklistValues($pickListValues);
        }
        return $fieldModel;
    }
Exemplo n.º 6
0
 public function deleteInheritsharing()
 {
     global $log, $adb;
     $log->debug("Entering YetiForceUpdate::deleteInheritsharing() method ...");
     $result = $adb->pquery("SELECT fieldid FROM vtiger_field WHERE columnname IN (?);", ['inheritsharing']);
     while ($row = $adb->fetch_array($result)) {
         $fieldInstance = Settings_LayoutEditor_Field_Model::getInstance($row['fieldid']);
         try {
             $fieldInstance->delete();
         } catch (Exception $e) {
             $log->debug("ERROR YetiForceUpdate::deleteInheritsharing: code " . $e->getCode() . " message " . $e->getMessage());
         }
     }
     if ($adb->getRowCount($result)) {
         $adb->query('ALTER TABLE `vtiger_crmentity` DROP COLUMN `inheritsharing`;');
     }
     $log->debug("Exiting YetiForceUpdate::deleteInheritsharing() method ...");
 }