~fabiocbalbuquerque/sahana-agasti/web-services

« back to all changes in this revision

Viewing changes to apps/frontend/lib/util/agStaffImportNormalization.class.php

  • Committer: Shirley Chan
  • Date: 2011-07-28 19:57:01 UTC
  • mto: (1.26.1 push-trunk)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: shirley.chan@mail.cuny.edu-20110728195701-k3itriwln21bbssd
Made the staff import's set address method a cleaner code, easier to read.

Show diffs side-by-side

added added

removed removed

Lines of Context:
700
700
      if (isset($rowData['primaryKeys']['entity_id'])) {
701
701
        // this just makes it easier to use
702
702
        $entityId = $rowData['primaryKeys']['entity_id'];
 
703
        $rawData = $rowData['_rawData'];
703
704
 
704
705
        // we start with an empty array, devoid of types in case the entity has no types/values
705
 
        $entityAddresses[$entityId] = array();
706
706
        list($homeAddr, $workAddr) = array(array(), array());
707
 
        foreach ($rowData['_rawData'] AS $element => $value) {
708
 
          if (preg_match('/^home_address/', $element)) {
709
 
            $formElem = str_replace('home_address_', '', $element);
710
 
            $elemId = $importAddressElements[$formElem];
711
 
            $homeAddr[$importAddressElements[str_replace('home_address_', '', $element)]] = $value;
712
 
          } else if (preg_match('/^work_address/', $element)) {
713
 
            $workAddr[$importAddressElements[str_replace('work_address_', '', $element)]] = $value;
 
707
        foreach ($importAddressElements AS $element => $id) {
 
708
          if (isset($rawData['home_address_' . $element])) {
 
709
            $homeAddr[$id] = $rawData['home_address_' . $element];
 
710
          }
 
711
 
 
712
          if (isset($rawData['work_address_' . $element])) {
 
713
            $workAddr[$id] = $rawData['work_address_' . $element];
714
714
          }
715
715
        }
716
716
 
717
 
        if (count($homeAddr) > 0 && isset($rowData['_rawData']['home_latitude']) &&
718
 
            isset($rowData['_rawData']['home_longitude'])) {
 
717
        if (count($homeAddr) > 0 && isset($rawData['home_latitude']) &&
 
718
                isset($rawData['home_longitude'])) {
719
719
          $homeAddrComp = array($homeAddr, $addressStandardId);
720
 
          $homeAddrComp[] = array(array(array($rowData['_rawData']['home_latitude'],
721
 
                $rowData['_rawData']['home_longitude'])),
 
720
          $homeAddrComp[] = array(array(array($rawData['home_latitude'],
 
721
                $rawData['home_longitude'])),
722
722
            $geoMatchScoreId);
723
723
          $entityAddresses[$entityId][] = array($importAddressTypes['home_address'], $homeAddrComp);
724
 
        } else {
725
724
        }
726
725
 
727
 
        if (count($workAddr) > 0 && isset($rowData['_rawData']['work_latitude']) &&
728
 
            isset($rowData['_rawData']['work_longitude'])) {
 
726
        if (count($workAddr) > 0 && isset($rawData['work_latitude']) &&
 
727
            isset($rawData['work_longitude'])) {
729
728
          $workAddrComp = array($workAddr, $addressStandardId);
730
 
          $workAddrComp[] = array(array(array($rowData['_rawData']['work_latitude'],
731
 
                $rowData['_rawData']['work_longitude'])),
 
729
          $workAddrComp[] = array(array(array($rawData['work_latitude'],
 
730
              $rawData['work_longitude'])),
732
731
            $geoMatchScoreId);
733
732
          $entityAddresses[$entityId][] = array($importAddressTypes['work_address'], $workAddrComp);
734
733
        } else {