quota.php 755 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * User quota
  4. */
  5. $user = elgg_get_logged_in_user_entity();
  6. $quota = elgg_get_plugin_setting('quota', 'tidypics');
  7. if ($quota) {
  8. $image_repo_size = (int)$user->image_repo_size;
  9. $image_repo_size = $image_repo_size / 1024 / 1024;
  10. $quote_percentage = round(100 * ($image_repo_size / $quota));
  11. // for small quotas, so one decimal place
  12. if ($quota < 10) {
  13. $image_repo_size = sprintf('%.1f', $image_repo_size);
  14. } else {
  15. $image_repo_size = round($image_repo_size);
  16. }
  17. if ($image_repo_size > $quota) {
  18. $image_repo_size = $quota;
  19. }
  20. $title = elgg_echo('tidypics:title:quota');
  21. $body = elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)";
  22. echo elgg_view_module('aside', $title, $body);
  23. }