static function savePref($user_id, $followEveryone) { $ufep = self::getKV('user_id', $user_id); if (empty($ufep)) { $ufep = new User_followeveryone_prefs(); $ufep->user_id = $user_id; $ufep->followeveryone = $followEveryone; $ufep->insert(); } else { $orig = clone $ufep; $ufep->followeveryone = $followEveryone; $ufep->update(); } return true; }
/** * Called when a new user is registered. * * We find all users, and try to subscribe them to the new user, and * the new user to them. Exceptions (like silenced users or whatever) * are caught, logged, and ignored. * * @param Profile &$newProfile The new user's profile * @param User &$newUser The new user * * @return boolean hook value * */ function onEndUserRegister(&$newProfile, &$newUser) { $otherUser = new User(); $otherUser->whereAdd('id != ' . $newUser->id); if ($otherUser->find()) { while ($otherUser->fetch()) { $otherProfile = $otherUser->getProfile(); try { if (User_followeveryone_prefs::followEveryone($otherUser->id)) { Subscription::start($otherProfile, $newProfile); } Subscription::start($newProfile, $otherProfile); } catch (Exception $e) { common_log(LOG_WARNING, $e->getMessage()); continue; } } } $ufep = new User_followeveryone_prefs(); $ufep->user_id = $newUser->id; $ufep->followeveryone = true; $ufep->insert(); return true; }