public function ExeDelete($CategoryId) { $this->CatId = (int) $CategoryId; $WsCategories = new WsCategories(); $WsCategories->setCategory_id($this->CatId); $WsCategories->Query("WHERE #category_id#"); if (!$WsCategories->getResult()) { $this->Result = false; $this->Error = ['Oppsss, você tentou remover uma categoria que não existe no sistema!', WS_INFOR]; } else { extract((array) $WsCategories->getResult()[0]); if (!$category_parent && !$this->checkCats()) { $this->Result = false; $this->Error = ["A <b>seção {$category_title}</b> possui categorias cadastradas. Para deletar, antes altere ou remova todas as categorias filhas!", WS_ALERT]; } elseif ($category_parent && !$this->checkPosts()) { $this->Result = false; $this->Error = ["A <b>categoria {$category_title}</b> possui artigos cadastradas. Para deletar, antes altere ou remova todos os postes desta categoria!", WS_ALERT]; } else { $this->Result = true; $tipo = empty($category_parent) ? 'seção' : 'categoria'; $WsCategories->setCategory_id($this->CatId); $WsCategories->delete(); $this->Error = ["A <b>{$tipo} {$category_title}</b> foi removida com sucesso do sistema!", WS_ACCEPT]; } } }