function updatePhoto() { $cur = common_current_user(); $this->photo->title = $this->trimmed('phototitle'); $this->photo->photo_description = $this->trimmed('photo_description'); $profile_id = $cur->id; $album = GNUsocialPhotoAlbum::getKV('album_id', $this->trimmed('album')); if ($album->profile_id != $profile_id) { $this->showForm(_('Error: This is not your album!')); return; } $this->photo->album_id = $album->album_id; if ($this->photo->validate()) { $this->photo->update(); } else { $this->showForm(_('Error: The photo data is not valid.')); return; } common_redirect('/photo/' . $this->photo->id, '303'); // common_redirect exits }
function deleteAlbum() { $cur = common_current_user(); if (empty($cur)) { return; } $album_id = $this->trimmed('album'); $album = GNUsocialPhotoAlbum::getKV('album_id', $album_id); if (empty($album)) { $this->showForm(_('This album does not exist or has been deleted.')); return; } //Check if the album has any photos in it before deleting $photos = GNUsocialPhoto::getKV('album_id', $album_id); if (empty($photos)) { $album->delete(); $this->showForm(_('Album deleted'), true); } else { $this->showForm(_('Cannot delete album when there are photos in it!'), false); } }
function showAlbum($album_id) { $album = GNUsocialPhotoAlbum::getKV('album_id', $album_id); if (!$album) { return; } $page = $_GET['pageid']; if (!filter_var($page, FILTER_VALIDATE_INT)) { $page = 1; } $photos = GNUsocialPhoto::getGalleryPage($page, $album->album_id, 9); $this->elementStart('div', array('class' => 'galleryheader')); if ($page > 1) { $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page - 1)), 'Previous page'); $this->raw(' | '); } if (GNUsocialPhoto::getGalleryPage($page + 1, $album->album_id, 9)) { $this->element('a', array('href' => $album->getPageLink() . '?pageid=' . ($page + 1)), 'Next page'); $this->raw(' | '); } //$this->element('a', array('href' => '#', // 'onclick' => 'return increasePhotoSize()'), '+'); //$this->raw(' | '); //$this->element('a', array('href' => '#', // 'onclick' => 'return decreasePhotoSize()'), '-'); //$this->raw(' | '); $this->showResizeImagesBox(); $this->elementEnd('div'); foreach ($photos as $photo) { $this->elementStart('a', array('href' => $photo->getPageLink())); $this->elementStart('div', array('class' => 'photocontainer')); $this->element('img', array('src' => $photo->thumb_uri, 'class' => 'photoingallery')); $this->element('div', array('class' => 'phototitle'), $photo->title); $this->elementEnd('div'); $this->elementEnd('a'); } }