/** * Load topic by bound model * * @static * @param Model $bind_model Bound model * @param string $bind_name Bind config if multiple binds per model * @return Model_Forum_Topic */ public static function find_by_bind(Model $bind_model, $bind_name = null) { $model = Model::model_name($bind_model); // Get correct bind config if (!$bind_name) { foreach (Model_Forum_Area::get_binds(false) as $bind_name => $bind_config) { if ($bind_config['model'] == $model) { $config = $bind_config; break; } } } else { $config = Model_Forum_Area::get_binds($bind_name); } if ($config) { // Get area $area = Model_Forum_Area::factory(); $area = $area->load(DB::select_array($area->fields())->where('area_type', '=', Model_Forum_Area::TYPE_BIND)->where('bind', '=', $bind_name)); if ($area->loaded()) { // Get topic $topic = Model_Forum_Topic::factory(); $topic = $topic->load(DB::select_array($topic->fields())->where('forum_area_id', '=', $area->id)->where('bind_id', '=', $bind_model->id())); // If topic found, go there! if ($topic->loaded()) { return $topic; } } } return null; }
/** * Find all objectcs * * @return Database_Result */ public function find_all() { return AutoModeler::factory(Model::model_name(get_called_class()))->load(null, null); }
/** * Permission denied * * @param Permission_Interface $model * @param integer $id * @param string $permission */ public function __construct(Permission_Interface $model, $id = 0, $permission = null) { parent::__construct("Permission ':permission' denied: :model #:id", array(':id' => $id, ':model' => Model::model_name($model), ':permission' => $permission)); }
/** * Model not found or no access * * @param Model $model * @param integer $id */ public function __construct(Model $model, $id = 0) { parent::__construct('Model not found: :model #:id', array(':id' => $id, ':model' => Model::model_name($model))); }
/** * Return model specific route * * @param Model $model * @param string $action * @param string $params * @param string $route Defaults to model name * @return string */ public static function model(Model $model, $action = '', $params = null, $route = null) { return Route::url($route ? $route : Model::model_name($model), array('id' => self::model_id($model), 'action' => $action, 'params' => $params)); }