Skip to content

Commit

Permalink
Feature/6 0/mystaff enhancements (#2363)
Browse files Browse the repository at this point in the history
* 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
mstuder authored Dec 6, 2019
1 parent 6a33b9a commit 88c1f26
Show file tree
Hide file tree
Showing 33 changed files with 3,321 additions and 969 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ilOrgUnitOperation extends ActiveRecord
const OP_ACCESS_ENROLMENTS = 'access_enrolments';
const OP_MANAGE_PARTICIPANTS = 'manage_participants';
const OP_SCORE_PARTICIPANTS = 'score_participants';
const OP_VIEW_CERTIFICATES = 'view_certificates';
const OP_VIEW_COMPETENCES = 'view_competences';
const OP_EDIT_USER_ACCOUNTS = 'edit_user_accounts';
const OP_VIEW_MEMBERS = 'view_members';
const OP_VIEW_INDIVIDUAL_PLAN = 'view_individual_plan';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ class ilOrgUnitOperationContext extends ActiveRecord
const CONTEXT_USRF = "usrf";
const CONTEXT_PRG = "prg";

/**
* @var array
*/
public static $available_contexts = [
self::CONTEXT_OBJECT,
self::CONTEXT_CRS,
self::CONTEXT_GRP,
self::CONTEXT_IASS,
self::CONTEXT_TST,
self::CONTEXT_EXC,
self::CONTEXT_SVY,
self::CONTEXT_USRF,
self::CONTEXT_PRG,
];





/**
* @return array if own and
*/
Expand Down
3 changes: 2 additions & 1 deletion Modules/OrgUnit/classes/class.ilObjOrgUnitGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ public function showPossibleSubObjects()
{
$gui = new ilObjectAddNewItemGUI($this->object->getRefId());
$gui->setMode(ilObjectDefinition::MODE_ADMINISTRATION);
$gui->setCreationUrl("ilias.php?ref_id=" . $_GET["ref_id"] . "&admin_mode=settings&cmd=create&baseClass=ilAdministrationGUI");
//$gui->setCreationUrl("ilias.php?ref_id=" . $_GET["ref_id"] . "&admin_mode=settings&cmd=create&baseClass=ilAdministrationGUI&cmdClass=ilobjorgunitgui");
$gui->setCreationUrl($this->ctrl->getLinkTarget($this, 'create'));
$gui->render();
}

Expand Down
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;
}
}
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;
}
}
Loading

0 comments on commit 88c1f26

Please sign in to comment.