Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sat, Feb 1, 7:44 PM

in-portal

Index: trunk/kernel/include/searchconfig.php
===================================================================
--- trunk/kernel/include/searchconfig.php (revision 90)
+++ trunk/kernel/include/searchconfig.php (revision 91)
@@ -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';
- print_pre($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."'";
$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)
{
$f = new clsSearchConfig();
if($DisplayOrder==0)
$DisplayOrder = $this->GetNextDisplayOrder($Module);
$f->Set(Array("TableName","ModuleName","SimpleSearch","AdvancedSearch","Description","DisplayName","ConfigHeader",
"DisplayOrder","Priority","FieldType","FieldName"),
Array($Table,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder,$Priority,$FieldType,$FieldName));
$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.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/include/parseditem.php
===================================================================
--- trunk/kernel/include/parseditem.php (revision 90)
+++ trunk/kernel/include/parseditem.php (revision 91)
@@ -1,2753 +1,2753 @@
<?php
global $ItemTypePrefixes;
$ItemTypePrefixes = array();
$ItemTagFiles = array();
function RegisterPrefix($class,$prefix,$file)
{
global $ItemTypePrefixes, $ItemTagFiles;
$ItemTypePrefixes[$class] = $prefix;
$ItemTagFiles[$prefix] = $file;
}
class clsParsedItem extends clsItemDB
{
var $TagPrefix;
var $Parser;
var $AdminParser;
function clsParsedItem($id=NULL)
{
global $TemplateRoot;
$this->clsItemDB();
$this->Parser = new clsTemplateList($TemplateRoot);
$this->AdminParser = new clsAdminTemplateList();
}
/* function ParseObject($element)
{
$extra_attribs = ExtraAttributes($element->attributes);
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
$tag = $this->TagPrefix."_".$field;
$ret = $this->parsetag($tag);
}
return $ret;
}
*/
function ParseTimeStamp($d,$attribs=array())
{
if($attribs["_tz"])
{
$d = GetLocalTime($d,$objSession->Get("tz"));
}
$part = strtolower($attribs["_part"]);
if(strlen($part))
{
$ret = ExtractDatePart($part,$d);
}
else
{
if($d<=0)
{
$ret = "";
}
else
$ret = LangDate($d);
}
return $ret;
}
function ParseObject($element)
{
global $objConfig, $objCatList, $var_list_update, $var_list, $n_var_list_update, $m_var_list_update;
$extra_attribs = ExtraAttributes($element->attributes);
$ret = "";
if ($this->TagPrefix == "email" && strtolower($element->name) == "touser") {
$this->TagPrefix = "touser";
}
if(strtolower($element->name)==$this->TagPrefix)
{
$field = strtolower($element->attributes["_field"]);
switch($field)
{
case "id":
$ret = $this->Get($this->id_field);
break;
case "resourceid":
if(!$this->NoResourceId)
$ret = $this->Get("ResourceId");
break;
case "category":
$c = $objCatList->GetItem($this->Get("CategoryId"));
if(is_object($c))
{
$ret = $c->parsetag($element->attributes["_cattag"]);
}
break;
case "priority":
if($this->Get("Priority")!=0)
{
$ret = (int)$this->Get("Priority");
}
else
$ret = "";
break;
case "link":
if(method_exists($this,"ItemURL"))
{
$ret = $this->ItemURL($element->attributes["_template"],FALSE,"");
}
break;
case "cat_link":
if(method_exists($this,"ItemURL"))
{
$ret = $this->ItemURL($element->attributes["_template"],TRUE,"");
}
break;
case "fullpath":
$ret = $this->Get("CachedNavbar");
if(!strlen($ret))
{
if(is_numeric($this->Get("CategoryId")))
{
$c = $objCatList->GetItem($this->Get("CategoryId"));
if(is_object($c))
$ret = $c->Get("CachedNavbar");
}
else
{
if(method_exists($this,"GetPrimaryCategory"))
{
$cat = $this->GetPrimaryCategory();
$c = $objCatList->GetItem($cat);
if(is_object($c))
$ret = $c->Get("CachedNavbar");
}
}
}
// $ret = $this->HighlightText($ret);
break;
case "relevance":
$style = $element->attributes["_displaymode"];
if(!strlen($style))
$style = "numerical";
switch ($style)
{
case "numerical":
$ret = (100 * LangNumber($this->Get("Relevance"),1))."%";
break;
case "bar":
$OffColor = $element->attributes["_offbackgroundcolor"];
$OnColor = $element->attributes["_onbackgroundcolor"];
$percentsOff = (int)(100 - (100 * $this->Get("Relevance"))); if ($percentsOff)
{
$percentsOn = 100 - $percentsOff;
$ret = "<td width=\"$percentsOn%\" bgcolor=\"$OnColor\"><img src=\"img/s.gif\"></td><td width=\"$percentsOff%\" bgcolor=\"$OffColor\"><img src=\"img/s.gif\"></td>";
}
else
$ret = "<td width=\"100%\" bgcolor=\"$OnColor\"><img src=\"img/s.gif\"></td>";
break;
case "graphical":
$OnImage = $element->attributes["_onimage"];
if (!strlen($OnImage))
break;
// Get image extension
$image_data = explode(".", $OnImage);
$image_ext = $image_data[count($image_data)-1];
unset($image_data[count($image_data)-1]);
$rel = (10 * LangNumber($this->Get("Relevance"),1));
$OnImage1 = join(".", $image_data);
if ($rel)
$img_src = $OnImage1."_".$rel.".".$image_ext;
else
$img_src = $OnImage;
$ret = "<img src=\"$img_src\" border=\"0\" alt=\"".(10*$rel)."\">";
break;
}
break;
case "rating":
$style = $element->attributes["_displaymode"];
if(!strlen($style))
$style = "numerical";
switch($style)
{
case "numerical":
$ret = LangNumber($this->Get("CachedRating"),1);
break;
case "text":
$ret = RatingText($this->Get("CachedRating"));
break;
case "graphical":
$OnImage = $element->attributes["_onimage"];
$OffImage = $element->attributes["_offimage"];
$images = RatingTickImage($this->Get("CachedRating"),$OnImage,$OffImage);
for($i=1;$i<=count($images);$i++)
{
$url = $images[$i];
if(strlen($url))
{
$ret .= "<IMG src=\"$url\" $extra_attribs >";
$ret .= $element->attributes["_separator"];
}
}
break;
}
break;
case "reviews":
$today = FALSE;
if(method_exists($this,"ReviewCount"))
{
if($element->attributes["_today"])
$today = TRUE;
$ret = $this->ReviewCount($today);
}
else
$ret = "";
break;
case "votes":
$ret = (int)$this->Get("CachedVotesQty");
break;
case "favorite":
if(method_exists($this,"IsFavorite"))
{
if($this->IsFavorite())
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_favorite";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "new":
if(method_exists($this,"IsNewItem"))
{
if($this->IsNewItem())
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_new";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "pop":
if(method_exists($this,"IsPopItem"))
{
if($this->IsPopItem())
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_pop";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "hot":
if(method_exists($this,"IsHotItem"))
{
if($this->IsHotItem())
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_hot";
$ret = language($ret);
}
else
$ret = "";
}
break;
case "pick":
if($this->Get("EditorsPick")==1)
{
$ret = $element->attributes["_label"];
if(!strlen($ret))
$ret = "lu_pick";
$ret = language($ret);
}
else
$ret = "";
break;
case "admin_icon":
if(method_exists($this,"StatusIcon"))
{
if($element->attributes["fulltag"])
{
$ret = "<IMG $extra_attribs SRC=\"".$this->StatusIcon()."\">";
}
else
$ret = $this->StatusIcon();
}
break;
case "custom":
if(method_exists($this,"GetCustomFieldValue"))
{
$field = $element->attributes["_customfield"];
$default = $element->attributes["_default"];
if (strlen($field))
$ret = $this->GetCustomFieldValue($field,$default);
}
break;
case "image":
$default = $element->attributes["_primary"];
$name = $element->attributes["_name"];
if(strlen($name))
{
$img = $this->GetImageByName($name);
}
else
{
if($default)
$img = $this->GetDefaultImage();
}
if(is_object($img))
{
if(strlen($element->attributes["_imagetemplate"]))
{
$ret = $img->ParseTemplate($element->attributes["_imagetemplate"]);
break;
}
else
{
if($element->attributes["_thumbnail"])
{
$url = $img->parsetag("thumb_url");
}
else
{
if(!$element->attributes["_nothumbnail"])
{
$url = $img->parsetag("image_url");
}
else
{
$url = $img->FullURL(TRUE,"");
}
}
}
}
else
{
$url = $element->attributes["_defaulturl"];
}
if($element->attributes["_imagetag"])
{
if(strlen($url))
{
$ret = "<IMG src=\"$url\" $extra_attribs >";
}
else
$ret = "";
}
else
$ret = $url;
break;
default:
$ret = "Undefined:".$element->name;
break;
}
}
else if ($this->TagPrefix == 'email'){
$ret = "Undefined:".$element->name;
}
return $ret;
}
function ParseString($name)
{
$el = new clsHtmlTag();
$el->Clear();
$el->prefix = "inp";
$el->name = $name;
$numargs = func_num_args();
$arg_list = func_get_args();
for ($i = 1; $i < $numargs; $i++)
{
$attr = $arg_list[$i];
$parts = explode("=",$attr,2);
$name = $parts[0];
$val = $parts[1];
$el->attributes[$name] = $val;
}
return $this->ParseObject($el);
}
/* pass attributes as strings
ie: ParseStringEcho('tagname','_field="something" _data="somethingelse"');
*/
function ParseStringEcho($name)
{
$el = new clsHtmlTag();
$el->Clear();
$el->prefix = "inp";
$el->name = $name;
$numargs = func_num_args();
$arg_list = func_get_args();
for ($i = 1; $i < $numargs; $i++)
{
$attr = $arg_list[$i];
$parts = explode("=",$attr,2);
$name = $parts[0];
$val = $parts[1];
$el->attributes[$name] = $val;
}
echo $this->ParseObject($el);
}
function ParseElement($raw, $inner_html ="")
{
$tag = new clsHtmlTag($raw);
$tag->inner_html = $inner_html;
if($tag->parsed)
{
if($tag->name=="include" || $tag->name=="perm_include" || $tag->name=="lang_include")
{
$output = $this->Parser->IncludeTemplate($tag);
}
else
{
$output = $this->ParseObject($tag);
//echo $output."<br>";
if(substr($output,0,9)=="Undefined")
{
$output = $tag->Execute();
// if(substr($output,0,8)="{Unknown")
// $output = $raw;
} return $output;
}
}
else
return "";
}
function AdminParseTemplate($file)
{
$html = "";
$t = $this->AdminParser->GetTemplate($file);
if(is_object($t))
{
array_push($this->AdminParser->stack,$file);
$html = $t->source;
$next_tag = strpos($html,"<inp:");
while($next_tag)
{
$end_tag = strpos($html,"/>",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseElement($tagtext);
$html = $pre.$inner.$post;
$next_tag = strpos($html,"<inp:");
}
array_pop($this->AdminParser->stack);
}
return $html;
}
function ParseTemplateText($text)
{
$html = $text;
$search = "<inp:".$this->TagPrefix;
$next_tag = strpos($html,"<inp:");
//$next_tag = strpos($html,$search);
while($next_tag)
{
$closer = strpos(strtolower($html),">",$next_tag);
$end_tag = strpos($html,"/>",$next_tag);
if($end_tag < $closer || $closer == 0)
{
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+2);
$pre = substr($html,0,$next_tag);
$post = substr($html,$end_tag+2);
$inner = $this->ParseElement($tagtext);
$html = $pre.$inner.$post;
}
else
{
$OldTagStyle = "</inp>";
## Try to find end of TagName
$TagNameEnd = strpos($html, " ", $next_tag);
## Support Old version
// $closer = strpos(strtolower($html),"</inp>",$next_tag);
if ($TagNameEnd)
{
$Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag));
$TagName = explode(":", $Tag);
if (strlen($TagName[1]))
$CloserTag = "</inp:".$TagName[1].">";
}
else
{
$CloserTag = $OldTagStyle;
}
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
## Try to find old tag closer
if (!$closer && ($CloserTag != $OldTagStyle))
{
$CloserTag = $OldTagStyle;
$closer = strpos(strtolower($html), $CloserTag, $next_tag);
}
$end_tag = strpos($html,">",$next_tag);
$tagtext = substr($html,$next_tag,($end_tag - $next_tag)+1);
$pre = substr($html,0,$next_tag);
$inner = substr($html,$end_tag+1,$closer-($end_tag+1));
$post = substr($html,$end_tag+1+strlen($inner) + strlen($CloserTag));
//echo "PRE:". htmlentities($pre,ENT_NOQUOTES);
//echo "INNER:". htmlentities($inner,ENT_NOQUOTES);
//echo "POST:". htmlentities($post,ENT_NOQUOTES);
$parsed = $this->ParseElement($tagtext);
if(strlen($parsed))
{
$html = $pre.$this->ParseTemplateText($inner).$post;
}
else
$html = $pre.$post;
}
$next_tag = strpos($html,$search);
}
return $html;
}
function ParseTemplate($tname)
{
global $objTemplate, $LogLevel,$ptime,$timestart;
LogEntry("Parsing $tname\n");
$LogLevel++;
$html = "";
$t = $objTemplate->GetTemplate($tname);
//$t = $this->Parser->GetTemplate($tname);
if(is_object($t))
{
array_push($this->Parser->stack,$tname);
$html = $t->source;
$html = $this->ParseTemplateText($html);
array_pop($this->Parser->stack);
}
$LogLevel--;
LogEntry("Finished Parsing $tname\n");
$ptime = round(getmicrotime() - $timestart,6);
$xf = 867530; //Download ID
if($xf != 0)
{
$x2 = substr($ptime,-6);
$ptime .= $xf ^ $x2; //(1/1000);
}
return $html;
}
function SendUserEventMail($EventName,$ToUserId,$LangId=NULL,$RecptName=NULL)
{
global $objMessageList,$FrontEnd;
$Event =& $objMessageList->GetEmailEventObject($EventName,0,$LangId);
if(is_object($Event))
{
if($Event->Get("Enabled")=="1" || ($Event->Get("Enabled")==2 && $FrontEnd))
{
$Event->Item = $this;
if(is_numeric($ToUserId))
{
return $Event->SendToUser($ToUserId);
}
else
return $Event->SendToAddress($ToUserId,$RecptName);
}
}
}
function SendAdminEventMail($EventName,$LangId=NULL)
{
global $objMessageList,$FrontEnd;
//echo "Firing Admin Event $EventName <br>\n";
$Event =& $objMessageList->GetEmailEventObject($EventName,1,$LangId);
if(is_object($Event))
{
if($Event->Get("Enabled")=="1" || ($Event->Get("Enabled")==2 && $FrontEnd))
{
$Event->Item = $this;
//echo "Admin Event $EventName Enabled <br>\n";
return $Event->SendAdmin($ToUserId);
}
}
}
function parse_template($t)
{
}
}
class clsItemCollection
{
var $Items;
var $CurrentItem;
var $adodbConnection;
var $classname;
var $SourceTable;
var $LiveTable;
var $QueryItemCount;
var $AdminSearchFields = array();
var $SortField;
var $debuglevel;
var $id_field = null; // id field for list item
var $BasePermission;
var $Dummy = null;
function SetTable($action, $table_name = null) // new by Alex
{
// $action = {'live', 'restore','edit'}
switch($action)
{
case 'live':
$this->LiveTable = $table_name;
$this->SourceTable = $this->LiveTable;
break;
case 'restore':
$this->SourceTable = $this->LiveTable;
break;
case 'edit':
global $objSession;
$this->SourceTable = $objSession->GetEditTable($this->LiveTable);
break;
}
}
function &GetDummy() // new by Alex
{
if( !isset($this->Dummy) )
$this->Dummy =& new $this->classname();
$this->Dummy->tablename = $this->SourceTable;
return $this->Dummy;
}
function clsItemCollection()
{
$this->adodbConnection = GetADODBConnection();
$this->Clear();
$this->BasePermission="";
}
function GetIDField() // new by Alex
{
// returns id field for list item
if( !isset($this->id_field) )
{
$dummy =& $this->GetDummy();
$this->id_field = $dummy->IdField();
}
return $this->id_field;
}
function &GetNewItemClass()
{
return new $this->classname();
}
function Clear()
{
unset($this->Items);
$this->Items = array();
$this->CurrentItem=0;
}
function &SetCurrentItem($id)
{
$this->CurrentItem=$id;
return $this->GetItem($id);
}
function &GetCurrentItem()
{
if($this->CurrentItem>0)
{
return $this->GetItem($this->CurrentItem);
}
else
return FALSE;
}
function NumItems()
{
if(is_array($this->Items))
{
// echo "TEST COUNT: ".count($this->Items)."<BR>";
return count($this->Items);
}
else
return 0;
}
function ItemLike($index, $string)
{
// check if any of the item field
// even partially matches $string
$found = false;
$string = strtolower($string);
$item_data = $this->Items[$index]->GetData();
foreach($item_data as $field => $value)
if( in_array($field, $this->AdminSearchFields) )
if( strpos(strtolower($value), $string) !== false)
{
$found = true;
break;
}
return $found;
}
function DeleteItem($index) // by Alex
{
// deletes item with specific index from list
$i = $index; $item_count = $this->NumItems();
while($i < $item_count - 1)
{
$this->Items[$i] = $this->Items[$i + 1];
$i++;
}
unset($this->Items[$i]);
}
function ShowItems()
{
$i = 0; $item_count = $this->NumItems();
while($i < $item_count)
{
echo "Item No <b>$i</b>:<br>";
$this->Items[$i]->PrintVars();
$i++;
}
}
function SwapItems($Index,$Index2)
{
$temp = $this->Items[$Index]->GetData();
$this->Items[$Index]->SetData($this->Items[$Index2]->GetData());
$this->Items[$Index2]->SetData($temp);
}
function CopyResource($OldId,$NewId)
{
$this->Clear();
$sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$OldId";
$this->Query_Item($sql);
// echo $sql."<br>\n";
if($this->NumItems()>0)
{
foreach($this->Items as $item)
{
$item->UnsetIdField();
$item->Set("ResourceId",$NewId);
$item->Create();
}
}
}
function ItemsOnClipboard()
{
global $objSession;
$clip = $objSession->GetPersistantVariable("ClipBoard");
$count = 0;
$table = $this->SourceTable;
$prefix = GetTablePrefix();
if(substr($table,0,strlen($prefix))==$prefix)
$table = substr($table,strlen($prefix));
if(strlen($clip))
{
$clipboard = ParseClipboard($clip);
if($clipboard["table"] == $table)
{
$count = count(explode(",",$clipboard["ids"]));
}
else
$count = 0;
}
else
$count = 0;
return $count;
}
function CopyToClipboard($command,$idfield, $idlist)
{
global $objSession,$objCatList;
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$clip = $command."-".$objCatList->CurrentCategoryID().".".$this->SourceTable.".$idfield=".$list;
$objSession->SetVariable("ClipBoard",$clip);
}
function SortItems($asc=TRUE)
{
$done = FALSE;
$field = $this->SortField;
$ItemCount = $this->NumItems();
while(!$done)
{
$done=TRUE;
for($i=1;$i<$this->NumItems();$i++)
{
$doswap = FALSE;
if($asc)
{
$val1 = $this->Items[$i-1]->Get($field);
$val2 = $this->Items[$i]->Get($field);
$doswap = ($val1 > $val2);
}
else
{
$val1 = $this->Items[$i-1]->Get($field);
$val2 = $this->Items[$i]->Get($field);
$doswap = ($val1 < $val2);
}
if($doswap)
{
$this->SwapItems($i-1,$i);
$done = FALSE;
}
}
}
}
function &GetItem($ID,$LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items))
{
for($x=0;$x<count($this->Items);$x++)
{
$i =& $this->GetItemRefByIndex($x);
if($i->UniqueID()==$ID)
{
$found=TRUE;
break;
}
}
}
if(!$found)
{
if($LoadFromDB)
{
$n = NULL;
$n = new $this->classname();
$n->tablename = $this->SourceTable;
$n->LoadFromDatabase($ID);
$index = array_push($this->Items, $n);
$i =& $this->Items[count($this->Items)-1];
}
else
$i = FALSE;
}
return $i;
}
function GetItemByIndex($index)
{
return $this->Items[$index];
}
function &GetItemRefByIndex($index)
{
return $this->Items[$index];
}
function &GetItemByField($Field,$Value,$LoadFromDB=TRUE)
{
$found=FALSE;
if(is_array($this->Items))
{
foreach($this->Items as $i)
{
if($i->Get($Field)==$Value)
{
$found = TRUE;
break;
}
}
}
if(!$found && $LoadFromDB==TRUE)
{
$sql = "SELECT * FROM ".$this->SourceTable." WHERE $Field = '$Value'";
//echo $sql;
$res = $this->adodbConnection->Execute($sql);
if($res && !$res->EOF)
{
$i = $this->AddItemFromArray($res->fields);
$i->tablename = $this->SourceTable;
$i->Clean();
}
else
$i = FALSE;
}
return $i;
}
function GetPage($Page, $ItemsPerPage)
{
$result = array_slice($this->Items, ($Page * $ItemsPerPage) - $ItemsPerPage, $ItemsPerPage);
return $result;
}
function GetNumPages($ItemsPerPage)
{
return GetPageCount($ItemsPerPage,$this->QueryItemCount);
}
function &AddItemFromArray($data, $clean=FALSE)
{
$class = new $this->classname;
$class->SetFromArray($data);
$class->tablename = $this->SourceTable;
if($clean==TRUE)
$class->Clean();
//array_push($this->Items,$class);
$this->Items[] =& $class;
return $class;
}
function Query_Item($sql, $offset=-1,$rows=-1)
{
global $Errors;
$dummy =& $this->GetDummy();
if( !$dummy->TableExists() )
{
if($this->debuglevel) echo "ERROR: table <b>".$dummy->tablename."</b> missing.<br>";
$this->Clear();
return false;
}
if($rows>-1 && $offset>-1)
{
//echo "<b>Executing SelectLimit</b> $sql <b>Offset:</b> $offset,$rows<br>\n";
$result = $this->adodbConnection->SelectLimit($sql, $rows,$offset);
}
else {
//echo $sql."<br><br>";
$result = $this->adodbConnection->Execute($sql);
}
if ($result === false)
{
$Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Query_Item");
echo '<br><br>'.$sql.'<br><br>';
echo "Error: ".$this->adodbConnection->ErrorMsg()."<br>";
return false;
}
$this->Clear();
if($this->debuglevel > 0)
{
echo "This SQL: $sql<br>";
if( ($this->debuglevel > 1) && ($result->RecordCount() > 0) )
{
echo '<pre>'.print_r($result->GetRows(), true).'</pre>';
$result->MoveFirst();
}
}
LogEntry("SQL Loop Start\n");
$count = 0;
while ($result && !$result->EOF)
{
$count++;
$data = $result->fields;
$this->AddItemFromArray($data,TRUE);
if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 )
adodb_movenext($result);
else
$result->MoveNext();
}
LogEntry("SQL Loop End ($count iterations)\n");
return $this->Items;
}
function GetOrderClause($FieldVar,$OrderVar,$DefaultField,$DefaultVar,$Priority=TRUE,$UseTableName=FALSE)
{
global $objConfig, $objSession;
if($UseTableName)
{
$TableName = $this->SourceTable.".";
}
else
$TableName = "";
$PriorityClause = $TableName."EditorsPick DESC, ".$TableName."Priority DESC";
if(strlen(trim($FieldVar))>0)
{
if(is_object($objSession))
{
if(strlen($objSession->GetPersistantVariable($FieldVar))>0)
{
$OrderBy = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ".
$objSession->GetPersistantVariable($OrderVar));
$FieldUsed = $objSession->GetPersistantVariable($FieldVar);
}
}
$OrderBy = trim($OrderBy);
if (strlen(trim($OrderBy))==0)
{
if(!$UseTableName)
{
$OrderBy = trim($DefaultField." ".$DefaultVar);
}
else
{
if(strlen(trim($DefaultField))>0)
{
$OrderBy = $this->SourceTable.".".$DefaultField.".".$DefaultVar;
}
$FieldUsed=$DefaultField;
}
}
}
if(($FieldUsed != "Priority" || strlen($OrderBy)==0) && $Priority==TRUE)
{
if(strlen($OrderBy)==0)
{
$OrderBy = $PriorityClause;
}
else
$OrderBy = $PriorityClause.", ".$OrderBy;
}
return $OrderBy;
}
function GetResourceIDList()
{
$ret = array();
foreach($this->Items as $i)
array_push($ret,$i->Get("ResourceId"));
return $ret;
}
function GetFieldList($field)
{
$ret = array();
foreach($this->Items as $i)
array_push($ret,$i->Get($field));
return $ret;
}
function SetCommonField($FieldName,$FieldValue)
{
for($i=0;$i<$this->NumItems();$i++)
{
$this->Items[$i]->Set($FieldName,$fieldValue);
$this->Items[$i]->Update();
}
}
function ClearCategoryItems($CatId,$CatTable = "CategoryItems")
{
$CatTable = AddTablePrefix($CatTable);
$sql = "SELECT * FROM ".$this->SourceTable." INNER JOIN $CatTable ".
" ON (".$this->SourceTable.".ResourceId=$CatTable.ItemResourceId) WHERE CategoryId=$CatId";
$this->Clear();
$this->Query_Item($sql);
if($this->NumItems()>0)
{
foreach($this->Items as $i)
{
$i->DeleteCategoryItems($CatId,$CatTable);
}
}
}
function CopyToEditTable($idfield = null, $idlist = 0)
{
global $objSession;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function CreateEmptyEditTable($idfield = null)
{
global $objSession;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
$query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield = -1";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function CopyFromEditTable($idfield = null)
{
global $objSession;
$dropRelTableFlag = false;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
$sql = "SELECT * FROM $edit_table";
$rs = $this->adodbConnection->Execute($sql);
// echo $sql."<BR>";
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
$c->idfield = $idfield;
$c->Dirty();
if($c->Get($idfield)<1)
{
$old_id = $c->Get($idfield);
$c->UnsetIdField();
if(!is_numeric($c->Get("OrgId")) || $c->Get("OrgId")==0)
{
$c->Clean(array("OrgId"));
}
else
{
if($c->Get("Status") != -2)
{
$org = new $this->classname();
$org->LoadFromDatabase($c->Get("OrgId"));
$org->DeleteCustomData();
$org->Delete(TRUE);
$c->Set("OrgId",0);
}
}
$c->Create();
}
if(is_numeric($c->Get("ResourceId")))
{
if( isset($c->Related) && is_object($c->Related) )
{
$r = $c->Related;
$r->CopyFromEditTable($c->Get("ResourceId"));
$dropRelTableFlag = true;
}
unset($r);
if( isset($c->Reviews) && is_object($c->Reviews) )
{
$r = $c->Reviews;
$r->CopyFromEditTable($c->Get("ResourceId"));
}
}
if(!is_numeric($c->Get("OrgId")) || $c->Get("OrgId")==0)
{
$c->Clean(array("OrgId"));
}
else
{
if($c->Get("Status") != -2)
{
$org = new $this->classname();
$org->LoadFromDatabase($c->Get("OrgId"));
$org->DeleteCustomData();
$org->Delete(TRUE);
$c->Set("OrgId",0);
}
}
if(method_exists($c,"CategoryMemberList"))
{
$cats = $c->CategoryMemberList($objSession->GetEditTable("CategoryItems"));
//echo "CATS: [$cats]<br>";
$c->Update();
UpdateCategoryItems($c,$cats);
}
else
$c->Update();
unset($c);
unset($r);
$rs->MoveNext();
}
if ($dropRelTableFlag)
{
$objRelGlobal = new clsRelationshipList();
$objRelGlobal->PurgeEditTable();
}
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->GetEditTable("CategoryItems"));
}
function GetNextTempID()
{
// get next temporary id (lower then zero) from temp table
$db =& $this->adodbConnection;
$sql = 'SELECT MIN(%s) AS MinValue FROM %s';
return $db->GetOne( sprintf($sql, $this->GetIDField(), $this->SourceTable) ) - 1;
}
function PurgeEditTable($idfield = null)
{
global $objSession;
if($idfield == null) $idfield = $this->GetIDField();
$edit_table = $objSession->GetEditTable($this->SourceTable);
/* $rs = $this->adodbConnection->Execute("SELECT * FROM $edit_table");
while($rs && !$rs->EOF)
{
$data = $rs->fields;
$c = new $this->classname;
$c->SetFromArray($data);
$c->id_field = $idfield;
$c->tablename = $edit_table;
$c->Delete();
$rs->MoveNext();
}*/
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->Get("CategoryItems"));
}
function CopyCatListToEditTable($idfield, $idlist)
{
global $objSession;
$edit_table = $objSession->GetEditTable("CategoryItems");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
if(is_array($idlist))
{
$list = implode(",",$idlist);
}
else
$list = $idlist;
$query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield IN ($list)";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function CreateEmptyCatListTable($idfield)
{
global $objSession;
$edit_table = $objSession->GetEditTable("CategoryItems");
@$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
$query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield = -1";
$insert = "CREATE TABLE ".$edit_table." ".$query;
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($insert,ENT_NOQUOTES)."<br>\n";
$this->adodbConnection->Execute($insert);
}
function PurgeCatListEditTable()
{
global $objSession;
$edit_table = $objSession->GetEditTable("CategoryItems");
$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table");
}
function AdminSearchWhereClause($SearchList)
{
$sql = "";
if(!is_array($SearchList))
{
$SearchList = explode(",",$SearchList);
}
if(!count($SearchList) || !count($this->AdminSearchFields))
return "";
for($f=0;$f<count($SearchList);$f++)
{
$value = $SearchList[$f];
if(strlen($value))
{
$inner_sql = "";
for($i=0; $i<count($this->AdminSearchFields);$i++)
{
$field = $this->AdminSearchFields[$i];
if(strlen(trim($value)))
{
if(strlen($inner_sql))
$inner_sql .= " OR ";
$inner_sql .= $field." LIKE '%".$value."%'";
}
}
if(strlen($inner_sql))
{
$sql .= "(".$inner_sql.") ";
if($f<count($SearchList)-1)
$sql .= " AND ";
}
}
}
return $sql;
}
function BackupData($OutFileName,$Start,$Limit)
{
$fp=fopen($Outfile,"a");
if($fp)
{
if($Start==1)
{
$sql = "DELETE FROM ".$this->SourceTable;
fputs($fp,$sql);
}
$this->Query_Item("SELECT * FROM ".$this->SourceTable." LIMIT $Start, $Limit");
foreach($this->Items as $i)
{
$sql = $i->CreateSQL();
fputs($fp,$sql);
}
fclose($fp);
$this->Clear();
}
}
function RestoreData($InFileName,$Start,$Limit)
{
$res = -1;
$fp=fopen($InFileName,"r");
if($fp)
{
fseek($fp,$Start);
$Line = 0;
while($Line < $Limit)
{
$sql = fgets($fp,16384);
$this->adodbConnection->Execute($sql);
$Line++;
}
$res = ftell($fp);
fclose($fp);
}
return $res;
}
function Delete_Item($Id)
{
global $objCatList;
$l =& $this->GetItem($Id);
$l->BasePermission=$this->BasePermission;
$l->DeleteCategoryItems($objCatList->CurrentCategoryID());
}
function Move_Item($Id, $OldCat, $ParentTo)
{
global $objCatList;
$l = $this->GetItem($Id);
$l->BasePermission=$this->BasePermission;
$l->AddtoCategory($ParentTo);
$l->RemoveFromCategory($OldCat);
}
function Copy_Item($Id, $ParentTo)
{
$l = $this->GetItem($Id);
$l->BasePermission=$this->BasePermission;
$l->AddtoCategory($ParentTo);
}
}/* clsItemCollection */
class clsItemList extends clsItemCollection
{
var $Page;
var $PerPageVar;
var $EnablePaging;
var $MaxListCount = 0;
var $PageEnvar;
var $PageEnvarIndex;
var $ListType;
function clsItemList()
{
$this->clsItemCollection();
$this->EnablePaging = TRUE;
$this->PageEnvarIndex = "p";
}
function GetPageLimitSQL()
{
global $objConfig;
$limit = NULL;
if($this->EnablePaging)
{
if($this->Page<1)
$this->Page=1;
//echo "Limited to ".$objConfig->Get($this->PerPageVar)." items per page<br>\n";
if(is_numeric($objConfig->Get($this->PerPageVar)))
{
$Start = ($this->Page-1)*$objConfig->Get($this->PerPageVar);
$limit = "LIMIT ".$Start.",".$objConfig->Get($this->PerPageVar);
}
else
$limit = NULL;
}
else
{
if($this->MaxListCount)
{
$limit = "LIMIT 0, $MaxListCount";
}
}
return $limit;
}
function GetPageOffset()
{
global $objConfig;
$Start = 0;
if($this->EnablePaging)
{
if($this->Page<1)
$this->Page=1;
if(is_numeric($objConfig->Get($this->PerPageVar)))
{
$Start = ($this->Page-1)*$objConfig->Get($this->PerPageVar);
}
}
else
{
if((int)$this->MaxListCount==0)
$Start = -1;
}
return $Start;
}
function GetPageRowCount()
{
global $objConfig;
if($this->EnablePaging)
{
if($this->Page<1)
$this->Page=1;
// echo "PerPageVar = ".$this->PerPageVar."<br>\n";
// echo "<pre>"; print_r($objConfig); echo "</pre>";
return $objConfig->Get($this->PerPageVar);
}
else
return (int)$this->MaxListCount;
}
function Query_Item($sql,$limit=NULL)
{
if(strlen($limit))
{
$sql .= " ".$limit;
//echo "[$sql]<br>\n";
return parent::Query_Item($sql);
}
else
{
// echo "-------------------<br>$sql<br>\n";
// echo "Paging: ".$this->EnablePaging." Offset: ".$this->GetPageOffset()." Count: ".$this->GetPageRowCount()."<br>\n";
// echo "===================<br>\n";
return parent::Query_Item($sql,$this->GetPageOffset(),$this->GetPageRowCount());
}
}
function Query_List($whereClause,$orderByClause=NULL,$JoinCats=TRUE)
{
global $objSession, $Errors;
if($JoinCats)
{
$cattable = GetTablePrefix()."CategoryItems";
$t = $this->SourceTable;
$sql = "SELECT *,CategoryId FROM $t INNER JOIN $cattable ON $cattable.ItemResourceId=$t.ResourceId";
}
else
$sql = "SELECT * FROM ". $this->SourceTable;
if(trim($whereClause)!="")
{
if(isset($whereClause))
$sql = sprintf('%s WHERE %s',$sql,$whereClause);
}
if(strlen($orderByClause)>0)
{
if(substr($orderByClause,0,8)=="ORDER BY")
{
$sql .= " ".$orderByClause;
}
else
{
$sql .= " ORDER BY $orderByClause";
}
}
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo $sql."<br>\n";
return $this->Query_Item($sql);
}
function GetPageLinkList($dest_template=NULL,$page = "",$PagesToList=10, $HideEmpty=TRUE)
{
global $objConfig, $var_list_update, $var_list;
$v= $this->PageEnvar;
global ${$v};
if(!strlen($page))
$page = GetIndexURL();
$PerPage = $objConfig->Get($this->PerPageVar);
if($PerPage<1)
$PerPage=20;
$NumPages = ceil($this->GetNumPages($PerPage));
if($NumPages==1 && $HideEmpty)
return "";
if(strlen($dest_template))
{
$var_list_update["t"] = $dest_template;
}
else
$var_list_update["t"] = $var_list["t"];
$o = "";
if($this->Page==0 || !is_numeric($this->Page))
$this->Page=1;
if($this->Page>$NumPages)
$this->Page=$NumPages;
$StartPage = (int)$this->Page - ($PagesToList/2);
if($StartPage<1)
$StartPage=1;
$EndPage = $StartPage+($PagesToList-1);
if($EndPage>$NumPages)
{
$EndPage = $NumPages;
$StartPage = $EndPage-($PagesToList-1);
if($StartPage<1)
$StartPage=1;
}
$o = "";
if($StartPage>1)
{
${$v}[$this->PageEnvarIndex] = $this->Page-$PagesToList;
$prev_url = $page."?env=".BuildEnv();
$o .= "<A HREF=\"$prev_url\">&lt;&lt;</A>";
}
for($p=$StartPage;$p<=$EndPage;$p++)
{
if($p!=$this->Page)
{
${$v}[$this->PageEnvarIndex]=$p;
$href = $page."?env=".BuildEnv();
$o .= " <A HREF=\"$href\">$p</A> ";
}
else
{
$o .= " <SPAN class=\"current-page\">$p</SPAN>";
}
}
if($EndPage<$NumPages && $EndPage>0)
{
${$v}[$this->PageEnvarIndex]=$this->Page+$PagesToList;
$next_url = $page."?env=".BuildEnv();
$o .= "<A HREF=\"$next_url\"> &gt;&gt;</A>";
}
unset(${$v}[$this->PageEnvarIndex],$var_list_update["t"] );
return $o;
}
function GetAdminPageLinkList($url)
{
global $objConfig, $var_list_update, $var_list;
$v = $this->PageEnvar;
global ${$v};
if(strlen($this->PerPageVar)==0)
$this->PerPageVar = "Perpage_Links";
$PerPage = $objConfig->Get($this->PerPageVar);
if($PerPage<1)
$PerPage=20;
$NumPages = ceil($this->GetNumPages($PerPage));
//echo $this->CurrentPage." of ".$NumPages." Pages";
$o = "";
if($this->Page>$NumPages)
$this->Page=$NumPages;
$StartPage = $this->Page - 5;
if($StartPage<1)
$StartPage=1;
$EndPage = $StartPage+9;
if($EndPage>$NumPages)
{
$EndPage = $NumPages;
$StartPage = $EndPage-9;
if($StartPage<1)
$StartPage=1;
}
$o = "";
if($StartPage>1)
{
${$v}[$this->PageEnvarIndex]= $this->Page-10;
$prev_url = $url."?env=".BuildEnv();
$o .= "<A HREF=\"$prev_url\">&lt;&lt;</A>";
}
for($p=$StartPage;$p<=$EndPage;$p++)
{
if($p!=$this->Page)
{
${$v}[$this->PageEnvarIndex]=$p;
$href = $url."?env=".BuildEnv();
$o .= " <A HREF=\"$href\" class=\"NAV_URL\">$p</A> ";
}
else
{
$o .= "<SPAN class=\"CURRENT_PAGE\">$p</SPAN>";
}
}
if($EndPage<$NumPages)
{
${$v}[$this->PageEnvarIndex]=$this->Page+10;
$next_url = $url."?env=".BuildEnv();
$o .= "<A HREF=\"$next_url\"> &gt;&gt;</A>";
}
unset( ${$v}[$this->PageEnvarIndex]);
return $o;
}
}
function ParseClipboard($clip)
{
$ret = array();
$parts = explode(".",$clip,3);
$command = $parts[0];
$table = $parts[1];
$prefix = GetTablePrefix();
if(substr($table,0,strlen($prefix))==$prefix)
$table = substr($table,strlen($prefix));
$subparts = explode("=",$parts[2],2);
$idfield = $subparts[0];
$idlist = $subparts[1];
$cmd = explode("-",$command);
$ret["command"] = $cmd[0];
$ret["source"] = $cmd[1];
$ret["table"] = $table;
$ret["idfield"] = $idfield;
$ret["ids"] = $idlist;
//print_pre($ret);
return $ret;
}
function UpdateCategoryItems($item,$NewCatList)
{
global $objCatList;
$CurrentList = explode(",",$item->CategoryMemberList());
$del_list = array();
$ins_list = array();
if(!is_array($NewCatList))
{
if(strlen(trim($NewCatList))==0)
$NewCatList = $objCatList->CurrentCategoryID();
$NewCatList = explode(",",$NewCatList);
}
//print_r($NewCatList);
for($i=0;$i<count($NewCatList);$i++)
{
$cat = $NewCatList[$i];
if(!in_array($cat,$CurrentList))
$ins_list[] = $cat;
}
for($i=0;$i<count($CurrentList);$i++)
{
$cat = $CurrentList[$i];
if(!in_array($cat,$NewCatList))
$del_list = $cat;
}
for($i=0;$i<count($ins_list);$i++)
{
$cat = $ins_list[$i];
$item->AddToCategory($cat);
}
for($i=0;$i<count($del_list);$i++)
{
$cat = $del_list[$i];
$item->RemoveFromCategory($cat);
}
}
class clsCatItemList extends clsItemList
{
var $PerPageVarLong;
var $PerPageShortVar;
var $Query_SortField;
var $Query_SortOrder;
var $ItemType;
function clsCatItemList()
{
$this->ClsItemList();
$this->Query_SortField = array();
$this->Query_SortOrder = array();
}
function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE)
{
global $objSession;
if($UseTableName)
{
$TableName = $this->SourceTable.".";
}
else {
$TableName = "";
}
$Orders = array();
if($EditorsPick)
{
$Orders[] = $TableName."EditorsPick DESC";
}
if($Priority)
{
$Orders[] = $TableName."Priority DESC";
}
if(count($this->Query_SortField)>0)
{
for($x=0; $x<count($this->Query_SortField); $x++)
{
$FieldVar = $this->Query_SortField[$x];
$OrderVar = $this->Query_SortOrder[$x];
if(is_object($objSession))
{
$FieldVarData = $objSession->GetPersistantVariable($FieldVar);
if(strlen($FieldVarData)>0)
{
$Orders[] = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ".
$objSession->GetPersistantVariable($OrderVar));
}
}
}
}
if(count($Orders)>0)
{
$OrderBy = "ORDER BY ".implode(", ",$Orders);
}
else
$OrderBy="";
return $OrderBy;
}
function AddSortField($SortField, $SortOrder)
{
if(strlen($SortField))
{
$this->Query_SortField[] = $SortField;
$this->Query_SortOrder[] = $SortOrder;
}
}
function ClearSortFields()
{
$this->Query_SortField = array();
$this->Query_SortOrder = array();
}
/* skeletons in this closet */
function GetNewValue($CatId=NULL)
{
return 0;
}
function GetPopValue($CategoryId=NULL)
{
return 0;
}
/* end of skeletons */
function GetCountSQL($PermName,$CatId=NULL, $GroupId=NULL, $AdditonalWhere="")
{
global $objSession, $objPermissions, $objCatList;
$ltable = $this->SourceTable;
$acl = $objSession->GetACLClause();
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$VIEW = $objPermissions->GetPermId($PermName);
$sql = "SELECT count(*) as CacheVal FROM $ltable ";
$sql .="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) ";
$sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) ";
$sql .="INNER JOIN $ptable ON ($cattable.CategoryId=$ptable.CategoryId) ";
$sql .="WHERE ($acl AND PermId=$VIEW AND $cattable.PrimaryCat=1 AND $CategoryTable.Status=1) ";
if(strlen($AdditonalWhere)>0)
{
$sql .= "AND (".$AdditonalWhere.")";
}
return $sql;
}
function SqlCategoryList($attribs = array())
{
$CatTable = GetTablePrefix()."CategoryItems";
$t = $this->SourceTable;
$sql = "SELECT *,$CatTable.CategoryId FROM $t INNER JOIN $CatTable ON $CatTable.ItemResourceId=$t.ResourceId ";
$sql .="WHERE ($CatTable.CategoryId=".$catid." AND $t.Status=1)";
return $sql;
}
function CategoryCount($attribs=array())
{
global $objCatList, $objCountCache;
$cat = $attribs["_catid"];
if(!is_numeric($cat))
{
$cat = $objCatList->CurrentCategoryID();
}
if((int)$cat>0)
$c = $objCatList->GetCategory($cat);
$CatTable = GetTablePrefix()."CategoryItems";
$t = $this->SourceTable;
$sql = "SELECT count(*) as MyCount FROM $t INNER JOIN $CatTable ON ($CatTable.ItemResourceId=$t.ResourceId) ";
if($attribs["_subcats"])
{
$ctable = $objCatList->SourceTable;
$sql .= "INNER JOIN $ctable ON ($CatTable.CategoryId=$ctable.CategoryId) ";
$sql .= "WHERE (ParentPath LIKE '".$c->Get("ParentPath")."%' ";
if(!$attribs["_countcurrent"])
{
$sql .=" AND $ctable.CategoryId != $cat) ";
}
else
$sql .=") ";
}
else
$sql .="WHERE ($CatTable.CategoryId=".$cat." AND $t.Status=1) ";
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$sql .= "AND ($t.CreatedOn>=$today) ";
}
//echo $sql."<br><br>\n";
$rs = $this->adodbConnection->Execute($sql);
$ret = "";
if($rs && !$rs->EOF)
$ret = (int)$rs->fields["MyCount"];
return $ret;
}
function SqlGlobalCount($attribs=array())
{
global $objSession;
$p = $this->BasePermission.".VIEW";
$t = $this->SourceTable;
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where = "($t.CreatedOn>=$today)";
}
if($attribs["_grouponly"])
{
$GroupList = $objSession->Get("GroupList");
}
else
$GroupList = NULL;
$sql = $this->GetCountSQL($p,NULL,$GroupList,$where);
return $sql;
}
function DoGlobalCount($attribs)
{
global $objCountCache;
$cc = $objCountCache->GetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)$attribs["_today"], 3600);
if(!is_numeric($cc))
{
$sql = $this->SqlGlobalCount($attribs);
$ret = QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)$attribs["_today"],$ret);
}
else
$ret = $cc;
return $ret;
}
function CacheListExtraId($ListType)
{
global $objSession;
if(!strlen($ListType))
$ListType="_";
switch($ListType)
{
case "_":
$ExtraId = $objSession->Get("GroupList");
break;
case "category":
$ExtraId = $objSession->Get("GroupList");
break;
case "myitems":
$ExtraId = $objSession->Get("PortalUserId");
break;
case "hot":
$ExtraId = $objSession->Get("GroupList");
break;
case "pop":
$ExtraId = $objSession->Get("GroupList");
break;
case "pick":
$ExtraId = $objSession->Get("GroupList");
break;
case "favorites":
$ExtraId = $objSession->Get("PortalUserId");
break;
case "new":
$ExtraId = $objSession->Get("GroupList");
break;
}
return $ExtraId;
}
function CacheListType($ListType)
{
if(!strlen($ListType))
$ListType="_";
switch($ListType)
{
case "_":
$ListTypeId = 0;
break;
case "category":
$ListTypeId = 1;
break;
case "myitems":
$ListTypeId = 2;
break;
case "hot":
$ListTypeId = 3;
break;
case "pop":
$ListTypeId = 4;
break;
case "pick":
$ListTypeId = 5;
break;
case "favorites":
$ListTypeId = 6;
break;
case "new":
$ListTypeId = 8;
break;
}
return $ListTypeId;
}
function PerformItemCount($attribs=array())
{
global $objCountCache, $objSession;
$ret = "";
$ListType = $attribs["_listtype"];
if(!strlen($ListType))
$ListType="_";
$ListTypeId = $this->CacheListType($ListType);
//echo "ListType: $ListType ($ListTypeId)<br>\n";
$ExtraId = $this->CacheListExtraId($ListType);
switch($ListType)
{
case "_":
$ret = $this->DoGlobalCount($attribs);
break;
case "category":
$ret = $this->CategoryCount($attribs);
break;
case "myitems":
$sql = $this->SqlMyItems($attribs);
break;
case "hot":
$sql = $this->SqlHotItems($attribs);
break;
case "pop":
$sql = $this->SqlPopItems($attribs);
break;
case "pick":
$sql = $this->SqlPickItems($attribs);
break;
case "favorites":
$sql = $this->SqlFavorites($attribs);
break;
case "search":
$sql = $this->SqlSearchItems($attribs);
break;
case "new":
$sql = $this->SqlNewItems($attribs);
break;
}
//echo "SQL: $sql<br>";
if(strlen($sql))
{
if(is_numeric($ListTypeId))
{
$cc = $objCountCache->GetValue($ListTypeId,$this->ItemType,$ExtraId,(int)$attribs["_today"], 3600);
if(!is_numeric($cc) || $attribs['_nocache'] == 1)
{
$ret = QueryCount($sql);
$objCountCache->SetValue($ListTypeId,$this->ItemType,$ExtraId,(int)$attribs["_today"],$ret);
}
else
$ret = $cc;
}
else
$ret = QueryCount($sql);
}
return $ret;
}
function GetJoinedSQL($PermName, $CatId=NULL, $AdditionalWhere="")
{
global $objSession, $objPermissions;
$ltable = $this->SourceTable;
$acl = $objSession->GetACLClause();
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$VIEW = $objPermissions->GetPermId($PermName);
$sql ="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) ";
$sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) ";
$sql .= "INNER JOIN $ptable ON ($cattable.CategoryId=$ptable.CategoryId) ";
$sql .="WHERE ($acl AND PermId=$VIEW AND PrimaryCat=1 AND $CategoryTable.Status=1) ";
if(is_numeric($CatId))
{
$sql .= " AND ($CategoryTable.CategoryId=$CatId) ";
}
if(strlen($AdditionalWhere)>0)
{
$sql .= "AND (".$AdditionalWhere.")";
}
return $sql;
}
function CountFavorites($attribs)
{
if($attribs["_today"])
{
global $objSession, $objConfig, $objPermissions;
$acl = $objSession->GetACLClause();
$favtable = GetTablePrefix()."Favorites";
$ltable = $this->SourceTable;
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1";
$where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType;
$p = $this->BasePermission.".VIEW";
$sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) ";
$sql .= $this->GetJoinedSQL($p,NULL,$where);
$ret = QueryCount($sql);
}
else
{
if (!$this->ListType == "favorites")
{
$this->ListType = "favorites";
$this->LoadFavorites($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
}
return $ret;
}
function CountPickItems($attribs)
{
if (!$this->ListType == "pick")
{
$this->ListType = "pick";
$this->LoadPickItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountMyItems($attribs)
{
if (!$this->ListType == "myitems")
{
$this->ListType = "myitems";
$this->LoadMyItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountHotItems($attribs)
{
if (!$this->ListType == "hotitems")
{
$this->ListType = "hotitems";
$this->LoadHotItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountNewItems($attribs)
{
if (!$this->ListType == "newitems")
{
$this->ListType = "newitems";
$this->LoadNewItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountPopItems($attribs)
{
if (!$this->ListType == "popitems")
{
$this->ListType = "popitems";
$this->LoadPopItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function CountSearchItems($attribs)
{
if (!$this->ListType == "search")
{
$this->ListType = "search";
$this->LoadSearchItems($attribs);
$ret = $this->QueryItemCount;
}
else
$ret = $this->QueryItemCount;
return $ret;
}
function SqlFavorites($attribs)
{
global $objSession, $objConfig, $objPermissions;
$acl = $objSession->GetACLClause();
$favtable = GetTablePrefix()."Favorites";
$ltable = $this->SourceTable;
$cattable = GetTablePrefix()."CategoryItems";
$CategoryTable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1";
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType;
}
$p = $this->BasePermission.".VIEW";
$sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) ";
$sql .= $this->GetJoinedSQL($p,NULL,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadFavorites($attribs)
{
global $objSession, $objCountCache;
$sql = $this->SqlFavorites($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount = QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount = (int)$CachedCount;
return $this->Query_Item($sql);
}
function SqlPickItems($attribs)
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
//$JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ".$TableName.".EditorsPick=1 AND ".$TableName.".Status=1";
}
else
{
$where = $TableName.".EditorsPick=1 AND ".$TableName.".Status=1 ";
$catid=NULL;
}
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$CatUd,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadPickItems($attribs)
{
global $objSession, $objCountCache;
$sql = $this->SqlPickItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlMyItems($attribs= array())
{
global $objSession;
$TableName = $this->SourceTable;
$where = " ".$TableName.".Status>-1 AND ".$TableName.".CreatedById=".$objSession->Get("PortalUserId");
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$CatUd,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadMyItems($attribs=array())
{
global $objSession,$objCountCache;
$sql = $this->SqlMyItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlNewItems($attribs = array())
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
//$JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
if($attribs["_today"])
{
$cutoff = mktime(0,0,0,date("m"),date("d"),date("Y"));
}
else
{
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$cutoff = $this->GetNewValue($catid);
}
else
$cutoff = $this->GetNewValue();
}
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ((".$TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 ";
}
else
{
$where = "((".$TableName.".CreatedOn >=".$this->GetNewValue()." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 ";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$CatUd,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadNewItems($attribs)
{
global $objSession,$objCountCache;
$sql = $this->SqlNewItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlPopItems($attribs)
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
//$JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ((".$TableName.".Hits >=".$this->GetLinkPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1";
}
else
{
$where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 ";
$where = "((".$TableName.".Hits >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 ";
}
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$sql .= $this->GetJoinedSQL($p,$catid,$where);
$OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE);
$sql .= " ".$OrderBy;
return $sql;
}
function LoadPopItems($attribs)
{
global $objSession,$objCountCache;
$sql = $this->SqlPopItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],3600);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlHotItems($attribs)
{
global $objSession, $objCatList;
$catid = (int)$attribs["_catid"];
$scope = (int)$attribs["_scope"];
// $JoinCats = (int)$attribs["_catinfo"] || $scope;
$TableName = $this->SourceTable;
$OrderBy = $TableName.".CachedRating DESC";
if($scope)
{
if (!$catid)
{
$catid = $objCatList->CurrentCategoryID();
}
$where = "CategoryId =".$catid." AND ((".$TableName.".CachedRating >=".$this->GetHotValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1";
}
else
{
$where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 ";
}
if($attribs["_today"])
{
$today = mktime(0,0,0,date("m"),date("d"),date("Y"));
$where .= " AND ($TableName.CreatedOn>=$today)";
}
$CategoryTable = GetTablePrefix()."Category";
$sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.CachedNavBar FROM $TableName ";
$p = $this->BasePermission.".VIEW";
$CatId = !$scope? NULL : $catid;
$sql .= $this->GetJoinedSQL($p,$CatId,$where);
if(strlen($OrderBy))
$sql .= " ORDER BY $OrderBy ";
return $sql;
}
function LoadHotItems($attribs)
{
global $objSession,$objCountCache;
$sql = $this->SqlHotItems($attribs);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
if($attribs["_shortlist"])
{
$this->PerPageVar = $this->PerPageShortVar;
}
else
$this->PerPageVar = $this->PerPageVarLong;
$CachedCount = $objCountCache->GetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"], 0);
if(!is_numeric($CachedCount))
{
$this->QueryItemCount= QueryCount($sql);
$objCountCache->SetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"],$this->QueryItemCount);
}
else
$this->QueryItemCount=$CachedCount;
return $this->Query_Item($sql);
}
function SqlSearchItems($attribs = array())
{
global $objConfig, $objItemTypes, $objSession, $objPermissions, $CountVal;
$acl = $objSession->GetACLClause();
$this->Clear();
//$stable = "ses_".$objSession->GetSessionKey()."_Search";
$stable = $objSession->GetSearchTable();
$ltable = $this->SourceTable;
$catitems = GetTablePrefix()."CategoryItems";
$cattable = GetTablePrefix()."Category";
$ptable = GetTablePrefix()."PermCache";
$p = $this->BasePermission.".VIEW";
$i = new $this->classname();
$sql = "SELECT $cattable.CategoryId,$cattable.CachedNavbar,$ltable.*, Relevance FROM $stable ";
$sql .= "INNER JOIN $ltable ON ($stable.ItemId=$ltable.".$i->id_field.") ";
$where = "ItemType=".$this->ItemType." AND $ltable.Status=1";
$sql .= $this->GetJoinedSQL($p,NULL,$where);
$sql .= " ORDER BY EdPick DESC,Relevance DESC ";
$tmp = $this->QueryOrderByClause(FALSE,TRUE,TRUE);
$tmp = substr($tmp,9);
if(strlen($tmp))
{
$sql .= ", ".$tmp." ";
}
return $sql;
}
function LoadSearchItems($attribs = array())
{
global $CountVal, $objSession;
//echo "Loading <b>".get_class($this)."</b> Search Items<br>";
$sql = $this->SqlSearchItems($attribs);
//echo "$sql<br>";
$this->Query_Item($sql);
$Keywords = GetKeywords($objSession->GetVariable("Search_Keywords"));
//echo "SQL Loaded ItemCount (<b>".get_class($this).'</b>): '.$this->NumItems().'<br>';
for($i = 0; $i < $this->NumItems(); $i++)
{
$this->Items[$i]->Keywords = $Keywords;
}
if(is_numeric($CountVal[$this->ItemType]))
{
$this->QueryItemCount = $CountVal[$this->ItemType];
// echo "CACHE: <pre>"; print_r($CountVal); echo "</pre><BR>";
}
else
{
$this->QueryItemCount = QueryCount($sql);
-// echo "SQL: ".$sql."<BR>";
+ //echo "<b>SQL</b>: ".$sql."<br><br>";
$CountVal[$this->ItemType] = $this->QueryItemCount;
}
}
function PasteFromClipboard($TargetCat,$NameField="")
{
global $objSession,$objCatList;
$clip = $objSession->GetVariable("ClipBoard");
if(strlen($clip))
{
$ClipBoard = ParseClipboard($clip);
$IsCopy = (substr($ClipBoard["command"],0,4)=="COPY") || ($ClipBoard["source"] == $TargetCat);
$item_ids = explode(",",$ClipBoard["ids"]);
for($i=0;$i<count($item_ids);$i++)
{
$item = $this->GetItem($item_ids[$i]);
if(!$IsCopy) // paste to other category then current
{
$item->MoveToCategory($ClipBoard["source"],$TargetCat);
$clip = str_replace("CUT","COPY",$clip);
$objSession->SetVariable("ClipBoard",$clip);
}
else
{
$item->CopyToNewResource($TargetCat,$NameField); // create item copy, but with new ResourceId
$item->AddToCategory($TargetCat);
UpdateCategoryCount($item->type,$TargetCat);
}
}
}
}
}
?>
Property changes on: trunk/kernel/include/parseditem.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/kernel/searchaction.php
===================================================================
--- trunk/kernel/searchaction.php (revision 90)
+++ trunk/kernel/searchaction.php (revision 91)
@@ -1,174 +1,191 @@
<?php
/* action handlers for listview searches */
+
+ //echo "in search action (global)<br>";
+ //print_pre($_REQUEST);
+
switch($Action)
{
case "m_SearchWord": /* browse and modify*/
$searchlist = trim($objSession->GetVariable("SearchWord"));
if($_POST["NewSearch"]==1)
$searchlist = "";
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["SearchWord"];
$objSession->SetVariable("SearchWord",$searchlist);
$objSession->SetVariable("SearchType",$_POST["SearchType"]);
$objSession->SetVariable("SearchScope",(int)$_POST["SearchScope"]);
break;
case "m_ClearSearch": /* browse and modify*/
$objSession->SetVariable("SearchWord","");
break;
case "m_user_search": /* user list */
$searchlist = trim($objSession->GetVariable("UserSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("UserSearchWord",$searchlist);
$objSession->SetVariable("Page_Userlist",1);
break;
case "m_user_search_reset": /*user list */
$objSession->SetVariable("UserSearchWord","");
$objSession->SetVariable("Page_Userlist",1);
break;
case "m_summary_search": /* summary list */
$searchlist = trim($objSession->GetVariable("UserSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("SummarySearchWord",$searchlist);
$objSession->SetVariable("Page_Summary",1);
break;
case "m_summary_search_reset": /* summary list */
$objSession->SetVariable("SummarySearchWord","");
$objSession->SetVariable("Page_Summary",1);
break;
case "m_userselect_search": /* popup user list */
$searchlist = trim($objSession->GetVariable("UserSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("UserSelectSearchWord",$searchlist);
$objSession->SetVariable("Page_UserSelect",1);
break;
case "m_userselect_search_reset": /* popup user list */
$objSession->SetVariable("UserSelectSearchWord","");
$objSession->SetVariable("Page_UserSelect",1);
break;
case "m_group_search": /* group list */
$searchlist = trim($objSession->GetVariable("GroupSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("GroupSearchWord",$searchlist);
$objSession->SetVariable("Page_Grouplist",1);
break;
case "m_group_search_reset": /*group list */
$objSession->SetVariable("GroupSearchWord","");
break;
case "m_rel_search": /* category relations list */
$searchlist = trim($objSession->GetVariable("CatRelSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("CatRelSearchWord",$searchlist);
$objSession->SetVariable("Page_Relations",1);
break;
case "m_rel_search_reset": /* category relations list */
$objSession->SetVariable("CatRelSearchWord","");
break;
case "m_group_search": /* group list */
$searchlist = trim($objSession->GetVariable("GroupSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("GroupSearchWord",$searchlist);
$objSession->SetVariable("Page_Grouplist",1);
break;
case "m_group_search_reset": /*group list */
$objSession->SetVariable("GroupSearchWord","");
break;
case "m_phrase_search": /* category relations list */
$searchlist = trim($objSession->GetVariable("PhraseSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("PhraseSearchWord",$searchlist);
$objSession->SetVariable("Page_Phrase",1);
break;
case "m_phrase_search_reset": /* category relations list */
$objSession->SetVariable("PhraseSearchWord","");
$objSession->SetVariable("Page_Phrase",1);
break;
case "m_template_file_search": /* theme template file list */
$searchlist = trim($objSession->GetVariable("TemplateSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("TemplateSearchWord",$searchlist);
$objSession->SetVariable("Page_Template",1);
break;
case "m_template_file_search_reset": /* theme template file list */
$objSession->SetVariable("TemplateSearchWord","");
$objSession->SetVariable("Page_Template",1);
break;
case "m_lang_search": /* language package list */
$searchlist = trim($objSession->GetVariable("LangSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("LangSearchWord",$searchlist);
$objSession->SetVariable("Page_LV_Lang",1);
break;
case "m_lang_search_reset": /* language package list */
$objSession->SetVariable("LangSearchWord","");
$objSession->SetVariable("Page_LV_Lang",1);
break;
case "m_emailevent_search": /* Email event list */
$searchlist = trim($objSession->GetVariable("EmailEventSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("EmailEventSearchWord",$searchlist);
$objSession->SetVariable("Page_Email",1);
break;
case "m_emailevent_search_reset":
$objSession->SetVariable("EmailEventSearchWord","");
$objSession->SetVariable("Page_Email",1);
break;
case "m_langemailevent_search": /* Email event list */
$searchlist = trim($objSession->GetVariable("LangEmailEventSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("LangEmailEventSearchWord",$searchlist);
$objSession->SetVariable("Page_LangEmail",1);
break;
case "m_langemailevent_search_reset":
$objSession->SetVariable("LangEmailEventSearchWord","");
$objSession->SetVariable("Page_LangEmail",1);
break;
case "m_rule_search": /* Email event list */
$searchlist = trim($objSession->GetVariable("RuleSearchWord"));
if(strlen($searchlist)>0)
$searchlist = ",";
$searchlist = $_POST["list_search"];
$objSession->SetVariable("RuleSearchWord",$searchlist);
$objSession->SetVariable("Page_BanRules",1);
break;
case "m_rule_search_reset":
$objSession->SetVariable("RuleSearchWord","");
$objSession->SetVariable("Page_BanRules",1);
- break;
+ break;
-
+ // Theme List Search
+ case 'm_theme_search':
+ echo "in search action (themes)<br>";
+ $searchlist = trim( $objSession->GetVariable("ThemeSearchWord") );
+ if(strlen($searchlist) > 0) $searchlist = ",";
+ $searchlist = $_POST["list_search"];
+ $objSession->SetVariable("ThemeSearchWord",$searchlist);
+ $objSession->SetVariable("Page_LV_Themes",1);
+ break;
+
+ case 'm_theme_search_reset':
+ $objSession->SetVariable("ThemeSearchWord","");
+ $objSession->SetVariable("Page_LV_Themes",1);
+ break;
}
?>
Property changes on: trunk/kernel/searchaction.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1
\ No newline at end of property
+1.2
\ No newline at end of property
Index: trunk/kernel/frontaction.php
===================================================================
--- trunk/kernel/frontaction.php (revision 90)
+++ trunk/kernel/frontaction.php (revision 91)
@@ -1,832 +1,832 @@
<?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
{
if ($objSession->Login($_POST["login_user"], md5($_POST["login_password"])) == FALSE)
{
$FormError["login"]["login_password"] = language("lu_incorrect_login");
}
else
{
if(!headers_sent() && ($_POST["usercookie"]==1 || $_GET["usercookie"]==1))
{
$c = $_POST["login_user"]."|";
$pw = $_POST["login_password"];
if(strlen($pw)<31)
$pw = md5($pw);
$c .= $pw;
setcookie("login",$c,time()+2592000);
}
$dest = $_POST["dest"];
if(!strlen($dest))
$dest = $_GET["dest"];
if(!strlen($dest))
$dest = $_POST["DestTemplate"];
if(!strlen($dest))
$dest = $_GET["DestTemplate"];
if(strlen($dest))
{
$var_list["t"] = $dest;
//header("Location: ../../index.php?env=" . BuildEnv());
}
// echo "DEST: ".$t; die();
}
}
}
}
break;
case "m_forgotpw":
$MissingCount = SetMissingDataErrors("forgotpw");
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"));
}
if($found)
{
$newpw = makepassword();
$u->Set("Password",$newpw);
$u->Update();
$u->SendUserEventMail("USER.PSWD",$u->Get("PortalUserId"));
$u->SendAdminEventMail("USER.PSWD");
$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");
$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"));
}
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);
}
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":
$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();
}
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);
}
$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);
$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);
}
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_field_sort"]);
$objSession->SetVariable("Category_Sortorder",$_POST["cat_sort_order"]);
break;
case "m_add_cat_confirm":
// phpinfo(INFO_VARIABLES);
$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");
$name = $_POST["name"];
$desc = $_POST["description"];
$metadesc = $_POST["meta_description"];
$keywords = $_POST["meta_keywords"];
$parent = $objCatList->CurrentCategoryID();
$cat =& $objCatList->Add($parent, $name, inp_escape($desc,0), $CreatedOn,
0, $perm, 2, 2, 2, 0, $keywords,$metadesc);
$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_escape($_POST["review_text"],$html);
$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 = $_POST["suggest_email"];
if (strlen($email))
{
if(ValidEmail($email))
{
$sql = "SELECT * FROM ".GetTablePrefix()."SuggestMail WHERE email='".inp_escape($email,0)."' 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 ('".inp_escape($email,0)."','".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");
if(strlen($keywords))
{
$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_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>";
+ //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");
if(strlen($keywords))
{
$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_no_keyword");
}
break;
}
?>
Property changes on: trunk/kernel/frontaction.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/admin/config/config_theme.php
===================================================================
--- trunk/admin/config/config_theme.php (revision 90)
+++ trunk/admin/config/config_theme.php (revision 91)
@@ -1,223 +1,225 @@
<?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($_SERVER['SCRIPT_FILENAME']));
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;
require_once($pathtoroot."kernel/startup.php");
//admin only util
$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";
//$pathtolocal = $pathtoroot."in-news/";
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."/toolbar.php");
require_once($pathtoroot.$admin."/listview/listview.php");
$section = "in-portal:configure_themes";
$m = GetModuleArray();
foreach($m as $key=>$value)
{
$path = $pathtoroot. $value."admin/include/parser.php";
if(file_exists($path))
{
include_once($path);
}
}
unset($objEditItems);
$envar = "env=".BuildEnv();
$formaction = $_SERVER["PHP_SELF"]."?".$envar;
$sec = $objSections->GetSection($section);
$objListToolBar = new clsToolBar();
$objListToolBar->Set("section",$section);
$objListToolBar->Set("load_menu_func","");
$objListToolBar->Set("CheckClass","ThemeChecks");
$objListToolBar->Set("CheckForm","theme");
$listImages = array();
//$img, $alt, $link, $onMouseOver, $onMouseOut, $onClick
$objListToolBar->Add("new_theme", "la_ToolTip_New_Theme",$adminURL."/config/addtheme.php?$envar&new=1","swap('new_theme','toolbar/tool_new_theme_f2.gif');",
"swap('new_theme', 'toolbar/tool_new_theme.gif');","",$imagesURL."/toolbar/tool_new_theme.gif");
$objListToolBar->Add("theme_edit","la_ToolTip_Edit","#", "if (ThemeChecks.itemChecked()) swap('theme_edit','toolbar/tool_edit_f2.gif');",
"if (ThemeChecks.itemChecked()) swap('theme_edit', 'toolbar/tool_edit.gif');","if (ThemeChecks.itemChecked()) ThemeChecks.check_submit('addtheme', '');",
"tool_edit.gif",TRUE,TRUE);
$listImages[] = "ThemeChecks.addImage('theme_edit','$imagesURL/toolbar/tool_edit.gif','$imagesURL/toolbar/tool_edit_f3.gif',1); ";
$objListToolBar->Add("theme_del","la_ToolTip_Delete","#", "if (ThemeChecks.itemChecked()) swap('theme_del','toolbar/tool_delete_f2.gif');",
"if (ThemeChecks.itemChecked()) swap('theme_del', 'toolbar/tool_delete.gif');","if (ThemeChecks.itemChecked()) ThemeChecks.check_submit('config_theme', 'm_theme_delete');",
"tool_delete.gif",FALSE,TRUE);
$listImages[] = "ThemeChecks.addImage('theme_del','$imagesURL/toolbar/tool_delete.gif','$imagesURL/toolbar/tool_delete_f3.gif',1); ";
$objListToolBar->Add("theme_primary","la_ToolTip_Primary","#", "if (ThemeChecks.itemChecked()) swap('theme_primary','toolbar/tool_primary_theme_f2.gif');",
"if (ThemeChecks.itemChecked()) swap('theme_primary', 'toolbar/tool_primary_theme.gif');","if (ThemeChecks.itemChecked()) ThemeChecks.check_submit('config_theme', 'm_theme_primary');",
"tool_primary_theme.gif");
$listImages[] = "ThemeChecks.addImage('theme_primary','$imagesURL/toolbar/tool_primary_theme.gif','$imagesURL/toolbar/tool_primary_theme_f3.gif',1); ";
$objListToolBar->AddToInitScript($listImages);
$objListToolBar->AddToInitScript("fwLoadMenus(); \n");
$objThemes->CreateMissingThemes();
$SearchWords = $objSession->GetVariable("ThemeSearchWord");
if(strlen($SearchWords))
{
$where = $objUsers->AdminSearchWhereClause($SearchWords);
}
else
$where = "";
$order = trim($objConfig->Get("Theme_LV_Sortfield")." ".$objConfig->Get("Theme_LV_Sortorder"));
$sql = "SELECT t.*,ELT(t.enabled+1,'".admin_language("la_Text_Disabled")."','".admin_language("la_Text_Enabled")."') as Status ";
$sql .= "FROM ".GetTablePrefix()."Theme as t";
if(strlen($where))
$sql .= "WHERE ".$where." ";
if(strlen($order))
$sql .= " ORDER BY ".$order;
-$sql .= ' '.GetLimitSQL($objSession->GetVariable("Page_LV_Themes"),$objConfig->Get("Perpage_LV_Themes"));
+$objListView = new clsListView($objListToolBar);
+$objListView->CurrentPageVar = "Page_LV_Themes";
+$objListView->PerPageVar = "Perpage_LV_Themes";
+$sql .= ' '.$objListView->GetLimitSQL();
$objThemes->Query_Item($sql);
$itemcount = TableCount(GetTablePrefix()."Theme", $where,0);
if($objSession->HasSystemPermission("DEBUG.LIST"))
echo htmlentities($sql,ENT_NOQUOTES)."<br>\n";
-$objListView = new clsListView($objListToolBar,$objThemes);
+$objListView->SetListItems($objThemes);
$objListView->IdField = "ThemeId";
$order = $objConfig->Get("Theme_LV_Sortfield");
$objListView->ColumnHeaders->Add("Name",admin_language("la_prompt_Name"),1,0,$order,"width=\"30%\"","Theme_LV_Sortfield","Theme_LV_Sortorder","Name");
$objListView->ColumnHeaders->Add("Description",admin_language("la_prompt_Description"),1,0,$order,"width=\"30%\"","Theme_LV_Sortfield","Theme_LV_Sortorder","Description");
$objListView->ColumnHeaders->Add("Status",admin_language("la_ColHeader_Status"),1,0,$order,"width=\"30%\"","Theme_LV_Sortfield","Theme_LV_Sortorder","Status");
$objListView->ColumnHeaders->SetSort($objConfig->Get("Theme_LV_Sortfield"), $objConfig->Get("Theme_LV_Sortorder"));
$objListView->PrintToolBar = FALSE;
$objListView->checkboxes = TRUE;
-$objListView->CurrentPageVar = "Page_LV_Themes";
-$objListView->PerPageVar = "Perpage_LV_Themes";
+
$objListView->CheckboxName = "itemlist[]";
$objListView->SearchBar = TRUE;
$objListView->SearchKeywords = $SearchWords;
$objListView->SearchAction="m_theme_search";
$objListView->TotalItemCount = $itemcount;
for($i=0;$i<count($objThemes->Items);$i++)
{
$objListView->RowIcons[] = $objThemes->Items[$i]->AdminIcon();
}
$objListView->ConfigureViewMenu($SortFieldVar,$SortOrderVar,$DefaultSortField,"","",0);
$title = prompt_language("la_Text_Editing")." ".prompt_language("la_Text_Theme");
$h = "\n\n<SCRIPT Language=\"JavaScript1.2\">\n".$objListView->GetViewMenu($imagesURL)."\n</SCRIPT>\n";
int_header($objListToolBar,NULL,$title, NULL, $h);
?>
<form name="theme" ID="theme" action="<?php echo $_SERVER["PHP_SELF"]."?".$envar;?>" method=POST>
<table cellSpacing="0" cellPadding="2" width="100%" class="tableborder">
<tbody>
<?php
print $objListView->PrintList();
?>
<input TYPE="hidden" NAME="DataType" VALUE="<?php echo $FieldType; ?>">
<input type="hidden" NAME="section" VALUE="<?php echo $section; ?>">
<input type="hidden" name="Action" value="m_config_custom">
</FORM>
<!-- CODE FOR VIEW MENU -->
<form ID="viewmenu" method="post" action="<?php echo $_SERVER["PHP_SELF"]."?".$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>
<script src="<?php echo $adminURL; ?>/listview/listview.js"></script>
<script>
initSelectiorContainers();
<?php echo $objListToolBar->Get("CheckClass").".setImages();"; ?>
</script>
<?php int_footer(); ?>
Property changes on: trunk/admin/config/config_theme.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/import/import.php
===================================================================
--- trunk/admin/import/import.php (revision 90)
+++ trunk/admin/import/import.php (revision 91)
@@ -1,930 +1,931 @@
<?php
#import script
#taking care of actual importing from in-link db to in-portal db
if(!strlen($pathtoroot))
{
$path=dirname(realpath($_SERVER['SCRIPT_FILENAME']));
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;
}
require_once($pathtoroot."kernel/startup.php");
$admin = $objConfig->Get("AdminDirectory");
if(!strlen($admin))
$admin = "admin";
if ($_POST["Action"]=="Import")
{
$objSession->SetVariable("import_user_admin",$_POST["user_admin"]);
$objSession->SetVariable("import_user_regular",$_POST["user_regular"]);
$objSession->SetVariable("import_init_cat",$_POST["init_cat"]);
$objSession->SetVariable("image_name",$_POST["image_name"]);
$objSession->SetVariable("importtodo","initialize");
$objSession->SetVariable("importstart",0);
$objSession->SetVariable("importtotal",0);
if((int)$_POST["init_cat"]>0)
{
$c = $objCatList->GetItemByField("ResourceId",(int)$_POST["init_cat"]);
$c->UpdateACL();
$c->UpdateCachedPath();
}
}
$allgroups = $objGroups->GetAllGroupList();
$inlink_sql_type=$objSession->GetVariable("import_inlink_sql_type");
$inlink_server=$objSession->GetVariable("import_inlink_server");
$inlink_db=$objSession->GetVariable("import_inlink_db");
$inlink_user=$objSession->GetVariable("import_inlink_user");
$inlink_pass=$objSession->GetVariable("import_inlink_pass");
$user_admin=$objSession->GetVariable("import_user_admin");
$user_regular=$objSession->GetVariable("import_user_regular");
if(!is_object($c))
$c = $objCatList->GetItemByField("ResourceId",$objSession->GetVariable("import_init_cat"));
$init_cat= $c->Get("CategoryId");
$image_name=$objSession->GetVariable("image_name");
$start = $objSession->GetVariable("importstart");
$acl = explode(",",$c->GetACL("CATEGORY.VIEW"));
//IN-LINK connection
$linkconn=&ADONewConnection($inlink_sql_type);
$linkconn->PConnect($inlink_server, $inlink_user, $inlink_pass, $inlink_db);
if(!$linkconn)
{ echo "Database connection failed. DB Type: $sql_type, DB Server: $inlink_server, DB User: $inlink_user, DB Name: $inlink_db"; //fatal;
echo $linkconn->ErrorMsg();
die();
}
if($pconnect)
{
$linkconn->Close();
$linkconn = ADONewConnection($inlink_sql_type);
$linkconn->PConnect($inlink_server, $inlink_user, $inlink_pass, $inlink_db);
}
//admin only util
$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/toolbar.php");
//Set Section
$section = "in-portal:inlink_inport";
//Set Environment Variable
$envar = "env=" . BuildEnv();
$sec = $objSections->GetSection($section);
$objCatToolBar = new clsToolBar();
$title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 4";
//In-Portal
$portalconn = GetAdodbConnection();
$TablePrefix = "ses_".$objSession->GetSessionKey()."_".GetTablePrefix();
$olddbname=$inlink_db;
//$newdbname="inportal";
$newdbname=$g_DBName;
##############creating a temproary table have to be here
if ($_POST["Action"]=="Import")
{
$portalconn->Execute("DROP TABLE ".$TablePrefix."import");
$portalconn->Execute("DROP TABLE ".$TablePrefix."importcat");
$temptable = "CREATE TABLE ".$TablePrefix."import (otname varchar(40), oid int(11), ocustomid int(11), oparentid int(11), ntname varchar(40), nid int(11), nrid int(11), npid int(11)) ";
$portalconn->Execute($temptable);
$cattable ="CREATE TABLE ".$TablePrefix."importcat (op int(11), np int(11), flag int(11)) ";
$portalconn->Execute($cattable);
$newcat = 1;
}
global $admin, $pathtoroot;
require_once ($pathtoroot.$admin."/import/status.php"); #for status bar and all visual effects
$todo= $objSession->GetVariable("importtodo");
$total = $objSession->GetVariable("importtotal");
switch ($todo)
{
case "users":
status($start, $total, "users");
usersimport();
//setstart(0,"cats"); #for debugging
break;
case "cats":
status($start, $total, "cats");
catmanager();
#setstart(0,"links"); #for debugging
break;
case "links":
status($start, $total, "links");
linksimport();
#setstart(0,"custom");#For debugging only
break;
case "custom":
status($start, $total, "custom");
customimport();
#setstart(0,"relcat");#for debuggin only
break;
case "relcat":
status($start, $total, "relcat");
relcatimport();
#setstart(0,"terminate"); #for debuggin only
break;
case "terminate":
terminator();
status(1,1,"terminate");
break;
default:
status(0,0,"initializing");
setstart(0,"users"); #to start importing from users first
break;
}
function terminator()
{
global $portalconn, $TablePrefix;
$query="DROP TABLE IF EXISTS ".$TablePrefix."import, ".$TablePrefix."importcat";
$portalconn->Execute($query);
}
function reload()
{
global $newurl;
print '<script language="javascript">' ;
print " setTimeout('location.href=location.href',40);";
print ' </script>';
}
function setstart($mystart, $part)
{
global $objSession;
$objSession->SetVariable("importstart",$mystart);
$objSession->SetVariable("importtodo",$part);
reload();
}
function settotal($total)
{
global $objSession;
$objSession->SetVariable("importtotal",$total);
}
//users import from inlink to inportal
function usersimport()
{
global $objUsers, $objSession, $linkconn, $portalconn, $olddbname,
$user_admin,$objGroups, $user_regular, $start, $TablePrefix;
$counter = 0;
$limit = 350;
$oldtablename = "inl_users";
$newtablename = $objUsers->SourceTable;
if ($start == 0)
{
$query="select count(*) as NumUsers from inl_users";
$row =$linkconn->Execute($query);
if ($row && !$row->EOF)
{
settotal($row->fields["NumUsers"]);
}
}
$query="select * from inl_users LIMIT $start, $limit";
$row =$linkconn->Execute($query);
while($row && !$row->EOF)
{
$counter++; #needed to know when close to time out
if ($row->fields['user_name'] != "root") {
$olduserid=$row->fields["user_id"];
//$Login, $Password, $Email, $CreatedOn, $FirstName="", $LastName="", $Status=2,
// $Phone="", $Street="", $City="", $State="", $Zip="", $Country=""
if($row->fields["user_status"]==1)
{
$Status=1;
}
else
{
if($row->fields["user_pend"]==0)
{
$Status=2;
}
else
$Status=0;
}
$u = $objUsers->Add_User( $row->fields["user_name"], $row->fields["user_pass"], $row->fields["email"],
$row->fields["user_date"], $row->fields["first"], $row->fields["last"],
$Status);
$oldid=$row->fields["user_id"];
$oldcustom=$row->fields["user_cust"];
$newid=$u->Get("PortalUserId");
$resid=$u->Get("ResourceId");
#adding user to usergroup
$userpermission = $row->fields["user_perm"];
if ($userpermission==2 || $userpermission==1)
{
$glist = explode(",",$user_admin);
$Primary=1;
for($i=0;$i<count($glist);$i++)
{
$group=$objGroups->GetItem($glist[$i]);
$group->AddUser($newid,$Primary);
$Primary = 0;
}
}
else
{
$glist = explode(",",$user_regular);
$Primary=1;
for($i=0;$i<count($glist);$i++)
{
$group=$objGroups->GetItem($glist[$i]);
$group->AddUser($newid,$Primary);
$Primary = 0;
}
}
//$group=$objGroups->GetItem($g);
//$group->AddUser($newid,1);
#inserting values to the temproary table
$totemp = "INSERT INTO ".$TablePrefix."import (otname,oid,ocustomid,oparentid,ntname,nid,nrid,npid) ";
$tovalues= " VALUES ('$oldtablename',$olduserid,$oldcustom,0,'$newtablename', $newid, $resid, 0 )";
$totemp=$totemp.$tovalues;
$portalconn->Execute($totemp);
}
$row->moveNext();
}
if ($counter == $limit)
{
setstart($start+$limit, "users");
}
else
setstart(0,"cats");
}
//END OF USERS IMPORT ^^^^^^^^^^^^^^^^^^^^^
//Categories Import
function catmanager()
{
global $portalconn, $init_cat,$start,$TablePrefix;
if ($start == 0)
{
$counter = catimport(0,$init_cat);
setstart($counter,"cats");
$portalconn->Execute("UPDATE ".$TablePrefix."importcat SET flag=1 WHERE np=$init_cat");
}
else
{
$query="select * from ".$TablePrefix."importcat WHERE flag=0 LIMIT 0,1";
$row =$portalconn->Execute($query);
if($row && !$row->EOF)
{
$oldid= $row->fields["op"];
$newid = $row->fields["np"];
$counter= catimport($oldid,$newid);
$query2="UPDATE ".$TablePrefix."importcat SET flag=1 WHERE op=$oldid and np=$newid";
$portalconn->Execute($query2);
setstart($counter+$start-1,"cats");
$x=5;
}
else
{
setstart(0,"links");
}
}
}
#pushes into the quque
function pushid($op,$np)
{
global $linkconn, $portalconn, $TablePrefix;
$addnew = "INSERT INTO ".$TablePrefix."importcat (op,np,flag) VALUES ($op,$np,0)";
$portalconn->Execute($addnew);
}
function checkifexist($id)
{
global $linkconn;
$addnew = "select * from inl_cats where cat_sub=$id";
$row =$linkconn->Execute($addnew);
if ($row && !$row->EOF)
{
if ($row->fields["cat_id"] !=0)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
#import itself
function catimport($oldparentid, $parentid)
{
global $objCatList, $linkconn, $objUsers, $linkconn, $portalconn,
$olddbname, $user_admin,$objGroups, $user_regular, $acl,$allgroups,
$c, $start, $TablePrefix;
$counter=0;
$objCacheCount = new clsCacheCountList();
if ($start == 0)
{
$query="select count(*) as CatCount from inl_cats";
$row =$linkconn->Execute($query);
if ($row && !$row->EOF)
{
settotal($row->fields["CatCount"]);
$catcount = $row->fields["CatCount"];
$catcount += (int)$c->Get("CachedDescendantCatsQty");
$c->Set("CachedDescendantCatsQty",$catcount);
$c->Update();
}
}
$query="select * from inl_cats WHERE cat_sub=$oldparentid";
$oldtablename = "inl_cats";
$newtablename = "Category";
$row =$linkconn->Execute($query);
if($row && !$row->EOF)
{
$RowCount = $row->NumRows();
$ResInc = $RowCount;
$ResourceId = GetNextResourceId($ResInc);
}
if($parentid>0)
{
$ParentCat = new clsCategory($parentid);
$Path = $ParentCat->Get("ParentPath");
}
while($row && !$row->EOF)
{
$counter++;
$cat = new clsCategory();
if($row->fields["cat_pend"]==0)
{
$Status=1;
}
else
{
if($row->fields["cat_vis"]==0)
{
$Status=2;
}
else
$Status=0;
}
$CreatedById = getnewid($row->fields["cat_id"]);
$cat->Set(array("ParentId", "Name", "Description", "CreatedOn", "EditorsPick", "Status", "HotItem",
"NewItem","PopItem", "Priority", "MetaKeywords", "MetaDescription", "CreatedById",
"CachedDescendantCatsQty"),
array($parentid, $row->fields["cat_name"], $row->fields["cat_desc"],
$row->fields["cat_date"], (int)$row->fields["cat_pick"], $Status, 2, 2, 2, 0,
$row->fields["meta_keywords"],$row->fields["meta_desc"],
(int)$CreatedById,(int)$row->fields["cat_cats"]));
$cat->Set("ResourceId",$ResourceId);
$ResourceId++;
$cat->Create();
$FullPath = $Path.$cat->Get("CategoryId")."|";
$cat->Set("ParentPath",$FullPath);
$cat->SetViewPerms("CATEGORY.VIEW",$acl,$allgroups);
+ $cat->SetViewPerms("LINK.VIEW",$acl,$allgroups);
$cat->Update();
$cat->UpdateCachedPath();
$objCacheCount->CategoryId= $cat->Get("CategoryId");
$objCacheCount->SetValue(0,0,0,0,0);
$newid = $cat->Get("CategoryId");
$resid = $cat->Get("ResourceId");
$oldid = $row->fields["cat_id"];
$oldcustom = $row->fields["cat_cust"];
$oldpid = $row->fields["cat_sub"];
#inserting values to the temproary table
$totemp = "INSERT INTO ".$TablePrefix."import (otname,oid,ocustomid,oparentid,ntname,nid,nrid,npid) ";
$tovalues= " VALUES ('$oldtablename',$oldid,$oldcustom,$oldpid,'$newtablename', $newid, $resid, $parentid )";
$totemp=$totemp.$tovalues;
$portalconn->Execute($totemp);
#pushes into the queue
if(checkifexist($oldid))
{
pushid($oldid,$newid);
}
$row->moveNext();
}
return $counter;
}
//Links Import
function linksimport()
{
global $objLinkList, $init_cat, $linkconn, $portalconn, $olddbname,
$user_admin,$objGroups, $user_regular, $start, $TablePrefix;
$limit = 750; #need to change to a higher number like 100, forty is only for debugging
$counter = 0;
set_time_limit(0);
if ($start == 0)
{
$query="select count(*) as LinkCount from inl_lc";
$row =$linkconn->Execute($query);
if ($row && !$row->EOF)
{
settotal($row->fields["LinkCount"]);
}
}
$query="select * from inl_lc INNER JOIN inl_links ON (inl_lc.link_id=inl_links.link_id) limit $start,$limit";
$oldtablename="inl_links";
$newtablename="link";
$row =$linkconn->Execute($query);
if($row && !$row->EOF)
{
$RowCount = $row->NumRows();
$ResInc = $RowCount;
$ResourceId = GetNextResourceId($ResInc);
}
while($row && !$row->EOF)
{
$counter++;
$oldid=$row->fields["link_id"];
$flag=1;
$oldcatid = $row->fields["cat_id"];
$pending = $row->fields["link_pend"];
#getting a new category id
$rs = $portalconn->Execute("SELECT nid FROM ".$TablePrefix."import WHERE ntname='Category' and oid=$oldcatid");
if ($rs && ! $rs->EOF)
{
$categoryid=$rs->fields["nid"];
}
else
{
$categoryid = $init_cat;
}
$rs = $portalconn->Execute("SELECT * FROM ".$TablePrefix."import WHERE otname='inl_link' AND oid='$oldid'");
if($rs && ! $rs->EOF)
{
$NewLinkId = $rs->fields["nid"];
}
else
$NewLinkId=0;
if ($NewLinkId==0)
{
#gets the new user id of the user who created a link
$newuserid=getnewid($row->fields["link_user"]);
#adds link to the IN-PORTAL
$link = new clsLink();
if($Pending==0)
{
$Status=1;
}
else
$Status=2;
$link->Set(array("Name", "Description", "Url", "CreatedOn", "Status", "EditorsPick",
"NewItem","PopItem","HotItem", "CreatedById", "CachedRating",
"CachedVotesQty","Hits", "Priority"),
array($row->fields["link_name"], $row->fields["link_desc"], $row->fields["link_url"], $row->fields["link_date"], $Status,
$row->fields["link_pick"], 2, 2, 2, $newuserid, (int)$row->fields["link_rating"],
(int)$row->fields["link_votes"],(int)$row->fields["link_hits"], 0));
$link->Set("ResourceId",$ResourceId);
$ResourceId++;
$link->Create();
$link->AddToCategory($categoryid,"",1);
$newid = $link->Get("LinkId");
$resid = $link->Get("ResourceId");
$oldcustom=$row->fields["link_cust"];
$linkimage =$row->fields["link_image"];
if ($linkimage)
{
addimage($resid,$linkimage);
}
#calls to import reviews
reviewimport($link,$oldid,$resid);
$parentid = 0;
$totemp = "INSERT INTO ".$TablePrefix."import (odb,otname,oid,ocustomid,oparentid,ndb,ntname,nid,nrid,npid) ";
$tovalues= " VALUES ('$olddbname','$oldtablename',$oldid,$oldcustom,$oldcatid,'inportal','$newtablename', $newid, $resid, $parentid )";
$totemp = $totemp.$tovalues;
//$portalconn->Execute($totemp);
}
else #if link is related to more than one category
{
$link = new clsLink($NewLinkId);
$link->AddtoCategory($categoryid,"",0);
}
#prelast while
$row->moveNext();
}
if ($counter == $limit)
{
setstart($start+$limit, "links");
}
else
{
setstart(0,"custom");
}
}
#importing image from the in-link
function addimage($resourceid, $imageurl)
{
global $objImageList, $image_name;
#echo "<br />IMAGE RESOURCEID: $resourceid IMAGE URL: $imageurl <br />";
if(!is_object($objImageList))
$objImageList = new clsImageList();
$LocalImage = 0;
$LocalThumb = 0;
if(!strlen($image_name))
$image_name="inlink_image";
$img = $objImageList->Add($image_name,"",$resourceid, 0, 0,"", $imageurl, 1,0, 1, 0,1);
}
#Reviews Import for links
function reviewimport($myclass,$oldid,$rid)
{
global $objCustomFieldList, $linkconn, $portalconn;
#ITEM AddReview($createdBy,$reviewText,0)
$query="select * from inl_reviews where rev_link= $oldid";
$row =$linkconn->Execute($query);
while($row && !$row->EOF)
{
$oldreviewuser= $row->fields["rev_user"];
if($oldreviewuser !=0) #meaning was not created by guest
{
$newrid=getnewid($oldreviewuser);
if ($newrid)
{
$temp=$myclass->AddReview($newrid,$row->fields["rev_text"],0,"127.0.0.1",1, "In-Link");
}
else
{
$temp=$myclass->AddReview(0,$row->fields["rev_text"],0,"127.0.0.1",1, "In-Link");
}
}
else #meaning was created by guest
{
$temp=$myclass->AddReview(0,$row->fields["rev_text"],0,"127.0.0.1",1, "In-Link");
}
$row->moveNext();
}
}
#HELPER FUNCTION THAT GETS THE NEW ID of the USER
function getnewid($oldid)
{
global $portalconn, $TablePrefix;
$query2="select * from ".$TablePrefix."import where otname='inl_users' and oid=".$oldid;
$row2=$portalconn->Execute($query2);
if ($row2->fields["nid"])
{
return $row2->fields["nid"];
}
else
{
return 0;
}
}
//^^^^^^^^^^^^^^^^^^^^^^ABOVE IS LINKS IMPORT
#########################################Custom Fields Import
#create a new CustomField first and then
#by selecting all and receiving from one record of inl_config the values of cc1,cc2,cc3,cc4,cc5,cc6,uc1,uc2,uc3,uc4,uc5,uc6,lc1,lc2,lc3,lc4,lc5,lc6
#go through all import table and if ocustomid occures get the row from inl_custom and
#create CustomMetaData field
#---------------------
#Regarding CustomField:
#FieldName= cc1,cc2 .... from inl_config
#FieldLabel= value of cc1, cc2 ....
#Type=4 for links 6 for users 0 category
#------------
#Regarding CustomMetaData
#ResourceId <= link id
#CustomFieldId <= id from the top
#Value = Value from the table custom
//VVVVV BELOW ARE CUSTOM FIELD IMPORT REQUIRES TO HAVE A TEMPROARY TABLE IMPORT
function customimport()
{
global $linkconn, $portalconn, $start, $TablePrefix;
$limit = 40; #just for debugging purposes, in real life set it to higher number
$counter=0;
if ($start == 0)
{
$r=buildfields();
$query="SELECT count(*) as cc from ".$TablePrefix."import WHERE NOT ocustomid=0";
$row =$portalconn->Execute($query);
if ($row && !$row->EOF)
{
settotal($row->fields["cc"]);
}
}
else
{
$r=getfields();
}
$query="SELECT * from ".$TablePrefix."import WHERE ocustomid!=0 limit $start,$limit";
$row =$portalconn->Execute($query);
while($row && !$row->EOF)
{
$counter++;
if ($row->fields["ocustomid"]!=0)
{
loadcustom($row->fields["ocustomid"],$row->fields["nrid"],$row->fields["otname"],$r);
}
$row->moveNext();
}
if ($counter == $limit)
{
setstart($start+$limit, "custom");
}
else
{
setstart(0,"relcat");
}
}
function loadcustom($customid,$rid,$tablename,$r)
{
global $linkconn, $objCustomDataList, $objSession;
$objCustomDataList->Clear();
if ($tablename =="inl_cats")
{
//$myfieldname="cc";
$fields = explode(",",$objSession->GetVariable("custom_category"));
}
else if($tablename =="inl_users")
{
//$myfieldname="uc";
$fields = explode(",",$objSession->GetVariable("custom_user"));
}
else if($tablename =="inl_links")
{
//$myfieldname="lc";
$fields = explode(",",$objSession->GetVariable("custom_links"));
}
$oldtablename="inl_links";
$newtablename="link";
$query="select * from inl_custom Where cust_id=$customid";
$row =$linkconn->Execute($query);
if ($row)
{
for ($x=0; $x<count($fields);$x++)
{
$cust=$row->fields["cust".$x];
if ($cust!="")
{
$fieldid =$r[$fields[$x]];
$objCustomDataList->SetFieldValue($fieldid,$rid,$cust);
}
}
$objCustomDataList->SaveData();
}
}
function buildfields() #building and populating an array
{
global $objCustomFieldList, $objSession,$linkconn;
$lc="lc";
$uc="uc";
$cc="cc";
$query = "SELECT * FROM inl_config WHERE name LIKE 'uc%'";
$row =$linkconn->Execute($query);
$names = array();
while($row && !$row->EOF)
{
$data = $row->fields;
$fieldlabel=$data["name"];
if(strlen($data["value"]))
{
$fieldlabel = $data["value"];
}
$f=$objCustomFieldList->AddField(6,$data["name"],$fieldlabel);
$r["'".$data["name"]."'"]=$f->Get("CustomFieldId");
$objSession->SetVariable("custom_".$data["name"],$f->Get("CustomFieldId"));
$names[] = $data["name"];
$row->MoveNext();
}
$objSession->SetVariable("custom_user",implode(",",$names));
unset($names);
$names = array();
$query = "SELECT * FROM inl_config WHERE name LIKE 'cc%'";
$row =$linkconn->Execute($query);
while($row && !$row->EOF)
{
$data = $row->fields;
$fieldlabel=$data["name"];
if(strlen($data["value"]))
{
$fieldlabel = $data["value"];
}
$f=$objCustomFieldList->AddField(1,$data["name"],$fieldlabel);
$r["'".$data["name"]."'"]=$f->Get("CustomFieldId");
$objSession->SetVariable("custom_".$data["name"],$f->Get("CustomFieldId"));
$names[] = $data["name"];
$row->MoveNext();
}
$objSession->SetVariable("custom_category",implode(",",$names));
unset($names);
$names = array();
$query = "SELECT * FROM inl_config WHERE name LIKE 'lc%'";
$row =$linkconn->Execute($query);
while($row && !$row->EOF)
{
$data = $row->fields;
$fieldlabel=$data["name"];
if(strlen($data["value"]))
{
$fieldlabel = $data["value"];
}
$f=$objCustomFieldList->AddField(4,$data["name"],$fieldlabel);
$r["'".$data["name"]."'"]=$f->Get("CustomFieldId");
$objSession->SetVariable("custom_".$data["name"],$f->Get("CustomFieldId"));
$names[] = $data["name"];
$row->MoveNext();
}
$objSession->SetVariable("custom_links",implode(",",$names));
return $r;
}
function getfields() #building and populating an array
{
global $objSession;
$lc="lc";
$uc="uc";
$cc="cc";
$userfields = explode(",",$objSession->GetVariable("custom_user"));
for ($x=0;$x<=count($userfields);$x++)
{
$r[$userfields[$x]]=$objSession->GetVariable("custom_".$userfields[$x]);
}
$catfields = explode(",",$objSession->GetVariable("custom_category"));
for ($x=0;$x<=count($catfields);$x++)
{
$r[$catfields[$x]]=$objSession->GetVariable("custom_".$catfields[$x]);
}
$linkfields = explode(",",$objSession->GetVariable("custom_links"));
for ($x=0;$x<=count($linkfields);$x++)
{
$r[$linkfields[$x]]=$objSession->GetVariable("custom_".$linkfields[$x]);
}
return $r;
}
################################################Relationships Import
function relcatimport()
{
global $linkconn,$objSession, $start;
$limit = 100;
$counter =0;
if ($start == 0)
{
$query="SELECT count(*) from inl_rel_cats";
$row =$linkconn->Execute($query);
if ($row && !$row->EOF)
{
settotal($row->fields[0]);
}
}
$objRelList = new clsRelationshipList();
$query="select * from inl_rel_cats LIMIT $start, $limit";
$row =$linkconn->Execute($query);
while($row && !$row->EOF)
{
$counter++;
$sourceid = newcatrid($row->fields["cat_id"]);
$targetid = newcatrid($row->fields["rel_id"]);
if ($sourceid !="" && $targetid !="")
{
$r = $objRelList->Add($sourceid, 1,$targetid, 1);
$r->Create();
}
$row->moveNext();
}
if ($counter == $limit)
{
setstart($start+$limit, "relcat");
}
else
{
setstart(0,"terminate");
}
}
function newcatrid($oid)
{
global $portalconn, $TablePrefix;
$query2="select * from ".$TablePrefix."import where otname='inl_cats' and oid=$oid";
$row =$portalconn->Execute($query2);
if ($row->fields["nrid"])
{
return $row->fields["nrid"];
}
else
{
return "";
}
}
// END OF RELATIONSHIP IMPORT
?>
\ No newline at end of file
Property changes on: trunk/admin/import/import.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property

Event Timeline