Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrgUnit: new code style #4022

Merged
merged 2 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Modules/OrgUnit/PublicApi/OrgUnitUserService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace OrgUnit\PublicApi;

use OrgUnit\User\ilOrgUnitUser;
Expand All @@ -10,12 +11,10 @@ public function __construct()
{
}


/**
* @param array $user_ids
* @param bool $with_superios
* @param bool $with_positions
*
* @return ilOrgUnitUser[]
*/
public function getUsers(array $user_ids, $with_superios = false, $with_positions = false)
Expand Down
14 changes: 11 additions & 3 deletions Modules/OrgUnit/PublicApi/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
## Public Service

Usage:

```
$orgunit = new OrgUnitUserService();
$orgu_users = $orgunit->getUsers([292,291]);
```
This will return a list of ilOrgUnitUser. The Positions and the Superios can be lazy loaded.

Position: A position in ILIAS is a possibility to assign users to an organisational unit. For example, a user can be assigned to an organisational unit in the position superior or employee. The positions Employees and Superiors are standard ILIAS positions. Note Additional Positions can be configured arbitrarily in ILIAS.
This will return a list of ilOrgUnitUser. The Positions and the Superios can be lazy loaded.

Position: A position in ILIAS is a possibility to assign users to an organisational unit. For example, a user can be
assigned to an organisational unit in the position superior or employee. The positions Employees and Superiors are
standard ILIAS positions. Note Additional Positions can be configured arbitrarily in ILIAS.

Superiors: Superiors of a user are those users who are assigned as superiors to the ILIAS organisational unit for which a user has assigned the position Employee.
Superiors: Superiors of a user are those users who are assigned as superiors to the ILIAS organisational unit for which
a user has assigned the position Employee.

You may load them by:

```
foreach($orgu_users as $orgu_user) {
/**
Expand All @@ -22,6 +29,7 @@ foreach($orgu_users as $orgu_user) {
```

If you know that you will use Superiors or Positions for the whole list. Load it Eager by:

```
$orgunit = new OrgUnitUserService();
$orgu_users = $orgunit->getUsers([292,291],$with_superios = true, $with_positions = true);
Expand Down
15 changes: 1 addition & 14 deletions Modules/OrgUnit/classes/ARHelper/BaseCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

/**
* Interface BaseCommands
*
* @author Fabian Schmid <[email protected]>
*/
abstract class BaseCommands
{
use DIC;

const CMD_INDEX = "index";
const CMD_ADD = "add";
const CMD_CREATE = "create";
Expand All @@ -24,7 +24,6 @@ abstract class BaseCommands
*/
protected $parent_gui = null;


/**
* @return \ILIAS\Modules\OrgUnit\ARHelper\BaseCommands
*/
Expand All @@ -33,7 +32,6 @@ public function getParentGui()
return $this->parent_gui;
}


/**
* @param \ILIAS\Modules\OrgUnit\ARHelper\BaseCommands $parent_gui
*/
Expand All @@ -42,10 +40,8 @@ public function setParentGui($parent_gui)
$this->parent_gui = $parent_gui;
}


abstract protected function index();


/**
* @return array of GUI_Class-Names
*/
Expand All @@ -54,7 +50,6 @@ protected function getPossibleNextClasses()
return array();
}


/**
* @return null|string of active Tab
*/
Expand All @@ -63,13 +58,11 @@ protected function getActiveTabId()
return null;
}


protected function cancel()
{
$this->ctrl()->redirect($this, self::CMD_INDEX);
}


/***
* @param $html
*/
Expand All @@ -78,7 +71,6 @@ protected function setContent($html)
$this->tpl()->setContent($html);
}


public function executeCommand()
{
$this->dic()->language()->loadLanguageModule("orgu");
Expand Down Expand Up @@ -111,7 +103,6 @@ public function executeCommand()
}
}


/**
* @param $subtab_id
* @param $url
Expand All @@ -121,7 +112,6 @@ protected function pushSubTab($subtab_id, $url)
$this->dic()->tabs()->addSubTab($subtab_id, $this->txt($subtab_id), $url);
}


/**
* @param $subtab_id
*/
Expand All @@ -130,7 +120,6 @@ protected function activeSubTab($subtab_id)
$this->dic()->tabs()->activateSubTab($subtab_id);
}


protected function checkRequestReferenceId()
{
/**
Expand All @@ -144,7 +133,6 @@ protected function checkRequestReferenceId()
return true;
}


/**
* @return int|null
*/
Expand All @@ -156,7 +144,6 @@ protected function getParentRefId()
return $ref_id;
}


public function addSubTabs()
{
}
Expand Down
13 changes: 0 additions & 13 deletions Modules/OrgUnit/classes/ARHelper/BaseForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

/**
* Class BaseForm
*
* @package ILIAS\Modules\OrgUnit\CtrlHelper
*/
abstract class BaseForm extends \ilPropertyFormGUI
Expand All @@ -23,10 +22,8 @@ abstract class BaseForm extends \ilPropertyFormGUI
*/
protected $object;


/**
* BaseForm constructor.
*
* @param \ILIAS\Modules\OrgUnit\ARHelper\BaseCommands $parent_gui
* @param \ActiveRecord $object
*/
Expand All @@ -42,16 +39,12 @@ public function __construct(BaseCommands $parent_gui, \ActiveRecord $object)
parent::__construct();
}


abstract protected function initFormElements();


abstract public function fillForm();


abstract protected function fillObject();


/**
* @return int ID of the object
*/
Expand All @@ -69,7 +62,6 @@ public function saveObject()
return $this->object->getId();
}


protected function initButtons()
{
if (!$this->object->getId()) {
Expand All @@ -83,29 +75,24 @@ protected function initButtons()
}
}


/**
* @param $key
*
* @return string
*/
protected function txt($key)
{
return $this->parent_gui->txt($key);
}


/**
* @param $key
*
* @return string
*/
protected function infoTxt($key)
{
return $this->parent_gui->txt($key . '_info');
}


/**
* @return \ILIAS\DI\Container
*/
Expand Down
18 changes: 3 additions & 15 deletions Modules/OrgUnit/classes/ARHelper/DIC.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace ILIAS\Modules\OrgUnit\ARHelper;

use ILIAS\HTTP\RawHTTPServices;/**
use ILIAS\HTTP\RawHTTPServices;

/**
* Class DIC
* @author Fabian Schmid <[email protected]>
*/
Expand All @@ -17,7 +19,6 @@ public function dic()
return $GLOBALS['DIC'];
}


/**
* @return \ilCtrl
*/
Expand All @@ -26,18 +27,15 @@ protected function ctrl()
return $this->dic()->ctrl();
}


/**
* @param $variable
*
* @return string
*/
public function txt($variable)
{
return $this->lng()->txt($variable);
}


/**
* @return \ilTemplate
*/
Expand All @@ -46,7 +44,6 @@ protected function tpl()
return $this->dic()->ui()->mainTemplate();
}


/**
* @return \ilLanguage
*/
Expand All @@ -55,7 +52,6 @@ protected function lng()
return $this->dic()->language();
}


/**
* @return \ilTabsGUI
*/
Expand All @@ -64,7 +60,6 @@ protected function tabs()
return $this->dic()->tabs();
}


/**
* @return \ILIAS\DI\UIServices
*/
Expand All @@ -73,7 +68,6 @@ protected function ui()
return $this->dic()->ui();
}


/**
* @return \ilObjUser
*/
Expand All @@ -82,7 +76,6 @@ protected function user()
return $this->dic()->user();
}


/**
* @return \ILIAS\HTTP\Services
*/
Expand All @@ -91,7 +84,6 @@ protected function http()
return $this->dic()->http();
}


/**
* @return \ilAccessHandler
*/
Expand All @@ -100,7 +92,6 @@ protected function access()
return $this->dic()->access();
}


/**
* @return \ilToolbarGUI
*/
Expand All @@ -109,7 +100,6 @@ protected function toolbar()
return $this->dic()->toolbar();
}


/**
* @return \ilDB
*/
Expand All @@ -128,10 +118,8 @@ public function checkPermissionAndFail($a_perm)
}
}


/**
* @param $a_perm
*
* @return bool
*/
public function checkPermissionBoolAndReturn($a_perm)
Expand Down
2 changes: 0 additions & 2 deletions Modules/OrgUnit/classes/Exceptions/class.ilOrguException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

/**
* Class ilOrguException
*
* @author Oskar Truffer <[email protected]>
*
* This is the base class for OrgUnit Exceptions as described in the dev guide.
*/
class ilOrguException extends ilException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* Class ilPositionPermissionsNotActive
*
* @author Oskar Truffer <[email protected]>
*/
class ilPositionPermissionsNotActive extends ilOrguException
Expand All @@ -11,10 +10,8 @@ class ilPositionPermissionsNotActive extends ilOrguException
/** @var string */
protected $object_type = "";


/**
* ilPositionPermissionsNotActive constructor.
*
* @param string $message
* @param string $type
* @param int $code
Expand All @@ -26,7 +23,6 @@ public function __construct($message, $type, $code = 0)
$this->object_type = $type;
}


/**
* @return string
*/
Expand Down
Loading