private function internalGetChildRoles($data) { $manager = BaseManager::build('FelixOnline\\Core\\Role', 'roles'); if (is_int($parentId)) { $manager->filter("parent = %i", array($data)); } else { $manager->filter("parent IN (%q)", array($data)); } $values = $manager->values(); if (!$values) { return array(); } $children = array(); $newIds = array(); foreach ($values as $value) { $children[] = $value; $newIds[] = $value->getId(); } $newIds = array_unique($newIds); $moreChildren = $this->internalGetChildRoles($newIds); if ($moreChildren) { $children = array_merge($moreChildren, $children); } return $children; }
public function enablePublishedFilter() { $publishedManager = BaseManager::build('\\FelixOnline\\Core\\ArticlePublication', 'article_publication'); $publishedManager = $publishedManager->filter('republished = 0')->filter('publication_date <= NOW()'); $this->join($publishedManager, 'LEFT', 'id', 'article'); $this->order(array('article_publication.publication_date', 'id'), 'DESC'); return $this; }
/** * Get date that the last article was posted */ function getEndDate() { $topic = BaseManager::build('FelixOnline\\Core\\Topic', 'article_topic', 'topic')->filter('topic = "%s"', array($this->getSlug())); $article = BaseManager::build('FelixOnline\\Core\\Article', 'article', 'id')->join($topic, 'LEFT', 'id', 'article')->filter('published > 0')->order('published', 'DESC')->limit(0, 1)->values(); if (!$article) { throw new \FelixOnline\Exceptions\InternalException('No articles posted in this topic'); } return $article[0]->getPublished(); }
function getAll() { $articles = $this->order('sort_order', 'ASC'); $articleManager = BaseManager::build('FelixOnline\\Core\\Article', 'article'); $categoryManager = BaseManager::build('FelixOnline\\Core\\Category', 'category'); $app = App::getInstance(); $currentuser = $app['currentuser']; $articleManager->join($categoryManager, null, 'category'); $articles->join($articleManager, null, 'article'); $articles = $articles->values(); return $articles; }
public static function isEmailValidated($email) { $manager = BaseManager::build('FelixOnline\\Core\\EmailValidation', 'email_validation'); $manager->filter('email = "%s"', array($email)); $count = $manager->count(); if ($count > 1) { throw new FelixOnline\Exceptions\InternalException('Too many email validation records found'); } if ($count == 0) { return false; } $record = $manager->one(); return $record->getConfirmed(); }
public static function randomPick($on = 'frontpage', $sidebar = 0, $category = null) { if ($on != 'frontpage' && $on != 'categories' && $on != 'articles') { throw new \FelixOnline\Exceptions\InternalException('Trying to find advert on invalid on type'); } $ads = BaseManager::build('FelixOnline\\Core\\Advert', 'advert')->filter('max_impressions > views')->filter('start_date < NOW()')->filter('end_date > NOW()')->filter($on . ' = 1')->filter('sidebar = %i', array((bool) $sidebar))->randomise()->limit(0, 1); if ($category) { $second = BaseManager::build('FelixOnline\\Core\\AdvertCategory', 'advert_category')->filter('category = ' . $category->getId(), array(), array(array('category IS NULL', array()))); $ads->join($second, 'LEFT OUTER', null, 'advert'); } else { $second = BaseManager::build('FelixOnline\\Core\\AdvertCategory', 'advert_category')->filter('category IS NULL'); $ads->join($second, 'LEFT OUTER', null, 'advert'); } $ads = $ads->values(); if ($ads) { $ads = $ads[0]; } else { return false; } return $ads; }
public function getValidatedReplyManager() { $comments = (new CommentManager())->filter("active = 1")->filter("spam = 0 ")->filter("reply = %i", array($this->getId()))->order("timestamp", "ASC"); $validation = BaseManager::build('FelixOnline\\Core\\EmailValidation', 'email_validation')->filter("confirmed = 1"); $comments->join($validation, null, 'email', 'email'); return $comments; }
public function getSpecificFile($part) { $manager = BaseManager::build('FelixOnline\\Core\\ArchiveFile', 'archive_file'); return $manager->filter('issue_id = %i', array($this->getId()))->filter('part = "%s"', array($part))->one(); }
/** * Public: Get categories this user edits * * Returns array of category objects */ public function getCategories() { $editors = BaseManager::build('FelixOnline\\Core\\Category', 'category_author', 'category')->filter("user = '******'", array($this->getUser()))->values(); return $editors; }
/** * Static: Get all categories */ public static function getCategories() { $app = App::getInstance(); $manager = BaseManager::build('FelixOnline\\Core\\Category', 'category'); try { $values = $manager->filter('hidden = 0')->filter('deleted = 0')->filter('id > 0')->order('order', 'ASC')->values(); return $values; } catch (\Exception $e) { return array(); } }