Allow all users to create and link people tags.

This commit is contained in:
2016-11-13 14:42:53 +01:00
parent 7f5ce1820d
commit 0a55730696
6 changed files with 94 additions and 63 deletions

View File

@@ -18,6 +18,9 @@ class ViewPhoto extends HTMLController
if (empty($photo))
throw new NotFoundException();
if (!empty($_POST))
$this->handleTagging($photo->getImage());
parent::__construct($photo->getTitle() . ' - ' . SITE_TITLE);
$page = new PhotoPage($photo->getImage());
@@ -47,4 +50,21 @@ class ViewPhoto extends HTMLController
if (Registry::get('user')->isAdmin())
$this->admin_bar->appendItem(BASEURL . '/editasset/?id=' . $photo->getId(), 'Edit this photo');
}
private function handleTagging(Image $photo)
{
header('Content-Type: text/json; charset=utf-8');
// Are we tagging a photo?
if (!isset($_POST['id_tag']))
{
echo json_encode(['error' => true, 'msg' => 'Invalid tag request.']);
exit;
}
// We are!
$photo->linkTags([(int) $_POST['id_tag']]);
echo json_encode(['success' => true]);
exit;
}
}