Skip to content

Commit

Permalink
Autocommit PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
luke- authored and github-actions[bot] committed Sep 9, 2024
1 parent 83a0e80 commit 529eabf
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 51 deletions.
18 changes: 9 additions & 9 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static function onIntegrityCheck($event)
try {
foreach (Message::find()->each() as $message) {
/* @var $message Message */
if(!$message->getAuthor()->count()) {
if (!$message->getAuthor()->count()) {
if ($integrityController->showFix("Deleting conversation id " . $message->id . " without existing author!")) {
$message->delete();
}
Expand All @@ -53,12 +53,12 @@ public static function onIntegrityCheck($event)

foreach (MessageEntry::find()->each() as $messageEntry) {
/* @var $messageEntry MessageEntry */
if(!$messageEntry->getUser()->count()) {
if (!$messageEntry->getUser()->count()) {
if ($integrityController->showFix("Deleting message entry id " . $messageEntry->id . " without existing user!")) {
$messageEntry->delete();
}
}
if(!$messageEntry->message) {
if (!$messageEntry->message) {
if ($integrityController->showFix("Deleting message entry id " . $messageEntry->id . " without existing conversation!")) {
$messageEntry->delete();
}
Expand All @@ -69,7 +69,7 @@ public static function onIntegrityCheck($event)

foreach (UserMessage::find()->each() as $userMessage) {
/* @var $userMessage UserMessage */
if(!$userMessage->getUser()->count()) {
if (!$userMessage->getUser()->count()) {
if ($integrityController->showFix("Deleting user message id " . $userMessage->message_id . " without existing user!")) {
$userMessage->delete();
}
Expand All @@ -80,13 +80,13 @@ public static function onIntegrityCheck($event)

foreach (UserMessageTag::find()->each() as $messageTag) {
/* @var $messageTag UserMessageTag */
if(!$messageTag->getUser()->count()) {
if (!$messageTag->getUser()->count()) {
if ($integrityController->showFix("Deleting user tag id " . $messageTag->id . " without existing user!")) {
$messageTag->delete();
}
}
}
} catch(\Throwable $e) {
} catch (\Throwable $e) {
Yii::error($e);
}
}
Expand All @@ -109,7 +109,7 @@ public static function onUserDelete($event)
}

foreach (UserMessage::findAll(['user_id' => $event->sender->id]) as $userMessage) {
if($userMessage->message) {
if ($userMessage->message) {
$userMessage->message->leave($event->sender->id);
}

Expand All @@ -119,7 +119,7 @@ public static function onUserDelete($event)
foreach (UserMessageTag::findAll(['user_id' => $event->sender->id]) as $userMessageTag) {
$userMessageTag->delete();
}
} catch(\Throwable $e) {
} catch (\Throwable $e) {
Yii::error($e);
}

Expand Down Expand Up @@ -150,7 +150,7 @@ public static function onTopMenuInit($event)
'sortOrder' => 300,
]);
}
} catch(\Throwable $e) {
} catch (\Throwable $e) {
Yii::error($e);
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/InboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function actionLoadMore()
foreach ($userMessages as $userMessage) {
try {
$result .= InboxMessagePreview::widget(['userMessage' => $userMessage]);
} catch(\Throwable $e) {
} catch (\Throwable $e) {
Yii::error($e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function actionAdd()
{
$model = new AddTag();
$model->load(Yii::$app->request->post());
if($model->save()) {
if ($model->save()) {
$model = new AddTag();
}
return $this->render('manage', ['model' => $model]);
Expand All @@ -53,7 +53,7 @@ public function actionEdit($id)
{
$tag = $this->findTag($id);

if($tag->load(Yii::$app->request->post()) && $tag->save()) {
if ($tag->load(Yii::$app->request->post()) && $tag->save()) {
return ModalClose::widget(['reload' => true]);
}

Expand Down
2 changes: 1 addition & 1 deletion migrations/m150709_050452_message_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function safeUp()

try {
$this->addForeignKey('fk-message-tag-user-id', 'message_tag', 'user_id', 'user', 'id', 'cascade');
} catch(\Exception $e) {
} catch (\Exception $e) {
Yii::error($e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions migrations/m150709_050453_conversation_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public function safeUp()

try {
$this->addForeignKey('fk-user-message-id', 'user_message_tag', ['message_id', 'user_id'], 'user_message', ['message_id', 'user_id'], 'cascade');
} catch(\Exception $e) {
} catch (\Exception $e) {
Yii::error($e, 'mail');
}

try {
$this->addForeignKey('fk-conversation-tag-tag-id', 'user_message_tag', 'tag_id', 'message_tag', 'id', 'cascade');
} catch(\Exception $e) {
} catch (\Exception $e) {
Yii::error($e, 'mail');
}
}
Expand Down
10 changes: 5 additions & 5 deletions models/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function attributeLabels()

public function save()
{
if(!$this->validate()) {
if (!$this->validate()) {
return false;
}

Expand All @@ -103,7 +103,7 @@ public function save()

public function canCreateConversation(User $originator)
{
if($originator->isSystemAdmin()) {
if ($originator->isSystemAdmin()) {
return true;
}

Expand All @@ -116,7 +116,7 @@ public function canCreateConversation(User $originator)

public function isNewUser(User $originator)
{
if(empty($this->newUserRestrictionEnabled)) {
if (empty($this->newUserRestrictionEnabled)) {
return false;
}

Expand All @@ -128,7 +128,7 @@ public function getConversationCount($originator)
$module = static::getModule();
$lastTS = $module->settings->contentContainer($originator)->get('conversationCountTime');

if(!$lastTS) {
if (!$lastTS) {
$module->settings->contentContainer($originator)->set('conversationCountTime', time());
$module->settings->contentContainer($originator)->set('conversationCount', 0);
return 0;
Expand All @@ -137,7 +137,7 @@ public function getConversationCount($originator)
$lastDate = (new \DateTime())->setTimestamp($lastTS);
$today = (new \DateTime())->setTime(0, 0, 0);

if($today > $lastDate) {
if ($today > $lastDate) {
$module->settings->contentContainer($originator)->set('conversationCountTime', time());
$module->settings->contentContainer($originator)->set('conversationCount', 0);
return 0;
Expand Down
14 changes: 7 additions & 7 deletions models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ public function getOriginator()
*/
public function attributeLabels()
{
return array(
return [
'id' => 'ID',
'title' => Yii::t('MailModule.base', 'Title'),
'created_at' => Yii::t('MailModule.base', 'Created At'),
'created_by' => Yii::t('MailModule.base', 'Created By'),
'updated_at' => Yii::t('MailModule.base', 'Updated At'),
'updated_by' => Yii::t('MailModule.base', 'Updated By'),
);
];
}

/**
Expand Down Expand Up @@ -240,7 +240,7 @@ public function getLastActiveParticipant(bool $includeMe = false): User
public function deleteEntry($entry)
{
if ($entry->message->id == $this->id) {
if($this->getEntries()->count() > 1) {
if ($this->getEntries()->count() > 1) {
$entry->delete();
} else {
$this->delete();
Expand Down Expand Up @@ -318,10 +318,10 @@ public function leave($userId = null)
public function seen($userId)
{
// Update User Message Entry
$userMessage = UserMessage::findOne(array(
$userMessage = UserMessage::findOne([
'user_id' => $userId,
'message_id' => $this->id,
));
]);
if ($userMessage !== null) {
$userMessage->last_viewed = date('Y-m-d G:i:s');
$userMessage->save();
Expand All @@ -333,11 +333,11 @@ public function seen($userId)
*/
public function delete()
{
foreach (MessageEntry::findAll(array('message_id' => $this->id)) as $messageEntry) {
foreach (MessageEntry::findAll(['message_id' => $this->id]) as $messageEntry) {
$messageEntry->delete();
}

foreach (UserMessage::findAll(array('message_id' => $this->id)) as $userMessage) {
foreach (UserMessage::findAll(['message_id' => $this->id]) as $userMessage) {
$userMessage->delete();
}

Expand Down
8 changes: 4 additions & 4 deletions models/MessageTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function rules()

public static function search($userId, $keyword)
{
if(empty($userId)) {
if (empty($userId)) {
return [];
}

Expand All @@ -63,7 +63,7 @@ public static function attach($userId, Message $message, $tags = [])

$userMessage = $message->getUserMessage();

if(!$userMessage) {
if (!$userMessage) {
throw new NotFoundHttpException();
}

Expand All @@ -77,7 +77,7 @@ public static function attach($userId, Message $message, $tags = [])
$tags = is_array($tags) ? $tags : [$tags];

foreach ($tags as $tag) {
if(is_string($tag) && strpos($tag, '_add:') === 0) {
if (is_string($tag) && strpos($tag, '_add:') === 0) {
$newTag = new static([
'name' => substr($tag, strlen('_add:')),
'user_id' => $userId,
Expand Down Expand Up @@ -108,7 +108,7 @@ private static function deleteTagRelations($userId, UserMessage $message)

public function afterDelete()
{
foreach(UserMessageTag::find()->where(['tag_id' => $this->id])->all() as $messageTag) {
foreach (UserMessageTag::find()->where(['tag_id' => $this->id])->all() as $messageTag) {
$messageTag->delete();
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/UserMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function getNewMessageCount($userId = null)
$userId = Yii::$app->user->id;
}

if($userId instanceof User) {
if ($userId instanceof User) {
$userId = $userId->id;
}

Expand Down
2 changes: 1 addition & 1 deletion models/forms/ConversationTagsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ConversationTagsForm extends Model
public function init()
{
parent::init();
if(empty($this->tags)) {
if (empty($this->tags)) {
$this->tags = MessageTag::findByMessage(Yii::$app->user->id, $this->message)->all();
}
}
Expand Down
14 changes: 7 additions & 7 deletions models/forms/InboxFilterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function init()
*/
public function apply()
{
if(!empty($this->term)) {
if (!empty($this->term)) {
$messageEntryContentSubQuery = MessageEntry::find()->where('message_entry.message_id = message.id')
->andWhere($this->createTermLikeCondition('message_entry.content'));

Expand All @@ -102,7 +102,7 @@ public function apply()
]));
}

if(!empty($this->participants)) {
if (!empty($this->participants)) {
foreach ($this->participants as $userGuid) {
$participantsExistsSubQuery = UserMessage::find()->joinWith('user')->where('user_message.message_id = message.id')
->andWhere(['user.guid' => $userGuid]);
Expand All @@ -111,7 +111,7 @@ public function apply()

}

if(!empty($this->tags)) {
if (!empty($this->tags)) {
foreach ($this->tags as $tag) {
$participantsExistsSubQuery = UserMessageTag::find()
->where('user_message.message_id = user_message_tag.message_id')
Expand All @@ -121,16 +121,16 @@ public function apply()
}
}

if(!empty($this->from)) {
if (!empty($this->from)) {
$message = Message::findOne(['id' => $this->from]);
if(!$message) {
if (!$message) {
throw new InvalidCallException();
}
$this->query->andWhere(['<=', 'message.updated_at', $message->updated_at]);
$this->query->andWhere(['<>', 'message.id', $message->id]);
}

if(!empty($this->ids)) {
if (!empty($this->ids)) {
$this->query->andWhere(['IN', 'user_message.message_id', $this->ids]);
}
}
Expand All @@ -155,7 +155,7 @@ public function getPage()

public function wasLastPage()
{
if($this->wasLastPage === null) {
if ($this->wasLastPage === null) {
throw new InvalidCallException();
}

Expand Down
6 changes: 3 additions & 3 deletions models/forms/InviteParticipantForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function checkRecipient($attribute, $params)
$name = Html::encode($user->getDisplayName());
if (Yii::$app->user->identity->is($user)) {
$this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "You cannot send a email to yourself!"));
} elseif($this->message->isParticipant($user)) {
} elseif ($this->message->isParticipant($user)) {
$this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "User {name} is already participating!", ['name' => $name]));
} elseif(!$user->can(SendMail::class) && !Yii::$app->user->isAdmin()) {
} elseif (!$user->can(SendMail::class) && !Yii::$app->user->isAdmin()) {
$this->addError($attribute, Yii::t('MailModule.forms_InviteRecipientForm', "You are not allowed to send user {name} is already!", ['name' => $name]));
} else {
$this->recipientUsers[] = $user;
Expand All @@ -95,7 +95,7 @@ public function getUrl()

public function save()
{
if(!$this->validate()) {
if (!$this->validate()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/codeception/unit/InboxFilterFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private function createMessage($title, $message, $users = null, $tags = [])
{
$this->becomeUser('User1');

if(!$users) {
if (!$users) {
$user2 = User::findOne(['id' => 3]);
$users = [$user2->guid];
}
Expand Down
2 changes: 1 addition & 1 deletion widgets/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function run()
*/
private function getEntries()
{
if($this->entries) {
if ($this->entries) {
return $this->entries;
}

Expand Down
Loading

0 comments on commit 529eabf

Please sign in to comment.