Changeset 12763
- Timestamp:
- Aug 26, 2009, 7:57:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/branches/fukamachi/db-convert-from-2.x/lib/task/openpneUpgradeFrom2Task.class.php
r12760 r12763 233 233 ->fetchOne(); 234 234 235 // NOTICE: ignore if the file with same name had saved 235 236 if ($dupNamedFile) 236 237 { 237 238 $dupNamedFile->free(); 239 238 240 return; 239 241 } … … 335 337 336 338 $community->setName($cCommu->getName()); 337 // add index if already created same name community339 // NOTICE: add index if already created same name community 338 340 if ($this->_isDuplicateCommunityName($cCommu->getName())) 339 341 { … … 594 596 } 595 597 598 // NOTICE: ignore if the member image isn't exist 599 if (!($fileId = $this->getFileIdByName($param['image_filename']))) 600 { 601 return; 602 } 603 596 604 $memberImage = new TempMemberImage(); 597 605 $memberImage->setMemberId($param['member_id']); 598 $memberImage->setFileId($ this->getFileIdByName($param['image_filename']));606 $memberImage->setFileId($fileId); 599 607 if ($param['image_filename'] === $param['primary_image']) 600 608 { … … 752 760 protected function convertMemberProfile() 753 761 { 754 $this->connectTo2();755 $cMemberProfiles = Doctrine::getTable('CMemberProfile')->findAll();756 762 $this->connectTo3(); 757 763 $this->clearDbTable('MemberProfile'); 758 764 $treeProfile = Doctrine::getTable('MemberProfile')->getTree(); 759 765 760 foreach ($cMemberProfiles as $cMemberProfile) 761 { 762 $memberProfile = $this->_getMemberProfile(array( 763 'id' => $cMemberProfile->getCMemberProfileId(), 764 'member_id' => $cMemberProfile->getCMemberId(), 765 'profile_id' => $cMemberProfile->getCProfileId(), 766 'profile_option_id' => $cMemberProfile->getCProfileOptionId(), 767 'value' => $cMemberProfile->getValue(), 768 'public_flag' => $cMemberProfile->getPublicFlag(), 769 )); 770 771 $memberProfile->save(); 772 773 $this->connectTo2(); 774 $cMember = Doctrine::getTable('CMember')->find($cMemberProfile->getCMemberId()); 775 $this->connectTo3(); 776 777 $birthdayRoot = new TempMemberProfile(); 778 779 $birthdayYear = $this->_getMemberProfile(array( 780 'member_id' => $cMemberProfile->getCMemberId(), 781 'profile_id' => $this->birthdayProfileId, 782 'value' => $cMember->getBirthYear(), 783 'public_flag' => $cMember->getPublicFlagBirthYear(), 784 )); 785 $birthdayMonth = $this->_getMemberProfile(array( 786 'member_id' => $cMemberProfile->getCMemberId(), 787 'profile_id' => $this->birthdayProfileId, 788 'value' => $cMember->getBirthMonth(), 789 'public_flag' => $cMember->getPublicFlagBirthMonthDay(), 790 )); 791 $birthdayDay = $this->_getMemberProfile(array( 792 'member_id' => $cMemberProfile->getCMemberId(), 793 'profile_id' => $this->birthdayProfileId, 794 'value' => $cMember->getBirthDay(), 795 'public_flag' => $cMember->getPublicFlagBirthMonthDay(), 796 )); 797 798 $birthdayYear->getNode()->insertAsLastChildOf($birthdayRoot); 799 $birthdayMonth->getNode()->insertAsLastChildOf($birthdayRoot); 800 $birthdayDay->getNode()->insertAsLastChildOf($birthdayRoot); 801 $birthdayRoot->save(); 802 803 $cMember->free(); 804 $memberProfile->free(); 805 $birthdayRoot->free(); 766 $offset = 0; 767 while ($cMemberProfiles = $this->getModelsIterator('CMemberProfile', 100, $offset)) 768 { 769 foreach ($cMemberProfiles as $cMemberProfile) 770 { 771 $memberProfile = $this->_getMemberProfile(array( 772 'member_id' => $cMemberProfile->getCMemberId(), 773 'profile_id' => $cMemberProfile->getCProfileId(), 774 'profile_option_id' => $cMemberProfile->getCProfileOptionId(), 775 'value' => $cMemberProfile->getValue(), 776 'public_flag' => $cMemberProfile->getPublicFlag(), 777 )); 778 779 $memberProfile->save(); 780 781 $this->connectTo2(); 782 $cMember = Doctrine::getTable('CMember')->find($cMemberProfile->getCMemberId()); 783 $this->connectTo3(); 784 785 $birthdayRoot = $this->_getMemberProfile(array( 786 'member_id' => $cMemberProfile->getCMemberId(), 787 'profile_id' => $this->birthdayProfileId, 788 )); 789 $birthdayYear = $this->_getMemberProfile(array( 790 'member_id' => $cMemberProfile->getCMemberId(), 791 'profile_id' => $this->birthdayProfileId, 792 'value' => $cMember->getBirthYear(), 793 'public_flag' => $cMember->getPublicFlagBirthYear(), 794 )); 795 $birthdayMonth = $this->_getMemberProfile(array( 796 'member_id' => $cMemberProfile->getCMemberId(), 797 'profile_id' => $this->birthdayProfileId, 798 'value' => $cMember->getBirthMonth(), 799 'public_flag' => $cMember->getPublicFlagBirthMonthDay(), 800 )); 801 $birthdayDay = $this->_getMemberProfile(array( 802 'member_id' => $cMemberProfile->getCMemberId(), 803 'profile_id' => $this->birthdayProfileId, 804 'value' => $cMember->getBirthDay(), 805 'public_flag' => $cMember->getPublicFlagBirthMonthDay(), 806 )); 807 808 $birthdayYear->getNode()->insertAsLastChildOf($birthdayRoot); 809 $birthdayMonth->getNode()->insertAsLastChildOf($birthdayRoot); 810 $birthdayDay->getNode()->insertAsLastChildOf($birthdayRoot); 811 $birthdayRoot->save(); 812 813 $cMemberProfile->free(); 814 $cMember->free(); 815 $memberProfile->free(); 816 $birthdayRoot->free(); 817 } 818 $offset += 100; 806 819 } 807 820 } … … 809 822 protected function _getMemberProfile($param = array()) 810 823 { 824 // NOTICE: ignore if c_member_profile.c_profile_id = 0 825 if (!array_key_exists('profile_id', $param) || !$param['profile_id']) 826 { 827 return; 828 } 829 811 830 $memberProfile = new TempMemberProfile(); 812 if (array_key_exists('id', $param))813 {814 $memberProfile->setId($param['id']);815 }816 831 $memberProfile->setMemberId($param['member_id']); 817 832 $memberProfile->setProfileId($param['profile_id']); 818 if (array_key_exists('profile_option_id', $param) )833 if (array_key_exists('profile_option_id', $param) && $param['profile_option_id']) 819 834 { 820 835 $memberProfile->setProfileOptionId($param['profile_option_id']); 821 836 } 822 $memberProfile->setValue($param['value']); 823 $memberProfile->setPublicFlag($param['public_flag']); 837 if (array_key_exists('value', $param) && $param['value']) 838 { 839 $memberProfile->setValue($param['value']); 840 } 841 if (array_key_exists('public_flag', $param) && $param['public_flag']) 842 { 843 $memberProfile->setPublicFlag($param['public_flag']); 844 } 824 845 $memberProfile->setCreatedAt($this->date); 825 846 $memberProfile->setUpdatedAt($this->date); … … 955 976 if ($file) 956 977 { 957 return $file->getId(); 978 $id = $file->getId(); 979 $file->free(); 980 981 return $id; 958 982 } 959 983 }
Note: See TracChangeset
for help on using the changeset viewer.