//item() ); } /** * Syncing to run when hiding * * @return void */ public function onHide() { parent::onHide(); static::recordSync( $this->item() ); } /** * Syncing to run when unhiding * * @param bool $approving If true, is being approved for the first time * @return void */ public function onUnhide( $approving ) { parent::onUnhide( $approving ); static::recordSync( $this->item() ); } /** * Sync up the topic * * @param \IPS\forums\Topic $item Topic object * * @return void */ protected static function recordSync( $item ) { $synced = array(); foreach( \IPS\Db::i()->select( '*', 'cms_database_categories', array( 'category_forum_record=? AND category_forum_forum=? AND category_forum_comments=?', 1, $item->forum_id, 1 ) ) as $category ) { try { $synced[] = $category['category_database_id']; $class = '\IPS\cms\Records' . $category['category_database_id']; $class::load( $item->tid, 'record_topicid' )->syncRecordFromTopic( $item ); } catch( \Exception $ex ) { } } foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_forum_record=? AND database_forum_forum=? AND database_forum_comments=?', 1, $item->forum_id, 1 ) ) as $database ) { try { if ( ! in_array( $database['database_id'], $synced ) ) { $class = '\IPS\cms\Records' . $database['database_id']; $class::load( $item->tid, 'record_topicid' )->syncRecordFromTopic( $item ); } } catch( \Exception $ex ) { } } } }