Changeset 521

Show
Ignore:
Timestamp:
08/30/06 10:58:42 (2 years ago)
Author:
ben
Message:

Profile fields can now be set to only display for a certain kind of use (eg person, community).

Files:

Legend:

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

    r458 r521  
    7979 
    8080        global $page_owner; 
    81  
    82         global $data
     81        global $data; 
     82        global $CFG
    8383 
    8484        $run_result = ''; 
     
    155155                                                Short / unique internal name, 
    156156                                                Type of field, 
    157                                                 User instructions for entering data 
     157                                                User instructions for entering data, 
     158                                                Optional: type of user that can see this field 
     159                                                    (e.g. "person", "community" etc) 
    158160                                            ) 
    159161        e.g. 
     
    181183        */ 
    182184     
    183         $data['profile:details'][] = array(gettext("Who am I?"),"biography","longtext",gettext("A short introduction for you.")); 
     185        $data['profile:details'][] = array(gettext("Who am I?"),"biography","longtext",gettext("A short introduction for you."),"person"); 
     186        $data['profile:details'][] = array(gettext("Introduction"),"biography","longtext",gettext("A short introduction to this community."),"community"); 
    184187        $data['foaf:profile'][] = array("biography","bio:olb","collated","enclosed"); 
    185188         
     
    260263    function editfield_display ($field) { 
    261264 
     265        global $page_owner; 
     266        $usertype = user_type($page_owner); 
     267         
    262268        // copy array element with default to '' 
    263269        $flabel = !empty($field[0]) ? $field[0] : ''; 
     
    265271        $ftype  = !empty($field[2]) ? $field[2] : ''; 
    266272        $fblurb = !empty($field[3]) ? $field[3] : ''; 
     273        $fusertype = !empty($field[4]) ? $field[4] : ''; 
     274         
     275        if (!empty($fusertype) && $fusertype != $usertype) { 
     276            return ''; 
     277        } 
    267278 
    268279        global $page_owner; 
     
    629640 
    630641        global $data; 
     642        global $page_owner; 
     643         
    631644        $run_result = ''; 
     645        $usertype = user_type($page_owner); 
    632646 
    633647        // Cycle through all defined profile detail fields and display them 
     
    637651            if ($allvalues = get_records('profile_data','owner',$this->id)) { 
    638652                foreach($data['profile:details'] as $field) { 
     653                    if (empty($field[4]) || $usertype == $field[4]) { 
    639654                    // $field is an array, with the name 
    640655                    // of the field in $field[0] 
    641                     $run_result .= $this->field_display($field,$allvalues); 
     656                        $run_result .= $this->field_display($field,$allvalues); 
     657                    } 
    642658                } 
    643659            }