groupmemberlistitem.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // @todo FIXME: add documentation.
  3. class GroupMemberListItem extends ProfileListItem
  4. {
  5. var $group = null;
  6. function __construct($profile, $group, $action)
  7. {
  8. parent::__construct($profile, $action);
  9. $this->group = $group;
  10. }
  11. function showFullName()
  12. {
  13. parent::showFullName();
  14. if ($this->profile->isAdmin($this->group)) {
  15. $this->out->text(' '); // for separating the classes.
  16. // TRANS: Indicator in group members list that this user is a group administrator.
  17. $this->out->element('span', 'role', _m('GROUPADMIN','Admin'));
  18. }
  19. }
  20. function showActions()
  21. {
  22. $this->startActions();
  23. if (Event::handle('StartProfileListItemActionElements', array($this))) {
  24. $this->showSubscribeButton();
  25. $this->showMakeAdminForm();
  26. $this->showGroupBlockForm();
  27. Event::handle('EndProfileListItemActionElements', array($this));
  28. }
  29. $this->endActions();
  30. }
  31. function showMakeAdminForm()
  32. {
  33. $user = common_current_user();
  34. if (!empty($user) &&
  35. $user->id != $this->profile->id &&
  36. ($user->isAdmin($this->group) || $user->hasRight(Right::MAKEGROUPADMIN)) &&
  37. !$this->profile->isAdmin($this->group)) {
  38. $this->out->elementStart('li', 'entity_make_admin');
  39. $maf = new MakeAdminForm($this->out, $this->profile, $this->group,
  40. $this->returnToArgs());
  41. $maf->show();
  42. $this->out->elementEnd('li');
  43. }
  44. }
  45. function showGroupBlockForm()
  46. {
  47. $user = common_current_user();
  48. if (!empty($user) && $user->id != $this->profile->id && $user->isAdmin($this->group)) {
  49. $this->out->elementStart('li', 'entity_block');
  50. $bf = new GroupBlockForm($this->out, $this->profile, $this->group,
  51. $this->returnToArgs());
  52. $bf->show();
  53. $this->out->elementEnd('li');
  54. }
  55. }
  56. function linkAttributes()
  57. {
  58. $aAttrs = parent::linkAttributes();
  59. if (common_config('nofollow', 'members')) {
  60. $aAttrs['rel'] .= ' nofollow';
  61. }
  62. return $aAttrs;
  63. }
  64. function homepageAttributes()
  65. {
  66. $aAttrs = parent::linkAttributes();
  67. if (common_config('nofollow', 'members')) {
  68. $aAttrs['rel'] = 'nofollow';
  69. }
  70. return $aAttrs;
  71. }
  72. /**
  73. * Fetch necessary return-to arguments for the profile forms
  74. * to return to this list when they're done.
  75. *
  76. * @return array
  77. */
  78. protected function returnToArgs()
  79. {
  80. $args = array('action' => 'groupmembers',
  81. 'nickname' => $this->group->nickname);
  82. $page = $this->out->arg('page');
  83. if ($page) {
  84. $args['param-page'] = $page;
  85. }
  86. return $args;
  87. }
  88. }