Hi,
Hi I wanted to show the total file upload space used by the user on his profile page,by using following query.
db_result(db_query("SELECT SUM(filesize) FROM {files} WHERE uid = %d", $uid));
Which function I need to so the changes and add the field for this result.Thanks in advance.

Comments

PawelR’s picture

you can copy user-profile.tpl file from /modules/user/ to your theme folder and amend it to show your additional information.

maheshg85’s picture



function hook_user($op, &$edit, &$account, $category = NULL) {
  if($op == 'view') {    
    global $user;
  
    $space_used= db_result(db_query("SELECT SUM(size) FROM {filedepot_files} WHERE submitter = %d", $user->uid)); 
    $space_used_inMB=($space_used/1024)/1024;
  
    $rid=db_result(db_query("SELECT ur.rid as rid FROM users_roles as ur, role_weights as rw  where rw.rid = ur.rid and ur.uid = '%d' 
 order by weight asc limit 1", $user->uid)); 
    if($user->uid != 1){
      $userlimit  = variable_get(upload_usersize_.$rid,$rid);
      $inPerc   = (($space_used_inMB/$userlimit)*100);
      $remaining  = (100-$inPerc);
      //Total Upload Space Limit : ".$userlimit."MB<br/><br/>
      $output = "<span style='color:Green'>"."
<b>
Space Used : ".round($space_used_inMB,2)."MB (".round($inPerc,0)."%)&nbsp;&nbsp;<span style='color:#888888;'>Assigned : ".$userlimit."MB</span><br/>
Space Available: ".round((((($userlimit*1024*1024))-$space_used)/1024/1024),2)."MB</b>"."</span>";
      $account->content['og_gsu_support'] = array(
'#type' => 'user_profile_item',
'#title' => t('<div class = "profile"> <h3>Space </h3></div>'),
'#value' => $output,
'#weight' => 200,
      );   
    }   
   
  }
}