Location: PHPKode > projects > Teampopor > teampopor-0.5/teampopor/modules/network/network-files.tpl.php
<?php
/**
 * page callback: network/%network/files
 *
 * @param $network
 * @param filter
 */

global $user;
$groups = array(l($network->name, 'network/' . $network->nid . '/files/0'));
$result = db_query("SELECT g.* FROM {group_members} gm LEFT JOIN {groups} g ON g.gid = gm.gid WHERE gm.uid = %d AND g.nid = %d", $user->uid, $network->nid);
while ($group = db_fetch_object($result)) {
  $groups[] = l($group->name, 'network/' . $network->nid . '/files/' . $group->gid);
}
$menu = array(
  l(t('Recent Files'), 'network/' . $network->nid . '/files'),
  l(t('Files I Followed'), 'network/' . $network->nid . '/files/followed'),
  l(t('Files I Uploaded'), 'network/' . $network->nid . '/files/uploaded'),
  $groups,
);
?>
<div class="feed feed-nhome">
  <div class="header">
    <?php print theme('menu', $menu); ?>
  </div>

  <?php
  global $user;

  if (is_string($filter)) {
    switch ($filter) {
      case 'recent':
        // joined groups
        $gids = array();
        $result = db_query("SELECT gm.gid FROM {group_members} gm LEFT JOIN {groups} g ON g.gid = gm.gid WHERE g.nid = %d AND gm.uid = %d", $network->nid, $user->uid);
        while ($row = db_fetch_object($result)) {
          $gids[] = $row->gid;
        }

        $result = db_query_range("SELECT * FROM {files} WHERE nid = %d AND gid IN (" . implode(',', array_merge($gids, array(0))) . ") ORDER BY created DESC", $network->nid, 0, 20);
        break;
      case 'followed':
      case 'uploaded':
        $result = db_query_range("SELECT * FROM {files} WHERE nid = %d AND uid = %d ORDER BY created DESC", $network->nid, $user->uid, 0, 20);
        break;
    }
  }
  else {
    $result = db_query_range("SELECT * FROM {files} WHERE nid = %d AND gid =%d ORDER BY created DESC", $network->nid, $filter, 20);
  }
  ?>
  <div class="content">
    <div id="feed-content">
      <ul class="chron">
        <?php while ($file = db_fetch_object($result)) { ?>
          <?php file_prepare($file) ?>
          <?php print theme('file_item', $file, $network) ?>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>
Return current item: Teampopor