-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/dev/1.9' into 1.9
- Loading branch information
Showing
30 changed files
with
857 additions
and
116 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
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
43 changes: 43 additions & 0 deletions
43
src/OroCRM/Bundle/MagentoBundle/EventListener/CustomerGroupGridListener.php
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,43 @@ | ||
<?php | ||
|
||
namespace OroCRM\Bundle\MagentoBundle\EventListener; | ||
|
||
use Oro\Bundle\DataGridBundle\Datasource\Orm\OrmDatasource; | ||
use Oro\Bundle\DataGridBundle\Event\BuildAfter; | ||
use Oro\Bundle\SecurityBundle\SecurityFacade; | ||
|
||
/** | ||
* Listener for grid "magento-customers-group-by-channel-grid". | ||
* | ||
* @see \OroCRM\Bundle\MagentoBundle\Autocomplete\CustomerGroupSearchHandler | ||
*/ | ||
class CustomerGroupGridListener | ||
{ | ||
/** @var SecurityFacade */ | ||
protected $securityFacade; | ||
|
||
/** | ||
* @param SecurityFacade $securityFacade | ||
*/ | ||
public function __construct(SecurityFacade $securityFacade) | ||
{ | ||
$this->securityFacade = $securityFacade; | ||
} | ||
|
||
/** | ||
* @param BuildAfter $event | ||
*/ | ||
public function onBuildAfter(BuildAfter $event) | ||
{ | ||
$datagrid = $event->getDatagrid(); | ||
$datasource = $datagrid->getDatasource(); | ||
if ($datasource instanceof OrmDatasource) { | ||
$queryBuilder = $datasource->getQueryBuilder(); | ||
$isGranted = $this->securityFacade->isGranted('oro_integration_assign'); | ||
// if permission for integration channel assign is not granted | ||
if (!$isGranted) { | ||
$queryBuilder->andWhere('1 = 0'); | ||
} | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/OroCRM/Bundle/MagentoBundle/EventListener/StoreGridListener.php
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,86 @@ | ||
<?php | ||
|
||
namespace OroCRM\Bundle\MagentoBundle\EventListener; | ||
|
||
use Doctrine\ORM\EntityManager; | ||
|
||
use Oro\Bundle\DataGridBundle\Datasource\Orm\OrmDatasource; | ||
use Oro\Bundle\DataGridBundle\Event\BuildAfter; | ||
use Oro\Bundle\SecurityBundle\SecurityFacade; | ||
|
||
use OroCRM\Bundle\MagentoBundle\Entity\MagentoSoapTransport; | ||
use OroCRM\Bundle\MagentoBundle\Provider\Iterator\StoresSoapIterator; | ||
use OroCRM\Bundle\ChannelBundle\Entity\Channel; | ||
|
||
/** | ||
* Listener for grid "magento-store-by-channel-grid". | ||
* | ||
* @see \OroCRM\Bundle\MagentoBundle\Autocomplete\StoreSearchHandler | ||
*/ | ||
class StoreGridListener | ||
{ | ||
/** @var SecurityFacade */ | ||
protected $securityFacade; | ||
|
||
/** @var string */ | ||
protected $dataChannelClass; | ||
|
||
/** @var EntityManager */ | ||
protected $entityManager; | ||
|
||
/** | ||
* @param SecurityFacade $securityFacade | ||
* @param string $dataChannelClass | ||
* @param EntityManager $entityManager | ||
*/ | ||
public function __construct(SecurityFacade $securityFacade, $dataChannelClass, EntityManager $entityManager) | ||
{ | ||
$this->securityFacade = $securityFacade; | ||
$this->dataChannelClass = $dataChannelClass; | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
/** | ||
* Limit stores to website selected in integration settings | ||
* if ASSIGN permission for integration channel is granted | ||
* | ||
* @param BuildAfter $event | ||
*/ | ||
public function onBuildAfter(BuildAfter $event) | ||
{ | ||
$datagrid = $event->getDatagrid(); | ||
$datasource = $datagrid->getDatasource(); | ||
if ($datasource instanceof OrmDatasource) { | ||
if ($this->securityFacade->isGranted('oro_integration_assign')) { | ||
$parameters = $datagrid->getParameters(); | ||
$channelIds = $parameters->get('channelIds'); | ||
$dataChannel = $this->getDataChannelById($channelIds); | ||
if ($dataChannel) { | ||
$transport = $dataChannel->getDataSource()->getTransport(); | ||
if ($transport instanceof MagentoSoapTransport) { | ||
$websiteId = $transport->getSettingsBag()->get('website_id'); | ||
if ($websiteId !== StoresSoapIterator::ALL_WEBSITES) { | ||
$datasource | ||
->getQueryBuilder() | ||
->andWhere('w.originId = :id') | ||
->setParameter('id', $websiteId); | ||
} | ||
} | ||
} | ||
} else { | ||
// if permission for integration channel assign is not granted | ||
$datasource->getQueryBuilder() | ||
->andWhere('1 = 0'); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @param int $dataChannelId | ||
* @return Channel | ||
*/ | ||
protected function getDataChannelById($dataChannelId) | ||
{ | ||
return $this->entityManager->find($this->dataChannelClass, $dataChannelId); | ||
} | ||
} |
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
Oops, something went wrong.