forked from Public/pics
Adds a Delete button to the ViewPhotoPage.
The Delete button is non functional yet and is only available for admins and the photo owner.
This commit is contained in:
parent
fcbbc7106d
commit
344db6e4c5
@ -43,6 +43,11 @@ class ViewPhoto extends HTMLController
|
|||||||
if ($next_url)
|
if ($next_url)
|
||||||
$page->setNextPhotoUrl($next_url);
|
$page->setNextPhotoUrl($next_url);
|
||||||
|
|
||||||
|
$user = Registry::get('user');
|
||||||
|
$author = $photo->getAuthor();
|
||||||
|
if ($user->isAdmin() || $user->getUserId() === $author->getUserId())
|
||||||
|
$page->setIsAssetOwner(true);
|
||||||
|
|
||||||
$this->page->adopt($page);
|
$this->page->adopt($page);
|
||||||
$this->page->setCanonicalUrl($photo->getPageUrl());
|
$this->page->setCanonicalUrl($photo->getPageUrl());
|
||||||
|
|
||||||
|
@ -619,6 +619,16 @@ a#previous_photo:hover, a#next_photo:hover {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#user_actions_box {
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
|
margin: 25px 0 25px 0;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 2%;
|
||||||
|
float: right;
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Responsive: smartphone in portrait
|
/* Responsive: smartphone in portrait
|
||||||
---------------------------------------*/
|
---------------------------------------*/
|
||||||
|
@ -12,6 +12,7 @@ class PhotoPage extends SubTemplate
|
|||||||
private $exif;
|
private $exif;
|
||||||
private $previous_photo_url = '';
|
private $previous_photo_url = '';
|
||||||
private $next_photo_url = '';
|
private $next_photo_url = '';
|
||||||
|
private $is_asset_owner = false;
|
||||||
|
|
||||||
public function __construct(Image $photo)
|
public function __construct(Image $photo)
|
||||||
{
|
{
|
||||||
@ -28,6 +29,10 @@ class PhotoPage extends SubTemplate
|
|||||||
$this->next_photo_url = $url;
|
$this->next_photo_url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIsAssetOwner($flag) {
|
||||||
|
$this->is_asset_owner = $flag;
|
||||||
|
}
|
||||||
|
|
||||||
protected function html_content()
|
protected function html_content()
|
||||||
{
|
{
|
||||||
$this->photoNav();
|
$this->photoNav();
|
||||||
@ -45,6 +50,10 @@ class PhotoPage extends SubTemplate
|
|||||||
|
|
||||||
$this->photoMeta();
|
$this->photoMeta();
|
||||||
|
|
||||||
|
if($this->is_asset_owner) {
|
||||||
|
$this->addUserActions();
|
||||||
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<script type="text/javascript" src="', BASEURL, '/js/photonav.js"></script>';
|
<script type="text/javascript" src="', BASEURL, '/js/photonav.js"></script>';
|
||||||
}
|
}
|
||||||
@ -183,4 +192,13 @@ class PhotoPage extends SubTemplate
|
|||||||
{
|
{
|
||||||
$this->exif = $exif;
|
$this->exif = $exif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addUserActions()
|
||||||
|
{
|
||||||
|
echo '
|
||||||
|
<div id=user_actions_box>
|
||||||
|
<h3>Actions</h3>
|
||||||
|
<a class="btn btn-red" href="', BASEURL, '/editasset/?id=', $this->photo->getId(), '&delete">Delete asset</a>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user