From 1ed6b8f50b495c59c74a9885c28edffda9106d67 Mon Sep 17 00:00:00 2001 From: lvessiller <lvessiller@open-dsi.fr> Date: Wed, 30 Sep 2020 11:01:02 +0200 Subject: [PATCH] FIX agent display name if no user found (agent list) --- templates/content/agent_list.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/templates/content/agent_list.php b/templates/content/agent_list.php index dc62598..6dbe0fd 100644 --- a/templates/content/agent_list.php +++ b/templates/content/agent_list.php @@ -4,6 +4,8 @@ $exportDirUserPath = (isset($_['exportDirUserPath']) ? $_['exportDirUserPath'] : ''); $msgList = (isset($_['msgList']) ? $_['msgList'] : array()); + $urlGenerator = OC::$server->getURLGenerator(); + // alert messages $htmlAlert = ''; if (!empty($msgList)) { @@ -46,10 +48,10 @@ <?php if (!empty($htmlAlert)) { ?> <div id="dematpayslip_alert"><?php print $htmlAlert; ?></div> <?php } ?> - <h2><?php p($l->t('Liste des agents')); ?> <a href="<?php echo \OC\URLGenerator::linkToRoute('dematpayslip.page.agent_csv'); ?>" class="button" title="<?php p($l->t('Export CSV')); ?>"><?php p($l->t('CSV')); ?></a></h2> + <h2><?php p($l->t('Liste des agents')); ?> <a href="<?php echo $urlGenerator->linkToRoute('dematpayslip.page.agent_csv'); ?>" class="button" title="<?php p($l->t('Export CSV')); ?>"><?php p($l->t('CSV')); ?></a></h2> <div> - <a href="<?php echo \OC\URLGenerator::linkToRoute('files.view.index', ['dir' => $exportDirUserPath]); ?>" class="button" target="_blank" title="<?php p($l->t('Accéder aux exports CSV')); ?>"><?php p($l->t('Accéder aux exports CSV')); ?></a> + <a href="<?php echo $urlGenerator->linkToRoute('files.view.index', ['dir' => $exportDirUserPath]); ?>" class="button" target="_blank" title="<?php p($l->t('Accéder aux exports CSV')); ?>"><?php p($l->t('Accéder aux exports CSV')); ?></a> </div> <br /> @@ -74,10 +76,16 @@ <tbody> <?php foreach ($dematpayslipUserList as $dematpayslipUser) { + $dematpayslipUserId = $dematpayslipUser->getUserId(); + $dematpayslipUserDisplayName = $dematpayslipUserId; + $user = OC::$server->getUserManager()->get($dematpayslipUserId); + if ($user) { + $dematpayslipUserDisplayName = $user->getDisplayName(); + } ?> <tr> <!-- <th>--><?php //print $dematpayslipUser->getUserId(); ?><!--</th>--> - <th scope="row"><?php print \OC::$server->getUserManager()->get($dematpayslipUser->getUserId())->getDisplayName(); ?></th> + <th scope="row"><?php print $dematpayslipUserDisplayName; ?></th> <td><?php print $dematpayslipUser->getSiret(); ?></td> <td><?php print $dematpayslipUser->getMatricule(); ?></td> <td><?php print $dematpayslipUser->getEmail(); ?></td> -- GitLab