ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 12746


Ignore:
Timestamp:
Aug 24, 2009, 8:04:57 PM (10 years ago)
Author:
fukamachi
Message:

db converter - added birthday option to profile table because it recorded at c_member (not c_profile)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/branches/fukamachi/db-convert-from-2.x/lib/task/openpneUpgradeFrom2Task.class.php

    r12745 r12746  
    1919  private $mapCategoryIds    = array();
    2020  private $mapCommunityAdmin = array();
     21  private $birthdayProfileId = 0;
    2122
    2223  protected function configure()
     
    469470      $profileTranslation->save();
    470471    }
     472
     473    $profileBirthday = new TempProfile();
     474    $profileBirthday->setName('birthday');
     475    $profileBirthday->setIsRequired(true);
     476    $profileBirthday->setIsEditPublicFlag(false);
     477    $profileBirthday->setDefaultPublicFlag(true);
     478    $profileBirthday->setFormType('date');
     479    $profileBirthday->setValueType('string');
     480    $profileBirthday->setIsDispRegist(true);
     481    $profileBirthday->setIsDispConfig(true);
     482    $profileBirthday->setIsDispSearch(true);
     483    $profileBirthday->setValueMin('-100years');
     484    $profileBirthday->setValueMax('now');
     485    $profileBirthday->setSortOrder('1');
     486    $profileBirthday->setCreatedAt($this->date);
     487    $profileBirthday->setUpdatedAt($this->date);
     488
     489    $profileBirthday->save();
     490
     491    $profileBirthdayTranslation = Doctrine::getTable('Profile')->createQuery('p')
     492      ->leftJoin('p.Translation t WITH t.lang = "ja_JP"')
     493      ->orderBy('id desc')
     494      ->fetchOne();
     495
     496    $this->birthdayProfileId = $profileBirthdayTranslation->getId();
     497
     498    $profileBirthdayTranslation->setCaption('誕生日');
     499    $profileBirthdayTranslation->setLang('ja_JP');
     500
     501    $profileBirthdayTranslation->save();
    471502  }
    472503
     
    481512    foreach ($cProfileOptions as $cProfileOption)
    482513    {
    483       $profileOption = new TempProfileOption();
    484       $profileOption->setId($cProfileOption->getCProfileOptionId());
    485       $profileOption->setProfileId($cProfileOption->getCProfileId());
    486       $profileOption->setSortOrder($cProfileOption->getSortOrder());
    487       $profileOption->setCreatedAt($this->date);
    488       $profileOption->setUpdatedAt($this->date);
    489 
    490       $profileOption->save();
    491 
     514      $this->_createProfileOption(array(
     515        'id'         => $cProfileOption->getCProfileOptionId(),
     516        'profile_id' => $cProfileOption->getCProfileId(),
     517        'sort_order' => $cProfileOption->getSortOrder(),
     518        'value'      => $cProfileOption->getCProfileOptionId(),
     519      ));
     520    }
     521
     522    $this->_createProfileOption(array(
     523      'profile_id' => $this->birthdayProfileId,
     524      'sort_order' => 0,
     525    ));
     526  }
     527
     528  protected function _createProfileOption($param = array())
     529  {
     530    $profileOption = new TempProfileOption();
     531    if ($param['id'])
     532    {
     533      $profileOption->setId($param['id']);
     534    }
     535    $profileOption->setProfileId($param['profile_id']);
     536    $profileOption->setSortOrder($param['sort_order']);
     537    $profileOption->setCreatedAt($this->date);
     538    $profileOption->setUpdatedAt($this->date);
     539
     540    $profileOption->save();
     541
     542    if ($param['value'])
     543    {
    492544      $profileOptionTranslation = Doctrine::getTable('ProfileOption')->createQuery('p')
    493545        ->leftJoin('p.Translation t WITH t.lang = "ja_JP"')
    494         ->where('p.id = ? ', $cProfileOption->getCProfileOptionId())
     546        ->where('p.id = ?', $param['id'])
    495547        ->fetchOne();
    496548
    497       $profileOptionTranslation->setValue($cProfileOption->getValue());
     549      $profileOptionTranslation->setValue($param['value']);
    498550      $profileOptionTranslation->setLang('ja_JP');
    499551
Note: See TracChangeset for help on using the changeset viewer.