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