Commit deaef8e1 authored by Raph El's avatar Raph El

Hotfix CP sur Import

parent 9dbd7375
...@@ -5275,6 +5275,51 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){ ...@@ -5275,6 +5275,51 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
echo "Number of user with preferences modified : ".$nbUser; 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;
}
}
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment