Index: trunk/kernel/include/category.php =================================================================== diff -u -r4126 -r4446 --- trunk/kernel/include/category.php (.../category.php) (revision 4126) +++ trunk/kernel/include/category.php (.../category.php) (revision 4446) @@ -26,42 +26,42 @@ $this->CloseTagVar = "Category_Highlight_CloseTag"; if($CategoryId!=NULL) - { + { $this->LoadFromDatabase($CategoryId); $this->Permissions = new clsPermList($CategoryId,$objSession->Get("GroupId")); - + } else - { + { $this->Permissions = new clsPermList(); } } - + function StripDisallowed($string) { $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~', '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ','); - + $string = str_replace($not_allowed, '_', $string); $string = preg_replace('/(_+)/', '_', $string); $string = $this->checkAutoFilename($string); - + return $string; } - + function checkAutoFilename($filename) { global $m_var_list; - + if(!$filename || $this->UniqueId() == 0 ) return $filename; $db =& GetADODBConnection(); - + $sql = 'SELECT CategoryId FROM '.$this->tablename.' WHERE (Filename = '.$db->qstr($filename).') AND (ParentId = '.$m_var_list['cat'].')'; $found_category_ids = $db->GetCol($sql); $has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets); - + $duplicates_found = (count($found_category_ids) > 1) || ($found_category_ids && $found_category_ids[0] != $this->UniqueId()); if ($duplicates_found || $has_page) { @@ -71,20 +71,20 @@ $filename = $rets[1].'_'.$rets[2]; $append = $rets[3] ? $rets[3] : '_a'; } - + $sql = 'SELECT CategoryId FROM '.$this->tablename.' WHERE (Filename = %s) AND (CategoryId != '.$this->UniqueId().') AND (ParentId = '.$m_var_list['cat'].')'; while ( $db->GetOne( sprintf($sql, $db->qstr($filename.$append)) ) > 0 ) { if (substr($append, -1) == 'z') $append .= 'a'; $append = substr($append, 0, strlen($append) - 1) . chr( ord( substr($append, -1) ) + 1 ); } - + return $filename.$append; } - + return $filename; } - + function GenerateFilename() { if ( !$this->Get('AutomaticFilename') && $this->Get('Filename') ) @@ -96,100 +96,100 @@ $name = $this->Get('Name'); } $name = $this->StripDisallowed($name); - + if ( $name != $this->Get('Filename') ) $this->Set('Filename', $name); } function ClearCacheData() { /*$env = "':m".$this->Get("CategoryId")."%'"; DeleteTagCache("m_list_cats","",$env); */ - DeleteTagCache("m_itemcount","Category%"); + DeleteTagCache("m_itemcount","Category%"); DeleteModuleTagCache('kernel'); } - + function DetectChanges($name, $value) - { + { global $objSession; //print_pre($_POST); if (!isset($this->Data[$name]) ) return false; - - if ($this->Data[$name] != $value) { + + if ($this->Data[$name] != $value) { //echo "$name Modified tt ".$this->Data[$name]." tt $value
"; if (!stristr($name, 'Modif') && !stristr($name, 'Created')) { if ($objSession->GetVariable("HasChanges") != 1) { - $objSession->SetVariable("HasChanges", 2); + $objSession->SetVariable("HasChanges", 2); } } } - } + } - + function Delete() { global $CatDeleteList; - + if(!is_array($CatDeleteList)) - $CatDeleteList = array(); + $CatDeleteList = array(); if($this->UsingTempTable()==FALSE) { $this->Permissions->Delete_CatPerms($this->Get("CategoryId")); - + // TODO: find way to delete specific category cache only /*$sql = "DELETE FROM ".GetTablePrefix()."CountCache WHERE CategoryId=".$this->Get("CategoryId"); $this->adodbConnection->Execute($sql);*/ - - $CatDeleteList[] = $this->Get("CategoryId"); + + $CatDeleteList[] = $this->Get("CategoryId"); if($this->Get("CreatedById")>0) $this->SendUserEventMail("CATEGORY.DELETE",$this->Get("CreatedById")); - $this->SendAdminEventMail("CATEGORY.DELETE"); - + $this->SendAdminEventMail("CATEGORY.DELETE"); + parent::Delete(); - $this->ClearCacheData(); + $this->ClearCacheData(); } - else + else { - parent::Delete(); + parent::Delete(); } } - + function Update($UpdatedBy=NULL) { parent::Update($UpdatedBy); $this->GenerateFilename(); - + parent::Update($UpdatedBy); - + if ($this->tablename == GetTablePrefix().'Category') $this->ClearCacheData(); } function Create() { if( (int)$this->Get('CreatedOn') == 0 ) $this->Set('CreatedOn', adodb_date('U') ); parent::Create(); - + $this->GenerateFilename(); parent::Update(); - + if ($this->tablename == GetTablePrefix().'Category') $this->ClearCacheData(); } - function SetParentId($value) + function SetParentId($value) { //Before we set a parent verify that propsed parent is not our child. //Otherwise it will cause recursion. - + $id = $this->Get("CategoryId"); $path = $this->Get("ParentPath"); - $sql = sprintf("SELECT CategoryId From ".GetTablePrefix()."Category WHERE ParentPath LIKE '$path%' AND CategoryId = %d ORDER BY ParentPath",$value); + $sql = sprintf("SELECT CategoryId From ".GetTablePrefix()."Category WHERE ParentPath LIKE '$path%' AND CategoryId = %d ORDER BY ParentPath",$value); $rs = $this->adodbConnection->SelectLimit($sql,1,0); if(!$rs->EOF) { return; } $this->Set("ParentId",$value); - } + } function Approve() { @@ -215,45 +215,45 @@ } - function IsEditorsPick() + function IsEditorsPick() { return $this->Is("EditorsPick"); } - - function SetEditorsPick($value) + + function SetEditorsPick($value) { $this->Set("EditorsPick", $value); } - + function GetSubCats($limit=NULL, $target_template=NULL, $separator=NULL, $anchor=NULL, $ending=NULL, $class=NULL) { global $m_var_list, $m_var_list_update, $var_list, $var_list_update; - + $sql = "SELECT CategoryId, Name from ".GetTablePrefix()."Category where ParentId=".$this->Get("CategoryId")." AND Status=1 ORDER BY Priority"; if(isset($limit)) - { + { $rs = $this->adodbConnection->SelectLimit($sql, $limit, 0); } else { $rs = $this->adodbConnection->Execute($sql); } $count=1; - + $class_name = is_null($class)? "catsub" : $class; - - + + while($rs && !$rs->EOF) - { + { $var_list_update["t"] = !is_null($target_template)? $target_template : $var_list["t"]; $m_var_list_update["cat"] = $rs->fields["CategoryId"]; $m_var_list_update["p"] = "1"; $cat_name = $rs->fields['Name']; if (!is_null($anchor)) - $ret .= "$cat_name"; + $ret .= "$cat_name"; else - $ret .= "$cat_name"; - + $ret .= "$cat_name"; + $rs->MoveNext(); if(!$rs->EOF) { @@ -262,41 +262,41 @@ } if(strlen($ret)) $ret .= is_null($ending)? " ..." : $ending; - + unset($var_list_update["t"], $m_var_list_update["cat"], $m_var_list_update["p"]); - + return $ret; } function Validate() { global $objSession; - - $dataValid = true; + + $dataValid = true; if(!isset($this->m_Type)) { $Errors->AddError("error.fieldIsRequired",'Type',"","","clsCategory","Validate"); $dataValid = false; } - + if(!isset($this->m_Name)) { $Errors->AddError("error.fieldIsRequired",'Name',"","","clsCategory","Validate"); $dataValid = false; } - + if(!isset($this->m_Description)) { $Errors->AddError("error.fieldIsRequired",'Description',"","","clsCategory","Validate"); $dataValid = false; } - + if(!isset($this->m_Visible)) { $Errors->AddError("error.fieldIsRequired",'Visible',"","","clsCategory","Validate"); $dataValid = false; } - + if(!isset($this->m_CreatedById)) { $Errors->AddError("error.fieldIsRequired",'CreatedBy',"","","clsCategory","Validate"); @@ -322,6 +322,7 @@ $path_parts[] = $Id2; $nav_parts[] = $rs->fields['Name']; $named_parts[] = $rs->fields['Filename']; + if (!$cateogry_template && $rs->fields['CachedCategoryTemplate']) { $cateogry_template = $rs->fields['CachedCategoryTemplate']; } @@ -373,12 +374,12 @@ global $objSession, $Errors, $objConfig; if($Id==0) return FALSE; - + 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 CategoryId = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) @@ -407,30 +408,30 @@ $this->IsNew = FALSE; if($value>$cutoff) $this->IsNew = TRUE; - return $this->IsNew; + return $this->IsNew; } - + function LoadFromResourceId($Id) { global $objSession, $Errors; if(!isset($Id)) { $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromResourceId"); return false; - } - $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ResourceId = '%s'",$Id); + } + $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ResourceId = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) { $Errors->AddError("error.DatabaseError",NULL,$adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromResourceId"); return false; - } + } $data = $result->fields; if(is_array($data)) $this->SetFromArray($data); else - return false; + return false; return true; } @@ -459,8 +460,8 @@ return $ret; } - + function GetCustomField($fieldName) { global $objSession, $Errors; @@ -485,26 +486,26 @@ } return SetCustomFieldValue($this->m_CategoryId,"category",$fieldName,$value); } - + function LoadPermissions($first=1) - { + { /* load all permissions for group on this category */ $this->Permissions->CatId=$this->Get("CategoryId"); if($this->Permissions->NumItems()==0) - { + { $cats = explode("|",substr($this->Get("ParentPath"),1,-1)); if(is_array($cats)) - { - $cats = array_reverse($cats); + { + $cats = array_reverse($cats); $cats[] = 0; foreach($cats as $catid) - { + { $this->Permissions->LoadCategory($catid); } } } if($this->Permissions->NumItems()==0) - { + { if($first==1) { $this->Permissions->GroupId=NULL; @@ -525,7 +526,7 @@ } function HasPermission($PermissionName,$GroupID) - { + { global $objSession; $perm = $this->PermissionValue($PermissionName,$GroupID); @@ -539,7 +540,7 @@ function PermissionValue($PermissionName,$GroupID) { - //$this->LoadPermissions(); + //$this->LoadPermissions(); $ret=NULL; //echo "Looping though ".count($this->Permissions)." permissions Looking for $PermissionName of $GroupID
\n"; if($this->Permissions->GroupId != $GroupID) @@ -555,11 +556,11 @@ $cats = explode("|",substr($this->Get("ParentPath"),1,-1)); if(is_array($cats)) - { - $cats = array_reverse($cats); + { + $cats = array_reverse($cats); $cats[] = 0; foreach($cats as $catid) - { + { $this->Permissions->LoadCategory($catid); $ret = $this->Permissions->GetPermissionValue($PermissionName); if(is_numeric($ret)) @@ -573,7 +574,7 @@ function SetPermission($PermName,$GroupID,$Value,$Type=0) { global $objSession, $objPermissions, $objGroups; - + if($this->Permissions->GroupId != $GroupID) { $this->Permissions->Clear(); @@ -600,7 +601,7 @@ $this->Permissions->Add_Permission($this->Get("CategoryId"),$GroupId,$PermName,$Value,$Type); } if($PermName == "CATEGORY.VIEW") - { + { $Groups = $objGroups->GetAllGroupList(); $ViewList = $this->Permissions->GetGroupPermList($this,"CATEGORY.VIEW",$Groups); $this->SetViewPerms("CATEGORY.VIEW",$ViewList,$Groups); @@ -619,7 +620,7 @@ global $objGroups; $allgroups = $objGroups->GetAllGroupList(); } - + for($i=0;$iPermissions->GetPermId($PermName); $pc = $objPermCache->GetPerm($this->Get("CategoryId"),$PermId); if(is_object($pc)) - { + { $pc->Set("ACL",$aval); $pc->Set("DACL",$dval); $pc->Update(); @@ -662,7 +663,7 @@ $PermId = $this->Permissions->GetPermId($PermName); $pc = $objPermCache->GetPerm($this->Get("CategoryId"),$PermId); if(is_object($pc)) - { + { $ret = $this->Get("ACL"); } return $ret; @@ -675,11 +676,11 @@ $glist = $objGroups->GetAllGroupList(); - $ViewList = $this->Permissions->GetGroupPermList($this,"CATEGORY.VIEW",$glist); + $ViewList = $this->Permissions->GetGroupPermList($this,"CATEGORY.VIEW",$glist); $perms = $this->Permissions->GetAllViewPermGroups($this,$glist); //echo "
";print_r($perms); echo "
"; foreach($perms as $PermName => $l) - { + { $this->SetViewPerms($PermName,$l,$glist); } } @@ -728,15 +729,15 @@ $ret .= "icon16_cat_disabled.gif"; break; case STATUS_PENDING: - $ret .= "icon16_cat_pending.gif"; + $ret .= "icon16_cat_pending.gif"; break; case STATUS_ACTIVE: $img = "icon16_cat.gif"; if($this->IsPopItem()) $img = "icon16_cat_pop.gif"; if($this->IsHotItem()) $img = "icon16_cat_hot.gif"; - if($this->IsNewItem()) + if($this->IsNewItem()) $img = "icon16_cat_new.gif"; if($this->Is("EditorsPick")) $img = "icon16_car_pick.gif"; @@ -756,12 +757,12 @@ { $val = $rs->fields["SubCount"]; if($val != $this->Get("CachedDescendantCatsQty")) - { + { $this->Set("CachedDescendantCatsQty",$val); $this->Update(); } - $ret = $this->Get("CachedDescendantCatsQty"); - } + $ret = $this->Get("CachedDescendantCatsQty"); + } return $ret; } @@ -777,7 +778,7 @@ } return $ret; } - + function GetParentIds() { $Parents = array(); @@ -789,18 +790,18 @@ } return $Parents; } - + function ItemCount($ItemType="") { global $objItemTypes,$objCatList,$objCountCache; - + if(!is_numeric($ItemType)) { - $TypeId = $objItemTypes->GetItemTypeValue($ItemType); + $TypeId = $objItemTypes->GetItemTypeValue($ItemType); } else - $TypeId = (int)$ItemType; - + $TypeId = (int)$ItemType; + //$path = $this->Get("ParentPath"); //$path = substr($path,1,-1); //$path = str_replace("|",",",$path); @@ -811,32 +812,32 @@ } else $path = $this->Get("CategoryId"); - - $res = TableCount(GetTablePrefix()."CategoryItems","CategoryId IN ($path)",FALSE); - - return $res; + + $res = TableCount(GetTablePrefix()."CategoryItems","CategoryId IN ($path)",FALSE); + + return $res; } function ParseObject($element) { global $objConfig, $objCatList, $rootURL, $var_list, $var_list_update, $m_var_list_update, $objItemTypes,$objCountCache, $objUsers; - + $extra_attribs = ExtraAttributes($element->attributes); - + //print_r($element); if(strtolower($element->name)==$this->TagPrefix) - { + { $field = strtolower( $element->GetAttributeByName('_field') ); switch($field) { case 'filename': $ret = $this->Get('Filename'); break; - + case 'm_language': $ret = language( $element->GetAttributeByName('_Phrase') ); break; - + case 'parentcategorylink': $m_var_list_update['cat'] = $this->Get('ParentId'); $m_var_list_update['p'] = 1; @@ -854,10 +855,10 @@ array_pop($ret); $ret = implode('>',$ret); } - + $ret = prompt_language($objConfig->Get("Root_Name")).($ret ? '>' : '').$ret; break; - + case "name": case "Name": /* @@ -870,7 +871,7 @@ /* @field:cat.description @description:Category Description - */ + */ $ret = ($this->Get("Description")); $ret = $this->HighlightText($ret); break; @@ -894,7 +895,7 @@ @attrib:_name::Return the image with this name @attrib:_thumbnail:bool:If true, return the thumbnail version of the image @attrib:_imagetag:bool:If true, returns a complete image tag. exta html attributes are passed to the image tag - */ + */ $default = $element->GetAttributeByName('_primary'); $name = $element->GetAttributeByName('_name'); if(strlen($name)) @@ -937,39 +938,39 @@ /* @field:cat.createdby @description:parse a user field of the user that created the category - @attrib:_usertag::User field to return (defaults to login ID) - */ + @attrib:_usertag::User field to return (defaults to login ID) + */ $field = $element->GetAttributeByName('_usertag'); if(!strlen($field)) { $field = "user_login"; } - - $userId = $this->Get("CreatedById"); + + $userId = $this->Get("CreatedById"); if (!empty($userId) && ($userId > 0)) { $u =& $objUsers->GetItem($userId); if (is_object($u)) - { - $ret = $u->parsetag($field); + { + $ret = $u->parsetag($field); } } else - $ret = " "; - + $ret = " "; + break; case "custom": /* @field:cat.custom @description:Returns a custom field @attrib:_customfield::field name to return @attrib:_default::default value - */ - $field = $element->GetAttributeByName('_customfield'); + */ + $field = $element->GetAttributeByName('_customfield'); $default = $element->GetAttributeByName('_default'); $ret = $this->GetCustomFieldValue($field,$default); break; - + case "catsubcats": /* @field:cat.catsubcats @@ -979,27 +980,27 @@ @attrib:_anchor:bool:Make an anchor (only if template is not specified) @attrib:_TargetTemplate:tpl:Target template @attrib:_Ending::Add special text at the end of subcategory list - @attrib:_Class::Specify stly sheet class for anchors (if used) or "span" object - */ - $limit = ((int)$element->attributes["_limit"]>0)? $element->attributes["_limit"] : NULL; + @attrib:_Class::Specify stly sheet class for anchors (if used) or "span" object + */ + $limit = ((int)$element->attributes["_limit"]>0)? $element->attributes["_limit"] : NULL; $separator = $element->attributes["_separator"]; - $anchor = (int)($element->attributes["_anchor"])? 1 : NULL; - $templ = $element->GetAttributeByName("_TargetTemplate"); - $template = !empty($templ)? $templ : NULL; + $anchor = (int)($element->attributes["_anchor"])? 1 : NULL; + $templ = $element->GetAttributeByName("_TargetTemplate"); + $template = !empty($templ)? $templ : NULL; $ending = strlen($element->attributes["_ending"])? $element->attributes["_ending"] : NULL; $class = strlen($element->attributes["_class"])? $element->attributes["_class"] : NULL; - + $ret = $this->GetSubCats($limit, $template, $separator, $anchor, $ending, $class); - + break; - + case "date": /* @field:cat.date @description:Returns the date/time the category was created @attrib:_tz:bool:Convert the date to the user's local time @attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr - */ + */ $d = $this->Get("CreatedOn"); if( $element->GetAttributeByName('_tz') ) @@ -1013,9 +1014,9 @@ $ret = ExtractDatePart($part,$d); } else - { + { if(!is_numeric($d)) - { + { $ret = ""; } else @@ -1026,20 +1027,20 @@ /* @field:cat.link @description:Returns a URL setting the category to the current category - @attrib:_template:tpl:Template URL should point to + @attrib:_template:tpl:Template URL should point to @attrib:_mod_template:tpl:Template INSIDE a module to which the category belongs URL should point to - */ - if ( strlen( $element->GetAttributeByName('_mod_template') ) ){ + */ + if ( strlen( $element->GetAttributeByName('_mod_template') ) ){ //will prefix the template with module template root path depending on category $ids = $this->GetParentIds(); $tpath = GetModuleArray("template"); $roots = GetModuleArray("rootcat"); - - // get template path of module, by searching for moudle name - // in this categories first parent category + + // get template path of module, by searching for moudle name + // in this categories first parent category // and then using found moudle name as a key for module template paths array $path = $tpath[array_search ($ids[0], $roots)]; - + $module_templates = explode(',', $element->GetAttributeByName('_mod_template')); $m_templates = Array(); foreach($module_templates as $module_t) @@ -1049,7 +1050,7 @@ { $m_templates[$module_t[0]] = $module_t[1]; } - else + else { $m_templates['default'] = $module_t[0]; } @@ -1061,20 +1062,20 @@ { $target_template = $m_templates[$module]; } - else + else { $target_template = $m_templates['default']; } $t = $path . $target_template; } - else + else { $t = $element->GetAttributeByName('_template'); - } - + } + $url_params = Array(); if(strlen($t)) - { + { $var_list_update["t"] = $t; } else @@ -1083,7 +1084,7 @@ } $m_var_list_update["cat"] = $this->Get("CategoryId"); if( $element->GetAttributeByName('reset') ) $url_params['reset'] = 1; - + $ret = HREF_Wrapper('', $url_params); unset($m_var_list_update["cat"], $var_list_update["t"]); break; @@ -1094,11 +1095,11 @@ unset($m_var_list_update["cat"]); unset($m_var_list_update["p"]); return $ret; - break; + break; case "customlink": $t = $this->GetCustomFieldValue("indextemplate",""); if(strlen($t)) - { + { $var_list_update["t"] = $t; } else @@ -1108,16 +1109,16 @@ $m_var_list_update["cat"] = $this->Get("CategoryId"); $ret = HREF_Wrapper(); unset($m_var_list_update["cat"], $var_list_update["t"]); - break; + break; case "link_selector": $m_var_list_update["cat"] = $this->Get("CategoryId"); $ret = $_SERVER["PHP_SELF"]."?env=" . BuildEnv(); - + $tmp = GetVar('Selector'); if($tmp) $ret .= '&Selector='.$tmp; $tmp = GetVar('new'); if($tmp) $ret .= '&new='.$tmp; $tmp = GetVar('destform'); if($tmp) $ret .= '&destform='.$tmp; - + unset($m_var_list_update["cat"]); return $ret; break; @@ -1132,14 +1133,14 @@ case "subcats": /* @field:cat.subcats - @description: Loads category's subcategories into a list and renders using the m_list_cats global tag + @description: Loads category's subcategories into a list and renders using the m_list_cats global tag @attrib:_subcattemplate:tpl:Template used to render subcategory list elements @attrib: _columns:int: Numver of columns to display the categories in (defaults to 1) @attrib: _maxlistcount:int: Maximum number of categories to list @attrib: _FirstItemTemplate:tpl: Template used for the first category listed - @attrib: _LastItemTemplate:tpl: Template used for the last category listed + @attrib: _LastItemTemplate:tpl: Template used for the last category listed @attrib: _NoTable:bool: If set to 1, the categories will not be listed in a table. If a table is used, all HTML attributes are passed to the TABLE tag - */ + */ $attr = array(); $attr["_catid"] = $this->Get("CategoryId"); $attr["_itemtemplate"] = $element->GetAttributeByName('_subcattemplate'); @@ -1156,8 +1157,8 @@ $txt = "Get("CategoryId")."\" _SubCats=\"1\" "; $txt .="_CategoryCount=\"1\" _ItemType=\"1\" _GroupOnly=\"$GroupOnly\" />"; $tag = new clsHtmlTag($txt); - $ret = $tag->Execute(); - break; + $ret = $tag->Execute(); + break; case "itemcount": /* @field:cat.itemcount @@ -1176,7 +1177,7 @@ $txt = "Get("CategoryId")."\" _SubCats=\"1\" "; $txt .=" _ListType=\"category\" _CountCurrent=\"1\" _ForceUpdate=\"$ForceUpdate\" _ItemType=\"$TypeId\" _GroupOnly=\"$GroupOnly\" />"; $tag = new clsHtmlTag($txt); - $ret = $tag->Execute(); + $ret = $tag->Execute(); //echo "Category parseobject: $ret
"; } else @@ -1190,11 +1191,11 @@ case "totalitems": /* @field:cat.totalitems - @description:returns the number of items in the category and all subcategories - */ - $ret = $this->ItemCount(); + @description:returns the number of items in the category and all subcategories + */ + $ret = $this->ItemCount(); break; - + case 'modified': $ret = ''; $date = $this->Get('Modified'); @@ -1214,14 +1215,14 @@ $ret = ($date <= 0) ? '' : LangDate($date); } break; - + case "itemdate": /* @field:cat.itemdate @description:Returns the date the cache count was last updated @attrib:_itemtype:Item name to check @attrib:_tz:bool:Convert the date to the user's local time - @attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr + @attrib:_part::Returns part of the date. The following options are available: month,day,year,time_24hr,time_12hr */ $typestr = $element->GetAttributeByName('_itemtype'); $type = $objItemTypes->GetTypeByName($typestr); @@ -1233,9 +1234,9 @@ { $date = $cc->Get("LastUpdate"); } - else + else $date = ""; - + //$date = $this->GetCacheCountDate($TypeId); if( $element->GetAttributeByName('_tz') ) { @@ -1264,8 +1265,8 @@ /* @field:cat.new @description:returns text if category's status is "new" - @attrib:_label:lang: Text to return if status is new - */ + @attrib:_label:lang: Text to return if status is new + */ if($this->IsNewItem()) { $ret = $element->GetAttributeByName('_label'); @@ -1280,8 +1281,8 @@ /* @field:cat.pick @description:returns text if article's status is "hot" - @attrib:_label:lang: Text to return if status is "hot" - */ + @attrib:_label:lang: Text to return if status is "hot" + */ if($this->Get("EditorsPick")==1) { $ret = $element->GetAttributeByName('_label'); @@ -1292,49 +1293,49 @@ else $ret = ""; break; - + case "parsetag": /* @field:cat.parsetag @description:returns a tag output with this categoriy set as a current category - @attrib:_tag:: tag name - */ - + @attrib:_tag:: tag name + */ + $tag = new clsHtmlTag(); $tag->name = $element->GetAttributeByName('_tag'); - $tag->attributes = $element->attributes; - $tag->attributes["_catid"] = $this->Get("CategoryId"); - $ret = $tag->Execute(); + $tag->attributes = $element->attributes; + $tag->attributes["_catid"] = $this->Get("CategoryId"); + $ret = $tag->Execute(); break; - - + + /* @field:cat.relevance @description:Displays the category relevance in search results @attrib:_displaymode:: How the relevance should be displayed
    -
  • "Numerical": Show the decimal value +
  • "Numerical": Show the decimal value
  • "Bar": Show the HTML representing the relevance. Returns two HTML cells ≶td< with specified background colors
  • "Graphical":Show image representing the relevance -
+ @attrib:_onimage::Zero relevance image shown in graphical display mode. Also used as prefix to build other images (i.e. prefix+"_"+percentage+".file_extension" @attrib:_OffBackGroundColor::Off background color of HTML cell in bar display mode - @attrib:_OnBackGroundColor::On background color of HTML cell in bar display mode - */ - + @attrib:_OnBackGroundColor::On background color of HTML cell in bar display mode + */ + } if( !isset($ret) ) $ret = parent::ParseObject($element); - + } return $ret; } function parsetag($tag) - { + { global $objConfig,$objUsers, $m_var_list, $m_var_list_update; if(is_object($tag)) - { + { $tagname = $tag->name; } else @@ -1344,10 +1345,10 @@ { case "cat_id": return $this->Get("CategoryId"); - break; + break; case "cat_parent": return $this->Get("ParentId"); - break; + break; case "cat_fullpath": return $this->Get("CachedNavbar"); break; @@ -1359,7 +1360,7 @@ break; case "cat_priority": if($this->Get("Priority")!=0) - { + { return (int)$this->Get("Priority"); } else @@ -1436,9 +1437,9 @@ $ret = "addcategory.php?env=" . BuildEnv(); unset($m_var_list_update["id"]); return $ret; - break; + break; - case "cat_date": + case "cat_date": return LangDate($this->Get("CreatedOn"), 0, true); break; case "cat_num_cats": @@ -1470,21 +1471,21 @@ $nav = ""; //echo "Rebuilding Navbar..
\n"; if(strlen($this->Get("ParentPath"))==0) - { + { $this->UpdateCachedPath(); } $cats = explode("|",substr($this->Get("ParentPath"),1,-1)); - + foreach($cats as $catid) - { + { $cat =& $objCatList->GetCategory($catid); if(is_object($cat)) - { + { if(strlen($cat->Get("Name"))) - $names[] = $cat->Get("Name"); - + $names[] = $cat->Get("Name"); + } - } + } $nav = implode(">", $names); $this->Set("CachedNavbar",$nav); $this->Update(); @@ -1506,7 +1507,7 @@ UpdateCategoryCount(0,$CatId); } }*/ - + /** * @return void * @param int $date @@ -1516,16 +1517,16 @@ { $parents = $this->Get('ParentPath'); if (!$parents) return false; - + $parents = substr($parents, 1, strlen($parents) - 2 ); $parents = explode('|', $parents); - + $db =&GetADODBConnection(); $sql = 'UPDATE '.$this->tablename.' SET Modified = '.$date.' WHERE CategoryId IN ('.implode(',', $parents).')'; $db->Execute($sql); } - - + + } class clsCatList extends clsItemList //clsItemCollection @@ -1556,14 +1557,14 @@ 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"; + $ptable = GetTablePrefix()."PermCache"; $VIEW = $objPermissions->GetPermId($PermName); - + $sql = "SELECT count(*) as CacheVal FROM $ltable "; $sql .="INNER JOIN $ptable ON ($ltable.CategoryId=$ptable.CategoryId) "; $sql .="WHERE ($acl AND PermId=$VIEW AND $ltable.Status=1) "; @@ -1573,7 +1574,7 @@ $sql .= "AND (".$AdditonalWhere.")"; } return $sql; - } + } function CountCategories($attribs) { @@ -1586,56 +1587,56 @@ } if((int)$cat>0) $c = $this->GetCategory($cat); - + if( getArrayValue($attribs,'_subcats') && $cat>0) { $ParentWhere = "(ParentPath LIKE '".$c->Get("ParentPath")."%' AND ".$this->SourceTable.".CategoryId != $cat)"; } if( getArrayValue($attribs,'_today') ) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - $TodayWhere = "(CreatedOn>=$today)"; + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $TodayWhere = "(CreatedOn>=$today)"; } else { $TodayWhere = ''; } if( getArrayValue($attribs,'_grouponly') ) { - $GroupList = $objSession->Get("GroupList"); + $GroupList = $objSession->Get("GroupList"); } - else + else $GroupList = NULL; - + $where = ""; if(strlen($ParentWhere)) { - $where = $ParentWhere; + $where = $ParentWhere; } if(strlen($TodayWhere)) { - if(strlen($where)) + if(strlen($where)) $where .=" AND "; $where .= $TodayWhere; } $sql = $this->GetCountSQL("CATEGORY.VIEW",$cat,$GroupList,$where); - + // echo "SQL: ".$sql."
"; - - $rs = $this->adodbConnection->Execute($sql); + + $rs = $this->adodbConnection->Execute($sql); if($rs && !$rs->EOF) { - $ret = $rs->fields["CacheVal"]; + $ret = $rs->fields["CacheVal"]; } else $ret = 0; - - return $ret; - } - + + return $ret; + } + function CurrentCategoryID() { - global $m_var_list; + global $m_var_list; return (int)$m_var_list["cat"]; } @@ -1660,63 +1661,63 @@ return $this->GetItemByField("ResourceId",$ResId); } - function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE) + function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE) { global $objSession; - + if($UseTableName) { $TableName = $this->SourceTable."."; } else - $TableName = ""; + $TableName = ""; $Orders = array(); - if($EditorsPick) + if($EditorsPick) { $Orders[] = $TableName."EditorsPick DESC"; } if($Priority) { - $Orders[] = $TableName."Priority DESC"; + $Orders[] = $TableName."Priority DESC"; } - + $FieldVar = "Category_Sortfield"; $OrderVar = "Category_Sortorder"; - + if(is_object($objSession)) { - if(strlen($objSession->GetPersistantVariable($FieldVar))>0) - { - $Orders[] = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". - $objSession->GetPersistantVariable($OrderVar)); + if(strlen($objSession->GetPersistantVariable($FieldVar))>0) + { + $Orders[] = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". + $objSession->GetPersistantVariable($OrderVar)); } } $FieldVar = "Category_Sortfield2"; $OrderVar = "Category_Sortorder2"; - + if(is_object($objSession)) { - if(strlen($objSession->GetPersistantVariable($FieldVar))>0) - { - $Orders[] = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". - $objSession->GetPersistantVariable($OrderVar)); + if(strlen($objSession->GetPersistantVariable($FieldVar))>0) + { + $Orders[] = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". + $objSession->GetPersistantVariable($OrderVar)); } } - - + + if(count($Orders)>0) { $OrderBy = "ORDER BY ".implode(", ",$Orders); } - else + else $OrderBy=""; - return $OrderBy; + return $OrderBy; } - + function LoadCategories($where="", $orderBy = "", $no_limit = true, $fix_method = 'set_first') { // load category list using $where clause @@ -1725,7 +1726,7 @@ // in case if stored page is greather then page count issue page_fixing with // method specified (see "FixInvalidPage" method for details) $PerPage = $this->GetPerPage(); - + $this->QueryItemCount = TableCount($this->SourceTable,$where,0); if($no_limit == false) { @@ -1734,13 +1735,13 @@ $limit = "LIMIT ".$Start.",".$PerPage; } else - $limit = NULL; - + $limit = NULL; + return $this->Query_Category($where, $orderBy, $limit); } function Query_Category($whereClause="",$orderByClause="",$limit=NULL) - { + { global $m_var_list, $objSession, $Errors, $objPermissions; $GroupID = $objSession->Get("GroupID"); $resultset = array(); @@ -1749,11 +1750,11 @@ $ptable = GetTablePrefix()."PermCache"; $CAT_VIEW = $objPermissions->GetPermId("CATEGORY.VIEW"); if(!$objSession->HasSystemPermission("ADMIN")) - { + { $sql = "SELECT * FROM $table INNER JOIN $ptable ON ($ptable.CategoryId=$table.CategoryId)"; - $acl_where = $objSession->GetACLClause(); + $acl_where = $objSession->GetACLClause(); if(strlen($whereClause)) - { + { $sql .= " WHERE ($acl_where) AND PermId=$CAT_VIEW AND ".$whereClause; } else @@ -1772,7 +1773,7 @@ //echo "SQL: $sql
"; return $this->Query_item($sql); } - + function CountPending() { return TableCount($this->SourceTable,"Status=".STATUS_PENDING,0); @@ -1786,7 +1787,7 @@ $PerPage = $this->GetPerPage(); $NumPages = ceil( $this->GetNumPages($PerPage) ); - + if($NumPages == 1 && $HideEmpty) return ''; if(strlen($dest_template)) @@ -1844,11 +1845,11 @@ unset($m_var_list_update,$var_list_update["t"] ); return $o; } - + function GetAdminPageLinkList($url) { global $objConfig, $m_var_list_update, $var_list_update, $var_list; - + $PerPage = $this->GetPerPage(); $NumPages = ceil($this->GetNumPages($PerPage)); $o = ""; @@ -1880,29 +1881,29 @@ else $o .= "$p"; } - + if($this->Page < $NumPages) $o .= ">>"; - return $o; + return $o; } function Search_Category($orderByClause) { - global $objSession, $objConfig, $Errors; + global $objSession, $objConfig, $Errors; $PerPage = $this->GetPerPage(); $Start = ($this->Page-1) * $PerPage; $objResults = new clsSearchResults("Category","clsCategory"); $this->Clear(); $this->Categories = $objResults->LoadSearchResults($Start,$PerPage); - + return $this->Categories; } function GetSubCats($ParentCat) - { + { return $this->Query_Category("ParentId=".$ParentCat,""); } @@ -1931,7 +1932,7 @@ } function cat_navbar($admin=0, $cat, $target_template, $separator = " > ", $LinkLeaf = FALSE, - $root = 0,$RootTemplate="",$modcat=0, $ModTemplate="", $LinkRoot = FALSE) + $root = 0,$RootTemplate="",$modcat=0, $ModTemplate="", $LinkRoot = FALSE) { // draw category navigation bar (at top) global $Errors, $var_list_update, $var_list, $m_var_list_update, $m_var_list, $objConfig; @@ -1941,13 +1942,13 @@ if( GetVar('new') ) $url_params['new'] = GetVar('new'); if( GetVar('destform') ) $url_params['destform'] = GetVar('destform'); if( GetVar('destfield') ) $url_params['destfield'] = GetVar('destfield'); - + $nav = ""; - $m_var_list_update["p"]=1; + $m_var_list_update["p"]=1; if(strlen($target_template)==0) $target_template = $var_list["t"]; - - + + if($cat == 0) { $cat_name = language($objConfig->Get("Root_Name")); @@ -1962,15 +1963,15 @@ { $nav = array(); $c =& $this->GetCategory($cat); - $nav_unparsed = $c->Get("ParentPath"); + $nav_unparsed = $c->Get("ParentPath"); if(strlen($nav_unparsed)==0) - { + { $c->UpdateCachedPath(); $nav_unparsed = $c->Get("ParentPath"); } //echo " Before $nav_unparsed "; if($root) - { + { $r =& $this->GetCategory($root); $rpath = $r->Get("ParentPath"); $nav_unparsed = substr($nav_unparsed,strlen($rpath),-1); @@ -1981,8 +1982,8 @@ $nav[] = "".$cat_name.""; //href=\"browse.php?env=". BuildEnv() ."\" } else - { - if ($admin == 1) + { + if ($admin == 1) { $nav[] = "".$cat_name.""; } @@ -2001,7 +2002,7 @@ } } else - { + { $nav_unparsed = substr($nav_unparsed,1,-1); $cat_name = language($objConfig->Get("Root_Name")); $m_var_list_update["cat"] = 0; @@ -2010,8 +2011,8 @@ $nav[] = "".$cat_name.""; //href=\"browse.php?env=". BuildEnv() ."\" } else - { - if ($admin == 1) + { + if ($admin == 1) { $nav[] = "".$cat_name.""; } @@ -2026,36 +2027,36 @@ $nav[] = "".$cat_name.""; } } - + } //echo " After $nav_unparsed
\n"; if(strlen($target_template)==0) - $target_template = $var_list["t"]; - + $target_template = $var_list["t"]; + $cats = explode("|", $nav_unparsed); foreach($cats as $catid) { if($catid) - { + { $c =& $this->GetCategory($catid); if(is_object($c)) - { + { $cat_name = $c->Get("Name"); - + $m_var_list_update["cat"] = $catid; if($catid==$modcat && strlen($ModTemplate)>0) { $t = $ModTemplate; } - else + else $t = $target_template; if($cat == $catid && !$LinkLeaf) { $nav[] = "".$cat_name.""; } else - { - if ($admin == 1) + { + if ($admin == 1) { $nav[] = "".$cat_name.""; } @@ -2066,17 +2067,17 @@ unset($var_list_update["t"]); } } - unset($m_var_list_update["cat"]); + unset($m_var_list_update["cat"]); } - } + } } $nav = implode($separator, $nav); } return $nav; } - function &Add_NEW($fields_hash) + function &Add_NEW($fields_hash, $from_import = false) { global $objSession; @@ -2096,21 +2097,24 @@ } $d->Create(); - if ($d->Get('Status') == STATUS_ACTIVE) { - $d->SendUserEventMail("CATEGORY.ADD", $objSession->Get("PortalUserId")); - $d->SendAdminEventMail("CATEGORY.ADD"); + + if (!$from_import) { + if ($d->Get('Status') == STATUS_ACTIVE) { + $d->SendUserEventMail("CATEGORY.ADD", $objSession->Get("PortalUserId")); + $d->SendAdminEventMail("CATEGORY.ADD"); + } + else + { + $d->SendUserEventMail("CATEGORY.ADD.PENDING", $objSession->Get("PortalUserId")); + $d->SendAdminEventMail("CATEGORY.ADD.PENDING"); + } + $d->UpdateCachedPath(); } - else - { - $d->SendUserEventMail("CATEGORY.ADD.PENDING", $objSession->Get("PortalUserId")); - $d->SendAdminEventMail("CATEGORY.ADD.PENDING"); - } - $d->UpdateCachedPath(); return $d; } function &Add( $ParentId, $Name, $Description, $CreatedOn, $EditorsPick, $Status, $Hot, $New, $Pop, - $Priority, $MetaKeywords,$MetaDesc, $auto_filename = 1, $filename = '') + $Priority, $MetaKeywords,$MetaDesc, $auto_filename = 1, $filename = '') { global $objSession; @@ -2119,13 +2123,13 @@ $d = new clsCategory(NULL); $filename = $d->StripDisallowed($filename); $d->tablename = $this->SourceTable; - + if( $d->UsingTempTable() ) $d->Set('CategoryId', -1); $d->idfield = 'CategoryId'; - - $d->Set(Array( 'ParentId', 'Name', 'Description', 'CreatedOn', 'EditorsPick', 'Status', 'HotItem', + + $d->Set(Array( 'ParentId', 'Name', 'Description', 'CreatedOn', 'EditorsPick', 'Status', 'HotItem', 'NewItem','PopItem', 'Priority', 'MetaKeywords', 'MetaDescription', 'CreatedById', - 'AutomaticFilename', 'Filename'), + 'AutomaticFilename', 'Filename'), Array( $ParentId, $Name, $Description, $CreatedOn, $EditorsPick, $Status, $Hot, $New, $Pop, $Priority, $MetaKeywords,$MetaDesc, $UserId, $auto_filename, $filename) ); @@ -2163,19 +2167,19 @@ function Move_Category($Id, $ParentTo) { global $objCatList; - + $d =& $this->GetCategory($Id); - $oldparent = $d->Get("ParentId"); + $oldparent = $d->Get("ParentId"); $ChildList = $d->GetSubCatIds(); - + /* echo "Target Parent Id: $ParentTo
\n"; echo "
";print_r($ChildList); echo "
"; echo "Old Parent: $oldparent
\n"; echo "ID: $Id
\n"; */ /* sanity checks */ - + if(!in_array($ParentTo,$ChildList) && $oldparent != $ParentTo && $oldparent != $Id && $Id != $ParentTo) { @@ -2186,15 +2190,15 @@ RunUp($oldparent, "Decrement_Count"); RunUp($ParentTo, "Increment_Count"); RunDown($ParentTo, "UpdateCachedPath"); - return TRUE; + return TRUE; } - else + else { global $Errors; $Errors->AddAdminUserError("la_error_move_subcategory"); return FALSE; - } - die(); + } + die(); } function Copy_CategoryTree($Id, $ParentTo) @@ -2210,7 +2214,7 @@ if ($result && !$result->EOF) { while(!$result->EOF) - { + { $this->Copy_CategoryTree($result->fields["CategoryId"], $new); $result->MoveNext(); } @@ -2220,19 +2224,19 @@ } function Copy_Category($Id, $ParentTo) - { + { global $objGroups; - + $src = $this->GetCategory($Id); $Children = $src->GetSubCatIds(); if($Id==$ParentTo || in_array($ParentTo,$Children)) { /* sanity error here */ global $Errors; - $Errors->AddAdminUserError("la_error_copy_subcategory"); + $Errors->AddAdminUserError("la_error_copy_subcategory"); return 0; - } + } $dest = $src; $dest->Set("ParentId", $ParentTo); if ($src->get("ParentId") == $ParentTo) @@ -2251,20 +2255,20 @@ $Name = $parts[2]." ".$parts[3]; } else - $Name = $OldName; + $Name = $OldName; } else - $Name = $OldName; + $Name = $OldName; //echo "New Name: $Name
"; - $dest->Set("Name", $Name); - $Names = CategoryNameCount($ParentTo,$Name); + $dest->Set("Name", $Name); + $Names = CategoryNameCount($ParentTo,$Name); //echo "Names Count: ".count($Names)."
"; if(count($Names)>0) - { + { $NameCount = count($Names); $found = FALSE; $NewName = "Copy of $Name"; - + if(!in_array($NewName,$Names)) { //echo "Matched on $NewName in:
\n"; @@ -2281,55 +2285,55 @@ $found = TRUE; break; } - + } - } + } if(!$found) { $NameCount++; $NewName = "Copy $NameCount of $Name"; - } + } //echo "New Name: $NewName
"; - $dest->Set("Name",$NewName); + $dest->Set("Name",$NewName); } - + } $dest->UnsetIdField(); $dest->Set("CachedDescendantCatsQty",0); $dest->Set("ResourceId",NULL); $dest->Set('Filename', ''); - $dest->Create(); - $dest->UpdateCachedPath(); + $dest->Create(); + $dest->UpdateCachedPath(); $p = new clsPermList(); - $p->Copy_Permissions($src->Get("CategoryId"),$dest->Get("CategoryId")); + $p->Copy_Permissions($src->Get("CategoryId"),$dest->Get("CategoryId")); $glist = $objGroups->GetAllGroupList(); $view = $p->GetGroupPermList($dest, "CATEGORY.VIEW", $glist); $dest->SetViewPerms("CATEGORY.VIEW",$view,$glist); RunUp($ParentTo, "Increment_Count"); - return $dest->Get("CategoryId"); + return $dest->Get("CategoryId"); } function Delete_Category($Id) { global $objSession; $d =& $this->GetCategory($Id); - + if(is_object($d)) - { + { if($d->Get("CategoryId")==$Id) - { + { $d->SendUserEventMail("CATEGORY.DELETE",$objSession->Get("PortalUserId")); $d->SendAdminEventMail("CATEGORY.DELETE"); - $p =& $this->GetCategory($d->Get("ParentId")); + $p =& $this->GetCategory($d->Get("ParentId")); RunDown($d->Get("CategoryId"), "Delete"); - RunUp($p->Get("CategoryId"), "Decrement_Count"); + RunUp($p->Get("CategoryId"), "Decrement_Count"); RunUp($d->Get("CategoryId"),"ClearCacheData"); } } } - + function PasteFromClipboard($TargetCat) { global $objSession; @@ -2342,17 +2346,17 @@ $item_ids = explode(",",$ClipBoard["ids"]); for($i=0;$iGetItem($item_ids[$i]); if(!$IsCopy) - { - $this->Move_Category($ItemId, $TargetCat); + { + $this->Move_Category($ItemId, $TargetCat); $clip = str_replace("CUT","COPY",$clip); $objSession->SetVariable("ClipBoard",$clip); } else - { + { $this->Copy_CategoryTree($ItemId,$TargetCat); } } @@ -2361,7 +2365,7 @@ function NumChildren($ParentID) - { + { $cat_filter = "m_cat_filter"; global $$cat_filter; @@ -2393,9 +2397,9 @@ $c->SetFromArray($data); $c->UpdateCachedPath(); $rs->MoveNext(); - } + } } - + function CopyFromEditTable($idfield) { global $objGroups, $objSession, $objPermList; @@ -2410,11 +2414,11 @@ { $data = $rs->fields; $c = new $this->classname; - $c->SetFromArray($data); - $c->Dirty(); - + $c->SetFromArray($data); + $c->Dirty(); + if($c->Get("CategoryId")>0) - { + { $c->Update(); } else @@ -2424,13 +2428,13 @@ $sql = "UPDATE ".GetTablePrefix()."Permissions SET CatId=".$c->Get("CategoryId")." WHERE CatId=-1"; $this->adodbConnection->Execute($sql); } - $c->UpdateCachedPath(); + $c->UpdateCachedPath(); $c->UpdateACL(); $c->SendUserEventMail("CATEGORY.MODIFY",$objSession->Get("PortalUserId")); $c->SendAdminEventMail("CATEGORY.MODIFY"); $c->Related = new clsRelationshipList(); if(is_object($c->Related)) - { + { $r = $c->Related; $r->CopyFromEditTable($c->Get("ResourceId")); } @@ -2445,8 +2449,8 @@ unset($GLOBALS['_CopyFromEditTable']); return $item_ids; //$this->UpdateMissingCacheData(); - } - + } + function PurgeEditTable($idfield) { parent::PurgeEditTable($idfield); @@ -2472,65 +2476,65 @@ $p = substr($path,0,strlen($rpath)); //echo $rpath." vs. .$p [$path]
\n"; if($rpath==$p) - { + { $itemtype = $Type; break; } - } + } } return $itemtype; } } function RunUp($Id, $function, $Param=NULL) -{ +{ global $objCatList; $d = $objCatList->GetCategory($Id); $ParentId = $d->Get("ParentId"); if ($ParentId == 0) { if($Param == NULL) - { + { $d->$function(); } else - { + { $d->$function($Param); } } else { RunUp($ParentId, $function, $Param); if($Param == NULL) - { + { $d->$function(); } else - { + { $d->$function($Param); } } - + } function RunDown($Id, $function, $Param=NULL) { global $objCatList; - $adodbConnection = &GetADODBConnection(); + $adodbConnection = &GetADODBConnection(); $sql = "select CategoryId from ".GetTablePrefix()."Category where ParentId='$Id'"; $rs = $adodbConnection->Execute($sql); - - while($rs && !$rs->EOF) - { - RunDown($rs->fields["CategoryId"], $function, $Param); + + while($rs && !$rs->EOF) + { + RunDown($rs->fields["CategoryId"], $function, $Param); $rs->MoveNext(); } $d = $objCatList->GetCategory($Id); if($Param == NULL) - { + { $d->$function(); } else