123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- if (!defined('STATUSNET')) { exit(1); }
- class ForceGroupPlugin extends Plugin
- {
-
- public $post = array();
-
- public $join = array();
-
- function onStartNoticeDistribute($notice)
- {
- $profile = $notice->getProfile();
- $isRemote = !(User::getKV('id', $profile->id));
- if ($isRemote) {
-
- return true;
- }
- foreach ($this->post as $nickname) {
- $group = User_group::getForNickname($nickname);
- if ($group && $profile->isMember($group)) {
- $notice->addToGroupInbox($group);
- }
- }
- return true;
- }
- public function onEndUserRegister(Profile $profile)
- {
- foreach ($this->join as $nickname) {
- $group = User_group::getForNickname($nickname);
- if ($group && !$profile->isMember($group)) {
- try {
- $profile->joinGroup($group);
- } catch (Exception $e) {
-
-
- throw new ServerException(sprintf(_m('Could not join user %1$s to group %2$s.'),
- $profile->nickname, $group->nickname));
- }
- }
- }
- }
-
- function onPluginVersion(&$versions)
- {
- $url = 'http://status.net/wiki/Plugin:ForceGroup';
- $versions[] = array('name' => 'ForceGroup',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Brion Vibber',
- 'homepage' => $url,
- 'rawdescription' =>
-
- _m('Allows forced group memberships and forces all notices to appear in groups that users were forced in.'));
- return true;
- }
- }
|