Introduction   Getting Started   Upgrading   Function Reference   Changelog   Support and Feedback

IPB SDK's Topic Functions allow you to create new topics, retrieve information on topics and grab posts from a topic.



User Contributed Notes

eXed
my modification of list_topic_info function
'srart_time'=>'', 'end_time'=>'' have format day/month/year

CODE

       function list_forum_topics_limit_by_date($forumid, $settings = array('order' => 'desc', 'limit' => '15', 'start' => '0', 'orderby' => 'last_post', 'srart_time'=>'', 'end_time'=>''), $bypassperms = '0') {
               // As of SDK 1.0 this function can be used to get topics
               // from multiple forums. So heres the updated thingy :)
               $expforums = array();
               if (is_array($forumid)) {
                       foreach ($forumid as $i) {
                               if ($this->is_forum_readable(intval($i)) OR $bypassperms) {
                                       $expforum[] = intval($i);
                               }
                       }
               } elseif ($forumid == '*') {
                       // Get readable forums
                       $readable = $this->get_member_readable_forums();
                       foreach ($readable as $j => $k) {
                               $expforum[] = intval($k['id']);
                       }
               } else {
                       if ($this->is_forum_readable(intval($forumid)) OR $bypassperms) {
                               $expforum[] = intval($forumid);
                       }
               }

               if (count($expforum) < 1) {
                       $this->sdkerror($this->lang['sdk_noperms']);
                       return FALSE;
               } else {
                       // What shall I order it by guv?
                       $allowedorder = array('tid', 'title', 'posts', 'starter_name', 'starter_id', 'start_date', 'last_post', 'views', 'post_date');

                       if (in_array($settings['orderby'], $allowedorder)) {
                               $order = $settings['orderby'] . ' ' . (($settings['order'] == 'desc') ? 'DESC' : 'ASC');
                       } elseif ($settings['orderby'] == 'random') {
                               $order = 'RAND()';
                       } else {
                               $order = 'start_date ' . (($settings['order'] == 'desc') ? 'DESC' : 'ASC');
                       }
                       // Grab Posts
                       $limit = $settings['limit'] ? intval($settings['limit']) : '15';
                       $start = $settings['start'] ? intval($settings['start']) : '0';
                       // Forum ID Code
                       if ($forumid == '*' AND $bypassperms) {
                               $forums = '';
                       } else {
                               $forums = 't.forum_id IN ('.implode(',', $expforum).')';
                       }

/* Some more setings by exed[dog]mozg.org */

   if($settings['start_time'] && !$settings['end_time']) {
    list( $day_a, $month_a, $year_a ) = explode('/', $settings['start_time']);
    $mk_a = @mktime(0,0,0, $month_a, $day_a, $year_a);
     $where_query = " AND t.start_date > $mk_a";
     $limit_query = " LIMIT $start, $limit";
   }
    elseif($settings['start_time'] && $settings['end_time']) {

    list( $day_a, $month_a, $year_a ) = explode('/', $settings['start_time']);
     $mk_a = @mktime(0,0,0, $month_a, $day_a, $year_a);
    list( $day_b, $month_b, $year_b ) = explode('/', $settings['end_time']);
     $mk_b = @mktime(0,0,0, $month_b, $day_b, $year_b);
     if($mk_a < $mk_b)
     {
      $where_query = " AND t.start_date > $mk_a AND t.start_date < $mk_b";
      $limit_query = " ";
     }
   else
    $limit_query = " LIMIT $start, $limit";

     }
   else
    $limit_query = " LIMIT $start, $limit";

/* end of eXed's edition */

                       $this->DB->query ('SELECT t.*, p.*, g.g_dohtml AS usedohtml FROM ibf_topics t LEFT JOIN ibf_posts p ON (t.tid=p.topic_id) LEFT JOIN ibf_members m ON (p.author_id=m.id) LEFT JOIN ibf_groups g ON (m.mgroup=g.g_id) WHERE '.$forums." AND t.approved='1' AND p.new_topic='1'".$where_query." ORDER BY ".$order." ".$limit_query); // LIMIT $start,$limit

                       $return = array();
                       while ($row = $this->DB->fetch_row()) {
                               // Parse [doHTML] taggy
                               $row['post'] = $GLOBALS['parser']->post_db_parse($row['post'], $row['usedohtml']);
                               $return[] = $row;
                       }
                       return $return;
               }
       }

Documentation Generated at Sat, 16 Apr 2005 07:36:35 -0700
Find the latest version at http://ipbsdk.sourceforge.net