/** * Stops following an user. * * @return array */ public function unfollow() { $follow = UserFollow::getFollow(WCF::getUser()->userID, $this->parameters['data']['userID']); if ($follow->followID) { $followEditor = new UserFollowEditor($follow); $followEditor->delete(); // remove activity event UserActivityEventHandler::getInstance()->removeEvents('com.woltlab.wcf.user.recentActivityEvent.follow', array($this->parameters['data']['userID'])); } // reset storage UserStorageHandler::getInstance()->reset(array($this->parameters['data']['userID']), 'followerUserIDs'); UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'followingUserIDs'); return array('following' => 0); }
/** * Executes this action. * * @param \wcf\form\LoginForm $eventObj Object firing the event * @param string $className class name of $eventObj * @param string $eventName name of the event fired * @param array &$parameters given parameters */ public function execute($eventObj, $className, $eventName, array &$parameters) { $sql = "SELECT\tuserID\n\t\t\tFROM\t" . UserFollow::getDatabaseTableName() . "\n\t\t\tWHERE\tfollowUserID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array(WCF::getUser()->userID)); // collect users $userIDs = array(); while ($row = $statement->fetchArray()) { $userIDs[] = $row['userID']; } // send push notifications if ($userIDs) { PushHandler::getInstance()->sendDeferredMessage('com.mrk.wcf.loginNotification', $userIDs, array('username' => WCF::getUser()->username)); } }