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

Changeset 11300


Ignore:
Timestamp:
Apr 14, 2009, 6:16:54 PM (11 years ago)
Author:
ebihara
Message:

#3765:fixed some models to work MemberProfile? correctly

Location:
OpenPNE3/branches/goto_doctrine
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/branches/goto_doctrine/apps/pc_backend/modules/profile/actions/actions.class.php

    r11258 r11300  
    3131    foreach ($this->profiles as $value) {
    3232      $this->option_form[$value->getId()] = array();
    33       foreach ($value->getProfileOptions() as $option) {
     33      foreach ($value->getProfileOption() as $option) {
    3434        $this->option_form[$value->getId()][$option->getId()] = new ProfileOptionForm(Doctrine::getTable('ProfileOption')->find($option->getId()));
    3535      }
     
    5454      if ($this->form->getObject()->isNew())
    5555      {
    56         $parameter['sort_order'] = ProfilePeer::getMaxSortOrder();
     56        $parameter['sort_order'] = Doctrine::getTable('Profile')->getMaxSortOrder();
    5757      }
    5858      $this->form->bind($parameter);
     
    7878      if ($this->form->getObject()->isNew())
    7979      {
    80         $parameter['sort_order'] = ProfileOptionPeer::getMaxSortOrder();
     80        $parameter['sort_order'] = Doctrine::getTable('ProfileOption')->getMaxSortOrder();
    8181      }
    8282      $this->form->bind($parameter);
  • OpenPNE3/branches/goto_doctrine/apps/pc_backend/modules/profile/templates/listSuccess.php

    r11001 r11300  
    3030<td><?php echo ($value->getIsRequired() ? '○' : '×') ?></t
    3131<td><?php echo ($value->getIsEditPublicFlag() ? '○' :'×') ?></>
    32 <td><?php echo (ProfilePeer::getPublicFlag($value->getDefaultPublicFlag())) ?> </td>
     32<td><?php echo (Doctrine::getTable('Profile')->getPublicFlag($value->getDefaultPublicFlag())) ?> </td>
    3333<td><?php echo ($value->getIsUnique() ? '×' :'○') ?></td>
    3434<td><?php echo $value->getFormType() ?></td>
  • OpenPNE3/branches/goto_doctrine/data/fixtures/002_import_first_member.yml

    r11270 r11300  
    1818    Profile: profile_birthday
    1919    children:
     20      first_member_profile_birthday_day:
     21        value: "23"
     22        Member: first_member
     23        Profile: profile_birthday
     24        ProfileOption: profile_option_birthday_day
     25      first_member_profile_birthday_month:
     26        value: "4"
     27        Member: first_member
     28        Profile: profile_birthday
     29        ProfileOption: profile_option_birthday_month
    2030      first_member_profile_birthday_year:
    2131        value: "1988"
     
    2333        Profile: profile_birthday
    2434        ProfileOption: profile_option_birthday_year
    25       first_member_profile_birthday_month:
    26         value: "4"
    27         Member: first_member
    28         Profile: profile_birthday
    29         ProfileOption: profile_option_birthday_month
    30       first_member_profile_birthday_day:
    31         value: "23"
    32         Member: first_member
    33         Profile: profile_birthday
    34         ProfileOption: profile_option_birthday_day
    3535
    3636  first_member_profile_self_intro:
  • OpenPNE3/branches/goto_doctrine/lib/form/doctrine/MemberProfileForm.class.php

    r11270 r11300  
    5151
    5252      $memberProfile = Doctrine::getTable('MemberProfile')->retrieveByMemberIdAndProfileId($memberId, $profile->getId());
    53       if ($memberProfile)
    54       {
    55         $memberProfile->clearChildren();
    56       }
    57       else
     53      if (!$memberProfile)
    5854      {
    5955        $memberProfile = new MemberProfile();
    6056        $memberProfile->setMemberId($memberId);
    6157        $memberProfile->setProfileId($profile->getId());
    62       }
    63 
    64       if (!$profile->isMultipleSelect())
    65       {
    66         $memberProfile->setValue($value['value']);
    6758      }
    6859
     
    7263        $memberProfile->setPublicFlag($value['public_flag']);
    7364      }
    74       $memberProfile->refreshRelated('Profile');
    7565      $memberProfile->save();
    76 
    77       $treeObject = Doctrine::getTable('MemberProfile')->getTree();
    78 //      $treeObject->createRoot($memberProfile);
    7966
    8067      if ($profile->isMultipleSelect())
     
    9077            $ids[] = $option->getId();
    9178          }
     79          $memberProfile->setValue($value['value']);
    9280        }
    9381        else
     
    9684        }
    9785        Doctrine::getTable('MemberProfile')->createChild($memberProfile, $memberId, $profile->getId(), $ids, $_values);
     86      }
     87      else
     88      {
     89        $memberProfile->setValue($value['value']);
    9890      }
    9991
  • OpenPNE3/branches/goto_doctrine/lib/form/doctrine/ProfileForm.class.php

    r11260 r11300  
    117117        ->update('MemberProfile')
    118118        ->set('public_flag', $values['default_public_flag'])
    119         ->where('lft_key = 1')
     119        ->where('lft = 1')
    120120        ->andWhere('profile_id = ?', $profile->getId())
    121121        ->execute();
  • OpenPNE3/branches/goto_doctrine/lib/model/doctrine/MemberProfile.class.php

    r11270 r11300  
    3333  public function construct()
    3434  {
    35     $this->mapValue('name', $this->Profile->getName());
    36     Profile::initializeI18n();
    37     $this->mapValue('caption', $this->Profile->Translation['ja_JP']->caption);
     35    if (!$this->isNew())
     36    {
     37      $this->mapValue('name', $this->Profile->getName());
     38      Profile::initializeI18n();
     39      $this->mapValue('caption', $this->Profile->Translation['ja_JP']->caption);
     40    }
    3841
    3942    return parent::construct();
     
    9396  }
    9497
    95   public function clearChildren()
    96   {
    97     Doctrine::getTable('MemberProfilePeer')->createQuery()
    98       ->where('tree_key = ?', $this->getTreeKey())
    99       ->delete();
    100   }
    101 
    10298  public function getFormType()
    10399  {
     
    105101  }
    106102
    107   public function preSave($event)
     103  public function setValue($value)
    108104  {
    109105    if ($this->getProfile()->isSingleSelect())
    110106    {
    111       $this->setProfileOptionId((int)$this->getValue());
    112       $this->setValue(null);
     107      $this->setProfileOptionId($value);
     108    }
     109    else
     110    {
     111      $this->_set('value', $value);
     112    }
     113  }
     114
     115  public function postSave($event)
     116  {
     117    if ($this->getTreeKey())
     118    {
     119      $parent = $this->getTable()->find($this->getTreeKey());
     120      $this->getNode()->insertAsLastChildOf($parent);
     121    }
     122    else
     123    {
     124      $tree = $this->getTable()->getTree();
     125      $tree->createRoot($this);
    113126    }
    114127  }
     
    137150    }
    138151  }
     152
     153  public function clearChildren()
     154  {
     155    if ($this->getTreeKey() && $this->getNode()->hasChildren())
     156    {
     157      $children = $this->getNode()->getChildren();
     158      $children->delete();
     159    }
     160  }
    139161}
  • OpenPNE3/branches/goto_doctrine/lib/model/doctrine/MemberProfileTable.class.php

    r11270 r11300  
    5454  public function retrieveByMemberIdAndProfileId($memberId, $profileId)
    5555  {
    56     return null;
    57 
    58     $c = new Criteria();
    59     $c->add(self::MEMBER_ID, $memberId);
    60     $c->add(self::PROFILE_ID, $profileId);
    61 
    62     $result = self::doSelectOne($c);
    63     return $result;
     56    return $this->createQuery()
     57      ->where('member_id = ?', $memberId)
     58      ->andWhere('profile_id = ?', $profileId)
     59      ->fetchOne();
    6460  }
    6561
    6662  public function retrieveByMemberIdAndProfileName($memberId, $profileName)
    6763  {
    68     return null;
    69 
    70     $c = new Criteria();
    71     $c->add(ProfilePeer::NAME, $profileName);
    72     $c->add(MemberProfilePeer::MEMBER_ID, $memberId);
    73     $c->addJoin(MemberProfilePeer::PROFILE_ID, ProfilePeer::ID);
    74     return MemberProfilePeer::doSelectOne($c);
     64    return $this->createQuery()
     65      ->where('member_id = ?', $memberId)
     66      ->andWhere('p.name = ?', $profileName)
     67      ->leftJoin('Profile p')
     68      ->fetchOne();
    7569  }
    7670
     
    166160  public function createChild(Doctrine_Record $parent, $memberId, $profileId, $optionIds, $values = array())
    167161  {
     162    $parent->clearChildren();
     163
    168164    foreach ($optionIds as $i => $optionId)
    169165    {
     
    176172        $childProfile->setValue($values[$i]);
    177173      }
    178       $childProfile->clearRelated();
    179174      $childProfile->getNode()->insertAsLastChildOf($parent);
    180 
    181175      $childProfile->save();
    182176    }
  • OpenPNE3/branches/goto_doctrine/lib/model/doctrine/ProfileOptionTable.class.php

    r11249 r11300  
    2727    if ($result)
    2828    {
    29       return (int)$result->sortOrder;
     29      return (int)$result->getSortOrder();
    3030    }
    3131
  • OpenPNE3/branches/goto_doctrine/lib/model/doctrine/ProfileTable.class.php

    r11249 r11300  
    7575    if ($result)
    7676    {
    77       return (int)$result->sortOrder;
     77      return (int)$result->getSortOrder();
    7878    }
    7979
Note: See TracChangeset for help on using the changeset viewer.