]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Notifications and deleting albums
authorMax Shinn <trombonechamp@gmail.com>
Thu, 30 Dec 2010 14:02:59 +0000 (08:02 -0600)
committerMax Shinn <trombonechamp@gmail.com>
Thu, 30 Dec 2010 14:02:59 +0000 (08:02 -0600)
plugins/GNUsocialPhotos/actions/editphoto.php
plugins/GNUsocialPhotos/actions/photoupload.php

index e32b5fe01d7e3d63e25c9d9002f8f50eea346af5..34f41a275257840cfdf67c2b825b4619e7881749 100644 (file)
@@ -76,6 +76,12 @@ class EditphotoAction extends Action
             return;
         } 
 
+        //showForm() data
+        if(!empty($this->msg)) {
+            $class = ($this->success) ? 'success' : 'error';
+            $this->element('p', array('class' => $class), $this->msg);
+        }
+
         $this->element('img', array('src' => $this->photo->uri));
         $this->elementStart('form', array('method' => 'post',
                                           'action' => '/editphoto/' . $this->photo->id));
@@ -173,7 +179,7 @@ class EditphotoAction extends Action
             return;
         }
         common_redirect('/photo/' . $this->photo->id, '303');
-        $this->showForm(_('Success!'));
+        $this->showForm(_('Success!'), true);
 
     }
 
index fc86b8e3abe079b27688d943cf367d6e1df0ecff..5411ec8089ce5b8a5d448421fc8b1dc39b1432b9 100644 (file)
@@ -63,6 +63,12 @@ class PhotouploadAction extends Action
         if(empty($this->user)) {
             $this->element('p', array(), 'You are not logged in.');
         } else {
+            //showForm() data
+            if(!empty($this->msg)) {
+                $class = ($this->success) ? 'success' : 'error';
+                $this->element('p', array('class' => $class), $this->msg);
+            }
+
             $this->elementStart('form', array('enctype' => 'multipart/form-data',
                                               'method' => 'post',
                                               'action' => common_local_url('photoupload')));
@@ -101,6 +107,18 @@ class PhotouploadAction extends Action
             $this->elementEnd('ul');
             $this->submit('create', _('Create'));
             $this->elementEnd('form');
+
+            //Delete an album
+            $this->element('h3', array(), _("Delete an album"));
+            $this->elementStart('form', array('method' => 'post',
+                                              'action' =>common_local_url('photoupload')));
+            $this->elementStart('ul', 'form_data');
+            $this->elementStart('li');
+            $this->dropdown('album', _("Album"), $this->albumList(), _("The album in which to place this photo"), false);
+            $this->elementEnd('li');
+            $this->elementEnd('ul');
+            $this->submit('deletealbum', _('Delete'));
+            $this->elementEnd('form');
             
         }
     }
@@ -138,6 +156,9 @@ class PhotouploadAction extends Action
         if ($this->arg('create')) {
             $this->createAlbum();
         }
+        if ($this->arg('deletealbum')) {
+            $this->deleteAlbum();
+        }
     }
 
     function showForm($msg, $success=false)
@@ -213,4 +234,26 @@ class PhotouploadAction extends Action
        
         GNUsocialPhotoAlbum::newAlbum($cur->id, $album_name, $album_description);
     }
+
+    function deleteAlbum()
+    {
+        $cur = common_current_user();
+        if(empty($cur)) return;
+        
+        $album_id = $this->trimmed('album');
+        $album = GNUsocialPhotoAlbum::staticGet('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::staticGet('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);
+        }
+    }
 }