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');
 }
示例#2
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 {
         $result = $cur->joinGroup($this->group);
     } catch (Exception $e) {
         common_log(LOG_ERR, sprintf("Couldn't join user %s to group %s: '%s'", $cur->nickname, $this->group->nickname, $e->getMessage()));
         // TRANS: Server error displayed when joining a group failed in the database.
         // TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
         $this->serverError(sprintf(_('Could not join user %1$s to 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 join group page after joining.
         $this->element('title', null, sprintf(_m('TITLE', '%1$s joined group %2$s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         if ($result instanceof Group_member) {
             $form = new LeaveForm($this, $this->group);
         } else {
             if ($result instanceof Group_join_queue) {
                 $form = new CancelGroupForm($this, $this->group);
             } else {
                 // wtf?
                 // TRANS: Exception thrown when there is an unknown error joining a group.
                 throw new Exception(_("Unknown error joining group."));
             }
         }
         $form->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
示例#3
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');
 }