Index: trunk/kernel/include/item.php =================================================================== diff -u -r389 -r440 --- trunk/kernel/include/item.php (.../item.php) (revision 389) +++ trunk/kernel/include/item.php (.../item.php) (revision 440) @@ -4,977 +4,976 @@ class clsItem extends clsParsedItem { - var $type; - var $Reviews; - var $Related; - var $Images; - var $PrimaryCat; - var $IsNew = FALSE; - var $IsHot = FALSE; - var $IsPop = FALSE; - var $Keywords; - var $OpenTagVar; - var $CloseTagVar; - var $AdminParser; - var $CustomFields; - var $FieldClass; - var $CustomLoaded=0; - var $ReviewSortOrder; - var $ReviewPerPageVar; + var $type; + var $Reviews; + var $Related; + var $Images; + var $PrimaryCat; + var $IsNew = FALSE; + var $IsHot = FALSE; + var $IsPop = FALSE; + var $Keywords; + var $OpenTagVar; + var $CloseTagVar; + var $AdminParser; + var $CustomFields; + var $FieldClass; + var $CustomLoaded=0; + var $ReviewSortOrder; + var $ReviewPerPageVar; - function clsItem($FullItem=FALSE) - { - $this->clsParsedItem(); - if($FullItem==TRUE) - { - $this->Reviews = new clsItemReviewList(); - $this->Related = new clsRelationshipList(); - } - $this->Images = new clsImageList(); - $this->CustomFields = array(); - $this->FieldClass = new clsCustomFieldList(); - } + function clsItem($FullItem=FALSE) + { + $this->clsParsedItem(); + if($FullItem==TRUE) + { + $this->Reviews = new clsItemReviewList(); + $this->Related = new clsRelationshipList(); + } + $this->Images = new clsImageList(); + $this->CustomFields = array(); + $this->FieldClass = new clsCustomFieldList(); + } - function ClearCacheData() - { - } - - /* item reviews */ - function &GetItemReviews($Page=1) - { - $res_id = $this->Get("ResourceId"); - $this->Reviews->itemID=$res_id; - $this->Reviews->PerPageVar = $this->ReviewPerPageVar; - $this->Reviews->Page = $Page; - $this->Reviews->GetReviewList("Status=1",$this->ReviewSortOrder); - return $this->Reviews; - } + function ClearCacheData() + { + } - function ReviewCount($TodayOnly=FALSE) - { + /* item reviews */ + function &GetItemReviews($Page=1) + { + $res_id = $this->Get("ResourceId"); + $this->Reviews->itemID=$res_id; + $this->Reviews->PerPageVar = $this->ReviewPerPageVar; + $this->Reviews->Page = $Page; + $this->Reviews->GetReviewList("Status=1",$this->ReviewSortOrder); + return $this->Reviews; + } - if(is_numeric($this->Get("CachedReviewsQty")) && !$TodayOnly) - return (int)$this->Get("CachedReviewsQty"); + function ReviewCount($TodayOnly=FALSE) + { - $this->Reviews->itemID=$this->Get("ResourceId"); - return (int)$this->Reviews->GetItemReviewCount($TodayOnly); - } - - function ReviewsLoaded() - { - if($this->Reviews->itemID==$this->Get("ResourceId")) - { - return $this->Reviews->ItemCount(); - } - else - return 0; - } + if(is_numeric($this->Get("CachedReviewsQty")) && !$TodayOnly) + return (int)$this->Get("CachedReviewsQty"); - function &AddReview($createdBy,$reviewText,$isPending,$ip=NULL,$ForceIP=0, $Module="") - { - $this->Reviews->itemID=$this->Get("ResourceId"); - if($ip == NULL) - $ip = $_SERVER["REMOTE_ADDR"]; + $this->Reviews->itemID=$this->Get("ResourceId"); + return (int)$this->Reviews->GetItemReviewCount($TodayOnly); + } - $CreatedOn = mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - $Status=1; - if($isPending) - $Status=2; + function ReviewsLoaded() + { + if($this->Reviews->itemID==$this->Get("ResourceId")) + { + return $this->Reviews->ItemCount(); + } + else + return 0; + } - $AutoModule = GetModuleByAction(); // determine module name by action - if( $Module && ($AutoModule != $Module) ) $AutoModule = $Module; - - $r = $this->Reviews->AddReview($CreatedOn,$reviewText,$Status,$ip,0,$this->Get("ResourceId"),$this->type,$createdBy,0,$AutoModule); - $this->Increment("CachedReviewsQty"); - return $r; - } + function &AddReview($createdBy,$reviewText,$isPending,$ip=NULL,$ForceIP=0, $Module="", $CreatedOn = 0) + { + $this->Reviews->itemID=$this->Get("ResourceId"); + if($ip == NULL) + $ip = $_SERVER["REMOTE_ADDR"]; - function ReviewIPExists($ip) - { - return ip_exists($ip,$this->Get("ResourceId"),$this->Reviews->SourceTable); - } + if(!$CreatedOn) + $CreatedOn = mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $Status = 1; + if($isPending) + $Status = 2; - function DeleteReview($reviewID) - { - $r = $this->Reviews->GetReview($reviewID); - if(is_object($r)) - { - $r->Delete(); - $this->Decrement("CachedReviewsQty"); - } - } + $AutoModule = GetModuleByAction(); // determine module name by action + if( $Module && ($AutoModule != $Module) ) $AutoModule = $Module; - function DeleteReviews() - { - $res_id = $this->Get("ResourceId"); - if($res_id) - { - $sql = "DELETE FROM ".GetTablePrefix()."ItemReview WHERE ResourceId=$res_id"; - $this->adodbConnection->Execute($sql); - unset($this->Reviews); - $this->Reviews = new clsItemReviewList($res_id); - } - } + $r = $this->Reviews->AddReview($CreatedOn,$reviewText,$Status,$ip,0,$this->Get("ResourceId"),$this->type,$createdBy,0,$AutoModule); + $this->Increment("CachedReviewsQty"); + return $r; + } - /* item custom fields */ + function ReviewIPExists($ip) + { + return ip_exists($ip,$this->Get("ResourceId"),$this->Reviews->SourceTable); + } - function LoadCustomFields() - { - if(!$this->CustomLoaded && $this->Get("ResourceId")>0) - { - $this->FieldClass = new clsCustomFieldList(); - $this->FieldClass->Type = $this->type; - $this->FieldClass->LoadFieldsAndValues($this->Get("ResourceId")); - foreach($this->FieldClass->Items as $f) - { - $this->CustomFields[$f->Get("FieldName")] = $f->HasField('Value') ? $f->Get('Value') : ''; - } - $this->CustomLoaded = 1; - } - } + function DeleteReview($reviewID) + { + $r = $this->Reviews->GetReview($reviewID); + if(is_object($r)) + { + $r->Delete(); + $this->Decrement("CachedReviewsQty"); + } + } - function SetCustomField($fieldname,$value) - { - // echo "Setting CF [$fieldname] = [$value]
"; - if(!$this->CustomLoaded) - $this->LoadCustomFields(); - $this->CustomFields[$fieldname] = $value; - } + function DeleteReviews() + { + $res_id = $this->Get("ResourceId"); + if($res_id) + { + $sql = "DELETE FROM ".GetTablePrefix()."ItemReview WHERE ResourceId=$res_id"; + $this->adodbConnection->Execute($sql); + unset($this->Reviews); + $this->Reviews = new clsItemReviewList($res_id); + } + } - function SaveCustomFields() - { - //echo "Saving CFs
"; - if(!(int)$this->Get("ResourceId")) - return TRUE; - - if(!$this->CustomLoaded) - return TRUE; - - $data = new clsCustomDataList(); - $data->LoadResource($this->Get("ResourceId")); - foreach($this->FieldClass->Items as $f) - { - $value = $this->CustomFields[$f->Get("FieldName")]; - $data->SetFieldValue($f->Get("CustomFieldId"),$this->Get("ResourceId"),$value); - } - $data->SaveData(); - unset($data); - } + /* item custom fields */ - function GetCustomFieldValue($fieldname,$default="") - { - if(!$this->CustomLoaded) - $this->LoadCustomFields(); - if(isset($this->CustomFields[$fieldname])) - { - $ret = $this->CustomFields[$fieldname]; - } - else - $ret = $default; - return $ret; - } + function LoadCustomFields() + { + if(!$this->CustomLoaded && $this->Get("ResourceId")>0) + { + $this->FieldClass = new clsCustomFieldList(); + $this->FieldClass->Type = $this->type; + $this->FieldClass->LoadFieldsAndValues($this->Get("ResourceId")); + foreach($this->FieldClass->Items as $f) + { + $this->CustomFields[$f->Get("FieldName")] = $f->HasField('Value') ? $f->Get('Value') : ''; + } + $this->CustomLoaded = 1; + } + } + function SetCustomField($fieldname,$value) + { + // echo "Setting CF [$fieldname] = [$value]
"; + if(!$this->CustomLoaded) + $this->LoadCustomFields(); + $this->CustomFields[$fieldname] = $value; + } - function DeleteCustomData() - { - $cdata = new clsCustomDataList(); - $cdata->DeleteResource($this->Get("ResourceId")); - } + function SaveCustomFields() + { + //echo "Saving CFs
"; + if(!(int)$this->Get("ResourceId")) + return TRUE; - function Delete($RecordOnly=FALSE) - { - global $objFavorites; + if(!$this->CustomLoaded) + return TRUE; - if($RecordOnly==FALSE) - { - $this->DeleteReviews(); - $this->DeleteRelations(); - $this->DeleteCustomData(); - if($this->NoResourceId==0) - { - if($this->UsingTempTable()==FALSE) - { - if(is_object($this->Images)) - $this->Images->DeleteResource($this->Get("ResourceId")); - $objFavorites->DeleteItem($this->Get("ResourceId")); - } - } - } - parent::Delete(); - } + $data = new clsCustomDataList(); + $data->LoadResource($this->Get("ResourceId")); + foreach($this->FieldClass->Items as $f) + { + $value = $this->CustomFields[$f->Get("FieldName")]; + $data->SetFieldValue($f->Get("CustomFieldId"),$this->Get("ResourceId"),$value); + } + $data->SaveData(); + unset($data); + } - /* item relationships */ - function GetRelatedItems() - { - global $objConfig; + function GetCustomFieldValue($fieldname,$default="") + { + if(!$this->CustomLoaded) + $this->LoadCustomFields(); + if(isset($this->CustomFields[$fieldname])) + { + $ret = $this->CustomFields[$fieldname]; + } + else + $ret = $default; + return $ret; + } - $where = "SourceId = ".$this->Get("ResourceId"); - $where .= " OR (TargetId=".$this->Get("ResourceId")." AND Type=1)"; - $orderBy = $objConfig->Get("Relation_Sortfield")." ".$objConfig->Get("Relation_Sortorder"); - $orderBy = trim($orderBy); - $this->Related->Clear(); - $res = $this->Related->LoadRelated($where,$orderBy); - return $res; - } - function &RelationObject() - { - return $this->Related; - } + function DeleteCustomData() + { + $cdata = new clsCustomDataList(); + $cdata->DeleteResource($this->Get("ResourceId")); + } - function DeleteRelations() - { - $res_id = $this->Get("ResourceId"); - if($res_id) - { - $sql = "DELETE FROM ".GetTablePrefix()."Relationship WHERE SourceId=$res_id OR TargetId=$res_id"; - $this->adodbConnection->Execute($sql); - unset($this->Reviews); - $this->Related = new clsRelationshipList($res_id); - } - } + function Delete($RecordOnly=FALSE) + { + global $objFavorites; + if($RecordOnly==FALSE) + { + $this->DeleteReviews(); + $this->DeleteRelations(); + $this->DeleteCustomData(); + if($this->NoResourceId==0) + { + if($this->UsingTempTable()==FALSE) + { + if(is_object($this->Images)) + $this->Images->DeleteResource($this->Get("ResourceId")); + $objFavorites->DeleteItem($this->Get("ResourceId")); + } + } + } + parent::Delete(); + } - /* keyword highlighting for searches */ + /* item relationships */ + function GetRelatedItems() + { + global $objConfig; - function HighlightField($field) - { - global $objConfig; + $where = "SourceId = ".$this->Get("ResourceId"); + $where .= " OR (TargetId=".$this->Get("ResourceId")." AND Type=1)"; + $orderBy = $objConfig->Get("Relation_Sortfield")." ".$objConfig->Get("Relation_Sortorder"); + $orderBy = trim($orderBy); + $this->Related->Clear(); + $res = $this->Related->LoadRelated($where,$orderBy); + return $res; + } - if(/*!strlen($OpenTag) || !strlen($CloseTag) ||*/ !is_array($this->Keywords)) - { - //echo "Missing something
\n"; - return $this->Get($field); - } - - if(strlen($this->OpenTagVar)) - $OpenTag = $objConfig->Get($this->OpenTagVar); - if(strlen($this->CloseTagVar)) - $CloseTag = $objConfig->Get($this->CloseTagVar); + function &RelationObject() + { + return $this->Related; + } - $k = array_merge($this->Keywords["required"],$this->Keywords["normal"]); - if(count($k)) - { - $result = HighlightKeywords($k, $this->Get($field), $OpenTag, $CloseTag); - } - else - { - $result = $this->Get($field); - //echo "No Keywords
\n"; - } - return $result; - } - - function HighlightText($text) - { - global $objConfig; + function DeleteRelations() + { + $res_id = $this->Get("ResourceId"); + if($res_id) + { + $sql = "DELETE FROM ".GetTablePrefix()."Relationship WHERE SourceId=$res_id OR TargetId=$res_id"; + $this->adodbConnection->Execute($sql); + unset($this->Reviews); + $this->Related = new clsRelationshipList($res_id); + } + } - if(strlen($this->OpenTagVar)) - $OpenTag = $objConfig->Get($this->OpenTagVar); - if(strlen($this->CloseTagVar)) - $CloseTag = $objConfig->Get($this->CloseTagVar); - if(!strlen($OpenTag) || !strlen($CloseTag) || !is_array($this->Keywords)) { - return $text; - } - $k = array_merge($this->Keywords["required"],$this->Keywords["normal"]); - if(count($k)) - { - $result = HighlightKeywords($k,$text, $OpenTag, $CloseTag); - } - else - $result = $text; + /* keyword highlighting for searches */ - return $result; - } + function HighlightField($field) + { + global $objConfig; - /* item status functions */ + if(/*!strlen($OpenTag) || !strlen($CloseTag) ||*/ !is_array($this->Keywords)) + { + //echo "Missing something
\n"; + return $this->Get($field); + } - function Is($name) - { - $var = "m_" . $name; - return ( isset($this->$var) && $this->$var ) ? true : false; - } + if(strlen($this->OpenTagVar)) + $OpenTag = $objConfig->Get($this->OpenTagVar); + if(strlen($this->CloseTagVar)) + $CloseTag = $objConfig->Get($this->CloseTagVar); - function IsHotItem() - { - switch($this->Get("HotItem")) - { - case ALWAYS: - return TRUE; - break; - case NEVER: - return FALSE; - break; - case AUTO: - return $this->IsHot; - break; - } - } + $k = array_merge($this->Keywords["required"],$this->Keywords["normal"]); + if(count($k)) + { + $result = HighlightKeywords($k, $this->Get($field), $OpenTag, $CloseTag); + } + else + { + $result = $this->Get($field); + //echo "No Keywords
\n"; + } + return $result; + } - function SetHotItem() - { - $this->IsHot = FALSE; - } + function HighlightText($text) + { + global $objConfig; - function IsNewItem() - { - switch($this->Get("NewItem")) - { - case ALWAYS: - return TRUE; - break; - case NEVER: - return FALSE; - break; - case AUTO: - return $this->IsNew; - break; - } - } + if(strlen($this->OpenTagVar)) + $OpenTag = $objConfig->Get($this->OpenTagVar); + if(strlen($this->CloseTagVar)) + $CloseTag = $objConfig->Get($this->CloseTagVar); - function SetNewItem() - { - $this->IsNew = FALSE; - } + if(!strlen($OpenTag) || !strlen($CloseTag) || !is_array($this->Keywords)) { + return $text; + } + $k = array_merge($this->Keywords["required"],$this->Keywords["normal"]); + if(count($k)) + { + $result = HighlightKeywords($k,$text, $OpenTag, $CloseTag); + } + else + $result = $text; - function IsPopItem() - { - switch($this->Get("PopItem")) - { - case ALWAYS: - return TRUE; - break; - case NEVER: - return FALSE; - break; - case AUTO: - return $this->IsPop; - break; - } - } + return $result; + } - function SetPopItem() - { - $this->IsPop = FALSE; - } + /* item status functions */ - function SetFromArray($data, $dirty = false) - { - parent::SetFromArray($data, $dirty); - if(is_array($data)) - { - if(array_key_exists("NewItem",$data)) - { - $this->SetNewItem(); - } - if(array_key_exists("HotItem",$data)) - { - $this->SetHotItem(); - } - if(array_key_exists("PopItem",$data)) - { - $this->SetPopItem(); - } - } - } + function Is($name) + { + $var = "m_" . $name; + return ( isset($this->$var) && $this->$var ) ? true : false; + } - function Validate() - { - /* skeleton*/ - return true; - } + function IsHotItem() + { + switch($this->Get("HotItem")) + { + case ALWAYS: + return TRUE; + break; + case NEVER: + return FALSE; + break; + case AUTO: + return $this->IsHot; + break; + } + } - function LoadFromDatabase($Id, $IdField = null) // custom IdField by Alex) - { - /* skeleton */ - parent::LoadFromDatabase($Id, $IdField); - } + function SetHotItem() + { + $this->IsHot = FALSE; + } + function IsNewItem() + { + switch($this->Get("NewItem")) + { + case ALWAYS: + return TRUE; + break; + case NEVER: + return FALSE; + break; + case AUTO: + return $this->IsNew; + break; + } + } + function SetNewItem() + { + $this->IsNew = FALSE; + } - //Changes priority - function MoveDown() - { - $this->Decrement("Priority"); - } + function IsPopItem() + { + switch($this->Get("PopItem")) + { + case ALWAYS: + return TRUE; + break; + case NEVER: + return FALSE; + break; + case AUTO: + return $this->IsPop; + break; + } + } - function MoveUp() - { - $this->Increment("Priority"); - } + function SetPopItem() + { + $this->IsPop = FALSE; + } - function CheckPermission($permissionName) - { - //Check permission and if needs approval set approval - global $objSession,$objCatList; + function SetFromArray($data, $dirty = false) + { + parent::SetFromArray($data, $dirty); + if(is_array($data)) + { + if(array_key_exists("NewItem",$data)) + { + $this->SetNewItem(); + } + if(array_key_exists("HotItem",$data)) + { + $this->SetHotItem(); + } + if(array_key_exists("PopItem",$data)) + { + $this->SetPopItem(); + } + } + } - $perm = $this->BasePermission; - if(strlen($perm)>0) - $perm .= "."; - $perm .= $permissionName; + function Validate() + { + /* skeleton*/ + return true; + } - //get an instance of the forum category - $cat =& $objCatList->GetCategory($this->Get("CategoryId")); - if(!is_object($cat)) - { - return FALSE; - } - else - { - return ($cat->HasPermission($perm,$objSession->Get("GroupId"))); - } - } + function LoadFromDatabase($Id, $IdField = null) // custom IdField by Alex) + { + /* skeleton */ + parent::LoadFromDatabase($Id, $IdField); + } - function SubmitVote($voteRating, $voteNotes) - { - global $Errors; - global $REMOTE_ADDR; - if($this->rating_ip_exists($REMOTE_ADDR)) - { -// $Errors->AddError("error.already_voted","","","",get_class($this),"SubmitVote"); - return false; - } - $vote = new clsItemRating(NULL); - $vote->Set("ItemId",$this->UniqueId()); - $vote->Set("RatingValue",$voteRating); - if(!$vote->Create()) - return false; - $NumVotes = (int)$this->Get("CachedVotesQty"); - $CurrentRating = (int)$this->Get("CachedRating"); + //Changes priority + function MoveDown() + { + $this->Decrement("Priority"); + } - $Rating = (($NumVotes * $CurrentRating) + $voteRating)/($NumVotes+1); - $this->Set("CachedRating",$Rating); - $this->Update(); - $this->Increment("CachedVotesQty"); - } + function MoveUp() + { + $this->Increment("Priority"); + } - function rating_ip_exists($ip) - { - $count = 0; - $id = $this->Get("ResourceId"); - $sql = "SELECT count(*) as DupCount FROM ItemRating WHERE IPAddress='$ip' and ItemId=$id"; - $adodbConnection = GetADODBConnection(); - $rs = $adodbConnection->Execute($sql); - if($rs) - { - $count = $rs->fields["DupCount"]; - } - return ($count>0); - //return FALSE; - } + function CheckPermission($permissionName) + { + //Check permission and if needs approval set approval + global $objSession,$objCatList; - function PurgeRatings() - { - global $objConfig; + $perm = $this->BasePermission; + if(strlen($perm)>0) + $perm .= "."; + $perm .= $permissionName; - $expired=time()-86400*$objConfig->Get("Timeout_Rating"); - $query="DELETE FROM ItemRating WHERE CreatedOn<$expired"; - $this->adodbConnection->Execute($query); - } + //get an instance of the forum category + $cat =& $objCatList->GetCategory($this->Get("CategoryId")); + if(!is_object($cat)) + { + return FALSE; + } + else + { + return ($cat->HasPermission($perm,$objSession->Get("GroupId"))); + } + } - function GetThumbnailImage() - { - if($this->Images->NumItems()==0) - $this->Images->GetResourceImages($this->Get("ResourceId")); - return $this->Images->GetResourceThumbnail($this->Get("ResourceId")); - } + function SubmitVote($voteRating, $voteNotes) + { + global $Errors; + global $REMOTE_ADDR; - function GetImage($number) - { - return $this->Images->GetImageByResource($this->Get("ResourceId"),$number); - } + if($this->rating_ip_exists($REMOTE_ADDR)) + { + // $Errors->AddError("error.already_voted","","","",get_class($this),"SubmitVote"); + return false; + } + $vote = new clsItemRating(NULL); + $vote->Set("ItemId",$this->UniqueId()); + $vote->Set("RatingValue",$voteRating); + if(!$vote->Create()) + return false; - function GetImageByName($name) - { - if(!is_object($this->Images)) - $this->Images = new clsImageList(); - return $this->Images->GetImageByName($this->Get("ResourceId"),$name); - } + $NumVotes = (int)$this->Get("CachedVotesQty"); + $CurrentRating = (int)$this->Get("CachedRating"); - function &GetDefaultImage() - { - return $this->Images->GetDefaultImage($this->Get("ResourceId")); - } + $Rating = (($NumVotes * $CurrentRating) + $voteRating)/($NumVotes+1); + $this->Set("CachedRating",$Rating); + $this->Update(); + $this->Increment("CachedVotesQty"); + } - function CreatePendingCopy() - { - $OrgId = $this->IdField(); - $this->Dirty(); - $this->Set("OrgId",$OrgId); - $this->UnsetIdField(); - $this->Set("ResourceId",0); - $this->Set("Status",-2); - $this->Create(); - } - - function AddFavorite($PortalUserId=NULL) - { - global $objSession, $objFavorites; + function rating_ip_exists($ip) + { + $count = 0; + $id = $this->Get("ResourceId"); + $sql = "SELECT count(*) as DupCount FROM ItemRating WHERE IPAddress='$ip' and ItemId=$id"; + $adodbConnection = GetADODBConnection(); + $rs = $adodbConnection->Execute($sql); + if($rs) + { + $count = $rs->fields["DupCount"]; + } + return ($count>0); + //return FALSE; + } - $res = FALSE; - if($objSession->HasCatPermission("FAVORITES")) - { - if(!$PortalUserId) - $PortalUserId = $objSession->Get("PortalUserId"); - if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN")) - { - $objFavorites->AddFavorite($PortalUserId,$this->Get("ResourceId"), $this->type); - $res = TRUE; - } - } - return $res; - } + function PurgeRatings() + { + global $objConfig; - function DeleteFavorite($PortalUserId=NULL) - { - global $objSession, $objFavorites; + $expired=time()-86400*$objConfig->Get("Timeout_Rating"); + $query="DELETE FROM ItemRating WHERE CreatedOn<$expired"; + $this->adodbConnection->Execute($query); + } - $res = FALSE; + function GetThumbnailImage() + { + if($this->Images->NumItems()==0) + $this->Images->GetResourceImages($this->Get("ResourceId")); + return $this->Images->GetResourceThumbnail($this->Get("ResourceId")); + } - if($objSession->HasCatPermission("FAVORITES")) - { - if(!$PortalUserId) - $PortalUserId = $objSession->Get("PortalUserId"); - //echo $PortalUserId." ".$objSession->Get("PortalUserId"); - if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN")) - { - $objFavorites->DeleteFavorite($PortalUserId,$this->Get("ResourceId")); - $res = TRUE; - } - } - return $res; - } + function GetImage($number) + { + return $this->Images->GetImageByResource($this->Get("ResourceId"),$number); + } - function IsFavorite($PortalUserId=NULL) - { - global $objSession, $objFavorites; + function GetImageByName($name) + { + if(!is_object($this->Images)) + $this->Images = new clsImageList(); + return $this->Images->GetImageByName($this->Get("ResourceId"),$name); + } - $res = FALSE; - - - if($objSession->HasCatPermission("FAVORITES")) - { - if(!$PortalUserId) - $PortalUserId = $objSession->Get("PortalUserId"); - - if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN")) - { - $i = $objFavorites->GetFavoriteObject($PortalUserId,$this->Get("ResourceId")); - - if(is_object($i)) - { - $res = TRUE; - } - else - $res = FALSE; - } - } - - return $res; - } - - function CheckBanned() - { - global $objBanList; - - $objBanList->LoadItemRules($this->type); - $found = FALSE; - $MatchedRule = 0; - foreach($objBanList->Items as $b) - { - $field = $b->Get("ItemField"); - if($this->FieldExists($field)) - { - $ThisValue = strtolower($this->Get($field)); - $TestValue = strtolower($b->Get("ItemValue")); - switch($b->Get("ItemVerb")) - { - case 0: /* any */ - $found = TRUE; - break; - case 1: /* is */ - if($ThisValue==$TestValue) - $found = TRUE; - break; - case 2: /* is not */ - if($ThisValue != $TestValue) - $found = TRUE; - break; - case 3: /* contains */ - if(strstr($ThisValue,$TestValue)) - $found = TRUE; - break; - case 4: /* not contains */ - if(!strstr($ThisValue,$TestValue)) - $found = TRUE; - break; - case 5: /* Greater Than */ - if($TestValue > $ThisValue) - $found = TRUE; - break; - case 6: /* Less Than */ - if($TestValue < $ThisValue) - $found = TRUE; - break; - case 7: /* exists */ - if(strlen($ThisValue)>0) - $found = TRUE; - break; - case 8: /* unique */ - if($this->ValueExists($field,$ThisValue)) - $found = TRUE; - break; - } - } - if($found) - { - if($b->Get("RuleType")==0) - { - $MatchedRule = $b->Get("RuleId"); - } - else - { - $MatchedRule = 0; - } - break; - } - } - return $MatchedRule; - } + function &GetDefaultImage() + { + return $this->Images->GetDefaultImage($this->Get("ResourceId")); + } + + function CreatePendingCopy() + { + $OrgId = $this->IdField(); + $this->Dirty(); + $this->Set("OrgId",$OrgId); + $this->UnsetIdField(); + $this->Set("ResourceId",0); + $this->Set("Status",-2); + $this->Create(); + } + + function AddFavorite($PortalUserId=NULL) + { + global $objSession, $objFavorites; + + $res = FALSE; + if($objSession->HasCatPermission("FAVORITES")) + { + if(!$PortalUserId) + $PortalUserId = $objSession->Get("PortalUserId"); + if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN")) + { + $objFavorites->AddFavorite($PortalUserId,$this->Get("ResourceId"), $this->type); + $res = TRUE; + } + } + return $res; + } + + function DeleteFavorite($PortalUserId=NULL) + { + global $objSession, $objFavorites; + + $res = FALSE; + + if($objSession->HasCatPermission("FAVORITES")) + { + if(!$PortalUserId) + $PortalUserId = $objSession->Get("PortalUserId"); + //echo $PortalUserId." ".$objSession->Get("PortalUserId"); + if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN")) + { + $objFavorites->DeleteFavorite($PortalUserId,$this->Get("ResourceId")); + $res = TRUE; + } + } + return $res; + } + + function IsFavorite($PortalUserId=NULL) + { + global $objSession, $objFavorites; + + $res = FALSE; + + + if($objSession->HasCatPermission("FAVORITES")) + { + if(!$PortalUserId) + $PortalUserId = $objSession->Get("PortalUserId"); + + if($PortalUserId==$objSession->Get("PortalUserId") || $objSession->HasSystemPermission("ADMIN")) + { + $i = $objFavorites->GetFavoriteObject($PortalUserId,$this->Get("ResourceId")); + + if(is_object($i)) + { + $res = TRUE; + } + else + $res = FALSE; + } + } + + return $res; + } + + function CheckBanned() + { + global $objBanList; + + $objBanList->LoadItemRules($this->type); + $found = FALSE; + $MatchedRule = 0; + foreach($objBanList->Items as $b) + { + $field = $b->Get("ItemField"); + if($this->FieldExists($field)) + { + $ThisValue = strtolower($this->Get($field)); + $TestValue = strtolower($b->Get("ItemValue")); + switch($b->Get("ItemVerb")) + { + case 0: /* any */ + $found = TRUE; + break; + case 1: /* is */ + if($ThisValue==$TestValue) + $found = TRUE; + break; + case 2: /* is not */ + if($ThisValue != $TestValue) + $found = TRUE; + break; + case 3: /* contains */ + if(strstr($ThisValue,$TestValue)) + $found = TRUE; + break; + case 4: /* not contains */ + if(!strstr($ThisValue,$TestValue)) + $found = TRUE; + break; + case 5: /* Greater Than */ + if($TestValue > $ThisValue) + $found = TRUE; + break; + case 6: /* Less Than */ + if($TestValue < $ThisValue) + $found = TRUE; + break; + case 7: /* exists */ + if(strlen($ThisValue)>0) + $found = TRUE; + break; + case 8: /* unique */ + if($this->ValueExists($field,$ThisValue)) + $found = TRUE; + break; + } + } + if($found) + { + if($b->Get("RuleType")==0) + { + $MatchedRule = $b->Get("RuleId"); + } + else + { + $MatchedRule = 0; + } + break; + } + } + return $MatchedRule; + } } /* clsItem */ -class clsCatItem extends clsItem +class clsCatItem extends clsItem { function clsCatItem($FullItem=FALSE) { $this->clsItem($FullItem); } - - function Delete($RecordOnly=FALSE) - { - global $objFavorites; - parent::Delete($RecordOnly); - if($RecordOnly==FALSE) - { - $this->RemoveFromAllCategories(); - } - } - /* category membership functions */ + function Delete($RecordOnly=FALSE) + { + global $objFavorites; - function AssignPrimaryCategory($SourceTable) - { - $catid = 0; - $sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId")." LIMIT 1"; - $rs = $this->adodbConnection->Execute($sql); - if($rs && !$rs->EOF) - { - $catid = $rs->fields["CategoryId"]; - $this->SetPrimaryCategory($catid,$SourceTable); - } - return $catid; - } + parent::Delete($RecordOnly); + if($RecordOnly==FALSE) + { + $this->RemoveFromAllCategories(); + } + } + /* category membership functions */ - function GetPrimaryCategory($SourceTable = "") - { - if(is_numeric($this->PrimaryCat)) - return $this->PrimaryCat; + function AssignPrimaryCategory($SourceTable) + { + $catid = 0; + $sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId")." LIMIT 1"; + $rs = $this->adodbConnection->Execute($sql); + if($rs && !$rs->EOF) + { + $catid = $rs->fields["CategoryId"]; + $this->SetPrimaryCategory($catid,$SourceTable); + } + return $catid; + } - $this->PrimaryCat=""; - if( strlen($SourceTable) == 0 ) $SourceTable = GetTablePrefix()."CategoryItems"; - $res_id = $this->HasField('ResourceId') ? $this->Get('ResourceId') : 0; - $sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$res_id." AND PrimaryCat=1"; - $rs = $this->adodbConnection->Execute($sql); - if($rs && !$rs->EOF) - { - $this->PrimaryCat=$rs->fields["CategoryId"]; - return $this->PrimaryCat; - } - else - { - $this->AssignPrimaryCategory($SourceTable); - return $this->PrimaryCat; - } - } + function GetPrimaryCategory($SourceTable = "") + { + if(is_numeric($this->PrimaryCat)) + return $this->PrimaryCat; - function SetPrimaryCategory($CategoryId,$SourceTable = "") - { - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; - - $rs = $this->adodbConnection->Execute('SELECT * FROM '.$SourceTable.' WHERE CategoryId='.$CategoryId.' AND ItemResourceId='.$this->Get("ResourceId")); - $this->adodbConnection->Execute("UPDATE $SourceTable SET PrimaryCat=0 WHERE ItemResourceId=".$this->Get("ResourceId")); - $this->adodbConnection->Execute("UPDATE $SourceTable SET PrimaryCat=1 WHERE CategoryId=$CategoryId AND ItemResourceId=".$this->Get("ResourceId")); - - $this->PrimaryCat=$CategoryId; - } - - function CategoryMemberCount($SourceTable="") - { - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; + $this->PrimaryCat=""; + if( strlen($SourceTable) == 0 ) $SourceTable = GetTablePrefix()."CategoryItems"; + $res_id = $this->HasField('ResourceId') ? $this->Get('ResourceId') : 0; + $sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$res_id." AND PrimaryCat=1"; + $rs = $this->adodbConnection->Execute($sql); + if($rs && !$rs->EOF) + { + $this->PrimaryCat=$rs->fields["CategoryId"]; + return $this->PrimaryCat; + } + else + { + $this->AssignPrimaryCategory($SourceTable); + return $this->PrimaryCat; + } + } - $sql = "SELECT count(*) as CatCount FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId"); - if($this->debuglevel) - echo $sql."
\n"; - - $rs = $this->adodbConnection->Execute($sql); - $count = 0; - if($rs && !$rs->EOF) - $count = $rs->fields["CatCount"]; - return $count; - } + function SetPrimaryCategory($CategoryId,$SourceTable = "") + { + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; - function CategoryMemberList($SourceTable="") - { - $cats = array(); - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; + $rs = $this->adodbConnection->Execute('SELECT * FROM '.$SourceTable.' WHERE CategoryId='.$CategoryId.' AND ItemResourceId='.$this->Get("ResourceId")); + $this->adodbConnection->Execute("UPDATE $SourceTable SET PrimaryCat=0 WHERE ItemResourceId=".$this->Get("ResourceId")); + $this->adodbConnection->Execute("UPDATE $SourceTable SET PrimaryCat=1 WHERE CategoryId=$CategoryId AND ItemResourceId=".$this->Get("ResourceId")); - $sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId"); - - if($this->debuglevel) - echo $sql."
\n"; - - $rs = $this->adodbConnection->Execute($sql); - while($rs && !$rs->EOF) - { - $cats[] = $rs->fields["CategoryId"]; - $rs->MoveNext(); - } - $catlist = implode(",",$cats); - return $catlist; - } + $this->PrimaryCat=$CategoryId; + } - function AddToCategory($CatId,$SourceTable="",$PrimaryValue=NULL) - { - global $objSession, $objCatList; + function CategoryMemberCount($SourceTable="") + { + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; - if(!$SourceTable) - $SourceTable = GetTablePrefix()."CategoryItems"; + $sql = "SELECT count(*) as CatCount FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId"); + if($this->debuglevel) + echo $sql."
\n"; - if($this->type>0) - { - $Primary = 0; - if(is_numeric($PrimaryValue)) - { - $Primary = $PrimaryValue; - if($Primary==1) - $this->PrimaryCat = $CatId; - } - else - { - if(!is_numeric($this->GetPrimaryCategory())) - { - $Primary =1; - $this->PrimaryCat = $CatId; - } - } + $rs = $this->adodbConnection->Execute($sql); + $count = 0; + if($rs && !$rs->EOF) + $count = $rs->fields["CatCount"]; + return $count; + } - // check if not exists - - $db =& $this->adodbConnection; - $sql = sprintf('SELECT * FROM %s WHERE CategoryId = %s AND ItemResourceId = %s', $SourceTable, $CatId, $this->Get("ResourceId")); - $rs = $db->Execute($sql); + function CategoryMemberList($SourceTable="") + { + $cats = array(); + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; - if (is_object($rs)) { - if($rs->RecordCount() == 0 ) - { - $sql = "INSERT INTO $SourceTable (CategoryId,ItemResourceId, PrimaryCat) VALUES ('$CatId','".$this->Get("ResourceId")."',$Primary)"; - if($this->debuglevel) - echo $sql."
\n"; - $this->adodbConnection->Execute($sql); - } - } - - $c = $objCatList->GetCategory($CatId); - } - } + $sql = "SELECT * FROM $SourceTable WHERE ItemResourceId=".$this->Get("ResourceId"); - function RemoveFromCategory($CatId,$SourceTable="",$Force=0) - { - global $objSession, $objCatList; + if($this->debuglevel) + echo $sql."
\n"; - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; + $rs = $this->adodbConnection->Execute($sql); + while($rs && !$rs->EOF) + { + $cats[] = $rs->fields["CategoryId"]; + $rs->MoveNext(); + } + $catlist = implode(",",$cats); + return $catlist; + } - if($this->type>0) - { - $primary = $this->GetPrimaryCategory(); - if(($primary==$CatId && $this->CategoryMemberCount($SourceTable)>1) || ($primary != $CatId) || $Force) - { - $sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId"); - if($objSession->HasSystemPermission("DEBUG.LIST")) - echo $sql."
\n"; + function AddToCategory($CatId,$SourceTable="",$PrimaryValue=NULL) + { + global $objSession, $objCatList; - $this->adodbConnection->Execute($sql); - $c = $objCatList->GetCategory($CatId); - $c->ClearCacheData(); - } - } - } + if(!$SourceTable) + $SourceTable = GetTablePrefix()."CategoryItems"; - function MoveToCategory($OldCatId,$NewCatId,$SourceTable="") - { - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; + if($this->type>0) + { + $Primary = 0; + if(is_numeric($PrimaryValue)) + { + $Primary = $PrimaryValue; + if($Primary==1) + $this->PrimaryCat = $CatId; + } + else + { + if(!is_numeric($this->GetPrimaryCategory())) + { + $Primary =1; + $this->PrimaryCat = $CatId; + } + } - $sql = "UPDATE $SourceTable SET CategoryId=$NewCatId WHERE CategoryId=$OldCatId AND ItemResourceId=".$this->Get("ResourceId"); - if($this->debuglevel) - echo $sql."
\n"; - - $this->adodbConnection->Execute($sql); - } + // check if not exists - function DeleteCategoryItems($CatId,$SourceTable = "") - { - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; + $db =& $this->adodbConnection; + $sql = sprintf('SELECT * FROM %s WHERE CategoryId = %s AND ItemResourceId = %s', $SourceTable, $CatId, $this->Get("ResourceId")); + $rs = $db->Execute($sql); - $CatCount = $this->CategoryMemberCount($SourceTable); - if($CatCount>1) - { - $this->RemoveFromCategory($CatId,$SourceTable); - $this->ClearCacheData(); - } - else - { - $this->Delete(); - $sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId"); - if($this->debuglevel) - echo $sql."
\n"; + if (is_object($rs)) { + if($rs->RecordCount() == 0 ) + { + $sql = "INSERT INTO $SourceTable (CategoryId,ItemResourceId, PrimaryCat) VALUES ('$CatId','".$this->Get("ResourceId")."',$Primary)"; + if($this->debuglevel) + echo $sql."
\n"; + $this->adodbConnection->Execute($sql); + } + } - $this->adodbConnection->Execute($sql); - } - } - function RemoveFromAllCategories($SourceTable = "") - { - if(strlen($SourceTable)==0) - $SourceTable = GetTablePrefix()."CategoryItems"; + $c = $objCatList->GetCategory($CatId); + } + } - if($this->type>0) - { - $sql = "SELECT * FROM $SourceTable WHERE ResourceId=".$this->Get("ResourceId"); - $rs = $this->adodbConnection->Execute($sql); - while ($rs && !$rs->EOF) - { - $CategoryId = $rs->fields["CategoryId"]; - $rs->MoveNext(); - } - $sql = "DELETE FROM $SourceTable WHERE ResourceId=".$this->Get("ResourceId"); - if($this->debuglevel) - echo $sql."
\n"; - - $this->adodbConnection->Execute($sql); - } - } - - function CopyToNewResource($TargetCat = NULL,$NameField="Name") - { - global $objSession; + function RemoveFromCategory($CatId,$SourceTable="",$Force=0) + { + global $objSession, $objCatList; - $CatList = $this->CategoryMemberList(); - - $Cats = explode(",",$CatList); - //echo "Target: $TargetCat
"; - $OldId = $this->Get("ResourceId"); - $this->UnsetIdField(); - $this->Dirty(); - if(!is_numeric($this->Get("OrgId"))) - $this->UnsetField("OrgId"); - $this->UnsetField("ResourceId"); - if(is_numeric($TargetCat) && strlen($NameField)) - { - $OldName = $this->Get($NameField); - if(substr($OldName,0,5)=="Copy ") - { - $parts = explode(" ",$OldName,4); - if($parts[2]=="of" && is_numeric($parts[1])) - { - $Name = $parts[3]; - } - else - if($parts[1]=="of") - { - $Name = $parts[2]." ".$parts[3]; - } - else - $Name = $OldName; - } - else - $Name = $OldName; - $Names = CategoryItemNameCount($TargetCat,$this->tablename,$NameField,$Name); - if(count($Names)>0) - { - $NameCount = count($Names); - $found = FALSE; - $NewName = "Copy of $Name"; - - if(!in_array("Copy of $Name",$Names)) - { - $found = TRUE; - } - else - { - for($x=2;$x<$NameCount+2;$x++) - { + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; - $NewName = "Copy ".$x." of ".$Name; - if(!in_array($NewName,$Names)) - { - $found = TRUE; - break; - } - - } - } - if(!$found) - { - $NameCount++; - $NewName = "Copy $NameCount of $Name"; - } - $this->Set($NameField,$NewName); - } - } - $this->Create(); - // copy relationships - $NewId = $this->Get("ResourceId"); - $reldata = new clsRelationshipList($TargetCat,$this->IdField()); - $reldata->CopyToResource($OldId,$NewId); - - // copy reviews - $rdata = new clsItemReviewList(); - $rdata->CopyToItemId($OldId,$NewId); - unset($rdata); - - // copy custom fields - $cdata = new clsCustomDataList(); - $cdata->CopyResource($OldId,$NewId); - unset($cdata); - - // copy images - if(is_object($this->Images)) - $this->Images->CopyResource($OldId,$NewId); + if($this->type>0) + { + $primary = $this->GetPrimaryCategory(); + if(($primary==$CatId && $this->CategoryMemberCount($SourceTable)>1) || ($primary != $CatId) || $Force) + { + $sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId"); + if($objSession->HasSystemPermission("DEBUG.LIST")) + echo $sql."
\n"; - $this->AddToCategory($TargetCat, '', 0); // insert (but with duplicate records check) - //echo "ok"; - if(is_numeric($TargetCat)) - { - if(is_array($Cats)) - { - if(!in_array($TargetCat,$Cats)) - { - $this->AddToCategory($TargetCat, 0); // insert - } - } - $this->SetPrimaryCategory($TargetCat); // 2 updates - } - } + $this->adodbConnection->Execute($sql); + $c = $objCatList->GetCategory($CatId); + $c->ClearCacheData(); + } + } + } - - + function MoveToCategory($OldCatId,$NewCatId,$SourceTable="") + { + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; + + $sql = "UPDATE $SourceTable SET CategoryId=$NewCatId WHERE CategoryId=$OldCatId AND ItemResourceId=".$this->Get("ResourceId"); + if($this->debuglevel) + echo $sql."
\n"; + + $this->adodbConnection->Execute($sql); + } + + function DeleteCategoryItems($CatId,$SourceTable = "") + { + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; + + $CatCount = $this->CategoryMemberCount($SourceTable); + if($CatCount>1) + { + $this->RemoveFromCategory($CatId,$SourceTable); + $this->ClearCacheData(); + } + else + { + $this->Delete(); + $sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId"); + if($this->debuglevel) + echo $sql."
\n"; + + $this->adodbConnection->Execute($sql); + } + } + function RemoveFromAllCategories($SourceTable = "") + { + if(strlen($SourceTable)==0) + $SourceTable = GetTablePrefix()."CategoryItems"; + + if($this->type>0) + { + $sql = "SELECT * FROM $SourceTable WHERE ResourceId=".$this->Get("ResourceId"); + $rs = $this->adodbConnection->Execute($sql); + while ($rs && !$rs->EOF) + { + $CategoryId = $rs->fields["CategoryId"]; + $rs->MoveNext(); + } + $sql = "DELETE FROM $SourceTable WHERE ResourceId=".$this->Get("ResourceId"); + if($this->debuglevel) + echo $sql."
\n"; + + $this->adodbConnection->Execute($sql); + } + } + + function CopyToNewResource($TargetCat = NULL,$NameField="Name") + { + global $objSession; + + $CatList = $this->CategoryMemberList(); + + $Cats = explode(",",$CatList); + //echo "Target: $TargetCat
"; + $OldId = $this->Get("ResourceId"); + $this->UnsetIdField(); + $this->Dirty(); + if(!is_numeric($this->Get("OrgId"))) + $this->UnsetField("OrgId"); + $this->UnsetField("ResourceId"); + if(is_numeric($TargetCat) && strlen($NameField)) + { + $OldName = $this->Get($NameField); + if(substr($OldName,0,5)=="Copy ") + { + $parts = explode(" ",$OldName,4); + if($parts[2]=="of" && is_numeric($parts[1])) + { + $Name = $parts[3]; + } + else + if($parts[1]=="of") + { + $Name = $parts[2]." ".$parts[3]; + } + else + $Name = $OldName; + } + else + $Name = $OldName; + $Names = CategoryItemNameCount($TargetCat,$this->tablename,$NameField,$Name); + if(count($Names)>0) + { + $NameCount = count($Names); + $found = FALSE; + $NewName = "Copy of $Name"; + + if(!in_array("Copy of $Name",$Names)) + { + $found = TRUE; + } + else + { + for($x=2;$x<$NameCount+2;$x++) + { + + $NewName = "Copy ".$x." of ".$Name; + if(!in_array($NewName,$Names)) + { + $found = TRUE; + break; + } + + } + } + if(!$found) + { + $NameCount++; + $NewName = "Copy $NameCount of $Name"; + } + $this->Set($NameField,$NewName); + } + } + $this->Create(); + // copy relationships + $NewId = $this->Get("ResourceId"); + $reldata = new clsRelationshipList($TargetCat,$this->IdField()); + $reldata->CopyToResource($OldId,$NewId); + + // copy reviews + $rdata = new clsItemReviewList(); + $rdata->CopyToItemId($OldId,$NewId); + unset($rdata); + + // copy custom fields + $cdata = new clsCustomDataList(); + $cdata->CopyResource($OldId,$NewId); + unset($cdata); + + // copy images + if(is_object($this->Images)) + $this->Images->CopyResource($OldId,$NewId); + + $this->AddToCategory($TargetCat, '', 0); // insert (but with duplicate records check) + //echo "ok"; + if(is_numeric($TargetCat)) + { + if(is_array($Cats)) + { + if(!in_array($TargetCat,$Cats)) + { + $this->AddToCategory($TargetCat, 0); // insert + } + } + $this->SetPrimaryCategory($TargetCat); // 2 updates + } + } + } ?> \ No newline at end of file Index: trunk/kernel/admin/include/help/server_info.txt =================================================================== diff -u --- trunk/kernel/admin/include/help/server_info.txt (revision 0) +++ trunk/kernel/admin/include/help/server_info.txt (revision 440) @@ -0,0 +1,3 @@ + +

This section is for advanced administrators who need to reference the server information. It displays the common PHP Information page, as reported by the PHP engine.

+It is useful mostly for debugging purposes. Index: trunk/kernel/admin/include/help/main_import.txt =================================================================== diff -u -r326 -r440 --- trunk/kernel/admin/include/help/main_import.txt (.../main_import.txt) (revision 326) +++ trunk/kernel/admin/include/help/main_import.txt (.../main_import.txt) (revision 440) @@ -1,15 +1,13 @@ This section allows the administrator to import the data from other applications into your existing In-portal system.

-Step 1 of the import begins with a disclaimer that the data in your current system will be affected. Please ensure you understand the import process and the particular kind of import you are doing before proceeding. +Step 1 of the import begins with a disclaimer that the data in your current system will be affected. Please ensure you understand the import process and the particular kind of import you are doing before proceeding. In the current version, only the import from In-link2 and from phpBB 2.x is available +

-In-link 2 Import
-In the current version, only the import from In-link2 is available. The import is designed for In-link version 2.3.4, however it will work, or partially work, for most of the older In-link2 versions up to 2.0.10. If you have one of the older In-link2 versions and are experiencing problems, please upgrade your In-link2 to the version 2.3.4, and then run this import. It is not possible to use In-link2 import if you do not have In-link3 installed on your In-portal platform. Some In-link2 license holders are entitled to a complimentary In-link3 license, please go to your account at http://www.intechnic.com/myaccount for more information, or submit a support ticket. + +Step 2
+Import source selection.

+ Step 3
-In this step, the administrator will be asked to enter all database information for the In-link2 data. The current version of In-portal only supports import from the MySQL databases of In-link2.

-Step 4
-In this step, the administrator will need to designate the options of the import � how the In-link2 data is supposed to be integrated into In-portal and In-link3. -
  • Administrative Group � this field designates the In-portal administrative group (by default, �Admin'), into which the old In-link2 administrators should be imported. You can choose a different group for the import, and then designate the administrative users later. Clicking on the group button will pop up a list of In-portal groups. -
  • Regular User Group - this field designates the In-portal group (by default, �Members'), into which the old In-link2 users (link owners) should be imported. It is recommended to import then into a group that will give them access to the front-end, and to modify their links. However, you can choose a different group for the import, and then manage the users later. Clicking on the group button will pop up a list of In-portal groups. -
  • Initial Import Category � this field designates the In-portal category, which will serve as a root for the In-link2 import. This category will be the equivalent of the Home category in In-link2, and all of the sub-categories will be created underneath. Clicking on the category button (folder icon) will pop up a catalog navigator, where you can select the category. -
  • Link Image Name � this field designates the link image field in the In-link2 database, which was used to store the link image name. By default, it is �link_image' , however many users have used a custom field for this purpose, in which case you should enter the custom field name here. \ No newline at end of file +In this step, the administrator will be asked to enter all database information for the import source data. The current version of In-portal only supports import from the MySQL databases.

    + \ No newline at end of file Index: trunk/admin/help/manual.pdf =================================================================== diff -u -r421 -r440 Binary files differ Index: trunk/admin/include/sections.php =================================================================== diff -u -r396 -r440 --- trunk/admin/include/sections.php (.../sections.php) (revision 396) +++ trunk/admin/include/sections.php (.../sections.php) (revision 440) @@ -413,9 +413,10 @@ if( in_array($module_name, $url_split) ) return 1; // module section match - if( isset($_REQUEST['section']) ) + $section = GetVar('section'); + if($section) { - $section = explode(':', $_GET['section']); + $section = explode(':', $section); if( $section[0] == $module_name ) return true; } return false; @@ -463,7 +464,7 @@ return $o; } - function section_header($envar,$navbar=NULL,$extra_title=NULL, $no_help = false) + function section_header($envar,$navbar=NULL,$extra_title=NULL, $no_help = false, $OtherSection = '') { global $pathtoroot; global $pathtolocal; @@ -512,7 +513,7 @@ $o .= $output; if(strlen($navbar)) $o .= "::".$navbar.""; - + if($OtherSection) $node_key = $OtherSection; $o .= ""; if($no_help == false) $o .= ""; $o .= ""; Index: trunk/kernel/admin/include/help/emaillog.txt =================================================================== diff -u --- trunk/kernel/admin/include/help/emaillog.txt (revision 0) +++ trunk/kernel/admin/include/help/emaillog.txt (revision 440) @@ -0,0 +1,2 @@ +This section displays a list of all emails generated and sent by the system. You can refresh this information by clicking the "Refresh" button, or delete one or more entries by clicking the �Reset' button (a recycling bin icon with a red x).

    +The email log is useful when addressing problems with users, who either received unwanted email communications, or visa versa � have not received a notification they were waiting for. \ No newline at end of file Index: trunk/admin/help/help.php =================================================================== diff -u -r374 -r440 --- trunk/admin/help/help.php (.../help.php) (revision 374) +++ trunk/admin/help/help.php (.../help.php) (revision 440) @@ -63,7 +63,7 @@ $rootURL="http://".ThisDomain().$objConfig->Get("Site_Path"); -$baseURL = $_SERVER['DOCUMENT_ROOT'].$path_char.$objConfig->Get("Site_Path"); +$baseURL = $_SERVER['DOCUMENT_ROOT'].$objConfig->Get("Site_Path"); $admin = $objConfig->Get("AdminDirectory"); if(!strlen($admin)) Index: trunk/kernel/images/3493_1.gif =================================================================== diff -u -r13 -r440 Binary files differ Index: trunk/admin/include/elements.php =================================================================== diff -u -r402 -r440 --- trunk/admin/include/elements.php (.../elements.php) (revision 402) +++ trunk/admin/include/elements.php (.../elements.php) (revision 440) @@ -90,7 +90,7 @@ //*********************************** //Page Header -function int_header($toolbar=NULL,$NavBarText=NULL,$ExtraTitle=NULL,$onLoad=NULL, $ExtraHead=NULL,$skip_modules=Array()) +function int_header($toolbar=NULL,$NavBarText=NULL,$ExtraTitle=NULL,$onLoad=NULL, $ExtraHead=NULL,$skip_modules=Array(),$OtherSection = '') { global $pathtoroot; global $pathtolocal; @@ -189,7 +189,7 @@ print $objSections->page_tabs($envar); if ($sec->Get("nonavbar") != 1) //Section Navigatior - print $objSections->section_header($envar,$NavBarText,$ExtraTitle); + print $objSections->section_header($envar,$NavBarText,$ExtraTitle,false,$OtherSection); //Toolbar if appropriate if ( isset($sections[$section]) && ($sections[$section]['toolbar']==1) || ( is_object($toolbar) ) ) @@ -213,9 +213,7 @@ $style_sheet_global = $adminURL."/include/style.css"; $style_sheet_local = $localURL."admin/include/style.css"; - - $ExtraTitle = htmlentities($ExtraTitle); - + // TOOLBAR: print "In-Portal - Help"; print ""; @@ -235,7 +233,7 @@ if ($sec->Get("notitle") != 1) print $objSections->page_title(); if ($sec->Get("nonavbar") != 1) //Section Navigatior - print $objSections->section_header($envar,$NavBarText,$ExtraTitle, true); + print $objSections->section_header($envar,'','', true); } }// HELP Page Header Index: trunk/admin/import/step4.php =================================================================== diff -u -r374 -r440 --- trunk/admin/import/step4.php (.../step4.php) (revision 374) +++ trunk/admin/import/step4.php (.../step4.php) (revision 440) @@ -134,7 +134,8 @@ // Header $title = admin_language("la_performing_import")." - ".admin_language("la_Step")." 4"; - int_header($objCatToolBar,NULL,$title); + $NewSection = strtolower($import_script['module']).':'.$import_script['id']; + int_header($objCatToolBar,NULL,$title,NULL,NULL,Array(),$NewSection); ?>