Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 8:39 AM

in-portal

Index: trunk/kernel/include/searchitems.php
===================================================================
--- trunk/kernel/include/searchitems.php (revision 963)
+++ trunk/kernel/include/searchitems.php (revision 964)
@@ -1,741 +1,741 @@
<?php
/* search string syntax:
+<word> : <word> is required
-<word> : <word> cannot exist in the searched field
"word word" : contents between the quotes are treated as a single entity
+/-"word word" is supported
ignore words are not case sensitive
*/
class clsSearchLog extends clsItemDB
{
function clsSearchLog($id=NULL)
{
$this->clsItemDB();
$this->tablename = GetTablePrefix()."SearchLog";
$this->id_field = "SearchLogId";
$this->NoResourceId = 1;
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;
}
}
class clsSearchLogList extends clsItemCollection
{
var $Page;
var $PerPageVar;
function clsSearchLogList()
{
$this->clsItemCollection();
$this->SourceTable = GetTablePrefix()."SearchLog";
$this->classname = "clsSearchLog";
$this->Page=1;
$this->PerPageVar = "Perpage_SearchLog";
$this->AdminSearchFields = array("Keyword");
}
function UpdateKeyword($keyword,$SearchType)
{
$sql = "UPDATE ".$this->SourceTable." SET Indices = Indices+1 WHERE Keyword='$keyword' AND SearchType=$SearchType";
//echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
if($this->adodbConnection->Affected_Rows()==0)
{
//echo "Creating Keyword record..<br>\n";
$k = new clsSearchLog();
$k->Set("Keyword",$keyword);
$k->Set("Indices",1);
$k->Set("SearchType",$SearchType);
$k->Create();
}
}
function AddKeywords($Keywords)
{
if(is_array($Keywords))
{
for($i=0;$i<count($Keywords);$i++)
{
$this->UpdateKeyword($Keywords[$i]);
}
}
else
$this->UpdateKeyword($Keywords);
}
}
class clsEmailLog extends clsItemDB
{
function clsEmailLog($id=NULL)
{
$this->clsItemDB();
$this->tablename = GetTablePrefix()."SearchLog";
$this->id_field = "SearchLogId";
$this->NoResourceId = 1;
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;
}
}
class clsEmailLogList extends clsItemCollection
{
var $Page;
var $PerPageVar;
function clsEmailLogList()
{
$this->clsItemCollection();
$this->SourceTable = GetTablePrefix()."SearchLog";
$this->classname = "clsEmailLog";
$this->Page=1;
$this->PerPageVar = "Perpage_EmailsL";
$this->AdminSearchFields = array("event", "fromuser", "addressto", "subject");
}
function UpdateKeyword($keyword,$SearchType)
{
$sql = "UPDATE ".$this->SourceTable." SET Indices = Indices+1 WHERE Keyword='$keyword' AND SearchType=$SearchType";
//echo $sql."<br>\n";
$this->adodbConnection->Execute($sql);
if($this->adodbConnection->Affected_Rows()==0)
{
//echo "Creating Keyword record..<br>\n";
$k = new clsSearchLog();
$k->Set("Keyword",$keyword);
$k->Set("Indices",1);
$k->Set("SearchType",$SearchType);
$k->Create();
}
}
function AddKeywords($Keywords)
{
if(is_array($Keywords))
{
for($i=0;$i<count($Keywords);$i++)
{
$this->UpdateKeyword($Keywords[$i]);
}
}
else
$this->UpdateKeyword($Keywords);
}
}
class clsSearchResults 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 clsSearchResults($SearchSource,$DataClass)
{
global $objConfig;
$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;
}
function SetResultTable($SearchSource,$DataClass)
{
global $objSession;
$this->ResultTable = $objSession->GetSearchTable();
$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 AddSimpleCustomFields()
{
$sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND SimpleSearch=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 AddSimpleFields()
{
$sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND SimpleSearch=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->AddSimpleCustomFields();
}
function AddSearchWhereClause($FieldName)
{
$req_where = "";
/* build required keywords string */
if(count($this->keywords["required"])>0)
{
$required = $this->keywords["required"];
for($i=0;$i<count($required);$i++)
{
if(strlen($required[$i])>0)
{
if($i>0)
{
$or =" AND ";
}
else
$or = "";
$w .= $or." ".$FieldName." LIKE '%".$required[$i]."%'";
}
}
if(strlen($w)>0)
{
$req_where = "(". $w.")";
}
else
$req_where = "";
}
$w = "";
$not_where="";
if(count($this->keywords["notallowed"])>0)
{
$words = $this->keywords["notallowed"];
for($i=0;$i<count($words);$i++)
{
if(strlen($words[$i])>0)
{
if($i>0)
{
$or =" AND ";
}
else
$or = "";
$w .= $or." ".$FieldName." NOT LIKE '%".$words[$i]."%'";
}
}
if(strlen($w)>0)
{
$not_where = "(".$w.")";
}
else
$not_where = "";
}
$w="";
$normal = $this->keywords["normal"];
if(count($normal)>0)
{
for($i=0;$i<count($normal);$i++)
{
if (strlen($normal[$i])>0)
{
if($i>0)
{
$or =" OR ";
}
else
$or = "";
$w .= "$or $FieldName LIKE '%".$normal[$i]."%'";
}
}
if(count($required)>0)
$w .= " OR ";
for($i=0;$i<count($required);$i++)
{
if(strlen($required[$i])>0)
{
if($i>0)
{
$or = " OR ";
}
else
$or="";
$w .= "$or $FieldName LIKE '%".$required[$i]."%'";
}
}
if(strlen($w)>0)
{
$where = "(".$w.")";
}
else
$where = "";
}
$complete= BuildWhereClause($where,$req_where,$not_where);
$this->WhereClauses[$FieldName]="(".$complete.")";
$this->Ignored_Words=$this->keywords["ignored"];
}
function PerformSearch($ItemType,$OrderBy=NULL,$InitTable=FALSE, $idlist=NULL)
{
static $SelectSQL, $OldItemType;
global $objSession, $objItemTypes;
//echo "perfirming Simple Search<br>";
//echo "Old Item Type: $OldItemType New: $ItemType <br>\n";
if($ItemType != $OldItemType)
$SelectSQL = "";
$OldItemType = $ItemType;
$ctype = $objItemTypes->GetItem($ItemType);
$idField = $ctype->Get("SourceTable")."Id";
$this->SourceTable = GetTablePrefix().$ctype->Get("SourceTable");
$result=0;
$PopField = $ctype->Get("PopField");
- $RateField = $ctype->Get("RateField");
-
+ $RateField = $ctype->Get("RateField");
//print_pre($this->keywords);
if(!strlen($SelectSQL))
{
$typestr = str_pad($ItemType,2,"0",STR_PAD_LEFT);
$SelectSQL = "SELECT ";
$ifs = array();
$weightsum = 0;
foreach($this->FieldWeight as $w)
$weightsum += $w;
$wordcount = count($this->keywords["normal"])+count($this->keywords["required"]);
$single = ($wordcount == 1);
foreach($this->FieldList as $f)
{
$weight = (int)$this->FieldWeight[$f];
$s = array();
if(!$single)
{
$full = trim(implode(" ",$this->keywords["normal"]));
$s[] = " (IF ($f LIKE '%$full%', ".$weightsum.", 0))";
}
foreach($this->keywords["normal"] as $k)
{
if($k != $full || $single)
{
$temp = " (IF ($f LIKE '%$k%', ".$weight.", 0))";
$s[] = $temp;
}
}
foreach($this->keywords["required"] as $k)
{
if($this->RequiredRelevance>0)
$weight = $this->FieldWeight[$f] + ($this->FieldWeight[$f]*($this->RequiredRelevance/100));
if($k != $full || $single)
{
$s[] = " (IF ($f LIKE '%$k%', ".$weight.", 0))";
}
}
// echo "<PRE>";print_r($s); echo "</PRE>";
$txt = implode("+",$s);
//echo $txt."<br>\n";
$ifs[] = $txt;
unset($s);
}
// echo "<PRE>";print_r($ifs); echo "</PRE>";
/* add relevance formula for weighting hits & popularity */
if($weightsum==0)
$weightsum=1;
if(strlen($PopField)>0 && $this->PctPop>0)
{
$popcalc = " + ((($PopField + 1) / (max($PopField)+1)*".$this->PctPop."))";
}
else
$popcalc = "";
if(strlen($RateField)>0 && $this->PctRating>0)
{
$ratecalc = " + ((($RateField + 1) / (max($RateField)+1)*".$this->PctRating."))";
}
else
$ratecalc = "";
if($this->PctRelevance>0)
{
$relcalc = "(((".implode("+",$ifs).")/$weightsum)*".$this->PctRelevance.")";
}
else
$relcalc = "0";
$SelectSQL .= $relcalc.$popcalc.$ratecalc." as Relevance, ";
$SelectSQL .= $this->SourceTable.".".$idField." as ItemId, ".$this->SourceTable.".ResourceId as 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;
$where=0;
foreach($this->FieldList as $field)
{
if(strpos($field,"as")>0)
{
$fparts = explode("as",$field,2);
$f = $fparts[1];
$this->AddSearchWhereClause($field);
}
else {
$this->AddSearchWhereClause($field);
}
}
$SelectSQL .= " WHERE ";
$SelectSQL .= implode(" or ",$this->WhereClauses);
if(is_array($idlist))
{
$SelectSQL .= " AND (ResourceId IN (".implode(",",$idlist)."))";
}
}
$SelectSQL .= "GROUP BY $idField ";
//echo $SelectSQL."<br><br>\n";
if($InitTable)
{
$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$this->ResultTable);
//$indexSQL = "(INDEX(Relevance), INDEX(ItemId), INDEX(ItemType), INDEX sorting (EdPick,Relevance)) ";
$full_sql = "CREATE TABLE ".$this->ResultTable." ".$indexSQL.$SelectSQL;
//echo $full_sql."<br>\n";
$this->adodbConnection->Execute($full_sql);
//echo $this->adodbConnection->ErrorMsg()."<br>\n";
$objSession->SetVariable("Search_Keywords",$this->Phrase);
}
else
{
$full_sql = "INSERT INTO ".$this->ResultTable." (Relevance,ItemId,ResourceId,ItemType,EdPick) ".$SelectSQL;
//echo "[<b>".htmlspecialchars($full_sql)."</b>]<br>\n";
$this->adodbConnection->Execute($full_sql);
//echo $this->adodbConnection->ErrorMsg()."<br>\n";
}
//Here we need to remove found items which was found by HTML tags matching keywords
//$this->adodbConnection->Execute("DELETE FROM ".$this->ResultTable." WHERE ItemId = 13 AND ItemType = 4");
}
function BuildIndexes()
{
$sql = "ALTER TABLE ".$this->ResultTable." ADD INDEX (Relevance), ";
$sql .="ADD INDEX (ItemId), ";
$sql .="ADD INDEX (ItemType), ";
$sql .=" ADD INDEX sorting (EdPick,Relevance)";
//echo $sql;
$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 count_words($string)
{
// below line added to make contiguous spaces count as one space
if(strlen($string))
{
$string = eregi_replace(" +", " ", $string);
return substr_count($string," ")+1;
}
else
return 0;
}
function GetKeywords($phrase)
{
global $KeywordIgnore;
if(count($KeywordIgnore)==0)
GetIgnoreList();
$keywords["normal"]= array();
$keywords["required"]= array();
$keywords["notallowed"] = array();
$keywords["ignored"] = array();
if(!strlen($phrase))
return $keywords;
$w_array = array();
$phrase=trim($phrase);
//if(count_words($phrase)>1)
// $keywords["normal"][] = $phrase;
$t_len = strlen($phrase);
$ce=0;
for ($i=0; $i<$t_len; $i++)
{ #search for next special tag
switch ($phrase[$i])
{
case "\"":
$exact_match_close = strpos($phrase,"\"", $i+1);
if(!$exact_match_close)
break;
$exact_word=substr($phrase, $i+1, ($exact_match_close-$i)-1);
+ $exact_word = str_replace("\\", "", $exact_word);
$i=$exact_match_close;
if($exact_word)
{
if(strlen($token)==0)
$token="|";
$w_array[$ce]=$token.addslashes($exact_word);
$token="";
$ce++;
$exact_word="";
}
break;
case "+":
if(strlen($exact_word)==0)
{
$token = "+";
}
else
$exact_word .= "+";
break;
case "-":
if(strlen($exact_word)==0)
{
$token = "-";
}
else
$exact_word .="-";
break;
case " ":
case ",":
if($exact_word)
{
if(strlen($token)==0)
$token="|";
if($token=="|")
{
if($KeywordIgnore[strtolower($exact_word)]==1)
{
$w_array[$ce]= "=".addslashes($exact_word);
$ce++;
}
else
{
$w_array[$ce]=$token.addslashes($exact_word);
$ce++;
}
}
else
{
$w_array[$ce]=$token.addslashes($exact_word);
$ce++;
}
$token="";
$exact_word="";
}
break;
default:
$exact_word.=$phrase[$i];
}
}
if($exact_word)
{
if(strlen($token)==0)
$token="|";
if($KeywordIgnore[strtolower($exact_word)]==1 && ($token =="|" || $token=="="))
{
$w_array[$ce]= "=".addslashes($exact_word);
$ce++;
}
else
{
$w_array[$ce]=$token.addslashes($exact_word);
$ce++;
}
}
for ($i=0;$i<count($w_array);$i++)
{
$keyword = $w_array[$i];
switch(substr($keyword,0,1))
{
case "|":
$keywords["normal"][]=substr($keyword,1);
break;
case "+":
$keywords["required"][] = substr($keyword,1);
break;
case "-":
$keywords["notallowed"][] = substr($keyword,1);
break;
case "=":
$keywords["ignored"][] = substr($keyword,1);
break;
}
}
return($keywords);
}
function BuildWhereClause($normal,$required,$notallowed)
{
$return="";
$return = $required;
if(strlen($return)>0 && strlen($notallowed)>0)
{
$return .= " AND ";
}
$return .= $notallowed;
if(strlen($return)>0 && strlen($normal)>0)
{
$return .= " AND ";
}
$return .= $normal;
return $return;
}
function GetIgnoreList()
{
global $KeywordIgnore;
$adodbConnection = &GetADODBConnection();
$rs = $adodbConnection->Execute("SELECT * FROM ".GetTablePrefix()."IgnoreKeywords");
while($rs && !$rs->EOF)
{
$KeywordIgnore[strtolower($rs->fields["keyword"])]=1;
$rs->MoveNext();
}
// foreach($KeywordIgnore as $word=>$dummy)
// echo $word.",";
// echo "<br>\n";
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/include/searchitems.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.13
\ No newline at end of property
+1.14
\ No newline at end of property
Index: trunk/kernel/frontaction.php
===================================================================
--- trunk/kernel/frontaction.php (revision 963)
+++ trunk/kernel/frontaction.php (revision 964)
@@ -1,971 +1,972 @@
<?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_arr = explode(';', base64_decode($_GET['user_key']));
$found = false;
$u = $objUsers->GetItemByField("Email", $passed_arr[1]);
if(is_object($u)) {
$found = ($u->Get("PortalUserId")==$passed_arr[0] && $u->Get("Status")==1) && strlen($u->Get("Password"));
}
if($found)
{
$newpw = makepassword();
$objSession->Set('password', $newpw);
$u->Set("Password",$newpw);
$u->Set("PassResetTime", time());
$u->Update();
$u->SendUserEventMail("USER.PSWD",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.PSWD");
$u->Set("Password",md5($newpw));
$u->Update();
$u->Clean();
}
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;
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"));
}
$allow_reset = $u->Get("PassResetTime") + $pass_reset_add;
if($found && $allow_reset <= time())
{
//$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
{
if(strlen($username))
$FormError["forgotpw"]["username"] = language("lu_ferror_unknown_username");
if(strlen($email))
$FormError["forgotpw"]["email"] = language("lu_ferror_unknown_email");
if ($allow_reset > time()) {
$FormError["forgotpw"]["username"] = language("lu_ferror_reset_denied");
//$FormError["forgotpw"] = language("lu_ferror_reset_denied");
}
$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);
}
break;
case "m_del_friend":
$id = $_GET["UserId"];
$userid = $objSession->Get("PortalUserId");
$u =& $objUsers->GetItem($id);
$u->DeleteFavorite();
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);
$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();
}
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["cat_sort_field"]);
$objSession->SetVariable("Category_Sortorder",$_POST["cat_sort_order"]);
$objSession->SetVariable("Perpage_Category",$_POST["cat_perpage"]);
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"];
}
}
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");
}
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 = $_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);
+ $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);
+ //$keywords = str_replace('\"', '', $keywords);
$performSearch = (strlen($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();
switch($_GET["type"])
{
case 1: /* category */
//echo "Searching for categories<br>";
$objAdvSearch = new clsAdvancedSearchResults("Category","clsCategory");
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($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);
$performSearch = (strlen($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.34
\ No newline at end of property
+1.35
\ No newline at end of property
Index: trunk/admin/include/mainscript.php
===================================================================
--- trunk/admin/include/mainscript.php (revision 963)
+++ trunk/admin/include/mainscript.php (revision 964)
@@ -1,541 +1,553 @@
<?php
global $imagesURL,$objConfig,$adminURL,$rootURL, $en;
$group_select = $adminURL."/users/group_select.php";
$item_select = $adminURL."/relation_select.php";
$user_select = $adminURL."/users/user_select.php";
$cat_select = $adminURL."/cat_select.php";
$missing_edit = $adminURL."/config/missing_label_search.php";
$lang_Filter = language("la_Text_Filter");
$lang_View = language("la_Text_View");
$lang_Sort = language("la_Text_Sort");
$lang_Select = language("la_Text_Select");
$lang_Unselect = language("la_Text_Unselect");
$lang_Invert = language("la_Text_Invert");
$lang_PerPage = language("la_prompt_PerPage");
$lang_All = language("la_Text_All");
$lang_Asc = language("la_common_ascending");
$lang_Desc = language("la_common_descending");
$lang_Disabled = language("la_Text_Disabled");
$lang_Enabled = language("la_Text_Enabled");
$lang_Pending = language("la_Text_Pending");
$lang_Default = language("la_Text_Default");
$lang_CreatedOn = language("la_prompt_CreatedOn");
$lang_None = language("la_Text_None");
$lang_PerPage = language("la_prompt_PerPage");
$lang_Views = language("la_Text_Views");
$lang_URL = language("la_ColHeader_Url");
$lang_Status = language("la_prompt_Status");
$lang_Name = language("la_prompt_Name");
$lang_MoveDn = language("la_prompt_MoveDown");
$lang_MoveUp = language("la_prompt_MoveUp");
$lang_Delete = language("la_prompt_Delete");
$lang_Edit = language("la_prompt_Edit");
$errormsg = language("la_validation_AlertMsg");
$env2 = BuildEnv();
if(is_numeric($en))
{
$env2 = BuildEnv() . "&en=$en";
}
$editor_url = $adminURL."/editor/editor.php?env=$env2";
$email_url = $adminURL."/email/sendmail.php?env=$env2";
$phrase_edit = $adminURL."/config/edit_label.php?env=".$env2;
$submit_done = isset($_REQUEST['submit_done']) ? 1 : 0; // returns form submit status
$Cal = GetDateFormat();
if(strpos($Cal,"y"))
{
$Cal = str_replace("y","yy",$Cal);
}
else
$Cal = str_replace("Y","y",$Cal);
$Cal = str_replace("m","mm",$Cal);
$Cal = str_replace("n","m",$Cal);
$Cal = str_replace("d","dd",$Cal);
$format = GetStdFormat(GetDateFormat());
$yearpos = (int)DateFieldOrder($format,"year");
$monthpos = (int)DateFieldOrder($format,"month");
$daypos = (int)DateFieldOrder($format,"day");
$ampm = "false";
if($objConfig->Get("ampm_time")=="1")
{
$ampm = "true";
}
require_once($pathtoroot.$admin."/lv/js/js_lang.php");
print <<<END
<script type="text/javascript" src="$adminURL/lv/js/in-portal.js"></script>
<script language="Javascript">
var CurrentTab= new String();
var lang_Filter = "$lang_Filter";
var lang_Sort = "$lang_Sort";
var lang_Select = "$lang_Select";
var lang_Unselect = "$lang_Unselect";
var lang_Invert = "$lang_Invert";
var lang_PerPage = "$lang_PerPage";
var lang_All = "$lang_All";
var lang_Asc = "$lang_Asc";
var lang_Desc = "$lang_Desc";
var lang_Disabled = "$lang_Disabled";
var lang_Pending = "$lang_Pending";
var lang_Default = "$lang_Default";
var lang_CreatedOn = "$lang_CreatedOn";
var lang_View = "$lang_View";
var lang_Views = "$lang_Views";
var lang_None = "$lang_None";
var lang_PerPage = "$lang_PerPage";
var lang_Enabled = "$lang_Enabled";
var lang_URL = "$lang_URL";
var lang_Status = "$lang_Status";
var lang_Name = "$lang_Name";
var lang_Edit = "$lang_Edit";
var lang_Delete = "$lang_Delete";
var lang_MoveUp = "$lang_MoveUp";
var lang_MoveDn = "$lang_MoveDn";
var ampm = $ampm;
var listview_clear=1;
var CalDateFormat = "$Cal";
var yearpos = $yearpos;
var monthpos = $monthpos;
var daypos = $daypos;
var ErrorMsg = '$errormsg';
//en = $en
var rootURL = '$rootURL';
function clear_list_checkboxes()
{
var inputs = document.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; i++)
if (inputs[i].type == "checkbox" && inputs[i].getAttribute("isSelector"))
{
inputs[i].checked=false;
}
}
function getRealLeft(el) {
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null) {
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
function getRealTop(el) {
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null) {
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function SetButtonStateByImage(btn_id, img_src)
{
// set state depending on image name
var btn = document.getElementById(btn_id);
if(btn)
{
if( !HasParam(img_src) ) img_src = btn.getAttribute('src');
var img_name = img_src.split('/');
img_name = img_name.length ? img_name[img_name.length - 1] : img_name;
img_name = img_name.split('.');
img_name = img_name[0].split('_');
img_name = img_name.length ? img_name[img_name.length - 1] : img_name;
if(img_name)
{
switch(img_name)
{
case 'f2': btn.setAttribute('ButtonState','over'); break;
case 'f3': btn.setAttribute('ButtonState','disabled'); break;
default: btn.setAttribute('ButtonState','enabled'); break;
}
}
}
}
function swap(imgid, src, module_name){
// swaps toobar icons from kernel
// admin or from module specified
var ob = document.getElementById(imgid);
if(ob)
{
SetButtonStateByImage(imgid, src);
var s = src;
s = s.slice(0,4);
if(s=='http')
{
ob.src = src;
}
else
{
if(module_name == null)
ob.src = '$adminURL' + '/images/' + src;
else
{
ob.src = '$rootURL' + module_name + '/$admin/images/' + src;
}
}
}
}
function flip(val)
{
if (val == 0)
return 1;
else
return 0;
}
function config_val(field, val2,url){
//alert('Setting ' + field + ' to ' + val2);
if(url)
document.viewmenu.action=url;
document.viewmenu.Action.value = "m_SetVariable";
document.viewmenu.fieldname.value = field;
document.viewmenu.varvalue.value = val2;
document.viewmenu.submit();
}
function session_val(field, val2){
//alert('Setting ' + field + ' to ' + val2);
document.viewmenu.Action.value = "m_SetSessionVariable";
document.viewmenu.fieldname.value = field;
document.viewmenu.varvalue.value = val2;
document.viewmenu.submit();
}
function Submit_ListSearch(action)
{
f = document.getElementById('ListSearchForm');
s = document.getElementById('ListSearchWord');
if(f)
{
f.Action.value = action;
f.list_search.value = s.value;
f.submit();
}
}
function ValidTime(time_str)
{
var valid = true;
if( trim(time_str) == '' ) return true; // is valid in case if not entered
time_str = time_str.toUpperCase();
parts = time_str.split(/\s*[: ]\s*/);
hour = parseInt(parts[0]);
minute = parseInt(parts[1]);
sec = parseInt(parts[2]);
if(ampm == true)
{
amstr = parts[3];
var am_valid = (amstr == 'AM' || amstr == 'PM');
if(am_valid && hour > 12) valid = false;
if(amstr == 'PM' && hour <= 12) hour = hour + 12;
if(hour == 24) hour = 0;
if(!am_valid) valid = false;
}
valid = valid && (hour > -1 && hour < 24);
valid = valid && (minute > -1 && minute < 60);
valid = valid && (sec > -1 && sec < 60);
return valid;
}
+function ValidCustomName(name_str)
+{
+ if (trim(name_str) == '') return false;
+ var re = new RegExp('^[a-zA-Z0-9_]{1,}$');
+ if (name_str.match(re)) {
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
function DaysInMonth(month,year)
{
timeA = new Date(year, month,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
return timeB.getDate();
}
function ValidDate(date_str)
{
var valid = true;
if( trim(date_str) == '' ) return true; // is valid in case if not entered
parts = date_str.split(/\s*\D\s*/);
year = parts[yearpos-1];
month = parts[monthpos-1];
day = parts[daypos-1];
valid = (year>0);
valid = valid && ((month>0) && (month<13));
valid = valid && (day<DaysInMonth(month,year)+1);
return valid;
}
function trim(str)
{
return str.replace(/(^\s*)|(\s*$)/g,'');
}
function ValidateNumber(aValue, aNumberType)
{
var valid = true;
if( trim(aValue) == '' ) return true;
return (parseInt(aValue) == aValue);
}
function OpenEditor(extra_env,TargetForm,TargetField)
{
var url = '$editor_url';
url = url+'&TargetForm='+TargetForm+'&TargetField='+TargetField+'&destform=popup';
if(extra_env.length>0)
url = url+extra_env;
window.open(url,"html_edit","width=800,height=575,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function BitStatus(Value,bit)
{
var val = Math.pow(2,bit);
if((Value & val))
{
return 1;
}
else
return 0;
}
function FlipBit(ValueName,Value,bit)
{
var val = Math.pow(2,bit);
//alert("Setting bit "+bit);
if(BitStatus(Value,bit))
{
Value = Value - val;
}
else
Value = Value + val;
session_val(ValueName,Value);
}
function PerPageSelected(Value,PageCount)
{
if(Value==PageCount)
{
return 2;
}
else
return 0;
}
function RadioIsSelected(Value1,Value2)
{
if(Value1 == Value2)
{
return 2;
}
else
return 0;
}
function OpenItemSelector(envstr)
{
//alert(envstr);
window.open('$item_select?'+envstr,"groupselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function OpenUserSelector(CheckIdField,Checks,envstr)
{
if(Checks) var retval = Checks.getItemList();
f = document.getElementById('userpopup');
if(f)
{
if(CheckIdField)
f.elements[CheckIdField].value = retval;
}
SessionPrepare('$user_select', envstr, 'userselect');
}
function SessionPrepare(url, get_str, window_name)
{
var params = ExtractParams(get_str);
if(params['destform'])
{
if(params['destform'] == 'popup')
{
CreatePopup(window_name, url + '?' + get_str);
return true;
}
else
var frm = CreateFakeForm();
}
else
var frm = CreateFakeForm();
if(!frm) return false;
frm.destform.value = params['destform'];
params['destform'] = 'popup';
get_str = MergeParams(params);
CreatePopup(window_name);
frm.target = window_name;
frm.method = 'POST';
frm.action = url + '?' + get_str;
frm.submit();
}
function addField(form, type, name, value)
{
// create field in form
var field = document.createElement("INPUT");
field.type = type;
field.name = name;
field.id = name;
field.value = value;
form.insertBefore(field, form.nextSibling);
}
function CreateFakeForm()
{
if($submit_done == 0)
{
var theBody = document.getElementsByTagName("BODY");
if(theBody.length == 1)
{
var frm = document.createElement("FORM");
frm.name = "fake_form";
frm.id = "fake_form";
frm.method = "post";
theBody[0].insertBefore(frm, theBody[0].nextSibling);
addField(frm, 'hidden', 'submit_done', 1);
addField(frm, 'hidden', 'destform', '');
return document.getElementById('fake_form');
}
}
return false;
}
function CreatePopup(window_name, url, width, height)
{
// creates a popup window & returns it
if(url == null && typeof(url) == 'undefined' ) url = '';
if(width == null && typeof(width) == 'undefined' ) width = 750;
if(height == null && typeof(height) == 'undefined' ) height = 400;
return window.open(url,window_name,'width='+width+',height='+height+',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no');
}
function ShowHelp(section)
{
var frm = document.getElementById('help_form');
frm.section.value = section;
frm.method = 'POST';
CreatePopup('HelpPopup','$rootURL$admin/help/blank.html'); // , null, 600
frm.target = 'HelpPopup';
frm.submit();
}
function ExtractParams(get_str)
{
// extract params into associative array
var params = get_str.split('&');
var result = Array();
var temp_var;
var i = 0;
var params_count = params.length;
while(i < params_count)
{
temp_var = params[i].split('=');
result[temp_var[0]] = temp_var[1];
i++;
}
return result;
}
function MergeParams(params)
{
// join splitted params into GET string
var key;
var result = '';
for(key in params)
result += key + '=' + params[key] + '&';
if(result.length) result = result.substring(0, result.length - 1);
return result;
}
function show_props(obj, objName)
{
var result = "";
for (var i in obj) {
result += objName + "." + i + " = " + obj[i] + "\\n";
}
return result;
}
function OpenGroupSelector(envstr)
{
//alert(envstr);
SessionPrepare('$group_select', envstr, 'groupselect');
//window.open('$group_select?'+envstr,"groupselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function OpenCatSelector(envstr)
{
//alert(envstr);
window.open('$cat_select?'+envstr,"catselect","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
function openEmailPopup(envar,form,Checks)
{
var email_url='$email_url';
var url = email_url+envar;
if(Checks.itemChecked())
{
f = document.getElementById(form);
if(f)
{
window.open('',"sendmail","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
f.idlist.value = Checks.getItemList();
f.submit();
}
}
}
function OpenPhraseEditor(extra_env)
{
//SessionPrepare('$phrase_edit', extra_env, 'phrase_edit');
var url = '$phrase_edit'+extra_env+'&destform=popup';
window.open(url,"phrase_edit","width=750,height=400,status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no");
}
var env = '$env2';
var SubmitFunc = false;
</script>
END;
?>
Property changes on: trunk/admin/include/mainscript.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property
Index: trunk/admin/include/tabs.js
===================================================================
--- trunk/admin/include/tabs.js (revision 963)
+++ trunk/admin/include/tabs.js (revision 964)
@@ -1,272 +1,275 @@
//parses input tags looking for validation attributes
function DataIsValid(f)
{
var ValType = '';
var span_id = '';
var form_result = true;
var field_result = true;
var j = 0;
for (var i = 0; i < f.elements.length; i++)
{
ValType = '';
Field = f.elements[i];
ValType = Field.getAttribute('ValidationType');
if(ValType)
{
ValType = TransformValidationType(ValType); // for capability with old forms
span_id = 'prompt_' + Field.name;
span = document.getElementById(span_id);
if(span)
{
field_result = true;
ValType = ValType.split(',');
j = 0;
while(j < ValType.length)
{
//alert('Validating ['+Field.name+'] as ['+ValType[j]+']');
if(ValType[j] == 'password')
{
var repasswd = document.getElementById(Field.name + '_verify');
if(repasswd)
{
field_result &= ValidateField(Field.value, ValType[j], repasswd.value);
document.getElementById('prompt_' + Field.name + '_verify').className = field_result ? 'text' : 'validation_error';
}
}
else
field_result &= ValidateField(Field.value, ValType[j]);
j++;
}
span.className = field_result ? 'text' : 'validation_error';
form_result &= field_result;
}
}
}
return form_result;
}
function TransformValidationType(OldType)
{
// replace old validation types with new
// on the fly in case if we have some forms
// that still use old validation types
var NewType = '';
switch(OldType)
{
case 'optional_date':
NewType = 'date';
break;
default:
NewType = OldType;
break;
}
return NewType;
}
function ValidateField(FieldValue, ValidateAs, RePasswdValue)
{
// validate FieldValue based on ValidateAs rule specified;
// in case if password field compare it with RePasswdValue
var result = true;
switch(ValidateAs)
{
case 'exists': // field is required
if(FieldValue.length == 0) result = false;
break;
case 'integer': // field must be integer number
result = ValidateNumber(FieldValue, ValidateAs);
break;
case 'password': // validate as password field
result = (FieldValue == RePasswdValue) || (FieldValue.length == 0);
break;
case 'date': // text must be a formatted date
result = ValidDate(FieldValue);
break;
case 'time': // text must be a formatted time
result = ValidTime(FieldValue);
break;
+ case 'custom_name':
+ result = ValidCustomName(FieldValue);
+ break;
}
return result;
}
function MarkAsRequired(f)
{
var ValType = '';
var span_id = '';
var result = true;
for (var i = 0; i < f.elements.length; i++)
{
ValType = '';
Field = f.elements[i];
ValType = Field.getAttribute('ValidationType');
if(ValType)
{
ValType = ValType.split(',');
if( InArray(ValType,'exists') !== false )
{
span_id = 'prompt_' + Field.name;
span = document.getElementById(span_id);
span.innerHTML = span.innerHTML + '<span class="error">*</span>';
}
}
}
}
function InArray(aArray, aValue)
{
// checks if element in array
var k = 0;
while(k < aArray.length)
{
if(aArray[k] == aValue) return k;
k++;
}
return false;
}
//Used to submit the form when a tab is clicked on
function edit_submit(formname, status_field, targetURL, save_value, env_str, new_target)
{
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3) != "env") full_env = 'env=' + full_env;
f = document.getElementById(formname);
if(f)
{
var valid = false;
if(save_value != 2 && save_value !=-1)
{
valid = DataIsValid(f);
}
else
{
var a = f.Action;
if(a)
{
a.value='';
}
}
if(valid || save_value==2 || save_value==-1)
{
var URLPrefix = '';
if( targetURL.substring(0, rootURL.length) != rootURL ) URLPrefix = rootURL;
f.action = URLPrefix + targetURL + '?' + full_env;
if(status_field.length > 0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
if(new_target != null && typeof(new_target) != 'undefined') f.target = new_target;
f.submit();
}
else
if(!valid) alert(ErrorMsg);
}
else
alert('Form '+formname+' was not found.');
}
//Used when the save or cancel buttin is hit
function do_edit_save(formname, status_field, targetURL, save_value, env_str)
{
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
f = document.getElementById(formname);
if(f)
{
f.action = rootURL + targetURL + '?' + full_env;
//alert(f.action);
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
f.submit();
}
else
alert('Form '+formname+' was not found.');
}
function jump_to_url(targetURL, env_str)
{
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
document.location = rootURL + targetURL + '?' + full_env;
}
// -------------------------------------------------------------------------------------------------------------
function submit_form(formname, status_field, targetURL, save_value, env_str)
{
// by Alex, submits form.
var full_env = env;
if( HasParam(env_str) ) full_env += env_str;
if(full_env.substr(0,3)!="env")
full_env = 'env='+full_env;
f = document.getElementById(formname);
if(f)
{
var valid = false;
if(save_value != 2 && save_value !=-1)
{
valid = DataIsValid(f);
}
else
{
var a = f.Action;
if(a)
{
a.value='';
}
}
if(valid || save_value==2 || save_value==-1)
{
f.action = rootURL + targetURL + '?' + full_env;
if(status_field.length>0)
{
f.elements[status_field].value = save_value; //0= stay in temp, 1=save to perm, 2 = purge no save
}
f.submit();
}
else
if(!valid)
alert(ErrorMsg);
}
else
alert('Form '+formname+' was not found.');
}
function HasParam(param)
{
// checks of parameter is passed to function (cross-browser)
return typeof(param) == 'undefined' ? false : true;
}
function SetBackground(element_id, img_url)
{
// set background image of element specified by id
var el = document.getElementById(element_id);
el.style.backgroundImage = 'url('+img_url+')';
}
\ No newline at end of file
Property changes on: trunk/admin/include/tabs.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.8
\ No newline at end of property
+1.9
\ No newline at end of property
Index: trunk/admin/config/addcustomfield.php
===================================================================
--- trunk/admin/config/addcustomfield.php (revision 963)
+++ trunk/admin/config/addcustomfield.php (revision 964)
@@ -1,261 +1,261 @@
<?php
##############################################################
##In-portal ##
##############################################################
## In-portal ##
## Intechnic Corporation ##
## All Rights Reserved, 1998-2002 ##
## ##
## No portion of this code may be copied, reproduced or ##
## otherwise redistributed without proper written ##
## consent of Intechnic Corporation. Violation will ##
## result in revocation of the license and support ##
## privileges along maximum prosecution allowed by law. ##
##############################################################
if(!strlen($pathtoroot))
{
$path=dirname(realpath(__FILE__));
if(strlen($path))
{
/* determine the OS type for path parsing */
$pos = strpos($path,":");
if ($pos === false)
{
$gOS_TYPE="unix";
$pathchar = "/";
}
else
{
$gOS_TYPE="win";
$pathchar="\\";
}
$p = $path.$pathchar;
/*Start looking for the root flag file */
while(!strlen($pathtoroot) && strlen($p))
{
$sub = substr($p,strlen($pathchar)*-1);
if($sub==$pathchar)
{
$filename = $p."root.flg";
}
else
$filename = $p.$pathchar."root.flg";
if(file_exists($filename))
{
$pathtoroot = $p;
}
else
{
$parent = realpath($p.$pathchar."..".$pathchar);
if($parent!=$p)
{
$p = $parent;
}
else
$p = "";
}
}
if(!strlen($pathtoroot))
$pathtoroot = ".".$pathchar;
}
else
{
$pathtoroot = ".".$pathchar;
}
}
$sub = substr($pathtoroot,strlen($pathchar)*-1);
if($sub!=$pathchar)
{
$pathtoroot = $pathtoroot.$pathchar;
}
//echo $pathtoroot;
//print_r($_GET);
//print_r($_POST);
require_once($pathtoroot."kernel/startup.php");
//admin only util
/* set the destination of the image upload, relative to the root path */
$DestDir = "kernel/images/";
$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
$localURL=$rootURL."kernel/";
$adminURL = $rootURL.$admin;
$imagesURL = $adminURL."/images";
$cssURL = $adminURL."/include";
$browseURL = $adminURL."/browse";
$pathtolocal = $pathtoroot."kernel/";
require_once ($pathtoroot.$admin."/include/elements.php");
require_once ($pathtoroot."kernel/admin/include/navmenu.php");
require_once ($pathtolocal."admin/include/navmenu.php");
require_once($pathtoroot.$admin."/browse/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/parser.php";
if(file_exists($path))
{
include_once($path);
}
}
$FieldType = (int)$_GET["DataType"];
if($FieldType==0)
$FieldType = (int)$_POST["DataType"];
$objCustomFields = new clsCustomFieldList($FieldType);
//$objEditItems->SourceTable = $objSession->GetEditTable("Images");
if(isset($_POST["itemlist"]))
{
if(is_array($_POST["itemlist"]))
{
$FieldId = $_POST["itemlist"][0];
}
else
{
$FieldId = $_POST["itemlist"];
}
$c = $objCustomFields->GetItem($FieldId);
$action = "m_customfield_edit";
$name = $c->Get("FieldName");
}
else
{
$c = new clsCustomField();
$c->Set("Type",$DataType);
$action = "m_customfield_add";
$name = prompt_language("la_Text_NewField");
}
$section = $_GET["section"];
if(strlen($section)==0)
$section = $_POST["section"];
$section_env = "section=$section&DataType=$FieldType";
$envar = "$section_env&env=".BuildEnv();
$ado = &GetADODBConnection();
/* page header */
$charset = GetRegionalOption('Charset');
print <<<END
<html>
<head>
<title>In-portal</title>
<meta http-equiv="content-type" content="text/html;charset=$charset">
<meta http-equiv="Pragma" content="no-cache">
<script language="JavaScript">
imagesPath='$imagesURL'+'/';
</script>
<script src="$browseURL/common.js"></script>
<script src="$browseURL/toolbar.js"></script>
<script src="$browseURL/utility.js"></script>
<script src="$browseURL/checkboxes.js"></script>
<script language="JavaScript1.2" src="$browseURL/fw_menu.js"></script>
<link rel="stylesheet" type="text/css" href="$browseURL/checkboxes.css">
<link rel="stylesheet" type="text/css" href="$cssURL/style.css">
<link rel="stylesheet" type="text/css" href="$browseURL/toolbar.css">
END;
$title = GetTitle("la_Text_CustomField", '', $FieldId, $name);//prompt_language("la_Text_Editing")." ".prompt_language("la_Text_CustomField")." ".prompt_language("la_text_for")." ".prompt_language("la_Text_DataType_".$_GET["DataType"]);
$title .= " ".prompt_language("la_text_for")." ".prompt_language("la_Text_DataType_".$_GET["DataType"]);
$objCatToolBar = new clsToolBar();
$objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","submit_form('customfield','','".$admin."/config/edit_customfields.php',0,'&$section_env');",$imagesURL."/toolbar/tool_select.gif");
$objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","submit_form('customfield','','".$admin."/config/edit_customfields.php',-1,'&$section_env');",$imagesURL."/toolbar/tool_cancel.gif");
int_header($objCatToolBar,NULL,$title);
?>
<FORM enctype="multipart/form-data" ID="customfield" NAME="customfield" method="POST" ACTION="">
<TABLE cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
<?php int_subsection_title(prompt_language("la_tab_General")); ?>
<TR <?php int_table_color(); ?> >
<TD><?php echo prompt_language("la_prompt_FieldId"); ?></TD>
<TD><?php echo $c->Get("CustomFieldId"); ?></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_fieldname"><?php echo prompt_language("la_prompt_FieldName"); ?></SPAN></TD>
- <TD><input ValidationType="exists" tabindex="1" type=text NAME="fieldname" VALUE="<?php echo $c->Get("FieldName"); ?>"></TD>
+ <TD><input ValidationType="custom_name" tabindex="1" type=text NAME="fieldname" VALUE="<?php echo $c->Get("FieldName"); ?>"></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_fieldlabel"><?php echo prompt_language("la_prompt_FieldLabel"); ?></SPAN></TD>
<td><?php if(strlen($c->Get("FieldName"))) echo "lu_fieldcustom__".$c->Get("FieldName"); ?>:
<?php echo prompt_language("lu_fieldcustom__".$c->Get("FieldName"),0); ?>
</td>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<td colspan="3">
<input type=hidden NAME="Action" VALUE="<?php echo $action; ?>">
<INPUT TYPE="hidden" NAME="CustomFieldId" VALUE="<?php echo $c->Get("CustomFieldId"); ?>">
<input TYPE="HIDDEN" NAME="DataType" VALUE="<?php echo $_GET["DataType"]; ?>">
</td>
</tr>
<?php int_subsection_title(prompt_language("la_tab_AdminUI")); ?>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_generaltab"><?php echo prompt_language("la_prompt_showgeneraltab"); ?></SPAN></TD>
<TD><input type=checkbox NAME="generaltab" tabindex="2" VALUE="1" <?php if ($c->Get("OnGeneralTab")) echo "CHECKED"; ?>></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_heading"><?php echo prompt_language("la_prompt_heading"); ?></SPAN></TD>
<TD><input type=text NAME="heading" tabindex="3" VALUE="<?php echo $c->Get("Heading"); ?>"></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_fieldprompt"><?php echo prompt_language("la_prompt_FieldPrompt"); ?></SPAN></TD>
<TD><input type=text NAME="fieldprompt" tabindex="4" VALUE="<?php echo $c->Get("Prompt"); ?>"></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_input_type"><?php echo prompt_language("la_prompt_InputType"); ?></SPAN></TD>
<td>
<SELECT name="input_type" tabindex="5">
<option VALUE="text" <?php if($c->Get("ElementType")=="text") echo "SELECTED"; ?>><?php echo admin_language("la_type_text"); ?></OPTION>
<option VALUE="select" <?php if($c->Get("ElementType")=="select") echo "SELECTED"; ?>><?php echo admin_language("la_type_select"); ?></OPTION>
<option VALUE="radio" <?php if($c->Get("ElementType")=="radio") echo "SELECTED"; ?>><?php echo admin_language("la_type_radio"); ?></OPTION>
<option VALUE="password" <?php if($c->Get("ElementType")=="password") echo "SELECTED"; ?>><?php echo admin_language("la_type_password"); ?></OPTION>
<option VALUE="textarea" <?php if($c->Get("ElementType")=="textarea") echo "SELECTED"; ?>><?php echo admin_language("la_type_textarea"); ?></OPTION>
<option VALUE="label" <?php if($c->Get("ElementType")=="label") echo "SELECTED"; ?>><?php echo admin_language("la_type_label"); ?></OPTION>
</SELECT>
</td>
<td></td>
</TR>
<TR <?php int_table_color(); ?> >
<TD><SPAN id="prompt_valuelist"><?php echo prompt_language("la_prompt_valuelist"); ?></SPAN></TD>
<TD><input type=text tabindex="6" NAME="valuelist" VALUE="<?php echo $c->Get("ValueList"); ?>"></TD>
<TD></TD>
</TR>
<TR <?php int_table_color(); ?> >
<TD></TD>
<td><?php echo prompt_language("la_valuelist_help"); ?></td>
<td></td>
</tr>
</FORM>
</TABLE>
<!-- CODE FOR VIEW MENU -->
<form method="post" action="user_groups.php?<?php echo $envar; ?>" name="viewmenu">
<input type="hidden" name="fieldname" value="">
<input type="hidden" name="varvalue" value="">
<input type="hidden" name="varvalue2" value="">
<input type="hidden" name="Action" value="">
</form>
<!-- END CODE-->
<?php int_footer(); ?>
Property changes on: trunk/admin/config/addcustomfield.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property

Event Timeline