Skip to content

Commit

Permalink
Merge branch 'concretecms:9.3.x' into wordish-patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
wordish authored Oct 29, 2024
2 parents bb072c4 + ae3bed9 commit 2a83b4b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
29 changes: 26 additions & 3 deletions concrete/src/Csv/Export/UserExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Concrete\Core\Attribute\Category\UserCategory;
use Concrete\Core\Attribute\ObjectInterface;
use Concrete\Core\Config\Repository\Repository;
use Concrete\Core\Localization\Service\Date;
use League\Csv\Writer;

Expand All @@ -15,17 +16,29 @@ class UserExporter extends AbstractExporter
*/
protected $appTimezone;

/**
* @var Date
*/
protected $dateService;

/**
* @var string
*/
protected $format;

/**
* Initialize the instance.
*
* @param Writer $writer
* @param UserCategory $userCategory
* @param Date $dateService
*/
public function __construct(Writer $writer, UserCategory $userCategory, Date $dateService)
public function __construct(Writer $writer, UserCategory $userCategory, Date $dateService, Repository $config)
{
parent::__construct($writer, $userCategory);
$this->appTimezone = $dateService->getTimezone('app');
$this->dateService = $dateService;
$this->format = $this->getFormat($config->get('concrete.export.csv.datetime_format', 'ATOM'));
}

/**
Expand Down Expand Up @@ -58,12 +71,22 @@ protected function getStaticFieldValues(ObjectInterface $userInfo)
$dateTime = $userInfo->getUserDateAdded();
if ($dateTime) {
$dateTime = clone $dateTime;
$dateTime->setTimezone($this->appTimezone);
yield $dateTime->format('Y-m-d H:i:s');
yield $this->dateService->formatCustom($this->format, $dateTime, 'app');
} else {
yield '';
}
yield $userInfo->isActive() ? '1' : '0';
yield (string) (int) $userInfo->getNumLogins();
}

protected function getFormat(string $formatName = 'ATOM')
{
$datetime_format_constant = sprintf('DATE_%s', $formatName);

if (defined($datetime_format_constant)) {
return constant($datetime_format_constant);
}

return DATE_ATOM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function view(): RedirectResponse
$repository = $this->app->make(PackageRepositoryInterface::class);
$coordinator = $this->app->make(PurchaseConnectionCoordinator::class);
$connection = $repository->getConnection();
if ($repository->validate($connection)) {
if ($connection !== null && $repository->validate($connection)) {
// Redirect the url to the marketplace with a verified connection
$url = $coordinator->createPurchaseConnectionUrl(
$connection,
Expand Down

0 comments on commit 2a83b4b

Please sign in to comment.