ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMailSearchCoursesMembersTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Table/classes/class.ilTable2GUI.php';
5 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
6 require_once 'Services/Utilities/classes/class.ilStr.php';
7 require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
8 
18 {
22  protected $lng;
23 
27  protected $ctrl;
28 
32  protected $user;
33 
34  protected $mode;
35  protected $mailing_allowed;
45  public function __construct($a_parent_obj, $type = 'crs', $context = 'mail', $contextObjects)
46  {
47  global $DIC;
48 
49  $this->ctrl = $DIC['ilCtrl'];
50  $this->lng = $DIC['lng'];
51  $this->user = $DIC['ilUser'];
52 
53  $tableId = $type . '_cml_' . implode('_', (array) $contextObjects);
54  $this->setId($tableId);
55  parent::__construct($a_parent_obj, 'showMembers');
56 
57  $this->context = $context;
58  if ($this->context == 'mail') {
59  // check if current user may send mails
60  include_once "Services/Mail/classes/class.ilMail.php";
61  $mail = new ilMail($GLOBALS['DIC']['ilUser']->getId());
62  $this->mailing_allowed = $DIC->rbac()->system()->checkAccess('internal_mail', $mail->getMailObjectReferenceId());
63  }
64 
65  $this->setDefaultOrderDirection('ASC');
66  $this->setDefaultOrderField('members_login');
67 
68  $this->lng->loadLanguageModule('crs');
69  $this->lng->loadLanguageModule('buddysystem');
70 
71  $mode = array();
72  if ($type == 'crs') {
73  $mode["checkbox"] = 'search_crs';
74  $mode["short"] = 'crs';
75  $mode["long"] = 'course';
76  $mode["lng_type"] = $this->lng->txt('course');
77  $mode["view"] = "crs_members";
78  } elseif ($type == 'grp') {
79  $mode["checkbox"] = 'search_grp';
80  $mode["short"] = 'grp';
81  $mode["long"] = 'group';
82  $mode["lng_type"] = $this->lng->txt('group');
83  $mode["view"] = "grp_members";
84  }
85  $this->setTitle($this->lng->txt('members'));
86  $this->mode = $mode;
87  $this->ctrl->setParameter($a_parent_obj, 'view', $mode['view']);
88  if ($_GET['ref'] != '') {
89  $this->ctrl->setParameter($a_parent_obj, 'ref', $_GET['ref']);
90  }
91  if (is_array($_POST[$mode["checkbox"]])) {
92  $this->ctrl->setParameter($a_parent_obj, $mode["checkbox"], implode(',', $_POST[$mode["checkbox"]]));
93  }
94 
95  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
96  //$this->ctrl->clearParameters($a_parent_obj);
97 
98  $this->setRowTemplate('tpl.mail_search_courses_members_row.html', 'Services/Contact');
99 
100  // setup columns
101  $this->addColumn('', '', '1%', true);
102  $this->addColumn($this->lng->txt('login'), 'members_login', '22%');
103  $this->addColumn($this->lng->txt('name'), 'members_name', '22%');
104  $this->addColumn($this->lng->txt($mode['long']), 'members_crs_grp', '22%');
105  if (ilBuddySystem::getInstance()->isEnabled()) {
106  $this->addColumn($this->lng->txt('buddy_tbl_filter_state'), 'status', '23%');
107  }
108  $this->addColumn($this->lng->txt('actions'), '', '10%');
109 
110  if ($this->context == "mail") {
111  if ($this->mailing_allowed) {
112  $this->setSelectAllCheckbox('search_members[]');
113  $this->addMultiCommand('mail', $this->lng->txt('mail_members'));
114  }
115  } else {
116  $this->setSelectAllCheckbox('search_members[]');
117  $this->lng->loadLanguageModule("wsp");
118  $this->addMultiCommand('share', $this->lng->txt("wsp_share_with_members"));
119  }
120  $this->lng->loadLanguageModule('buddysystem');
121  $this->addCommandButton('cancel', $this->lng->txt('cancel'));
122  }
123 
131  public function fillRow($a_set)
132  {
133  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
134  $current_selection_list = new ilAdvancedSelectionListGUI();
135  $current_selection_list->setListTitle($this->lng->txt("actions"));
136  $current_selection_list->setId("act_" . md5($a_set['members_id'] . '::' . $a_set['search_' . $this->mode['short']]));
137 
138  $this->ctrl->setParameter($this->parent_obj, 'search_members', $a_set['members_id']);
139  $this->ctrl->setParameter(
140  $this->parent_obj,
141  'search_' . $this->mode['short'],
142  is_array($_REQUEST['search_' . $this->mode['short']]) ?
143  implode(',', array_filter(array_map('intval', $_REQUEST['search_' . $this->mode['short']]))) :
144  ilUtil::stripSlashes($_REQUEST['search_' . $this->mode['short']])
145  );
146  $this->ctrl->setParameter($this->parent_obj, 'view', $this->mode['view']);
147 
148  $action_html = '';
149  if ($this->context == "mail") {
150  if ($this->mailing_allowed) {
151  $current_selection_list->addItem($this->lng->txt("mail_member"), '', $this->ctrl->getLinkTarget($this->parent_obj, "mail"));
152  }
153  } else {
154  $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $this->ctrl->getLinkTarget($this->parent_obj, "share"));
155  }
156 
157  if ($this->context == 'mail' && ilBuddySystem::getInstance()->isEnabled()) {
158  $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId($a_set['members_id']);
159  if (
160  $a_set['members_id'] != $this->user->getId() &&
161  $relation->isUnlinked() &&
162  ilUtil::yn2tf(ilObjUser::_lookupPref($a_set['members_id'], 'bs_allow_to_contact_me'))
163  ) {
164  $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $a_set['members_id']);
165  $current_selection_list->addItem($this->lng->txt('buddy_bs_btn_txt_unlinked_a'), '', $this->ctrl->getLinkTargetByClass('ilBuddySystemGUI', 'request'));
166  }
167  }
168 
169  if ($current_selection_list->getItems()) {
170  $action_html = $current_selection_list->getHTML();
171  }
172  $this->tpl->setVariable(strtoupper('CURRENT_ACTION_LIST'), $action_html);
173 
174  foreach ($a_set as $key => $value) {
175  $this->tpl->setVariable(strtoupper($key), $value);
176  }
177  }
178 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static getInstanceByGlobalUser()
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setId($a_val)
Set id.
user()
Definition: user.php:4
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
This class handles base functions for mail handling.
addMultiCommand($a_cmd, $a_text)
Add Command button.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static _lookupPref($a_usr_id, $a_keyword)
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
__construct($a_parent_obj, $type='crs', $context='mail', $contextObjects)
Constructor.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
static yn2tf($a_yn)
convert "y"/"n" to true/false
getId()
Get element id.
$key
Definition: croninfo.php:18
$_POST["username"]