/** * @param null|int $id * @return bool */ public function delete( $id = null ) { global $_CB_framework, $_PLUGINS; $_PLUGINS->trigger( 'gj_onBeforeDeleteCategory', array( &$this ) ); if ( ! parent::delete( $id ) ) { return false; } // Delete groups in this category: $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__groupjive_groups' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'category' ) . " = " . (int) $this->get( 'id' ); $this->getDbo()->setQuery( $query ); $groups = $this->getDbo()->loadObjectList( null, '\CB\Plugin\GroupJive\Table\GroupTable', array( $this->getDbo() ) ); /** @var GroupTable[] $groups */ foreach ( $groups as $group ) { $group->delete(); } // Delete canvas and logo: if ( $this->get( 'canvas' ) || $this->get( 'logo' ) ) { CBGroupJive::deleteDirectory( $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/plug_cbgroupjive/' . (int) $this->get( 'id' ) ); } $_PLUGINS->trigger( 'gj_onAfterDeleteCategory', array( $this ) ); return true; }
/** * delete the local photos and the directory when a category is deleted * * @param CategoryTable $category */ public function deleteCategory( $category ) { global $_CB_framework; CBGroupJive::deleteDirectory( $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivephoto/' . (int) $category->get( 'id' ) ); }
/** * delete all the files for the group that was deleted * * @param GroupTable $group */ public function deleteGroup( $group ) { global $_CB_framework, $_CB_database; $query = 'SELECT *' . "\n FROM " . $_CB_database->NameQuote( '#__groupjive_plugin_file' ) . "\n WHERE " . $_CB_database->NameQuote( 'group' ) . " = " . (int) $group->get( 'id' ); $_CB_database->setQuery( $query ); $files = $_CB_database->loadObjectList( null, '\CB\Plugin\GroupJiveFile\Table\FileTable', array( $_CB_database ) ); /** @var FileTable[] $files */ foreach ( $files as $file ) { $file->delete(); } CBGroupJive::deleteDirectory( $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/cbgroupjivefile/' . (int) $group->get( 'category' ) . '/' . (int) $group->get( 'id' ) ); }