Changeset 1301

Show
Ignore:
Timestamp:
11/21/07 11:38:18 (9 months ago)
Author:
dramirez
Message:

Moved from units to mod:

  • profile
  • users
  • template

Updated .htaccess rules

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/htaccess-dist

    r1298 r1301  
    7474#RewriteBase / 
    7575 
    76 RewriteRule ^_templates/css/(.+)$ _templates/css.php?template=$1 
     76RewriteRule ^_templates(\/)?$ mod/template/index.php?%{QUERY_STRING} 
     77RewriteRule ^_templates\/edit.php$ mod/template/edit.php?%{QUERY_STRING} 
     78RewriteRule ^_templates\/preview.php$ mod/template/preview.php?%{QUERY_STRING} 
     79RewriteRule ^_templates/css/(.+)$ mod/template/css.php?template=$1 
    7780 
    7881RewriteRule ^(.+)\/rssstyles.xsl$ mod/newsclient/styles.php?rssurl=$1&url=$1 
  • devel/includes.php

    r1296 r1301  
    104104 
    105105    /*************************************************************************** 
    106     *    PLUGIN INITIALISATION 
    107     ****************************************************************************/ 
    108  
    109     // XMLRPC 
    110         @include($CFG->dirroot . "units/rpc/main.php"); 
    111  
    112     /*************************************************************************** 
    113106    *    CONTENT MODULES 
    114107    *    This should make languages easier, although some kind of 
     
    124117 
    125118    /*************************************************************************** 
    126     *    HELP MODULES 
    127     ****************************************************************************/ 
    128  
    129     // Include main 
    130         // include_once($CFG->dirroot . "help/mainindex/main.php"); 
    131  
    132     // Calendaring system 
    133     //    require($CFG->dirroot . "units/calendar/main.php"); 
    134  
    135     /*************************************************************************** 
    136119    *    START-OF-PAGE RUNNING 
    137120    ****************************************************************************/ 
    138121 
    139         run("init"); 
    140          
    141122        if ($allmods = get_list_of_plugins('mod') ) { 
    142123            foreach ($allmods as $mod) { 
     
    147128           } 
    148129        } 
     130 
     131        run("init"); 
    149132 
    150133    // Walled garden checking: if we're not logged in, 
  • devel/includes_system.php

    r1251 r1301  
    1313                //@todo All the libraries has a strong dependence with this 'plugin' 
    1414        require_once($CFG->dirroot . "mod/gettext/lib.php"); 
    15     // Users 
    16         require($CFG->dirroot . "units/users/main.php"); 
    17     // Templates 
    18         require($CFG->dirroot . "units/templates/main.php"); 
    19     // Profiles 
    20         include($CFG->dirroot . "units/profile/main.php"); 
    21          
    2215    // XML parsing 
    2316        require($CFG->dirroot . "lib/xmllib.php"); 
  • devel/mod/profile/lib.php

    r1300 r1301  
    11<?php 
    2  
    32function profile_pagesetup() { 
    4     // register links --  
    5     global $profile_id; 
    6     global $PAGE; 
    7     global $CFG; 
    8  
    9     // don't clobber $page_owner, use a  
    10     // local $pgowner instead for clarity 
    11     $pgowner = $profile_id; 
    12  
    13     if (isloggedin()) { 
    14         if (defined("context") && context == "profile" && $pgowner == $_SESSION['userid']) { 
    15             $PAGE->menu[] = array( 'name' => 'profile',  
    16                                    'html' => '<li><a href="'.$CFG->wwwroot.$_SESSION['username'].'/profile/" class="selected">'.__gettext("Your Profile").'</a></li>'); 
    17         } else { 
    18             $PAGE->menu[] = array( 'name' => 'profile', 
    19                                    'html' => '<li><a href="'.$CFG->wwwroot.$_SESSION['username'].'/profile/">'.__gettext("Your Profile").'</a></li>'); 
    20         } 
    21  
    22         if (profile_permissions_check("profile") && defined("context") && context == "profile") { 
    23  
    24             if (user_type($pgowner) == "person") { 
    25                 $PAGE->menu_sub[] = array( 'name' => 'profile:edit',  
    26                                            'html' => '<a href="'.$CFG->wwwroot.'profile/edit.php?profile_id='.$pgowner.'">' 
    27                                            . __gettext("Edit this profile") . '</a>'); 
    28  
    29                 $PAGE->menu_sub[] = array( 'name' => 'profile:picedit',  
    30                                            'html' => '<a href="'.$CFG->wwwroot.'_icons/?context=profile&amp;profile_id='.$pgowner.'">' 
    31                                            . __gettext("Change site picture") . '</a>'); 
    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                 }                    
    41             } 
    42         } 
    43     } 
     3        // register links --  
     4        global $profile_id; 
     5        global $PAGE; 
     6        global $CFG; 
     7 
     8        // don't clobber $page_owner, use a  
     9        // local $pgowner instead for clarity 
     10        $pgowner = $profile_id; 
     11 
     12        if (isloggedin()) { 
     13                if (defined("context") && context == "profile" && $pgowner == $_SESSION['userid']) { 
     14                        $PAGE->menu[] = array ( 
     15                                'name' => 'profile', 
     16                                'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/profile/" class="selected">' . __gettext("Your Profile") . '</a></li>'); 
     17                } else { 
     18                        $PAGE->menu[] = array ( 
     19                                'name' => 'profile', 
     20                                'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/profile/">' . __gettext("Your Profile") . '</a></li>'); 
     21                } 
     22 
     23                if (profile_permissions_check("profile") && defined("context") && context == "profile") { 
     24 
     25                        if (user_type($pgowner) == "person") { 
     26                                $PAGE->menu_sub[] = array ( 
     27                                        'name' => 'profile:edit', 
     28                                        'html' => '<a href="' . $CFG->wwwroot . 'profile/edit.php?profile_id=' . $pgowner . '">' . __gettext("Edit this profile") . '</a>'); 
     29 
     30                                $PAGE->menu_sub[] = array ( 
     31                                        'name' => 'profile:picedit', 
     32                                        'html' => '<a href="' . $CFG->wwwroot . '_icons/?context=profile&amp;profile_id=' . $pgowner . '">' . __gettext("Change site picture") . '</a>'); 
     33                                if (!empty ($CFG->uses_YUI)) { 
     34                                        $PAGE->menu_sub[] = array ( 
     35                                                'name' => 'profile:widget:manage', 
     36                                                'html' => '<a href="' . $CFG->wwwroot . 'mod/widget/manage_widgets.php">' . __gettext("Manage widgets") . '</a>'); 
     37                                } else { 
     38                                        $PAGE->menu_sub[] = array ( 
     39                                                'name' => 'profile:widget:add', 
     40                                                'html' => '<a href="' . $CFG->wwwroot . 'mod/profile/add.php?owner=' . $pgowner . '">' . __gettext("Add widget") . '</a>'); 
     41                                } 
     42                        } 
     43                } 
     44        } 
     45 
     46        $PAGE->search_menu[] = array ( 
     47                'name' => __gettext("People"), 'user_type' => 'person'); 
     48 
     49
     50 
     51function profile_init() { 
     52 
     53        global $CFG, $messages, $function, $metatags, $data; 
     54 
     55        // Check to see if the profile config file doesn't exist 
     56        if (!isset ($CFG->profilelocation)) { 
     57                $CFG->profilelocation = $CFG->dirroot . "mod/profile/"; 
     58        } else { 
     59 
     60                if (!file_exists($CFG->profilelocation . "profile.config.php")) { 
     61                        if (!copy($CFG->dirroot . "mod/profile/profile.config.php", $CFG->profilelocation . "profile.config.php")) { 
     62                                $CFG->profilelocation = $CFG->dirroot . "mod/profile/"; 
     63                        } 
     64                } 
     65 
     66        } 
     67 
     68        $css = file_get_contents($CFG->dirroot . "mod/profile/css"); 
     69        $css = str_replace("{{url}}", $CFG->wwwroot, $css); 
     70        $metatags .= $css; 
     71 
    4472     
    45     $PAGE->search_menu[] = array( 'name' => __gettext("People"), 
    46                                   'user_type' => 'person'); 
    47  
    48 
    49  
    50 function profile_init() { 
     73    // Profile initialisation 
     74    $function['profile:init'][] = dirname(__FILE__) . "/lib/function_init.php"; 
     75    // $function['profile:init'][] = $CFG->dirroot . "units/profile/function_editfield_defaults.php"; 
     76    $function['profile:init'][] = dirname(__FILE__) . "/lib/function_upload_foaf.php"; 
    5177     
    52     global $CFG, $messages, $function, $metatags, $data; 
     78    // Initialisation for the search function 
     79    $function['search:init'][] = dirname(__FILE__) . "/lib/function_init.php"; 
     80        $function['search:init'][] = $CFG->profilelocation . "profile.config.php"; 
     81 
     82    $function['search:all:tagtypes'][] = dirname(__FILE__) . "/lib/function_search_all_tagtypes.php"; 
     83    $function['search:all:tagtypes:rss'][] = dirname(__FILE__) . "/lib/function_search_all_tagtypes_rss.php"; 
     84         
     85    // Function to search through profiles 
     86    $function['search:display_results'][] = dirname(__FILE__) . "/lib/function_search.php"; 
     87    $function['search:display_results:rss'][] = dirname(__FILE__) . "/lib/function_search_rss.php"; 
     88         
     89    // Functions to view and edit individual profile fields         
     90    $function['profile:editfield:display'][] = dirname(__FILE__) . "/lib/function_editfield_display.php"; 
     91    $function['profile:field:display'][] = dirname(__FILE__) . "/lib/function_field_display.php"; 
    5392     
    54     // Check to see if the profile config file doesn't exist 
    55     if (!isset($CFG->profilelocation)) { 
    56         $CFG->profilelocation = $CFG->dirroot . "mod/profile/"; 
    57     } else { 
     93    // Function to edit all profile fields 
     94    $function['profile:edit'][] = dirname(__FILE__) . "/lib/function_edit.php"; 
     95         
     96    // Function to view all profile fields 
     97    $function['profile:view'][] = dirname(__FILE__) . "/lib/function_view.php"; 
     98         
     99    // Function to display user's name 
     100    $function['profile:display:name'][] = dirname(__FILE__) . "/lib/function_display_name.php"; 
     101         
     102    $function['profile:user:info'][] = dirname(__FILE__) . "/lib/profile_user_info.php"; 
    58103     
    59         if (!file_exists($CFG->profilelocation . "profile.config.php")) { 
    60             if (!copy($CFG->dirroot . "mod/profile/profile.config.php",$CFG->profilelocation . "profile.config.php")) { 
    61                 $CFG->profilelocation = $CFG->dirroot . "mod/profile/"; 
    62             } 
    63         } 
    64      
    65     } 
    66      
    67     $css = file_get_contents($CFG->dirroot . "mod/profile/css"); 
    68     $css = str_replace("{{url}}", $CFG->wwwroot, $css); 
    69     $metatags .= $css; 
    70      
    71     $function['search:init'][] = $CFG->profilelocation . "profile.config.php"; 
    72     // include($CFG->profilelocation . "profile.config.php"); 
    73      
    74     // Delete users 
    75     listen_for_event("user","delete","profile_user_delete"); 
    76      
    77     // Add items to the dashboard if it exists 
    78     //$CFG->widgets->display['profile'] = "profile_widget_display"; 
    79     //$CFG->widgets->edit['profile'] = "profile_widget_edit"; 
    80     $CFG->widgets->list[] = array( 
    81                                         'name' => __gettext("Profile widget"), 
    82                                         'description' => __gettext("Displays the contents of a profile field."), 
    83                                         'type' => "profile::profile" 
    84                                 ); 
    85     $CFG->widgets->list[] = array( 
    86                                         'name' => __gettext("Friends widget"), 
    87                                         'description' => __gettext("Displays the icons of your most recently logged-in friends."), 
    88                                         'type' => "profile::friends" 
    89                                 ); 
    90     /* 
    91     $CFG->widgets->list[] = array( 
    92                                         'name' => __gettext("Files widget"), 
    93                                         'description' => __gettext("Displays images of some of your files."), 
    94                                         'type' => "profile::files" 
    95                                 ); 
    96     */ 
    97 
    98  
    99 function profile_permissions_check ($object) { 
    100     global $page_owner; 
    101      
    102     if ($object === "profile" && ($page_owner == $_SESSION['userid'] || user_flag_get("admin", $_SESSION['userid']))) { 
    103         return true; 
    104     } 
    105     return false; 
    106 
    107  
     104    // Descriptive text 
     105    $function['content:profile:edit'][] = dirname(__FILE__) . "/lib/content_edit.php"; 
     106 
     107    // Establish permissions 
     108    $function['permissions:check'][] = dirname(__FILE__) . "/lib/permissions_check.php"; 
     109         
     110    // FOAF 
     111    $function['foaf:generate:fields'][] = dirname(__FILE__) . "/lib/generate_foaf_fields.php"; 
     112    $function['vcard:generate:fields:adr'][] = dirname(__FILE__) . "/lib/generate_vcard_adr_fields.php"; 
     113                 
     114    // Actions to perform when an access group is deleted 
     115    $function['groups:delete'][] = dirname(__FILE__) . "/lib/groups_delete.php"; 
     116         
     117    // Publish static RSS file of posts and files 
     118    $function['profile:rss:publish'][] = dirname(__FILE__) . "/lib/function_rss_publish.php"; 
     119 
     120        // Delete users 
     121        listen_for_event("user", "delete", "profile_user_delete"); 
     122 
     123        // Add items to the dashboard if it exists 
     124        //$CFG->widgets->display['profile'] = "profile_widget_display"; 
     125        //$CFG->widgets->edit['profile'] = "profile_widget_edit"; 
     126        $CFG->widgets->list[] = array ( 
     127                'name' => __gettext("Profile widget"),  
     128                'description' => __gettext("Displays the contents of a profile field."),  
     129                'type' => "profile::profile"); 
     130                 
     131        $CFG->widgets->list[] = array ( 
     132                'name' => __gettext("Friends widget"),  
     133                'description' => __gettext("Displays the icons of your most recently logged-in friends."),  
     134                'type' => "profile::friends"); 
     135        /* 
     136        $CFG->widgets->list[] = array( 
     137                                            'name' => __gettext("Files widget"), 
     138                                            'description' => __gettext("Displays images of some of your files."), 
     139                                            'type' => "profile::files" 
     140                                    ); 
     141        */ 
     142
     143 
     144function profile_permissions_check($object) { 
     145        global $page_owner; 
     146 
     147        if ($object === "profile" && ($page_owner == $_SESSION['userid'] || user_flag_get("admin", $_SESSION['userid']))) { 
     148                return true; 
     149        } 
     150        return false; 
     151
    108152 
    109153function profile_widget_display($widget) { 
    110      
    111     global $CFG, $profile_id, $data, $page_owner, $db; 
    112     static $profile; 
    113      
    114     if ($widget->type == 'profile::profile') { 
    115      
    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         if (run("users:access_level_check", $value->access)) { 
    143             $body = display_output_field(array($value->value,$field->field_type,$field->internal_name,$field->name,$value->ident)); 
    144         } else { 
    145             $body = ""; 
    146         } 
    147              
    148         return array('title'=>$title,'content'=>$body); 
    149     } elseif ($widget->type == 'profile::friends') { 
    150         return profile_friends_widget_display($widget->owner); 
    151     } elseif ($widget->type == 'profile::files') { 
    152         return profile_files_widget_display($widget->owner); 
    153     } 
    154      
    155 
    156  
    157 function profile_show_thumbs($id_list,$list_type) { 
    158     global $profile_id, $page_owner; 
    159     global $CFG, $USER; 
    160      
    161     // Given a series of IDs as a parameter, will display a box containing the icons and names of each specified user, community or file 
    162     // $parameter[0] is the title of the box; $parameter[1..n] is the user ID 
    163  
    164     $body  = ""; 
    165     $body .= "<table>\n\t<tr>\n"; 
    166     $cellnum = -1; 
    167     if ($list_type == 'files') { 
    168         $in_a_row = 3; 
    169     } else { 
    170         $in_a_row = 5; 
    171     } 
    172  
    173     foreach ($id_list as $key => $ident) { 
    174          
    175         if ($list_type == 'files') { 
    176             if ($info = get_record_sql('SELECT folder, title, originalname FROM '.$CFG->prefix.'files ' 
    177                                .'WHERE ident = ?',array($page_owner,$ident))) { 
    178                 $displayname = $info->title; 
    179                 $icon_url = $CFG->wwwroot.'_icon/file/'.$ident; 
    180                 $username = user_info('username',$page_owner); 
    181                 $object_url = $CFG->wwwroot.$username.'/files/'.$info->folder.'/'.$ident.'/'.$info->originalname; 
    182             } 
    183         } else {                 
    184  
    185             $ident = (int) $ident; 
    186             $info = get_record('users','ident',$ident); 
    187             $_SESSION['user_info_cache'][$ident] = $info; 
    188              
    189             $icon = user_info('icon',$ident); 
    190             $icon_url = $CFG->wwwroot.'_icon/user/'.$icon.'/w/50'; 
    191      
    192             $info = $_SESSION['user_info_cache'][$ident]; 
    193             $displayname = run("profile:display:name", $info->ident); 
    194             $usermenu = ''; 
    195             $object_url = $CFG->wwwroot.$info->username.'/'; 
    196         } 
    197          
    198         if ($info) {     
    199             $cellnum++; 
    200             if ($cellnum % $in_a_row == 0 && $cellnum > 0) { 
    201                 $body .= "</tr><tr>"; 
    202             } 
    203             if ($list_type == 'files') { 
    204                 $body .= <<< END 
     154 
     155        global $CFG, $profile_id, $data, $page_owner, $db; 
     156        static $profile; 
     157 
     158        if ($widget->type == 'profile::profile') { 
     159 
     160                $profile_id = $page_owner; 
     161 
     162                require_once ($CFG->dirroot . 'profile/profile.class.php'); 
     163 
     164                $profile_field = widget_get_data("profile_widget_field", $widget->ident); 
     165                $profile_id = $widget->owner; 
     166 
     167                $title = __gettext("Profile widget"); 
     168                $body = "<p>" . __gettext("This profile box is undefined.") . "</p>"; 
     169 
     170                if (!isset ($profile)) { 
     171                        $profile = new ElggProfile($profile_id); 
     172                } 
     173 
     174                $field = null; 
     175 
     176                $user_type = user_info("user_type", $widget->owner); 
     177 
     178                foreach ($data['profile:details'] as $field_row) { 
     179                        if ($field_row->internal_name == $profile_field && (empty ($field_row->user_type) || $field_row->user_type == $user_type)) { 
     180                                $field = $field_row; 
     181                        } 
     182                } 
     183 
     184                $title = $field->name; 
     185                $value = get_record_sql("select * from " . $CFG->prefix . "profile_data where owner = " . $widget->owner . " and name = " . $db->qstr($field->internal_name)); 
     186                if (run("users:access_level_check", $value->access)) { 
     187                        $body = display_output_field(array ( 
     188                                $value->value, 
     189                                $field->field_type, 
     190                                $field->internal_name, 
     191                                $field->name, 
     192                                $value->ident 
     193                        )); 
     194                } else { 
     195                        $body = ""; 
     196                } 
     197 
     198                return array ( 
     199                        'title' => $title, 
     200                        'content' => $body 
     201                ); 
     202        } 
     203        elseif ($widget->type == 'profile::friends') { 
     204                return profile_friends_widget_display($widget->owner); 
     205        } 
     206        elseif ($widget->type == 'profile::files') { 
     207                return profile_files_widget_display($widget->owner); 
     208        } 
     209 
     210
     211 
     212function profile_show_thumbs($id_list, $list_type) { 
     213        global $profile_id, $page_owner; 
     214        global $CFG, $USER; 
     215 
     216        // Given a series of IDs as a parameter, will display a box containing the icons and names of each specified user, community or file 
     217        // $parameter[0] is the title of the box; $parameter[1..n] is the user ID 
     218 
     219        $body = ""; 
     220        $body .= "<table>\n\t<tr>\n"; 
     221        $cellnum = -1; 
     222        if ($list_type == 'files') { 
     223                $in_a_row = 3; 
     224        } else { 
     225                $in_a_row = 5; 
     226        } 
     227 
     228        foreach ($id_list as $key => $ident) { 
     229 
     230                if ($list_type == 'files') { 
     231                        if ($info = get_record_sql('SELECT folder, title, originalname FROM ' . $CFG->prefix . 'files ' . 
     232                                'WHERE ident = ?', array ($page_owner,$ident))) { 
     233                                $displayname = $info->title; 
     234                                $icon_url = $CFG->wwwroot . '_icon/file/' . $ident; 
     235                                $username = user_info('username', $page_owner); 
     236                                $object_url = $CFG->wwwroot . $username . '/files/' . $info->folder . '/' . $ident . '/' . $info->originalname; 
     237                        } 
     238                } else { 
     239 
     240                        $ident = (int) $ident; 
     241                        $info = get_record('users', 'ident', $ident); 
     242                        $_SESSION['user_info_cache'][$ident] = $info; 
     243 
     244                        $icon = user_info('icon', $ident); 
     245                        $icon_url = $CFG->wwwroot . '_icon/user/' . $icon . '/w/50'; 
     246 
     247                        $info = $_SESSION['user_info_cache'][$ident]; 
     248                        $displayname = run("profile:display:name", $info->ident); 
     249                        $usermenu = ''; 
     250                        $object_url = $CFG->wwwroot . $info->username . '/'; 
     251                } 
     252 
     253                if ($info) { 
     254                        $cellnum++; 
     255                        if ($cellnum % $in_a_row == 0 && $cellnum > 0) { 
     256                                $body .= "</tr><tr>"; 
     257                        } 
     258                        if ($list_type == 'files') { 
     259                                $body .=<<< END 
    205260                <td> 
    206261                <a href="$object_url"> 
     
    209264                </td> 
    210265END; 
    211             } else { 
    212                 $body .= <<< END 
     266                       } else { 
     267                               $body .=<<< END 
    213268                <td> 
    214269                <div style="clear:right;"> 
     
    222277                </td> 
    223278END; 
    224            
    225        
    226    
    227  
    228     $body .= "\t</tr>\n</table>\n"; 
    229          
    230     return $body; 
     279                       
     280               
     281       
     282 
     283       $body .= "\t</tr>\n</table>\n"; 
     284 
     285       return $body; 
    231286} 
    232287 
    233288function profile_files_widget_display($userid) { 
    234     global $CFG; 
    235     $file_list = array(); 
    236     $where1 = run("users:access_level_sql_where",$_SESSION['userid']); 
    237     if ($files = get_records_sql('SELECT * FROM '.$CFG->prefix.'files WHERE files_owner = '.$userid.' AND '.$where1.' LIMIT 9')) { 
    238         $file_count = count_records('files','files_owner',$userid); 
    239         foreach($files as $file) { 
    240             //if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { 
    241                 $file_list[] = (int) $file->ident; 
    242             //} 
    243         } 
    244     } 
    245     if ($file_list) { 
    246         $username = user_info('username',$userid); 
    247         $title = __gettext('Files'); 
    248         $menu = array(array('text' => __gettext('View all'), 'link' => $CFG->wwwroot.$username.'/files', 'title'=>$file_count .' '. ($file_count == 1 ? __gettext("file"):__gettext("files")))); 
    249         $content = profile_show_thumbs($file_list,'files'); 
    250         $widget_array = array('title'=>$title,'menu'=>$menu,'content'=>$content); 
    251     } else { 
    252         $widget_array = array(); 
    253     } 
    254     return $widget_array; 
     289        global $CFG; 
     290        $file_list = array (); 
     291        $where1 = run("users:access_level_sql_where", $_SESSION['userid']); 
     292        if ($files = get_records_sql('SELECT * FROM ' . $CFG->prefix . 'files WHERE files_owner = ' . $userid . ' AND ' . $where1 . ' LIMIT 9')) { 
     293                $file_count = count_records('files', 'files_owner', $userid); 
     294                foreach ($files as $file) { 
     295                        //if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { 
     296                        $file_list[] = (int) $file->ident; 
     297                        //} 
     298                } 
     299        } 
     300        if ($file_list) { 
     301                $username = user_info('username', $userid); 
     302                $title = __gettext('Files'); 
     303                $menu = array ( 
     304                        array ( 
     305                                'text' => __gettext('View all' 
     306                        ), 
     307                        'link' => $CFG->wwwroot . $username . '/files', 
     308                        'title' => $file_count . ' ' . ($file_count == 1 ? __gettext("file" 
     309                ) : __gettext("files")))); 
     310                $content = profile_show_thumbs($file_list, 'files'); 
     311                $widget_array = array ( 
     312                        'title' => $title, 
     313                        'menu' => $menu, 
     314                        'content' => $content 
     315                ); 
     316        } else { 
     317                $widget_array = array (); 
     318        } 
     319        return $widget_array; 
    255320} 
    256321 
    257322function profile_friends_widget_display($userid) { 
    258     global $CFG; 
    259      
    260     $html = ''; 
    261     $friends = array(); 
    262     if ($result = get_records_sql('SELECT DISTINCT u.ident,1 FROM '.$CFG->prefix.'friends f 
    263                                JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
    264                                WHERE f.owner = ? AND u.user_type = ? order by u.last_action desc LIMIT 9',array($userid,'person'))) { 
    265         $friend_count = get_record_sql('SELECT count(*) as count FROM '.$CFG->prefix.'friends f 
    266                                JOIN '.$CFG->prefix.'users u ON u.ident = f.friend 
    267                                WHERE f.owner = ? AND u.user_type = ?',array($userid,'person')); 
    268         foreach($result as $row) { 
    269             $friends[] = (int) $row->ident; 
    270         } 
    271         if ($userid != $_SESSION['userid']) { 
    272             $link = url."_friends/?owner=$userid"; 
    273         } else { 
    274             $link = url.$_SESSION['username']."/friends/"; 
    275         } 
    276         $title = __gettext('Friends'); 
    277         $menu_array = array(array('text' => __gettext('View all Friends'), 'link' => $link, 'title'=>$friend_count->count .' '. ($friend_count->count == 1 ? __gettext("friend"):__gettext("friends")))); 
    278         $content = profile_show_thumbs($friends,'users'); 
    279         $widget_array = array('title'=>$title,'menu'=>$menu_array,'content'=>$content); 
    280     } else { 
    281         $widget_array = array(); 
    282     } 
    283     return $widget_array; 
     323        global $CFG; 
     324 
     325        $html = ''; 
     326        $friends = array (); 
     327        if ($result = get_records_sql('SELECT DISTINCT u.ident,1 FROM ' . $CFG->prefix . 'friends f 
     328                                       JOIN ' . $CFG->prefix . 'users u ON u.ident = f.friend 
     329                                       WHERE f.owner = ? AND u.user_type = ? order by u.last_action desc LIMIT 9', array ( 
     330                        $userid, 
     331                        'person' 
     332                ))) { 
     333                $friend_count = get_record_sql('SELECT count(*) as count FROM ' . $CFG->prefix . 'friends f 
     334                                               JOIN ' . $CFG->prefix . 'users u ON u.ident = f.friend 
     335                                               WHERE f.owner = ? AND u.user_type = ?', array ( 
     336                        $userid, 
     337                        'person' 
     338                )); 
     339                foreach ($result as $row) { 
     340                        $friends[] = (int) $row->ident; 
     341                } 
     342                if ($userid != $_SESSION['userid']) { 
     343                        $link = url . "_friends/?owner=$userid"; 
     344                } else { 
     345                        $link = url . $_SESSION['username'] . "/friends/"; 
     346                } 
     347                $title = __gettext('Friends'); 
     348                $menu_array = array ( 
     349                        array ( 
     350                                'text' => __gettext('View all Friends'), 
     351                                'link' => $link, 
     352                                'title' => $friend_count->count . ' ' . ($friend_count->count == 1 ? __gettext("friend") : __gettext("friends")))); 
     353                $content = profile_show_thumbs($friends, 'users'); 
     354                $widget_array = array ( 
     355                        'title' => $title, 
     356                        'menu' => $menu_array, 
     357                        'content' => $content 
     358                ); 
     359        } else { 
     360                $widget_array = array (); 
     361        } 
     362        return $widget_array; 
    284363} 
    285364 
    286365function profile_widget_edit($widget) { 
    287      
    288     global $CFG, $profile_id, $data, $page_owner; 
    289     static $profile; 
    290      
    291     if ($widget->type == 'profile::profile') { 
    292      
    293         $profile_id = $page_owner; 
    294          
    295         require_once($CFG->dirroot . 'profile/profile.class.php'); 
    296          
    297         $profile_field = widget_get_data("profile_widget_field",$widget->ident); 
    298          
    299         if (!isset($profile)) { 
    300             $profile = new ElggProfile($profile_id); 
    301         } 
    302     &nbs