Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Mar 9, 2024
1 parent 9fe315c commit 4494e31
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 21 deletions.
10 changes: 1 addition & 9 deletions src/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,7 @@ public function createMailer(SettingsModel $settings = null): Mailer
*/
public function maxPowerLieutenant(): void
{
$settings = $this->getSettings();

// Set memory limit
@ini_set('memory_limit', $settings->memoryLimit);

// Try to reset time limit
if (!function_exists('set_time_limit') || !@set_time_limit($settings->timeLimit)) {
$this->log('set_time_limit() is not available');
}
App::maxPowerCaptain();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/SendoutsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function actionQueuePendingSendouts(): Response
public function actionGetPendingRecipientCount(): Response
{
$sendout = $this->_getSendoutFromParamId();
$this->response->content = (string)Campaign::$plugin->sendouts->getPendingRecipientCount($sendout);
$this->response->content = number_format(Campaign::$plugin->sendouts->getPendingRecipientCount($sendout));

return $this->response;
}
Expand Down
4 changes: 0 additions & 4 deletions src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ public function actionEditSendout(SettingsModel $settings = null): Response
'settings' => $settings,
'config' => Craft::$app->getConfig()->getConfigFromFile('campaign'),
'contactElementType' => ContactElement::class,
'memoryLimit' => ini_get('memory_limit'),
'timeLimit' => ini_get('max_execution_time'),
]);
}

Expand Down Expand Up @@ -267,8 +265,6 @@ public function actionSaveSendout(): ?Response
$settings->defaultNotificationContactIds = $this->request->getBodyParam('defaultNotificationContactIds', $settings->defaultNotificationContactIds) ?: null;
$settings->showSendoutTitleField = $this->request->getBodyParam('showSendoutTitleField', $settings->showSendoutTitleField) ?: false;
$settings->maxBatchSize = $this->request->getBodyParam('maxBatchSize', $settings->maxBatchSize) ?: null;
$settings->memoryLimit = $this->request->getBodyParam('memoryLimit', $settings->memoryLimit) ?: null;
$settings->timeLimit = $this->request->getBodyParam('timeLimit', $settings->timeLimit) ?: null;

// Save it
if (!Craft::$app->getPlugins()->savePluginSettings(Campaign::$plugin, $settings->getAttributes())) {
Expand Down
2 changes: 1 addition & 1 deletion src/models/SettingsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function behaviors(): array
protected function defineRules(): array
{
return [
[['apiKey', 'fromNamesEmails', 'transportType', 'maxBatchSize', 'memoryLimit', 'timeLimit'], 'required'],
[['apiKey', 'fromNamesEmails', 'transportType', 'maxBatchSize'], 'required'],
[['apiKey'], 'string', 'length' => [16]],
[['fromNamesEmails'], 'validateFromNamesEmails'],
[['maxBatchSize', 'timeLimit'], 'integer'],
Expand Down
8 changes: 4 additions & 4 deletions src/records/ImportRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
/**
* @property int $id ID
* @property int $assetId Asset ID
* @property string $fileNameFile name
* @property string $filePathFile path
* @property string $fileName File name
* @property string $filePath File path
* @property int $userGroupId User group ID
* @property int $userId User ID
* @property int $mailingListId Mailing list ID
* @property bool $unsubscribe
* @property bool $forceSubscribe
* @property string $emailFieldIndex Email field index
* @property mixed $fieldIndexesField
* @property mixed $fieldIndexes Field indexes
* @property int $added Added
* @property int $updated Updated
* @property int $failures Failures
* @property DateTime $dateImportedDate imported
* @property DateTime $dateImported Date imported
*/
class ImportRecord extends ActiveRecord
{
Expand Down
2 changes: 1 addition & 1 deletion src/records/SendoutRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @property string $sid SID
* @property int $campaignId Campaign ID
* @property int $senderId Sender ID
* @property string $sendoutTypeSendout Sendout type
* @property string $sendoutType Sendout type
* @property string $sendStatus Send status
* @property string $fromName From name
* @property string $fromEmail From email
Expand Down
2 changes: 1 addition & 1 deletion src/resources/js/ContactEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Campaign.ContactEdit = Garnish.Base.extend({

$row.find('input, .remove').addClass('hidden');

if (response.data.subscriptionStatus == 'subscribed') {
if (response.data.subscriptionStatus === 'subscribed') {
$row.find('input.unsubscribe').removeClass('hidden');
}
else {
Expand Down

0 comments on commit 4494e31

Please sign in to comment.