get("path"); $id = $input->get("g2_itemId"); if ($id) { $where = array("g2_id", "=", $id); } else if ($path) { $where = array("g2_url", "=", $path); } else { throw new Kohana_404_Exception(); } $g2_map = ORM::factory("g2_map") ->merge_where(array($where)) ->find(); if (!$g2_map->loaded()) { throw new Kohana_404_Exception(); } $item = ORM::factory("item")->where("id", "=", $g2_map->g3_id)->find(); if (!$item->loaded() || !access::can("view", $item)) { throw new Kohana_404_Exception(); } // Redirect the user to the new url switch ($g2_map->resource_type) { case "thumbnail": url::redirect($item->thumb_url(true)); case "resize": url::redirect($item->resize_url(true)); case "full": url::redirect($item->file_url(true)); case "item": case "album": url::redirect($item->abs_url()); case "group": case "user": default: throw new Kohana_404_Exception(); } } }