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

add_js(get_path('module', 'network') . '/network_updates.js');

global $theme;
add_css(get_path('theme', $theme) . '/network_updates.css');

global $user;
?>
<div class="feed feed-nhome">
  <div class="post-home">
    <div class="post-module">
      <div class="post-module-in">
        <?php print get_form('share_form', $network) ?>
      </div>
    </div>
  </div>
  <div class="header">
        <?php
        /**
Feeds types:
following - Messages from people you're following and groups you're in.
received - Messages @addressed to you.
private - Private messages you've sent and received
sent - Messages you've sent
liked - Messages you've liked
bookmarked - Messages you've bookmarked
all - All non-private messages within your network
groups - Messages posted to your groups
         */
        $more = array(
          t('More'),
          l(t('Sent'), 'network/' . $network->nid, array('query' => 'type=sent')),
          l(t('Liked'), 'network/' . $network->nid, array('query' => 'type=liked')),
          l(t('Bookmarked'), 'network/' . $network->nid, array('query' => 'type=bookmarked')),
          l(t('All'), 'network/' . $network->nid, array('query' => 'type=all')),
          l(t('Groups'), 'network/' . $network->nid, array('query' => 'type=groups')),
        );
        $menu = array(
          l(t('My Feed'), 'network/' . $network->nid, array('query' => 'type=following')),
          l(t('Received'), 'network/' . $network->nid, array('query' => 'type=received')),
          l(t('Direct Messages'), 'network/' . $network->nid, array('query' => 'type=private')),
          $more,
        );
        print theme('menu', $menu);
        ?>
  </div>
  <div class="content">
    <div id="feed-content">
      <?php
      $type = $_GET['type'];
      if (empty($type)) {
        $type = 'following';
      }

      switch ($type) {
        case 'following':
          // 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;
          }

          // followed tags
          $tids = array();
          $result = db_query("SELECT tf.tid FROM {tag_follows} tf LEFT JOIN {tags} t ON t.tid = tf.tid WHERE t.nid = %d AND tf.uid = %d", $network->nid, $user->uid);
          while ($row = db_fetch_object($result)) {
            $tids[] = $row->tid;
          }

          if (empty($gids)) {
            if (empty($tids)) {
              if (db_result(db_query("SELECT COUNT(*) FROM {follows} WHERE uid = %d", $user->uid))) {
                // no joined group, has followee, no followed tag
                $result = db_query_range("SELECT * FROM {messages} WHERE type >= 0 AND thread_mid = 0 AND nid = %d AND gid = 0 AND (uid = %d OR uid IN (SELECT followee_uid FROM {follows} WHERE uid = %d)) ORDER BY timestamp DESC", $network->nid, $user->uid, $user->uid, 0, 20);
              }
              else {
                // if no joined group, no followee, no followed tag, then display all messages.
                $result = db_query_range("SELECT * FROM {messages} WHERE type >= 0 AND thread_mid = 0 AND nid = %d AND gid = 0 ORDER BY timestamp DESC", $network->nid, 0, 20);
              }
            }
            else {
              // no joined group, has followed tags
              $result = db_query_range("SELECT * FROM {messages} WHERE type >= 0 AND thread_mid = 0 AND nid = %d AND gid = 0 AND (uid = %d OR uid IN (SELECT followee_uid FROM {follows} WHERE uid = %d) OR mid IN (SELECT mid FROM {message_tags} WHERE tid IN (" . implode(',', $tids) . "))) ORDER BY timestamp DESC", $network->nid, $user->uid, $user->uid, 0, 20);
            }
          }
          else {
            if (empty($tids)) {
              // has joined group, no followed tag
              $result = db_query_range("SELECT * FROM {messages} WHERE type >= 0 AND thread_mid = 0 AND nid = %d AND gid IN (" . implode(',', array_merge($gids, array(0))) . ") AND (uid = %d OR uid IN (SELECT followee_uid FROM {follows} WHERE uid = %d) OR uid IN (SELECT uid FROM {group_members} WHERE gid IN (" . implode(',', $gids) . "))) ORDER BY timestamp DESC", $network->nid, $user->uid, $user->uid, 0, 20);
            }
            else {
              // has joined group, has followed tags
              $result = db_query_range("SELECT * FROM {messages} WHERE type >= 0 AND thread_mid = 0 AND nid = %d AND gid IN (" . implode(',', array_merge($gids, array(0))) . ") AND (uid = %d OR uid IN (SELECT followee_uid FROM {follows} WHERE uid = %d) OR uid IN (SELECT uid FROM {group_members} WHERE gid IN (" . implode(',', $gids) . ")) OR mid IN (SELECT mid FROM {message_tags} WHERE tid IN (" . implode(',', $tids) . "))) ORDER BY timestamp DESC", $network->nid, $user->uid, $user->uid, 0, 20);
            }
          }
          break;
        case 'received':
          $result = db_query_range("SELECT m.* FROM {recipients} r LEFT JOIN {messages} m ON m.mid = r.mid WHERE m.type >= 0 AND r.uid = %d AND m.nid = %d", $user->uid, $network->nid, 0, 20);
          break;
        case 'private':
          $result = db_query_range("SELECT m.* FROM {recipients} r LEFT JOIN {messages} m ON m.mid = r.mid WHERE m.type < 0 AND m.nid = %d AND (r.uid = %d OR m.uid = %d)", $network->nid, $user->uid, $user->uid, 0, 20);
          break;
        case 'sent':
          $result = db_query_range("SELECT * FROM {messages} WHERE thread_mid = 0 AND nid = %d AND uid = %d ORDER BY timestamp DESC", $network->nid, $user->uid, 0, 20);
          break;
        case 'liked':
          $result = db_query_range("SELECT m.* FROM {likes} l LEFT JOIN {messages} m ON m.mid = l.mid WHERE m.thread_mid = 0 AND l.uid = %d AND m.nid = %d", $user->uid, $network->nid, 0, 20);
          break;
        case 'bookmarked':
        case 'all':
          // 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("SELECT * FROM {messages} WHERE type >= 0 AND thread_mid = 0 AND nid = %d AND gid IN (" . implode(',', array_merge($gids, array(0))) . ") ORDER BY timestamp DESC", $network->nid);
          break;
        case 'groups':
          // 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;
          }

          if (empty($gids)) {
            $result = db_query_range("SELECT * FROM {messages} WHERE thread_mid = 0 AND nid = %d AND gid = 0 ORDER BY timestamp DESC", $network->nid, 0, 20);
          } else {
            $result = db_query_range("SELECT * FROM {messages} WHERE thread_mid = 0 AND nid = %d AND gid IN (" . implode(',', $gids) . ") ORDER BY timestamp DESC", $network->nid, 0, 20);
          }
          break;
      }
      ?>
      <ul class="chron">
        <?php while ($message = db_fetch_object($result)) { ?>
          <?php message_prepare($message) ?>
          <?php print theme('feed_item', $message, $network) ?>
        <?php } ?>
      </ul>
    </div>
  </div> <!-- .content -->
</div>
Return current item: Teampopor