123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class OStatusGroupAction extends OStatusSubAction
- {
- protected $profile_uri;
- protected $oprofile;
- function validateRemoteProfile()
- {
- if (!$this->oprofile->isGroup()) {
-
- $target = common_local_url('ostatussub', array(), array('profile' => $this->profile_uri));
- common_redirect($target, 303);
- }
- }
-
- function showInputForm()
- {
- $this->elementStart('form', array('method' => 'post',
- 'id' => 'form_ostatus_sub',
- 'class' => 'form_settings',
- 'action' => $this->selfLink()));
- $this->hidden('token', common_session_token());
- $this->elementStart('fieldset', array('id' => 'settings_feeds'));
- $this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->input('profile',
-
- _m('Join group'),
- $this->profile_uri,
-
-
- _m("OStatus group's address, like http://example.net/group/nickname."));
- $this->elementEnd('li');
- $this->elementEnd('ul');
-
- $this->submit('validate', _m('BUTTON','Continue'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
- }
-
- function preview()
- {
- $group = $this->oprofile->localGroup();
- if ($this->scoped->isMember($group)) {
- $this->element('div', array('class' => 'error'),
-
- _m('You are already a member of this group.'));
- $ok = false;
- } else {
- $ok = true;
- }
- $this->showEntity($group,
- $group->homeUrl(),
- $group->homepage_logo,
- $group->description);
- return $ok;
- }
-
- function success()
- {
- $url = common_local_url('usergroups', array('nickname' => $this->scoped->getNickname()));
- common_redirect($url, 303);
- }
-
- function saveFeed()
- {
- $group = $this->oprofile->localGroup();
- if ($this->scoped->isMember($group)) {
-
- $this->showForm(_m('Already a member!'));
- return;
- }
- try {
- $this->scoped->joinGroup($group);
- } catch (Exception $e) {
- common_log(LOG_ERR, "Exception on remote group join: " . $e->getMessage());
- common_log(LOG_ERR, $e->getTraceAsString());
-
- $this->showForm(_m('Remote group join failed!'));
- return;
- }
- $this->success();
- }
-
- function title()
- {
-
- return _m('Confirm joining remote group');
- }
-
- function getInstructions()
- {
-
- return _m('You can subscribe to groups from other supported sites. Paste the group\'s profile URI below:');
- }
- function selfLink()
- {
- return common_local_url('ostatusgroup');
- }
- }
|