ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Mail\Provider\MailGlobalScreenToolProvider Class Reference
+ Inheritance diagram for ILIAS\Mail\Provider\MailGlobalScreenToolProvider:
+ Collaboration diagram for ILIAS\Mail\Provider\MailGlobalScreenToolProvider:

Public Member Functions

 __construct (Container $dic, ?UIFactory $ui_factory=null, ?UIRenderer $ui_renderer=null, ?ilObjUser $user=null, ?ilCtrlInterface $ctrl=null, ?HttpWrapper $http_wrapper=null, ?Refinery $refinery=null, ?ilLanguage $lng=null, ?IconFactory $icon_factory=null)
 
 isInterestedInContexts ()
 
 getToolsForContextStack (CalledContexts $called_contexts)
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider
 __construct (Container $dic)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (protected Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getToolsForContextStack (CalledContexts $called_contexts)
 
 isInterestedInContexts ()
 

Data Fields

final const string SHOW_MAIL_FOLDERS_TOOL = 'show_mail_folders_tool'
 

Private Member Functions

 buildSubItems ()
 
 buildFolderLink (int $folderId, string|array $class, ?string $cmd=null)
 
 buildItem (string $title, string $icon_name, string $link)
 
 buildIcon (string $title, string $type)
 
 filterUserFolders (array &$folders)
 

Private Attributes

readonly UIFactory $ui_factory
 
readonly UIRenderer $ui_renderer
 
readonly ilMailbox $mbox
 
readonly ilObjUser $user
 
readonly ilCtrlInterface $ctrl
 
readonly HttpWrapper $http_wrapper
 
readonly Refinery $refinery
 
readonly ilLanguage $lng
 
readonly IconFactory $icon_factory
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider
ToolIdentificationProviderInterface $identification_provider
 
ContextCollection $context_collection
 
ToolFactory $factory
 

Detailed Description

Definition at line 51 of file MailGlobalScreenToolProvider.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::__construct ( Container  $dic,
?UIFactory  $ui_factory = null,
?UIRenderer  $ui_renderer = null,
?ilObjUser  $user = null,
?ilCtrlInterface  $ctrl = null,
?HttpWrapper  $http_wrapper = null,
?Refinery  $refinery = null,
?ilLanguage  $lng = null,
?IconFactory  $icon_factory = null 
)

Definition at line 65 of file MailGlobalScreenToolProvider.php.

75 {
77 $this->ui_factory = $ui_factory ?? $this->dic->ui()->factory();
78 $this->ui_renderer = $ui_renderer ?? $this->dic->ui()->renderer();
79 $this->user = $user ?? $this->dic->user();
80 $this->ctrl = $ctrl ?? $this->dic->ctrl();
81 $this->http_wrapper = $http_wrapper ?? $this->dic->http()->wrapper();
82 $this->refinery = $refinery ?? $this->dic->refinery();
83 $this->lng = $lng ?? $this->dic->language();
84 $this->icon_factory = $icon_factory ?? $this->ui_factory->symbol()->icon();
85
86 $this->mbox = new ilMailbox($this->user->getId());
87 }
$dic
Definition: ltiresult.php:33
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $dic, ILIAS\Mail\Provider\MailGlobalScreenToolProvider\$http_wrapper, ILIAS\Mail\Provider\MailGlobalScreenToolProvider\$icon_factory, ILIAS\Mail\Provider\MailGlobalScreenToolProvider\$ui_factory, ILIAS\Mail\Provider\MailGlobalScreenToolProvider\$ui_renderer, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildFolderLink()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::buildFolderLink ( int  $folderId,
string|array  $class,
?string  $cmd = null 
)
private
Parameters
class-string|list<class-string>$class
Exceptions
ilCtrlException

Definition at line 206 of file MailGlobalScreenToolProvider.php.

206 : string
207 {
208 $this->ctrl->setParameterByClass(is_array($class) ? current($class) : $class, 'mobj_id', $folderId);
209 $url = $this->ctrl->getLinkTargetByClass($class, $cmd);
210 $this->ctrl->setParameterByClass(is_array($class) ? current($class) : $class, 'mob_id', null);
211
212 return $url;
213 }
$url
Definition: shib_logout.php:68

References $url, and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ buildIcon()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::buildIcon ( string  $title,
string  $type 
)
private

Definition at line 224 of file MailGlobalScreenToolProvider.php.

224 : CustomIcon
225 {
226 return $this->icon_factory->custom(
227 ilUtil::getImagePath("standard/icon_$type.svg"),
228 $title
229 );
230 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References ilUtil\getImagePath().

Referenced by ILIAS\Mail\Provider\MailGlobalScreenToolProvider\buildItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildItem()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::buildItem ( string  $title,
string  $icon_name,
string  $link 
)
private

Definition at line 215 of file MailGlobalScreenToolProvider.php.

215 : BulkyButton
216 {
217 return $this->ui_factory->button()->bulky(
218 $this->buildIcon($title, $icon_name),
219 $title,
220 $link
221 );
222 }

References ILIAS\Mail\Provider\MailGlobalScreenToolProvider\buildIcon().

Referenced by ILIAS\Mail\Provider\MailGlobalScreenToolProvider\buildSubItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildSubItems()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::buildSubItems ( )
private
Returns
Clickable[]

Definition at line 155 of file MailGlobalScreenToolProvider.php.

155 : array
156 {
157 $items = [];
158
159 $folders = $this->mbox->getSubFolders();
160 usort(
161 $folders,
162 static fn(MailFolderData $a, MailFolderData $b): int => $a->isTrash() && !$b->isUserLocalFolder() ? 1 : 0
163 );
164 $user_folders = $this->filterUserFolders($folders);
165
166 foreach ($folders as $folder) {
167 if ($folder->isUserLocalFolder() && $user_folders !== []) {
168 $icon_name = $folder->getType()->value;
169 $items[] = $this->ui_factory->menu()->sub(
170 $folder->getTitle(),
171 [
172 $this->buildItem(
173 $this->lng->txt('mail_main_folder'),
174 $icon_name,
175 $this->buildFolderLink($folder->getFolderId(), ilMailFolderGUI::class)
176 ),
177 ...array_map(
178 function (MailFolderData $folder) use ($icon_name): BulkyButton {
179 return $this->buildItem(
180 $folder->getTitle(),
181 $icon_name,
182 $this->buildFolderLink($folder->getFolderId(), ilMailFolderGUI::class)
183 );
184 },
185 $user_folders
186 ),
187 ]
188 );
189 continue;
190 }
191
192 $items[] = $this->buildItem(
193 $folder->getTitle(),
194 $folder->getType()->value,
195 $this->buildFolderLink($folder->getFolderId(), ilMailFolderGUI::class)
196 );
197 }
198
199 return $items;
200 }
buildItem(string $title, string $icon_name, string $link)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, ILIAS\Mail\Provider\MailGlobalScreenToolProvider\buildItem(), ILIAS\Mail\Provider\MailGlobalScreenToolProvider\filterUserFolders(), ILIAS\Mail\Folder\MailFolderData\getFolderId(), and ILIAS\Mail\Folder\MailFolderData\getTitle().

+ Here is the call graph for this function:

◆ filterUserFolders()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::filterUserFolders ( array &  $folders)
private
Parameters
list<MailFolderData>$folders
Returns
list<MailFolderData>

Definition at line 236 of file MailGlobalScreenToolProvider.php.

236 : array
237 {
238 $user_folders = [];
239 $filtered_folders = [];
240
241 foreach ($folders as $folder) {
242 if ($folder->isUserFolder()) {
243 $user_folders[] = $folder;
244 continue;
245 }
246
247 $filtered_folders[] = $folder;
248 }
249 $folders = $filtered_folders;
250
251 return $user_folders;
252 }

Referenced by ILIAS\Mail\Provider\MailGlobalScreenToolProvider\buildSubItems().

+ Here is the caller graph for this function:

◆ getToolsForContextStack()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::getToolsForContextStack ( CalledContexts  $called_contexts)
Parameters
CalledContexts$called_contexts
Returns
Tool[] These Slates can be passed to the MainMenu dynamic for a specific location/context.
See also
DynamicProvider

Implements ILIAS\GlobalScreen\Scope\Tool\Provider\DynamicToolProvider.

Definition at line 94 of file MailGlobalScreenToolProvider.php.

94 : array
95 {
96 $identification = fn($id): IdentificationInterface => $this->identification_provider->contextAwareIdentifier($id);
97
98 $tools = [];
99
100 $additional_data = $called_contexts->getLast()->getAdditionalData();
101 if ($additional_data->exists(self::SHOW_MAIL_FOLDERS_TOOL) &&
102 $additional_data->get(self::SHOW_MAIL_FOLDERS_TOOL) === true) {
103
104 $tools[] = $this->factory
105 ->tool($identification('mail_folders_tree'))
106 ->withTitle($this->lng->txt('mail'))
107 ->withSymbol($this->icon_factory->standard('mail', $this->lng->txt('mail')))
108 ->withContentWrapper(function (): LegacyContent {
109 $current_folder_id = $this->http_wrapper->query()->retrieve(
110 'mobj_id',
111 $this->refinery->kindlyTo()->int()
112 );
113
114 $this->ctrl->setParameterByClass(ilMailFormGUI::class, 'type', ilMailFormGUI::MAIL_FORM_TYPE_NEW);
115
116 $sub_items = [
117 $this->buildItem(
118 $this->lng->txt('mail_new'),
119 'mail',
120 $this->buildFolderLink($current_folder_id, ilMailFormGUI::class)
121 ),
122 ...$this->buildSubItems(),
123 $this->buildItem(
124 $this->lng->txt('mail_attachments'),
125 'attach',
126 $this->buildFolderLink($current_folder_id, [ilMailGUI::class, ilMailAttachmentGUI::class])
127 )
128 ];
129
130 if ($this->dic->settings()->get('show_mail_settings', '0')) {
131 $sub_items[] = $this->buildItem(
132 $this->lng->txt('mail_options'),
133 'adm',
134 $this->buildFolderLink($current_folder_id, ilMailOptionsGUI::class)
135 );
136 }
137
138 $item = $this->ui_factory->menu()->drilldown(
139 $this->lng->txt('mail'),
140 $sub_items
141 );
142
143 return $this->ui_factory->legacy()->content(
144 $this->ui_renderer->render($item)
145 );
146 });
147 }
148
149 return $tools;
150 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
final const string MAIL_FORM_TYPE_NEW
if(!file_exists('../ilias.ini.php'))

References $id, factory(), ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\getLast(), if, ILIAS\Repository\lng(), ilMailFormGUI\MAIL_FORM_TYPE_NEW, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ isInterestedInContexts()

ILIAS\Mail\Provider\MailGlobalScreenToolProvider::isInterestedInContexts ( )
Returns
ContextCollection

Implements ILIAS\GlobalScreen\ScreenContext\ScreenContextAwareProvider.

Definition at line 89 of file MailGlobalScreenToolProvider.php.

89 : ContextCollection
90 {
91 return $this->context_collection->main()->repository()->administration();
92 }

References ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\main().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

readonly ilCtrlInterface ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$ctrl
private

Definition at line 59 of file MailGlobalScreenToolProvider.php.

◆ $http_wrapper

readonly HttpWrapper ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$http_wrapper
private

◆ $icon_factory

readonly IconFactory ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$icon_factory
private

◆ $lng

readonly ilLanguage ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$lng
private

Definition at line 62 of file MailGlobalScreenToolProvider.php.

◆ $mbox

readonly ilMailbox ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$mbox
private

Definition at line 57 of file MailGlobalScreenToolProvider.php.

◆ $refinery

readonly Refinery ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$refinery
private

Definition at line 61 of file MailGlobalScreenToolProvider.php.

◆ $ui_factory

readonly UIFactory ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$ui_factory
private

◆ $ui_renderer

readonly UIRenderer ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$ui_renderer
private

◆ $user

readonly ilObjUser ILIAS\Mail\Provider\MailGlobalScreenToolProvider::$user
private

Definition at line 58 of file MailGlobalScreenToolProvider.php.

◆ SHOW_MAIL_FOLDERS_TOOL

final const string ILIAS\Mail\Provider\MailGlobalScreenToolProvider::SHOW_MAIL_FOLDERS_TOOL = 'show_mail_folders_tool'

Definition at line 53 of file MailGlobalScreenToolProvider.php.


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