Changeset 1046

Show
Ignore:
Timestamp:
03/26/07 12:27:53 (2 years ago)
Author:
sven
Message:

fixes for profile stuff: whitespace, html validation, php notices, cache-unfriendly queries, missing functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/lib/uploadlib.php

    r659 r1046  
    223223                } 
    224224            } 
    225             if ($savedsomething && $this->config->deleteothers) { 
     225            if (!empty($savedsomething) && $this->config->deleteothers) { 
    226226                $this->delete_other_files($destination, $exceptions); 
    227227            } 
  • devel/lib/userlib.php

    r1022 r1046  
    9797     * @return string Returns the user's name, or a blank string if something went wrong (eg the user didn't exist). 
    9898     */ 
    99      function user_name($user_id) { 
    100          global $CFG; 
    101          $user_name = new stdClass; 
    102          $user_name->owner = $user_id; 
    103          if ($user_name->name = user_info("name",$user_id)) { 
    104              if ($user_name = plugin_hook("user_name","display",$user_name)) { 
    105                  return $user_name->name; 
    106              } 
    107          } 
    108          return ""; 
    109      } 
     99    function user_name($user_id) { 
     100        global $CFG; 
     101        $user_name = new stdClass; 
     102        $user_name->owner = $user_id; 
     103        if ($user_name->name = user_info("name",$user_id)) { 
     104            if ($user_name = plugin_hook("user_name","display",$user_name)) { 
     105                return $user_name->name; 
     106            } 
     107        } 
     108        return ""; 
     109    } 
     110      
    110111    /** 
    111112     * Returns the HTML to display a user's icon, with event hooks allowing for interception. 
     
    119120     * @return string Returns the icon HTML, or the default icon if something went wrong (eg the user didn't exist). 
    120121     */ 
    121     function user_icon_html($user_id, $size = 100, $urlonly = false) { 
    122         global $CFG; 
    123         $extra = ""; 
    124         $user_icon = new stdClass; 
    125         $user_icon->owner = $user_id; 
    126         $user_icon->size = $size; 
    127         if ($size < 100) { 
    128             $extra = "/h/$size/w/$size"; 
    129        
    130         if ($user_icon->icon = user_info("icon",$user_id)) { 
    131             $user_icon->url = "{$CFG->wwwroot}_icon/user/{$user_icon->icon}{$extra}"; 
    132             $user_icon->html = "<img src=\"{$user_icon->url}\" border=\"0\" />"; 
    133             if ($user_icon = plugin_hook("user_icon","display",$user_icon)) { 
    134                 if ($urlonly) { 
     122    function user_icon_html($user_id, $size = 100, $urlonly = false) { 
     123        global $CFG; 
     124        $extra = ""; 
     125        $user_icon = new stdClass; 
     126        $user_icon->owner = $user_id; 
     127        $user_icon->size = $size; 
     128        if ($size < 100) { 
     129            $extra = "/h/$size/w/$size"; 
     130       
     131        if ($user_icon->icon = user_info("icon",$user_id)) { 
     132            $user_icon->url = "{$CFG->wwwroot}_icon/user/{$user_icon->icon}{$extra}"; 
     133            $user_icon->html = "<img src=\"{$user_icon->url}\" border=\"0\" alt=\"user icon\" />"; 
     134            if ($user_icon = plugin_hook("user_icon","display",$user_icon)) { 
     135                if ($urlonly) { 
    135136                    return $user_icon->url; 
    136                 } else { 
     137                } else { 
    137138                    return $user_icon->html; 
    138139                } 
    139            
    140        
    141         if ($urlonly) { 
    142             return -1; 
    143         } else { 
    144             return "<img src=\"{$CFG->wwwroot}_icon/user/-1{$extra}\" border=\"0\" />"; 
    145        
    146    
     140           
     141       
     142        if ($urlonly) { 
     143            return -1; 
     144        } else { 
     145            return "<img src=\"{$CFG->wwwroot}_icon/user/-1{$extra}\" border=\"0\" alt=\"default user icon\" />"; 
     146       
     147   
    147148     
    148149// USER FLAGS ////////////////////////////////////////////////////////////////// 
  • devel/mod/newsclient/lib.php

    r1030 r1046  
    8282    global $CFG; 
    8383     
     84    // Delete users 
     85    listen_for_event("user","delete","newsclient_user_delete"); 
     86     
    8487    //$CFG->widgets->display['feed'] = "newsclient_widget_display"; 
    8588    //$CFG->widgets->edit['feed'] = "newsclient_widget_edit"; 
     
    179182function newsclient_get_subscriptions_user($userid, $joined = false) { 
    180183     
    181        global $CFG; 
    182          
     184    global $CFG; 
     185     
    183186    $userid = (int) $userid; 
    184187    if (empty($joined)) { 
     
    197200} 
    198201 
     202function newsclient_user_delete($object_type, $event, $object) { 
     203    global $CFG, $data; 
     204    if (!empty($object->ident) && $object_type == "user" && $event == "delete") { 
     205        delete_records('feed_subscriptions','user_id',$object->ident); 
     206    } 
     207    return $object; 
     208} 
     209 
     210 
    199211?> 
  • devel/mod/profile/css

    r1037 r1046  
    1 <style
     1<style type="text/css"
    22 
    33/* 
     
    66 
    77img.profile-photo { 
    8    border:1px solid #eee; 
    9    padding:2px; 
     8       border:1px solid #eee; 
     9       padding:2px; 
    1010} 
    1111 
    1212.profile_main p { 
    13    color:#000; 
     13       color:#000; 
    1414} 
    1515 
    1616.profile_main p a { 
    17     text-decoration: underline; 
     17       text-decoration: underline; 
    1818} 
    1919 
    2020.profile_main_bottom { 
    21     clear: both; 
     21       clear: both; 
    2222} 
    2323 
    2424.profile_primary { 
    25     float: left; 
    26     width: 270px; 
    27     margin-top: 10px; 
    28     margin-left: 10px; 
     25       float: left; 
     26       width: 270px; 
     27       margin-top: 10px; 
     28       margin-left: 10px; 
    2929} 
    3030 
    3131.profile_secondary { 
    32     float: right; 
    33     width: 400px; 
    34     margin-top: 10px; 
    35     color:#000; 
     32       float: right; 
     33       width: 400px; 
     34       margin-top: 10px; 
     35       color:#000; 
    3636} 
    3737 
    3838.profile_bio { 
    39     padding-top: 10px; 
    40     background:#efefef; 
     39       padding-top: 10px; 
     40       background:#efefef; 
    4141} 
    4242 
    4343.profile_widgets { 
    44     clear: both; 
    45     width: 760px; 
    46     /*background: #004995;*/ 
     44       clear: both; 
     45       width: 760px; 
     46       /*background: #004995;*/ 
    4747} 
    4848 
    4949.profile_icon img { 
    50     border:1px solid #eee; 
    51     padding:2px 2px 2px 2px; 
     50       border:1px solid #eee; 
     51       padding:2px 2px 2px 2px; 
    5252} 
    5353 
    5454.profile_widgets_left { 
    55     float: left; 
    56     width: 330px; 
     55       float: left; 
     56       width: 330px; 
    5757} 
    5858 
    5959.profile_widgets_right { 
    60     float: right; 
    61     width: 330px 
     60       float: right; 
     61       width: 330px 
    6262} 
    6363 
     
    6565 
    6666#profile_widgets { 
    67    position:relative; 
     67       position:relative; 
    6868} 
    6969 
    7070.profile_bio { 
    71    width:244px; 
    72    padding:2px; 
     71       width:244px; 
     72       padding:2px; 
    7373} 
    7474 
    7575.widgets_even { 
    76    float:left; 
    77    width:340px; 
    78    margin:0; 
    79    padding:0; 
     76       float:left; 
     77       width:340px; 
     78       margin:0; 
     79       padding:0; 
    8080} 
    8181 
    8282.widgets_odd { 
    83    float:right; 
    84    width:340px; 
    85    margin:0; 
    86    padding:0; 
     83       float:right; 
     84       width:340px; 
     85       margin:0; 
     86       padding:0; 
    8787} 
    8888 
    8989.widget { 
    90     border: 1px solid #BBDCE9; /*#95BDCD;*/ 
    91     margin-bottom: 15px; 
    92     padding: 0; 
     90       border: 1px solid #BBDCE9; /*#95BDCD;*/ 
     91       margin-bottom: 15px; 
     92       padding: 0; 
    9393} 
    9494 
    9595.widget .widget_content { 
    96     padding: 4px 10px 4px 10px; 
     96       padding: 4px 10px 4px 10px; 
    9797} 
    9898 
    9999.widget .widget_content h3 { 
    100     padding:0; 
    101     margin:0; 
     100       padding:0; 
     101       margin:0; 
    102102} 
    103103 
    104104.widget .widget_bottom { 
    105     display: block; 
    106     background-color: #E2F0F6; /*#CBE5EF;*/ 
    107     margin: 0px; 
    108     padding-left: 10px; 
    109     border-top: 1px solid #BBDCE9; 
    110     font-size:0.8em; 
     105        display: block; 
     106        background-color: #E2F0F6; /*#CBE5EF;*/ 
     107        margin: 0px; 
     108        padding-left: 10px; 
     109        border-top: 1px solid #BBDCE9; 
     110        font-size:0.8em; 
    111111} 
    112112 
    113113.widget .widget_menu ul { 
    114     margin:0 0 0 5px; 
    115     padding:0; 
     114       margin:0 0 0 5px; 
     115       padding:0; 
    116116} 
    117117 
    118118.widget .widget_menu ul li { 
    119     list-style:none; 
     119        list-style:none; 
    120120} 
    121121 
    122122.widget .widget_menu ul li a { 
    123     text-decoration:underline; 
     123        text-decoration:underline; 
    124124} 
    125125 
    126126.widget .widget_admin_menu { 
    127     background-color: #E2F0F6; 
    128     padding:2px 0 0 5px; 
     127       background-color: #E2F0F6; 
     128       padding:2px 0 0 5px; 
    129129} 
    130130 
     
    134134 
    135135.widget .widget_title { 
    136           border:0; 
    137           border-bottom:1px solid #cdcdcd; /*#BBDCE9;*/ 
    138           padding:0 2px 0 2px; 
    139           margin:0 0 10px 0; 
    140           color:#000; 
    141           font-size:1.2em; 
    142         font-weight:bold; 
     136                 border:0; 
     137                 border-bottom:1px solid #cdcdcd; /*#BBDCE9;*/ 
     138                 padding:0 2px 0 2px; 
     139                 margin:0 0 10px 0; 
     140                 color:#000; 
     141                 font-size:1.2em; 
     142                font-weight:bold; 
    143143} 
    144144 
    145145.widget  .widget_content h2 a { 
    146     background:url( {{url}}_templates/icons/arrow.gif) no-repeat left; 
    147     padding:0 0 0 10px; 
     146       background:url( {{url}}_templates/icons/arrow.gif) no-repeat left; 
     147       padding:0 0 0 10px; 
    148148} 
    149149 
  • devel/mod/profile/lib.php

    r1041 r1046  
    3030                                           'html' => '<a href="'.$CFG->wwwroot.'_icons/?context=profile&amp;profile_id='.$pgowner.'">' 
    3131                                           . __gettext("Change site picture") . '</a>'); 
    32                 if ($CFG->uses_YUI) { 
    33                        $PAGE->menu_sub[] = array( 'name' => 'profile:widget:manage', 
    34                                'html' => '<a href="'.$CFG->wwwroot.'mod/widget/manage_widgets.php">' 
    35                                . __gettext("Manage widgets") . '</a>'); 
    36                } else { 
    37                        $PAGE->menu_sub[] = array( 'name' => 'profile:widget:add', 
    38                                'html' => '<a href="'.$CFG->wwwroot.'mod/profile/add.php?owner='.$pgowner.'">' 
    39                                . __gettext("Add widget") . '</a>'); 
    40                }                        
     32                if (!empty($CFG->uses_YUI)) { 
     33                    $PAGE->menu_sub[] = array( 'name' => 'profile:widget:manage', 
     34                        'html' => '<a href="'.$CFG->wwwroot.'mod/widget/manage_widgets.php">' 
     35                        . __gettext("Manage widgets") . '</a>'); 
     36                } else { 
     37                    $PAGE->menu_sub[] = array( 'name' => 'profile:widget:add', 
     38                        'html' => '<a href="'.$CFG->wwwroot.'mod/profile/add.php?owner='.$pgowner.'">' 
     39                        . __gettext("Add widget") . '</a>'); 
     40                }                    
    4141            } 
    4242        } 
     
    8989                                ); 
    9090    /* 
    91        $CFG->widgets->list[] = array( 
     91    $CFG->widgets->list[] = array( 
    9292                                        'name' => __gettext("Files widget"), 
    9393                                        'description' => __gettext("Displays images of some of your files."), 
     
    114114    if ($widget->type == 'profile::profile') { 
    115115     
    116            $profile_id = $page_owner; 
    117             
    118            require_once($CFG->dirroot . 'profile/profile.class.php'); 
    119             
    120            $profile_field = widget_get_data("profile_widget_field",$widget->ident); 
    121            $profile_id = $widget->owner; 
    122             
    123            $title = __gettext("Profile widget"); 
    124            $body = "<p>" . __gettext("This profile box is undefined.") . "</p>"; 
    125             
    126            if (!isset($profile)) { 
    127                $profile = new ElggProfile($profile_id); 
    128            } 
    129             
    130            $field = null; 
    131             
    132            $user_type = user_info("user_type",$widget->owner); 
    133             
    134            foreach($data['profile:details'] as $field_row) { 
    135                if ($field_row->internal_name == $profile_field && (empty($field_row->user_type) || $field_row->user_type == $user_type)) { 
    136                    $field = $field_row; 
    137                } 
    138            } 
    139             
    140            $title = $field->name; 
    141            $value = get_record_sql("select * from ".$CFG->prefix."profile_data where owner = ".$widget->owner." and name = " . $db->qstr($field->internal_name)); 
    142            $body = display_output_field(array($value->value,$field->field_type,$field->internal_name,$field->name,$value->ident)); 
    143                 
    144        return array('title'=>$title,'content'=>$body); 
    145        } elseif ($widget->type == 'profile::friends') { 
    146                return profile_friends_widget_display($widget->owner); 
    147        } elseif ($widget->type == 'profile::files') { 
    148                return profile_files_widget_display($widget->owner); 
    149        
     116        $profile_id = $page_owner; 
     117         
     118        require_once($CFG->dirroot . 'profile/profile.class.php'); 
     119         
     120        $profile_field = widget_get_data("profile_widget_field",$widget->ident); 
     121        $profile_id = $widget->owner; 
     122         
     123        $title = __gettext("Profile widget"); 
     124        $body = "<p>" . __gettext("This profile box is undefined.") . "</p>"; 
     125         
     126        if (!isset($profile)) { 
     127            $profile = new ElggProfile($profile_id); 
     128        } 
     129         
     130        $field = null; 
     131         
     132        $user_type = user_info("user_type",$widget->owner); 
     133         
     134        foreach($data['profile:details'] as $field_row) { 
     135            if ($field_row->internal_name == $profile_field && (empty($field_row->user_type) || $field_row->user_type == $user_type)) { 
     136                $field = $field_row; 
     137            } 
     138        } 
     139         
     140        $title = $field->name; 
     141        $value = get_record_sql("select * from ".$CFG->prefix."profile_data where owner = ".$widget->owner." and name = " . $db->qstr($field->internal_name)); 
     142        $body = display_output_field(array($value->value,$field->field_type,$field->internal_name,$field->name,$value->ident)); 
     143             
     144        return array('title'=>$title,'content'=>$body); 
     145    } elseif ($widget->type == 'profile::friends') { 
     146        return profile_friends_widget_display($widget->owner); 
     147    } elseif ($widget->type == 'profile::files') { 
     148        return profile_files_widget_display($widget->owner); 
     149   
    150150     
    151151} 
     
    153153function profile_show_thumbs($id_list,$list_type) { 
    154154    global $profile_id, $page_owner; 
    155        global $CFG, $USER; 
    156          
    157        // Given a series of IDs as a parameter, will display a box containing the icons and names of each specified user, community or file 
    158        // $parameter[0] is the title of the box; $parameter[1..n] is the user ID 
     155    global $CFG, $USER; 
     156     
     157    // Given a series of IDs as a parameter, will display a box containing the icons and names of each specified user, community or file 
     158    // $parameter[0] is the title of the box; $parameter[1..n] is the user ID 
    159159 
    160160    $body  = ""; 
     
    162162    $cellnum = -1; 
    163163    if ($list_type == 'files') { 
    164            $in_a_row = 3; 
     164        $in_a_row = 3; 
    165165    } else { 
    166            $in_a_row = 5; 
     166        $in_a_row = 5; 
    167167    } 
    168168 
    169169    foreach ($id_list as $key => $ident) { 
    170             
    171            if ($list_type == 'files') { 
    172                    if ($info = get_record_sql('SELECT folder, title, originalname FROM '.$CFG->prefix.'files ' 
     170         
     171        if ($list_type == 'files') { 
     172            if ($info = get_record_sql('SELECT folder, title, originalname FROM '.$CFG->prefix.'files ' 
    173173                               .'WHERE ident = ?',array($page_owner,$ident))) { 
    174                                $displayname = $info->title; 
    175                                $icon_url = $CFG->wwwroot.'_icon/file/'.$ident; 
    176                                $username = user_info('username',$page_owner); 
    177                                $object_url = $CFG->wwwroot.$username.'/files/'.$info->folder.'/'.$ident.'/'.$info->originalname; 
    178                        
    179                } else {                             
    180  
    181                $ident = (int) $ident; 
    182                $info = get_record('users','ident',$ident); 
    183                $_SESSION['user_info_cache'][$ident] = $info; 
    184                 
    185                $icon = user_info('icon',$ident); 
    186                        $icon_url = $CFG->wwwroot.'_icon/user/'.$icon.'/w/50'; 
    187          
    188                $info = $_SESSION['user_info_cache'][$ident]; 
    189                $displayname = run("profile:display:name", $info->ident); 
    190                $usermenu = ''; 
    191                $object_url = $CFG->wwwroot.$info->username.'/'; 
    192         } 
    193          
    194         if ($info) {    
    195                $cellnum++; 
    196                if ($cellnum % $in_a_row == 0 && $cellnum > 0) { 
    197                    $body .= "</tr><tr>"; 
    198                } 
    199                if ($list_type == 'files') { 
    200                                $body .= <<< END 
    201                        <td> 
    202                        <a href="$object_url"> 
    203                            <img border="0" src="$icon_url" alt="{$displayname}" title="{$displayname}" /> 
    204                        </a> 
    205                         </td>        
     174                $displayname = $info->title; 
     175                $icon_url = $CFG->wwwroot.'_icon/file/'.$ident; 
     176                $username = user_info('username',$page_owner); 
     177                $object_url = $CFG->wwwroot.$username.'/files/'.$info->folder.'/'.$ident.'/'.$info->originalname; 
     178           
     179        } else {                 
     180 
     181            $ident = (int) $ident; 
     182            $info = get_record('users','ident',$ident); 
     183            $_SESSION['user_info_cache'][$ident] = $info; 
     184             
     185            $icon = user_info('icon',$ident); 
     186            $icon_url = $CFG->wwwroot.'_icon/user/'.$icon.'/w/50'; 
     187     
     188            $info = $_SESSION['user_info_cache'][$ident]; 
     189            $displayname = run("profile:display:name", $info->ident); 
     190            $usermenu = ''; 
     191            $object_url = $CFG->wwwroot.$info->username.'/'; 
     192        } 
     193         
     194        if ($info) {     
     195            $cellnum++; 
     196            if ($cellnum % $in_a_row == 0 && $cellnum > 0) { 
     197                $body .= "</tr><tr>"; 
     198            } 
     199            if ($list_type == 'files') { 
     200                $body .= <<< END 
     201                <td> 
     202                <a href="$object_url"> 
     203                    <img border="0" src="$icon_url" alt="{$displayname}" title="{$displayname}" /> 
     204                </a> 
     205                </td> 
    206206END; 
    207                         } else {         
    208                        $body .= <<< END 
    209                        <td> 
    210                        <div style="clear:right;"> 
    211                        <a href="$object_url"> 
    212                            <img border="0" src="$icon_url" alt="{$displayname}" title="{$displayname}" /> 
    213                        </a> 
    214                        </div> 
    215                        <div> 
    216                        <a href="{$CFG->wwwroot}{$info->username}/">{$info->username}</a> 
    217                        </div> 
    218                         </td>        
     207            } else { 
     208                $body .= <<< END 
     209                <td> 
     210                <div style="clear:right;"> 
     211                <a href="$object_url"> 
     212                    <img border="0" src="$icon_url" alt="{$displayname}" title="{$displayname}" /> 
     213                </a> 
     214                </div> 
     215                <div> 
     216                <a href="{$CFG->wwwroot}{$info->username}/">{$info->username}</a> 
     217                </div> 
     218                </td> 
    219219END; 
    220                        
    221                 }                
     220           
     221        } 
    222222    } 
    223223 
    224224    $body .= "\t</tr>\n</table>\n"; 
    225             
    226        return $body; 
     225         
     226    return $body; 
    227227} 
    228228 
    229229function profile_files_widget_display($userid) { 
    230        global $CFG; 
    231        $file_list = array(); 
    232        $where1 = run("users:access_level_sql_where",$_SESSION['userid']); 
    233        if ($files = get_records_sql('SELECT * FROM '.$CFG->prefix.'files WHERE files_owner = '.$userid.' AND '.$where1.' LIMIT 9')) { 
    234                $file_count = count_records('files','files_owner',$userid); 
    235                foreach($files as $file) { 
    236                //if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { 
    237                        $file_list[] = (int) $file->ident; 
    238                //} 
    239                
    240        
    241        if ($file_list) { 
    242                $username = user_info('username',$userid); 
    243                $title = __gettext('Files'); 
     230    global $CFG; 
     231    $file_list = array(); 
     232    $where1 = run("users:access_level_sql_where",$_SESSION['userid']); 
     233    if ($files = get_records_sql('SELECT * FROM '.$CFG->prefix.'files WHERE files_owner = '.$userid.' AND '.$where1.' LIMIT 9')) { 
     234        $file_count = count_records('files','files_owner',$userid); 
     235        foreach($files as $file) { 
     236            //if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { 
     237                $file_list[] = (int) $file->ident; 
     238            //} 
     239       
     240   
     241    if ($file_list) { 
     242        $username = user_info('username',$userid); 
     243        $title = __gettext('Files'); 
    244244        $menu = array(array('text' => __gettext('View all'), 'link' => $CFG->wwwroot.$username.'/files', 'title'=>$file_count .' '. ($file_count == 1 ? __gettext("file"):__gettext("files")))); 
    245            $content = profile_show_thumbs($file_list,'files'); 
     245        $content = profile_show_thumbs($file_list,'files'); 
    246246        $widget_array = array('title'=>$title,'menu'=>$menu,'content'=>$content); 
    247247    } else { 
     
    256256    $html = ''; 
    257257    $friends = array(); 
    258        if ($result = get_records_sql('SELECT DISTINCT u.ident,1 FROM '.$CFG->prefix.'friends f 
     258    if ($result = get_records_sql('SELECT DISTINCT u.ident,1 FROM '.$CFG->prefix.'friends f 
    259259                               JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
    260260                               WHERE f.owner = ? AND u.user_type = ? order by u.last_action desc LIMIT 9',array($userid,'person'))) { 
    261            $friend_count = get_record_sql('SELECT count(*) as count FROM '.$CFG->prefix.'friends f 
     261        $friend_count = get_record_sql('SELECT count(*) as count FROM '.$CFG->prefix.'friends f 
    262262                               JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
    263263                               WHERE f.owner = ? AND u.user_type = ?',array($userid,'person')); 
     
    266266        } 
    267267        if ($userid != $_SESSION['userid']) { 
    268                $link = url."_friends/?owner=$userid"; 
    269            } else { 
    270                $link = url.$_SESSION['username']."/friends/"; 
    271            } 
     268            $link = url."_friends/?owner=$userid"; 
     269        } else { 
     270            $link = url.$_SESSION['username']."/friends/"; 
     271        } 
    272272        $title = __gettext('Friends'); 
    273273        $menu_array = array(array('text' => __gettext('View all Friends'), 'link' => $link, 'title'=>$friend_count->count .' '. ($friend_count->count == 1 ? __gettext("friend"):__gettext("friends")))); 
    274            $content = profile_show_thumbs($friends,'users'); 
    275            $widget_array = array('title'=>$title,'menu'=>$menu_array,'content'=>$content); 
     274        $content = profile_show_thumbs($friends,'users'); 
     275        $widget_array = array('title'=>$title,'menu'=>$menu_array,'content'=>$content); 
    276276    } else { 
    277            $widget_array = array(); 
    278        
    279        return $widget_array; 
     277        $widget_array = array(); 
     278   
     279    return $widget_array; 
    280280} 
    281281 
     
    287287    if ($widget->type == 'profile::profile') { 
    288288     
    289            $profile_id = $page_owner; 
    290             
    291            require_once($CFG->dirroot . 'profile/profile.class.php'); 
    292             
    293            $profile_field = widget_get_data("profile_widget_field",$widget->ident); 
    294             
    295            if (!isset($profile)) { 
    296                $profile = new ElggProfile($profile_id); 
    297            } 
    298          
    299            $body = "<h2>" . __gettext("Profile widget") . "</h2>"; 
    300            $body .= "<p>" . __gettext("Select a profile field below; the widget will then display the profile content from this field.") . "</p>"; 
    301             
    302            $body .= "<select name=\"widget_data[profile_widget_field]\">"; 
    303          
    304            $user_type = user_info("user_type",$widget->owner); 
    305             
    306             
    307            foreach($data['profile:details'] as $field_row) { 
    308                 
    309                if (empty($field_row->user_type) || $field_row->user_type == $user_type) { 
    310                    if ($field_row->internal_name == $profile_field ) { 
    311                        $selected = "selected=\"selected\""; 
    312                    } else { 
    313                        $selected = ""; 
    314                    } 
    315                     
    316                    $body .= "<option value=\"" . $field_row->internal_name . "\">" . $field_row->name . "</option>\n"; 
    317                }     
    318            } 
    319             
    320            $body .= "</select>"; 
    321      
    322        } elseif ($widget->type == 'profile::friends') { 
    323            // can't edit this widget for now 
    324            $body = ''; 
     289        $profile_id = $page_owner; 
     290         
     291        require_once($CFG->dirroot . 'profile/profile.class.php'); 
     292         
     293        $profile_field = widget_get_data("profile_widget_field",$widget->ident); 
     294         
     295        if (!isset($profile)) { 
     296            $profile = new ElggProfile($profile_id); 
     297        } 
     298     
     299        $body = "<h2>" . __gettext("Profile widget") . "</h2>"; 
     300        $body .= "<p>" . __gettext("Select a profile field below; the widget will then display the profile content from this field.") . "</p>"; 
     301         
     302        $body .= "<select name=\"widget_data[profile_widget_field]\">"; 
     303     
     304        $user_type = user_info("user_type",$widget->owner); 
     305         
     306         
     307        foreach($data['profile:details'] as $field_row) { 
     308             
     309            if (empty($field_row->user_type) || $field_row->user_type == $user_type) { 
     310                if ($field_row->internal_name == $profile_field ) { 
     311                    $selected = "selected=\"selected\""; 
     312                } else { 
     313                    $selected = ""; 
     314                } 
     315                 
     316                $body .= "<option value=\"" . $field_row->internal_name . "\">" . $field_row->name . "</option>\n"; 
     317            }     
     318        } 
     319         
     320        $body .= "</select>"; 
     321     
     322    } elseif ($widget->type == 'profile::friends') { 
     323        // can't edit this widget for now 
     324        $body = ''; 
    325325    } elseif ($widget->type == 'profile::files') { 
    326            // can't edit this widget for now 
    327            $body = ''; 
     326        // can't edit this widget for now 
     327        $body = ''; 
    328328    } 
    329329     
  • devel/mod/profile/profile.config.php

    r1030 r1046  
    6262                                                                    "invisible" => false, 
    6363                                                                    "required" => false, 
     64                                                                    "user_type" => "", 
    6465                                                                    )); 
    6566         
  • devel/mod/profile_photo/lib.php

    r1036 r1046  
    3535            } 
    3636            if (!empty($parameter[1])) { 
    37                 $html .= "<img src=\"{$CFG->wwwroot}mod/profile_photo/img.php?id={$parameter[4]}&constraint1=w&size1=250&constraint2=h&size2=200\" /><br />"; 
    38                 $html .= "<input name=\"".$parameter[0]."\" type=\"checkbox\" id=\"$cleanid\" value=\"photo\" />"; 
     37                $html .= "<img src=\"{$CFG->wwwroot}mod/profile_photo/img.php?id={$parameter[4]}&amp;constraint1=w&amp;size1=250&amp;constraint2=h&amp;size2=200\" alt=\"Profile photo\" /><br />"; 
     38                $html .= "<label for=\"$cleanid\"><input name=\"".$parameter[0]."\" type=\"checkbox\" id=\"$cleanid\" value=\"photo\" />"; 
    3939                $html .= __gettext("Click here to remove this photo."); 
     40                $html .= "</label>"; 
    4041            } else { 
    4142                $html .= "<input name=\"profile_photo_".$parameter[3]."\" type=\"file\" /><br />"; 
    42                 $html .= "<input name=\"".$parameter[0]."\" type=\"checkbox\" id=\"$cleanid\" value=\"photo\" />"; 
     43                $html .= "<label for=\"$cleanid\"><input name=\"".$parameter[0]."\" type=\"checkbox\" id=\"$cleanid\" value=\"photo\" />"; 
    4344                $html .= __gettext("Click here to verify that this is a photo of you and that it is not obscene or abusive."); 
     45                $html .= "</label>"; 
    4446            } 
    4547        } 
     
    4951    function profile_photo_display_output_field($parameter) { 
    5052        global $CFG, $profile_id; 
     53        $html = ''; 
    5154        if ($parameter[1] == "profile_photo") { 
    52             if (!empty($parameter[4]) 
    53                 && $parameter[0] != "photo") { 
    54                 $html .= "<img class=\"profile-photo\" src=\"{$CFG->wwwroot}mod/profile_photo/img.php?id={$parameter[4]}&constraint1=w&size1=250\" />"; 
     55            if (!empty($parameter[4]) && $parameter[0] != "photo") { 
     56                $html .= "<img class=\"profile-photo\" src=\"{$CFG->wwwroot}mod/profile_photo/img.php?id={$parameter[4]}&amp;constraint1=w&amp;size1=250\" alt=\"Profile photo\" />"; 
    5557            } else { 
    5658                $pictureglyph = __gettext("Click here to upload a photo"); 
    5759                $html = <<< END 
    5860</p> 
    59 <style
     61<style type="text/css"
    6062div#default-profile-icon { 
    6163    width:250px; 
     
    8284<div id="default-profile-icon"> 
    8385<p><a href="{$CFG->wwwroot}profile/edit.php?profile_id={$profile_id}">{$pictureglyph}</a></p> 
    84 </div>                 
     86</div> 
    8587<p> 
    8688END; 
  • devel/mod/widget/ajax_delete_widget.php

    r1030 r1046  
    22 
    33// Load Elgg framework 
    4         @require_once("../../includes.php"); 
    5          
     4@require_once("../../includes.php"); 
     5 
    66$id = optional_param('id',0,PARAM_INT); 
    77 
    88if (isloggedin()) { 
    9         $widget = get_record_sql("select * from ".$CFG->prefix."widgets where ident = $id"); 
     9    if ($widget = get_record('widgets','ident',$id)) { 
     10         
     11        // Page owner = where the widget resides 
     12        $page_owner = $widget->owner; 
     13         
     14        // Do we have permission to touch this? 
     15        // If so, wipe it! 
     16        if (run("permissions:check","profile")) { 
    1017             
    11         // Page owner = where the widget resides 
    12         $page_owner = $widget->owner; 
    13          
    14         // Do we have permission to touch this? 
    15         // If so, wipe it! 
    16         if (run("permissions:check","profile")) { 
    17              
    18             widget_destroy($widget->ident); 
    19             widget_reorder($page_owner,$widget->location,$widget->location_id,$widget->column); 
    20              
    21         } 
     18            widget_destroy($widget->ident); 
     19            widget_reorder($page_owner,$widget->location,$widget->location_id,$widget->column); 
     20             
     21        } 
     22    } 
    2223} 
    2324 
  • devel/mod/widget/css

    r1030 r1046  
    22 
    33#profile_widgets { 
    4    position:relative; 
     4       position:relative; 
    55} 
    66 
    77.widgets_even { 
    8    float:left; 
    9    width:330px; 
     8       float:left; 
     9       width:330px; 
    1010} 
    1111 
    1212.widgets_odd { 
    13    float:right; 
    14    width:330px; 
     13       float:right; 
     14       width:330px; 
    1515} 
    1616 
    1717.widget { 
    18     border: 1px solid #BBDCE9; /*#95BDCD;*/ 
    19     margin-bottom: 5px; 
    20     padding: 0; 
     18       border: 1px solid #BBDCE9; /*#95BDCD;*/ 
     19       margin-bottom: 5px; 
     20       padding: 0; 
    2121} 
    2222 
    2323.widget .widget_content { 
    24     padding: 10px; 
     24       padding: 10px; 
    2525} 
    2626.widget .widget_content h3 { 
    27     padding:0; 
    28     margin:0; 
     27       padding:0; 
     28       margin:0; 
    2929} 
    3030 
    3131.widget .widget_menu { 
    32      display: block; 
    33      background-color: #E2F0F6; /*#CBE5EF;*/ 
    34