function imagepicker_admin_groups_list in Image Picker 7
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_admin_groups_list()
- 6.2 imagepicker.admin.inc \imagepicker_admin_groups_list()
1 call to imagepicker_admin_groups_list()
File
- ./
imagepicker.admin.inc, line 993 - @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function imagepicker_admin_groups_list($label = "") {
$max = imagepicker_variable_get('imagepicker_rows_per_page', 25);
$use_icons = imagepicker_variable_get('imagepicker_use_icons', 1);
$rows = NULL;
$header = array(
array(
'data' => t('Group Name'),
'field' => 'g.group_name',
),
array(
'data' => t('User Name'),
'field' => 'u.name',
),
array(
'data' => t('Status'),
'field' => 'g.public',
),
array(
'data' => t('Images'),
'field' => 'ct',
),
array(
'data' => t('Actions'),
'colspan' => 2,
),
);
$countquery = db_select('imagepicker_user_groups', 'g');
$countquery
->addExpression('COUNT(g.gid)', 'ct');
$query = db_select('imagepicker_user_groups', 'g')
->extend('PagerDefault')
->limit($max)
->extend('TableSort')
->orderByHeader($header);
$query
->setCountQuery($countquery);
$query
->fields('g', array(
'gid',
'uid',
'group_name',
'public',
))
->addField('u', 'name');
$query
->addExpression('COUNT(i.img_id)', 'ct');
$query
->leftjoin('imagepicker_group_images', 'i', 'g.gid = i.gid');
$query
->leftjoin('users', 'u', 'g.uid = u.uid');
$query
->groupBy('g.gid');
$records = $query
->execute();
foreach ($records as $row) {
// get image count
$ict = $row->ct;
$editpath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row->uid . '/edit/' . $row->gid;
$deletepath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row->uid . '/delete/' . $row->gid;
$row_data = array(
$row->group_name,
l($row->name, IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row->uid),
$row->public ? t('Public') : t('Private'),
$ict ? l(format_plural($ict, '1 image', '@count images'), IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $row->uid . '/browse/' . $row->gid) : t('No images'),
$use_icons ? _imagepicker_get_icon('edit', $editpath, array(
'title' => t('Edit'),
)) : l(t('Edit'), $editpath),
$use_icons ? _imagepicker_get_icon('delete', $deletepath, array(
'title' => t('Delete'),
)) : l(t('Delete'), $deletepath),
);
$rows[] = $row_data;
}
$pref = '';
$suff = '';
return theme('imagepicker_list', array(
'header' => $header,
'rows' => $rows,
'max' => $max,
'message' => t('No groups found.'),
'pref' => $pref,
'suff' => $suff,
'label' => $label,
));
}