ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilMailOptionsFormGUI Class Reference
+ Inheritance diagram for ilMailOptionsFormGUI:
+ Collaboration diagram for ilMailOptionsFormGUI:

Public Member Functions

 __construct (protected ilMailOptions $options, object $parent_gui, protected string $positive_command, ?AutoresponderRepository $auto_responder_repository=null)
 
 save ()
 
 populate ()
 
- Public Member Functions inherited from ilPropertyFormGUI
 __construct ()
 
 executeCommand ()
 
 setTableWidth (string $a_width)
 
 getTableWidth ()
 
 setMode (string $a_mode)
 
 getMode ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setTitleIcon (string $a_titleicon)
 
 getTitleIcon ()
 
 setDescription (string $a_val)
 
 getDescription ()
 
 setTopAnchor (string $a_val)
 
 getTopAnchor ()
 
 setShowTopButtons (bool $a_val)
 
 getShowTopButtons ()
 
 setForceTopButtons (bool $a_val)
 
 getForceTopButtons ()
 
 addItem ($a_item)
 
 removeItemByPostVar (string $a_post_var, bool $a_remove_unused_headers=false)
 
 getItemByPostVar (string $a_post_var)
 
 setItems (array $a_items)
 
 getItems ()
 
 getInputItemsRecursive ()
 returns a flat array of all input items including the possibly existing subitems recursively More...
 
 setDisableStandardMessage (bool $a_val)
 
 getDisableStandardMessage ()
 
 getHideLabels ()
 
 setHideLabels (bool $a_value=true)
 
 setValuesByArray (array $a_values, bool $a_restrict_to_value_keys=false)
 
 setValuesByPost ()
 
 checkInput ()
 
 getInput (string $a_post_var, bool $ensureValidation=true)
 Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-POST variable, identified by the passed postvar. More...
 
 addCommandButton (string $a_cmd, string $a_text, string $a_id="")
 
 getCommandButtons ()
 
 clearCommandButtons ()
 
 getContent ()
 
 insertItem ( $item, bool $a_sub_item=false)
 
 addAsyncOnloadCode (string $code)
 
 getHTML ()
 
 getHTMLAsync ()
 
 getFileUpload (string $a_field, ?string $a_index=null, ?string $a_sub_index=null)
 Get file upload data. More...
 
 hasFileUpload (string $a_field, ?string $a_index=null, ?string $a_sub_index=null)
 
 moveFileUpload (string $a_target_directory, string $a_field, ?string $a_target_name=null, ?string $a_index=null, ?string $a_sub_index=null)
 Move upload to target directory. More...
 
- Public Member Functions inherited from ilFormGUI
 setFormAction (string $a_formaction)
 
 getFormAction ()
 
 setTarget (string $a_target)
 
 getTarget ()
 
 setMultipart (bool $a_multipart)
 
 getMultipart ()
 
 setId (string $a_id)
 
 getId ()
 
 setName (string $a_name)
 
 getName ()
 
 setKeepOpen (bool $a_keepopen)
 
 getKeepOpen ()
 
 setOpenTag (bool $a_open)
 
 getOpenTag ()
 
 setCloseTag (bool $a_val)
 
 getCloseTag ()
 
 setPreventDoubleSubmission (bool $a_val)
 
 getPreventDoubleSubmission ()
 
 getHTML ()
 
 getContent ()
 

Protected Member Functions

 init ()
 
- Protected Member Functions inherited from ilPropertyFormGUI
 getRequestedPostVar ()
 
 getFileHash ()
 
 hideRequired (string $a_type)
 
 appendOnloadCode (string $html)
 
 rebuildUploadedFiles ()
 
 checkForRequiredField ()
 

Protected Attributes

object $parent_gui
 
AutoResponderRepository $auto_responder_repository
 
- Protected Attributes inherited from ilPropertyFormGUI
bool $required_text = false
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilTemplate $tpl
 
ilObjUser $user = null
 
ilSetting $settings = null
 
string $mode = "std"
 
bool $check_input_called = false
 
bool $disable_standard_message = false
 
string $top_anchor = "il_form_top"
 
string $title = ''
 
string $titleicon = ""
 
string $description = ""
 
string $tbl_width = ""
 
bool $show_top_buttons = true
 
bool $hide_labels = false
 
bool $force_top_buttons = false
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
ilGlobalTemplateInterface $global_tpl = null
 
 $onload_code = []
 
- Protected Attributes inherited from ilFormGUI
string $formaction = ""
 
bool $multipart = false
 
bool $keepopen = false
 
bool $opentag = true
 
string $id = ''
 
string $name = ''
 
string $target = ''
 
bool $prevent_double_submission = false
 

Private Attributes

readonly int $default_auto_responder_absence_end_ts
 

Detailed Description

Definition at line 25 of file class.ilMailOptionsFormGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailOptionsFormGUI::__construct ( protected ilMailOptions  $options,
object  $parent_gui,
protected string  $positive_command,
?AutoresponderRepository  $auto_responder_repository = null 
)

Definition at line 31 of file class.ilMailOptionsFormGUI.php.

References $DIC, $parent_gui, ILIAS\GlobalScreen\Provider\__construct(), and init().

36  {
37  if (!method_exists($parent_gui, 'executeCommand')) {
38  throw new InvalidArgumentException(sprintf(
39  'Parameter $parent_gui must be ilCtrlInterface enabled by implementing executeCommand(), %s given.',
40  $parent_gui::class
41  ));
42  }
43 
45  global $DIC;
46  $this->parent_gui = $parent_gui;
47  $this->positive_command = $positive_command;
48  $this->auto_responder_repository = $auto_responder_repository ?? new AutoresponderDatabaseRepository($DIC->database());
49  $this->default_auto_responder_absence_end_ts = time() + 8640;
50 
51  $this->init();
52  }
AutoResponderRepository $auto_responder_repository
global $DIC
Definition: shib_login.php:26
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ init()

ilMailOptionsFormGUI::init ( )
protected

Definition at line 54 of file class.ilMailOptionsFormGUI.php.

References $duration, ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), ilTextAreaInputGUI\setRows(), ILIAS\Repository\settings(), and ilPropertyFormGUI\setTitle().

Referenced by __construct().

54  : void
55  {
56  $this->setTitle($this->lng->txt('mail_settings'));
57  $this->setFormAction($this->ctrl->getFormAction($this->parent_gui, $this->positive_command));
58 
59  if ($this->options->maySeeIndividualTransportSettings()) {
60  $incoming_mail_gui = new ilIncomingMailInputGUI(
61  $this->lng->txt('mail_incoming'),
62  'incoming_type',
63  false
64  );
65  $this->addItem($incoming_mail_gui);
66  }
67 
68  $absence = new ilCheckboxInputGUI($this->lng->txt('mail_absence_status'), 'absence_status');
69  $absence->setInfo($this->lng->txt('mail_absence_status_info'));
70  $absence->setValue("1");
71  $this->lng->loadLanguageModule('dateplaner');
72  $duration = new ilDateDurationInputGUI($this->lng->txt('mail_absence_duration'), 'absence_duration');
73  $duration->setRequired(true);
74  $duration->setStartText($this->lng->txt('mail_absent_from'));
75  $duration->setEndText($this->lng->txt('mail_absent_until'));
76  $duration->setShowTime(true);
77  $auto_responder_subject = new ilTextInputGUI($this->lng->txt('mail_absence_auto_responder_subject'), 'absence_auto_responder_subject');
78  $auto_responder_subject->setMaxLength(200);
79  $auto_responder_subject->setRequired(true);
80  $auto_responder_body = new ilTextAreaInputGUI($this->lng->txt('mail_absence_auto_responder_body'), 'absence_auto_responder_body');
81  $idle_time = (int) $this->settings->get('mail_auto_responder_idle_time', (string) AutoresponderService::AUTO_RESPONDER_DEFAULT_IDLE_TIME);
82  if ($idle_time === 1) {
83  $auto_responder_body->setInfo($this->lng->txt('mail_absence_auto_responder_body_info_single_day'));
84  } else {
85  $auto_responder_body->setInfo(sprintf($this->lng->txt('mail_absence_auto_responder_body_info'), $idle_time));
86  }
87  $auto_responder_body->setRequired(true);
88  $auto_responder_body->setCols(60);
89  $auto_responder_body->setRows(10);
90  $absence->addSubItem($duration);
91  $absence->addSubItem($auto_responder_subject);
92  $absence->addSubItem($auto_responder_body);
93  $this->addItem($absence);
94 
95  $ta = new ilTextAreaInputGUI($this->lng->txt('signature'), 'signature');
96  $ta->setRows(10);
97  $ta->setCols(60);
98  $this->addItem($ta);
99 
100  if ($this->settings->get('mail_notification', '0')) {
101  $cb = new ilCheckboxInputGUI(
102  $this->lng->txt('cron_mail_notification'),
103  'cronjob_notification'
104  );
105  $cb->setInfo($this->lng->txt('mail_cronjob_notification_info'));
106  $cb->setValue('1');
107  $this->addItem($cb);
108  }
109 
110  $this->addCommandButton($this->positive_command, $this->lng->txt('save'));
111  }
$duration
setFormAction(string $a_formaction)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populate()

ilMailOptionsFormGUI::populate ( )

Definition at line 161 of file class.ilMailOptionsFormGUI.php.

References $data, $default_auto_responder_absence_end_ts, IL_CAL_DATETIME, IL_CAL_UNIX, and ilPropertyFormGUI\setValuesByArray().

Referenced by ilMailOptionsGUI\showOptions().

161  : void
162  {
163  $data = [
164  'signature' => $this->options->getSignature(),
165  'cronjob_notification' => $this->options->isCronJobNotificationEnabled(),
166  'absence_status' => $this->options->getAbsenceStatus(),
167  'absence_duration' => [
168  'start' => (new ilDateTime(($this->options->getAbsentFrom() ?: time()), IL_CAL_UNIX))->get(IL_CAL_DATETIME),
169  'end' => (new ilDateTime(($this->options->getAbsentUntil() ?: $this->default_auto_responder_absence_end_ts), IL_CAL_UNIX))->get(IL_CAL_DATETIME),
170  ],
171  'absence_auto_responder_subject' => $this->options->getAbsenceAutoresponderSubject(),
172  'absence_auto_responder_body' => $this->options->getAbsenceAutoresponderBody(),
173  ];
174 
175  if ($this->options->maySeeIndividualTransportSettings()) {
176  $data['incoming_type'] = $this->options->getIncomingType();
177 
178  $mail_address_option = $this->options->getEmailAddressMode();
179 
180  $data['mail_address_option'] = $mail_address_option;
181  $data['mail_address_option_both'] = $mail_address_option;
182  }
183 
184  $this->setValuesByArray($data);
185  }
const IL_CAL_DATETIME
readonly int $default_auto_responder_absence_end_ts
const IL_CAL_UNIX
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilMailOptionsFormGUI::save ( )

Definition at line 113 of file class.ilMailOptionsFormGUI.php.

References ilPropertyFormGUI\checkInput(), ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), IL_CAL_UNIX, ilMailOptions\INCOMING_BOTH, ilMailOptions\INCOMING_EMAIL, ILIAS\Repository\int(), and ILIAS\Repository\user().

Referenced by ilMailOptionsGUI\saveOptions().

113  : bool
114  {
115  if (!$this->checkInput()) {
116  return false;
117  }
118 
119  if ($this->options->mayModifyIndividualTransportSettings()) {
120  $incoming_type = (int) $this->getInput('incoming_type');
121 
122  $mail_address_option = $this->options->getEmailAddressMode();
123  switch ($incoming_type) {
125  $mail_address_option = (int) $this->getInput('mail_address_option');
126  break;
127 
129  $mail_address_option = (int) $this->getInput('mail_address_option_both');
130  break;
131  }
132  } else {
133  $incoming_type = $this->options->getIncomingType();
134  $mail_address_option = $this->options->getEmailAddressMode();
135  }
136 
137  $absence_duration = $this->getItemByPostVar('absence_duration');
138  $absence_status = (bool) $this->getInput('absence_status');
139  $old_absence_status = $this->options->getAbsenceStatus();
140  if (!$absence_status && $old_absence_status) {
141  $this->auto_responder_repository->deleteBySenderId($this->user->getId());
142  }
143  $this->options->setAbsenceStatus((bool) $this->getInput('absence_status'));
144  if ($absence_duration && $absence_duration->getStart() && $absence_duration->getEnd()) {
145  $this->options->setAbsentFrom($absence_duration->getStart()->get(IL_CAL_UNIX));
146  $this->options->setAbsentUntil($absence_duration->getEnd()->get(IL_CAL_UNIX));
147  }
148  $this->options->setAbsenceAutoresponderSubject($this->getInput('absence_auto_responder_subject'));
149  $this->options->setAbsenceAutoresponderBody($this->getInput('absence_auto_responder_body'));
150 
151  $this->options->setSignature($this->getInput('signature'));
152  $this->options->setIsCronJobNotificationStatus((bool) $this->getInput('cronjob_notification'));
153  $this->options->setIncomingType($incoming_type);
154  $this->options->setEmailAddressmode($mail_address_option);
155 
156  $this->options->updateOptions();
157 
158  return true;
159  }
final const int INCOMING_BOTH
getItemByPostVar(string $a_post_var)
final const int INCOMING_EMAIL
const IL_CAL_UNIX
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $auto_responder_repository

AutoResponderRepository ilMailOptionsFormGUI::$auto_responder_repository
protected

Definition at line 29 of file class.ilMailOptionsFormGUI.php.

◆ $default_auto_responder_absence_end_ts

readonly int ilMailOptionsFormGUI::$default_auto_responder_absence_end_ts
private

Definition at line 27 of file class.ilMailOptionsFormGUI.php.

Referenced by populate().

◆ $parent_gui

object ilMailOptionsFormGUI::$parent_gui
protected

Definition at line 28 of file class.ilMailOptionsFormGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: