function _imagepicker_browse_admin in Image Picker 5.2
Same name and namespace in other branches
- 5 imagepicker.module \_imagepicker_browse_admin()
- 6.2 imagepicker.functions.inc \_imagepicker_browse_admin()
- 7 imagepicker.functions.inc \_imagepicker_browse_admin()
2 calls to _imagepicker_browse_admin()
File
- ./
imagepicker.module, line 2276 - Enables permitted roles to upload images for insertion into configured nodes.
Code
function _imagepicker_browse_admin($src = "iframe", $account = FALSE, $public = FALSE, $range = 1) {
if ($account) {
$user = $account;
}
else {
global $user;
}
$content = "";
// paths
if ($src == 'iframe') {
$editpath = "imagepicker/edit/";
$deletepath = "imagepicker/delete/";
$imgpath = 'imagepicker/browse/';
}
elseif ($src == 'admin') {
$editpath = 'admin/settings/imagepicker/images/user/' . $user->uid . '/edit/';
$deletepath = 'admin/settings/imagepicker/images/user/' . $user->uid . '/delete/';
$imgpath = 'admin/settings/imagepicker/images/user/' . $user->uid . '/browse/';
}
else {
$editpath = 'user/' . $user->uid . '/imagepicker/images/edit/';
$deletepath = 'user/' . $user->uid . '/imagepicker/images/delete/';
$imgpath = 'user/' . $user->uid . '/imagepicker/images/browse/';
}
// if there are groups
$gid = 0;
if (!$public) {
if (_imagepicker_has_groups($src == 'admin' ? $user : FALSE) && imagepicker_has_grouplist($src == 'admin' ? $user : FALSE)) {
// add groups select here
$content .= drupal_get_form('imagepicker_browse_groups_form', $src == 'admin' ? $user : FALSE);
$gids = imagepicker_get_user_group_state(1, $src == 'admin' ? $user : FALSE);
$gid = $gids[0];
if ($account) {
$gid = variable_get('imagepicker_currentgroup', 0);
}
}
}
$how_many = variable_get('imagepicker_advanced_browser_page', 25);
// tablesort
if ($public && $src == 'admin') {
$header = array(
array(
'data' => t('Name'),
'field' => 'i.img_name',
),
array(
'data' => t('Title'),
'field' => 'i.img_title',
),
t('Description'),
array(
'data' => t('User'),
'field' => 'n.name',
),
array(
'data' => t('Date'),
'field' => 'i.img_date',
),
array(
'data' => t('Actions'),
'colspan' => 2,
),
);
}
else {
$header = array(
array(
'data' => t('Name'),
'field' => 'i.img_name',
),
array(
'data' => t('Title'),
'field' => 'i.img_title',
),
t('Description'),
array(
'data' => t('Date'),
'field' => 'i.img_date',
),
array(
'data' => t('Actions'),
'colspan' => 2,
),
);
}
if ($public && $src == 'admin') {
if ($range == 1) {
$sql = "SELECT i.img_id, i.uid, i.img_name, i.img_title, i.img_description, i.img_date, n.name\n FROM {imagepicker} i, {users} n, {imagepicker_user_groups} u, {imagepicker_group_images} g\n WHERE i.uid = n.uid\n AND u.public = 1\n AND g.img_id = i.img_id\n AND u.gid = g.gid" . tablesort_sql($header);
}
elseif ($range == 2) {
$sql = "SELECT i.img_id, i.uid, i.img_name, i.img_title, i.img_description, i.img_date, n.name\n FROM {imagepicker} i, {users} n, {imagepicker_user_groups} u, {imagepicker_group_images} g\n WHERE i.uid = n.uid\n AND u.public = 0\n AND g.img_id = i.img_id\n AND u.gid = g.gid" . tablesort_sql($header);
}
else {
$sql = "SELECT DISTINCT i.img_id, i.uid, i.img_name, i.img_title, i.img_description, i.img_date, n.name\n FROM {imagepicker} i, {users} n\n WHERE i.uid = n.uid" . tablesort_sql($header);
}
$result = pager_query($sql, $how_many, 0, NULL);
}
else {
// filter by selected group
if ($gid) {
$sql = "SELECT i.img_id, i.uid, i.img_name, i.img_title, i.img_description, i.img_date\n FROM {imagepicker} i, {imagepicker_group_images} g\n WHERE i.uid = %d AND i.img_id = g.img_id AND g.gid = %d" . tablesort_sql($header);
$result = pager_query($sql, $how_many, 0, NULL, array(
$user->uid,
$gid,
));
}
else {
$sql = "SELECT i.img_id, i.uid, i.img_name, i.img_title, i.img_description, i.img_date\n FROM {imagepicker} i\n WHERE i.uid=%d" . tablesort_sql($header);
$result = pager_query($sql, $how_many, 0, NULL, array(
$user->uid,
));
}
}
$rows = array();
while ($row = db_fetch_array($result)) {
// img_id img_name img_title img_description
$img_name = check_plain($row['img_name']);
$description = check_plain($row['img_description']);
if (drupal_strlen($description) > 30) {
$description = drupal_substr($description, 0, 30) . '...';
}
if ($public && $src == 'admin') {
$editpath = 'admin/settings/imagepicker/images/user/' . $row['uid'] . '/edit/';
$deletepath = 'admin/settings/imagepicker/images/user/' . $row['uid'] . '/delete/';
$imgpath = 'admin/settings/imagepicker/images/user/' . $row['uid'] . '/browse/';
$listpath = 'admin/settings/imagepicker/images/user/' . $row['uid'] . '/browseadmin';
$row_data = array(
l($img_name, $imgpath . $row['img_id']),
check_plain($row['img_title']),
$description,
l($row['name'], $listpath),
check_plain($row['img_date']),
l(t('Edit'), $editpath . $row['img_id']),
l(t('Delete'), $deletepath . $row['img_id']),
);
}
else {
$row_data = array(
l($img_name, $imgpath . $row['img_id']),
check_plain($row['img_title']),
$description,
check_plain($row['img_date']),
l(t('Edit'), $editpath . $row['img_id']),
l(t('Delete'), $deletepath . $row['img_id']),
);
}
$rows[] = $row_data;
}
if (count($rows)) {
if ($public && $src == 'admin') {
$content .= drupal_get_form('imagepicker_browse_public_form');
}
$content .= '<div class="imgp_imgs_list">';
$content .= theme('table', $header, $rows) . theme('pager', NULL, $how_many);
$content .= '</div>';
}
else {
$content = '<div class="messages">' . t('You do not have any uploaded images') . '</div>';
}
return $content;
}