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)
{
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()
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)){
}
$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;
+ }
}