summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorIan Denhardt <ian@zenhack.net>2010-08-11 10:54:06 -0400
committerIan Denhardt <ian@zenhack.net>2010-08-11 10:54:06 -0400
commit58d98a4c2b58fc69ddef81c2a0f32c079344e0d9 (patch)
treea46c46185cbe880902ba767641e7245538f53216 /plugins
parent50b12e5820e88682c27a75974143dc61159b327c (diff)
Photos now show up in feed (locally anywyay.) need cleanup/federation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php35
-rw-r--r--plugins/GNUsocialPhotos/actions/photoupload.php20
-rw-r--r--plugins/GNUsocialPhotos/classes/gnusocialphoto.php46
3 files changed, 87 insertions, 14 deletions
diff --git a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php
index f7cb6f398..46c67d5d9 100644
--- a/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php
+++ b/plugins/GNUsocialPhotos/GNUsocialPhotosPlugin.php
@@ -44,16 +44,16 @@ class GNUsocialPhotosPlugin extends Plugin
case 'PhotosAction':
include_once $dir . '/lib/photolib.php';
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
- return false;
+ break;
case 'PhotouploadAction':
include_once $dir . '/lib/photolib.php';
- include_once $dir . '/classes/gnusocialphoto.php';
include_once $dir . '/actions/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
- return false;
+ break;
default:
- return true;
+ break;
}
+ include_once $dir . '/classes/gnusocialphoto.php';
return true;
}
@@ -61,7 +61,7 @@ class GNUsocialPhotosPlugin extends Plugin
{
$schema = Schema::get();
$schema->ensureTable('GNUsocialPhoto',
- array(new ColumnDef('object_id', 'integer', null, false, 'PRI', true, null, null, true),
+ array(new ColumnDef('notice_id', 'integer', null, false, null, true, null, null, true),
new ColumnDef('path', 'varchar(150)', null, false),
new ColumnDef('thumb_path', 'varchar(156)', null, false), // 156 = 150 + strlen('thumb.')
new ColumnDef('owner_id', 'int(11)', null, false)));
@@ -74,4 +74,29 @@ class GNUsocialPhotosPlugin extends Plugin
common_log(LOG_INFO, "init'd!");
return true;
}
+
+ /* function onStartActivityDefaultObjectType(&$notice, &$xs, &$type)
+ {
+ $photo = GNUsocialPhoto::staticGet('notice_id', $notice->id);
+ if($photo) {
+ $type = ActivityObject::PHOTO;
+ }
+ } */
+
+ function onStartShowNoticeItem($action)
+ {
+ common_log(LOG_INFO, 'StartShowNoticeItem: ' . $action->notice->id);
+ $photo = GNUsocialPhoto::staticGet('notice_id', $action->notice->id);
+ if($photo) {
+ common_log(LOG_INFO, 'is photo.');
+ $action->out->elementStart('a', array('href' => 'http://' . common_config('site', 'server') . $photo->path));
+ $action->out->element('img', array('src' => 'http://' . common_config('site', 'server') . $photo->thumb_path));
+ $action->out->elementEnd('a');
+ $action->showNoticeInfo();
+ $action->showNoticeOptions();
+ return false;
+ }
+ common_log(LOG_INFO, 'not photo');
+ return true;
+ }
}
diff --git a/plugins/GNUsocialPhotos/actions/photoupload.php b/plugins/GNUsocialPhotos/actions/photoupload.php
index 9a643dbe6..6fdf51531 100644
--- a/plugins/GNUsocialPhotos/actions/photoupload.php
+++ b/plugins/GNUsocialPhotos/actions/photoupload.php
@@ -103,6 +103,14 @@ class PhotouploadAction extends Action
}
}
+ function showForm($msg, $success=false)
+ {
+ $this->msg = $msg;
+ $this->success = $success;
+
+// $this->showPage();
+ }
+
function uploadPhoto()
{
common_log(LOG_INFO, 'Is this function even getting called?');
@@ -123,15 +131,13 @@ class PhotouploadAction extends Action
common_log(LOG_INFO, 'upload path : ' . $imagefile->filepath);
- $filename = $cur->nickname . '-' . common_timestamp() . sha1_file($imagefile->filepath) . '.' . image_type_to_extension($imagefile->type);
+ $filename = $cur->nickname . '-' . common_timestamp() . sha1_file($imagefile->filepath) . image_type_to_extension($imagefile->type);
move_uploaded_file($imagefile->filepath, INSTALLDIR . '/file/' . $filename);
photo_make_thumbnail($filename);
- $photo = new GNUsocialPhoto();
- $photo->path = '/file/' . $filename;
- $photo->thumb_path = '/file/thumb.' . $filename;
- $photo->owner_id = $cur->id;
- $photo->object_id = 'DEFAULT';
- $photo->insert();
+ $path = '/file/' . $filename;
+ $thumb_path = '/file/thumb.' . $filename;
+ $profile_id = $cur->id;
+ GNUsocialPhoto::saveNew($profile_id, $thumb_path, $path, 'web');
}
}
diff --git a/plugins/GNUsocialPhotos/classes/gnusocialphoto.php b/plugins/GNUsocialPhotos/classes/gnusocialphoto.php
index 882d1026e..96288731e 100644
--- a/plugins/GNUsocialPhotos/classes/gnusocialphoto.php
+++ b/plugins/GNUsocialPhotos/classes/gnusocialphoto.php
@@ -35,7 +35,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
class GNUsocialPhoto extends Memcached_DataObject
{
public $__table = 'GNUsocialPhoto';
- public $object_id; // integer
+ public $noitce_id; // integer
public $path; // varchar(150)
public $thumb_path; // varchar(156)
public $owner_id; // int(11) (user who posted the photo)
@@ -58,9 +58,51 @@ class GNUsocialPhoto extends Memcached_DataObject
function table()
{
- return array('object_id' => DB_DATAOBJECT_INT,
+ return array('notice_id' => DB_DATAOBJECT_INT,
'path' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'thumb_path' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
'owner_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL);
}
+
+ function keys()
+ {
+ return array_keys($this->keyTypes());
+ }
+
+ function keyTypes()
+ {
+ return array('notice_id' => 'K');
+ }
+
+ function sequenceKey()
+ {
+ return array(false, false, false);
+ }
+
+ function saveNew($profile_id, $thumb_path, $path, $source)
+ {
+ $photo = new GNUsocialPhoto();
+ $photo->thumb_path = $thumb_path;
+ $photo->path = $path;
+ $photo->owner_id = $profile_id;
+
+ $notice = Notice::saveNew($profile_id, 'http://' . common_config('site', 'server') . $path, $source);
+ $photo->notice_id = $notice->id;
+ $photo_id = $photo->insert();
+ if (!$photo_id) {
+ common_log_db_error($photo, 'INSERT', __FILE__);
+ throw new ServerException(_m('Problem Saving Photo.'));
+ }
+ }
+ /*
+ function asActivityNoun($element)
+ {
+ $object = new ActivityObject();
+
+ $object->type = ActivityObject::PHOTO;
+ $object->title = "";
+ $object->thumbnail = 'http://' . common_config('site', 'server') . $this->thumb_path;
+ $object->largerImage = 'http://' . common_config('site', 'server') . $this->path;
+ return $object;
+ } */
}