<?php
/**
  * This plugin can be used to display the last articles written by a user. 
 
  */
 
class NP_MemberItems extends NucleusPlugin {
 
   function getEventList() { return array(); }
   function getName() { return 'Member Items'; }
   function getAuthor()  { return 'Ricardo Lamego'; }
   function getURL()  { return 'http://35mm.org/'; }
   function getVersion() { return '0.1'; }
   function getDescription() {
      return 'Use this plugin to display the last items posted by each user. <%MemberItems%> will show the default number of items from <strong>all</strong> blogs the member posts. <%MemberItems(5)%> overrides the default number of items and will display only 5. <%MemberItems(5,2)%> will do as stated before plus will only show items from blogid 2.';
   }
 
function supportsFeature($what) {
   switch($what) {
     case 'SqlTablePrefix':
       return 1;
     default:
       return 0;
   }
}
 
function install() {
   $this->createOption('option1','Max number of items?','text','10');
}
   // skinvar plugin can have a blogname as second parameter
   function doSkinVar($skinType) {
      global $manager, $blog, $CONF,$memberid;
       $params = func_get_args();
      $option1 = $this->getOption('option1');
 
      if ($option1) { $numberOfItems = $option1; }
         else { $numberOfItems = 10; }
      // how many items will be shown?
      if ($params[1])
         { $numberOfItems = $params[1]; }
      // show items from all blogs
      if (!$params[2])
         { $blogid = "";}
      // show items from the actual blog
      else if ($params[2] == "0")
         { $blogid = " AND iblog=".$blog->getID(); }
      // show items from the default blog
      else if ($params[2] == "default")
         { $blogid = " AND iblog=".$CONF['DefaultBlog'];  }
      // show items from the selected blog id
      else
         { $blogid = " AND iblog=".$params[2]; }
 
$itable = sql_table('item');
 
$query = "SELECT inumber, iauthor, ititle, itime FROM $itable WHERE iauthor=".$memberid." AND idraft=0".$blogid."  AND itime<=".mysqldate($blog->getCorrectTime()). " ORDER by itime DESC LIMIT 0,".$numberOfItems;
 
        $items = mysql_query($query);
        while($row = mysql_fetch_object($items)) {
             $title  = $row->ititle;
          $itime =  $row->itime;
          $time = ereg_replace("^(.{1,10})[ :,].*", "\\1", $itime);
 
             $itemlink = createItemLink($row->inumber, '');
             echo $time ."  &nbsp;&nbsp;&nbsp;   ";
             echo "<a class=\"linkpage\" href=\"".$IndexURL.$itemlink."\">". $title ."</a><br />";
 
         }
 
       }
}
?>
np_memberitems_code.txt · Last modified: 2007/11/16 20:16 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki