public function getPicklistValues() { $fieldDataType = $this->getFieldDataType(); if ($fieldDataType != 'picklist') { return parent::getPicklistValues(); } $pickListValues = array(); $pickListValues[""] = vtranslate("LBL_SELECT_OPTION", 'Settings:Webforms'); return $pickListValues + parent::getPicklistValues(); }
/** * Function which will give the picklistvalues for given roleids * @param type $roleIdList -- array of role ids * @param type $groupMode -- Intersection/Conjuction , intersection will give only picklist values that exist for all roles * @return type -- array */ public function getPicklistValues($roleIdList, $groupMode = 'INTERSECTION') { if (!$this->isRoleBased()) { return parent::getPicklistValues(); } $intersectionMode = false; if ($groupMode == 'INTERSECTION') { $intersectionMode = true; } $db = PearDatabase::getInstance(); $fieldName = $this->getName(); $tableName = 'vtiger_' . $fieldName; $idColName = $fieldName . 'id'; $query = 'SELECT ' . $fieldName; if ($intersectionMode) { $query .= ',count(roleid) as rolecount '; } $query .= ' FROM vtiger_role2picklist INNER JOIN ' . $tableName . ' ON vtiger_role2picklist.picklistvalueid = ' . $tableName . '.picklist_valueid' . ' WHERE roleid IN (' . generateQuestionMarks($roleIdList) . ') order by sortid'; if ($intersectionMode) { $query .= ' GROUP BY picklistvalueid'; } $result = $db->pquery($query, $roleIdList); $pickListValues = array(); $num_rows = $db->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $rowData = $db->query_result_rowdata($result, $i); if ($intersectionMode) { //not equal if specify that the picklistvalue is not present for all the roles if ($rowData['rolecount'] != count($roleIdList)) { continue; } } //Need to decode the picklist values twice which are saved from old ui $pickListValues[] = decode_html(decode_html($rowData[$fieldName])); } return $pickListValues; }
/** * Function to get all the available picklist values for the current field * @return <Array> List of picklist values if the field is of type picklist or multipicklist, null otherwise. */ public function getPicklistValues() { if ($this->get('uitype') == 32) { return Vtiger_Language_Handler::getAllLanguages(); } else { if ($this->get('uitype') == '115') { $db = PearDatabase::getInstance(); $query = 'SELECT ' . $this->getFieldName() . ' FROM vtiger_' . $this->getFieldName(); $result = $db->pquery($query, array()); $num_rows = $db->num_rows($result); $fieldPickListValues = array(); for ($i = 0; $i < $num_rows; $i++) { $picklistValue = $db->query_result($result, $i, $this->getFieldName()); $fieldPickListValues[$picklistValue] = vtranslate($picklistValue, $this->getModuleName()); } return $fieldPickListValues; } } return parent::getPicklistValues(); }