Validate()) return false; $this->SetDBField('ResourceId', $this->Application->NextResourceId()); $this->SetDBField('CreatedById', $this->Application->GetVar('u_id') ); $this->SetDBField('CreatedOn_date', time() ); $this->SetDBField('CreatedOn_time', time() ); $this->SetDBField('ParentId', $this->Application->GetVar('m_cat_id') ); $ret = parent::Create(); if($ret) { $sql = 'UPDATE %s SET ParentPath = %s WHERE CategoryId = %s'; $parent_path = $this->buildParentPath(); $this->Conn->Query( sprintf($sql, $this->TableName, $this->Conn->qstr($parent_path), $this->GetID() ) ); $this->SetDBField('ParentPath', $parent_path); } return $ret; } function buildParentPath() { $parent_id = $this->GetDBField('ParentId'); $cat_table = $this->Application->getUnitOption($this->Prefix, 'TableName'); $sql = 'SELECT ParentPath FROM '.$cat_table.' WHERE CategoryId = %s'; $parent_path = $this->Conn->GetOne( sprintf($sql, $parent_id) ); if(!$parent_path) $parent_path = '|'.$parent_id.'|'; return $parent_path.$this->GetID().'|'; } } ?>