ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailOptionsFormGUI Class Reference

Class ilMailOptionsFormGUI. More...

+ Inheritance diagram for ilMailOptionsFormGUI:
+ Collaboration diagram for ilMailOptionsFormGUI:

Public Member Functions

 __construct (protected ilMailOptions $options, object $parentGui, protected string $positiveCmd, ?AutoresponderRepository $autoResponderRepository=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 $parentGui
 
AutoResponderRepository $autoResponderRepository
 
- 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

Class ilMailOptionsFormGUI.

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

Constructor & Destructor Documentation

◆ __construct()

ilMailOptionsFormGUI::__construct ( protected ilMailOptions  $options,
object  $parentGui,
protected string  $positiveCmd,
?AutoresponderRepository  $autoResponderRepository = null 
)

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

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

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

Member Function Documentation

◆ init()

ilMailOptionsFormGUI::init ( )
protected

Definition at line 57 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().

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

◆ populate()

ilMailOptionsFormGUI::populate ( )

Definition at line 164 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().

164  : void
165  {
166  $data = [
167  'signature' => $this->options->getSignature(),
168  'cronjob_notification' => $this->options->isCronJobNotificationEnabled(),
169  'absence_status' => $this->options->getAbsenceStatus(),
170  'absence_duration' => [
171  'start' => (new ilDateTime(($this->options->getAbsentFrom() ?: time()), IL_CAL_UNIX))->get(IL_CAL_DATETIME),
172  'end' => (new ilDateTime(($this->options->getAbsentUntil() ?: $this->default_auto_responder_absence_end_ts), IL_CAL_UNIX))->get(IL_CAL_DATETIME),
173  ],
174  'absence_auto_responder_subject' => $this->options->getAbsenceAutoresponderSubject(),
175  'absence_auto_responder_body' => $this->options->getAbsenceAutoresponderBody(),
176  ];
177 
178  if ($this->options->maySeeIndividualTransportSettings()) {
179  $data['incoming_type'] = $this->options->getIncomingType();
180 
181  $mail_address_option = $this->options->getEmailAddressMode();
182 
183  $data['mail_address_option'] = $mail_address_option;
184  $data['mail_address_option_both'] = $mail_address_option;
185  }
186 
187  $this->setValuesByArray($data);
188  }
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 116 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().

116  : bool
117  {
118  if (!$this->checkInput()) {
119  return false;
120  }
121 
122  if ($this->options->mayModifyIndividualTransportSettings()) {
123  $incoming_type = (int) $this->getInput('incoming_type');
124 
125  $mail_address_option = $this->options->getEmailAddressMode();
126  switch ($incoming_type) {
128  $mail_address_option = (int) $this->getInput('mail_address_option');
129  break;
130 
132  $mail_address_option = (int) $this->getInput('mail_address_option_both');
133  break;
134  }
135  } else {
136  $incoming_type = $this->options->getIncomingType();
137  $mail_address_option = $this->options->getEmailAddressMode();
138  }
139 
140  $absence_duration = $this->getItemByPostVar('absence_duration');
141  $absence_status = (bool) $this->getInput('absence_status');
142  $old_absence_status = $this->options->getAbsenceStatus();
143  if (!$absence_status && $old_absence_status) {
144  $this->autoResponderRepository->deleteBySenderId($this->user->getId());
145  }
146  $this->options->setAbsenceStatus((bool) $this->getInput('absence_status'));
147  if ($absence_duration && $absence_duration->getStart() && $absence_duration->getEnd()) {
148  $this->options->setAbsentFrom($absence_duration->getStart()->get(IL_CAL_UNIX));
149  $this->options->setAbsentUntil($absence_duration->getEnd()->get(IL_CAL_UNIX));
150  }
151  $this->options->setAbsenceAutoresponderSubject($this->getInput('absence_auto_responder_subject'));
152  $this->options->setAbsenceAutoresponderBody($this->getInput('absence_auto_responder_body'));
153 
154  $this->options->setSignature($this->getInput('signature'));
155  $this->options->setIsCronJobNotificationStatus((bool) $this->getInput('cronjob_notification'));
156  $this->options->setIncomingType($incoming_type);
157  $this->options->setEmailAddressMode($mail_address_option);
158 
159  $this->options->updateOptions();
160 
161  return true;
162  }
getItemByPostVar(string $a_post_var)
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-...
final const INCOMING_EMAIL
final const INCOMING_BOTH
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $autoResponderRepository

AutoResponderRepository ilMailOptionsFormGUI::$autoResponderRepository
protected

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

◆ $default_auto_responder_absence_end_ts

readonly int ilMailOptionsFormGUI::$default_auto_responder_absence_end_ts
private

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

Referenced by populate().

◆ $parentGui

object ilMailOptionsFormGUI::$parentGui
protected

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

Referenced by __construct().


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