From 4fab7a9d8b5bc6d85b74b8b2574bb8167129fe39 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 21 Aug 2013 14:12:18 +0200 Subject: [PATCH] GNU Social extensions fixes (please read note) These extensions are not considered secure nor stable right now, so don't use them for a while. --- plugins/GNUsocialPhotos/classes/gnusocialphoto.php | 5 +++-- .../classes/gnusocialphotoalbum.php | 2 +- .../classes/GNUsocialProfileExtensionField.php | 14 ++------------ .../classes/GNUsocialProfileExtensionResponse.php | 10 +++++----- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/plugins/GNUsocialPhotos/classes/gnusocialphoto.php b/plugins/GNUsocialPhotos/classes/gnusocialphoto.php index 6e9daac2ed..9fbe5a58aa 100644 --- a/plugins/GNUsocialPhotos/classes/gnusocialphoto.php +++ b/plugins/GNUsocialPhotos/classes/gnusocialphoto.php @@ -60,7 +60,7 @@ class GNUsocialPhoto extends Managed_DataObject { return array( 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for Photo'), + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique ID for Photo'), 'notice_id' => array('type' => 'int', 'not null' => true, 'description' => 'Notice ID for the related notice'), 'album_id' => array('type' => 'int', 'not null' => true, 'description' => 'The parent album ID'), 'uri' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'unique address for this photo'), @@ -72,7 +72,8 @@ class GNUsocialPhoto extends Managed_DataObject ), 'primary key' => array('id'), 'unique keys' => array( - 'gnusocialphoto_uri' => array('uri'), + 'gnusocialphoto_id_key' => array('notice_id'), + 'gnusocialphoto_uri_key' => array('uri'), ), 'foreign keys' => array( 'gnusocialphoto_notice_id_fkey' => array('notice', array('notice_id' => 'id')), diff --git a/plugins/GNUsocialPhotos/classes/gnusocialphotoalbum.php b/plugins/GNUsocialPhotos/classes/gnusocialphotoalbum.php index 208c341851..8b8c1dbf5a 100644 --- a/plugins/GNUsocialPhotos/classes/gnusocialphotoalbum.php +++ b/plugins/GNUsocialPhotos/classes/gnusocialphotoalbum.php @@ -48,7 +48,7 @@ class GNUsocialPhotoAlbum extends Managed_DataObject { return array( 'fields' => array( - 'album_id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique identifier for the album'), + 'album_id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique identifier for the album'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile ID for the owner of the album'), 'album_name' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'Title for this album'), 'album_description' => array('type' => 'text', 'not null' => true, 'description' => 'A description for this album'), diff --git a/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionField.php b/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionField.php index 9574863c58..564ddce875 100644 --- a/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionField.php +++ b/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionField.php @@ -34,7 +34,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; class GNUsocialProfileExtensionField extends Managed_DataObject { - public $__table = 'GNUsocialProfileExtensionField'; + public $__table = 'gnusocialprofileextensionfield'; public $id; // int(11) public $systemname; // varchar(64) public $title; // varchar(255) @@ -47,7 +47,7 @@ class GNUsocialProfileExtensionField extends Managed_DataObject { return array( 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension field'), + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique ID for extension field'), 'systemname' => array('type' => 'varchar', 'not null' => true, 'length' => 64, 'description' => 'field systemname'), 'title' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'field title'), 'description' => array('type' => 'text', 'not null' => true, 'description' => 'field description'), @@ -62,16 +62,6 @@ class GNUsocialProfileExtensionField extends Managed_DataObject ); } - function keyTypes() - { - return array('id' => 'K'); - } - - function sequenceKey() - { - return array(false, false, false); - } - static function newField($title, $description=null, $type='str', $systemname=null) { $field = new GNUsocialProfileExtensionField(); diff --git a/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionResponse.php b/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionResponse.php index 4163d4d077..7af6bb5051 100644 --- a/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionResponse.php +++ b/plugins/GNUsocialProfileExtensions/classes/GNUsocialProfileExtensionResponse.php @@ -34,7 +34,7 @@ require_once INSTALLDIR . '/classes/Memcached_DataObject.php'; class GNUsocialProfileExtensionResponse extends Managed_DataObject { - public $__table = 'GNUsocialProfileExtensionResponse'; + public $__table = 'gnusocialprofileextensionresponse'; public $id; // int(11) public $extension_id; // int(11) public $profile_id; // int(11) @@ -46,7 +46,7 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject { return array( 'fields' => array( - 'id' => array('type' => 'int', 'not null' => true, 'description' => 'Unique ID for extension response'), + 'id' => array('type' => 'serial', 'not null' => true, 'description' => 'Unique ID for extension response'), 'extension_id' => array('type' => 'int', 'not null' => true, 'description' => 'The extension field ID'), 'profile_id' => array('type' => 'int', 'not null' => true, 'description' => 'Profile id that made the response'), 'value' => array('type' => 'text', 'not null' => true, 'description' => 'response entry'), @@ -56,7 +56,7 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject 'primary key' => array('id'), 'foreign keys' => array( 'gnusocialprofileextensionresponse_profile_id_fkey' => array('profile', array('profile_id' => 'id')), - 'gnusocialprofileextensionresponse_extension_id_fkey' => array('GNUsocialProfileExtensionField', array('extension_id' => 'id')), + 'gnusocialprofileextensionresponse_extension_id_fkey' => array('gnusocialprofileextensionfield', array('extension_id' => 'id')), ), 'indexes' => array( 'gnusocialprofileextensionresponse_extension_id_idx' => array('extension_id'), @@ -82,8 +82,8 @@ class GNUsocialProfileExtensionResponse extends Managed_DataObject static function findResponsesByProfile($id) { - $extf = 'GNUsocialProfileExtensionField'; - $extr = 'GNUsocialProfileExtensionResponse'; + $extf = 'gnusocialprofileextensionfield'; + $extr = 'gnusocialprofileextensionresponse'; $sql = "SELECT $extr.*, $extf.title, $extf.description, $extf.type, $extf.systemname FROM $extr JOIN $extf ON $extr.extension_id=$extf.id WHERE $extr.profile_id = $id"; $response = new GNUsocialProfileExtensionResponse(); $response->query($sql);