Get review campaign for automation review.

@param int $website

@return int
176065
public function getCampaign($website)
    {
        return $this->getReviewWebsiteSettings(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_REVIEW_CAMPAIGN,
            $website
        );
    }
1343477
public function _exportReviewsForWebsite(\Magento\Store\Model\Website $website)
    {
        $limit           = $this->helper->getWebsiteConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT,
            $website
        );
        $emailReviews    = $this->_getReviewsToExport($website, $limit);
        $this->reviewIds = [];

        if ($emailReviews->getSize()) {
            $ids = $emailReviews->getColumnValues('review_id');
            $reviewResourceFactory = $this->reviewResourceFactory->create();
            $reviews = $reviewResourceFactory->getMageReviewsByIds($ids);

            foreach ($reviews as $mageReview) {
                try {
                    $product = $reviewResourceFactory
                        ->getProductByIdAndStore($mageReview->getEntityPkValue(), $mageReview->getStoreId());

                    $connectorReview = $this->connectorReviewFactory->create()
                        ->setReviewData($mageReview)
                        ->setProduct($product);

                    $votesCollection = $reviewResourceFactory
                        ->getVoteCollectionByReview($mageReview->getReviewId());

                    foreach ($votesCollection as $ratingItem) {
                        $rating = $this->ratingFactory->create()
                            ->setRating($ratingItem);
                        $connectorReview->createRating(
                            $ratingItem->getRatingCode(),
                            $rating
                        );
                    }
                    $this->reviews[$website->getId()][] = $connectorReview->expose();
                    $this->reviewIds[]                  = $mageReview->getReviewId();
                } catch (\Exception $e) {
                    $this->helper->debug((string)$e, []);
                }
            }
        }
    }
1109124
public function getSyncLimit($website = 0)
    {
        $website = $this->storeManager->getWebsite($website);

        return $this->scopeConfig->getValue(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_LIMIT,
            \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
            $website
        );
    }
262163
public function getCampaignUtilizationActivitiesByBranches($node) {
    $branchIds = $node->get('field_campaign_branch_target')->getValue();
    $ids = [];
    foreach ($branchIds as $branchId) {
      $ids[] = $branchId['target_id'];
    }

    // Check for the started campaign.
    $isCampaignStarted = $this->checkIsCampaignStarted($node);

    if (!empty($ids) && $isCampaignStarted) {
      $query = $this->connection->select('openy_campaign_util_activity', 'ua');

      $query->leftJoin('openy_campaign_member_campaign', 'mc', 'ua.member_campaign = mc.id');
      $query->condition('mc.campaign', $node->id());
      $query->leftJoin('openy_campaign_member', 'cm', 'mc.member = cm.id');
      $query->fields('cm', ['branch']);
      $query->fields('ua', ['id']);
      $result = $query->execute()->fetchAll();

      $counter = [];
      foreach ($result as $item) {
        if (isset($counter[$item->branch])) {
          $counter[$item->branch]++;
        }
        else {
          $counter[$item->branch] = 1;
        }
      }

      return $counter;

    }
    return [];

  }
975013
def get_review(self, id):
        
        assert isinstance(id, (int, long)), id
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/reviews/" + str(id),
        )
        return github.PullRequestReview.PullRequestReview(self._requester, headers, data, completed=True)
1173702
public function getDisplayType($website)
    {
        return $this->getReviewWebsiteSettings(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_REVIEW_DISPLAY_TYPE,
            $website
        );
    }
524467
public function doReview($data) {
		$id = isset($data['ID']) ? (int)$data['ID'] : null;
		if (!$id) {
			user_error('Invalid ID passed for review action');
			$this->redirectBack();
		}
		return $this->owner->redirect(Controller::join_links($this->owner->Link('review'), $id));
	}
262323
public function exportCustomersForWebsite(\Magento\Store\Api\Data\WebsiteInterface $website)
    {
        $allMappedHash = [];
        //admin sync limit of batch size for contacts
        $syncLimit = $this->helper->getSyncLimit($website);
        //address book id mapped
        $customerAddressBook = $this->helper->getCustomerAddressBook($website);

        //skip website if address book not mapped
        if (!$customerAddressBook) {
            return 0;
        }

        $onlySubscribers = $this->helper->isOnlySubscribersForContactSync($website->getId());
        $contacts = $this->contactCollectionFactory->create();
        $contacts = ($onlySubscribers) ? $contacts->getContactsToImportByWebsite($website->getId(), $syncLimit, true) :
            $contacts->getContactsToImportByWebsite($website->getId(), $syncLimit);

        // no contacts found
        if (!$contacts->getSize()) {
            return 0;
        }
        //customer filename
        $customersFile = strtolower(
            $website->getCode() . '_customers_' . date('d_m_Y_His') . '.csv'
        );
        $this->helper->log('Customers file : ' . $customersFile);
        //get customers ids
        $customerIds = $contacts->getColumnValues('customer_id');
        /*
         * HEADERS.
         */
        $mappedHash = $this->helper->getWebsiteCustomerMappingDatafields(
            $website
        );
        $headers = $mappedHash;

        //custom customer attributes
        $customAttributes = $this->helper->getCustomAttributes($website);

        if ($customAttributes) {
            foreach ($customAttributes as $data) {
                $headers[] = $data['datafield'];
                $allMappedHash[$data['attribute']] = $data['datafield'];
            }
        }
        $headers[] = 'Email';
        $headers[] = 'EmailType';

        $this->file->outputCSV(
            $this->file->getFilePath($customersFile),
            $headers
        );
        /*
         * END HEADERS.
         */

        //customer collection
        $customerCollection = $this->contactResource->buildCustomerCollection($customerIds);

        //Customer sales data
        $salesData = $this->getCustomerSalesData($customerIds, $website->getId());

        $this->createCsvFile(
            $customerCollection,
            $mappedHash,
            $customAttributes,
            $customersFile,
            $salesData
        );

        $customerNum = count($customerIds);
        $this->helper->log(
            'Website : ' . $website->getName() . ', customers = ' . $customerNum .
            ', execution time :' . gmdate('H:i:s', microtime(true) - $this->start)
        );

        //file was created - continue to queue the export
        $this->contactImportQueueExport->enqueueForExport(
            $website,
            $customersFile,
            $customerNum,
            $customerIds,
            $this->contactResource
        );

        $this->countCustomers += $customerNum;

        return $customerNum;
    }
974613
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $dataObject = $observer->getEvent()->getDataObject();

        if ($dataObject->getCustomerId()
            && $dataObject->getStatusId()
            == \Magento\Review\Model\Review::STATUS_APPROVED
        ) {
            $customerId = $dataObject->getCustomerId();
            $this->helper->setConnectorContactToReImport($customerId);
            //save review info in the table
            $this->registerReview($dataObject);
            $store = $this->storeManager->getStore($dataObject->getStoreId());
            $storeName = $store->getName();
            $website = $this->storeManager->getStore($store)->getWebsite();
            $customer = $this->customerFactory->create();
            $this->customerResource->load($customer, $customerId);
            //if api is not enabled
            if (!$this->helper->isEnabled($website)) {
                return $this;
            }

            $programId
                = $this->helper->getWebsiteConfig('connector_automation/visitor_automation/review_automation');
            if ($programId) {
                $automation = $this->automationFactory->create();
                $automation->setEmail($customer->getEmail())
                    ->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_REVIEW)
                    ->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)
                    ->setTypeId($dataObject->getReviewId())
                    ->setWebsiteId($website->getId())
                    ->setStoreName($storeName)
                    ->setProgramId($programId);
                $this->automationResource->save($automation);
            }
        }

        return $this;
    }
109803
function get_call_count($tag='') {
		if ($tag) {
			$count = 0;
			foreach ($this->events as $e)
				if ($e['action'] == $tag)
					++$count;
			return $count;
		}
		return count($this->events);
	}
1232044
public static function getWebsitesCountToDisplay()
    {
        $count = max(Config::getInstance()->General['site_selector_max_sites'],
            Config::getInstance()->General['autocomplete_min_sites']);
        return (int)$count;
    }
438851
private function checkCampignEnrolmentActive($programId, $websiteId)
    {
        //program is not set
        if (!$programId) {
            return false;
        }
        $client = $this->helper->getWebsiteApiClient($websiteId);
        $program = $client->getProgramById($programId);
        //program status
        if (isset($program->status)) {
            $this->programStatus = $program->status;
        }
        if (isset($program->status) && $program->status == 'Active') {
            return true;
        }

        return false;
    }
406153
public function isCustomerSyncEnabled($website = 0)
    {
        $website = $this->storeManager->getWebsite($website);

        return $this->scopeConfig->isSetFlag(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_CUSTOMER_ENABLED,
            \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
            $website
        );
    }
816742
public function &GetReviewsPublished()
    {
        $oReviews = $this->GetFromInternalCache('oPublishedReviews');
        if (is_null($oReviews)) {
            $oReviews = &TdbShopArticleReviewList::GetPublishedReviews($this->id, $this->iLanguageId);
            $this->SetInternalCache('oPublishedReviews', $oReviews);
        }

        return $oReviews;
    }
992426
public function getGuests($website, $onlySubscriber = false)
    {
        return $this->getCollection()
            ->getGuests($website->getId(), $onlySubscriber);
    }
187039
public function tenant(Website $website = null): ?Website
    {
        if ($website !== null) {
            $this->app->instance(Tenant::class, $website);

            $this->emitEvent(new Events\Websites\Switched($website));

            return $website;
        }

        return $this->app->make(Tenant::class);
    }
469725
protected function isUserGranted($permission, Website $website, $collection = null)
    {
        if (null === $collection) {
            $collection = new ResourceCollection([$website->getResourceNode()]);
        }
        $checkPermission = false;
        if ($this->get('security.authorization_checker')->isGranted($permission, $collection)) {
            $checkPermission = true;
        }

        return $checkPermission;
    }