You are here

function photos_share in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.page.inc \photos_share()
1 string reference to 'photos_share'
photos_menu in ./photos.module

File

inc/photos.page.inc, line 83

Code

function photos_share() {
  global $user;
  $order = explode('|', variable_get('photos_display_imageorder', 'timestamp|desc'));
  $order = _photos_order_value_change($order[0], $order[1]);
  $term = _photos_order_value($_GET['field'], $_GET['sort'], 20, $order);
  if (arg(2) != 'all') {
    $result = pager_query('SELECT f.fid, f.filepath, f.filemime, f.filename FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid WHERE f.uid = %d' . $term['order'], $term['limit'], 0, NULL, $user->uid);
    $images['menu'] = _photos_order_link('photos/share', 0, 0, 1);
  }
  else {
    $result = pager_query(db_rewrite_sql('SELECT f.fid, f.filepath, f.filemime, f.timestamp, f.filename, f.filesize, u.uid, u.name FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid INNER JOIN {users} u ON f.uid = u.uid WHERE f.uid != %d' . $term['order'], 'p', 'pid'), $term['limit'], 0, NULL, $user->uid);
    $images['menu'] = _photos_order_link('photos/share/all', 0, 0, 1);
  }
  $label = variable_get('photos_title_0', false);
  while ($data = db_fetch_array($result)) {
    $image = photos_get_info(0, $data);
    if (is_array($image['thumb'])) {
      foreach ($image['thumb'] as $key => $thumb) {
        $thumbs[$key] = _photos_l($thumb);
      }
    }
    if ($data['name']) {
      $username = t('By: !name', array(
        '!name' => l($data['name'], "photos/user/{$data['uid']}/image"),
      ));
    }
    $share[] = array(
      'link' => _photos_l('photos/image/' . $image['fid']),
      'fid' => $image['fid'],
      'filename' => $image['filename'],
      'thumbs' => $thumbs,
      'username' => $username,
      'view' => theme('photos_imagehtml', $image['thumb'][$label], array(
        'filename' => $image['filename'],
      )),
    );
  }
  $images['links'] = l(t('« Back'), 'photos') . l(t('My images'), 'photos/share') . l(t('All the shared images'), 'photos/share/all');
  $images['data'] = $share[0]['fid'] ? $share : '';
  $v .= theme('photos_share', $images, 'image');
  $v .= theme('pager', NULL, $term['limit']);
  print $v;
}