summaryrefslogtreecommitdiff
path: root/lib/subs.php
diff options
context:
space:
mode:
authorEvan Prodromou <git@evanprodromou.name>2009-01-23 08:58:31 +0100
committerEvan Prodromou <git@evanprodromou.name>2009-01-23 08:58:31 +0100
commita7c85bebd5be9ea019a8c80d74730d7eb28d4651 (patch)
treec3fdf9575a342624bc71aad1d439ae73594f558c /lib/subs.php
parent4873277b58941ae6ec16543f437f4267ccab5ac0 (diff)
parent7aa496cd8a939960eeaf79f3397f6fe94097e047 (diff)
Merge branch 'master' of /var/www/mublog
Conflicts: actions/api.php actions/deletenotice.php actions/recoverpassword.php actions/remotesubscribe.php actions/tag.php actions/tagrss.php actions/twitapiaccount.php actions/twitapiusers.php classes/Notice.php classes/User.php lib/common.php lib/language.php lib/subs.php lib/twitterapi.php lib/util.php scripts/inbox_users.php scripts/update_translations.php Merged development trunk into laconica head. woohoo!
Diffstat (limited to 'lib/subs.php')
-rw-r--r--lib/subs.php101
1 files changed, 54 insertions, 47 deletions
diff --git a/lib/subs.php b/lib/subs.php
index 483b2f78e..0e7b9ded5 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -25,15 +25,16 @@ require_once('XMPPHP/XMPP.php');
Returns true or an error message.
*/
-function subs_subscribe_user($user, $other_nickname) {
+function subs_subscribe_user($user, $other_nickname)
+{
- $other = User::staticGet('nickname', $other_nickname);
+ $other = User::staticGet('nickname', $other_nickname);
- if (!$other) {
- return _('No such user.');
- }
+ if (!$other) {
+ return _('No such user.');
+ }
- return subs_subscribe_to($user, $other);
+ return subs_subscribe_to($user, $other);
}
/* Subscribe user $user to other user $other.
@@ -41,90 +42,96 @@ function subs_subscribe_user($user, $other_nickname) {
* Because the other way is quite a bit more complicated.
*/
-function subs_subscribe_to($user, $other) {
+function subs_subscribe_to($user, $other)
+{
- if ($user->isSubscribed($other)) {
- return _('Already subscribed!');
- }
+ if ($user->isSubscribed($other)) {
+ return _('Already subscribed!.');
+ }
if ($other->hasBlocked($user)) {
- return _('User has blocked you.');
+ return _('User has blocked you.');
}
- if (!$user->subscribeTo($other)) {
- return _('Could not subscribe.');
- return;
- }
+ if (!$user->subscribeTo($other)) {
+ return _('Could not subscribe.');
+ return;
+ }
subs_notify($other, $user);
- $cache = common_memcache();
+ $cache = common_memcache();
if ($cache) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
}
- if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
- if (!$other->subscribeTo($user)) {
- return _('Could not subscribe other to you.');
- }
+
+ if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
+ if (!$other->subscribeTo($user)) {
+ return _('Could not subscribe other to you.');
+ }
$cache = common_memcache();
if ($cache) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $other->id));
}
- subs_notify($user, $other);
- }
+ subs_notify($user, $other);
+ }
- return true;
+ return true;
}
-function subs_notify($listenee, $listener) {
- # XXX: add other notifications (Jabber, SMS) here
- # XXX: queue this and handle it offline
- # XXX: Whatever happens, do it in Twitter-like API, too
- subs_notify_email($listenee, $listener);
+function subs_notify($listenee, $listener)
+{
+ # XXX: add other notifications (Jabber, SMS) here
+ # XXX: queue this and handle it offline
+ # XXX: Whatever happens, do it in Twitter-like API, too
+ subs_notify_email($listenee, $listener);
}
-function subs_notify_email($listenee, $listener) {
- mail_subscribe_notify($listenee, $listener);
+function subs_notify_email($listenee, $listener)
+{
+ mail_subscribe_notify($listenee, $listener);
}
/* Unsubscribe $user from nickname $other_nickname
Returns true or an error message.
*/
-function subs_unsubscribe_user($user, $other_nickname) {
+function subs_unsubscribe_user($user, $other_nickname)
+{
- $other = User::staticGet('nickname', $other_nickname);
+ $other = User::staticGet('nickname', $other_nickname);
- if (!$other) {
- return _('No such user.');
- }
+ if (!$other) {
+ return _('No such user.');
+ }
- return subs_unsubscribe_to($user, $other->getProfile());
+ return subs_unsubscribe_to($user, $other->getProfile());
}
/* Unsubscribe user $user from profile $other
* NB: other can be a remote user. */
-function subs_unsubscribe_to($user, $other) {
+function subs_unsubscribe_to($user, $other)
+{
- if (!$user->isSubscribed($other))
- return _('Not subscribed!');
+ if (!$user->isSubscribed($other))
+ return _('Not subscribed!.');
- $sub = DB_DataObject::factory('subscription');
+ $sub = DB_DataObject::factory('subscription');
- $sub->subscriber = $user->id;
- $sub->subscribed = $other->id;
+ $sub->subscriber = $user->id;
+ $sub->subscribed = $other->id;
- $sub->find(true);
+ $sub->find(true);
- // note we checked for existence above
+ // note we checked for existence above
- if (!$sub->delete())
- return _('Couldn\'t delete subscription.');
+ if (!$sub->delete())
+ return _('Couldn\'t delete subscription.');
$cache = common_memcache();
@@ -132,6 +139,6 @@ function subs_unsubscribe_to($user, $other) {
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
}
- return true;
+ return true;
}