TagFaces bugfix.
This commit is contained in:
parent
84f9e25c42
commit
29001ad186
@ -20,12 +20,25 @@
|
|||||||
class tagfaces_Controller extends Controller {
|
class tagfaces_Controller extends Controller {
|
||||||
public function drawfaces($id) {
|
public function drawfaces($id) {
|
||||||
// Generate the page that allows the user to draw boxes over a photo.
|
// Generate the page that allows the user to draw boxes over a photo.
|
||||||
|
|
||||||
// Make sure user has access to view and edit the photo.
|
// Make sure user has access to view and edit the photo.
|
||||||
$item = ORM::factory("item", $id);
|
$item = ORM::factory("item", $id);
|
||||||
access::required("view", $item);
|
access::required("view", $item);
|
||||||
access::required("edit", $item);
|
access::required("edit", $item);
|
||||||
|
|
||||||
|
// Make sure the item actually has tags on it.
|
||||||
|
$all_tags = ORM::factory("tag")
|
||||||
|
->join("items_tags", "tags.id", "items_tags.tag_id")
|
||||||
|
->where("items_tags.item_id", $id)
|
||||||
|
->find_all();
|
||||||
|
|
||||||
|
// If it doesn't, display an error and direct back to the photo.
|
||||||
|
if (count($all_tags) == 0) {
|
||||||
|
message::error(t("Please add some tags first."));
|
||||||
|
url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Create the page.
|
// Create the page.
|
||||||
$template = new Theme_View("page.html", "drawfaces");
|
$template = new Theme_View("page.html", "drawfaces");
|
||||||
$template->set_global("item_id", $id);
|
$template->set_global("item_id", $id);
|
||||||
|
@ -34,10 +34,14 @@ class tagfaces_event_Core {
|
|||||||
|
|
||||||
static function site_menu($menu, $theme) {
|
static function site_menu($menu, $theme) {
|
||||||
// Create a menu option for adding face data.
|
// Create a menu option for adding face data.
|
||||||
|
if (!$theme->item()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$item = $theme->item();
|
$item = $theme->item();
|
||||||
|
|
||||||
if ((access::can("view", $item)) && (access::can("edit", $item))) {
|
if ($item->is_photo()) {
|
||||||
if ($item->is_photo()) {
|
if ((access::can("view", $item)) && (access::can("edit", $item))) {
|
||||||
$menu->get("options_menu")
|
$menu->get("options_menu")
|
||||||
->append(Menu::factory("link")
|
->append(Menu::factory("link")
|
||||||
->id("tagfaces")
|
->id("tagfaces")
|
||||||
|
Reference in New Issue
Block a user