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

MyStaff: new code style #4021

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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

/**
* Class ilMStListCertificates
*
* @author Martin Studer <[email protected]>
*/
class ilMStListCertificates
Expand All @@ -25,30 +24,25 @@ class ilMStListCertificates
*/
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(),
Expand All @@ -63,8 +57,8 @@ public function getData(array $options = array()) : array
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));

$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']);
Expand All @@ -73,8 +67,8 @@ public function getData(array $options = array()) : array
$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]));
$data = array_merge($data, $cert_api->getUserCertificateData($usr_data_filter,
[ilMyStaffGUI::class, ilMStListCertificatesGUI::class]));
}

$unique_cert_data = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

/**
* Class ilMStListCertificatesGUI
*
* @author Martin Studer <[email protected]>
*
* @ilCtrl_IsCalledBy ilMStListCertificatesGUI: ilMyStaffGUI
* @ilCtrl_Calls ilMStListCertificatesGUI: ilFormPropertyDispatchGUI
* @ilCtrl_Calls ilMStListCertificatesGUI: ilUserCertificateApiGUI
Expand All @@ -28,7 +26,6 @@ class ilMStListCertificatesGUI
protected $access;
private \ilGlobalTemplateInterface $main_tpl;


/**
*
*/
Expand All @@ -39,7 +36,6 @@ public function __construct()
$this->access = ilMyStaffAccess::getInstance();
}


/**
*
*/
Expand All @@ -55,7 +51,6 @@ protected function checkAccessOrFail()
}
}


/**
*
*/
Expand Down Expand Up @@ -95,7 +90,6 @@ public function executeCommand()
}
}


/**
*
*/
Expand All @@ -104,7 +98,6 @@ public function index()
$this->listUsers();
}


/**
*
*/
Expand All @@ -119,7 +112,6 @@ public function listUsers()
$DIC->ui()->mainTemplate()->setContent($this->table->getHTML());
}


/**
*
*/
Expand All @@ -131,7 +123,6 @@ public function applyFilter()
$this->index();
}


/**
*
*/
Expand All @@ -143,7 +134,6 @@ public function resetFilter()
$this->index();
}


/**
* @return string
*/
Expand All @@ -154,7 +144,6 @@ public function getId()
return $this->table->getId();
}


/**
*
*/
Expand All @@ -165,7 +154,6 @@ public function cancel()
$DIC->ctrl()->redirect($this);
}


/**
*
*/
Expand All @@ -181,22 +169,24 @@ public function getActions()

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);
$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) {
), 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)));
$selection = ilMyStaffGUI::extendActionMenuWithUserActions($selection, $mst_co_usr_id,
rawurlencode($DIC->ctrl()
->getLinkTarget($this, self::CMD_INDEX)));

echo $selection->getHTML(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

/**
* Class ilMStListCertificatesTableGUI
*
* @author Martin Studer <[email protected]>
*/
class ilMStListCertificatesTableGUI extends ilTable2GUI
Expand All @@ -33,7 +32,6 @@ class ilMStListCertificatesTableGUI extends ilTable2GUI
*/
protected $access;


/**
* @param ilMStListCertificatesGUI $parent_obj
* @param string $parent_cmd
Expand Down Expand Up @@ -70,7 +68,6 @@ public function __construct(ilMStListCertificatesGUI $parent_obj, $parent_cmd =
$this->parseData();
}


/**
*
*/
Expand Down Expand Up @@ -104,7 +101,6 @@ protected function parseData() : void
$this->setData($data);
}


public function initFilter() : void
{
global $DIC;
Expand All @@ -116,7 +112,8 @@ public function initFilter() : void

//user
$item = new ilTextInputGUI($DIC->language()->txt("login") . "/" . $DIC->language()->txt("email") . "/" . $DIC->language()
->txt("name"), "user");
->txt("name"),
"user");

$this->addFilterItem($item);
$item->readFromSession();
Expand All @@ -136,7 +133,6 @@ public function initFilter() : void
}
}


/**
* @return array
*/
Expand Down Expand Up @@ -204,7 +200,6 @@ public function getSelectableColumns() : array
return $cols;
}


/**
*
*/
Expand All @@ -229,15 +224,14 @@ private function addColumns()
}
}


/**
* @param array $a_set
*/
public function fillRow(array $a_set) : void
{
global $DIC;

$propGetter = Closure::bind(function ($prop) {
$propGetter = Closure::bind(function($prop) {
return $this->$prop;
}, $a_set, $a_set);

Expand All @@ -246,7 +240,8 @@ public function fillRow(array $a_set) : void
switch ($k) {
case 'usr_assinged_orgus':
$this->tpl->setCurrentBlock('td');
$this->tpl->setVariable('VALUE', strval(ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set->getUserId())));
$this->tpl->setVariable('VALUE',
strval(ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($a_set->getUserId())));
$this->tpl->parseCurrentBlock();
break;
case 'issuedOnTimestamp':
Expand All @@ -258,7 +253,8 @@ public function fillRow(array $a_set) : void
default:
if ($propGetter($k) !== null) {
$this->tpl->setCurrentBlock('td');
$this->tpl->setVariable('VALUE', (is_array($propGetter($k)) ? implode(", ", $propGetter($k)) : $propGetter($k)));
$this->tpl->setVariable('VALUE',
(is_array($propGetter($k)) ? implode(", ", $propGetter($k)) : $propGetter($k)));
$this->tpl->parseCurrentBlock();
} else {
$this->tpl->setCurrentBlock('td');
Expand All @@ -280,7 +276,6 @@ public function fillRow(array $a_set) : void
$this->tpl->parseCurrentBlock();
}


/**
* @param ilExcel $a_excel excel wrapper
* @param int $a_row
Expand All @@ -295,7 +290,6 @@ protected function fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set) : v
}
}


/**
* @param ilCSVWriter $a_csv
* @param array $a_set
Expand All @@ -308,15 +302,13 @@ protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set) : void
$a_csv->addRow();
}


/**
* @param UserCertificateDto $user_certificate_dto
*
* @return array
*/
protected function getFieldValuesForExport(UserCertificateDto $user_certificate_dto)
{
$propGetter = Closure::bind(function ($prop) {
$propGetter = Closure::bind(function($prop) {
return $this->$prop;
}, $user_certificate_dto, $user_certificate_dto);

Expand Down
Loading