function imagepicker_quota_ok in Image Picker 5.2
Same name and namespace in other branches
- 6.2 imagepicker.functions.inc \imagepicker_quota_ok()
- 7 imagepicker.functions.inc \imagepicker_quota_ok()
3 calls to imagepicker_quota_ok()
- imagepicker_admin_images in ./
imagepicker.module - imagepicker_upload in ./
imagepicker.module - Menu callback; presents the upload form for imagepicker
- imagepicker_user_upload in ./
imagepicker.module
File
- ./
imagepicker.module, line 4284 - Enables permitted roles to upload images for insertion into configured nodes.
Code
function imagepicker_quota_ok($src, $account = FALSE) {
if ($account) {
$user = $account;
}
else {
global $user;
}
$usedbytes = imagepicker_get_all_bytes($user) + 1;
$usedbytesprint = _imagepicker_bkmg($usedbytes);
$quota = 0;
$quota_enabled = variable_get('imagepicker_quota_enable', 1);
if ($quota_enabled) {
$quota = isset($user->imagepicker_quota) ? $user->imagepicker_quota : variable_get('imagepicker_quota_default', 1);
if ($quota > 0) {
$quota_ok = $quota * 1000000 > $usedbytes ? TRUE : FALSE;
}
else {
$quota_ok = TRUE;
}
}
else {
$quota_ok = TRUE;
}
$imgtot = _imagepicker_user_has_img($user);
if ($quota_enabled) {
if ($quota > 0) {
$pused = round($usedbytes / ($quota * 1000000) * 100, 2);
$quotaprint = imagepicker_get_quota_list($quota + 1);
if ($src == 'admin') {
$content .= '<p class="messages">' . t('The quota for %name is %quotaprint and has used %pused percent, or %usedbytesprint in %imgtot images', array(
'%name' => $user->name,
'%quotaprint' => $quotaprint,
'%pused' => $pused,
'%usedbytesprint' => $usedbytesprint,
'%imgtot' => $imgtot,
)) . '</p>';
}
else {
$content .= '<p class="messages">' . t('Your quota is %quotaprint and you have used %pused percent, or %usedbytesprint in %imgtot images', array(
'%quotaprint' => $quotaprint,
'%pused' => $pused,
'%usedbytesprint' => $usedbytesprint,
'%imgtot' => $imgtot,
)) . '</p>';
}
}
else {
$quotaprint = imagepicker_get_quota_list($quota + 1);
if ($src == 'admin') {
$content .= '<p class="messages">' . t('The quota for %name is %quotaprint and has used %usedbytesprint in %imgtot images', array(
'%name' => $user->name,
'%quotaprint' => $quotaprint,
'%usedbytesprint' => $usedbytesprint,
'%imgtot' => $imgtot,
)) . '</p>';
}
else {
$content .= '<p class="messages">' . t('Your quota is %quotaprint and you have used %usedbytesprint in %imgtot images', array(
'%quotaprint' => $quotaprint,
'%usedbytesprint' => $usedbytesprint,
'%imgtot' => $imgtot,
)) . '</p>';
}
}
}
else {
if ($src == 'admin') {
$content .= '<p class="messages">' . t('%name has used %usedbytesprint in %imgtot images', array(
'%name' => $user->name,
'%usedbytesprint' => $usedbytesprint,
'%imgtot' => $imgtot,
)) . '</p>';
}
else {
$content .= '<p class="messages">' . t('You have used %usedbytesprint in %imgtot images', array(
'%usedbytesprint' => $usedbytesprint,
'%imgtot' => $imgtot,
)) . '</p>';
}
}
if ($quota_ok) {
if ($account) {
if ($src == 'admin') {
$content .= drupal_get_form('imagepicker_upload_form', $user, TRUE);
}
elseif ($src == 'user') {
$content .= drupal_get_form('imagepicker_upload_form', $user);
}
}
else {
$content .= drupal_get_form('imagepicker_upload_form');
}
}
else {
if ($account) {
$content .= '<p class="messages">' . t('%name has used all of quota, please delete some files to make some room.', array(
'%name' => $user->name,
)) . '</p>';
}
else {
$content .= '<p class="messages">' . t('You have used all of your quota, please delete some files to make some room.') . '</p>';
}
}
return $content;
}