5 require_once
"Services/Table/classes/class.ilTable2GUI.php";
6 require_once
"Services/Contact/classes/class.ilMailingLists.php";
7 require_once
"Services/Mail/classes/class.ilFormatMail.php";
8 require_once
"Services/Contact/classes/class.ilAddressbook.php";
42 $this->mlists->setCurrentMailingList(
$_GET[
'ml_id']);
44 $this->ctrl->saveParameter($this,
'mobj_id');
49 $forward_class = $this->ctrl->getNextClass($this);
50 switch ($forward_class)
53 if (!(
$cmd = $this->ctrl->getCmd()))
55 $cmd =
'showMailingLists';
74 include_once(
'Services/Utilities/classes/class.ilConfirmationGUI.php');
77 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDelete'));
78 $c_gui->setHeaderText($this->lng->txt(
'mail_sure_delete_entry'));
79 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showMailingLists');
80 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDelete');
82 $entries = $this->mlists->getSelected($ml_ids);
83 foreach($entries as $entry)
85 $c_gui->addItem(
'ml_id[]', $entry->getId(), $entry->getTitle());
88 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
89 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_list.html',
'Services/Contact');
90 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
101 if (is_array(
$_POST[
'ml_id']))
104 foreach (
$_POST[
'ml_id'] as $id)
127 global $ilUser, $rbacsystem;
130 include_once
"Services/Mail/classes/class.ilMail.php";
132 $mailing_allowed = $rbacsystem->checkAccess(
'mail_visible',$mail->getMailObjectReferenceId());
134 if (!$mailing_allowed)
148 $mail_data = $this->umail->getSavedData();
149 if(!is_array($mail_data))
151 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
155 foreach($ml_ids as $id)
158 !$this->umail->doesRecipientStillExists(
'#il_ml_'.$id, $mail_data[
'rcp_to']))
160 $lists[] =
'#il_ml_'.$id;
166 $mail_data = $this->umail->appendSearchResult($lists,
'to');
167 $this->umail->savePostData(
168 $mail_data[
'user_id'],
169 $mail_data[
'attachments'],
170 $mail_data[
'rcp_to'],
171 $mail_data[
'rcp_cc'],
172 $mail_data[
'rcp_bcc'],
173 $mail_data[
'm_type'],
174 $mail_data[
'm_email'],
175 $mail_data[
'm_subject'],
176 $mail_data[
'm_message'],
177 $mail_data[
'use_placeholders']
190 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
191 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_list.html',
'Services/Contact');
194 include_once
"Services/Mail/classes/class.ilMail.php";
196 $mailing_allowed = $rbacsystem->checkAccess(
'mail_visible',$mail->getMailObjectReferenceId());
199 $tbl->setId(
'show_mlng_lists_tbl');
200 $tbl->setFormAction($this->ctrl->getFormAction($this),
'showForm');
201 $tbl->setTitle($this->lng->txt(
'mail_mailing_lists'));
202 $tbl->setRowTemplate(
'tpl.mail_mailing_lists_listrow.html',
'Services/Contact');
204 $tbl->setDefaultOrderField(
'title');
208 $tbl->addColumn(
'',
'check',
'10%',
true);
209 $tbl->addColumn($this->lng->txt(
'title'),
'title',
'30%');
210 $tbl->addColumn($this->lng->txt(
'description'),
'description',
'30%');
211 $tbl->addColumn($this->lng->txt(
'members'),
'members',
'20%');
212 $tbl->addColumn($this->lng->txt(
'actions'),
'',
'10%');
214 $entries = $this->mlists->getAll();
217 $tbl->enable(
'select_all');
218 $tbl->setSelectAllCheckbox(
'ml_id');
222 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
224 foreach ($entries as $entry)
227 $result[$counter][
'title'] = $entry->getTitle() .
" [#il_ml_" . $entry->getId() .
"]";
228 $result[$counter][
'description'] = $entry->getDescription();
229 $result[$counter][
'members'] = count($entry->getAssignedEntries());
231 $this->ctrl->setParameter($this,
'ml_id', $entry->getId());
238 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
239 $current_selection_list->setId(
"act_".$counter);
241 $current_selection_list->addItem($this->lng->txt(
"edit"),
'', $this->ctrl->getLinkTarget($this,
"showForm"));
242 $current_selection_list->addItem($this->lng->txt(
"members"),
'', $this->ctrl->getLinkTarget($this,
"showMembersList"));
243 if ($mailing_allowed)
244 $current_selection_list->addItem($this->lng->txt(
"send_mail_to"),
'', $this->ctrl->getLinkTarget($this,
"mailToList"));
245 $current_selection_list->addItem($this->lng->txt(
"delete"),
'', $this->ctrl->getLinkTarget($this,
"confirmDelete"));
247 $result[$counter][
'COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
252 if ($mailing_allowed)
253 $tbl->addMultiCommand(
'mailToList', $this->lng->txt(
'send_mail_to'));
254 $tbl->addMultiCommand(
'confirmDelete', $this->lng->txt(
'delete'));
258 $tbl->disable(
'header');
259 $tbl->disable(
'footer');
261 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
264 $tbl->setData($result);
266 $tbl->addCommandButton(
'showForm', $this->lng->txt(
'add'));
268 $this->tpl->setVariable(
'MAILING_LISTS', $tbl->getHTML());
276 if($this->mlists->getCurrentMailingList()->getId())
282 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
285 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
293 if($this->form_gui->checkInput())
295 $this->mlists->getCurrentMailingList()->setTitle(
$_POST[
'title']);
296 $this->mlists->getCurrentMailingList()->setDescription(
$_POST[
'description']);
297 if($this->mlists->getCurrentMailingList()->getId())
299 $this->mlists->getCurrentMailingList()->setChangedate(date(
'Y-m-d H:i:s', time()));
300 $this->mlists->getCurrentMailingList()->update();
305 $this->mlists->getCurrentMailingList()->setCreatedate(date(
'Y-m-d H:i:s', time()));
306 $this->mlists->getCurrentMailingList()->insert();
307 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
308 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'saveForm'));
310 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
311 $this->ctrl->redirect($this,
'showMembersList');
317 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
318 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_form.html',
'Services/Contact');
320 $this->form_gui->setValuesByPost();
322 $this->tpl->setVariable(
'FORM', $this->form_gui->getHTML());
323 return $this->tpl->show();
328 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
331 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'saveForm'));
332 $this->form_gui->setTitle($this->lng->txt(
'mail_mailing_list'));
334 $titleGui =
new ilTextInputGUI($this->lng->txt(
'title'),
'title');
336 $this->form_gui->addItem($titleGui);
338 $descriptionGui =
new ilTextAreaInputGUI($this->lng->txt(
'description'),
'description');
340 $descriptionGui->setRows(8);
341 $this->form_gui->addItem($descriptionGui);
343 $this->form_gui->addCommandButton(
'saveForm',$this->lng->txt(
'save'));
344 $this->form_gui->addCommandButton(
'showMailingLists',$this->lng->txt(
'cancel'));
349 $this->form_gui->setValuesByArray(array(
350 'title' => $this->mlists->getCurrentMailingList()->getTitle(),
351 'description' => $this->mlists->getCurrentMailingList()->getDescription()
357 $this->form_gui->setValuesByArray(array(
367 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
368 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_form.html',
'Services/Contact');
370 if($this->mlists->getCurrentMailingList()->getId())
374 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
377 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
387 $this->tpl->setVariable(
'FORM', $this->form_gui->getHTML());
388 return $this->tpl->show();
393 if (!$this->mlists->getCurrentMailingList()->getId())
400 $this->ctrl->setParameter($this,
'cmd',
'post');
401 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
403 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
404 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_members.html',
'Services/Contact');
407 $tbl->setId(
'show_mlng_mmbrs_list_tbl');
408 $tbl->setFormAction($this->ctrl->getFormAction($this),
'showMemberForm');
409 $tbl->setTitle($this->lng->txt(
'mail_members_of_mailing_list') .
' ' .$this->mlists->getCurrentMailingList()->getTitle());
410 $tbl->setRowTemplate(
'tpl.mail_mailing_lists_membersrow.html',
'Services/Contact');
412 $this->ctrl->setParameter($this,
'cmd',
'showMembersList');
414 $tbl->setDefaultOrderField(
'title');
418 $tbl->addColumn(
'',
'check',
'10%');
419 $tbl->addColumn($this->lng->txt(
'title'),
'title',
'90%');
421 $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
422 if (count($assigned_entries))
424 $tbl->enable(
'select_all');
425 $tbl->setSelectAllCheckbox(
'a_id');
428 foreach ($assigned_entries as $entry)
431 $result[$counter][
'title'] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
436 $tbl->addMultiCommand(
'confirmDeleteMembers', $this->lng->txt(
'delete'));
440 $tbl->disable(
'header');
441 $tbl->disable(
'footer');
443 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
446 $tbl->setData($result);
448 $tbl->addCommandButton(
'showAssignmentForm', $this->lng->txt(
'add'));
449 $tbl->addCommandButton(
'showMailingLists', $this->lng->txt(
'back'));
451 $this->tpl->setVariable(
'MEMBERS_LIST', $tbl->getHTML());
459 if (!isset(
$_POST[
'a_id']))
466 include_once(
'Services/Utilities/classes/class.ilConfirmationGUI.php');
468 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
469 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDeleteMembers'));
470 $c_gui->setHeaderText($this->lng->txt(
'mail_sure_delete_entry'));
471 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showMembersList');
472 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDeleteMembers');
474 $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
475 if (is_array($assigned_entries))
477 foreach ($assigned_entries as $entry)
479 if (in_array($entry[
'a_id'],
$_POST[
'a_id']))
481 $c_gui->addItem(
'a_id[]', $entry[
'a_id'], ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']));
486 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
487 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_members.html',
'Services/Contact');
488 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
501 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
504 if (is_array(
$_POST[
'a_id']))
506 foreach (
$_POST[
'a_id'] as $id)
529 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
532 if (
$_POST[
'addr_id'] ==
'') $this->
setError($this->lng->txt(
'mail_entry_of_addressbook'));
538 $all_entries = $this->abook->getEntries();
539 if ((
int)count($all_entries))
541 foreach ($all_entries as $entry)
543 if($entry[
'addr_id'] ==
$_POST[
'addr_id'])
567 if ($this->
isError()) $mandatory .=
', ';
570 ilUtil::sendInfo($this->lng->txt(
'fill_out_all_required_fields') .
': ' . $mandatory);
582 if (!$this->mlists->getCurrentMailingList()->getId())
591 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
594 $this->tpl->setVariable(
'HEADER', $this->lng->txt(
'mail'));
595 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_members_form.html',
'Services/Contact');
597 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
600 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
601 $form->setFormAction($this->ctrl->getFormAction($this,
'saveForm'));
602 $form->setTitle($this->lng->txt(
'mail_assign_entry_to_mailing_list') .
' ' . $this->mlists->getCurrentMailingList()->getTitle());
605 $options[
''] = $this->lng->txt(
'please_select');
607 $all_entries = $this->abook->getEntries();
608 if ((
int)count($all_entries))
610 foreach ($all_entries as $entry)
612 $options[$entry[
'addr_id']] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
616 $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
617 if ((
int)count($assigned_entries))
619 foreach ($assigned_entries as $assigned_entry)
621 if (is_array($options) && array_key_exists($assigned_entry[
'addr_id'], $options))
623 unset($options[$assigned_entry[
'addr_id']]);
628 if (count($options) > 1)
630 $formItem =
new ilSelectInputGUI($this->lng->txt(
'mail_entry_of_addressbook'),
'addr_id');
632 $formItem->setValue($this->mlists->getCurrentMailingList()->getTitle());
633 $form->addItem($formItem);
635 $form->addCommandButton(
'saveAssignmentForm',$this->lng->txt(
'assign'));
637 else if(count($options) == 1 && (int)count($all_entries))
639 ilUtil::sendInfo($this->lng->txt(
'mail_mailing_lists_all_addressbook_entries_assigned'));
641 else if(!(
int)count($all_entries))
643 ilUtil::sendInfo($this->lng->txt(
'mail_mailing_lists_no_addressbook_entries'));
647 $form->addCommandButton(
'showMembersList',$this->lng->txt(
'cancel'));
649 $this->tpl->setVariable(
'FORM', $form->getHTML());
657 return $this->error[] = $a_error;
661 return array_pop($this->error);
665 if (is_array($this->error) && !empty($this->error))
return true;