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

Changeset 9304


Ignore:
Timestamp:
Nov 21, 2008, 2:39:08 AM (11 years ago)
Author:
shingo
Message:

#2292:checkboxに対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/stable-2.12.x/webapp/lib/db/member.php

    r9110 r9304  
    9292    }
    9393
    94     $sql = 'SELECT cp.name, cp.caption, cp.form_type, cm.value, cm.public_flag' .
    95         ' FROM c_member_profile as cm, c_profile as cp' .
    96         ' WHERE cm.c_member_id = ?'.
    97             " AND cm.public_flag IN ($flags)" .
    98             ' AND cm.c_profile_id = cp.c_profile_id' .
    99         ' ORDER BY cp.sort_order, cp.c_profile_id, cm.c_member_profile_id';
     94    $sql = "SELECT cp.name, cp.caption, cp.form_type, cm.c_profile_option_id, cm.value, cm.public_flag"
     95         . " FROM c_member_profile as cm, c_profile as cp"
     96         . " WHERE cm.c_member_id = ?"
     97         . " AND cm.public_flag IN ($flags)"
     98         . " AND cm.c_profile_id = cp.c_profile_id"
     99         . " ORDER BY cp.sort_order, cp.c_profile_id, cm.c_member_profile_id";
    100100    $profile = db_get_all($sql, array(intval($c_member_id)));
    101 
    102101    $member_profile = array();
    103102    foreach ($profile as $value) {
    104103        $member_profile[$value['name']]['form_type'] = $value['form_type'];
    105104        if ($value['form_type'] == 'checkbox') {
    106             $member_profile[$value['name']]['value'][] = $value['value'];
     105            if ($value['c_profile_option_id'] == 0) {
     106                $member_profile[$value['name']]['value'] = '';
     107            } else {
     108                $member_profile[$value['name']]['value'][] = $value['value'];
     109            }
    107110        } else {
    108111            $member_profile[$value['name']]['value'] = $value['value'];
     
    16331636    //function cache削除
    16341637    cache_drop_c_member_profile($c_member_id);
    1635 
    16361638    foreach ($c_member_profile_list as $item) {
    16371639        $sql = 'DELETE FROM c_member_profile' .
     
    16391641        $params = array(intval($c_member_id), intval($item['c_profile_id']));
    16401642        db_query($sql, $params);
    1641 
    1642         if (is_null($item['value'])) {
    1643             $item['value'] = "";
    1644         }
    1645         if (is_array($item['value'])) {
     1643        if (is_array($item['value']) && !empty($item['value'])) {
    16461644            foreach ($item['value'] as $key => $value) {
    16471645                db_member_insert_c_member_profile($c_member_id, $item['c_profile_id'], $key, $value, $item['public_flag']);
    16481646            }
    16491647        } else {
     1648            if (empty($item['value'])) {
     1649                $item['value'] = "";
     1650            }
    16501651            db_member_insert_c_member_profile($c_member_id, $item['c_profile_id'], $item['c_profile_option_id'], $item['value'], $item['public_flag']);
    16511652        }
Note: See TracChangeset for help on using the changeset viewer.