--- gallery_assist/gallery_assist.module	2010-02-03 05:12:12.000000000 +0100
+++ gallery_assist_2/gallery_assist.module	2010-03-01 04:59:53.000000000 +0100
@@ -365,39 +365,51 @@ function gallery_assist_menu() {
   return $items;
 }
 
-function gallery_assist_list_galleries($user) {
-	$head = array(
+function gallery_assist_list_galleries($u) {
+	global $user;
+  if ($user->uid == 1 || $u->uid == $user->uid) {
+    $profile = '';
+  }
+  else {
+    $profile = 'AND g.in_profile = 1';
+  }
+
+  $head = array(
 		array('data' => t('Items'), 'field' => 'items'),
-		array('data' => t('Created'), 'field' => 'created', 'sort' => 'desc', 'class' => 'ga_created'),
+		array('data' => t('Image'), 'field' => 'tpath'),
+		array('data' => t('Last update'), 'field' => 'timestamp', 'sort' => 'desc', 'class' => 'ga_created'),
 		array('data' => t('Title'), 'field' => 'title', 'class' => 'ga_titles'),
 	);
-  
-  //$count = db_result(db_query("SELECT count( * ) FROM {gallery_assist_item} WHERE nid = ref AND uid = %d GROUP BY nid", $user->uid));
 
-  $q = "SELECT count( * ) as items, n.nid, n.created, n.title
+  $q = "SELECT count( * ) as items, p.tpath, p.nid, g.in_profile, f.timestamp
         FROM {gallery_assist_item} p 
-        JOIN {node} n ON n.nid = p.ref
-        WHERE p.uid = $user->uid 
-        GROUP BY p.gref ". tablesort_sql($head);
-  //$result = pager_query(db_rewrite_sql($q, 'n', 'nid'), 5);
-  $result = db_query(db_rewrite_sql($q, 'n', 'nid'));
+        JOIN {gallery_assist} g ON g.gref = p.gref 
+        JOIN {files} f ON f.fid = p.fid 
+        WHERE p.uid = %d ". $profile ." GROUP BY p.gref ". tablesort_sql($head);
+
+  $result = db_query($q, $u->uid);
 
   $df = t('Y/m/d');
   while ($r = db_fetch_object($result)) {
-    $c[$r->nid] = $r;
+      $node_extras = db_result(db_query(db_rewrite_sql("SELECT n.title FROM {node} n WHERE n.nid = %d"), $r->nid));
+      $c[$r->nid] = $r;
+      $c[$r->nid]->title = $node_extras;
   }
 
-  foreach ($c as $id => $r) {
-    $rows[] = array(
-      array('data' => $r->items),
-      array('data' => format_date($r->created, 'custom', $df)),
-      array('data' => l($r->title, 'node/'. $r->nid)),
-    );
+  if (count($c)) {
+    foreach ($c as $id => $r) {
+      $ipath = preg_replace('/thm\//', 'img/', $r->tpath);
+      $rows[] = array(
+        array('data' => $r->items),
+        array('data' => $r->items > 0 ? theme('image', $ipath, '', '') : 0),
+        array('data' => format_date($r->timestamp, 'custom', $df)),
+        array('data' => l($r->title, 'node/'. $r->nid)),
+      );
+    }
   }
 
-  $output = $count ? '<h3>'. $count .' Galleries</h3>' : '<h3>Galleries</h3>';
-  $output .= theme_table($head, $rows);
-  //$output .= theme('pager', 1, 5);
+  $output = theme('table', $head, $rows);
+  $output .= theme('pager', NULL, 5, $u->uid, NULL, 5);
 
   return $output ? $output : '0 galleries';
 }
@@ -2764,21 +2776,23 @@ function gallery_assist_block($op = 'lis
 }
 
 function _gallery_assist_get_blockdata($u) {
-  $query_str = "SELECT p.pid, p.uid, p.tpath, p.opath, f.timestamp, t.ptitle, g.gid, g.data, n.title, n.type, n.nid
+  $query_str = "SELECT p.pid, p.uid, p.tpath, p.opath, f.timestamp, t.ptitle, g.gid, g.data, p.nid
     FROM {gallery_assist_item} p
     JOIN {gallery_assist_translated} t ON p.pid = t.pid
     JOIN {files} f ON p.fid = f.fid
     JOIN {gallery_assist} g ON p.gid = g.gid 
-    JOIN {node} n ON g.nid = n.nid
     WHERE p.uid = %d
     GROUP BY g.gref
     ORDER BY f.timestamp DESC";
   
-  //$result = db_query(db_rewrite_sql($query_str, 'n', 'nid'), $u);
+  //$result = db_query(db_rewrite_sql($query_str, 'n', 'nid'), $u);db_fetch_object(db_query(
   $result = db_query(db_rewrite_sql($query_str), $u);
   while ($r = db_fetch_object($result)) {
     $count = db_result(db_query("SELECT count(*) FROM {gallery_assist_item} WHERE gid = %d", $r->gid));
+    $node_extras = db_fetch_object(db_query(db_rewrite_sql("SELECT n.title, n.type FROM {node} n WHERE n.nid = %d"), $r->nid));
     $my[$r->nid] = $r;
+    $my[$r->nid]->title = $node_extras->title;
+    $my[$r->nid]->type = $node_extras->type;
   }
   
   return array(
@@ -2795,7 +2809,7 @@ function _gallery_assist_render_blockdat
   $i = 0;
   foreach ($c['result'] as $k => $v) {
     $data = unserialize($v->data);
-    if ($data['show_in_homepage_block'] == 1 && $i < $c['block_data'][$delta]['visibles']) {
+    if ($i < $c['block_data'][$delta]['visibles']) {
       $links[] = l($v->title, 'node/'. $v->nid);
       $uid = $v->uid;
       ++$i;
