ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilUsersGalleryGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/User/classes/class.ilUserUtil.php';
5require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
6require_once 'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
7require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemLinkButton.php';
8require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemRelation.php';
9require_once 'Services/Contact/BuddySystem/classes/states/class.ilBuddySystemRelationStateFactory.php';
10require_once 'Services/Mail/classes/class.ilMailFormCall.php';
11
17{
22
26 protected $ctrl;
27
31 protected $tpl;
32
36 protected $lng;
37
41 protected $user;
42
46 protected $rbacsystem;
47
51 protected $factory;
52
56 protected $renderer;
57
63 {
67 global $DIC;
68
69 $this->ctrl = $DIC->ctrl();
70 $this->tpl = $DIC->ui()->mainTemplate();
71 $this->lng = $DIC->language();
72 $this->user = $DIC->user();
73 $this->rbacsystem = $DIC->rbac()->system();
74 $this->factory = $DIC->ui()->factory();
75 $this->renderer = $DIC->ui()->renderer();
76
77 $this->collection_provider = $collection_provider;
78 }
79
83 public function executeCommand()
84 {
85 $next_class = $this->ctrl->getNextClass();
86 $cmd = $this->ctrl->getCmd('view');
87
88 switch ($next_class) {
89 case 'ilpublicuserprofilegui':
90 require_once 'Services/User/classes/class.ilPublicUserProfileGUI.php';
91 $profile_gui = new ilPublicUserProfileGUI(ilUtil::stripSlashes($_GET['user']));
92 $profile_gui->setBackUrl($this->ctrl->getLinkTarget($this, 'view'));
93 $this->ctrl->forwardCommand($profile_gui);
94 break;
95
96 default:
97 switch ($cmd) {
98 default:
99 $this->$cmd();
100 break;
101 }
102 break;
103 }
104 }
105
109 protected function view()
110 {
111 $template = $this->populateTemplate($this->collection_provider->getGroupedCollections());
112 $this->tpl->setContent($template->get());
113 }
114
119 protected function addActionSection(ilObjUser $user, array &$sections)
120 {
121 $contact_btn_html = "";
122
123 if (
124 ilBuddySystem::getInstance()->isEnabled() &&
125 $this->user->getId() != $user->getId() &&
126 !$this->user->isAnonymous() &&
127 !$user->isAnonymous()
128 ) {
129 $contact_btn_html = ilBuddySystemLinkButton::getInstanceByUserId((int) $user->getId())->getHtml();
130 }
131
132 include_once("./Services/User/Actions/classes/class.ilUserActionGUI.php");
133 include_once("./Services/User/Gallery/classes/class.ilGalleryUserActionContext.php");
134 $ua_gui = ilUserActionGUI::getInstance(new ilGalleryUserActionContext(), $this->tpl, $this->user->getId());
135 $list_html = $ua_gui->renderDropDown($user->getId());
136
137 if ($contact_btn_html || $list_html) {
138 $sections[] = $this->factory->legacy("<div style='float:left; margin-bottom:5px;'>" . $contact_btn_html . "</div><div class='button-container'>&nbsp;" . $list_html . "</div>");
139 }
140 }
141
146 protected function populateTemplate(array $gallery_groups)
147 {
149 $tpl = new ilTemplate('tpl.users_gallery.html', true, true, 'Services/User');
150
151 require_once 'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
152 $panel = ilPanelGUI::getInstance();
153 $panel->setBody($this->lng->txt('no_gallery_users_available'));
154 $tpl->setVariable('NO_ENTRIES_HTML', json_encode($panel->getHTML()));
155
156 $groups_with_users = array_filter($gallery_groups, function (ilUsersGalleryGroup $group) {
157 return count($group) > 0;
158 });
159 $groups_with_highlight = array_filter($groups_with_users, function (ilUsersGalleryGroup $group) {
160 return $group->isHighlighted();
161 });
162
163 if (0 == count($groups_with_users)) {
164 $tpl->setVariable('NO_GALLERY_USERS', $panel->getHTML());
165 return $tpl;
166 }
167
168 require_once 'Services/UIComponent/Panel/classes/class.ilPanelGUI.php';
169 $panel = ilPanelGUI::getInstance();
170 $panel->setBody($this->lng->txt('no_gallery_users_available'));
171 $tpl->setVariable('NO_ENTRIES_HTML', json_encode($panel->getHTML()));
172
173 require_once 'Services/User/Gallery/classes/class.ilUsersGallerySortedUserGroup.php';
174 require_once 'Services/User/Gallery/classes/class.ilUsersGalleryUserCollectionPublicNameSorter.php';
175
176 $cards = [];
177
178 foreach ($gallery_groups as $group) {
180
181 foreach ($group as $user) {
182 $card = $this->factory->card()->standard($user->getPublicName());
183 $avatar = $this->factory->image()->standard($user->getAggregatedUser()->getPersonalPicturePath('big'), $user->getPublicName());
184
185 $sections = [];
186
187 if (count($groups_with_highlight) > 0) {
188 $card = $card->withHighlight($group->isHighlighted());
189 }
190
191 $sections[] = $this->factory->listing()->descriptive(
192 [
193 $this->lng->txt("username") => $user->getAggregatedUser()->getLogin(),
194 $this->lng->txt("crs_contact_responsibility") => $group->getLabel()
195 ]
196 );
197
198 $this->addActionSection($user->getAggregatedUser(), $sections);
199
200 if ($user->hasPublicProfile()) {
201 $this->ctrl->setParameterByClass('ilpublicuserprofilegui', 'user', $user->getAggregatedUser()->getId());
202 $public_profile_url = $this->ctrl->getLinkTargetByClass('ilpublicuserprofilegui', 'getHTML');
203
204 $avatar = $avatar->withAction($public_profile_url);
205 $card = $card->withTitleAction($public_profile_url);
206 }
207
208 $card = $card->withImage($avatar)->withSections($sections);
209
210 $cards[] = $card;
211 }
212 }
213
214 $tpl->setVariable('GALLERY_HTML', $this->renderer->render($this->factory->deck($cards)));
215
216 if ($this->collection_provider->hasRemovableUsers()) {
217 $tpl->touchBlock('js_remove_handler');
218 }
219
220 return $tpl;
221 }
222}
user()
Definition: user.php:4
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static getInstanceByGlobalUser()
Gallery context for user actions.
getId()
get object id @access public
static getInstance()
Get instance.
GUI class for public user profile presentation.
special template class to simplify handling of ITX/PEAR
static getInstance(ilUserActionContext $a_user_action_context, ilGlobalTemplateInterface $a_global_tpl, $a_current_user_id)
Get instance.
@ilCtrl_Calls ilUsersGalleryGUI: ilPublicUserProfileGUI @ilCtrl_isCalledBy ilUsersGalleryGUI: ilCours...
populateTemplate(array $gallery_groups)
view()
Displays the participants gallery.
addActionSection(ilObjUser $user, array &$sections)
Class ilUsersGalleryGroup.
isHighlighted()
Returns whether or not it is a highlighted group.boolean
Class ilUsersGallerySortedUserGroup.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Interface ilUsersGalleryCollectionProvider.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46