Merge branch '0.8.x' into 0.9.x
This commit is contained in:
commit
6a0f0e32d5
3
README
3
README
|
@ -953,12 +953,15 @@ sslserver: use an alternate server name for SSL URLs, like
|
||||||
shorturllength: Length of URL at which URLs in a message exceeding 140
|
shorturllength: Length of URL at which URLs in a message exceeding 140
|
||||||
characters will be sent to the user's chosen
|
characters will be sent to the user's chosen
|
||||||
shortening service.
|
shortening service.
|
||||||
|
<<<<<<< HEAD:README
|
||||||
design: a default design (colors and background) for the site.
|
design: a default design (colors and background) for the site.
|
||||||
Sub-items are: backgroundcolor, contentcolor, sidebarcolor,
|
Sub-items are: backgroundcolor, contentcolor, sidebarcolor,
|
||||||
textcolor, linkcolor, backgroundimage, disposition.
|
textcolor, linkcolor, backgroundimage, disposition.
|
||||||
dupelimit: minimum time allowed for one person to say the same thing
|
dupelimit: minimum time allowed for one person to say the same thing
|
||||||
twice. Default 60s. Anything lower is considered a user
|
twice. Default 60s. Anything lower is considered a user
|
||||||
or UI error.
|
or UI error.
|
||||||
|
=======
|
||||||
|
>>>>>>> 0.7.x:README
|
||||||
|
|
||||||
db
|
db
|
||||||
--
|
--
|
||||||
|
|
|
@ -51,6 +51,13 @@ class TwitapiusersAction extends TwitterapiAction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
|
if (!$profile) {
|
||||||
|
common_server_error(_('User has no profile.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$twitter_user = $this->twitter_user_array($user->getProfile(), true);
|
$twitter_user = $this->twitter_user_array($user->getProfile(), true);
|
||||||
|
|
||||||
if ($apidata['content-type'] == 'xml') {
|
if ($apidata['content-type'] == 'xml') {
|
||||||
|
|
|
@ -356,6 +356,8 @@ class Notice extends Memcached_DataObject
|
||||||
$this->blowTagCache($blowLast);
|
$this->blowTagCache($blowLast);
|
||||||
$this->blowGroupCache($blowLast);
|
$this->blowGroupCache($blowLast);
|
||||||
$this->blowConversationCache($blowLast);
|
$this->blowConversationCache($blowLast);
|
||||||
|
$profile = Profile::staticGet($this->profile_id);
|
||||||
|
$profile->blowNoticeCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
function blowConversationCache($blowLast=false)
|
function blowConversationCache($blowLast=false)
|
||||||
|
|
|
@ -337,4 +337,132 @@ class Profile extends Memcached_DataObject
|
||||||
|
|
||||||
return $profile;
|
return $profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function subscriptionCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
|
||||||
|
if (!empty($c)) {
|
||||||
|
$cnt = $c->get(common_cache_key('profile:subscription_count:'.$this->id));
|
||||||
|
if (is_integer($cnt)) {
|
||||||
|
return (int) $cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub = new Subscription();
|
||||||
|
$sub->subscriber = $this->id;
|
||||||
|
|
||||||
|
$cnt = (int) $sub->count('distinct subscribed');
|
||||||
|
|
||||||
|
$cnt = ($cnt > 0) ? $cnt - 1 : $cnt;
|
||||||
|
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->set(common_cache_key('profile:subscription_count:'.$this->id), $cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
common_debug("subscriptionCount == $cnt");
|
||||||
|
return $cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscriberCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
if (!empty($c)) {
|
||||||
|
$cnt = $c->get(common_cache_key('profile:subscriber_count:'.$this->id));
|
||||||
|
if (is_integer($cnt)) {
|
||||||
|
return (int) $cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sub = new Subscription();
|
||||||
|
$sub->subscribed = $this->id;
|
||||||
|
|
||||||
|
$cnt = (int) $sub->count('distinct subscriber');
|
||||||
|
|
||||||
|
$cnt = ($cnt > 0) ? $cnt - 1 : $cnt;
|
||||||
|
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->set(common_cache_key('profile:subscriber_count:'.$this->id), $cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
common_debug("subscriberCount == $cnt");
|
||||||
|
return $cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
function faveCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
if (!empty($c)) {
|
||||||
|
$cnt = $c->get(common_cache_key('profile:fave_count:'.$this->id));
|
||||||
|
if (is_integer($cnt)) {
|
||||||
|
return (int) $cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$faves = new Fave();
|
||||||
|
$faves->user_id = $this->id;
|
||||||
|
$cnt = (int) $faves->count('distinct notice_id');
|
||||||
|
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->set(common_cache_key('profile:fave_count:'.$this->id), $cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
common_debug("faveCount == $cnt");
|
||||||
|
return $cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
function noticeCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
|
||||||
|
if (!empty($c)) {
|
||||||
|
$cnt = $c->get(common_cache_key('profile:notice_count:'.$this->id));
|
||||||
|
if (is_integer($cnt)) {
|
||||||
|
return (int) $cnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$notices = new Notice();
|
||||||
|
$notices->profile_id = $this->id;
|
||||||
|
$cnt = (int) $notices->count('distinct id');
|
||||||
|
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->set(common_cache_key('profile:notice_count:'.$this->id), $cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
common_debug("noticeCount == $cnt");
|
||||||
|
return $cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
function blowSubscriberCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->delete(common_cache_key('profile:subscriber_count:'.$this->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function blowSubscriptionCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->delete(common_cache_key('profile:subscription_count:'.$this->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function blowFaveCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->delete(common_cache_key('profile:fave_count:'.$this->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function blowNoticeCount()
|
||||||
|
{
|
||||||
|
$c = common_memcache();
|
||||||
|
if (!empty($c)) {
|
||||||
|
$c->delete(common_cache_key('profile:notice_count:'.$this->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,6 +494,8 @@ class User extends Memcached_DataObject
|
||||||
$cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id));
|
$cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id));
|
||||||
$cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id.';last'));
|
$cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id.';last'));
|
||||||
}
|
}
|
||||||
|
$profile = $this->getProfile();
|
||||||
|
$profile->blowFaveCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelfTags()
|
function getSelfTags()
|
||||||
|
|
|
@ -97,18 +97,11 @@ class StatsCommand extends Command
|
||||||
{
|
{
|
||||||
function execute($channel)
|
function execute($channel)
|
||||||
{
|
{
|
||||||
|
$profile = $this->user->getProfile();
|
||||||
|
|
||||||
$subs = new Subscription();
|
$subs_count = $profile->subscriptionCount();
|
||||||
$subs->subscriber = $this->user->id;
|
$subbed_count = $profile->subscriberCount();
|
||||||
$subs_count = (int) $subs->count() - 1;
|
$notice_count = $profile->noticeCount();
|
||||||
|
|
||||||
$subbed = new Subscription();
|
|
||||||
$subbed->subscribed = $this->user->id;
|
|
||||||
$subbed_count = (int) $subbed->count() - 1;
|
|
||||||
|
|
||||||
$notices = new Notice();
|
|
||||||
$notices->profile_id = $this->user->id;
|
|
||||||
$notice_count = (int) $notices->count();
|
|
||||||
|
|
||||||
$channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
|
$channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
|
||||||
"Subscribers: %2\$s\n".
|
"Subscribers: %2\$s\n".
|
||||||
|
|
|
@ -282,6 +282,39 @@ if (function_exists('date_default_timezone_set')) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPlugin($name, $attrs = null)
|
||||||
|
{
|
||||||
|
$name = ucfirst($name);
|
||||||
|
$pluginclass = "{$name}Plugin";
|
||||||
|
|
||||||
|
if (!class_exists($pluginclass)) {
|
||||||
|
|
||||||
|
$files = array("local/plugins/{$pluginclass}.php",
|
||||||
|
"local/plugins/{$name}/{$pluginclass}.php",
|
||||||
|
"local/{$pluginclass}.php",
|
||||||
|
"local/{$name}/{$pluginclass}.php",
|
||||||
|
"plugins/{$pluginclass}.php",
|
||||||
|
"plugins/{$name}/{$pluginclass}.php");
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$fullpath = INSTALLDIR.'/'.$file;
|
||||||
|
if (@file_exists($fullpath)) {
|
||||||
|
include_once($fullpath);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$inst = new $pluginclass();
|
||||||
|
|
||||||
|
if (!empty($attrs)) {
|
||||||
|
foreach ($attrs as $aname => $avalue) {
|
||||||
|
$inst->$aname = $avalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $inst;
|
||||||
|
}
|
||||||
|
|
||||||
// From most general to most specific:
|
// From most general to most specific:
|
||||||
// server-wide, then vhost-wide, then for a path,
|
// server-wide, then vhost-wide, then for a path,
|
||||||
// finally for a dir (usually only need one of the last two).
|
// finally for a dir (usually only need one of the last two).
|
||||||
|
|
|
@ -163,18 +163,9 @@ class ProfileAction extends OwnerDesignAction
|
||||||
|
|
||||||
function showStatistics()
|
function showStatistics()
|
||||||
{
|
{
|
||||||
// XXX: WORM cache this
|
$subs_count = $this->profile->subscriptionCount();
|
||||||
$subs = new Subscription();
|
$subbed_count = $this->profile->subscriberCount();
|
||||||
$subs->subscriber = $this->profile->id;
|
$notice_count = $this->profile->noticeCount();
|
||||||
$subs_count = (int) $subs->count() - 1;
|
|
||||||
|
|
||||||
$subbed = new Subscription();
|
|
||||||
$subbed->subscribed = $this->profile->id;
|
|
||||||
$subbed_count = (int) $subbed->count() - 1;
|
|
||||||
|
|
||||||
$notices = new Notice();
|
|
||||||
$notices->profile_id = $this->profile->id;
|
|
||||||
$notice_count = (int) $notices->count();
|
|
||||||
|
|
||||||
$this->elementStart('div', array('id' => 'entity_statistics',
|
$this->elementStart('div', array('id' => 'entity_statistics',
|
||||||
'class' => 'section'));
|
'class' => 'section'));
|
||||||
|
@ -199,7 +190,7 @@ class ProfileAction extends OwnerDesignAction
|
||||||
array('nickname' => $this->profile->nickname))),
|
array('nickname' => $this->profile->nickname))),
|
||||||
_('Subscriptions'));
|
_('Subscriptions'));
|
||||||
$this->elementEnd('dt');
|
$this->elementEnd('dt');
|
||||||
$this->element('dd', null, (is_int($subs_count)) ? $subs_count : '0');
|
$this->element('dd', null, $subs_count);
|
||||||
$this->elementEnd('dl');
|
$this->elementEnd('dl');
|
||||||
|
|
||||||
$this->elementStart('dl', 'entity_subscribers');
|
$this->elementStart('dl', 'entity_subscribers');
|
||||||
|
@ -208,12 +199,12 @@ class ProfileAction extends OwnerDesignAction
|
||||||
array('nickname' => $this->profile->nickname))),
|
array('nickname' => $this->profile->nickname))),
|
||||||
_('Subscribers'));
|
_('Subscribers'));
|
||||||
$this->elementEnd('dt');
|
$this->elementEnd('dt');
|
||||||
$this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
|
$this->element('dd', 'subscribers', $subbed_count);
|
||||||
$this->elementEnd('dl');
|
$this->elementEnd('dl');
|
||||||
|
|
||||||
$this->elementStart('dl', 'entity_notices');
|
$this->elementStart('dl', 'entity_notices');
|
||||||
$this->element('dt', null, _('Notices'));
|
$this->element('dt', null, _('Notices'));
|
||||||
$this->element('dd', null, (is_int($notice_count)) ? $notice_count : '0');
|
$this->element('dd', null, $notice_count);
|
||||||
$this->elementEnd('dl');
|
$this->elementEnd('dl');
|
||||||
|
|
||||||
$this->elementEnd('div');
|
$this->elementEnd('div');
|
||||||
|
|
|
@ -94,8 +94,8 @@ class ProfileSection extends Section
|
||||||
$profile->fullname :
|
$profile->fullname :
|
||||||
$profile->nickname));
|
$profile->nickname));
|
||||||
$this->out->element('span', 'fn nickname', $profile->nickname);
|
$this->out->element('span', 'fn nickname', $profile->nickname);
|
||||||
$this->out->elementEnd('span');
|
|
||||||
$this->out->elementEnd('a');
|
$this->out->elementEnd('a');
|
||||||
|
$this->out->elementEnd('span');
|
||||||
$this->out->elementEnd('td');
|
$this->out->elementEnd('td');
|
||||||
if ($profile->value) {
|
if ($profile->value) {
|
||||||
$this->out->element('td', 'value', $profile->value);
|
$this->out->element('td', 'value', $profile->value);
|
||||||
|
|
13
lib/subs.php
13
lib/subs.php
|
@ -44,7 +44,6 @@ function subs_subscribe_user($user, $other_nickname)
|
||||||
|
|
||||||
function subs_subscribe_to($user, $other)
|
function subs_subscribe_to($user, $other)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($user->isSubscribed($other)) {
|
if ($user->isSubscribed($other)) {
|
||||||
return _('Already subscribed!.');
|
return _('Already subscribed!.');
|
||||||
}
|
}
|
||||||
|
@ -60,12 +59,16 @@ function subs_subscribe_to($user, $other)
|
||||||
|
|
||||||
subs_notify($other, $user);
|
subs_notify($other, $user);
|
||||||
|
|
||||||
$cache = common_memcache();
|
$cache = common_memcache();
|
||||||
|
|
||||||
if ($cache) {
|
if ($cache) {
|
||||||
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
|
$profile->blowSubscriptionsCount();
|
||||||
|
$other->blowSubscribersCount();
|
||||||
|
|
||||||
if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
|
if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
|
||||||
if (!$other->subscribeTo($user)) {
|
if (!$other->subscribeTo($user)) {
|
||||||
|
@ -117,7 +120,6 @@ function subs_unsubscribe_user($user, $other_nickname)
|
||||||
|
|
||||||
function subs_unsubscribe_to($user, $other)
|
function subs_unsubscribe_to($user, $other)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!$user->isSubscribed($other))
|
if (!$user->isSubscribed($other))
|
||||||
return _('Not subscribed!.');
|
return _('Not subscribed!.');
|
||||||
|
|
||||||
|
@ -139,6 +141,11 @@ function subs_unsubscribe_to($user, $other)
|
||||||
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
|
$profile->blowSubscriptionsCount();
|
||||||
|
$other->blowSubscribersCount();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ class TwitterapiAction extends Action
|
||||||
|
|
||||||
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
$twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
|
||||||
$twitter_user['protected'] = false; # not supported by Laconica yet
|
$twitter_user['protected'] = false; # not supported by Laconica yet
|
||||||
$twitter_user['followers_count'] = $this->count_subscriptions($profile);
|
$twitter_user['followers_count'] = $profile->subscriberCount();
|
||||||
|
|
||||||
// To be supported soon...
|
// To be supported soon...
|
||||||
$twitter_user['profile_background_color'] = '';
|
$twitter_user['profile_background_color'] = '';
|
||||||
|
@ -98,17 +98,11 @@ class TwitterapiAction extends Action
|
||||||
$twitter_user['profile_sidebar_fill_color'] = '';
|
$twitter_user['profile_sidebar_fill_color'] = '';
|
||||||
$twitter_user['profile_sidebar_border_color'] = '';
|
$twitter_user['profile_sidebar_border_color'] = '';
|
||||||
|
|
||||||
$subbed = DB_DataObject::factory('subscription');
|
$twitter_user['friends_count'] = $profile->subscriptionCount();
|
||||||
$subbed->subscriber = $profile->id;
|
|
||||||
$subbed_count = (int) $subbed->count() - 1;
|
|
||||||
$twitter_user['friends_count'] = (is_int($subbed_count)) ? $subbed_count : 0;
|
|
||||||
|
|
||||||
$twitter_user['created_at'] = $this->date_twitter($profile->created);
|
$twitter_user['created_at'] = $this->date_twitter($profile->created);
|
||||||
|
|
||||||
$faves = DB_DataObject::factory('fave');
|
$twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
|
||||||
$faves->user_id = $user->id;
|
|
||||||
$faves_count = (int) $faves->count();
|
|
||||||
$twitter_user['favourites_count'] = $faves_count; // British spelling!
|
|
||||||
|
|
||||||
// Need to pull up the user for some of this
|
// Need to pull up the user for some of this
|
||||||
$user = User::staticGet($profile->id);
|
$user = User::staticGet($profile->id);
|
||||||
|
@ -129,11 +123,7 @@ class TwitterapiAction extends Action
|
||||||
$twitter_user['profile_background_image_url'] = '';
|
$twitter_user['profile_background_image_url'] = '';
|
||||||
$twitter_user['profile_background_tile'] = false;
|
$twitter_user['profile_background_tile'] = false;
|
||||||
|
|
||||||
$notices = DB_DataObject::factory('notice');
|
$twitter_user['statuses_count'] = $profile->noticeCount();
|
||||||
$notices->profile_id = $profile->id;
|
|
||||||
$notice_count = (int) $notices->count();
|
|
||||||
|
|
||||||
$twitter_user['statuses_count'] = (is_int($notice_count)) ? $notice_count : 0;
|
|
||||||
|
|
||||||
// Is the requesting user following this user?
|
// Is the requesting user following this user?
|
||||||
$twitter_user['following'] = false;
|
$twitter_user['following'] = false;
|
||||||
|
@ -396,7 +386,7 @@ class TwitterapiAction extends Action
|
||||||
$enclosure = $entry['enclosures'][0];
|
$enclosure = $entry['enclosures'][0];
|
||||||
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
|
$this->element('enclosure', array('url'=>$enclosure['url'],'type'=>$enclosure['mimetype'],'length'=>$enclosure['size']), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elementEnd('item');
|
$this->elementEnd('item');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user