/** * Returns an instance of class. * * @return VIDEO_BOL_ClipFeaturedDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
/** * Deletes video clip * * @param int $id * @return int */ public function deleteClip($id) { $this->clipDao->deleteById($id); BOL_CommentService::getInstance()->deleteEntityComments('video_comments', $id); BOL_RateService::getInstance()->deleteEntityRates($id, 'video_rates'); BOL_TagService::getInstance()->deleteEntityTags($id, 'video'); $this->clipFeaturedDao->markUnfeatured($id); BOL_FlagService::getInstance()->deleteByTypeAndEntityId('video_clip', $id); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => 'video_comments', 'entityId' => $id))); $this->cleanListCache(); $event = new OW_Event(self::EVENT_AFTER_DELETE, array('clipId' => $id)); OW::getEventManager()->trigger($event); return true; }
/** * Deletes video clip * * @param int $id * @return int */ public function deleteClip($id) { $event = new OW_Event(self::EVENT_BEFORE_DELETE, array('clipId' => $id)); OW::getEventManager()->trigger($event); $this->clipDao->deleteById($id); BOL_CommentService::getInstance()->deleteEntityComments(self::ENTITY_TYPE, $id); BOL_RateService::getInstance()->deleteEntityRates($id, self::RATES_ENTITY_TYPE); BOL_TagService::getInstance()->deleteEntityTags($id, self::TAGS_ENTITY_TYPE); $this->clipFeaturedDao->markUnfeatured($id); BOL_FlagService::getInstance()->deleteByTypeAndEntityId(VIDEO_CLASS_ContentProvider::ENTITY_TYPE, $id); OW::getEventManager()->trigger(new OW_Event('feed.delete_item', array('entityType' => self::FEED_ENTITY_TYPE, 'entityId' => $id))); $this->cleanListCache(); $event = new OW_Event(self::EVENT_AFTER_DELETE, array('clipId' => $id)); OW::getEventManager()->trigger($event); return true; }
/** * Counts clips * * @param string $listtype * @return int */ public function countClips($listtype, $plugin = 'video') { switch ($listtype) { case 'featured': $featuredDao = VIDEO_BOL_ClipFeaturedDao::getInstance(); $query = "\n SELECT COUNT(`c`.`id`) \n FROM `" . $this->getTableName() . "` AS `c`\n LEFT JOIN `" . $featuredDao->getTableName() . "` AS `f` ON ( `c`.`id` = `f`.`clipId` )\n WHERE `c`.`status` = 'approved' AND `c`.`privacy` = 'everybody' AND `f`.`id` IS NOT NULL\n AND `c`.`plugin` = '" . $plugin . "'\n "; return $this->dbo->queryForColumn($query); break; case 'latest': $example = new OW_Example(); $example->andFieldEqual('status', 'approved'); $example->andFieldEqual('privacy', 'everybody'); $example->andFieldEqual('plugin', $plugin); return $this->countByExample($example); break; } return null; }
/** * Class constructor * */ private function __construct() { $this->clipFeaturedDao = VIDEO_BOL_ClipFeaturedDao::getInstance(); }