Index: trunk/themes/default/advsearch/item_form.tpl =================================================================== diff -u -r13 -r1108 --- trunk/themes/default/advsearch/item_form.tpl (.../item_form.tpl) (revision 13) +++ trunk/themes/default/advsearch/item_form.tpl (.../item_form.tpl) (revision 1108) @@ -1,5 +1,5 @@
- + \ No newline at end of file Index: trunk/kernel/include/advsearch.php =================================================================== diff -u -r979 -r1108 --- trunk/kernel/include/advsearch.php (.../advsearch.php) (revision 979) +++ trunk/kernel/include/advsearch.php (.../advsearch.php) (revision 1108) @@ -43,7 +43,10 @@ $objSearchConfig->Query_Item("SELECT * FROM ".$objSearchConfig->SourceTable." WHERE TableName='$SearchSource' AND AdvancedSearch=1 ORDER BY DisplayOrder"); } else { - $sql = "SELECT sc.* FROM ".$objSearchConfig->SourceTable." AS sc LEFT JOIN ".GetTablePrefix()."CustomField AS cf ON sc.CustomFieldId = cf.CustomFieldId WHERE TableName='$table' OR (TableName='CustomField' AND cf.Type = $ItemType) AND AdvancedSearch=1 ORDER BY sc.DisplayOrder"; + $tables = Array(1 => 'Category', 2 => 'News', + 3 => 'Topic', 4 => 'Link'); + $table = $tables[$ItemType]; + $sql = "SELECT sc.* FROM ".$objSearchConfig->SourceTable." AS sc LEFT JOIN ".GetTablePrefix()."CustomField AS cf ON sc.CustomFieldId = cf.CustomFieldId WHERE TableName='$table' OR (TableName='".GetTablePrefix()."CustomField' AND cf.Type = $ItemType) AND AdvancedSearch=1 ORDER BY sc.DisplayOrder"; $objSearchConfig->Query_Item($sql); } } @@ -92,10 +95,18 @@ if(!is_object($objSearchConfig)) $objSearchConfig = new clsSeachConfigList(); - $f = GetTablePrefix().$TableName.".".$FieldName; - $FieldConfig = $objSearchConfig->GetItemByName($TableName,$FieldName); - if(is_object($FieldConfig)) - { + if ($TableName==GetTablePrefix().'CustomField') + { + $prefix = ''; + } + else + { + $prefix = GetTablePrefix(); + } + $f = $prefix.$TableName.".".$FieldName; + $FieldConfig = $objSearchConfig->GetItemByName($TableName,$FieldName); + if(is_object($FieldConfig)) + { if(strlen($FieldConfig->Get("ForeignField"))>0) { $parts = explode(".",$FieldConfig->Get("ForeignField")); @@ -105,10 +116,10 @@ $join = $FieldConfig->Get("JoinClause"); $join = str_replace("{ForeignTable}",$Table,$join); $join = str_replace("{LocalTable}",AddTablePrefix($TableName),$join); - $join = str_replace("{Table}", $this->SourceTable, $join); + $join = str_replace("{Table}", AddTablePrefix($this->SourceTable), $join); $this->AddRelationship($Table,$join); - $FieldItem["where"] = $FieldConfig->GetWhereClause($Verb,$Value); + $FieldItem["where"] = GetTablePrefix().$FieldConfig->GetWhereClause($Verb,$Value); $FieldItem["Field"] = $FieldConfig->Get("ForeignField"); $FieldItem["Table"] = ""; $FieldItem["conjuction"] = $conj; @@ -129,6 +140,53 @@ } } + +/* function AddAdvancedCustomFields() + { + $sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND AdvancedSearch=1 AND CustomFieldId>0"; + //echo $sql; + foreach($this->Relationships as $Table=>$clause) + { + if(strlen($Table)>0 && $Table != "Category") + $sql .= " OR TableName='".$Table."'"; + } + $ctable = GetTablePrefix()."CustomMetaData"; + $rs = $this->adodbConnection->Execute($sql); + $CustomJoined = FALSE; + while($rs && !$rs->EOF) + { + $x = $rs->fields["CustomFieldId"]; + $t = $ctable." as c".$x; + $join = "(c$x.ResourceId=".GetTablePrefix().$this->SourceTable.".ResourceId AND c$x.CustomFieldId=".$rs->fields["CustomFieldId"].")"; + $this->AddRelationship($t,$join); + $f = "c".$x.".Value "; + $this->FieldList[] = $f; + $this->FieldWeight[$f] = $rs->fields["Priority"]; + $rs->MoveNext(); + } + } + + function AddAdvancedFields() + { + $sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND AdvancedSearch=1 AND CustomFieldId=0"; + //echo $sql; + foreach($this->Relationships as $Table=>$clause) + { + if(strlen($Table)>0 && $Table != "Category") + $sql .= " OR TableName='".$Table."'"; + } + $rs = $this->adodbConnection->Execute($sql); + + while($rs && !$rs->EOF) + { + $f = GetTablePrefix().$rs->fields["TableName"].".".$rs->fields["FieldName"]; + $this->FieldList[] = $f; + $this->FieldWeight[$f] = $rs->fields["Priority"]; + $rs->MoveNext(); + } + $this->AddAdvancedCustomFields(); + }*/ + /* ready to write the code to build the query and go */ function BuildWhereClause() @@ -141,7 +199,7 @@ $where = substr($where, 0, strlen($where) - $cut_length); return $where; } - + function PerformSearch($ItemType,$OrderBy=NULL,$InitTable=FALSE, $idlist=NULL) { static $SelectSQL, $OldItemType; Index: trunk/kernel/include/searchconfig.php =================================================================== diff -u -r979 -r1108 --- trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 979) +++ trunk/kernel/include/searchconfig.php (.../searchconfig.php) (revision 1108) @@ -246,7 +246,7 @@ function ResetModule() { $this->Clear(); - $sql = "UPDATE ".$this->SourceTable." SET SimpleSearch=0, AdvancedSearch=0 WHERE ModuleName='".$this->module."'"; + $sql = "UPDATE ".$this->SourceTable." SET SimpleSearch=0, AdvancedSearch=0 WHERE ModuleName='".$this->Module."'"; $this->adodbConnection->Execute($sql); } Index: trunk/themes/default/advsearch/alt_item_form.tpl =================================================================== diff -u -r13 -r1108 --- trunk/themes/default/advsearch/alt_item_form.tpl (.../alt_item_form.tpl) (revision 13) +++ trunk/themes/default/advsearch/alt_item_form.tpl (.../alt_item_form.tpl) (revision 1108) @@ -1,5 +1,5 @@
- + \ No newline at end of file Index: trunk/kernel/frontaction.php =================================================================== diff -u -r1080 -r1108 --- trunk/kernel/frontaction.php (.../frontaction.php) (revision 1080) +++ trunk/kernel/frontaction.php (.../frontaction.php) (revision 1108) @@ -896,8 +896,19 @@ $FormError["m_simplesearch"]["keywords"] = language("lu_no_keyword"); } break; - case "m_adv_search": - if( !is_object($objSearchConfig) ) $objSearchConfig = new clsSearchConfigList(); + case "m_adv_search": + + if ($_GET['type']) + { + $modules = Array(1 => 'In-Portal', 2 => 'In-News', + 3 => 'In-Bulletin', 4 => 'In-Link'); + $module = $modules[$_GET["type"]]; + } + else + { + $module = 0; + } + if( !is_object($objSearchConfig) ) $objSearchConfig = new clsSearchConfigList($module); switch($_GET["type"]) { case 1: /* category */ @@ -933,6 +944,12 @@ $Conjuction = ""; break; } + + if (strlen($Value) && $Verb=="any") + { + $Verb = 'contains'; + } + if(strlen($Verb)>0 && $Verb!="any") { //echo "Adding CAT SearchField: [".$field->Get("TableName")."]; [".$field->Get("FieldName")."]; [$Verb]; [$Value]; [$Conjuction]
";