-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better way to keep track of whether a user has a dashboard
fixes #2769
- Loading branch information
1 parent
49ce9c9
commit bfcbe29
Showing
9 changed files
with
77 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace craft\migrations; | ||
|
||
use Craft; | ||
use craft\db\Migration; | ||
use craft\db\Query; | ||
|
||
/** | ||
* m180418_205713_widget_cleanup migration. | ||
*/ | ||
class m180418_205713_widget_cleanup extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp() | ||
{ | ||
$this->addColumn('{{%users}}', 'hasDashboard', $this->boolean()->notNull()->defaultValue(false)->after('lockoutDate')); | ||
|
||
$usersWithWidgets = (new Query()) | ||
->select(['userId']) | ||
->distinct() | ||
->from(['{{%widgets}}']) | ||
->column(); | ||
|
||
$this->update('{{%users}}', [ | ||
'hasDashboard' => true, | ||
], [ | ||
'id' => $usersWithWidgets, | ||
], [], false); | ||
|
||
$this->delete('{{%widgets}}', ['enabled' => false]); | ||
$this->dropColumn('{{%widgets}}', 'enabled'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m180418_205713_widget_cleanup cannot be reverted.\n"; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
* @property int $sortOrder Sort order | ||
* @property int $colspan Colspan | ||
* @property array $settings Settings | ||
* @property bool $enabled Enabled | ||
* @property User $user User | ||
* @author Pixel & Tonic, Inc. <[email protected]> | ||
* @since 3.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters