]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/GNUsocialPhotos/classes/gnusocialphotoalbum.php
Cool js photo resizing effect
[quix0rs-gnu-social.git] / plugins / GNUsocialPhotos / classes / gnusocialphotoalbum.php
index 853854e428435e9c351ebcf8e837be9166cef6e1..848f92dffabdaed1488a71f2d23314b15cf65437 100644 (file)
@@ -36,9 +36,10 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
 class GNUsocialPhotoAlbum extends Memcached_DataObject
 {
     public $__table = 'GNUsocialPhotoAlbum';
-    public $album_id;       // int(11) -- Unique identifier for the album
-    public $profile_id;     // int(11) -- Profile ID for the owner of the album
-    public $album_name;     // varchar(256) -- Title for this album
+    public $album_id;          // int(11) -- Unique identifier for the album
+    public $profile_id;        // int(11) -- Profile ID for the owner of the album
+    public $album_name;        // varchar(256) -- Title for this album
+    public $album_description; // text -- A description of the album
     
 
     function staticGet($k,$v=NULL)
@@ -52,7 +53,8 @@ class GNUsocialPhotoAlbum extends Memcached_DataObject
     {
         return array('album_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
                      'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
-                     'album_name' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
+                     'album_name' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
+                     'album_description' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL);
     }
     
     function keys()
@@ -69,10 +71,24 @@ class GNUsocialPhotoAlbum extends Memcached_DataObject
 
     function sequenceKey()
     {
-        return array(false, false, false);
-    } 
+        return array('album_id', true, false);
+    }
 
-    static function newAlbum($profile_id, $album_name)
+    function getPageLink()
+    {
+        $profile = Profile::StaticGet('id', $this->profile_id);
+        return '/' . $profile->nickname . '/photos/' . $this->album_id;
+    }
+
+    function getThumbUri()
+    {
+        $photo = GNUsocialPhoto::staticGet('album_id', $this->album_id);
+        if (empty($photo))
+            return '/theme/default/default-avatar-profile.png'; //For now...
+        return $photo->thumb_uri;
+    }
+
+    static function newAlbum($profile_id, $album_name, $album_description)
     {
         //TODO: Should use foreign key instead...
         if (!Profile::staticGet('id', $profile_id)){
@@ -81,14 +97,17 @@ class GNUsocialPhotoAlbum extends Memcached_DataObject
         }
         
         $album = new GNUsocialPhotoAlbum();
-        //TODO: Should autoincrement..
         $album->profile_id = $profile_id;
         $album->album_name = $album_name;
-        
-        if ($album->insert() == false){
+        $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;
+    }
 
 }