static function newAlbum($profile_id, $album_name, $album_description)
 {
     //TODO: Should use foreign key instead...
     if (!Profile::getKV('id', $profile_id)) {
         //Is this a bit extreme?
         throw new ServerException(_m('No such user exists with id ' . $profile_id . ', couldn\'t create album.'));
     }
     $album = new GNUsocialPhotoAlbum();
     $album->profile_id = $profile_id;
     $album->album_name = $album_name;
     $album->album_description = $album_description;
     $album->album_id = $album->insert();
     if (!$album->album_id) {
         common_log_db_error($album, 'INSERT', __FILE__);
         throw new ServerException(_m('Error creating new album.'));
     }
     common_log(LOG_INFO, 'album_id : ' . $album->album_id);
     return $album;
 }
示例#2
0
 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);
     }
 }
示例#3
0
 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
 }
示例#4
0
 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');
     }
 }
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('GNUsocialPhoto', GNUsocialPhoto::schemaDef());
     $schema->ensureTable('GNUsocialPhotoAlbum', GNUsocialPhotoAlbum::schemaDef());
 }