Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed #4361 - [Workflows] Add notification option for Pimcore notification system * fixed #128 - [DataObjects] DataQuality reports - docs * Coding Standards Fixer Bot * [Document] Support for Folders & Links as a Fallback Document (#4860) * [Document] Support for folders & links as a fallback document * [DOCS] added docs for #4860 * add a check in ElementListener for PageSnippet, otherwise this can lead to exceptions under certain conditions
- Loading branch information
Showing
12 changed files
with
281 additions
and
105 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
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
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,92 @@ | ||
<?php | ||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Enterprise License (PEL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PEL | ||
*/ | ||
|
||
namespace Pimcore\Workflow\Notification; | ||
|
||
use Pimcore\Model\Element\Note; | ||
use Pimcore\Model\User; | ||
|
||
|
||
class AbstractNotificationService | ||
{ | ||
protected function getNoteInfo($id): string | ||
{ | ||
$noteList = new Note\Listing(); | ||
$noteList->addConditionParam('(cid = ?)', [$id]); | ||
$noteList->setOrderKey('date'); | ||
$noteList->setOrder('desc'); | ||
$noteList->setLimit(1); | ||
|
||
$notes = $noteList->load(); | ||
|
||
if (count($notes) == 1) { | ||
// found matching note | ||
return $notes[0]->getDescription(); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
/** | ||
* Returns a list of distinct users given an user- and role array containing their respective names | ||
* | ||
* @param $users | ||
* @param $roles | ||
* | ||
* @return User[][] | ||
*/ | ||
protected function getNotificationUsersByName($users, $roles, $includeAllUsers = false): array | ||
{ | ||
$notifyUsers = []; | ||
|
||
//get roles | ||
$roleList = new User\Role\Listing(); | ||
$roleList->setCondition('FIND_IN_SET(name, ?)', [implode(',', $roles)]); | ||
|
||
foreach ($roleList->load() as $role) { | ||
$userList = new User\Listing(); | ||
$userList->setCondition('FIND_IN_SET(?, roles) > 0', [$role->getId()]); | ||
|
||
foreach ($userList->load() as $user) { | ||
if ($includeAllUsers || $user->getEmail()) { | ||
$notifyUsers[$user->getLanguage()][$user->getId()] = $user; | ||
} | ||
} | ||
} | ||
|
||
//get users | ||
$userList = new User\Listing(); | ||
if($includeAllUsers) { | ||
$userList->setCondition('FIND_IN_SET(name, ?)', [implode(',', $users)]); | ||
} else { | ||
$userList->setCondition('FIND_IN_SET(name, ?) and email is not null', [implode(',', $users)]); | ||
} | ||
|
||
foreach ($userList->load() as $user) { | ||
/** | ||
* @var User $user | ||
*/ | ||
if ($includeAllUsers || $user->getEmail()) { | ||
$notifyUsers[$user->getLanguage()][$user->getId()] = $user; | ||
} | ||
} | ||
|
||
foreach ($notifyUsers as $language => $usersPerLanguage) { | ||
$notifyUsers[$language] = array_values($notifyUsers[$language]); | ||
} | ||
|
||
return $notifyUsers; | ||
} | ||
|
||
} |
Oops, something went wrong.