-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/6 0/mystaff enhancements (#2363)
* myStaffEnhancements - first step * Study Programmes * table columns certificate * MyStaff: Certificates and Competences * mystaff: added access functions * fixed certificate permission * lang fixes certificates * preparation for ilias 6 * removed some comments * fixes filter * fix access check
- Loading branch information
Showing
33 changed files
with
3,321 additions
and
969 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
Services/MyStaff/classes/ListCertificates/class.ilMStListCertificates.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace ILIAS\MyStaff\ListCertificates; | ||
|
||
use Certificate\API\Data\UserCertificateDto; | ||
use Certificate\API\Filter\UserDataFilter; | ||
use Certificate\API\UserCertificateAPI; | ||
use ILIAS\DI\Container; | ||
use ILIAS\MyStaff\ilMyStaffAccess; | ||
use ilLPStatus; | ||
use ilMStListCertificatesGUI; | ||
use ilMyStaffGUI; | ||
use ilOrgUnitOperation; | ||
|
||
/** | ||
* Class ilMStListCertificates | ||
* | ||
* @author Martin Studer <[email protected]> | ||
*/ | ||
class ilMStListCertificates | ||
{ | ||
|
||
/** | ||
* @var Container | ||
*/ | ||
protected $dic; | ||
|
||
|
||
/** | ||
* ilMStListCertificates constructor. | ||
* | ||
* @param Container $dic | ||
*/ | ||
public function __construct(Container $dic) | ||
{ | ||
$this->dic = $dic; | ||
} | ||
|
||
|
||
/** | ||
* @param array $arr_usr_ids | ||
* @param array $options | ||
* | ||
* @return UserCertificateDto[] | ||
*/ | ||
public function getData(array $options = array()) : array | ||
{ | ||
//Permission Filter | ||
$operation_access = ilOrgUnitOperation::OP_VIEW_CERTIFICATES; | ||
|
||
|
||
$_options = array( | ||
'filters' => array(), | ||
'sort' => array(), | ||
'limit' => array(), | ||
); | ||
$options = array_merge($_options, $options); | ||
|
||
$cert_api = new UserCertificateAPI(); | ||
|
||
$data = []; | ||
$users_per_position = ilMyStaffAccess::getInstance()->getUsersForUserPerPosition($this->dic->user()->getId()); | ||
foreach ($users_per_position as $position_id => $users) { | ||
$usr_data_filter = new UserDataFilter(); | ||
$usr_data_filter = $usr_data_filter->withUserIds($users); | ||
$usr_data_filter = $usr_data_filter->withObjIds(ilMyStaffAccess::getInstance()->getIdsForUserAndOperation($this->dic->user()->getId(), $operation_access)); | ||
|
||
|
||
if (!empty($options['filters']['user'])) { | ||
$usr_data_filter = $usr_data_filter->withUserLogin($options['filters']['user']); | ||
} | ||
if (!empty($options['filters']['obj_title'])) { | ||
$usr_data_filter = $usr_data_filter->withObjectTitle($options['filters']['obj_title']); | ||
} | ||
|
||
|
||
$data = array_merge($data, $cert_api->getUserCertificateData($usr_data_filter, [ilMyStaffGUI::class, ilMStListCertificatesGUI::class])); | ||
} | ||
|
||
$unique_cert_data = []; | ||
foreach ($data as $cert_data) { | ||
/** | ||
* @var UserCertificateDto $cert_data | ||
*/ | ||
$unique_cert_data[$cert_data->getCertificateId()] = $cert_data; | ||
} | ||
|
||
return $unique_cert_data; | ||
} | ||
} |
192 changes: 192 additions & 0 deletions
192
Services/MyStaff/classes/ListCertificates/class.ilMStListCertificatesGUI.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
<?php | ||
|
||
use ILIAS\MyStaff\ilMyStaffAccess; | ||
use ILIAS\MyStaff\ListCertificates\ilMStListCertificatesTableGUI; | ||
|
||
/** | ||
* Class ilMStListCertificatesGUI | ||
* | ||
* @author Martin Studer <[email protected]> | ||
* | ||
* @ilCtrl_IsCalledBy ilMStListCertificatesGUI: ilMyStaffGUI | ||
* @ilCtrl_Calls ilMStListCertificatesGUI: ilFormPropertyDispatchGUI | ||
* @ilCtrl_Calls ilMStListCertificatesGUI: ilUserCertificateApiGUI | ||
*/ | ||
class ilMStListCertificatesGUI { | ||
|
||
const CMD_APPLY_FILTER = 'applyFilter'; | ||
const CMD_INDEX = 'index'; | ||
const CMD_GET_ACTIONS = "getActions"; | ||
const CMD_RESET_FILTER = 'resetFilter'; | ||
/** | ||
* @var ilTable2GUI | ||
*/ | ||
protected $table; | ||
/** | ||
* @var ilMyStaffAccess | ||
*/ | ||
protected $access; | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function __construct() { | ||
$this->access = ilMyStaffAccess::getInstance(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
protected function checkAccessOrFail() { | ||
global $DIC; | ||
|
||
if ($this->access->hasCurrentUserAccessToMyStaff()) { | ||
return; | ||
} else { | ||
ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true); | ||
$DIC->ctrl()->redirectByClass(ilDashboardGUI::class, ""); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function executeCommand() { | ||
global $DIC; | ||
|
||
$cmd = $DIC->ctrl()->getCmd(); | ||
$next_class = $DIC->ctrl()->getNextClass(); | ||
|
||
switch ($next_class) { | ||
case strtolower(ilFormPropertyDispatchGUI::class): | ||
$this->checkAccessOrFail(); | ||
|
||
$DIC->ctrl()->setReturn($this, self::CMD_INDEX); | ||
$this->table = new ilMStListCertificatesTableGUI($this, self::CMD_INDEX); | ||
$this->table->executeCommand(); | ||
break; | ||
case strtolower(ilUserCertificateApiGUI::class): | ||
$this->checkAccessOrFail(); | ||
$DIC->ctrl()->forwardCommand(new ilUserCertificateApiGUI()); | ||
break; | ||
default: | ||
switch ($cmd) { | ||
|
||
case self::CMD_RESET_FILTER: | ||
case self::CMD_APPLY_FILTER: | ||
case self::CMD_INDEX: | ||
case self::CMD_GET_ACTIONS: | ||
$this->$cmd(); | ||
break; | ||
default: | ||
$this->index(); | ||
break; | ||
} | ||
break; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function index() { | ||
$this->listUsers(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function listUsers() { | ||
global $DIC; | ||
|
||
$this->checkAccessOrFail(); | ||
|
||
$this->table = new ilMStListCertificatesTableGUI($this, self::CMD_INDEX); | ||
$this->table->setTitle($DIC->language()->txt('mst_list_certificates')); | ||
$DIC->ui()->mainTemplate()->setContent($this->table->getHTML()); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function applyFilter() { | ||
$this->table = new ilMStListCertificatesTableGUI($this, self::CMD_APPLY_FILTER); | ||
$this->table->writeFilterToSession(); | ||
$this->table->resetOffset(); | ||
$this->index(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function resetFilter() { | ||
$this->table = new ilMStListCertificatesTableGUI($this, self::CMD_RESET_FILTER); | ||
$this->table->resetOffset(); | ||
$this->table->resetFilter(); | ||
$this->index(); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId() { | ||
$this->table = new ilMStListCertificatesTableGUI($this, self::CMD_INDEX); | ||
|
||
return $this->table->getId(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function cancel() { | ||
global $DIC; | ||
|
||
$DIC->ctrl()->redirect($this); | ||
} | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
public function getActions() { | ||
global $DIC; | ||
|
||
$mst_co_usr_id = $DIC->http()->request()->getQueryParams()['mst_lco_usr_id']; | ||
$mst_lco_crs_ref_id = $DIC->http()->request()->getQueryParams()['mst_lco_crs_ref_id']; | ||
|
||
if ($mst_co_usr_id > 0 && $mst_lco_crs_ref_id > 0) { | ||
$selection = new ilAdvancedSelectionListGUI(); | ||
|
||
if ($DIC->access()->checkAccess("visible", "", $mst_lco_crs_ref_id)) { | ||
$link = ilLink::_getStaticLink($mst_lco_crs_ref_id, ilMyStaffAccess::DEFAULT_CONTEXT); | ||
$selection->addItem(ilObject2::_lookupTitle(ilObject2::_lookupObjectId($mst_lco_crs_ref_id)), '', $link); | ||
}; | ||
|
||
$org_units = ilOrgUnitPathStorage::getTextRepresentationOfOrgUnits('ref_id'); | ||
foreach (ilOrgUnitUserAssignment::innerjoin('object_reference', 'orgu_id', 'ref_id')->where(array( | ||
'user_id' => $mst_co_usr_id, | ||
'object_reference.deleted' => null | ||
), array( 'user_id' => '=', 'object_reference.deleted' => '!=' ))->get() as $org_unit_assignment) { | ||
if ($DIC->access()->checkAccess("read", "", $org_unit_assignment->getOrguId())) { | ||
$link = ilLink::_getStaticLink($org_unit_assignment->getOrguId(), 'orgu'); | ||
$selection->addItem($org_units[$org_unit_assignment->getOrguId()], '', $link); | ||
} | ||
} | ||
|
||
$selection = ilMyStaffGUI::extendActionMenuWithUserActions($selection, $mst_co_usr_id, rawurlencode($DIC->ctrl() | ||
->getLinkTarget($this, self::CMD_INDEX))); | ||
|
||
echo $selection->getHTML(true); | ||
} | ||
exit; | ||
} | ||
} |
Oops, something went wrong.