Skip to content

Commit

Permalink
Services/Mail & Services/Contact/classes added strict types, return t…
Browse files Browse the repository at this point in the history
…ypes declarations, type hints, type properties

Contact/classes added strict types #2

Contact/classes added strict types #3

Mail/Address added strict types

Contact/classes Type Properties

mail added strict types

Services/Mail/classes addded strict types

Services/Mail/classes added strict types + Services/Contact/ template type fix

Services/Mail/classes added strict types 2

Services/Mail/classes added strict types 3

Services/Mail/classes added strict types 4

Services/Mail/classes added strict types 5

Services/Mail/classes added strict types 6

reverted changes to switch statements

revert unwanted changes

bugifx mixed default typ
  • Loading branch information
fhelfer committed Sep 28, 2021
1 parent 90ea3b1 commit 2779414
Show file tree
Hide file tree
Showing 131 changed files with 1,598 additions and 2,545 deletions.
4 changes: 3 additions & 1 deletion Services/Contact/classes/Provider/ContactMainBarProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace ILIAS\Contact\Provider;
<?php declare(strict_types=1);

namespace ILIAS\Contact\Provider;

use ilBuddySystem;
use ILIAS\GlobalScreen\Scope\MainMenu\Provider\AbstractStaticMainMenuProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* @author Ingmar Szmais <[email protected]>
* @author Michael Jansen <[email protected]>
*/
class ContactNotificationProvider extends AbstractNotificationProvider implements NotificationProvider
class ContactNotificationProvider extends AbstractNotificationProvider
{
const MUTED_UNTIL_PREFERENCE_KEY = 'bs_nc_muted_until';
public const MUTED_UNTIL_PREFERENCE_KEY = 'bs_nc_muted_until';

/**
* @param string $id
Expand Down
8 changes: 4 additions & 4 deletions Services/Contact/classes/class.ilAbstractMailMemberRoles.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* Class ilAbstractMailMemberRoles
Expand All @@ -10,18 +10,18 @@ abstract class ilAbstractMailMemberRoles
* @param int $ref_id
* @return array
*/
abstract public function getMailRoles($ref_id);
abstract public function getMailRoles(int $ref_id): array;

/**
* @return string
*/
abstract public function getRadioOptionTitle();
abstract public function getRadioOptionTitle(): string;

/**
* @param int $role_id
* @return String
*/
final public function getMailboxRoleAddress($role_id)
final public function getMailboxRoleAddress(int $role_id): string
{
return (new \ilRoleMailboxAddress($role_id))->value();
}
Expand Down
6 changes: 3 additions & 3 deletions Services/Contact/classes/class.ilContactAppEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class ilContactAppEventListener implements ilAppEventListener
/**
* @inheritDoc
*/
public static function handleEvent($a_component, $a_event, $a_parameter)
public static function handleEvent($a_component, $a_event, $a_parameter): void
{
global $DIC;

if ('Services/User' == $a_component && 'deleteUser' == $a_event) {
if ('Services/User' === $a_component && 'deleteUser' === $a_event) {
ilBuddyList::getInstanceByUserId((int) $a_parameter['usr_id'])->destroy();
ilMailingList::removeAssignmentsByUserId((int) $a_parameter['usr_id']);
}

if ('Services/Contact' == $a_component && 'contactRequested' == $a_event) {
if ('Services/Contact' === $a_component && 'contactRequested' === $a_event) {
$notification = new ilBuddySystemNotification($DIC->user(), $DIC->settings());
$notification->setRecipientIds([(int) $a_parameter['usr_id']]);
$notification->send();
Expand Down
113 changes: 33 additions & 80 deletions Services/Contact/classes/class.ilContactGUI.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */

require_once 'Services/Mail/classes/class.ilFormatMail.php';
Expand All @@ -17,60 +17,18 @@ class ilContactGUI
public const CONTACTS_VIEW_GALLERY = 1;
public const CONTACTS_VIEW_TABLE = 2;

/**
* @var ilTemplate
*/
protected $tpl;

/**
* @var ilCtrl
*/
protected $ctrl;

/**
* @var ilLanguage
*/
protected $lng;

/**
* @var ilTabsGUI
*/
protected $tabs_gui;

/**
* @var ilHelpGUI
*/
protected $help;

/**
* @var ilToolbarGUI
*/
protected $toolbar;

/**
* @var ilFormatMail
*/
protected $umail;

/**
* @var ilObjUser
*/
protected $user;

/**
* @var ilErrorHandling
*/
protected $error;

/**
* @var ilRbacSystem
*/
protected $rbacsystem;

/**
* @var bool
*/
protected $has_sub_tabs = false;
protected ilGlobalPageTemplate $tpl;
protected ilCtrl $ctrl;
protected ilLanguage $lng;
protected ilTabsGUI $tabs_gui;
protected ilHelpGUI $help;
protected ilToolbarGUI $toolbar;
protected ilFormatMail $umail;
protected ilObjUser $user;
protected ilErrorHandling $error;
protected ilRbacSystem $rbacsystem;
protected bool $has_sub_tabs = false;

/**
* ilContactGUI constructor.
Expand All @@ -95,7 +53,7 @@ public function __construct()
$this->lng->loadLanguageModule('buddysystem');
}

public function executeCommand()
public function executeCommand(): bool
{
$this->showSubTabs();

Expand Down Expand Up @@ -178,21 +136,21 @@ public function executeCommand()
/**
*
*/
private function showSubTabs()
private function showSubTabs(): void
{
if ($this->tabs_gui->hasTabs()) {
if (ilBuddySystem::getInstance()->isEnabled()) {
$this->tabs_gui->addSubTab('my_contacts', $this->lng->txt('my_contacts'), $this->ctrl->getLinkTarget($this));

if (in_array(strtolower($this->ctrl->getCmdClass()), array_map('strtolower', array('ilUsersGalleryGUI', get_class($this))))) {
if (in_array(strtolower($this->ctrl->getCmdClass()), array_map('strtolower', array('ilUsersGalleryGUI', get_class($this))), true)) {
require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
$view_selection = new ilSelectInputGUI('', 'contacts_view');
$view_selection->setOptions(array(
self::CONTACTS_VIEW_TABLE => $this->lng->txt('buddy_view_table'),
self::CONTACTS_VIEW_GALLERY => $this->lng->txt('buddy_view_gallery')
));
$view_selection->setValue(
strtolower($this->ctrl->getCmdClass()) == 'ilusersgallerygui' ? self::CONTACTS_VIEW_GALLERY : self::CONTACTS_VIEW_TABLE
strtolower($this->ctrl->getCmdClass()) === 'ilusersgallerygui' ? self::CONTACTS_VIEW_GALLERY : self::CONTACTS_VIEW_TABLE
);
$this->toolbar->addInputItem($view_selection);

Expand All @@ -204,10 +162,7 @@ private function showSubTabs()
$this->toolbar->setFormAction($this->ctrl->getFormAction($this, 'changeContactsView'));
}

if (
ilBuddySystem::getInstance()->isEnabled() &&
count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0
) {
if ( count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0) {
$this->tabs_gui->addSubTab(
'mail_my_mailing_lists',
$this->lng->txt('mail_my_mailing_lists'),
Expand All @@ -227,15 +182,12 @@ private function showSubTabs()
if (ilBuddySystem::getInstance()->isEnabled()) {
$this->tabs_gui->addTab('my_contacts', $this->lng->txt('my_contacts'), $this->ctrl->getLinkTarget($this));

if (in_array(strtolower($this->ctrl->getCmdClass()), array_map('strtolower', array('ilUsersGalleryGUI', get_class($this))))) {
if (in_array(strtolower($this->ctrl->getCmdClass()), array_map('strtolower', array('ilUsersGalleryGUI', get_class($this))), true)) {
$this->tabs_gui->addSubTab('buddy_view_table', $this->lng->txt('buddy_view_table'), $this->ctrl->getLinkTarget($this));
$this->tabs_gui->addSubTab('buddy_view_gallery', $this->lng->txt('buddy_view_gallery'), $this->ctrl->getLinkTargetByClass('ilUsersGalleryGUI'));
}

if (
ilBuddySystem::getInstance()->isEnabled() &&
count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0
) {
if (count(ilBuddyList::getInstanceByGlobalUser()->getLinkedRelations()) > 0) {
$this->tabs_gui->addTab(
'mail_my_mailing_lists',
$this->lng->txt('mail_my_mailing_lists'),
Expand All @@ -252,7 +204,7 @@ private function showSubTabs()
/**
* @param string $a_id
*/
protected function activateTab($a_id)
protected function activateTab($a_id): void
{
if ($this->has_sub_tabs) {
$this->tabs_gui->activateSubTab($a_id);
Expand All @@ -264,7 +216,7 @@ protected function activateTab($a_id)
/**
* This method is used to switch the contacts view between gallery and table in the mail system
*/
protected function changeContactsView()
protected function changeContactsView(): void
{
if (!ilBuddySystem::getInstance()->isEnabled()) {
$this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
Expand All @@ -288,7 +240,7 @@ protected function changeContactsView()
/**
*
*/
protected function applyContactsTableFilter()
protected function applyContactsTableFilter(): void
{
if (!ilBuddySystem::getInstance()->isEnabled()) {
$this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
Expand All @@ -306,7 +258,7 @@ protected function applyContactsTableFilter()
/**
*
*/
protected function resetContactsTableFilter()
protected function resetContactsTableFilter(): void
{
if (!ilBuddySystem::getInstance()->isEnabled()) {
$this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
Expand All @@ -324,7 +276,7 @@ protected function resetContactsTableFilter()
/**
*
*/
protected function showContacts()
protected function showContacts(): void
{
if (!ilBuddySystem::getInstance()->isEnabled()) {
$this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
Expand All @@ -343,13 +295,13 @@ protected function showContacts()
/**
*
*/
protected function mailToUsers()
protected function mailToUsers(): bool
{
if (!$this->rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) {
$this->error->raiseError($this->lng->txt('msg_no_perm_read'), $this->error->MESSAGE);
}

if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id']) || 0 == count($_POST['usr_id'])) {
if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id']) || 0 === count($_POST['usr_id'])) {
ilUtil::sendInfo($this->lng->txt('mail_select_one_entry'));
$this->showContacts();
return true;
Expand Down Expand Up @@ -386,13 +338,14 @@ protected function mailToUsers()
}

ilUtil::redirect('ilias.php?baseClass=ilMailGUI&type=search_res');
return false;
}

/**
* Last step of chat invitations
* check access for every selected user and send invitation
*/
public function submitInvitation()
public function submitInvitation(): void
{
if (!isset($_POST['usr_id']) || $_POST['usr_id'] === '') {
ilUtil::sendInfo($this->lng->txt('select_one'), true);
Expand Down Expand Up @@ -435,7 +388,7 @@ public function submitInvitation()

if (
!ilChatroom::checkPermissionsOfUser((int) $usr_id, 'read', $ref_id) ||
$room->isUserBanned($usr_id)
$room->isUserBanned((int)$usr_id)
) {
$no_access[$usr_id] = $login;
} else {
Expand All @@ -460,7 +413,7 @@ public function submitInvitation()
$message .= '</ul>';
}

if (count($no_login)) {
if (count($no_login) > 0) {
$message .= $this->lng->txt('chat_users_without_login') . ':<br>';
$list = '';

Expand Down Expand Up @@ -512,14 +465,14 @@ public function submitInvitation()
/**
* Send chat invitations to selected Users
*/
protected function inviteToChat()
protected function inviteToChat(): void
{
$this->tabs_gui->activateSubTab('buddy_view_table');
$this->activateTab('my_contacts');

$this->lng->loadLanguageModule('chatroom');

if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id']) || 0 == count($_POST['usr_id'])) {
if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id']) || 0 === count($_POST['usr_id'])) {
ilUtil::sendInfo($this->lng->txt('select_one'), true);
$this->ctrl->redirect($this);
}
Expand Down Expand Up @@ -555,7 +508,7 @@ protected function inviteToChat()

foreach ($subrooms as $subroom) {
foreach ($subroom as $sub_id => $parent_id) {
if ($parent_id == $ref_id) {
if ($parent_id === $ref_id) {
$title = ilChatroom::lookupPrivateRoomTitle($sub_id);
$options[$ref_id . ',' . $sub_id] = '+&nbsp;' . $title;
}
Expand Down
16 changes: 5 additions & 11 deletions Services/Contact/classes/class.ilMailMemberCourseRoles.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */

require_once 'Services/Contact/classes/class.ilAbstractMailMemberRoles.php';
Expand All @@ -9,15 +9,9 @@
*/
class ilMailMemberCourseRoles extends ilAbstractMailMemberRoles
{
/**
* @var ilLanguage
*/
protected $lng;

/**
* @var ilRbacReview
*/
protected $rbacreview;
protected ilLanguage $lng;
protected ilRbacReview $rbacreview;

/**
* ilMailMemberCourseRoles constructor.
Expand All @@ -33,7 +27,7 @@ public function __construct()
/**
* @return string
*/
public function getRadioOptionTitle()
public function getRadioOptionTitle(): string
{
return $this->lng->txt('mail_crs_roles');
}
Expand All @@ -42,7 +36,7 @@ public function getRadioOptionTitle()
* @param $ref_id
* @return array sorted_roles
*/
public function getMailRoles($ref_id)
public function getMailRoles(int $ref_id): array
{
$role_ids = $this->rbacreview->getLocalRoles($ref_id);

Expand Down
Loading

0 comments on commit 2779414

Please sign in to comment.