diff --git a/application/common/components/ExternalGroupsSync.php b/application/common/components/ExternalGroupsSync.php new file mode 100644 index 00000000..2fc33bc7 --- /dev/null +++ b/application/common/components/ExternalGroupsSync.php @@ -0,0 +1,66 @@ + Env::getArrayFromPrefix('EXTERNAL_GROUPS_SYNC_'), 'googleAnalytics' => [ 'apiSecret' => Env::get('GA_API_SECRET'), 'measurementId' => Env::get('GA_MEASUREMENT_ID'), diff --git a/application/console/controllers/CronController.php b/application/console/controllers/CronController.php index 22f15390..01c4648c 100644 --- a/application/console/controllers/CronController.php +++ b/application/console/controllers/CronController.php @@ -2,6 +2,7 @@ namespace console\controllers; +use common\components\ExternalGroupsSync; use common\helpers\Utils; use common\models\Invite; use common\models\Method; @@ -137,6 +138,16 @@ public function actionExportToSheets() User::exportToSheets(); } + /** + * Sync external groups from Google Sheets + */ + public function actionSyncExternalGroups() + { + ExternalGroupsSync::syncAllSets( + \Yii::$app->params['externalGroupsSyncSets'] ?? [] + ); + } + /** * Run all cron tasks, catching and logging errors to allow remaining tasks to run after an exception */ diff --git a/local.env.dist b/local.env.dist index 6d2604aa..c460df7a 100644 --- a/local.env.dist +++ b/local.env.dist @@ -337,3 +337,11 @@ GOOGLE_delegatedAdmin=admin@example.com # spreadsheet ID GOOGLE_spreadsheetId=putAnActualSheetIDHerejD70xAjqPnOCHlDK3YomH + +# === external groups sync sets === # + +# EXTERNAL_GROUPS_SYNC_set1AppPrefix= +# EXTERNAL_GROUPS_SYNC_set1GoogleSheetId= +# EXTERNAL_GROUPS_SYNC_set2AppPrefix= +# EXTERNAL_GROUPS_SYNC_set2GoogleSheetId= +# ... with as many sets as you want.