Project

General

Profile

Bug #3429 ยป 3429.patch

krileon, 09 April 2012 21:29

View differences:

components/com_comprofiler/plugin/user/plug_cbcore/cb.core.php
* @return array of cbSqlQueryPart
*/
function bindSearchCriteria( &$field, &$searchVals, &$postdata, $list_compare_types, $reason ) {
$query = array();
$query = array();
foreach ( $field->getTableColumns() as $col ) {
$minNam = $col . '__minval';
$maxNam = $col . '__maxval';
$searchMode = $this->_bindSearchRangeMode( $field, $searchVals, $postdata, $minNam, $maxNam, $list_compare_types );
$minNam = $col . '__minval';
$maxNam = $col . '__maxval';
$searchMode = $this->_bindSearchRangeMode( $field, $searchVals, $postdata, $minNam, $maxNam, $list_compare_types );
if ( $searchMode ) {
$minVal = (int) cbGetParam( $postdata, $minNam, 0 );
$maxVal = (int) cbGetParam( $postdata, $maxNam, 0 );
$minVal = (int) cbGetParam( $postdata, $minNam, 0 );
$maxVal = (int) cbGetParam( $postdata, $maxNam, 0 );
if ( $minVal && ( cbGetParam( $postdata, $minNam, '' ) !== '' ) ) {
$searchVals->$minNam = $minVal;
$query[] = $this->_intToSql( $field, $col, $minVal, '>=', $searchMode );
$min = new cbSqlQueryPart();
$min->tag = 'column';
$min->name = $col;
$min->table = $field->table;
$min->type = 'sql:field';
$min->operator = ( $searchMode == 'isnot' ? ( $minVal == $maxVal ? '<' : '<=' ) : '>=' );
$min->value = $minVal;
$min->valuetype = 'const:int';
$min->searchmode = $searchMode;
$searchVals->$minNam = $minVal;
}
if ( $maxVal && ( cbGetParam( $postdata, $maxNam, '' ) !== '' ) ) {
$searchVals->$maxNam = $maxVal;
$query[] = $this->_intToSql( $field, $col, $maxVal, '<=', $searchMode );
$max = new cbSqlQueryPart();
$max->tag = 'column';
$max->name = $col;
$max->table = $field->table;
$max->type = 'sql:field';
$max->operator = ( $searchMode == 'isnot' ? ( $maxVal == $minVal ? '>' : '>=' ) : '<=' );
$max->value = $maxVal;
$max->valuetype = 'const:int';
$max->searchmode = $searchMode;
$searchVals->$maxNam = $maxVal;
}
if ( isset( $min ) && isset( $max ) ) {
$sql = new cbSqlQueryPart();
$sql->tag = 'column';
$sql->name = $col;
$sql->table = $field->table;
$sql->type = 'sql:operator';
$sql->operator = ( $searchMode == 'isnot' ? 'OR' : 'AND' );
$sql->searchmode = $searchMode;
$sql->addChildren( array( $min, $max ) );
$query[] = $sql;
} elseif ( isset( $min ) ) {
$query[] = $min;
} elseif ( isset( $max ) ) {
$query[] = $max;
}
}
}
return $query;
}
function _intToSql( &$field, $col, $value, $operator, $searchMode ) {
$value = (int) $value;
// $this->validate( $field, $user, $col, $value, $postdata, $reason );
$sql = new cbSqlQueryPart();
$sql->tag = 'column';
$sql->name = $col;
$sql->table = $field->table;
$sql->type = 'sql:field';
$sql->operator = $operator;
$sql->value = $value;
$sql->valuetype = 'const:int';
$sql->searchmode = $searchMode;
return $sql;
}
}
class CBfield_date extends cbFieldHandler {
    (1-1/1)