[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.119.253.198: ~ $
<?php

namespace MailPoet\Segments;

if (!defined('ABSPATH')) exit;


use MailPoet\Entities\SegmentEntity;
use MailPoet\Listing\ListingDefinition;
use MailPoet\Listing\ListingRepository;
use MailPoet\Util\Helpers;
use MailPoetVendor\Doctrine\ORM\EntityManager;
use MailPoetVendor\Doctrine\ORM\QueryBuilder;

class SegmentListingRepository extends ListingRepository {
  const DEFAULT_SORT_BY = 'name';

  /** @var WooCommerce */
  private $wooCommerce;

  public function __construct(
    EntityManager $entityManager,
    WooCommerce $wooCommerce
  ) {
    parent::__construct($entityManager);
    $this->wooCommerce = $wooCommerce;
  }

  protected function applySelectClause(QueryBuilder $queryBuilder) {
    $queryBuilder->select("PARTIAL s.{id,name,type,description,createdAt,updatedAt,deletedAt,averageEngagementScore}");
  }

  protected function applyFromClause(QueryBuilder $queryBuilder) {
    $queryBuilder->from(SegmentEntity::class, 's');
  }

  protected function applyGroup(QueryBuilder $queryBuilder, string $group) {
    if ($group === 'trash') {
      $queryBuilder->andWhere('s.deletedAt IS NOT NULL');
    } else {
      $queryBuilder->andWhere('s.deletedAt IS NULL');
    }
  }

  protected function applySearch(QueryBuilder $queryBuilder, string $search) {
    $search = Helpers::escapeSearch($search);
    $queryBuilder
      ->andWhere('s.name LIKE :search or s.description LIKE :search')
      ->setParameter('search', "%$search%");
  }

  protected function applyFilters(QueryBuilder $queryBuilder, array $filters) {
  }

  protected function applyParameters(QueryBuilder $queryBuilder, array $parameters) {
    $types = [SegmentEntity::TYPE_DEFAULT, SegmentEntity::TYPE_WP_USERS];
    if ($this->wooCommerce->shouldShowWooCommerceSegment()) {
      $types[] = SegmentEntity::TYPE_WC_USERS;
    }
    $queryBuilder
      ->andWhere('s.type IN (:type)')
      ->setParameter('type', $types);
  }

  protected function applySorting(QueryBuilder $queryBuilder, string $sortBy, string $sortOrder) {
    if (!$sortBy) {
      $sortBy = self::DEFAULT_SORT_BY;
    }
    $queryBuilder->addOrderBy("s.$sortBy", $sortOrder);
  }

  public function getGroups(ListingDefinition $definition): array {
    $queryBuilder = clone $this->queryBuilder;
    $this->applyFromClause($queryBuilder);
    $this->applyParameters($queryBuilder, $definition->getParameters());

    $queryBuilder->select('count(s.id)');

    if (!$this->wooCommerce->shouldShowWooCommerceSegment()) {
      $queryBuilder
        ->andWhere('s.type != :wcUsers')
        ->setParameter('wcUsers', SegmentEntity::TYPE_WC_USERS);
    }

    $allQueryBuilder = clone $queryBuilder;
    $trashedQueryBuilder = clone $queryBuilder;

    $allQueryBuilder->andWhere('s.deletedAt IS NULL');
    $allCount = (int)$allQueryBuilder->getQuery()->getSingleScalarResult();

    $trashedQueryBuilder->andWhere('s.deletedAt IS NOT NULL');
    $trashedCount = (int)$trashedQueryBuilder->getQuery()->getSingleScalarResult();

    return [
      [
        'name' => 'all',
        'label' => __('All', 'mailpoet'),
        'count' => $allCount,
      ],
      [
        'name' => 'trash',
        'label' => __('Trash', 'mailpoet'),
        'count' => $trashedCount,
      ],
    ];
  }
}

Filemanager

Name Type Size Permission Actions
DynamicSegments Folder 0755
SegmentDependencyValidator.php File 2.39 KB 0644
SegmentListingRepository.php File 3.18 KB 0644
SegmentSaveController.php File 2.22 KB 0644
SegmentSubscribersRepository.php File 19.54 KB 0644
SegmentsRepository.php File 7.37 KB 0644
SegmentsSimpleListRepository.php File 4.77 KB 0644
SubscribersFinder.php File 4.68 KB 0644
WP.php File 11.88 KB 0644
WooCommerce.php File 17.52 KB 0644
index.php File 0 B 0644