/** * Compute different sources to get the columns that must be showed * 1) from form request 2) from session 3) from default value * @param sfBasicSecurityUser $user the user * @param sfForm $form The filter form with the 'col_fields' field defined * @param bool $as_string specify if you want the return to be a string (concat of visible cols) * @return array of fields with check or uncheck or a list of visible fields separated by | */ private function getVisibleColumns(sfBasicSecurityUser $user, sfForm $form, $as_string = false) { $flds = array('category', 'collection', 'taxon', 'type', 'gtu', 'codes', 'chrono', 'ig', 'acquisition_category', 'litho', 'lithologic', 'mineral', 'expedition', 'type', 'individual_type', 'sex', 'state', 'stage', 'social_status', 'rock_form', 'individual_count', 'part', 'object_name', 'part_status', 'building', 'floor', 'room', 'row', 'col', 'shelf', 'container', 'container_type', 'container_storage', 'sub_container', 'sub_container_type', 'sub_container_storage', 'specimen_count', 'part_codes', 'loans'); $flds = array_fill_keys($flds, 'uncheck'); if ($form->isBound() && $form->getValue('col_fields') != "") { $req_fields = $form->getValue('col_fields'); $req_fields_array = explode('|', $req_fields); } else { $req_fields_array = $user->fetchVisibleCols(); } if (empty($req_fields_array)) { $req_fields_array = explode('|', $form->getDefault('col_fields')); } if ($as_string) { return implode('|', $req_fields_array); } foreach ($req_fields_array as $k => $val) { $flds[$val] = 'check'; } return $flds; }