Пример #1
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');
 }
 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');
 }
Пример #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('StartJoinGroup', array($this->group, $cur))) {
             Group_member::join($this->group->id, $cur->id);
             Event::handle('EndJoinGroup', array($this->group, $cur));
         }
     } catch (Exception $e) {
         // 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');
         $lf = new LeaveForm($this, $this->group);
         $lf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
Пример #4
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('StartJoinGroup', array($this->group, $cur))) {
             Group_member::join($this->group->id, $cur->id);
             Event::handle('EndJoinGroup', array($this->group, $cur));
         }
     } catch (Exception $e) {
         $this->serverError(sprintf(_('Could not join user %1$s to group %2$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(_('%1$s joined group %2$s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $lf = new LeaveForm($this, $this->group);
         $lf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)), 303);
     }
 }
Пример #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');
 }
Пример #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');
 }
Пример #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');
 }
Пример #8
0
 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');
     }
 }
Пример #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;
     $member->created = common_sql_now();
     $result = $member->insert();
     if (!$result) {
         common_log_db_error($member, 'INSERT', __FILE__);
         $this->serverError(sprintf(_('Could not join 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 joined group %s'), $cur->nickname, $this->group->nickname));
         $this->elementEnd('head');
         $this->elementStart('body');
         $lf = new LeaveForm($this, $this->group);
         $lf->show();
         $this->elementEnd('body');
         $this->elementEnd('html');
     } else {
         common_redirect(common_local_url('groupmembers', array('nickname' => $this->group->nickname)));
     }
 }
Пример #10
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');
 }