Index: trunk/core/units/general/helpers/search_helper.php =================================================================== diff -u -N -r6833 -r7391 --- trunk/core/units/general/helpers/search_helper.php (.../search_helper.php) (revision 6833) +++ trunk/core/units/general/helpers/search_helper.php (.../search_helper.php) (revision 7391) @@ -58,6 +58,7 @@ break; case '': + $keyword = str_replace('"', '\"', $keyword); $normal_conditions[] = implode(' LIKE "%'.$keyword.'%" OR ', $fields).' LIKE "%'.$keyword.'%"'; break; } @@ -103,6 +104,13 @@ } $table_name = ($sql_filter_type == 'where') ? $table_name : ''; + + // replace wid inside table name to WID_MARK constant value + $is_temp_table = preg_match('/(.*)'.TABLE_PREFIX.'ses_'.$this->Application->GetSID().'(_[\d]+){0,1}_edit_(.*)/', $table_name, $regs); + if ($is_temp_table) { + $table_name = $regs[1].TABLE_PREFIX.'ses_'.EDIT_MARK.'_edit_'.$regs[3]; // edit_mark will be replaced with sid[_main_wid] in AddFilters + } + return Array ('field_name' => $field_name, 'field_type' => $field_type, 'table_name' => $table_name, 'sql_filter_type' => $sql_filter_type); } @@ -299,7 +307,7 @@ if ($submit_filters) { foreach ($submit_filters as $field_name => $field_options) { list ($filter_type, $field_value) = each($field_options); - $is_empty = is_array($field_value) ? !implode('', $field_value) : !$field_value; + $is_empty = strlen(is_array($field_value) ? implode('', $field_value) : $field_value) == 0; if ($is_empty) { if (isset($custom_filter[$field_name])) { // use isset, because non-existing key will cause "php notice"! @@ -357,7 +365,7 @@ */ function getRangeValue($value) { - return $value && is_numeric($value) ? $this->Conn->qstr($value) : false; + return strlen($value) && is_numeric($value) ? $this->Conn->qstr($value) : false; } function getCustomFilterSearchClause(&$object, $field_name, $filter_type, $field_options) @@ -415,9 +423,11 @@ $day_seconds = 23 * 60 * 60 + 59 * 60 + 59; if ($from !== false && $to === false) { + $from = strtotime(date('Y-m-d', $from).' 00:00:00', $from); // reset to morning $to = $from + $day_seconds; } elseif ($from === false && $to !== false) { + $to = strtotime(date('Y-m-d', $to).' 23:59:59', $to); // reset to evening $from = $to - $day_seconds; } @@ -428,7 +438,7 @@ case 'equals': case 'options': - $field_value = $field_options['submit_value'] ? $this->Conn->qstr($field_options['submit_value']) : false; + $field_value = strlen($field_options['submit_value']) ? $this->Conn->qstr($field_options['submit_value']) : false; if ($field_value) { $filter_value = $table_name.'`'.$field_name.'` = '.$field_value; } @@ -458,24 +468,25 @@ */ function processRangeField(&$object, $search_field, $value, $type) { - if (!$value[$type]) { + if (!strlen($value[$type])) { return false; } $lang_current =& $this->Application->recallObject('lang.current'); - $dt_separator = getArrayValue($object->GetFieldOptions($search_field), 'date_time_separator'); - if (!$dt_separator) { - $dt_separator = ' '; - } + $options = $object->GetFieldOptions($search_field); + $dt_separator = isset($options['date_time_separator']) ? $options['date_time_separator'] : ' '; - $time = ($type == 'from') ? adodb_mktime(0, 0, 0) : adodb_mktime(23, 59, 59); - $time = adodb_date($lang_current->GetDBField('InputTimeFormat'), $time); - - $full_value = $value[$type].$dt_separator.$time; + $tmp_value = explode($dt_separator, $value[$type], 2); + if (count($tmp_value) == 1) { + // time is missing, then guess it and add to date + $time = ($type == 'from') ? adodb_mktime(0, 0, 0) : adodb_mktime(23, 59, 59); + $time = adodb_date($lang_current->GetDBField('InputTimeFormat'), $time); + $value[$type] .= $dt_separator.$time; + } $formatter =& $this->Application->recallObject($object->Fields[$search_field]['formatter']); - $value_ts = $formatter->Parse($full_value, $search_field, $object); + $value_ts = $formatter->Parse($value[$type], $search_field, $object); $pseudo = getArrayValue($object->FieldErrors, $search_field, 'pseudo'); if ($pseudo) { unset($object->FieldErrors[$search_field]); // remove error!