ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
12 include_once('Services/Table/classes/class.ilTable2GUI.php');
13 
14 
16 {
17  protected $lng = null;
18  protected $ctrl;
19  protected $parentObject;
20  protected $mode;
21  protected $mailing_allowed;
31  public function __construct($a_parent_obj, $type = 'crs', $context = 'mail')
32  {
33  global $lng,$ilCtrl, $ilUser, $lng, $rbacsystem;
34 
35  $this->context = $context;
36  if($this->context == "mail")
37  {
38  // check if current user may send mails
39  include_once "Services/Mail/classes/class.ilMail.php";
40  $mail = new ilMail($_SESSION["AccountId"]);
41  $this->mailing_allowed = $rbacsystem->checkAccess('internal_mail',$mail->getMailObjectReferenceId());
42  }
43 
44  parent::__construct($a_parent_obj, 'showMembers');
45  $lng->loadLanguageModule('crs');
46  $this->parentObject = $a_parent_obj;
47  $mode = array();
48  if ($type == 'crs')
49  {
50  $mode["checkbox"] = 'search_crs';
51  $mode["short"] = 'crs';
52  $mode["long"] = 'course';
53  $mode["lng_type"] = $lng->txt('course');
54  $mode["view"] = "crs_members";
55  $mode["tableprefix"] = "crstable_members";
56  }
57  else if ($type == 'grp')
58  {
59  $mode["checkbox"] = 'search_grp';
60  $mode["short"] = 'grp';
61  $mode["long"] = 'group';
62  $mode["lng_type"] = $lng->txt('group');
63  $mode["view"] = "grp_members";
64  $mode["tableprefix"] = "grptable_members";
65  }
66  $this->setTitle($lng->txt('members'));
67  $this->mode = $mode;
68  $ilCtrl->setParameter($a_parent_obj, 'view', $mode['view']);
69  if ($_GET['ref'] != '')
70  $ilCtrl->setParameter($a_parent_obj, 'ref', $_GET['ref']);
71  if (is_array($_POST[$mode["checkbox"]]))
72  $ilCtrl->setParameter($a_parent_obj, $mode["checkbox"], implode(',', $_POST[$mode["checkbox"]]));
73 
74  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
75  $ilCtrl->clearParameters($a_parent_obj);
76 
77  $this->setPrefix($mode['tableprefix']);
78  $this->setSelectAllCheckbox('search_members[]');
79  $this->setRowTemplate('tpl.mail_search_courses_members_row.html', 'Services/Contact');
80 
81  // setup columns
82  $this->addColumn('', '', '1%', true);
83  $this->addColumn($lng->txt('login'), 'members_login', '22%');
84  $this->addColumn($lng->txt('name'), 'members_name', '22%');
85  $this->addColumn($lng->txt($mode['long']), 'members_crs_grp', '22%');
86  $this->addColumn($lng->txt('mail_in_addressbook'), 'members_in_addressbook', '23%');
87  $this->addColumn($lng->txt('actions'), '', '10%');
88 
89  if($this->context == "mail")
90  {
91  if ($this->mailing_allowed)
92  $this->addMultiCommand('mail', $lng->txt('mail_members'));
93  $this->addMultiCommand('adoptMembers', $lng->txt("mail_into_addressbook"));
94  }
95  else
96  {
97  $lng->loadLanguageModule("wsp");
98  $this->addMultiCommand('share', $lng->txt("wsp_share_with_members"));
99  }
100 
101  $this->addCommandButton('cancel', $lng->txt('cancel'));
102  }
103 
111  public function fillRow($a_set)
112  {
113  global $ilCtrl;
114  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
115  $current_selection_list = new ilAdvancedSelectionListGUI();
116  $current_selection_list->setListTitle($this->lng->txt("actions"));
117  $current_selection_list->setId("act_".md5($a_set['members_id'].'::'.$a_set['search_' . $this->mode['short']]));
118 
119  $ilCtrl->setParameter($this->parentObject, 'search_members', $a_set['members_id']);
120  $ilCtrl->setParameter($this->parentObject, 'search_' . $this->mode['short'],
121  is_array($_REQUEST['search_' . $this->mode['short']]) ?
122  implode(',', array_filter(array_map('intval', $_REQUEST['search_' . $this->mode['short']]))) :
123  (int)$_REQUEST['search_' . $this->mode['short']]
124  );
125  $ilCtrl->setParameter($this->parentObject, 'view', $this->mode['view']);
126 
127  if($this->context == "mail")
128  {
129  if ($this->mailing_allowed)
130  $current_selection_list->addItem($this->lng->txt("mail_member"), '', $ilCtrl->getLinkTarget($this->parentObject, "mail"));
131  $current_selection_list->addItem($this->lng->txt("mail_into_addressbook"), '', $ilCtrl->getLinkTarget($this->parentObject, "adoptMembers"));
132  }
133  else
134  {
135  $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $ilCtrl->getLinkTarget($this->parentObject, "share"));
136  }
137 
138  $this->tpl->setVariable(strtoupper('CURRENT_ACTION_LIST'), $current_selection_list->getHTML());
139 
140  foreach ($a_set as $key => $value)
141  {
142  $this->tpl->setVariable(strtoupper($key), $value);
143  }
144  }
145 }
146 ?>