ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMailOptionsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
15  private $tpl;
16 
20  private $ctrl;
21 
25  private $lng;
26 
30  private $settings;
31 
35  private $user;
36 
40  private $umail;
41 
45  private $mbox;
46 
50  protected $request;
51 
55  protected $form = null;
56 
68  public function __construct(
69  \ilTemplate $tpl = null,
70  \ilCtrl $ctrl = null,
71  \ilSetting $setting = null,
72  \ilLanguage $lng = null,
73  \ilObjUser $user = null,
74  \Psr\Http\Message\ServerRequestInterface $request = null,
75  \ilFormatMail $mail = null,
76  \ilMailbox $malBox = null
77  ) {
78  global $DIC;
79 
80  $this->tpl = $tpl;
81  if (null === $this->tpl) {
82  $this->tpl = $DIC->ui()->mainTemplate();
83  }
84 
85  $this->ctrl = $ctrl;
86  if (null === $this->ctrl) {
87  $this->ctrl = $DIC->ctrl();
88  }
89 
90  $this->settings = $setting;
91  if (null === $this->settings) {
92  $this->settings = $DIC->settings();
93  }
94 
95  $this->lng = $lng;
96  if (null === $this->lng) {
97  $this->lng = $DIC->language();
98  }
99 
100  $this->user = $user;
101  if (null === $this->user) {
102  $this->user = $DIC->user();
103  }
104 
105  $this->request = $request;
106  if (null === $this->request) {
107  $this->request = $DIC->http()->request();
108  }
109 
110  $this->umail = $mail;
111  if (null === $this->umail) {
112  $this->umail = new \ilFormatMail($this->user->getId());
113  }
114 
115  $this->mbox = $malBox;
116  if (null === $this->mbox) {
117  $this->mbox = new \ilMailbox($this->user->getId());
118  }
119 
120  $this->lng->loadLanguageModule('mail');
121  $this->ctrl->saveParameter($this, 'mobj_id');
122  }
123 
124  public function executeCommand()
125  {
126  if (!$this->settings->get('show_mail_settings')) {
127  $referrer = $this->request->getQueryParams()['referrer'] ?? '';
128  if (strtolower('ilPersonalSettingsGUI') === strtolower($referrer)) {
129  $this->ctrl->redirectByClass('ilPersonalSettingsGUI');
130  return;
131  }
132  $this->ctrl->redirectByClass('ilMailGUI');
133  return;
134  }
135 
136  $nextClass = $this->ctrl->getNextClass($this);
137  switch ($nextClass) {
138  default:
139  if (!($cmd = $this->ctrl->getCmd())) {
140  $cmd = 'showOptions';
141  }
142 
143  $this->$cmd();
144  break;
145  }
146  }
147 
152  {
153  $this->form = $form;
154  }
155 
159  protected function getForm()
160  {
161  if (null !== $this->form) {
162  return $this->form;
163  }
164 
165  return new \ilMailOptionsFormGUI(
166  new \ilMailOptions($this->user->getId()),
167  $this,
168  'saveOptions'
169  );
170  }
171 
176  protected function saveOptions()
177  {
178  $this->tpl->setTitle($this->lng->txt('mail'));
179 
180  $form = $this->getForm();
181  if ($form->save()) {
182  ilUtil::sendSuccess($this->lng->txt('mail_options_saved'), true);
183  $this->ctrl->redirect($this, 'showOptions');
184  }
185 
186  $this->showOptions($form);
187  }
188 
193  protected function showOptions(\ilMailOptionsFormGUI $form = null)
194  {
195  if (null === $form) {
196  $form = $this->getForm();
197  $form->populate();
198  } else {
199  $form->setValuesByPost();
200  }
201 
202  $this->tpl->setContent($form->getHTML());
203  $this->tpl->show();
204  }
205 }
Class ilMailOptions this class handles user mails.
This class provides processing control methods.
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
__construct(\ilTemplate $tpl=null, \ilCtrl $ctrl=null, \ilSetting $setting=null, \ilLanguage $lng=null, \ilObjUser $user=null, \Psr\Http\Message\ServerRequestInterface $request=null, \ilFormatMail $mail=null, \ilMailbox $malBox=null)
ilMailOptionsGUI constructor.
saveOptions()
Called if the user pushes the submit button of the mail options form.
user()
Definition: user.php:4
Class UserMail this class handles user mails.
Class ilMailOptionsFormGUI.
Mail Box class Base class for creating and handling mail boxes.
special template class to simplify handling of ITX/PEAR
showOptions(\ilMailOptionsFormGUI $form=null)
Called to display the mail options form.
setForm(\ilMailOptionsFormGUI $form)
language handling