ILIAS  trunk Revision v12.0_alpha-1329-g1094ddb0c33
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 52 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 66 of file MailGlobalScreenToolProvider.php.

76 {
78 $this->ui_factory = $ui_factory ?? $this->dic->ui()->factory();
79 $this->ui_renderer = $ui_renderer ?? $this->dic->ui()->renderer();
80 $this->user = $user ?? $this->dic->user();
81 $this->ctrl = $ctrl ?? $this->dic->ctrl();
82 $this->http_wrapper = $http_wrapper ?? $this->dic->http()->wrapper();
83 $this->refinery = $refinery ?? $this->dic->refinery();
84 $this->lng = $lng ?? $this->dic->language();
85 $this->icon_factory = $icon_factory ?? $this->ui_factory->symbol()->icon();
86
87 $this->mbox = new ilMailbox($this->user->getId());
88 }
$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 207 of file MailGlobalScreenToolProvider.php.

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

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 225 of file MailGlobalScreenToolProvider.php.

225 : CustomIcon
226 {
227 return $this->icon_factory->custom(
228 ilUtil::getImagePath("standard/icon_$type.svg"),
229 $title
230 );
231 }
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 216 of file MailGlobalScreenToolProvider.php.

216 : BulkyLink
217 {
218 return $this->ui_factory->link()->bulky(
219 $this->buildIcon($title, $icon_name),
220 $title,
221 new URI(ILIAS_HTTP_PATH . '/' . $link)
222 );
223 }

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 156 of file MailGlobalScreenToolProvider.php.

156 : array
157 {
158 $items = [];
159
160 $folders = $this->mbox->getSubFolders();
161 usort(
162 $folders,
163 static fn(MailFolderData $a, MailFolderData $b): int => $a->isTrash() && !$b->isUserLocalFolder() ? 1 : 0
164 );
165 $user_folders = $this->filterUserFolders($folders);
166
167 foreach ($folders as $folder) {
168 if ($folder->isUserLocalFolder() && $user_folders !== []) {
169 $icon_name = $folder->getType()->value;
170 $items[] = $this->ui_factory->menu()->sub(
171 $folder->getTitle(),
172 [
173 $this->buildItem(
174 $this->lng->txt('mail_main_folder'),
175 $icon_name,
176 $this->buildFolderLink($folder->getFolderId(), ilMailFolderGUI::class)
177 ),
178 ...array_map(
179 function (MailFolderData $folder) use ($icon_name): BulkyLink {
180 return $this->buildItem(
181 $folder->getTitle(),
182 $icon_name,
183 $this->buildFolderLink($folder->getFolderId(), ilMailFolderGUI::class)
184 );
185 },
186 $user_folders
187 ),
188 ]
189 );
190 continue;
191 }
192
193 $items[] = $this->buildItem(
194 $folder->getTitle(),
195 $folder->getType()->value,
196 $this->buildFolderLink($folder->getFolderId(), ilMailFolderGUI::class)
197 );
198 }
199
200 return $items;
201 }
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 237 of file MailGlobalScreenToolProvider.php.

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

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 95 of file MailGlobalScreenToolProvider.php.

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

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

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 60 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 63 of file MailGlobalScreenToolProvider.php.

◆ $mbox

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

Definition at line 58 of file MailGlobalScreenToolProvider.php.

◆ $refinery

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

Definition at line 62 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 59 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 54 of file MailGlobalScreenToolProvider.php.


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