ILIAS  release_7 Revision v7.30-3-g800a261c036
ilMailSearchGroupsGUI Class Reference
+ Collaboration diagram for ilMailSearchGroupsGUI:

Public Member Functions

 __construct ($wsp_access_handler=null, $wsp_node_id=null)
 
 executeCommand ()
 
 mail ()
 
 mailGroups ()
 
 mailMembers ()
 
 cancel ()
 Cancel action. More...
 
 showMembers ()
 Show course members. More...
 
 share ()
 

Protected Member Functions

 addPermission ($a_obj_ids)
 

Protected Attributes

 $tpl
 
 $ctrl
 
 $lng
 
 $user
 
 $error
 
 $rbacsystem
 
 $rbacreview
 
 $tree
 
 $cache
 
 $umail
 
 $rerfinery
 
 $mailing_allowed
 

Private Member Functions

 getContext ()
 

Detailed Description

Author
Jens Conze
Version
$Id$ @ilCtrl_Calls ilMailSearchGroupsGUI: ilBuddySystemGUI

Definition at line 16 of file class.ilMailSearchGroupsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailSearchGroupsGUI::__construct (   $wsp_access_handler = null,
  $wsp_node_id = null 
)

Definition at line 75 of file class.ilMailSearchGroupsGUI.php.

76 {
77 global $DIC;
78
79 $this->tpl = $DIC['tpl'];
80 $this->ctrl = $DIC['ilCtrl'];
81 $this->lng = $DIC['lng'];
82 $this->user = $DIC['ilUser'];
83 $this->error = $DIC['ilErr'];
84 $this->rbacsystem = $DIC['rbacsystem'];
85 $this->rbacreview = $DIC['rbacreview'];
86 $this->tree = $DIC['tree'];
87 $this->cache = $DIC['ilObjDataCache'];
88 $this->refinery = $DIC->refinery();
89
90 // personal workspace
91 $this->wsp_access_handler = $wsp_access_handler;
92 $this->wsp_node_id = $wsp_node_id;
93
94 $this->ctrl->saveParameter($this, "mobj_id");
95 $this->ctrl->saveParameter($this, "ref");
96
97 include_once "Services/Mail/classes/class.ilMail.php";
98 $mail = new ilMail($this->user->getId());
99 $this->mailing_allowed = $this->rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
100
101 $this->umail = new ilFormatMail($this->user->getId());
102 }
user()
Definition: user.php:4
error($a_errmsg)
set error message @access public
Class UserMail this class handles user mails.
global $DIC
Definition: goto.php:24

References $DIC, error(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addPermission()

ilMailSearchGroupsGUI::addPermission (   $a_obj_ids)
protected

Definition at line 534 of file class.ilMailSearchGroupsGUI.php.

535 {
536 if (!is_array($a_obj_ids)) {
537 $a_obj_ids = array($a_obj_ids);
538 }
539
540 $existing = $this->wsp_access_handler->getPermissions($this->wsp_node_id);
541 $added = false;
542 foreach ($a_obj_ids as $object_id) {
543 if (!in_array($object_id, $existing)) {
544 $added = $this->wsp_access_handler->addPermission($this->wsp_node_id, $object_id);
545 }
546 }
547
548 if ($added) {
549 ilUtil::sendSuccess($this->lng->txt("wsp_share_success"), true);
550 }
551 $this->ctrl->redirectByClass("ilworkspaceaccessgui", "share");
552 }

Referenced by share().

+ Here is the caller graph for this function:

◆ cancel()

ilMailSearchGroupsGUI::cancel ( )

Cancel action.

Definition at line 292 of file class.ilMailSearchGroupsGUI.php.

293 {
294 if ($_GET["view"] == "mygroups" &&
295 $_GET["ref"] == "mail") {
296 $this->ctrl->returnToParent($this);
297 } else {
298 $this->showMyGroups();
299 }
300 }
$_GET["client_id"]

References $_GET.

◆ executeCommand()

ilMailSearchGroupsGUI::executeCommand ( )

Definition at line 120 of file class.ilMailSearchGroupsGUI.php.

121 {
122 $forward_class = $this->ctrl->getNextClass($this);
123 switch ($forward_class) {
124 case 'ilbuddysystemgui':
125 if (!ilBuddySystem::getInstance()->isEnabled()) {
126 $this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
127 }
128
129 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystemGUI.php';
130 $this->ctrl->saveParameter($this, 'search_grp');
131 $this->ctrl->setReturn($this, 'showMembers');
132 $this->ctrl->forwardCommand(new ilBuddySystemGUI());
133 break;
134
135 default:
136 if (!($cmd = $this->ctrl->getCmd())) {
137 $cmd = "showMyGroups";
138 }
139
140 $this->$cmd();
141 break;
142 }
143 return true;
144 }
Class ilBuddySystemGUI.

References error(), and ilBuddySystem\getInstance().

+ Here is the call graph for this function:

◆ getContext()

ilMailSearchGroupsGUI::getContext ( )
private

Definition at line 104 of file class.ilMailSearchGroupsGUI.php.

104 : string
105 {
106 $context = 'mail';
107 if (isset($_GET['ref'])) {
108 $always = $context;
109 $context = $this->refinery->byTrying([
110 $this->refinery->kindlyTo()->string(),
111 $this->refinery->custom()->transformation(static function ($value) use ($always) {
112 return $always;
113 }),
114 ])->transform($_GET['ref']);
115 }
116
117 return $context;
118 }
$context
Definition: webdav.php:26

References $_GET, and $context.

◆ mail()

ilMailSearchGroupsGUI::mail ( )

Definition at line 146 of file class.ilMailSearchGroupsGUI.php.

147 {
148 if ($_GET["view"] == "mygroups") {
149 $ids = ((int) $_GET['search_grp']) ? array((int) $_GET['search_grp']) : $_POST['search_grp'];
150 if ($ids) {
151 $this->mailGroups();
152 } else {
153 ilUtil::sendInfo($this->lng->txt("mail_select_group"));
154 $this->showMyGroups();
155 }
156 } elseif ($_GET["view"] == "grp_members") {
157 $ids = ((int) $_GET['search_members']) ? array((int) $_GET['search_members']) : $_POST['search_members'];
158 if ($ids) {
159 $this->mailMembers();
160 } else {
161 ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
162 $this->showMembers();
163 }
164 } else {
165 $this->showMyGroups();
166 }
167 }
$_POST["username"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $_GET, $_POST, mailGroups(), mailMembers(), ilUtil\sendInfo(), and showMembers().

+ Here is the call graph for this function:

◆ mailGroups()

ilMailSearchGroupsGUI::mailGroups ( )

Definition at line 169 of file class.ilMailSearchGroupsGUI.php.

170 {
171 $members = array();
172
173 if (!is_array($old_mail_data = $this->umail->getSavedData())) {
174 $this->umail->savePostData(
175 $this->user->getId(),
176 array(),
177 "",
178 "",
179 "",
180 "",
181 "",
182 "",
183 "",
184 ""
185 );
186 }
187
188 require_once './Services/Object/classes/class.ilObject.php';
189 require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
190
191 $ids = ((int) $_GET['search_grp']) ? array((int) $_GET['search_grp']) : $_POST['search_grp'];
192 foreach ($ids as $grp_id) {
193 $ref_ids = ilObject::_getAllReferences($grp_id);
194 foreach ($ref_ids as $ref_id) {
195 $can_send_mails = ilParticipants::canSendMailToMembers(
196 (int) $ref_id,
197 $this->user->getId(),
199 );
200 if (!$can_send_mails) {
201 continue;
202 }
203
204 $roles = $this->rbacreview->getAssignableChildRoles($ref_id);
205 foreach ($roles as $role) {
206 if (substr($role['title'], 0, 14) == 'il_grp_member_' ||
207 substr($role['title'], 0, 13) == 'il_grp_admin_') {
208 if (isset($old_mail_data['rcp_to']) &&
209 trim($old_mail_data['rcp_to']) != '') {
210 $rcpt = (new \ilRoleMailboxAddress($role['obj_id']))->value();
211 if (!$this->umail->existsRecipient($rcpt, (string) $old_mail_data['rcp_to'])) {
212 array_push($members, $rcpt);
213 }
214 } else {
215 array_push($members, (new \ilRoleMailboxAddress($role['obj_id']))->value());
216 }
217 }
218 }
219 }
220 }
221
222 if (count($members)) {
223 $mail_data = $this->umail->appendSearchResult($members, 'to');
224 } else {
225 $mail_data = $this->umail->getSavedData();
226 }
227
228 $this->umail->savePostData(
229 $mail_data["user_id"],
230 $mail_data["attachments"],
231 $mail_data["rcp_to"],
232 $mail_data["rcp_cc"],
233 $mail_data["rcp_bcc"],
234 $mail_data["m_email"],
235 $mail_data["m_subject"],
236 $mail_data["m_message"],
237 $mail_data["use_placeholders"],
238 $mail_data['tpl_ctx_id'],
239 $mail_data['tpl_ctx_params']
240 );
241
242 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
243 }
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable.
static _getAllReferences($a_id)
get all reference ids of object
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
Class ilRoleMailboxAddress.
static redirect($a_script)

References $_GET, $_POST, ilObject\_getAllReferences(), ilParticipants\canSendMailToMembers(), ilMailGlobalServices\getMailObjectRefId(), ilUtil\redirect(), and user().

Referenced by mail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mailMembers()

ilMailSearchGroupsGUI::mailMembers ( )

Definition at line 245 of file class.ilMailSearchGroupsGUI.php.

246 {
247 $members = array();
248
249 if (!is_array($this->umail->getSavedData())) {
250 $this->umail->savePostData(
251 $this->user->getId(),
252 array(),
253 "",
254 "",
255 "",
256 "",
257 "",
258 "",
259 "",
260 ""
261 );
262 }
263
264 $ids = ((int) $_GET['search_members']) ? array((int) $_GET['search_members']) : $_POST['search_members'];
265
266 foreach ($ids as $member) {
268 array_push($members, $login);
269 }
270 $mail_data = $this->umail->appendSearchResult($members, "to");
271
272 $this->umail->savePostData(
273 $mail_data["user_id"],
274 $mail_data["attachments"],
275 $mail_data["rcp_to"],
276 $mail_data["rcp_cc"],
277 $mail_data["rcp_bcc"],
278 $mail_data["m_email"],
279 $mail_data["m_subject"],
280 $mail_data["m_message"],
281 $mail_data["use_placeholders"],
282 $mail_data['tpl_ctx_id'],
283 $mail_data['tpl_ctx_params']
284 );
285
286 ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res");
287 }
static _lookupLogin($a_user_id)
lookup login
$login
Definition: cron.php:13

References $_GET, $_POST, $login, ilObjUser\_lookupLogin(), ilUtil\redirect(), and user().

Referenced by mail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ share()

ilMailSearchGroupsGUI::share ( )

Definition at line 508 of file class.ilMailSearchGroupsGUI.php.

509 {
510 if ($_GET["view"] == "mygroups") {
511 $ids = $_REQUEST["search_grp"];
512 if (!is_array($ids) && $ids !== "") {
513 $ids = [$ids];
514 }
515 if (is_array($ids) && count($ids)) {
516 $this->addPermission($ids);
517 } else {
518 ilUtil::sendInfo($this->lng->txt("mail_select_group"));
519 $this->showMyGroups();
520 }
521 } elseif ($_GET["view"] == "grp_members") {
522 $ids = $_REQUEST["search_members"];
523 if (is_array($ids) && count($ids)) {
524 $this->addPermission($ids);
525 } else {
526 ilUtil::sendInfo($this->lng->txt("mail_select_one_entry"));
527 $this->showMembers();
528 }
529 } else {
530 $this->showMyGroups();
531 }
532 }

References $_GET, addPermission(), ilUtil\sendInfo(), and showMembers().

+ Here is the call graph for this function:

◆ showMembers()

ilMailSearchGroupsGUI::showMembers ( )

Show course members.

Definition at line 432 of file class.ilMailSearchGroupsGUI.php.

433 {
434 if ($_GET["search_grp"] != "") {
435 $_POST["search_grp"] = explode(",", $_GET["search_grp"]);
436 }
437
438 if (!is_array($_POST["search_grp"]) ||
439 count($_POST["search_grp"]) == 0) {
440 ilUtil::sendInfo($this->lng->txt("mail_select_group"));
441 $this->showMyGroups();
442 } else {
443 $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
444 include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
445 $context = $_GET["ref"] ? $_GET["ref"] : "mail";
446 $table = new ilMailSearchCoursesMembersTableGUI($this, 'grp', $context, $_POST["search_grp"]);
447 $this->lng->loadLanguageModule('crs');
448
449 $tableData = array();
450 $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
451
452 foreach ($_POST["search_grp"] as $grp_id) {
453 $ref_ids = ilObject::_getAllReferences($grp_id);
454 $ref_id = current($ref_ids);
455
456 if (is_object($group_obj = ilObjectFactory::getInstanceByRefId($ref_id, false))) {
457 $grp_members = $group_obj->getGroupMemberData($group_obj->getGroupMemberIds());
458
459 foreach ($grp_members as $member) {
460 $tmp_usr = new ilObjUser($member['id']);
461 if (!$tmp_usr->getActive()) {
462 continue;
463 }
464
465 $fullname = "";
466 if (in_array(ilObjUser::_lookupPref($member['id'], 'public_profile'), array("g", 'y'))) {
467 $fullname = $member['lastname'] . ', ' . $member['firstname'];
468 }
469
470 $rowData = array(
471 'members_id' => $member["id"],
472 'members_login' => $member["login"],
473 'members_name' => $fullname,
474 'members_crs_grp' => $group_obj->getTitle(),
475 'search_grp' => $grp_id,
476 );
477
478 if ('mail' == $context && ilBuddySystem::getInstance()->isEnabled()) {
479 $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId($member['id']);
480 $state_name = ilStr::convertUpperCamelCaseToUnderscoreCase($relation->getState()->getName());
481 $rowData['status'] = '';
482 if ($member['id'] != $this->user->getId()) {
483 if ($relation->isOwnedByActor()) {
484 $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_a');
485 } else {
486 $rowData['status'] = $this->lng->txt('buddy_bs_state_' . $state_name . '_p');
487 }
488 }
489 }
490
491 $tableData[] = $rowData;
492 }
493 }
494 }
495 $table->setData($tableData);
496 if (count($tableData)) {
497 $searchTpl->setVariable("TXT_MARKED_ENTRIES", $this->lng->txt("marked_entries"));
498 }
499 $searchTpl->setVariable('TABLE', $table->getHTML());
500 $this->tpl->setContent($searchTpl->get());
501
502 if ($_GET["ref"] != "wsp") {
503 $this->tpl->printToStdout();
504 }
505 }
506 }
static getInstanceByGlobalUser()
static _lookupPref($a_usr_id, $a_keyword)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static convertUpperCamelCaseToUnderscoreCase($value)
Convert a value given in camel case conversion to underscore case conversion (e.g.
special template class to simplify handling of ITX/PEAR

References $_GET, $_POST, $context, ilObject\_getAllReferences(), ilObjUser\_lookupPref(), ilStr\convertUpperCamelCaseToUnderscoreCase(), ilBuddySystem\getInstance(), ilBuddyList\getInstanceByGlobalUser(), ilObjectFactory\getInstanceByRefId(), ilUtil\sendInfo(), and user().

Referenced by mail(), and share().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cache

ilMailSearchGroupsGUI::$cache
protected

Definition at line 61 of file class.ilMailSearchGroupsGUI.php.

◆ $ctrl

ilMailSearchGroupsGUI::$ctrl
protected

Definition at line 26 of file class.ilMailSearchGroupsGUI.php.

◆ $error

ilMailSearchGroupsGUI::$error
protected

Definition at line 41 of file class.ilMailSearchGroupsGUI.php.

◆ $lng

ilMailSearchGroupsGUI::$lng
protected

Definition at line 31 of file class.ilMailSearchGroupsGUI.php.

◆ $mailing_allowed

ilMailSearchGroupsGUI::$mailing_allowed
protected

Definition at line 73 of file class.ilMailSearchGroupsGUI.php.

◆ $rbacreview

ilMailSearchGroupsGUI::$rbacreview
protected

Definition at line 51 of file class.ilMailSearchGroupsGUI.php.

◆ $rbacsystem

ilMailSearchGroupsGUI::$rbacsystem
protected

Definition at line 46 of file class.ilMailSearchGroupsGUI.php.

◆ $rerfinery

ilMailSearchGroupsGUI::$rerfinery
protected

Definition at line 68 of file class.ilMailSearchGroupsGUI.php.

◆ $tpl

ilMailSearchGroupsGUI::$tpl
protected

Definition at line 21 of file class.ilMailSearchGroupsGUI.php.

◆ $tree

ilMailSearchGroupsGUI::$tree
protected

Definition at line 56 of file class.ilMailSearchGroupsGUI.php.

◆ $umail

ilMailSearchGroupsGUI::$umail
protected

Definition at line 66 of file class.ilMailSearchGroupsGUI.php.

◆ $user

ilMailSearchGroupsGUI::$user
protected

Definition at line 36 of file class.ilMailSearchGroupsGUI.php.


The documentation for this class was generated from the following file: