Esempio n. 1
0
 public function actionJoin()
 {
     // Auth users shouldn't be able to register
     if (!Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl('timeline/index'));
     }
     $form = new JoinForm();
     if (isset($_POST['JoinForm'])) {
         $form->attributes = $_POST['JoinForm'];
         // Attempt to save user's info
         if ($form->save()) {
             // Try to automagically log the user in, if we fail
             // trough just redirect them to the login page
             $model = new LoginForm();
             $model->attributes = array('username' => $form->email, 'password' => $form->password);
             if ($model->login()) {
                 // Set a success flash
                 Yii::app()->user->setFlash('success', 'You successfully registered an account');
                 $this->redirect($this->createUrl('timeline/index'));
             } else {
                 $this->redirect($this->createUrl('site/index'));
             }
         }
     }
     $this->render('join', array('user' => $form));
 }
Esempio n. 2
0
 function showGroup()
 {
     $this->out->elementStart('li', array('class' => 'profile h-card', 'id' => 'group-' . $this->group->id));
     $user = common_current_user();
     $this->out->elementStart('div', 'entity_profile');
     $logo = $this->group->stream_logo ?: User_group::defaultLogo(AVATAR_STREAM_SIZE);
     $this->out->elementStart('a', array('href' => $this->group->homeUrl(), 'class' => 'u-url p-nickname', 'rel' => 'contact group'));
     $this->out->element('img', array('src' => $logo, 'class' => 'avatar u-photo', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => $this->group->getBestName()));
     $this->out->text($this->group->getNickname());
     $this->out->elementEnd('a');
     if ($this->group->fullname) {
         $this->out->text(' ');
         $this->out->elementStart('span', 'p-name');
         $this->out->raw($this->highlight($this->group->fullname));
         $this->out->elementEnd('span');
     }
     if ($this->group->location) {
         $this->out->text(' ');
         $this->out->elementStart('span', 'label');
         $this->out->raw($this->highlight($this->group->location));
         $this->out->elementEnd('span');
     }
     if ($this->group->homepage) {
         $this->out->text(' ');
         $this->out->elementStart('a', array('href' => $this->group->homepage, 'class' => 'u-url'));
         $this->out->raw($this->highlight($this->group->homepage));
         $this->out->elementEnd('a');
     }
     if ($this->group->description) {
         $this->out->elementStart('p', 'note');
         $this->out->raw($this->highlight($this->group->description));
         $this->out->elementEnd('p');
     }
     // If we're on a list with an owner (subscriptions or subscribers)...
     if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
         $this->showOwnerControls();
     }
     $this->out->elementEnd('div');
     if ($user) {
         $this->out->elementStart('div', 'entity_actions');
         $this->out->elementStart('ul');
         $this->out->elementStart('li', 'entity_subscribe');
         // XXX: special-case for user looking at own
         // subscriptions page
         if ($user->isMember($this->group)) {
             $lf = new LeaveForm($this->out, $this->group);
             $lf->show();
         } else {
             if (!Group_block::isBlocked($this->group, $user->getProfile())) {
                 $jf = new JoinForm($this->out, $this->group);
                 $jf->show();
             }
         }
         $this->out->elementEnd('li');
         $this->out->elementEnd('ul');
         $this->out->elementEnd('div');
     }
     $this->out->elementEnd('li');
 }
Esempio n. 3
0
 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @param array $args unused
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $cur = common_current_user();
     try {
         if (Event::handle('StartLeaveGroup', array($this->group, $cur))) {
             Group_member::leave($this->group->id, $cur->id);
             Event::handle('EndLeaveGroup', array($this->group, $cur));
         }
     } catch (Exception $e) {
         // TRANS: Server error displayed when leaving a group failed in the database.
         // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
         $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $cur->nickname, $this->group->nickname));
         return;
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for leave group page after leaving.
         $this->element('title', null, sprintf(_m('TITLE', '%1$s left group %2$s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $jf = new JoinForm($this, $this->group);
         $jf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
 function showActions()
 {
     $cur = common_current_user();
     $this->out->elementStart('div', 'entity_actions');
     // TRANS: Group actions header (h2). Text hidden by default.
     $this->out->element('h2', null, _('Group actions'));
     $this->out->elementStart('ul');
     if (Event::handle('StartGroupActionsList', array($this, $this->group))) {
         $this->out->elementStart('li', 'entity_subscribe');
         if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
             if ($cur) {
                 $profile = $cur->getProfile();
                 if ($profile->isMember($this->group)) {
                     $lf = new LeaveForm($this->out, $this->group);
                     $lf->show();
                 } else {
                     if ($profile->isPendingMember($this->group)) {
                         $cf = new CancelGroupForm($this->out, $this->group);
                         $cf->show();
                     } else {
                         if (!Group_block::isBlocked($this->group, $profile)) {
                             $jf = new JoinForm($this->out, $this->group);
                             $jf->show();
                         }
                     }
                 }
             }
             Event::handle('EndGroupSubscribe', array($this, $this->group));
         }
         $this->out->elementEnd('li');
         if ($cur && $cur->hasRight(Right::DELETEGROUP)) {
             $this->out->elementStart('li', 'entity_delete');
             $df = new DeleteGroupForm($this->out, $this->group);
             $df->show();
             $this->out->elementEnd('li');
         }
         Event::handle('EndGroupActionsList', array($this, $this->group));
     }
     $this->out->elementEnd('ul');
     $this->out->elementEnd('div');
 }
Esempio n. 5
0
 function showActions()
 {
     $cur = common_current_user();
     $this->out->elementStart('div', 'entity_actions');
     // TRANS: Group actions header (h2). Text hidden by default.
     $this->out->element('h2', null, _('Group actions'));
     $this->out->elementStart('ul');
     if (Event::handle('StartGroupActionsList', array($this, $this->group))) {
         $this->out->elementStart('li', 'entity_subscribe');
         if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
             if ($cur) {
                 $profile = $cur->getProfile();
                 if ($profile->isMember($this->group)) {
                     $lf = new LeaveForm($this->out, $this->group);
                     $lf->show();
                 } else {
                     if ($profile->isPendingMember($this->group)) {
                         $cf = new CancelGroupForm($this->out, $this->group);
                         $cf->show();
                     } else {
                         if (!Group_block::isBlocked($this->group, $profile)) {
                             $jf = new JoinForm($this->out, $this->group);
                             $jf->show();
                         }
                     }
                 }
             }
             Event::handle('EndGroupSubscribe', array($this, $this->group));
         }
         $this->out->elementEnd('li');
         if ($cur && $cur->isAdmin($this->group)) {
             $this->out->elementStart('li', 'entity_edit');
             $this->out->element('a', array('href' => common_local_url('editgroup', array('nickname' => $this->group->nickname)), 'title' => sprintf(_m('TOOLTIP', 'Edit %s group properties'), $this->group->nickname)), _m('BUTTON', 'Edit'));
             $this->out->elementEnd('li');
             $this->out->elementStart('li', 'entity_edit');
             $this->out->element('a', array('href' => common_local_url('grouplogo', array('nickname' => $this->group->nickname)), 'title' => sprintf(_m('TOOLTIP', 'Add or edit %s logo'), $this->group->nickname)), _m('MENU', 'Logo'));
             $this->out->elementEnd('li');
         }
         if ($cur && $cur->hasRight(Right::DELETEGROUP)) {
             $this->out->elementStart('li', 'entity_delete');
             $df = new DeleteGroupForm($this->out, $this->group);
             $df->show();
             $this->out->elementEnd('li');
         }
         Event::handle('EndGroupActionsList', array($this, $this->group));
     }
     $this->out->elementEnd('ul');
     $this->out->elementEnd('div');
 }
Esempio n. 6
0
 /**
  * Show the group profile
  *
  * Information about the group
  *
  * @return void
  */
 function showGroupProfile()
 {
     $this->elementStart('div', 'entity_profile vcard author');
     $this->element('h2', null, _('Group profile'));
     $this->elementStart('dl', 'entity_depiction');
     $this->element('dt', null, _('Avatar'));
     $this->elementStart('dd');
     $logo = $this->group->homepage_logo ? $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
     $this->element('img', array('src' => $logo, 'class' => 'photo avatar', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $this->group->nickname));
     $this->elementEnd('dd');
     $this->elementEnd('dl');
     $this->elementStart('dl', 'entity_nickname');
     $this->element('dt', null, _('Nickname'));
     $this->elementStart('dd');
     $hasFN = $this->group->fullname ? 'nickname url uid' : 'fn org nickname url uid';
     $this->element('a', array('href' => $this->group->homeUrl(), 'rel' => 'me', 'class' => $hasFN), $this->group->nickname);
     $this->elementEnd('dd');
     $this->elementEnd('dl');
     if ($this->group->fullname) {
         $this->elementStart('dl', 'entity_fn');
         $this->element('dt', null, _('Full name'));
         $this->elementStart('dd');
         $this->element('span', 'fn org', $this->group->fullname);
         $this->elementEnd('dd');
         $this->elementEnd('dl');
     }
     if ($this->group->location) {
         $this->elementStart('dl', 'entity_location');
         $this->element('dt', null, _('Location'));
         $this->element('dd', 'label', $this->group->location);
         $this->elementEnd('dl');
     }
     if ($this->group->homepage) {
         $this->elementStart('dl', 'entity_url');
         $this->element('dt', null, _('URL'));
         $this->elementStart('dd');
         $this->element('a', array('href' => $this->group->homepage, 'rel' => 'me', 'class' => 'url'), $this->group->homepage);
         $this->elementEnd('dd');
         $this->elementEnd('dl');
     }
     if ($this->group->description) {
         $this->elementStart('dl', 'entity_note');
         $this->element('dt', null, _('Note'));
         $this->element('dd', 'note', $this->group->description);
         $this->elementEnd('dl');
     }
     $this->elementEnd('div');
     $this->elementStart('div', 'entity_actions');
     $this->element('h2', null, _('Group actions'));
     $this->elementStart('ul');
     $this->elementStart('li', 'entity_subscribe');
     $cur = common_current_user();
     if ($cur) {
         if ($cur->isMember($this->group)) {
             $lf = new LeaveForm($this, $this->group);
             $lf->show();
         } else {
             $jf = new JoinForm($this, $this->group);
             $jf->show();
         }
     }
     $this->elementEnd('li');
     $this->elementEnd('ul');
     $this->elementEnd('div');
 }
Esempio n. 7
0
 /**
  * Show the group profile
  *
  * Information about the group
  *
  * @return void
  */
 function showGroupProfile()
 {
     $this->elementStart('div', array('id' => 'i', 'class' => 'entity_profile vcard author'));
     $this->element('h2', null, _('Group profile'));
     $this->elementStart('dl', 'entity_depiction');
     $this->element('dt', null, _('Avatar'));
     $this->elementStart('dd');
     $logo = $this->group->homepage_logo ? $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
     $this->element('img', array('src' => $logo, 'class' => 'photo avatar', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $this->group->nickname));
     $this->elementEnd('dd');
     $this->elementEnd('dl');
     $this->elementStart('dl', 'entity_nickname');
     $this->element('dt', null, _('Nickname'));
     $this->elementStart('dd');
     $hasFN = $this->group->fullname ? 'nickname url uid' : 'fn org nickname url uid';
     $this->element('a', array('href' => $this->group->homeUrl(), 'rel' => 'me', 'class' => $hasFN), $this->group->nickname);
     $this->elementEnd('dd');
     $this->elementEnd('dl');
     if ($this->group->fullname) {
         $this->elementStart('dl', 'entity_fn');
         $this->element('dt', null, _('Full name'));
         $this->elementStart('dd');
         $this->element('span', 'fn org', $this->group->fullname);
         $this->elementEnd('dd');
         $this->elementEnd('dl');
     }
     if ($this->group->location) {
         $this->elementStart('dl', 'entity_location');
         $this->element('dt', null, _('Location'));
         $this->element('dd', 'label', $this->group->location);
         $this->elementEnd('dl');
     }
     if ($this->group->homepage) {
         $this->elementStart('dl', 'entity_url');
         $this->element('dt', null, _('URL'));
         $this->elementStart('dd');
         $this->element('a', array('href' => $this->group->homepage, 'rel' => 'me', 'class' => 'url'), $this->group->homepage);
         $this->elementEnd('dd');
         $this->elementEnd('dl');
     }
     if ($this->group->description) {
         $this->elementStart('dl', 'entity_note');
         $this->element('dt', null, _('Note'));
         $this->element('dd', 'note', $this->group->description);
         $this->elementEnd('dl');
     }
     if (common_config('group', 'maxaliases') > 0) {
         $aliases = $this->group->getAliases();
         if (!empty($aliases)) {
             $this->elementStart('dl', 'entity_aliases');
             $this->element('dt', null, _('Aliases'));
             $this->element('dd', 'aliases', implode(' ', $aliases));
             $this->elementEnd('dl');
         }
     }
     $this->elementEnd('div');
     $cur = common_current_user();
     $this->elementStart('div', 'entity_actions');
     $this->element('h2', null, _('Group actions'));
     $this->elementStart('ul');
     $this->elementStart('li', 'entity_subscribe');
     if (Event::handle('StartGroupSubscribe', array($this, $this->group))) {
         if ($cur) {
             if ($cur->isMember($this->group)) {
                 $lf = new LeaveForm($this, $this->group);
                 $lf->show();
             } else {
                 if (!Group_block::isBlocked($this->group, $cur->getProfile())) {
                     $jf = new JoinForm($this, $this->group);
                     $jf->show();
                 }
             }
         }
         Event::handle('EndGroupSubscribe', array($this, $this->group));
     }
     $this->elementEnd('li');
     if ($cur && $cur->hasRight(Right::DELETEGROUP)) {
         $this->elementStart('li', 'entity_delete');
         $df = new DeleteGroupForm($this, $this->group);
         $df->show();
         $this->elementEnd('li');
     }
     $this->elementEnd('ul');
     $this->elementEnd('div');
 }
 function showJoinButton()
 {
     $user = $this->owner;
     if ($user) {
         $this->out->elementStart('li', 'entity_subscribe');
         // XXX: special-case for user looking at own
         // subscriptions page
         if ($user->isMember($this->profile->getGroup())) {
             $lf = new LeaveForm($this->out, $this->profile->getGroup());
             $lf->show();
         } else {
             if (!Group_block::isBlocked($this->profile->getGroup(), $user->getProfile())) {
                 $jf = new JoinForm($this->out, $this->profile->getGroup());
                 $jf->show();
             }
         }
         $this->out->elementEnd('li');
     }
 }
Esempio n. 9
0
 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @param array $args unused
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $cur = common_current_user();
     $member = new Group_member();
     $member->group_id = $this->group->id;
     $member->profile_id = $cur->id;
     if (!$member->find(true)) {
         $this->serverError(_('Could not find membership record.'));
         return;
     }
     $result = $member->delete();
     if (!$result) {
         common_log_db_error($member, 'INSERT', __FILE__);
         $this->serverError(sprintf(_('Could not remove user %s to group %s'), $cur->nickname, $this->group->nickname));
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         $this->element('title', null, sprintf(_('%s left group %s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $jf = new JoinForm($this, $this->group);
         $jf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)));
     }
 }
Esempio n. 10
0
 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @param array $args unused
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     try {
         $this->request->abort();
     } catch (Exception $e) {
         common_log(LOG_ERR, "Exception canceling group sub: " . $e->getMessage());
         // TRANS: Server error displayed when cancelling a queued group join request fails.
         // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
         $this->serverError(sprintf(_('Could not cancel request for user %1$s to join group %2$s.'), $this->profile->nickname, $this->group->nickname));
         return;
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for leave group page after leaving.
         // TRANS: %s$s is the leaving user's name, %2$s is the group name.
         $this->element('title', null, sprintf(_m('TITLE', '%1$s left group %2$s'), $this->profile->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $jf = new JoinForm($this, $this->group);
         $jf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
Esempio n. 11
0
 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     try {
         $this->scoped->leaveGroup($this->group);
     } catch (Exception $e) {
         common_log(LOG_ERR, "Error when {$this->scoped->nickname} tried to leave {$this->group->nickname}: " . $e->getMessage());
         // TRANS: Server error displayed when leaving a group failed in the database.
         // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
         $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $this->scoped->nickname, $this->group->nickname));
         return;
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         // TRANS: Title for leave group page after leaving.
         $this->element('title', null, sprintf(_m('TITLE', '%1$s left group %2$s'), $this->scoped->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $jf = new JoinForm($this, $this->group);
         $jf->show();
         $this->elementEnd('body');
         $this->endHTML();
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
Esempio n. 12
0
 /**
  * Handle the request
  *
  * On POST, add the current user to the group
  *
  * @param array $args unused
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $cur = common_current_user();
     try {
         if (Event::handle('StartLeaveGroup', array($this->group, $cur))) {
             Group_member::leave($this->group->id, $cur->id);
             Event::handle('EndLeaveGroup', array($this->group, $cur));
         }
     } catch (Exception $e) {
         $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'), $cur->nickname, $this->group->nickname));
         return;
     }
     if ($this->boolean('ajax')) {
         $this->startHTML('text/xml;charset=utf-8');
         $this->elementStart('head');
         $this->element('title', null, sprintf(_('%1$s left group %2$s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $jf = new JoinForm($this, $this->group);
         $jf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
Esempio n. 13
0
 function showGroup()
 {
     $this->out->elementStart('li', array('class' => 'profile', 'id' => 'group-' . $this->group->id));
     $user = common_current_user();
     $this->out->elementStart('div', 'entity_profile vcard');
     $logo = $this->group->stream_logo ? $this->group->stream_logo : User_group::defaultLogo(AVATAR_STREAM_SIZE);
     $this->out->elementStart('a', array('href' => $this->group->homeUrl(), 'class' => 'url', 'rel' => 'group'));
     $this->out->element('img', array('src' => $logo, 'class' => 'photo avatar', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => $this->group->fullname ? $this->group->fullname : $this->group->nickname));
     $hasFN = $this->group->fullname ? 'nickname url uid' : 'fn org nickname url uid';
     $this->out->elementStart('span', $hasFN);
     $this->out->raw($this->highlight($this->group->nickname));
     $this->out->elementEnd('span');
     $this->out->elementEnd('a');
     if ($this->group->fullname) {
         $this->out->elementStart('dl', 'entity_fn');
         $this->out->element('dt', null, 'Full name');
         $this->out->elementStart('dd');
         $this->out->elementStart('span', 'fn org');
         $this->out->raw($this->highlight($this->group->fullname));
         $this->out->elementEnd('span');
         $this->out->elementEnd('dd');
         $this->out->elementEnd('dl');
     }
     if ($this->group->location) {
         $this->out->elementStart('dl', 'entity_location');
         $this->out->element('dt', null, _('Location'));
         $this->out->elementStart('dd', 'label');
         $this->out->raw($this->highlight($this->group->location));
         $this->out->elementEnd('dd');
         $this->out->elementEnd('dl');
     }
     if ($this->group->homepage) {
         $this->out->elementStart('dl', 'entity_url');
         $this->out->element('dt', null, _('URL'));
         $this->out->elementStart('dd');
         $this->out->elementStart('a', array('href' => $this->group->homepage, 'class' => 'url'));
         $this->out->raw($this->highlight($this->group->homepage));
         $this->out->elementEnd('a');
         $this->out->elementEnd('dd');
         $this->out->elementEnd('dl');
     }
     if ($this->group->description) {
         $this->out->elementStart('dl', 'entity_note');
         $this->out->element('dt', null, _('Note'));
         $this->out->elementStart('dd', 'note');
         $this->out->raw($this->highlight($this->group->description));
         $this->out->elementEnd('dd');
         $this->out->elementEnd('dl');
     }
     # If we're on a list with an owner (subscriptions or subscribers)...
     if (!empty($user) && !empty($this->owner) && $user->id == $this->owner->id) {
         $this->showOwnerControls();
     }
     $this->out->elementEnd('div');
     if ($user) {
         $this->out->elementStart('div', 'entity_actions');
         $this->out->elementStart('ul');
         $this->out->elementStart('li', 'entity_subscribe');
         # XXX: special-case for user looking at own
         # subscriptions page
         if ($user->isMember($this->group)) {
             $lf = new LeaveForm($this->out, $this->group);
             $lf->show();
         } else {
             $jf = new JoinForm($this->out, $this->group);
             $jf->show();
         }
         $this->out->elementEnd('li');
         $this->out->elementEnd('ul');
         $this->out->elementEnd('div');
     }
     $this->out->elementEnd('li');
 }