diff options
Diffstat (limited to 'plugins/SocialPhoto/SocialPhoto.php')
-rw-r--r-- | plugins/SocialPhoto/SocialPhoto.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/SocialPhoto/SocialPhoto.php b/plugins/SocialPhoto/SocialPhoto.php new file mode 100644 index 000000000..f072ab814 --- /dev/null +++ b/plugins/SocialPhoto/SocialPhoto.php @@ -0,0 +1,50 @@ +<?php + +if (!defined('STATUSNET')) { + exit(1); +} + +require_once INSTALLDIR . '/plugins/SocialObject/SocialObject.php'; + +class SocialPhoto extends SocialObject +{ + public $__table = 'social_photo'; + public $id; + public $url; + public $title; + public $description; + + var $slug = 'photo'; + static function saveNew($notice, $action) + { + $photo = new SocialPhoto(); + $photo->id = $notice->id; # very essential + $photo->title = $action->trimmed('photo-title'); + $att = $notice->attachments(); + if(empty($att)) { + # no attachment uploaded? + $action->clientError(_('No photo was uploaded')); + $photo->delete(); + } + $att = $att[0]; # just use the 1st one :P + $photo->url = $att->url; + # TODO: Size the photo up/down and + # save copies of different sizes + $photo->insert(); + } + + static function schemaDef() + { + return array(new ColumnDef('id', 'int', + /*size*/null, + /*nullable*/false, + /*key*/'PRI'), + new ColumnDef('title', 'varchar', + /*size*/255, + /*nullable*/false), + new ColumnDef('url', 'varchar', + 255, false), + new ColumnDef('description', 'text', + null, true)); + } +} |