ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilAddressbookTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12include_once('Services/Table/classes/class.ilTable2GUI.php');
13include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
14
15
17{
18 protected $lng = null;
19 protected $ctrl;
20
24 private $mailing_allowed = false;
28 private $smtp_mailing_allowed = false;
32 private $cron_upd_adrbook = false;
36 private $chat_active = false;
37
41 private $filter = array();
42
50 public function __construct($a_parent_obj, $a_parent_cmd = '', $is_mailing_allowed = false, $is_chat_active = false)
51 {
52 global $lng, $ilCtrl, $ilSetting;
53
54 $this->lng = $lng;
55 $this->ctrl = $ilCtrl;
56
57 $this->setMailingAllowed($is_mailing_allowed);
58 $this->setChatActive($is_chat_active);
59
60 $this->setId('addr_book');
61 parent::__construct($a_parent_obj, $a_parent_cmd);
62
63 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, 'setAddressbookFilter'));
64
65 $this->setTitle($lng->txt("mail_addr_entries"));
66 $this->setRowTemplate("tpl.mail_addressbook_row.html", "Services/Contact");
67
68 $this->setDefaultOrderField('login');
69
70 $this->cron_upd_adrbook = $ilSetting->get('cron_upd_adrbook', 0);
71
72 $width = '20%';
73 if($this->cron_upd_adrbook != 0)
74 {
75 $width = '16.6%';
76 }
77
78 $this->addColumn('', 'addr_id', '1px', true);
79 $this->addColumn($this->lng->txt('login'), 'login', $width);
80 $this->addColumn($this->lng->txt('firstname'), 'firstname', $width);
81 $this->addColumn($this->lng->txt('lastname'), 'lastname', $width);
82 $this->addColumn($this->lng->txt('email'), 'email', $width);
83
84 if($ilSetting->get('cron_upd_adrbook', 0) != 0)
85 {
86 $this->addColumn($this->lng->txt('auto_update'), 'auto_update', $width);
87 }
88 $this->addColumn($this->lng->txt('actions'), 'actions', '20%');
89
90 $this->enable('select_all');
91 $this->setSelectAllCheckbox('addr_id');
92 $this->addCommandButton('showAddressForm', $this->lng->txt('add'));
93
94 if($this->mailing_allowed)
95 {
96 $this->addMultiCommand('mailToUsers', $this->lng->txt('send_mail_to'));
97 }
98 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
99
100 if($this->chat_active)
101 {
102 $this->addMultiCommand('inviteToChat', $this->lng->txt('invite_to_chat'));
103 }
104
105 $this->initFilter();
106 $this->setFilterCommand('setAddressbookFilter');
107 $this->setResetCommand('resetAddressbookFilter');
108 }
109
115 public function formatCellValue($key, $value)
116 {
117 switch($key)
118 {
119 case 'addr_id':
120 $value = ilUtil::formCheckbox(0, 'addr_id[]', $value);
121 break;
122 case 'auto_update':
123 if($this->cron_upd_adrbook != 0)
124 {
125 $value = $value == 1 ? $this->lng->txt('yes') : $this->lng->txt('no');
126 }
127 else
128 {
129 $value = '';
130 }
131 break;
132 }
133
134 return $value;
135 }
136
144 public function fillRow($row)
145 {
146 foreach ($row as $key => $value)
147 {
148 $value = $this->formatCellValue($key, $value);
149 $this->ctrl->setParameter($this->parent_obj, 'addr_id', $row['addr_id']);
150
151 if($key == 'check')
152 {
153 $this->tpl->setVariable("VAL_LOGIN_LINKED_LOGIN", $value);
154 }
155
156 if($key == "login" && $value != "")
157 {
158 if($this->mailing_allowed)
159 {
160 $this->tpl->setVariable("VAL_LOGIN_LINKED_LINK", $this->ctrl->getLinkTarget($this->parent_obj, 'mailToUsers'));
161 $this->tpl->setVariable("VAL_LOGIN_LINKED_LOGIN", $value);
162 }
163 else
164 {
165 $this->tpl->setVariable("VAL_LOGIN_UNLINKED", $value);
166 }
167 }
168
169 if($key == "email")
170 {
171 if($_GET["baseClass"] == "ilMailGUI" && $this->smtp_mailing_allowed)
172 {
173 $this->tpl->setVariable("VAL_EMAIL_LINKED_LINK", $this->ctrl->getLinkTarget($this->parent_obj, 'mailToUsers'));
174 $this->tpl->setVariable("VAL_EMAIL_LINKED_EMAIL", $value);
175 }
176 else
177 {
178 $this->tpl->setVariable("VAL_EMAIL_UNLINKED", $value);
179 }
180 }
181
182 if($key == 'auto_update' && $this->cron_upd_adrbook != 0)
183 {
184 $this->tpl->setVariable("VAL_CRON_AUTO_UPDATE", $value);
185 }
186
187 $this->tpl->setVariable("VAL_".strtoupper($key), $value);
188 }
189
190 $current_selection_list = new ilAdvancedSelectionListGUI();
191 $current_selection_list->setListTitle($this->lng->txt("actions"));
192 $current_selection_list->setId("act_" . $row['addr_id']);
193
194 $current_selection_list->addItem($this->lng->txt("edit"), '', $this->ctrl->getLinkTarget($this->parent_obj, "showAddressForm"));
195
196 if($this->mailing_allowed)
197 {
198 $current_selection_list->addItem($this->lng->txt("send_mail_to"), '', $this->ctrl->getLinkTarget($this->parent_obj, "mailToUsers"));
199 }
200
201 $current_selection_list->addItem($this->lng->txt("delete"), '', $this->ctrl->getLinkTarget($this->parent_obj, "confirmDelete"));
202
203
204 if($this->chat_active)
205 {
206 $current_selection_list->addItem($this->lng->txt("invite_to_chat"), '', $this->ctrl->getLinkTarget($this->parent_obj, "inviteToChat"));
207 }
208 $this->tpl->setVariable("VAL_ACTIONS", $current_selection_list->getHTML());
209 }
210
211
212 public function initFilter()
213 {
214 include_once 'Services/Form/classes/class.ilTextInputGUI.php';
215 $ul = new ilTextInputGUI($this->lng->txt('login').'/'.$this->lng->txt('email').'/'.$this->lng->txt('name'), 'query');
216 $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'lookupAddressbookAsync', '', true));
217 $ul->setSize(20);
218 $ul->setSubmitFormOnEnter(true);
219 $this->addFilterItem($ul);
220 $ul->readFromSession();
221 $this->filter['query'] = $ul->getValue();
222 }
223
224
226 {
227 $this->mailing_allowed = $mailing_allowed;
228 }
229
234 {
235 $this->chat_active = $chat_active;
236 }
237
242 {
243 $this->smtp_mailing_allowed = $smtp_mailing_allowed;
244 }
245
249 public function getFilterQuery()
250 {
251 return $this->filter['query'];
252 }
253
254}
255?>
$_GET["client_id"]
setSmtpMailingAllowed($smtp_mailing_allowed)
__construct($a_parent_obj, $a_parent_cmd='', $is_mailing_allowed=false, $is_chat_active=false)
Constructor.
User interface class for advanced drop-down selection lists.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
enable($a_module_name)
enables particular modules of table
This class represents a text property in a property form.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:40