コード例 #1
0
ファイル: User.php プロジェクト: stevertiqo/StatusNet
 function block($other)
 {
     // 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 themself.", $this->id, $this->nickname));
         return false;
     }
     $block = new Profile_block();
     // Begin a transaction
     $block->query('BEGIN');
     $block->blocker = $this->id;
     $block->blocked = $other->id;
     $result = $block->insert();
     if (!$result) {
         common_log_db_error($block, 'INSERT', __FILE__);
         return false;
     }
     $self = $this->getProfile();
     if (Subscription::exists($other, $self)) {
         Subscription::cancel($other, $self);
     }
     if (Subscription::exists($self, $other)) {
         Subscription::cancel($self, $other);
     }
     $block->query('COMMIT');
     return true;
 }
コード例 #2
0
ファイル: User.php プロジェクト: Br3nda/laconica
 function block($other)
 {
     # Add a new block record
     $block = new Profile_block();
     # Begin a transaction
     $block->query('BEGIN');
     $block->blocker = $this->id;
     $block->blocked = $other->id;
     $result = $block->insert();
     if (!$result) {
         common_log_db_error($block, 'INSERT', __FILE__);
         return false;
     }
     # 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;
         }
     }
     $block->query('COMMIT');
     return true;
 }