function imagepicker_groups_list in Image Picker 6.2
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_groups_list()
- 5 imagepicker.module \imagepicker_groups_list()
- 7 imagepicker.group.inc \imagepicker_groups_list()
3 calls to imagepicker_groups_list()
- imagepicker_admin_groups in ./
imagepicker.admin.inc - imagepicker_groups in ./
imagepicker.group.inc - @file contains the functions for group management
- imagepicker_user_groups in ./
imagepicker.group.inc - groups from imagepicker groups in my account
File
- ./
imagepicker.group.inc, line 274 - contains the functions for group management
Code
function imagepicker_groups_list($src = FALSE, $account = FALSE, $label = "") {
if ($account) {
$user = $account;
}
else {
global $user;
}
if ($src) {
if ($src == 'admin') {
$editpath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $user->uid . '/edit/';
$deletepath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $user->uid . '/delete/';
$browsepath = IMAGEPICKER_ADMIN_PATH . '/groups/user/' . $user->uid . '/browse/';
}
else {
$editpath = 'user/' . $user->uid . '/imagepicker/groups/edit/';
$deletepath = 'user/' . $user->uid . '/imagepicker/groups/delete/';
$browsepath = 'user/' . $user->uid . '/imagepicker/groups/browse/';
}
}
else {
$editpath = "imagepicker/groups/edit/";
$deletepath = "imagepicker/groups/delete/";
$browsepath = 'imagepicker/groups/';
}
$content = "";
$how_many = variable_get('imagepicker_rows_per_page', 25);
$use_icons = variable_get('imagepicker_use_icons', 1);
if (user_access('use public imagepicker') && variable_get('imagepicker_public_enabled', 1)) {
$header = array(
array(
'data' => t('Group name'),
'field' => 'g.group_name',
),
array(
'data' => t('Description'),
'field' => 'g.group_description',
),
array(
'data' => t('No. images'),
'field' => 'ct',
),
t('State'),
array(
'data' => t('Public'),
'field' => 'g.public',
),
array(
'data' => t('Actions'),
'colspan' => 2,
),
);
$cols = 7;
}
else {
$header = array(
array(
'data' => t('Group name'),
'field' => 'g.group_name',
),
array(
'data' => t('Description'),
'field' => 'g.group_description',
),
array(
'data' => t('No. images'),
'field' => 'ct',
),
t('State'),
array(
'data' => t('Actions'),
'colspan' => 2,
),
);
$cols = 6;
}
$countsql = "SELECT COUNT(DISTINCT(g.gid)) FROM {imagepicker_user_groups} g JOIN {imagepicker_group_images} u USING(gid) WHERE g.uid=%d";
$sql = "SELECT g.gid, g.group_name, g.group_description, g.public, COUNT(i.img_id) AS ct\n FROM {imagepicker_user_groups} g LEFT JOIN {imagepicker_group_images} i USING(gid)\n WHERE g.uid=%d\n GROUP BY g.gid, g.group_name, g.group_description, g.public" . tablesort_sql($header);
$result = pager_query($sql, $how_many, 0, $countsql, array(
$user->uid,
));
$rows = array();
$totcount = 0;
$rowcount = 0;
$enabledlist = imagepicker_get_enabled_group($account);
while ($row = db_fetch_array($result)) {
if (user_access('use public imagepicker') && variable_get('imagepicker_public_enabled', 1)) {
$row_data = array(
$row['group_name'],
$row['group_description'],
$row['ct'] && $browsepath ? l($row['ct'], $browsepath . $row['gid']) : $row['ct'],
$enabledlist && in_array($row['gid'], $enabledlist) ? t('selected') : '',
$row['public'] ? t('Yes') : t('No'),
$use_icons ? _imagepicker_get_icon('edit', $editpath . $row['gid'], array(
'title' => t('Edit'),
)) : l(t('Edit'), $editpath . $row['gid']),
$use_icons ? _imagepicker_get_icon('delete', $deletepath . $row['gid'], array(
'title' => t('Delete'),
)) : l(t('Delete'), $deletepath . $row['gid']),
);
}
else {
$row_data = array(
$row['group_name'],
$row['group_description'],
$row['ct'] && $browsepath ? l($row['ct'], $browsepath . $row['gid']) : $row['ct'],
$enabledlist && in_array($row['gid'], $enabledlist) ? t('selected') : '',
$use_icons ? _imagepicker_get_icon('edit', $editpath . $row['gid'], array(
'title' => t('Edit'),
)) : l(t('Edit'), $editpath . $row['gid']),
$use_icons ? _imagepicker_get_icon('delete', $deletepath . $row['gid'], array(
'title' => t('Delete'),
)) : l(t('Delete'), $deletepath . $row['gid']),
);
}
$rows[] = $row_data;
$rowcount++;
}
return theme('imagepicker_list', $header, $rows, $how_many, t('No groups found.'), '<div class="imgp_groups_list">', '</div>', $label, $cols);
}