/** * @param $a_parent_obj * @param string $a_parent_cmd * @param ilMailingList $mailing_list */ public function __construct($a_parent_obj, $a_parent_cmd = '', ilMailingList $mailing_list) { /** * @var $lng ilLanguage * @var $ilCtrl ilCtrl */ global $lng, $ilCtrl; $this->lng = $lng; $this->ctrl = $ilCtrl; $this->setId('show_mlng_mmbrs_list_tbl_' . $mailing_list->getId()); parent::__construct($a_parent_obj, $a_parent_cmd); $this->setFormAction($this->ctrl->getFormAction($a_parent_obj), 'showMemberForm'); $this->setTitle($this->lng->txt('mail_members_of_mailing_list') . ' ' . $mailing_list->getTitle()); $this->setRowTemplate('tpl.mail_mailing_lists_membersrow.html', 'Services/Contact'); $this->setDefaultOrderField('title'); $this->addCommandButton('showAssignmentForm', $this->lng->txt('add')); $this->addCommandButton('showMailingLists', $this->lng->txt('back')); $this->initColumns(); }
public function getAll() { $res = $this->db->queryf(' SELECT * FROM addressbook_mlist WHERE user_id = %s', array('integer'), array($this->user->getId())); $entries = array(); $counter = 0; while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $tmpObj = new ilMailingList($this->user, 0); $tmpObj->setId($row->ml_id); $tmpObj->setUserId($row->user_id); $tmpObj->setTitle($row->title); $tmpObj->setDescription($row->description); $tmpObj->setCreatedate($row->createdate); $tmpObj->setChangedate($row->changedae); $tmpObj->setMode($row->lmode); $entries[$counter] = $tmpObj; unset($tmpObj); ++$counter; } return $entries; }
public function showAssignmentForm() { global $ilUser, $ilErr; if (!$this->mlists->getCurrentMailingList()->getId()) { $this->showMembersList(); return true; } if (!ilMailingList::_isOwner($this->mlists->getCurrentMailingList()->getId(), $ilUser->getId())) { $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE); } $this->tpl->setTitle($this->lng->txt('mail_addressbook')); $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.mail_mailing_lists_members_form.html', 'Services/Contact'); include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; $form = new ilPropertyFormGUI(); $this->ctrl->setParameter($this, 'ml_id', $this->mlists->getCurrentMailingList()->getId()); $form->setFormAction($this->ctrl->getFormAction($this, 'saveForm')); $form->setTitle($this->lng->txt('mail_assign_entry_to_mailing_list') . ' ' . $this->mlists->getCurrentMailingList()->getTitle()); $options = array(); $options[''] = $this->lng->txt('please_select'); $all_entries = $this->abook->getEntries(); if ((int) count($all_entries)) { foreach ($all_entries as $entry) { $options[$entry['addr_id']] = $entry['login'] != '' ? $entry['login'] : $entry['email']; } } $assigned_entries = $this->mlists->getCurrentMailingList()->getAssignedEntries(); if ((int) count($assigned_entries)) { foreach ($assigned_entries as $assigned_entry) { if (is_array($options) && array_key_exists($assigned_entry['addr_id'], $options)) { unset($options[$assigned_entry['addr_id']]); } } } if (count($options) > 1) { $formItem = new ilSelectInputGUI($this->lng->txt('mail_entry_of_addressbook'), 'addr_id'); $formItem->setOptions($options); $formItem->setValue($this->mlists->getCurrentMailingList()->getTitle()); $form->addItem($formItem); $form->addCommandButton('saveAssignmentForm', $this->lng->txt('assign')); } else { if (count($options) == 1 && (int) count($all_entries)) { ilUtil::sendInfo($this->lng->txt('mail_mailing_lists_all_addressbook_entries_assigned')); } else { if (!(int) count($all_entries)) { ilUtil::sendInfo($this->lng->txt('mail_mailing_lists_no_addressbook_entries')); } } } $form->addCommandButton('showMembersList', $this->lng->txt('cancel')); $this->tpl->setVariable('FORM', $form->getHTML()); $this->tpl->show(); return true; }
function mailObject() { global $ilUser; $user_ids = $this->getActionUserIds(); if (!$user_ids) { ilUtil::sendFailure($this->lng->txt('select_one')); return $this->viewObject(); } // remove existing (temporary) lists include_once "Services/Contact/classes/class.ilMailingLists.php"; $list = new ilMailingLists($ilUser); $list->deleteTemporaryLists(); // create (temporary) mailing list include_once "Services/Contact/classes/class.ilMailingList.php"; $list = new ilMailingList($ilUser); $list->setMode(ilMailingList::MODE_TEMPORARY); $list->setTitle("-TEMPORARY SYSTEM LIST-"); $list->setDescription("-USER ACCOUNTS MAIL-"); $list->setCreateDate(date("Y-m-d H:i:s")); $list->insert(); $list_id = $list->getId(); // after list has been saved... foreach ($user_ids as $user_id) { $list->assignAddressbookEntry($user_id); } include_once "Services/Mail/classes/class.ilFormatMail.php"; $umail = new ilFormatMail($ilUser->getId()); $mail_data = $umail->getSavedData(); if (!is_array($mail_data)) { $mail_data = array("user_id" => $ilUser->getId()); } // ??? // $mail_data = $umail->appendSearchResult(array('#il_ml_'.$list_id), 'to'); $umail->savePostData($mail_data['user_id'], $mail_data['attachments'], '#il_ml_' . $list_id, $mail_data['rcp_cc'], $mail_data['rcp_bcc'], $mail_data['m_type'], $mail_data['m_email'], $mail_data['m_subject'], $mail_data['m_message'], $mail_data['use_placeholders']); ilUtil::redirect("ilias.php?baseClass=ilMailGUI&type=search_res"); }