Skip to content
Snippets Groups Projects
Verified Commit 95f3b585 authored by Damien's avatar Damien
Browse files

FEAT #13678 TIME 1:00 Migrate notifications properties

parent 01faf3b8
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
php ./migrateModulesConfig.php
php ./migrateNotificationsProperties.php
<?php
require '../../vendor/autoload.php';
chdir('../..');
$customs = scandir('custom');
$migrated = 0;
foreach ($customs as $custom) {
if ($custom == 'custom.xml' || $custom == '.' || $custom == '..') {
continue;
}
\SrcCore\models\DatabasePDO::reset();
new \SrcCore\models\DatabasePDO(['customId' => $custom]);
$notifications = \Notification\models\NotificationModel::get([
'select' => ['diffusion_properties', 'notification_sid'],
'where' => ['diffusion_type = ?'],
'data' => ['user']
]);
foreach ($notifications as $notification) {
$users = explode(',', $notification['diffusion_properties']);
if (!empty($users)) {
$users = \User\models\UserModel::get(['select' => ['id'], 'where' => ['user_id in (?)'], 'data' => [$users]]);
$users = array_column($users, 'id');
if (!empty($users)) {
$users = implode(',', $users);
\Notification\models\NotificationModel::update(['notification_sid' => $notification['notification_sid'], 'diffusion_properties' => $users]);
}
}
}
$migrated++;
}
printf("migrateNotificationsProperties : " . $migrated . " custom(s) trouvé(s) et migré(s).\n");
......@@ -243,10 +243,14 @@ abstract class NotificationModelAbstract
public static function getDiffusionTypesUsers()
{
$users = DatabaseModel::select([
'select' => ["user_id as id, concat(firstname,' ',lastname) as label"],
'select' => ["id, concat(firstname,' ',lastname) as label"],
'table' => ['users'],
]);
foreach ($users as $key => $user) {
$users[$key]['id'] = (string)$user['id'];
}
return $users;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment