Advertisement
0xAF

Untitled

Sep 16th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.31 KB | None | 0 0
  1.   <?php
  2.   function lastposts_channel_mod_init(&$a,&$b) {
  3.           logger('lastposts invoked');
  4.           if(! intval(get_pconfig(local_user(),'lastposts','lastposts_enable')))
  5.                   return;
  6.           $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/lastposts/lastposts.css' . '" media="all" /    
  7.  >' . "\r\n";
  8.           $lastposts = '<div id="lastposts-channel" class="widget">
  9.                  <div class="title tool">
  10.                  <h4>'.t("Latest Posts").'</h4></div>';
  11.           $lastposts .= '<ul>';
  12.           $channel = $a->profile();  // This is the channel owner, if it has been set
  13.           logger('lastposts chan=$channel');
  14.           $channel_hash = $channel['channel_hash'];
  15.           logger('lastposts chanhash=$channel_hash');
  16.           if($channel && perm_is_allowed($channel['profile_uid'],get_observer_hash(),'view_stream')) {
  17.                   $query = q("select title, plink, created from item where author_xchan='%s' where item_restrict = 0 and uid = %d and item_private = 0 order by
  18.  created desc LIMIT 0,5",
  19.                           dbesc($channel_hash),
  20.                           intval($channel['profile_uid'])
  21.                   );
  22.                   if($query) {
  23.                           foreach($query as $row) {
  24.                                   $plink = $row['plink'];
  25.                                   $created = $row['created'];
  26.                                   if (! $row['title'] ) {
  27.                                           $title = $created;
  28.                                   } else {
  29.                                           $title = $row['title'];
  30.                                   }
  31.                                   $lastposts .= '<li><a href="$plink">$title</a></li>';
  32.                           }
  33.                           $lastposts .= '</ul>';
  34.                           $lastposts .= '</div><div class="clear"></div>';
  35.                           if (! intval(get_pconfig(local_user(), 'lastposts', 'lastposts_right'))) {
  36.                                   $a->page['aside'] = $lastposts.$a->page['aside'];
  37.                           } else {
  38.                                   $a->page['right_aside'] = $lastposts.$a->page['right_aside'];
  39.                           }
  40.                   }
  41.           }
  42.   }
  43.   ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement