groupmemberlistitem.php 2.9 KB

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