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');
45 $this->ctrl->saveParameter($this,
'ref');
50 $forward_class = $this->ctrl->getNextClass($this);
51 switch ($forward_class)
54 if (!(
$cmd = $this->ctrl->getCmd()))
56 $cmd =
'showMailingLists';
75 include_once(
'Services/Utilities/classes/class.ilConfirmationGUI.php');
78 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDelete'));
79 $c_gui->setHeaderText($this->lng->txt(
'mail_sure_delete_entry'));
80 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showMailingLists');
81 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDelete');
83 $entries = $this->mlists->getSelected($ml_ids);
84 foreach($entries as $entry)
86 $c_gui->addItem(
'ml_id[]', $entry->getId(), $entry->getTitle());
89 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
90 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_list.html',
'Services/Contact');
91 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
102 if (is_array(
$_POST[
'ml_id']))
105 foreach (
$_POST[
'ml_id'] as $id)
131 include_once
"Services/Mail/classes/class.ilMail.php";
133 $mailing_allowed = $rbacsystem->checkAccess(
'internal_mail',$mail->getMailObjectReferenceId());
135 if (!$mailing_allowed)
149 $mail_data = $this->umail->getSavedData();
150 if(!is_array($mail_data))
152 $this->umail->savePostData($ilUser->getId(), array(),
'',
'',
'',
'',
'',
'',
'',
'');
156 foreach($ml_ids as $id)
159 !$this->umail->doesRecipientStillExists(
'#il_ml_'.$id, $mail_data[
'rcp_to']))
161 $lists[] =
'#il_ml_'.$id;
167 $mail_data = $this->umail->appendSearchResult($lists,
'to');
168 $this->umail->savePostData(
169 $mail_data[
'user_id'],
170 $mail_data[
'attachments'],
171 $mail_data[
'rcp_to'],
172 $mail_data[
'rcp_cc'],
173 $mail_data[
'rcp_bcc'],
174 $mail_data[
'm_type'],
175 $mail_data[
'm_email'],
176 $mail_data[
'm_subject'],
177 $mail_data[
'm_message'],
178 $mail_data[
'use_placeholders']
191 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
192 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_list.html',
'Services/Contact');
195 include_once
"Services/Mail/classes/class.ilMail.php";
197 $mailing_allowed = $rbacsystem->checkAccess(
'internal_mail',$mail->getMailObjectReferenceId());
200 $tbl->setId(
'show_mlng_lists_tbl');
201 $tbl->setFormAction($this->ctrl->getFormAction($this),
'showForm');
202 $tbl->setTitle($this->lng->txt(
'mail_mailing_lists'));
203 $tbl->setRowTemplate(
'tpl.mail_mailing_lists_listrow.html',
'Services/Contact');
205 $tbl->setDefaultOrderField(
'title');
209 $tbl->addColumn(
'',
'check',
'10%',
true);
210 $tbl->addColumn($this->lng->txt(
'title'),
'title',
'30%');
211 $tbl->addColumn($this->lng->txt(
'description'),
'description',
'30%');
212 $tbl->addColumn($this->lng->txt(
'members'),
'members',
'20%');
213 $tbl->addColumn($this->lng->txt(
'actions'),
'',
'10%');
215 $entries = $this->mlists->getAll();
218 $tbl->enable(
'select_all');
219 $tbl->setSelectAllCheckbox(
'ml_id');
223 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
225 foreach ($entries as $entry)
228 $result[$counter][
'title'] = $entry->getTitle() .
" [#il_ml_" . $entry->getId() .
"]";
229 $result[$counter][
'description'] = $entry->getDescription();
230 $result[$counter][
'members'] = count($entry->getAssignedEntries());
232 $this->ctrl->setParameter($this,
'ml_id', $entry->getId());
239 $current_selection_list->setListTitle($this->lng->txt(
"actions"));
240 $current_selection_list->setId(
"act_".$counter);
242 $current_selection_list->addItem($this->lng->txt(
"edit"),
'', $this->ctrl->getLinkTarget($this,
"showForm"));
243 $current_selection_list->addItem($this->lng->txt(
"members"),
'', $this->ctrl->getLinkTarget($this,
"showMembersList"));
244 if ($mailing_allowed)
245 $current_selection_list->addItem($this->lng->txt(
"send_mail_to"),
'', $this->ctrl->getLinkTarget($this,
"mailToList"));
246 $current_selection_list->addItem($this->lng->txt(
"delete"),
'', $this->ctrl->getLinkTarget($this,
"confirmDelete"));
248 $result[$counter][
'COMMAND_SELECTION_LIST'] = $current_selection_list->getHTML();
253 if ($mailing_allowed)
254 $tbl->addMultiCommand(
'mailToList', $this->lng->txt(
'send_mail_to'));
255 $tbl->addMultiCommand(
'confirmDelete', $this->lng->txt(
'delete'));
259 $tbl->disable(
'header');
260 $tbl->disable(
'footer');
262 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
267 $tbl->addCommandButton(
'showForm', $this->lng->txt(
'add'));
269 if(isset(
$_GET[
'ref']) &&
$_GET[
'ref'] ==
'mail')
271 $tbl->addCommandButton(
'cancel', $this->lng->txt(
'cancel'));
274 $this->tpl->setVariable(
'MAILING_LISTS', $tbl->getHTML());
285 if(isset(
$_GET[
'ref']) &&
$_GET[
'ref'] ==
'mail')
287 $this->ctrl->returnToParent($this);
297 if($this->mlists->getCurrentMailingList()->getId())
303 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
306 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
314 if($this->form_gui->checkInput())
316 $this->mlists->getCurrentMailingList()->setTitle(
$_POST[
'title']);
317 $this->mlists->getCurrentMailingList()->setDescription(
$_POST[
'description']);
318 if($this->mlists->getCurrentMailingList()->getId())
320 $this->mlists->getCurrentMailingList()->setChangedate(date(
'Y-m-d H:i:s', time()));
321 $this->mlists->getCurrentMailingList()->update();
326 $this->mlists->getCurrentMailingList()->setCreatedate(date(
'Y-m-d H:i:s', time()));
327 $this->mlists->getCurrentMailingList()->insert();
328 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
329 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'saveForm'));
331 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
332 $this->ctrl->redirect($this,
'showMembersList');
338 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
339 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_form.html',
'Services/Contact');
341 $this->form_gui->setValuesByPost();
343 $this->tpl->setVariable(
'FORM', $this->form_gui->getHTML());
344 return $this->tpl->show();
349 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
352 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'saveForm'));
353 $this->form_gui->setTitle($this->lng->txt(
'mail_mailing_list'));
355 $titleGui =
new ilTextInputGUI($this->lng->txt(
'title'),
'title');
357 $this->form_gui->addItem($titleGui);
359 $descriptionGui =
new ilTextAreaInputGUI($this->lng->txt(
'description'),
'description');
361 $descriptionGui->setRows(8);
362 $this->form_gui->addItem($descriptionGui);
364 $this->form_gui->addCommandButton(
'saveForm',$this->lng->txt(
'save'));
365 $this->form_gui->addCommandButton(
'showMailingLists',$this->lng->txt(
'cancel'));
370 $this->form_gui->setValuesByArray(array(
371 'title' => $this->mlists->getCurrentMailingList()->getTitle(),
372 'description' => $this->mlists->getCurrentMailingList()->getDescription()
378 $this->form_gui->setValuesByArray(array(
388 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
389 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_form.html',
'Services/Contact');
391 if($this->mlists->getCurrentMailingList()->getId())
395 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
398 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
408 $this->tpl->setVariable(
'FORM', $this->form_gui->getHTML());
409 return $this->tpl->show();
414 if (!$this->mlists->getCurrentMailingList()->getId())
421 $this->ctrl->setParameter($this,
'cmd',
'post');
422 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
424 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
425 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_members.html',
'Services/Contact');
428 $tbl->setId(
'show_mlng_mmbrs_list_tbl');
429 $tbl->setFormAction($this->ctrl->getFormAction($this),
'showMemberForm');
430 $tbl->setTitle($this->lng->txt(
'mail_members_of_mailing_list') .
' ' .$this->mlists->getCurrentMailingList()->getTitle());
431 $tbl->setRowTemplate(
'tpl.mail_mailing_lists_membersrow.html',
'Services/Contact');
433 $this->ctrl->setParameter($this,
'cmd',
'showMembersList');
435 $tbl->setDefaultOrderField(
'title');
439 $tbl->addColumn(
'',
'check',
'10%');
440 $tbl->addColumn($this->lng->txt(
'title'),
'title',
'90%');
442 $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
443 if (count($assigned_entries))
445 $tbl->enable(
'select_all');
446 $tbl->setSelectAllCheckbox(
'a_id');
449 foreach ($assigned_entries as $entry)
452 $result[$counter][
'title'] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
457 $tbl->addMultiCommand(
'confirmDeleteMembers', $this->lng->txt(
'delete'));
461 $tbl->disable(
'header');
462 $tbl->disable(
'footer');
464 $tbl->setNoEntriesText($this->lng->txt(
'mail_search_no'));
469 $tbl->addCommandButton(
'showAssignmentForm', $this->lng->txt(
'add'));
470 $tbl->addCommandButton(
'showMailingLists', $this->lng->txt(
'back'));
472 $this->tpl->setVariable(
'MEMBERS_LIST', $tbl->getHTML());
480 if (!isset(
$_POST[
'a_id']))
487 include_once(
'Services/Utilities/classes/class.ilConfirmationGUI.php');
489 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
490 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDeleteMembers'));
491 $c_gui->setHeaderText($this->lng->txt(
'mail_sure_delete_entry'));
492 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showMembersList');
493 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDeleteMembers');
495 $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
496 if (is_array($assigned_entries))
498 foreach ($assigned_entries as $entry)
500 if (in_array($entry[
'a_id'],
$_POST[
'a_id']))
502 $c_gui->addItem(
'a_id[]', $entry[
'a_id'], ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']));
507 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
508 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_members.html',
'Services/Contact');
509 $this->tpl->setVariable(
'DELETE_CONFIRMATION', $c_gui->getHTML());
522 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
525 if (is_array(
$_POST[
'a_id']))
527 foreach (
$_POST[
'a_id'] as $id)
550 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
553 if (
$_POST[
'addr_id'] ==
'') $this->
setError($this->lng->txt(
'mail_entry_of_addressbook'));
559 $all_entries = $this->abook->getEntries();
560 if ((
int)count($all_entries))
562 foreach ($all_entries as $entry)
564 if($entry[
'addr_id'] ==
$_POST[
'addr_id'])
588 if ($this->
isError()) $mandatory .=
', ';
591 ilUtil::sendInfo($this->lng->txt(
'fill_out_all_required_fields') .
': ' . $mandatory);
603 if (!$this->mlists->getCurrentMailingList()->getId())
612 $ilErr->raiseError($this->lng->txt(
'permission_denied'), $ilErr->MESSAGE);
615 $this->tpl->setTitle($this->lng->txt(
'mail_addressbook'));
616 $this->tpl->addBlockFile(
'ADM_CONTENT',
'adm_content',
'tpl.mail_mailing_lists_members_form.html',
'Services/Contact');
618 include_once(
'./Services/Form/classes/class.ilPropertyFormGUI.php');
621 $this->ctrl->setParameter($this,
'ml_id', $this->mlists->getCurrentMailingList()->getId());
622 $form->setFormAction($this->ctrl->getFormAction($this,
'saveForm'));
623 $form->setTitle($this->lng->txt(
'mail_assign_entry_to_mailing_list') .
' ' . $this->mlists->getCurrentMailingList()->getTitle());
626 $options[
''] = $this->lng->txt(
'please_select');
628 $all_entries = $this->abook->getEntries();
629 if ((
int)count($all_entries))
631 foreach ($all_entries as $entry)
633 $options[$entry[
'addr_id']] = ($entry[
'login'] !=
'' ? $entry[
'login'] : $entry[
'email']);
637 $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries();
638 if ((
int)count($assigned_entries))
640 foreach ($assigned_entries as $assigned_entry)
642 if (is_array($options) && array_key_exists($assigned_entry[
'addr_id'], $options))
644 unset($options[$assigned_entry[
'addr_id']]);
649 if (count($options) > 1)
651 $formItem =
new ilSelectInputGUI($this->lng->txt(
'mail_entry_of_addressbook'),
'addr_id');
653 $formItem->setValue($this->mlists->getCurrentMailingList()->getTitle());
654 $form->addItem($formItem);
656 $form->addCommandButton(
'saveAssignmentForm',$this->lng->txt(
'assign'));
658 else if(count($options) == 1 && (int)count($all_entries))
660 ilUtil::sendInfo($this->lng->txt(
'mail_mailing_lists_all_addressbook_entries_assigned'));
662 else if(!(
int)count($all_entries))
664 ilUtil::sendInfo($this->lng->txt(
'mail_mailing_lists_no_addressbook_entries'));
668 $form->addCommandButton(
'showMembersList',$this->lng->txt(
'cancel'));
670 $this->tpl->setVariable(
'FORM', $form->getHTML());
678 return $this->error[] = $a_error;
682 return array_pop($this->error);
686 if (is_array($this->error) && !empty($this->error))
return true;