pass_subscribe(); } } catch (Exception $ex) { Log::record("{$ex->getMessage()} member_id = {$member_id}",Log::ERR); } } static public function onRegister($user) { try { if(!relation\mem_relation::use_frineds_relation) { $relation = new relation\mem_relation($user); $relation->pass_subscribe(); } } catch (Exception $ex) { Log::record("{$ex->getMessage()} member_id = {$user}",Log::ERR); } } static public function onUpContacts($member_id,$contacts) { try { $relation = new relation\mem_relation($member_id); $relation->subscribe_contacts($contacts); } catch (Exception $ex) { Log::record("{$ex->getMessage()} member_id = {$member_id}",Log::ERR); } } static public function onInvite($me_id,$user_id) { try { if($me_id == $user_id) { return false; } $relation = new relation\mem_relation($me_id); return $relation->invite($user_id); } catch (Exception $ex) { Log::record("onInvite: {$ex->getMessage()} param = {$me_id},{$user_id}",Log::ERR); return false; } } static public function subscribed($me_id,$someone_id) { try { $me_id = intval($me_id); $someone_id = intval($someone_id); if($me_id == $someone_id) { return false; } $relation = new relation\mem_relation($me_id); return $relation->is_follower($someone_id); } catch (Exception $ex) { Log::record("onInvite: {$ex->getMessage()} param = {$me_id},{$someone_id}"); return false; } } static public function onSubscribe($me_id,$someone_id) { try { $me_id = intval($me_id); $someone_id = intval($someone_id); if($me_id == $someone_id) { return false; } $relation = new relation\mem_relation($me_id); $ret = $relation->subscribe($someone_id); if($ret == true) { $someone_relation = new relation\mem_relation($someone_id); $someone_relation->pass_subscribe(); $publisher = new message\publisher(); $publisher->add_follow($someone_id,[$me_id]); $minfo = new member_info($me_id); push_helper::notice_subscribe($someone_id,$minfo); } return $ret; } catch (Exception $ex) { Log::record("onInvite: {$ex->getMessage()} param = {$me_id},{$someone_id}",Log::ERR); return false; } } static public function onAccept($me_id,$someone_id) { try { $relation = new relation\mem_relation($me_id); return $relation->pass_onesub($someone_id); } catch (Exception $ex) { Log::record("onAccept: {$ex->getMessage()} param = {$me_id},{$someone_id}",Log::ERR); return false; } } static public function onUnSubscribe($me_id,$someone_id) { try { if($me_id == $someone_id) { return false; } $relation = new relation\mem_relation($me_id); $ret = $relation->unsubscribe($someone_id); if($ret == true) { $publisher = new message\publisher(); $publisher->del_follow($someone_id,[$me_id]); } return $ret; } catch (Exception $ex) { $msg = $ex->getMessage(); Log::record("onInvite: {$msg} param = {$me_id},{$someone_id}"); return false; } } //关注我的 static public function subscriber($member_id) { try { $relation = new relation\mem_relation($member_id); return $relation->subscriber(); } catch (Exception $ex) { $msg = $ex->getMessage(); Log::record("{$msg} member_id = {$member_id}"); return array(); } } static public function follower($member_id) { try { $relation = new relation\mem_relation($member_id); return $relation->follower(); } catch (Exception $ex) { $msg = $ex->getMessage(); Log::record("{$msg} member_id = {$member_id}"); return []; } } static public function friends($member_id) { try { $relation = new relation\mem_relation($member_id); $subscriber = $relation->subscriber(); $follower = $relation->follower(); return array_merge($subscriber,$follower); } catch (Exception $ex) { $msg = $ex->getMessage(); Log::record("{$msg} member_id = {$member_id}"); return []; } } static public function is_follow($me,$other) { try { $relation = new relation\mem_relation($me); return $relation->is_follower($other); } catch (Exception $ex) { $msg = $ex->getMessage(); Log::record("is_follow {$msg} member_id = {$me}"); return false; } } static public function is_friends($left,$right) { try{ $l = new relation\mem_relation($left); $r = new relation\mem_relation($right); return $l->is_friends($right) && $r->is_friends($left); } catch (Exception $ex) { Log::record(__METHOD__ . " {$ex->getMessage()}",Log::ERR); return false; } } }