Respect the $type parameter on Tag_Model::items_count()

This commit is contained in:
Tim Almdal
2009-07-23 11:57:34 -07:00
parent 070884d9e2
commit 67190412e6

View File

@@ -44,10 +44,14 @@ class Tag_Model extends ORM {
* @return integer
*/
public function items_count($type=null) {
return ORM::factory("item")
$model = ORM::factory("item")
->viewable()
->join("items_tags", "items.id", "items_tags.item_id")
->where("items_tags.tag_id", $this->id)
->count_all();
->where("items_tags.tag_id", $this->id);
if ($type) {
$model->where("items.type", $type);
}
return $model->count_all();
}
}