Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 8:52 AM

in-portal

Index: trunk/kernel/include/searchconfig.php
===================================================================
--- trunk/kernel/include/searchconfig.php (revision 1107)
+++ trunk/kernel/include/searchconfig.php (revision 1108)
@@ -1,424 +1,424 @@
<?php
RegisterPrefix("clsSearchConfig","searchfield","kernel/include/searchconfig.php");
class clsSearchConfig extends clsParsedItem
{
function clsSearchConfig($id=NULL)
{
$this->clsParsedItem();
$this->tablename = GetTablePrefix()."SearchConfig";
$this->id_field = "SearchConfigId";
$this->NoResourceId=1;
$this->TagPrefix="searchfield";
if($id)
$this->LoadFromDatabase($id);
}
function LoadFromDatabase($Id)
{
global $Errors;
if(!isset($Id))
{
$Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase");
return false;
}
$sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id);
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase");
return false;
}
$data = $result->fields;
$this->SetFromArray($data);
$this->Clean();
return true;
}
function GetWhereClause($verb,$value)
{
//$value = $this->adodbConnection->qstr(stripslashes($value));
$where = "";
if(strlen($this->Get("ForeignField"))>0)
{
$field = $this->Get("ForeignField");
}
else
$field = $this->Get("FieldName");
switch($verb)
{
case "is":
if(strlen($this->Get("IsWhere")))
{
$where = str_replace("{Value}",$value,$this->Get("IsWhere"));
}
else
$where = $field." = '".$value."'";
break;
case "isnot":
if(strlen($this->Get("IsNotWhere")))
{
$where = str_replace("{Value}",$value,$this->Get("IsNotWhere"));
}
else
$where = $field." != '".$value."'";
break;
case "contains":
if(strlen($this->Get("ContainsWhere")))
{
$where = str_replace("{Value}",$value,$this->Get("ContainsWhere"));
}
else
$where = $field." LIKE '%".$value."%'";
break;
case "notcontains":
if(strlen($this->Get("NotContainsWhere")))
{
$where = str_replace("{Value}",$value,$this->Get("NotContainsWhere"));
}
else
$where = $field." NOT LIKE '%".$value."%'";
break;
}
return $where;
}
function ParseObject($element)
{
global $objConfig, $objSession, $objUsers, $objCatList, $var_list_update, $var_list,
$bb_var_list_update, $m_var_list_update,$FormValues;
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
switch($field)
{
case "name":
$ret = $this->Get("FieldName");
break;
case "lang_name":
$ret = language($this->Get("DisplayName"));
break;
case "id":
$ret = $this->Get("SearchConfigId");
break;
case "header":
$hdr = $this->Get("ConfigHeader");
if(strlen($hdr))
$ret = language($hdr);
break;
case "table":
$ret = $this->Get("TableName");
break;
case "simple":
$ret = (int)$this->Get("SimpleSearch");
if($ret)
{
if(strlen($element->attributes["_text"]))
$ret = language($element->attributes["_text"]);
if(strlen($element->attributes["_plaintext"]))
$ret = $element->attributes["_plaintext"];
}
break;
case "advanced":
$ret = (int)$this->Get("AdvancedSearch");
if($ret)
{
if(strlen($element->attributes["_text"]))
$ret = language($element->attributes["_text"]);
if(strlen($element->attributes["_plaintext"]))
$ret = $element->attributes["_plaintext"];
}
break;
case "verb_select":
$datatype = $this->Get("FieldType");
switch($datatype)
{
case "text":
$fieldname = "verb[".$this->Get("FieldName")."]";
$ret = "<SELECT name=\"$fieldname\">";
$selected="";
if($FormValues[$fieldname]=="any")
$selected = " selected";
$ret .= "<OPTION value=\"any\" $selected>".language("lu_advsearch_any")."</OPTION>";
$selected="";
if($FormValues[$fieldname]=="is")
$selected = " selected";
$ret .= "<OPTION value=\"is\" $selected>".language("lu_advsearch_is")."</OPTION>";
$selected="";
if($FormValues[$fieldname]=="isnot")
$selected = " selected";
$ret .= "<OPTION value=\"isnot\" $selected>".language("lu_advsearch_isnot")."</OPTION>";
$selected="";
if($FormValues[$fieldname]=="contains")
$selected = " selected";
$ret .= "<OPTION value=\"contains\" $selected>".language("lu_advsearch_contains")."</OPTION>";
$selected="";
if($FormValues[$fieldname]=="notcontains")
$selected = " selected";
$ret .= "<OPTION value=\"notcontains\" $selected>".language("lu_advsearch_notcontains")."</OPTION>";
$ret .= "</SELECT>";
break;
case "boolean":
$ret = "";
break;
}
break;
case "form_input":
$datatype = $this->Get("FieldType");
$name = $this->Get("FieldName");
switch($datatype)
{
case "text":
$ret = "<INPUT TYPE=TEXT maxlength=50 name=\"value[$name]\" VALUE=\"".$FormValues[$name]."\">";
break;
case "boolean":
$ret = "<INPUT TYPE=RADIO name=\"value[$name]\" VALUE=\"-1\" ";
if(!is_numeric($FormValues[$name]) || ($FormValues[$name] != 1 && $FormValues[$name]!= 0))
$ret .= " CHECKED";
$ret .=">".language("lu_advsearch_any");
$ret .= "<INPUT TYPE=RADIO name=\"value[$name]\" VALUE=\"1\" ";
if($FormValues[$name]==1)
$ret .= " CHECKED";
$ret .= ">".language("lu_true");
$ret .= " <INPUT TYPE=RADIO name=\"value[$name]\" VALUE=\"0\" ";
if(is_numeric($FormValues[$name]) && $FormValues[$name]==0)
$ret .= " CHECKED";
$ret .= ">".language("lu_false");
break;
}
break;
case "andor_radio":
$name = $this->Get("FieldName");
$Field = "andor[$name]";
$checked = Array(1 => '', 2 => '');
$checked[ $FormValues[$Field] ] = ' checked';
if(!$FormValues[$Field]) $checked[1] = ' checked';
$ret = "<INPUT TYPE=RADIO NAME=\"$Field\" VALUE=\"1\" ".$checked[1].">".language("lu_and");
$ret .= "<INPUT TYPE=RADIO NAME=\"$Field\" VALUE=\"2\" ".$checked[2].">".language("lu_or");
return $ret;
}
}
return $ret;
}
}
class clsSearchConfigList
{
var $Module;
var $Items;
var $SourceTable;
var $classname;
var $adodbConnection;
function clsSearchConfigList($module=NULL)
{
$this->SourceTable = GetTablePrefix()."SearchConfig";
$this->classname = "clsSearchConfig";
$this->adodbConnection = &GetADODBConnection();
$this->Items = array();
if($module)
$this->LoadModule($module);
}
function Clear()
{
unset($this->Items);
$this->Items = array();
}
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);
}
function LoadModule($mod)
{
$this->Clear();
$this->Module = $mod;
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ModuleName ='$mod' ORDER BY DisplayOrder";
return $this->Query_Item($sql);
}
function GetNextDisplayOrder($mod)
{
$ret = 0;
$sql = "SELECT max(DisplayOrder) as do FROM ".$this->SourceTable." WHERE ModuleName='$mod'";
$rs = $this->adodbConnection->Execute($sql);
if($rs && !$rs->EOF)
$ret = $rs->fields["do"]+1;
return $ret;
}
function AddItemFromArray($data)
{
$class = new $this->classname;
$class->SetFromArray($data);
//foreach($data as $prop => $value)
// $class->Set($prop,$value);
array_push($this->Items,$class);
return $class;
}
function Query_Item($sql, $limit=NULL)
{
global $Errors;
if(isset($limit))
$result = $this->adodbConnection->SelectLimit($sql, $limit);
else
$result = $this->adodbConnection->Execute($sql);
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Query_Item");
return false;
}
$this->Clear();
while ($result && !$result->EOF)
{
$data = $result->fields;
$this->AddItemFromArray($data);
$result->MoveNext();
}
return $this->Items;
}
function GetItem($ID)
{
$found=FALSE;
if(is_array($this->Items))
{
foreach($this->Items as $i)
{
if($i->UniqueID()==$ID)
{
$found=TRUE;
break;
}
}
}
if(!$found)
{
$i = NULL;
$i = new $this->classname();
//$i->idfield = $i->IdField(); //set the id field before we change tables
$i->tablename = $this->SourceTable;
$i->LoadFromDatabase($ID);
array_push($this->Items, $i);
}
return $i;
}
function GetItemByName($Table,$Name)
{
$found=FALSE;
if(is_array($this->Items))
{
foreach($this->Items as $i)
{
if($i->Get("TableName")==$Table && $i->Get("FieldName")==$Name)
{
$found=TRUE;
break;
}
}
}
if(!$found)
{
$i = NULL;
$rs = $this->adodbConnection->Execute("SELECT * FROM ".$this->SourceTable." WHERE Tablename='$Table' AND FieldName='$Name'");
if($rs && !$rs->EOF)
{
$i = new $this->classname();
//$i->idfield = $i->IdField(); //set the id field before we change tables
$i->tablename = $this->SourceTable;
$i->SetFromArray($rs->fields);
}
array_push($this->Items, $i);
}
return $i;
}
function EditFieldSettings($FieldId,$SimpleSearch,$AdvancedSearch,$Priority)
{
$f = $this->GetItem($FieldId);
//echo "<PRE>"; print_r($f); echo "</PRE>";
$f->Set("SimpleSearch",(int)$SimpleSearch);
$f->Set("AdvancedSearch",(int)$AdvancedSearch);
$f->Set("Priority",(int)$Priority);
$f->Update();
return $f;
}
function &AddSearchField($Table,$FieldName,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder=0,
$Priority=0,$FieldType="text",$JoinClause=NULL,$IsWhere=NULL,$IsNotWhere=NULL,$ContainsWhere=NULL,$NotContainsWhere=NULL,$CustomId=0, $ForeignField = NULL)
{
$f = new clsSearchConfig();
if($DisplayOrder==0)
$DisplayOrder = $this->GetNextDisplayOrder($Module);
$f->Set(Array("TableName","ModuleName","SimpleSearch","AdvancedSearch","Description","DisplayName","ConfigHeader",
"DisplayOrder","Priority","FieldType","FieldName", "ForeignField"),
Array($Table,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder,$Priority,$FieldType,$FieldName, $ForeignField));
$f->Set("CustomFieldId",$CustomId);
if(strlen($JoinClause))
$f->Set("JoinClause",$JoinClause);
if(strlen($IsWhere))
$f->Set("IsWhere",$IsWhere);
if(strlen($IsNotWhere))
$f->Set("IsNotWhere",$IsNotWhere);
if(strlen($ContainsWhere))
$f->Set("ContainsWhere",$ContainsWhere);
if(strlen($NotContainsWhere))
$f->Set("NotContainsWhere",$NotContainsWhere);
$f->Create();
return $f;
}
function GetHeadingList()
{
$res = array();
foreach($this->Items as $i)
{
$header = $i->Get("ConfigHeader");
$res[$header]=1;
}
reset($res);
return array_keys($res);
}
function GetHeadingItems($heading)
{
$res = array();
foreach($this->Items as $i)
{
if($i->Get("ConfigHeader")==$heading)
array_push($res,$i);
}
return $res;
}
}
?>
Property changes on: trunk/kernel/include/searchconfig.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/kernel/include/advsearch.php
===================================================================
--- trunk/kernel/include/advsearch.php (revision 1107)
+++ trunk/kernel/include/advsearch.php (revision 1108)
@@ -1,206 +1,264 @@
<?php
class clsAdvancedSearchResults extends clsItemCollection
{
var $ResultTable;
var $FieldList;
var $FieldWeight;
var $WhereClauses;
var $SourceTable;
var $Relationships;
var $Ignored_Words;
var $CatClause;
var $Keywords;
var $Phrase = "";
var $SearchType;
var $RequiredRelevance;
var $PctRelevance;
var $PctPop;
var $PctRating;
function clsAdvancedSearchResults($SearchSource,$DataClass, $ItemType = 0)
{
global $objConfig, $objSearchConfig;
$this->clsItemCollection();
$this->SourceTable = $SearchSource;
$this->SetResultTable($SearchSource,$DataClass);
$this->FieldList = array();
$this->Relationships = array();
$this->Ignored_Words = array();
$this->WhereClauses = array();
$this->FieldWeight = array();
$this->Keywords = GetKeywords("");
$this->SearchType = 0; //simple
$this->RequiredRelevance=0;
$this->PctRelevance = $objConfig->Get("SearchRel_DefaultKeyword")/100;
$this->PctPop = $objConfig->Get("SearchRel_DefaultPop")/100;
$this->PctRating = $objConfig->Get("SearchRel_DefaultRating")/100;
if(!is_object($objSearchConfig))
$objSearchConfig = new clsSearchConfigList();
$objSearchConfig->Clear();
if ($ItemType == 0) {
$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);
}
}
function SetResultTable($SearchSource,$DataClass)
{
global $objSession;
//$this->ResultTable = $objSession->GetSessionKey()."_Search";
$this->ResultTable = $objSession->GetSessionTable('Search', '');
$this->classname= $DataClass;
}
function LoadSearchResults($Start=0,$PerPage=NULL)
{
if($PerPage)
{
$limit = "LIMIT $Start,$PerPage";
}
$sql = "SELECT * FROM ".$this->ResultTable." ".$limit;
$this->Clear();
$rs = $this->adodbConnection->Execute($sql);
return $this->Query_Item($sql);
}
function SetCategoryClause($whereclause)
{
$this->CatClause=$whereclause;
}
function AddRelationship($JoinTable,$JoinExpression=NULL)
{
$this->Relationships[$JoinTable]=$JoinExpression;
}
function SetKeywords($keywords)
{
$this->Phrase=$keywords;
$this->keywords = GetKeywords($keywords);
}
function AddAdvancedField($TableName,$FieldName,$Verb,$Value,$conj)
{
global $objSearchConfig;
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"));
$Table = $parts[0];
$Table = AddTablePrefix($Table);
$Field = $parts[1];
$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;
$FieldItem["weight"] = $FieldConfig->Get("Priority");
}
else
{
$FieldItem = array();
$FieldItem["Table"] = AddTablePrefix($TableName);
$FieldItem["Field"] = $FieldName;
$FieldItem["where"] = $FieldConfig->GetWhereClause($Verb,$Value);
$FieldItem["conjuction"] = $conj;
$FieldItem["weight"] = $FieldConfig->Get("Priority");
}
$this->FieldList[] = $FieldItem;
unset($FieldItem);
}
}
+
+/* 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()
{
$where = "";
foreach($this->FieldList as $f)
$where .= " (".$f["where"].") ".$f["conjuction"];
$cut_length = substr($where, -2) == 'OR' ? 2 : substr($where, -3) == 'AND' ? 3 : 0;
$where = substr($where, 0, strlen($where) - $cut_length);
return $where;
}
-
+
function PerformSearch($ItemType,$OrderBy=NULL,$InitTable=FALSE, $idlist=NULL)
{
static $SelectSQL, $OldItemType;
global $objSession, $objItemTypes;
$ctype = $objItemTypes->GetItem($ItemType);
$idField = $ctype->Get("SourceTable")."Id";
$this->SourceTable = AddTablePrefix($ctype->Get("SourceTable"));
$result=0;
$PopField = $ctype->Get("PopField");
$RateField = $ctype->Get("RateField");
$typestr = str_pad($ItemType,2,"0",STR_PAD_LEFT);
$SelectSQL = "SELECT ".$this->SourceTable.".".$idField." as ItemId, ". $this->SourceTable.".Priority as Relevance, ".$this->SourceTable.".ResourceId, CONCAT($typestr) as ItemType, EditorsPick as EdPick FROM ".$this->SourceTable." ";
foreach($this->Relationships as $JoinTable=>$OnClause)
{
$SelectSQL .= "LEFT JOIN $JoinTable ON ($OnClause) ";
}
$first=1;
$WhereClause = $this->BuildWhereClause();
if(strlen($WhereClause)>0)
{
$SelectSQL .= " WHERE ".$WhereClause;
}
$SelectSQL .= " GROUP BY $idField ";
//echo $SelectSQL;
$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$this->ResultTable);
$full_sql = "CREATE TABLE ".$this->ResultTable." ".$indexSQL.$SelectSQL;
$this->adodbConnection->Execute($full_sql);
// if advanced seaech used, then delete simple search keywords
$objSession->SetVariable('Search_Keywords', '');
//print_pre($full_sql);
}
function BuildIndexes()
{
$sql = "ALTER TABLE ".$this->ResultTable." ADD INDEX (Relevance), ";
$sql .="ADD INDEX (ItemId), ";
$sql .="ADD INDEX (ItemType), ";
$sql .=" ADD INDEX sorting (EdPick,Relevance)";
$this->adodbConnection->Execute($sql);
}
function Result_IdList()
{
/* returns an array contain a resource ID list */
$sql = "SELECT DISTINCT(ResourceId) FROM ".$this->ResultTable;
$rs = $this->adodbConnection->Execute($sql);
$result = array();
while($rs && !$rs->EOF)
{
$result[] = $rs->fields["ResourceId"];
$rs->MoveNext();
}
return $result;
}
function SetRelevence($ItemType, $IdField)
{
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/include/advsearch.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/kernel/frontaction.php
===================================================================
--- trunk/kernel/frontaction.php (revision 1107)
+++ trunk/kernel/frontaction.php (revision 1108)
@@ -1,1017 +1,1034 @@
<?php
switch($Action)
{
case "m_login":
// if($objSession->ValidSession()) $objSession->Logout();
//echo $objSession->GetSessionKey()."<br>\n";
if ($objConfig->Get("CookieSessions") == 1 && $_COOKIE["CookiesTest"] != "1") {
$FormError["login"]["login_user"] = language("lu_cookies_error");
}
else
{
$MissingCount = SetMissingDataErrors("login");
if($MissingCount==2)
{
$FormError["login"]["login_user"]= language("lu_ferror_loginboth");
unset($FormError["login"]["login_password"]);
}
if($MissingCount==0)
{
if($_POST["login_user"]=="root")
{
$FormError["login"]["login_user"]= language("lu_access_denied");
}
else
{
$LoginCheck = $objSession->Login( $_POST["login_user"], md5($_POST["login_password"]) );
if($LoginCheck === true)
{
if( !headers_sent() && GetVar('usercookie') == 1 )
{
$c = $_POST["login_user"]."|";
$pw = $_POST["login_password"];
if(strlen($pw) < 31) $pw = md5($pw);
$c .= $pw;
setcookie("login",$c,time()+2592000);
}
// set new destination template if passed
$dest = GetVar('dest', true);
if(!$dest) $dest = GetVar('DestTemplate', true);
if($dest) $var_list['t'] = $dest;
}
else
{
switch($LoginCheck)
{
case -1: // user or/and pass wrong
$FormError["login"]["login_password"] = language("lu_incorrect_login");
break;
case -2: // user ok, but has no permission
$FormError["login"]["login_password"] = language("la_text_nopermissions");
break;
}
}
}
}
}
break;
case "m_resetpw":
$passed_key = $_GET['user_key'];
$u = $objUsers->GetItemByField("PwResetConfirm", $passed_key);
$found = is_object($u);
if($found)
{
$exp_time = $u->Get('PwRequestTime') + 3600;
$u->Set("PwResetConfirm", '');
$u->Set("PwRequestTime", 0);
if ($exp_time > mktime())
{
$m_var_list_update['codevalidationresult'] = 'lu_resetpw_confirm_text';
$newpw = makepassword();
$objSession->Set('password', $newpw);
$u->Set("Password",$newpw);
$u->Set("PassResetTime", time());
$u->Set("PwResetConfirm", '');
$u->Set("PwRequestTime", 0);
$u->Update();
$u->SendUserEventMail("USER.PSWD",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.PSWD");
$u->Set("Password",md5($newpw));
$u->Update();
$u->Clean();
} else {
$m_var_list_update['codevalidationresult'] = 'lu_code_expired';
}
} else {
$m_var_list_update['codevalidationresult'] = 'lu_code_is_not_valid';
}
break;
case "m_forgotpw":
$MissingCount = SetMissingDataErrors("forgotpw");
// $pass_reset_add = $objConfig->Get("Users_AllowReset");
if($MissingCount==0)
{
$username = $_POST["username"];
$email = $_POST["email"];
$found = false;
$allow_reset = true;
if(strlen($username))
{
$u = $objUsers->GetItemByField("Login",$username);
if(is_object($u))
$found = ($u->Get("Login")==$username && $u->Get("Status")==1) && strlen($u->Get("Password"));
}
else if(strlen($email))
{
$u = $objUsers->GetItemByField("Email",$email);
if(is_object($u))
$found = ($u->Get("Email")==$email && $u->Get("Status")==1) && strlen($u->Get("Password"));
}
if(is_object($u))
{
$PwResetConfirm = $u->Get('PwResetConfirm');
$PwRequestTime = $u->Get('PwRequestTime');
$PassResetTime = $u->Get('PassResetTime');
$MinPwResetDelay = $u->Get('MinPwResetDelay');
$allow_reset = (strlen($PwResetConfirm) ?
mktime() > $PwRequestTime + $MinPwResetDelay :
mktime() > $PassResetTime + $MinPwResetDelay);
}
if($found && $allow_reset)
{
//$newpw = makepassword();
//$objSession->Set('password', $newpw);
$objSession->Set('tmp_user_id', $u->Get("PortalUserId"));
$objSession->Set('tmp_email', $u->Get("Email"));
//$u->Set("Password",$newpw);
//$u->Update();
$u->SendUserEventMail("USER.PSWDC",$u->Get("PortalUserId"));
//$u->SendAdminEventMail("USER.PSWDC");
//$u->Set("Password",md5($newpw));
//$u->Update();
$u->Clean();
}
else
{
if(!strlen($username) && !strlen($email))
{
$FormError["forgotpw"]["username"] = language("lu_ferror_forgotpw_nodata");
$MissingCount++;
}
else
{
$error_phrases=Array();
if($allow_reset)
{
$error_phrases['username']='lu_ferror_unknown_username';
$error_phrases['email']='lu_ferror_unknown_email';
}
else
{
$error_phrases['username']='lu_ferror_reset_denied';
$error_phrases['email']='lu_ferror_reset_denied';
}
foreach ($error_phrases as $field_name => $phrase_name) {
if(GetVar($field_name))
{
$FormError["forgotpw"][$field_name] = language($phrase_name);
break;
}
}
$MissingCount++;
}
if(strlen($_GET["error"]))
$var_list["t"] = $_GET["error"];
}
}
else
if(strlen($_GET["error"]))
$var_list["t"] = $_GET["error"];
break;
case "m_subscribe_confirm":
$t = "";
$SubscribeAddress = $_POST["subscribe_email"];
if(!ValidEmail($SubscribeAddress)&& strlen($SubscribeAddress))
{
$t = $_GET["Error"];
$SubscribeError = "lu_invalid_emailaddress";
}
else
{
if((int)$objConfig->Get("User_SubscriberGroup")>0)
{
$g = $objGroups->GetItem($objConfig->Get("User_SubscriberGroup"));
if(is_object($g))
{
$email = $_POST["subscribe_email"];
if(strlen($email)>0)
{
$u = $objUsers->GetItemByField("Email",$email);
if(is_object($u))
{
if($u->CheckBanned())
{
$t = $_GET["Error"];
$SubscribeError ="lu_subscribe_banned";
}
else
{
if($u->IsInGroup($g->Get("GroupId")))
{
$t = $_GET["Unsubscribe"];
}
else
$t = $_GET["Subscribe"];
}
}
else
$t = $_GET["Subscribe"];
}
else
{
$t = $_GET["Error"];
$SubscribeError ="lu_subscribe_no_address";
}
}
else
{
$t = $_GET["Error"];
$SubscribeError ="lu_subscribe_unknown_error";
}
}
}
if(strlen($t))
{
$var_list["t"] = $t;
$var_list_update["t"] = $t;
}
break;
case "m_subscribe":
//phpinfo(INFO_VARIABLES);
if($_POST["buttons"][0]==language("lu_button_yes"))
{
$SubscribeAddress = $_POST["subscribe_email"];
if(strlen($SubscribeAddress)>0)
{
if(ValidEmail($SubscribeAddress))
{
$GroupId = (int)$objConfig->Get("User_SubscriberGroup");
if ($GroupId)
{
$g = $objGroups->GetItem($GroupId);
$u = $objUsers->GetItemByField("Email",$SubscribeAddress);
if(is_object($u))
{
if(strtolower($u->Get("Email"))==strtolower($SubscribeAddress))
{
$bExists = TRUE;
}
else
$bExists = FALSE;
}
if($bExists)
{
$g->AddUser($u->Get("PortalUserId"),0,false);
}
else
{
$u = new clsPortalUser(NULL);
$u->Set("Email",$SubscribeAddress);
$u->Set("ip",$_SERVER['REMOTE_ADDR']);
$u->Set("CreatedOn",date("U"));
$u->Set("Status",1);
if(!$u->CheckBanned())
{
$u->Create();
$g->AddUser($u->Get("PortalUserId"),1,false);
}
else
$SubscribeResult = "lu_subscribe_banned";
}
$SubscribeResult = "lu_subscribe_success";
$u->SendUserEventMail("USER.SUBSCRIBE",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.SUBSCRIBE");
if(strlen($_GET["Subscribe"])>0)
$var_list["t"] = $_GET["Subscribe"];
}
}
else
{
$SubscribeResult = "lu_invalid_emailaddress";
}
}
else
$SubscribeResult = "lu_subscribe_missing_address";
}
if(!strlen($SubscribeResult))
$SubscribeResult = "lu_subscribe_success";
break;
case "m_unsubscribe":
if($_POST["buttons"][0]==language("lu_button_yes"))
{
$MissingCount = SetMissingDataErrors("m_unsubscribe");
if($MissingCount==0)
{
$email = $_POST["subscribe_email"];
$u = $objUsers->GetItemByField("Email",$email);
if(is_object($u))
{
if(strtolower($u->Get("Email"))==strtolower($email))
{
$GroupId = (int)$objConfig->Get("User_SubscriberGroup");
if($u->PrimaryGroup()==$GroupId)
{
$u_gorup_list = $u->GetGroupList();
if (count($u_gorup_list) > 1) {
$u->RemoveFromGroup($GroupId);
}
else {
$u->RemoveFromAllGroups();
$u->Delete();
}
}
else
{
$u->RemoveFromGroup($GroupId);
}
}
}
if(strlen($_GET["Subscribe"])>0)
$var_list["t"] = $_GET["Subscribe"];
}
}
break;
case "m_logout":
// $objSession->Logout();
//unset($objSession);
//$objSession = new clsUserSession();
// $var_list_update["t"] = "index";
// setcookie("login","",time()-3600);
break;
case "m_register":
$_POST=inp_escape($_POST);
$MissingCount = SetMissingDataErrors("m_register");
if(!$objConfig->Get("User_Password_Auto"))
{
if(($_POST["password"] != $_POST["passwordverify"]) || !strlen($_POST["passwordverify"]))
{
$MissingCount++;
$FormError["m_register"]["passwordverify"] = language("lu_ferror_pswd_mismatch");
}
if(strlen($_POST["password"])>30)
{
// echo "VAR: ".$_POST["password"]; die();
$MissingCount++;
$FormError["m_register"]["password"] = language("lu_ferror_pswd_toolong");
}
if (strlen($_POST['password']) < $objConfig->Get("Min_Password"))
{
$MissingCount++;
$FormError["m_register"]["password"] = language("lu_ferror_pswd_tooshort");
}
}
$u = $objUsers->GetItemByField("Login",$_POST["username"]);
if(is_object($u))
{
if($u->Get("Login")==$_POST["username"])
{
$MissingCount++;
$FormError["m_register"]["username"] = language("lu_user_exists");
}
}
if (strlen($_POST['username']) < $objConfig->Get("Min_UserName"))
{
$MissingCount++;
$FormError["m_register"]["username"] = language("lu_ferror_username_tooshort");
}
if(!$MissingCount)
{
$CreatedOn = adodb_date("U");
$GroupId = $objConfig->Get("User_NewGroup");
$Status=0;
/* determine the status of new users */
switch ($objConfig->Get("User_Allow_New"))
{
case "1":
$Status=1;
break;
case "3":
$Status=2;
break;
}
/* set Destination template */
$var_list["t"] = strlen($_GET["dest"])? $_GET["dest"] : "index";
if($Status>0)
{
if($objConfig->Get("User_Password_Auto"))
{
$password = makepassword();
$objSession->Set("password", $password);
}
else
$password = $_POST["password"];
$_POST["dob"] = $_POST["dob_month"]."/".$_POST["dob_day"]."/".$_POST["dob_year"];
$dob = DateTimestamp($_POST["dob"],GetDateFormat());
$ip = $_SERVER['REMOTE_ADDR'];
$u = &$objUsers->Add_User($_POST["username"], md5($password), $_POST["email"], $CreatedOn, $_POST["firstname"], $_POST["lastname"], $Status, $_POST["phone"], $_POST["street"], $_POST["city"], $_POST["state"], $_POST["zip"], $_POST["country"], $dob, $ip, TRUE);
if(!is_object($u))
{
$RuleId=$u;
$r = $objBanList->GetItem($RuleId);
$err = $r->Get("ErrorTag");
if(strlen($err))
{
$FormError["m_register"][$r->Get("ItemField")] = language($err);
$MissingCount++;
}
}
else
{
$u->Set("Password",$password);
$u->Clean();
if($GroupId>0)
{
$g = $objGroups->GetItem($GroupId);
$g->AddUser($u->Get("PortalUserId"),1,false);
}
$custom = $_POST["custom"];
if(is_array($custom))
{
for($x=0;$x<count($custom);$x++)
{
$u->SetCustomField($custom[$x],$_POST[$custom[$x]]);
}
$u->SaveCustomFields();
}
if($Status==1)
{
if($objConfig->Get("User_Password_Auto"))
{
$u->SendUserEventMail("USER.VALIDATE",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.VALIDATE");
}
else
{
$doLoginNow = true;
$u->SendUserEventMail("USER.ADD",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.ADD");
}
}
else
{
$u->SendUserEventMail("USER.ADD.PENDING",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.ADD.PENDING");
}
if ($doLoginNow)
$objSession->Login($_POST["username"], md5($password));
}
}
}
break;
case "m_add_friend":
$id = $_GET["UserId"];
$userid = $objSession->Get("PortalUserId");
if($id!=$userid)
{
$u =& $objUsers->GetItem($id);
$u->AddFavorite($userid);
}
DeleteModuleTagCache('kernel');
break;
case "m_del_friend":
$id = $_GET["UserId"];
$userid = $objSession->Get("PortalUserId");
$u =& $objUsers->GetItem($id);
$u->DeleteFavorite();
DeleteModuleTagCache('kernel');
break;
case "m_acctinfo":
// phpinfo(INFO_VARIABLES);
$_POST=inp_escape($_POST);
$MissingCount = SetMissingDataErrors("m_acctinfo");
$UserId = $_GET["UserId"];
if($UserId != $objSession->Get("PortalUserId"))
{
$MissingCount++;
$FormError["m_acctinfo"]["UserId"] = language("lu_ferror_m_profile_userid");
}
if(strlen($_POST["password"])>0)
{
if(($_POST["password"] != $_POST["passwordverify"]) || !strlen($_POST["passwordverify"]))
{
$MissingCount++;
$FormError["m_acctinfo"]["passwordverify"] = language("lu_ferror_pswd_mismatch");
}
if(strlen($_POST["password"])>30)
{
// echo "VAR: ".$_POST["password"]; die();
$MissingCount++;
$FormError["m_acctinfo"]["password"] = language("lu_ferror_pswd_toolong");
}
if (strlen($_POST['password']) < $objConfig->Get("Min_Password"))
{
$MissingCount++;
$FormError["m_acctinfo"]["password"] = language("lu_ferror_pswd_tooshort");
}
}
if(!$MissingCount)
{
/* save profile */
$u =& $objUsers->GetItem($UserId);
$status = $u->Get("Status");
$_POST["dob"] = $_POST["dob_month"]."/".$_POST["dob_day"]."/".$_POST["dob_year"];
$dob = DateTimestamp($_POST["dob"], GetDateFormat());
if(strlen($_POST["password"])>0)
{
$password = md5($_POST["password"]);
}
else
$password = "";
$objUsers->Edit_User($UserId, $_POST["username"], $password, $_POST["email"], 0,
$_POST["firstname"], $_POST["lastname"], $status, $_POST["phone"],
$_POST["street"], $_POST["city"], $_POST["state"], $_POST["zip"],
$_POST["country"], $dob, $_POST['MinPwResetDelay']);
$ResourceId= $u->Get("ResourceId");
$objCustomDataList->LoadResource($ResourceId);
$objCustomFields = new clsCustomFieldList(6);
for($i=0;$i<$objCustomFields->NumItems(); $i++)
{
$field = & $objCustomFields->GetItemRefByIndex($i);
$fieldid= $field->Get("CustomFieldId");
$fname = $field->Get("FieldName");
if(isset($_POST[$fname]))
$objCustomDataList->SetFieldValue($fieldid,$ResourceId,$_POST[$fname]);
elseif(isset($_POST[strtolower($fname)]))
$objCustomDataList->SetFieldValue($fieldid,$ResourceId,$_POST[strtolower($fname)]);
}
$objCustomDataList->SaveData();
}
DeleteModuleTagCache('kernel');
break;
case "m_profile":
$userid = $objSession->Get("PortalUserId");
if($userid>0)
{
$u = $objUsers->GetItem($userid);
foreach($_POST as $field=>$value)
{
if(substr($field,0,3)=="pp_")
{
$objSession->SetPersistantVariable($field,$value);
}
}
}
break;
case "m_set_lang":
$lang = $_GET["lang"];
$LangId = 0;
if(strlen($lang))
{
$l = $objLanguages->GetItemByField("PackName",$lang);
if(is_object($l))
{
$LangId = $l->Get("LanguageId");
}
}
if($LangId)
{
if($objSession->Get("PortalUserId")>0)
{
$objSession->SetPersistantVariable("Language",$LangId);
}
$objSession->Set("Language",$LangId);
$objSession->Update();
$m_var_list_update["lang"] = $LangId;
$m_var_list["lang"] = $LangId;
}
break;
case "m_set_theme":
$id = $_POST["ThemeId"];
if(!is_numeric($id))
$id = $_GET["ThemeId"];
if($id)
{
$objSession->SetThemeName($id);
$m_var_list["t"] = "index";
$m_var_list_update["theme"] = $id;
$m_var_list["theme"] = $id;
unset($CurrentTheme);
}
break;
case "m_sort_cats":
$objSession->SetVariable("Category_Sortfield",$_POST["Category_Sortfield"]);
$objSession->SetVariable("Category_Sortorder",$_POST["Category_Sortorder"]);
$objSession->SetVariable("Perpage_Category",$_POST["Perpage_Category"]);
DeleteModuleTagCache('kernel');
break;
case "m_add_cat_confirm":
$perm = 0;
$CategoryId=$objCatList->CurrentCategoryID();
if ($objSession->HasCatPermission("CATEGORY.ADD.PENDING"))
$perm = 2;
if ($objSession->HasCatPermission("CATEGORY.ADD"))
$perm = 1;
if ($perm == 0)
{
$MissingCount++;
$FormError["m_addcat"]["name"] = language("lu_ferror_no_access");
}
else
{
$MissingCount = SetMissingDataErrors("m_addcat");
if(is_array($_FILES))
{
foreach($_FILES as $field => $file)
{
$allowed = TRUE;
if(strlen($_POST["imagetypes"][$field]))
{
$types = explode(",",strtolower($_POST["imagetypes"][$field]));
if(is_array($types))
{
if(count($types)>0)
{
$path_parts = pathinfo($file["name"]);
$ext = $path_parts["extension"];
$allowed = in_array($ext,$types);
if(!$allowed)
{
$MissingCount++;
$FormError["m_addcat"][$field] = language("lu_ferror_wrongtype");
}
}
}
}
$maxsize = (int)$_POST["maxsize"][$field];
if($maxsize>0 && $allowed && $file["size"]>$maxsize)
{
$allowed = FALSE;
$MissingCount++;
$FormError["m_addcat"][$field] = language("lu_ferror_toolarge");
}
}
}
if($MissingCount==0)
{
$CreatedOn = date("U");
$_POST=inp_striptags($_POST);
$name = $_POST["name"];
$desc = $_POST["description"];
$metadesc = $_POST["meta_description"];
$keywords = $_POST["meta_keywords"];
$parent = $objCatList->CurrentCategoryID();
$cat =& $objCatList->Add($parent, $name, $desc, $CreatedOn,
0, $perm, 2, 2, 2, 0, $keywords,$metadesc);
$CatResourceId= $cat->Get('ResourceId');
$objCustomFields = new clsCustomFieldList($cat->type);
$field_list = $objCustomFields->Query_CustomField('Type='.$cat->type);
for($i=0;$i<$objCustomFields->NumItems(); $i++)
{
$field = & $objCustomFields->GetItemRefByIndex($i);
$fieldid= $field->Get('CustomFieldId');
$fname = $field->Get('FieldName');
if(isset($_POST[$fname]))
{
$objCustomDataList->SetFieldValue($fieldid,$CatResourceId,$_POST[$fname]);
}
elseif(isset($_POST[strtolower($fname)]))
{
$objCustomDataList->SetFieldValue($fieldid,$CatResourceId,$_POST[strtolower($fname)]);
}
}
$objCustomDataList->SaveData();
$cat->UpdateCachedPath();
$cat->Update();
$cat->UpdateACL();
$objCatList->UpdateMissingCacheData();
if(strlen($_GET["Confirm"]))
{
$var_list["t"] = $_GET["Confirm"];
}
else
$var_list["t"] = $_GET["DestTemplate"];
}
}
DeleteModuleTagCache('kernel');
break;
case "m_front_review_add":
if($objSession->InSpamControl($_POST["ItemId"]))
{
$StatusMessage["review"] = language("la_Review_AlreadyReviewed");
}
else
{
$objReviews = new clsItemReviewList();
$Status = $objConfig->Get("Review_DefaultStatus");
$CreatedOn = adodb_date("U");
$html = (int)$objConfig->Get("Review_Html");
$ReviewText = inp_striptags($_POST["review_text"]);
$r = $objReviews->AddReview($CreatedOn,$ReviewText,$Status, $IPAddress,
0, $_POST["ItemId"], $_POST["ItemType"], $objSession->Get("PortalUserId"));
foreach($ItemTypes as $type=>$id)
{
if($id==$_POST["ItemType"])
{
$ValName = $type."_ReviewDelay_Value";
$IntName = $type."_ReviewDelay_Interval";
break;
}
}
if(strlen($ValName) && strlen($IntName))
{
$exp_secs = $objConfig->Get($ValName) * $objConfig->Get($IntName);
$objSession->AddToSpamControl($_POST["ItemId"],$exp_secs);
if(is_object($r))
{
if($Status)
{
$StatusMessage["review"] = language("la_Review_Added");
}
else
$StatusMessage["review"] = language("la_Review_Pending");
}
else
$StatusMessage["review"] = language("la_Review_Error");
}
else
$StatusMessage["error"] = language("la_ConfigError_Review");
}
DeleteModuleTagCache('kernel');
break;
case "m_suggest_email":
$cutoff = time()+(int)$objConfig->Get("Suggest_MinInterval");
$email = inp_striptags($_POST["suggest_email"]);
if (strlen($email))
{
if(ValidEmail($email))
{
$sql = "SELECT * FROM ".GetTablePrefix()."SuggestMail WHERE email='".$email."' and sent<".$cutoff;
$adodbConnection = &GetADODBConnection();
$rs = $adodbConnection->Execute($sql);
$rs = false;
if($rs && !$rs->EOF)
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$suggest_result = "$email ".language("lu_already_suggested ")." ".LangDate($rs->fields["sent"]);
}
else
{
$Event =& $objMessageList->GetEmailEventObject("USER.SUGGEST");
if(is_object($Event))
{
if($Event->Get("Enabled")=="1")
{
$Event->Item = $this;
$Event->SendToAddress($email);
$sql = "INSERT INTO ".GetTablePrefix()."SuggestMail (email,sent) VALUES ('".$email."','".time()."')";
$rs = $adodbConnection->Execute($sql);
$suggest_result=language("lu_suggest_success")." ".$email;
}
}
$e =& $objMessageList->GetEmailEventObject("USER.SUGGEST",1);
if($e->Get("Enabled")==1)
$e->SendAdmin();
if(strlen($_GET["Confirm"])>0)
$var_list["t"] = $_GET["Confirm"];
}
}
else
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$suggest_result=language("lu_invalid_emailaddress");
}
}
else
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$suggest_result=language("lu_suggest_no_address");
}
break;
case "m_simple_search":
$keywords = trim($_POST["keywords"]);
$type = $objItemTypes->GetTypeByName("Category");
$objSearch = new clsSearchResults("Category","clsCategory");
$length = $objConfig->Get('Search_MinKeyword_Length');
if(strlen($keywords))
{
$performSearch = false;
$isExact = (substr($keywords, 0, 2) == '\"' && substr($keywords, strlen($keywords) - 2, 2) == '\"');
if ($isExact) {
$performSearch = (strlen(trim(str_replace('\"', '', $keywords))) >= $length);
}
else {
$key_arr = explode(' ', $keywords);
/*foreach($key_arr as $value) {
if (strlen(str_replace("+", "", $value)) < $length || strlen(str_replace("-", "", $value)) < $length) {
$keywords = str_replace($value, '', $keywords);
//$keywords = str_replace($value, '', $keywords);
}
}
//$keywords = str_replace(' ', ' ', $keywords);
//$keywords = str_replace('\"', '', $keywords);
*/
$tmp_keywords = str_replace("+", "", $keywords);
$tmp_keywords = str_replace("-", "", $tmp_keywords);
$performSearch = (strlen($tmp_keywords) >= $length);
}
if ($performSearch) {
$objSearchList = new clsSearchLogList();
$objSearchList->UpdateKeyword($keywords,0);
$objSearch->SetKeywords($keywords);
$objSearch->AddSimpleFields();
if(is_numeric($objConfig->Get("SearchRel_Pop_category")))
$objSearch->PctPop = ($objConfig->Get("SearchRel_Pop_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Keyword_category")))
$objSearch->PctRelevance = ($objConfig->Get("SearchRel_Keyword_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Rating_article")))
$objSearch->PctRating = ($objConfig->Get("SearchRel_Rating_category")/100);
//echo "Searching On $keywords<br>\n";
$objSearch->PerformSearch(1,$SortOrder,TRUE);
$SearchPerformed = TRUE;
//$objSearch->SetRelevence($type->Get("ItemType"), "CategoryId");
//echo "Finished Setting Category Relevence<br>\n";
}
else {
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$MissingCount = SetMissingDataErrors("m_simplesearch");
$MissingCount++;
$FormError["m_simplesearch"]["keywords"] = language("lu_keywords_tooshort");
}
}
else
{
if(strlen($_GET["Error"])>0)
$var_list["t"] = $_GET["Error"];
$MissingCount = SetMissingDataErrors("m_simplesearch");
$MissingCount++;
$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 */
//echo "Searching for categories<br>";
$objAdvSearch = new clsAdvancedSearchResults("Category","clsCategory", $_GET["type"]);
foreach($objSearchConfig->Items as $field)
{
$fld = $field->Get("FieldName");
$Verb = $_POST["verb"][$field->Get("FieldName")];
if(!strlen($Verb) && $field->Get("FieldType")=="boolean")
{
if($_POST["value"][$field->Get("FieldName")]!=-1)
{
$Value = $_POST["value"][$field->Get("FieldName")];
$Verb = "is";
}
}
else
{
$Value = $_POST["value"][$field->Get("FieldName")];
}
switch( $_POST["andor"][$field->Get("FieldName")])
{
case 1:
$Conjuction = "AND";
break;
case 2:
$Conjuction = "OR";
break;
default:
$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]<br>";
$objAdvSearch->AddAdvancedField($field->Get("TableName"),$field->Get("FieldName"),$Verb,$Value,$Conjuction);
}
}
$objAdvSearch->PerformSearch(1,NULL,TRUE);
break;
}
break;
case "m_id":
echo $Action.":".$DownloadId;
die();
break;
case "m_simple_subsearch":
$keywords = $_POST["keywords"];
$type = $objItemTypes->GetTypeByName("Category");
$objSearch = new clsSearchResults("Category","clsCategory");
$length = $objConfig->Get('Search_MinKeyword_Length');
if(strlen($keywords))
{
$performSearch = false;
$isExact = (substr($keywords, 0, 1) == '"' && substr($keywords, strlen($keywords) - 1, 1) == '"');
if ($isExact) {
$performSearch = (strlen(trim(str_replace('\"', '', $keywords))) >= $length);
}
else {
$key_arr = explode(' ', $keywords);
/*foreach($key_arr as $value) {
if (strlen($value) < $length) {
$keywords = str_replace(' '.$value, '', $keywords);
$keywords = str_replace($value.' ', '', $keywords);
}
}*/
//$keywords = str_replace(' ', ' ', $keywords);
$tmp_keywords = str_replace("+", "", $keywords);
$tmp_keywords = str_replace("-", "", $tmp_keywords);
$performSearch = (strlen($tmp_keywords) >= $length);
}
if ($performSearch) {
$objSearchList = new clsSearchLogList();
$objSearchList->UpdateKeyword($keywords,0);
$objSearch->SetKeywords($keywords);
$objSearch->AddSimpleFields();
if(is_numeric($objConfig->Get("SearchRel_Pop_category")))
$objSearch->PctPop = ($objConfig->Get("SearchRel_Pop_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Keyword_category")))
$objSearch->PctRelevance = ($objConfig->Get("SearchRel_Keyword_category")/100);
if(is_numeric($objConfig->Get("SearchRel_Rating_article")))
$objSearch->PctRating = ($objConfig->Get("SearchRel_Rating_category")/100);
$SearchResultIdList = $objSearch->Result_IdList();
if(count($SearchResultIdList)>0)
{
$objSearch->PerformSearch(1,$SortOrder, TRUE,$SearchResultIdList);
//$objSearch->SetRelevence($type->Get("ItemType"), "CategoryId");
}
$SearchPerformed = TRUE;
}
else {
$MissingCount = SetMissingDataErrors("m_simplesearch");
$MissingCount++;
$FormError["m_simplesearch"]["keywords"] = language("lu_keywords_tooshort");
}
}
else {
$MissingCount = SetMissingDataErrors("m_simplesearch");
$MissingCount++;
$FormError["m_simplesearch"]["keywords"] = language("lu_no_keyword");
}
break;
}
?>
Property changes on: trunk/kernel/frontaction.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.44
\ No newline at end of property
+1.45
\ No newline at end of property
Index: trunk/themes/default/advsearch/alt_item_form.tpl
===================================================================
--- trunk/themes/default/advsearch/alt_item_form.tpl (revision 1107)
+++ trunk/themes/default/advsearch/alt_item_form.tpl (revision 1108)
@@ -1,5 +1,5 @@
<tr valign="top">
<td align="right" class="field-name"><inp:searchfield _Field="lang_name" /></td>
<td class="field-content"><inp:searchfield _Field="verb_select" /><br /><inp:searchfield _Field="form_input" /></td>
- <td class="field-content"><inp:searchfield _Field="andor_radio" /></td>
+ <td class="field-content"><nobr><inp:searchfield _Field="andor_radio" /></nobr></td>
</tr>
\ No newline at end of file
Property changes on: trunk/themes/default/advsearch/alt_item_form.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/themes/default/advsearch/item_form.tpl
===================================================================
--- trunk/themes/default/advsearch/item_form.tpl (revision 1107)
+++ trunk/themes/default/advsearch/item_form.tpl (revision 1108)
@@ -1,5 +1,5 @@
<tr valign="top">
<td align="right" class="field-name"><inp:searchfield _Field="lang_name" /></td>
<td class="field-content"><inp:searchfield _Field="verb_select" /><br /><inp:searchfield _Field="form_input" /></td>
- <td class="field-content"><inp:searchfield _Field="andor_radio" /></td>
+ <td class="field-content"><nobr><inp:searchfield _Field="andor_radio" /></nobr></td>
</tr>
\ No newline at end of file
Property changes on: trunk/themes/default/advsearch/item_form.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property

Event Timeline