Advertisement
Guest User

Untitled

a guest
May 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. /**
  2. * Function for updating existing rapports, adding languange constants and updating pm to rapports
  3. */
  4. public function updateExistingReports()
  5. {
  6. try{
  7.  
  8. $guid = '2345mttsv-k65g-p03u-jlchw34bphphiiuu';
  9. $reports = json_decode($this->getAllReports($guid),true);
  10. $pmReports = array();
  11. $regularReports = array();
  12. $mongoDB = WServices::getDbo($guid, true);
  13. $mongoDB->collection = $mongoDB->getMongoDBCollection('fs.files');
  14. foreach($reports as $rep)
  15. {
  16. if($rep['model']=='pm')
  17. {
  18. $pmReports[]=$rep;
  19. $mongoDB->collection->update(
  20. array( '_id' => new \MongoId($rep['_id']['$id']) ),
  21. array('$set' => array(
  22. "model" => "rapports",
  23. "report_type_en-GB" => "Changelog",
  24. "report_type_sv-SE" => utf8_encode("Ändringslogg")
  25. )
  26. ));
  27. }
  28. else
  29. {
  30. $mongoDB->collection->update(
  31. array( '_id' => new \MongoId($rep['_id']['$id']) ),
  32. array('$set' => array(
  33. "report_type_en-GB" => "Report",
  34. "report_type_sv-SE" => "Rapport"
  35. )
  36. ));
  37. }
  38. }
  39. print_r($pmReports);
  40. }
  41. catch (\Exception $e)
  42. {
  43. return json_encode(array(self::ERROR => json_encode($e->getMessage())));
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement