function imagepicker_admin_images in Image Picker 7
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_admin_images()
- 6.2 imagepicker.admin.inc \imagepicker_admin_images()
1 string reference to 'imagepicker_admin_images'
- imagepicker_menu in ./
imagepicker.module - Implement hook_menu().
File
- ./
imagepicker.admin.inc, line 1467 - @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function imagepicker_admin_images() {
drupal_add_css(IMAGEPICKER_PATH . '/imagepicker.css');
$action = FALSE;
$imgaction = FALSE;
$img_id = FALSE;
$content = '';
if (!arg(5)) {
imagepicker_variable_del('imagepicker_currentuser');
imagepicker_variable_set('imagepicker_currentgroup', 0);
$action = 'users';
}
$uid = imagepicker_variable_get('imagepicker_currentuser', '');
if (arg(5) == 'user' && is_numeric(arg(6))) {
$uid = arg(6);
}
elseif (arg(5) == 'browse_public' || arg(5) == 'stats' || arg(5) == 'users' || arg(5) == 'list_public') {
$action = arg(5);
imagepicker_variable_del('imagepicker_currentuser');
imagepicker_variable_set('imagepicker_currentgroup', 0);
$uid = imagepicker_variable_get('imagepicker_currentuser', '');
}
if (arg(7) == 'browse_public' || arg(7) == 'browse' || arg(7) == 'edit' || arg(7) == 'delete' || arg(7) == 'browseadmin' || arg(7) == 'upload' || arg(7) == 'stats' || arg(7) == 'groups' || arg(7) == 'quota') {
$imgaction = arg(7);
}
if (is_numeric(arg(8))) {
$img_id = arg(8);
}
if (arg(7) == 'upload') {
module_load_include('inc', 'imagepicker', 'imagepicker.upload');
if (imagepicker_variable_get('imagepicker_upload_progress_enabled', 1)) {
$content .= imagepicker_upload_progress_get_script(imagepicker_variable_get('imagepicker_upload_progress_delay', 0));
}
}
$name = "";
if ($uid) {
$account = user_load($uid);
$name = $account->name;
}
$form = drupal_get_form('imagepicker_user_search_form', 'images');
$content .= render($form);
$content .= '<p>' . t('Managing images for !n', array(
'!n' => $name ? l($name, "user/{$uid}") : t('All'),
)) . '</p>';
if ($uid) {
if ($img_id) {
if ($imgaction == 'edit') {
module_load_include('inc', 'imagepicker', 'imagepicker.edit');
$img = _imagepicker_get_img($img_id, FALSE, $account);
$imgsrc = imagepicker_get_image_path($img, 'browser', array(
'uid' => $account->uid,
'name' => $account->name,
));
$content .= theme('imagepicker_image_edit_header', array(
'image' => $img,
'source' => $imgsrc,
));
$form = drupal_get_form('imagepicker_edit_form', $img, 'admin', $account);
$content .= render($form);
}
elseif ($imgaction == 'delete') {
imagepicker_image_delete($img_id, $account, 'admin');
}
else {
$content .= imagepicker_adminview($img_id, $account);
}
}
elseif ($imgaction == 'upload') {
$content .= imagepicker_quota_ok('admin', $account, t('Upload file for %name', array(
'%name' => $name,
)));
}
elseif ($imgaction == 'stats') {
$content .= imagepicker_group_stats($account, t('Statistics for %name', array(
'%name' => $name,
)));
}
elseif ($imgaction == 'browseadmin') {
$content .= _imagepicker_browse_admin('admin', $account, FALSE, 1, t('List images for %name', array(
'%name' => $name,
)));
}
elseif ($imgaction == 'quota') {
$usedbytes = imagepicker_get_all_bytes($account) + 1;
$usedbytesprint = _imagepicker_bkmg($usedbytes);
$quota = 0;
if (imagepicker_variable_get('imagepicker_quota_enable', 1)) {
if (imagepicker_variable_get('imagepicker_quota_byrole', 0)) {
$roleid = imagepicker_variable_get('imagepicker_quota_role', 2);
if (imagepicker_user_has_role($roleid, $account) && $account->uid > 1) {
$quota = imagepicker_variable_get('imagepicker_quota_default', 0);
}
}
else {
$quota = imagepicker_variable_get('imagepicker_quota_default', imagepicker_variable_get('imagepicker_quota_default', 0), $account->uid);
}
}
$label = t('Quota for %name', array(
'%name' => $name,
));
$imgtot = _imagepicker_user_has_img($account);
$pl = format_plural($imgtot, '1 image', '@count images');
if ($quota) {
$pused = round($usedbytes / ($quota * 1000000) * 100, 2);
$message = t('User %name has used %pused percent or %usedbytesprint of quota %quotaprint and has %pl.', array(
'%name' => $name,
'%pused' => $pused,
'%usedbytesprint' => $usedbytesprint,
'%pl' => $pl,
'%quotaprint' => imagepicker_get_quota_list($quota + 1),
));
}
else {
$message = t('User %name has used %usedbytesprint and has %pl.', array(
'%name' => $name,
'%usedbytesprint' => $usedbytesprint,
'%pl' => $pl,
));
}
$form = '';
if (!imagepicker_variable_get('imagepicker_quota_byrole', 0)) {
$form = drupal_get_form('imagepicker_quota_form', $account);
}
$content .= theme('imagepicker_quota', array(
'quotaform' => $form,
'message' => $message,
'label' => $label,
));
}
elseif ($imgaction == 'groups') {
drupal_goto(IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $uid);
}
else {
$content .= _imagepicker_browse('admin', $account, t('Browse images for %name', array(
'%name' => $name,
)));
}
}
else {
if ($action == 'stats') {
$content .= imagepicker_group_stats(FALSE, t('Statistics'));
}
elseif ($action == 'browse_public') {
$content .= _imagepicker_browse_public('admin', imagepicker_variable_get('imagepicker_browse_public', 0), t('Browse All Images'));
}
elseif ($action == 'list_public') {
$content .= _imagepicker_browse_admin('admin', FALSE, TRUE, imagepicker_variable_get('imagepicker_browse_public', 0), t('List All Images'));
}
else {
$label = t('Users');
$content .= imagepicker_admin_users_list('images', $label);
}
}
return $content;
}