ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
NewMailNotification.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29use ILIAS\Refinery\Factory as Refinery;
30
32{
34 private array $mail_options_by_user = [];
35
36 public function getIdentifier(): string
37 {
38 return 'new_mail_notification';
39 }
40
41 public function isAvailable(): bool
42 {
43 $settings = new \ilSetting();
44
45 return
46 $settings->get('mail_notification') === '1' &&
47 $settings->get('show_mail_settings', '0') === '1';
48 }
49
50 public function getLabel(Language $lng): string
51 {
52 return $lng->txt('cron_mail_notification');
53 }
54
56 {
57 return AvailablePages::MainSettings;
58 }
59
60 public function getSection(): AvailableSections
61 {
62 return AvailableSections::Communication;
63 }
64
65 public function getInput(
66 FieldFactory $field_factory,
70 ?\ilObjUser $user = null
71 ): Input {
72 $lng->loadLanguageModule('mail');
73
74 return $field_factory->checkbox(
75 $this->getLabel($lng),
76 $lng->txt('mail_cronjob_notification_info')
77 )->withValue(
78 $user !== null && $this->retrieveValueFromUser($user)
79 );
80 }
81
82 public function getLegacyInput(
85 ?\ilObjUser $user = null
87 $lng->loadLanguageModule('mail');
88
89 $input = new \ilCheckboxInputGUI($this->getLabel($lng));
90 $input->setInfo($lng->txt('mail_cronjob_notification_info'));
91 $input->setChecked(
92 $user !== null && $this->retrieveValueFromUser($user)
93 );
94 $input->setValue('1');
95
96 return $input;
97 }
98
102 ): string {
103 return $lng->txt('no');
104 }
105
108 \ilObjUser $user
109 ): bool {
110 $value = $this->retrieveValueFromUser($user);
111 return $value !== false;
112 }
113
114 public function persistUserInput(
115 \ilObjUser $user,
116 mixed $input,
117 ?\ilPropertyFormGUI $form = null
118 ): \ilObjUser {
119 $mail_options = $this->mailOptionsFor($user);
120 $mail_options->setIsCronJobNotificationStatus($input === true || $input === '1');
121 $mail_options->updateOptions();
122
123 return $user;
124 }
125
126 public function retrieveValueFromUser(\ilObjUser $user): bool
127 {
128 return $this->mailOptionsFor($user)->isCronJobNotificationEnabled();
129 }
130
131 private function mailOptionsFor(\ilObjUser $user): \ilMailOptions
132 {
133 if (!\array_key_exists($user->getId(), $this->mail_options_by_user)) {
134 $this->mail_options_by_user[$user->getId()] = new \ilMailOptions($user->getId());
135 }
136
137 return $this->mail_options_by_user[$user->getId()];
138 }
139}
$settings
Definition: index.php:44
Builds data types.
Definition: Factory.php:36
hasUserPersonalizedSetting(\ilSetting $settings, \ilObjUser $user)
getDefaultValueForDisplay(Language $lng, \ilSetting $settings)
persistUserInput(\ilObjUser $user, mixed $input, ?\ilPropertyFormGUI $form=null)
isAvailable()
If this function returns false the setting will not be shown, even if it's PropertyAttributes would a...
getLegacyInput(Language $lng, \ilSetting $settings, ?\ilObjUser $user=null)
You don't need to add a post_var to the input as the User will handle this for you,...
getInput(FieldFactory $field_factory, Language $lng, Refinery $refinery, \ilSetting $settings, ?\ilObjUser $user=null)
This class represents a property in a property form.
User class.
This class represents a property form user interface.
ILIAS Setting Class.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes commonalities between all inputs.
Definition: Input.php:47
global $lng
Definition: privfeed.php:26