diff --git a/classes/Managed_DataObject.php b/classes/Managed_DataObject.php index 7263b3e320..552d980fba 100644 --- a/classes/Managed_DataObject.php +++ b/classes/Managed_DataObject.php @@ -152,4 +152,18 @@ abstract class Managed_DataObject extends Memcached_DataObject return $style; } + + function links() + { + $links = array(); + + $table = call_user_func(array(get_class($this), 'schemaDef')); + + foreach ($table['foreign keys'] as $keyname => $keydef) { + if (count($keydef) == 2 && is_string($keydef[0]) && is_array($keydef[1]) && count($keydef[1]) == 1) { + $links[$keydef[1][0]] = $keydef[0].':'.$keydef[1][1]; + } + } + return $links; + } } \ No newline at end of file diff --git a/classes/Profile.php b/classes/Profile.php index bcbb406ae0..228a0ae202 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -435,6 +435,7 @@ class Profile extends Managed_DataObject $tags->tagged = $this->id; $lists->joinAdd($tags); + #@fixme: postgres (round(date_part('epoch', my_date))) $lists->selectAdd('unix_timestamp(profile_tag.modified) as "cursor"'); @@ -507,7 +508,8 @@ class Profile extends Managed_DataObject $lists = new Profile_list(); $subs = new Profile_tag_subscription(); - $lists->joinAdd($subs); + $lists->joinAdd('id', 'profile_tag_subscription:profile_tag_id'); + #@fixme: postgres (round(date_part('epoch', my_date))) $lists->selectAdd('unix_timestamp(profile_tag_subscription.created) as "cursor"'); diff --git a/classes/Profile_list.php b/classes/Profile_list.php index 50aa71f55d..c433a53fee 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -220,10 +220,9 @@ class Profile_list extends Managed_DataObject function getSubscribers($offset=0, $limit=null, $since=0, $upto=0) { $subs = new Profile(); - $sub = new Profile_tag_subscription(); - $sub->profile_tag_id = $this->id; - $subs->joinAdd($sub); + $subs->joinAdd(array('id', 'profile_tag_subscription:profile_tag_id')); + $subs->selectAdd('unix_timestamp(profile_tag_subscription.' . 'created) as "cursor"'); diff --git a/lib/default.php b/lib/default.php index 9c4c8cab05..71b2257cd5 100644 --- a/lib/default.php +++ b/lib/default.php @@ -310,7 +310,8 @@ $default = 'TagSub' => null, 'OpenID' => null, 'Directory' => null, - 'ExtendedProfile' => null), + 'ExtendedProfile' => null, + 'Activity' => null), 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories 'server' => null, 'sslserver' => null, diff --git a/lib/peopletagnoticestream.php b/lib/peopletagnoticestream.php index 9477ca8ea6..e82d754e8d 100644 --- a/lib/peopletagnoticestream.php +++ b/lib/peopletagnoticestream.php @@ -96,10 +96,10 @@ class RawPeopletagNoticeStream extends NoticeStream $notice->selectAdd(); $notice->selectAdd('notice.id'); - $ptag = new Profile_tag(); - $ptag->tag = $this->profile_list->tag; - $ptag->tagger = $this->profile_list->tagger; - $notice->joinAdd($ptag); + $notice->joinAdd(array('profile_id', 'profile_tag:tagged')); + + $notice->whereAdd(sprintf('profile_tag.tag = "%s"', $this->profile_list->tag)); + $notice->whereAdd(sprintf('profile_tag.tagger = %d', $this->profile_list->tagger)); if ($since_id != 0) { $notice->whereAdd('notice.id > ' . $since_id);