Allow all users to create and link people tags.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user