Changeset 866

Show
Ignore:
Timestamp:
01/25/07 18:10:57 (2 years ago)
Author:
ben
Message:

We're changing the format for profile fields (but the old format still works for now, while we change things round). Fields can be invisible to outside users and mandatory if required. Coming: edit profile categories.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/profile/profile.class.php

    r817 r866  
    159159         
    160160        // copy array element with default to '' 
    161         $flabel = !empty($field[0]) ? $field[0] : ''; 
    162         $fname  = !empty($field[1]) ? $field[1] : ''; 
    163         $ftype  = !empty($field[2]) ? $field[2] : ''; 
    164         $fblurb = !empty($field[3]) ? $field[3] : ''; 
    165         $fusertype = !empty($field[4]) ? $field[4] : ''; 
     161         
     162        // If we're dealing with the old-style profile fields 
     163        if (is_array($field)) { 
     164            $flabel = !empty($field[0]) ? $field[0] : ''; 
     165            $fname  = !empty($field[1]) ? $field[1] : ''; 
     166            $ftype  = !empty($field[2]) ? $field[2] : ''; 
     167            $fblurb = !empty($field[3]) ? $field[3] : ''; 
     168            $fusertype = !empty($field[4]) ? $field[4] : ''; 
     169        // Otherwise map things the new way! 
     170        } else { 
     171            $flabel = $field->name; 
     172            $fname = $field->internal_name; 
     173            $ftype = $field->field_type; 
     174            $fblurb = $field->description; 
     175            $fusertype = $field->user_type; 
     176            $finvisible = $field->invisible; 
     177            $frequired = $field->required; 
     178        } 
    166179         
    167180        if (!empty($fusertype) && $fusertype != $usertype) { 
     
    223236 
    224237        $run_result = ''; 
     238         
     239        // If we're dealing with the old-style profile fields 
     240        if (is_array($field)) { 
     241            $flabel = !empty($field[0]) ? $field[0] : ''; 
     242            $fname  = !empty($field[1]) ? $field[1] : ''; 
     243            $ftype  = !empty($field[2]) ? $field[2] : ''; 
     244            $fblurb = !empty($field[3]) ? $field[3] : ''; 
     245            $fusertype = !empty($field[4]) ? $field[4] : ''; 
     246        // Otherwise map things the new way! 
     247        } else { 
     248            $flabel = $field->name; 
     249            $fname = $field->internal_name; 
     250            $ftype = $field->field_type; 
     251            $fblurb = $field->description; 
     252            $fusertype = $field->user_type; 
     253            $finvisible = $field->invisible; 
     254            $frequired = $field->required; 
     255        } 
    225256 
    226257        if (sizeof($field) >= 2) { 
     
    229260         
    230261            foreach($allvalues as $curvalue) { 
    231                 if ($curvalue->name == stripslashes($field[1])) { 
     262                if ($curvalue->name == stripslashes($fname)) { 
    232263                    $value = $curvalue; 
    233264                    break; // found it, done! 
     
    239270            } 
    240271 
    241             if ((($value->value != "" && $value->value != "blank"))  
     272            if ((($value->value != "" && $value->value != "blank" && !$finvisible))  
    242273                && run("users:access_level_check", $value->access)) { 
    243                 $name = $field[0]
     274                $name = $flabel
    244275                $column1 = display_output_field(array($value->value,$field[2],$field[1],$field[0],$value->ident)); 
    245276                $run_result .=templates_draw(array( 
     
    543574            if ($allvalues = get_records('profile_data','owner',$this->id)) { 
    544575                foreach($data['profile:details'] as $field) { 
    545                     if (empty($field[4]) || $usertype == $field[4]) { 
     576                    if (is_array($field)) { 
     577                        $flabel = !empty($field[0]) ? $field[0] : ''; 
     578                        $fname  = !empty($field[1]) ? $field[1] : ''; 
     579                        $ftype  = !empty($field[2]) ? $field[2] : ''; 
     580                        $fblurb = !empty($field[3]) ? $field[3] : ''; 
     581                        $fusertype = !empty($field[4]) ? $field[4] : ''; 
     582                    // Otherwise map things the new way! 
     583                    } else { 
     584                        $flabel = $field->name; 
     585                        $fname = $field->internal_name; 
     586                        $ftype = $field->field_type; 
     587                        $fblurb = $field->description; 
     588                        $fusertype = $field->user_type; 
     589                        $finvisible = $field->invisible; 
     590                        $frequired = $field->required; 
     591                    } 
     592                    if (empty($fusertype) || $usertype == $fusertype) { 
    546593                    // $field is an array, with the name 
    547594                    // of the field in $field[0] 
  • devel/units/profile/function_actions.php

    r659 r866  
    2929                 
    3030                foreach($data['profile:details'] as $datatype) { 
    31                     if ($datatype[1] == $field && $datatype[2] == "keywords") { 
     31                    if (is_array($datatype)) { 
     32                        $flabel = !empty($datatype[0]) ? $datatype[0] : ''; 
     33                        $fname  = !empty($datatype[1]) ? $datatype[1] : ''; 
     34                        $ftype  = !empty($datatype[2]) ? $datatype[2] : ''; 
     35                        $fblurb = !empty($datatype[3]) ? $datatype[3] : ''; 
     36                        $fusertype = !empty($datatype[4]) ? $datatype[4] : ''; 
     37                    // Otherwise map things the new way! 
     38                    } else { 
     39                        $flabel = $datatype->name; 
     40                        $fname = $datatype->internal_name; 
     41                        $ftype = $datatype->field_type; 
     42                        $fblurb = $datatype->description; 
     43                        $fusertype = $datatype->user_type; 
     44                        $finvisible = $datatype->invisible; 
     45                        $frequired = $datatype->required; 
     46                    } 
     47                    if ($fname == $field && $ftype == "keywords") { 
    3248                        delete_records('tags', 'tagtype', $field, 'owner', $page_owner); 
    3349                        $value = insert_tags_from_string ($value, $field, $insert_id, $access, $page_owner);