123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class FollowEveryonePlugin extends Plugin
- {
- const PLUGIN_VERSION = '2.0.0';
-
- public function onEndUserRegister(Profile $profile)
- {
- $otherUser = new User();
- $otherUser->whereAdd('id != ' . $profile->id);
- if ($otherUser->find()) {
- while ($otherUser->fetch()) {
- $otherProfile = $otherUser->getProfile();
- try {
- if (User_followeveryone_prefs::followEveryone($otherUser->id)) {
- Subscription::start($otherProfile, $profile);
- }
- Subscription::start($profile, $otherProfile);
- } catch (Exception $e) {
- common_log(LOG_WARNING, $e->getMessage());
- continue;
- }
- }
- }
- $ufep = new User_followeveryone_prefs();
- $ufep->user_id = $profile->id;
- $ufep->followeveryone = true;
- $ufep->insert();
- return true;
- }
-
- function onCheckSchema()
- {
- $schema = Schema::get();
-
- $schema->ensureTable('user_followeveryone_prefs', User_followeveryone_prefs::schemaDef());
- return true;
- }
-
- function onEndProfileFormData($action)
- {
- $user = common_current_user();
- $action->elementStart('li');
-
- $action->checkbox('followeveryone', _m('Follow everyone'),
- ($action->arg('followeveryone')) ?
- $action->arg('followeveryone') :
- User_followeveryone_prefs::followEveryone($user->id));
- $action->elementEnd('li');
- return true;
- }
-
- function onEndProfileSaveForm($action)
- {
- $user = common_current_user();
- User_followeveryone_prefs::savePref($user->id,
- $action->boolean('followeveryone'));
- return true;
- }
-
- function onPluginVersion(array &$versions)
- {
- $versions[] = array('name' => 'FollowEveryone',
- 'version' => self::PLUGIN_VERSION,
- 'author' => 'Evan Prodromou',
- 'homepage' => 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/FollowEveryone',
- 'rawdescription' =>
-
- _m('New users follow everyone at registration and are followed in return.'));
- return true;
- }
- }
|