* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $ */ class Event extends BaseEvent { const LOGO_SRC_PATH = '/uploads/event-logo'; const WIDTH = 500; const HEIGHT = 500; const MIMETYPE = 'image/jpeg'; static public function getLogoCommonPath() { return sfConfig::get('sf_upload_dir').DIRECTORY_SEPARATOR.'event-logo'.DIRECTORY_SEPARATOR; } public function getLogoSrc($absolute = false) { $src = self::LOGO_SRC_PATH.'/'.$this->getLogo(); // if($absolute) // { // $src = Shopty::getHostForCulture().$src; // } return $src; } public function getLogoPath() { return self::getLogoCommonPath().$this->getLogo(); } public function hasLogo() { return strlen($this->getLogo()) && file_exists($this->getLogoPath()); } public function hasPermissions($user) { return $user->isSuperAdmin() || ($user->isAuthenticated() && $user->getProfile()->getId() == $this->getProfileId()); } public function getShortText() { return substr($this->getText(), 0, 200); } public function getCategoriesNames() { $result = array(); foreach($this->getCategories() as $category) { $result[] = $category->getName(); } return implode(', ', $result); } public function hasCategory($category) { return Doctrine::getTable('EventCategoryRelation')->createQuery() ->addWhere('event_id = ?', $this->getId()) ->addwhere('category_id = ?', $category->getId()) ->count() > 0; } }