/** * Convert an older version of the params to new format * and clean up any stupidities */ private function _convertParams($params) { if (empty($params)) { return array(); } if (!empty($params['dates'])) { foreach ($params['dates'] as $rule) { $params['custom_fields'][$rule['typeid']] = $rule; unset($params['custom_fields'][$rule['typeid']]['typeid']); } unset($params['dates']); } if (!empty($params['date_logic'])) { $params['custom_field_logic'] = $params['date_logic']; unset($params['date_logic']); } foreach (array_get($params, 'show_fields', array()) as $i => $v) { if (0 === strpos($v, 'date---')) { $params['show_fields'][$i] = self::CUSTOMFIELD_PREFIX . substr($v, strlen('date---')); } } if (0 === strpos($params['sort_by'], 'date---')) { $params['sort_by'] = self::CUSTOMFIELD_PREFIX . substr($params['sort_by'], strlen('date---')); } if ($params['group_by'] == 'groupid' && !count(array_remove_empties($params['include_groups']))) { $params['group_by'] = ''; } return $params; }
/** * Process an interface where an end user supplies a value for this custom field for a person record * @return mixed */ public function processWidget() { $res = process_widget('custom_' . $this->id, $this->getWidgetParams(), NULL, TRUE); if ($this->getValue('type') == 'date' && !empty($this->values['params']['allow_note'])) { $notes = process_widget('custom_' . $this->id . '_note', array('type' => 'text'), NULL, TRUE); foreach ((array) $notes as $k => $v) { if (!empty($res[$k]) && strlen($v)) { $res[$k] .= ' ' . $v; } } } if (is_array($res)) { $res = array_remove_empties($res); } return $res; }
function _processRuleDetails($field) { $res = array(); switch ($this->_field_details[$field]['type']) { case 'datetime': $res['from'] = process_widget('params_' . str_replace('.', '_', $field) . '_from', array('type' => 'date')); $res['to'] = process_widget('params_' . str_replace('.', '_', $field) . '_to', array('type' => 'date')); break; case 'select': case 'reference': $res = array_remove_empties(array_get($_POST, 'params_' . str_replace('.', '_', $field), array())); break; default: $res = array_get($_POST, 'params_' . str_replace('.', '_', $field)); break; } return $res; }