Skip to content

Commit

Permalink
tweak(Addressbook/List): catch 403 in getListMembersWithFunctions
Browse files Browse the repository at this point in the history
... because this is used in twig templates and exports should not fail
  • Loading branch information
pschuele committed Jan 21, 2025
1 parent d8e78ec commit 92c001e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
33 changes: 20 additions & 13 deletions tine20/Addressbook/Model/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,11 @@ public function getPathNeighbours()

/**
* @return string
* @throws Tinebase_Exception_InvalidArgument
* @throws Tinebase_Exception_AccessDenied
* @throws Tinebase_Exception_InvalidArgument
* @throws Tinebase_Exception_NotFound
*/
public function getListMembersWithFunctions()
public function getListMembersWithFunctions(): string
{
// @todo huge crap messed up by currently broken resolving.
if (is_string($this->members) || empty($this->members)) {
Expand All @@ -339,23 +340,29 @@ public function getListMembersWithFunctions()
$members = $this->members;
}

$roles = Addressbook_Controller_List::getInstance()->getMemberRolesBackend()->search(new Addressbook_Model_ListMemberRoleFilter([
$roles = Addressbook_Controller_List::getInstance()->getMemberRolesBackend()->search(
new Addressbook_Model_ListMemberRoleFilter([
'list_id' => $this->getId()
]));

$membersWithRoles = [];

foreach($members as $memberId) {
if (!($memberRole = $roles->filter('contact_id', $memberId)->getFirstRecord())) {
$membersWithRoles[] = Addressbook_Controller_Contact::getInstance()->get($memberId)->getTitle();
continue;
foreach ($members as $memberId) {
try {
if (!($memberRole = $roles->filter('contact_id', $memberId)->getFirstRecord())) {
$membersWithRoles[] = Addressbook_Controller_Contact::getInstance()->get($memberId)->getTitle();
continue;
}
$membersWithRoles[] = \sprintf(
'%s (%s)',
Addressbook_Controller_Contact::getInstance()->get($memberId)->getTitle(),
Addressbook_Controller_ListRole::getInstance()->get($memberRole->list_role_id)->getTitle()
);
} catch (Tinebase_Exception_AccessDenied $tead) {
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $tead->getMessage());
}
}

$membersWithRoles[] = \sprintf(
'%s (%s)',
Addressbook_Controller_Contact::getInstance()->get($memberId)->getTitle(),
Addressbook_Controller_ListRole::getInstance()->get($memberRole->list_role_id)->getTitle()
);
}

return implode(', ', $membersWithRoles);
Expand Down
6 changes: 3 additions & 3 deletions tine20/Addressbook/Model/ListHiddenFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public function appendFilterSql($_select, $_backend)

if ($value){
// nothing to do -> show all lists!
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all lists.');
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all lists.');
}
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Only query visible lists.');

$_select->joinLeft(
/* table */ array('groupvisibility' => $db->table_prefix . 'groups'),
/* on */ $db->quoteIdentifier('groupvisibility.list_id') . ' = ' . $db->quoteIdentifier('addressbook_lists.id'),
Expand Down

0 comments on commit 92c001e

Please sign in to comment.