_tableName_ = 'categories'; parent::__construct($fromArray); $this->setRelation('points', 'id', 'Point', 'categoryId', self::TO_MANY); } static function model() { return new self(); } static function getIcoById($id) { if (self::$categories === NULL) { self::$categories = self::model()->getAll(array('asArray'=>true)); } return (isset(self::$categories[$id])) ? self::$categories[$id]['icon'] : NULL; } public function getCategoriesForChoise() { if (App::$user && App::$user->isAdmin == 1) { return $this->getAll(array('order' => 'ord ASC', 'asArray' => true)); } else { return $this->getAll(array('where' => '`id` NOT IN ('. implode(',', self::$paidIds).')', 'order' => 'ord ASC', 'asArray' => true)); } } public static function isPaidCategory($id) { return array_search($id, self::$paidIds) !== FALSE; } }