summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-12-03 17:06:58 -0800
committerZach Copley <zach@status.net>2009-12-03 17:06:58 -0800
commitaef4cc0a59276938f0f0aec4d67374f578f2117a (patch)
tree46b429f939a680926fc01fe2defed6e037985ec9 /classes
parentc89b10ffe4adb1df724b6a7c5c31b42c7dd3376b (diff)
Make it impossible to block (and thus unsubscribe from your
self-subscription) via the API. Additionally, make it impossible to block yourself or unsubscribe from yourself, period. I also made User use the subs.php helper function for unsubscribing during a block. Hopefully, these changes will get rid of the problem of people accidentally deleting their self-subscriptions once and for all (knock on wood).
Diffstat (limited to 'classes')
-rw-r--r--classes/User.php36
1 files changed, 27 insertions, 9 deletions
diff --git a/classes/User.php b/classes/User.php
index f905ea2b7..4838fe1c7 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -502,6 +502,19 @@ class User extends Memcached_DataObject
{
// Add a new block record
+ // no blocking (and thus unsubbing from) yourself
+
+ if ($this->id == $other->id) {
+ common_log(LOG_WARNING,
+ sprintf(
+ "Profile ID %d (%s) tried to block his or herself.",
+ $profile->id,
+ $profile->nickname
+ )
+ );
+ return false;
+ }
+
$block = new Profile_block();
// Begin a transaction
@@ -520,15 +533,20 @@ class User extends Memcached_DataObject
// Cancel their subscription, if it exists
- $sub = Subscription::pkeyGet(array('subscriber' => $other->id,
- 'subscribed' => $this->id));
-
- if ($sub) {
- $result = $sub->delete();
- if (!$result) {
- common_log_db_error($sub, 'DELETE', __FILE__);
- return false;
- }
+ $result = subs_unsubscribe_to($this, $other);
+
+ if ($result !== true) {
+ common_log(LOG_WARNING,
+ sprintf(
+ "Error trying to unsubscribe profile ID %d (%s) from user ID %d (%s): %s",
+ $other->id,
+ $other->nickname,
+ $this->id,
+ $this->nickname,
+ $result
+ )
+ );
+ return false;
}
$block->query('COMMIT');