/** * @param null|self $object * @return self|bool */ public function copy( $object = null ) { global $_CB_framework, $_PLUGINS; if ( $object === null ) { $object = clone $this; } $old = new self(); $old->load( (int) $object->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeCopyCategory', array( &$object, $old ) ); $copy = parent::copy( $object ); if ( ! $copy ) { return false; } // Copy the groups in this category: $query = 'SELECT *' . "\n FROM " . $this->getDbo()->NameQuote( '#__groupjive_groups' ) . "\n WHERE " . $this->getDbo()->NameQuote( 'category' ) . " = " . (int) $old->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->set( 'category', (int) $object->get( 'id' ) ); $group->copy(); } // Copy the canvas and logo: if ( $object->get( 'canvas' ) || $object->get( 'logo' ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/plug_cbgroupjive'; $oldPath = $basePath . '/' . (int) $old->get( 'id' ); $newPath = $basePath . '/' . (int) $object->get( 'id' ); if ( is_dir( $oldPath ) ) { CBGroupJive::createDirectory( $basePath, $object->get( 'id' ) ); CBGroupJive::copyDirectory( $oldPath, $newPath ); } } $_PLUGINS->trigger( 'gj_onAfterCopyCategory', array( $object, $old ) ); return $copy; }
/** * @param null|self $object * @return self|bool */ public function copy( $object = null ) { global $_CB_framework, $_PLUGINS; if ( $object === null ) { $object = clone $this; } $old = new self(); $old->load( (int) $object->get( 'id' ) ); $_PLUGINS->trigger( 'gj_onBeforeCopyGroup', array( &$object, $old ) ); $copy = parent::copy( $object ); if ( ! $copy ) { return false; } // Copy the canvas and logo: if ( $object->get( 'canvas' ) || $object->get( 'logo' ) ) { $basePath = $_CB_framework->getCfg( 'absolute_path' ) . '/images/comprofiler/plug_cbgroupjive'; $oldPath = $basePath . '/' . (int) $old->get( 'category' ) . '/' . (int) $old->get( 'id' ); $newPath = $basePath . '/' . (int) $object->get( 'category' ) . '/' . (int) $object->get( 'id' ); if ( is_dir( $oldPath ) ) { CBGroupJive::createDirectory( $basePath, $object->get( 'category' ), $object->get( 'id' ) ); CBGroupJive::copyDirectory( $oldPath, $newPath ); } } $_PLUGINS->trigger( 'gj_onAfterCopyGroup', array( $object, $old ) ); return $copy; }