Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Thibaut Lefort
co2
Commits
deaef8e1
Commit
deaef8e1
authored
Nov 26, 2018
by
Raph El
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hotfix CP sur Import
parent
9dbd7375
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
controllers/DatamigrationController.php
controllers/DatamigrationController.php
+45
-0
No files found.
controllers/DatamigrationController.php
View file @
deaef8e1
...
...
@@ -5275,6 +5275,51 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
echo
"Number of user with preferences modified : "
.
$nbUser
;
}
}
public
function
actionHotfixAddressCPMissing
()
{
if
(
Role
::
isSuperAdmin
(
Role
::
getRolesUserId
(
Yii
::
app
()
->
session
[
"userId"
])
)){
$nbUser
=
0
;
$types
=
array
(
Organization
::
COLLECTION
,
Project
::
COLLECTION
,
Event
::
COLLECTION
);
foreach
(
$types
as
$keyT
=>
$valT
)
{
$elts
=
PHDB
::
find
(
$valT
,
array
(
"modifiedByBatch.HotfixAddressCPMissing"
=>
array
(
'$exists'
=>
0
),
"address.addressCountry"
=>
"FR"
,
"address.postalCode"
=>
array
(
'$exists'
=>
0
)));
//Rest::json($elts); exit;
foreach
(
$elts
as
$keyE
=>
$elt
)
{
$elt
[
"modifiedByBatch"
][]
=
array
(
"HotfixAddressCPMissing"
=>
new
MongoDate
(
time
()));
$city
=
City
::
getById
(
$elt
[
"address"
][
"localityId"
],
array
(
"postalCodes"
));
$cp
=
"NUUUUUUUULLLLLLL"
;
foreach
(
$city
[
"postalCodes"
]
as
$keyPC
=>
$valPC
)
{
$cp
=
$valPC
[
"postalCode"
];
break
;
}
$elt
[
"address"
][
"postalCode"
]
=
$cp
;
echo
"<br/> "
.
$keyE
.
" : "
.
$valT
.
" : "
.
$elt
[
"name"
]
.
" :: "
.
$cp
;
$res
=
PHDB
::
update
(
$valT
,
array
(
"_id"
=>
new
MongoId
(
$keyE
)),
array
(
'$set'
=>
array
(
"address"
=>
$elt
[
"address"
],
"modifiedByBatch"
=>
$elt
[
"modifiedByBatch"
])
)
);
if
(
$res
[
"ok"
]
==
1
){
$nbUser
++
;
}
else
{
echo
"<br/> Error with user id : "
.
$key
;
}
}
}
echo
"Number of user with preferences modified : "
.
$nbUser
;
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment