forum
[ class tree: forum ] [ index: forum ] [ all elements ]

Source for file forum.inc.php

Documentation is available at forum.inc.php

  1. <?php
  2.     /**
  3.      * @author            Matthias Reuter ($LastChangedBy: matthias $)
  4.      * @version            $LastChangedDate: 2009-08-26 19:19:41 +0200 (Mi, 26 Aug 2009) $
  5.      * @package            forum
  6.      * @copyright        2007-2010 IPBWI development team
  7.      * @link            http://ipbwi.com/examples/forum.php
  8.      * @since            2.0
  9.      * @license            http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
  10.      */
  11.     class ipbwi_forum extends ipbwi {
  12.         private $ipbwi            null;
  13.         /**
  14.          * @desc            Loads and checks different vars when class is initiating
  15.          * @author            Matthias Reuter
  16.          * @since            2.0
  17.          * @ignore
  18.          */
  19.         public function __construct($ipbwi){
  20.             // loads common classes
  21.             $this->ipbwi $ipbwi;
  22.         }
  23.         /**
  24.          * @desc            Converts forum name to forum-ids
  25.          * @param    string    $name Forum's Name
  26.          * @return    int        Forum's ID
  27.          * @author            Matthias Reuter
  28.          * @sample
  29.          *  <code>
  30.          *  $ipbwi->forum->name2id('forumname');
  31.          *  </code>
  32.          * @since            2.0
  33.          */
  34.         public function name2id($name){
  35.             $sql $this->ipbwi->ips_wrapper->DB->query('SELECT id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums WHERE name="'.addslashes(htmlentities($name)).'"');
  36.             $forums $this->ipbwi->ips_wrapper->DB->fetch($sql);
  37.             if($this->ipbwi->ips_wrapper->DB->getTotalRows($sql== 0){
  38.                 return false;
  39.             }elseif(is_array($forums&& count($forums=== 1){
  40.                 // return matching forum-id
  41.                 return  $forums['id'];
  42.             }else{
  43.                 // return array of matched forum-ids
  44.                 return $forums;
  45.             }
  46.         }
  47.         /**
  48.          * @desc            Returns information on a forum.
  49.          * @param    int        $forumID Forum's ID
  50.          * @return    array    Forum's Information.
  51.          * @author            Matthias Reuter
  52.          * @sample
  53.          *  <code>
  54.          *  $ipbwi->forum->info(55);
  55.          *  </code>
  56.          * @since            2.0
  57.          */
  58.         public function info($forumID){
  59.             if($cache $this->ipbwi->cache->get('forumInfo'$forumID)){
  60.                 return $cache;
  61.             }else{
  62.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT f.* from '.$this->ipbwi->board['sql_tbl_prefix'].'forums f WHERE f.id="'.$forumID.'"');
  63.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  64.                     $row['last_poster_name'$this->ipbwi->properXHTML($row['last_poster_name']);
  65.                     $row['name'$this->ipbwi->properXHTML($row['name']);
  66.                     $row['description'$this->ipbwi->properXHTML($row['description']);
  67.                     $row['last_title'$this->ipbwi->properXHTML($row['last_title']);
  68.                     $row['newest_title'$this->ipbwi->properXHTML($row['newest_title']);
  69.                     $perms $this->ipbwi->permissions->sort($row['permission_array']);
  70.                     $row['read_perms']   $perms['read_perms'];
  71.                     $row['reply_perms']  $perms['reply_perms'];
  72.                     $row['start_perms']  $perms['start_perms'];
  73.                     $row['upload_perms'$perms['upload_perms'];
  74.                     $row['show_perms']   $perms['show_perms'];
  75.                     $this->ipbwi->cache->save('forumInfo'$forumID$row);
  76.                     return $row;
  77.                 }else{
  78.                     return false;
  79.                 }
  80.             }
  81.         }
  82.         /**
  83.          * @desc            Returns forum permission data
  84.          * @param    string    $field, these are allowed: perm_view, perm_2, perm_3, perm_4, perm_5, perm_6, perm_7
  85.          * @return    array    permission data
  86.          * @author            Matthias Reuter
  87.          * @sample
  88.          *  <code>
  89.          *  $ipbwi->forum->getData('perm_view');
  90.          *  </code>
  91.          * @since            2.0
  92.          */
  93.          
  94.         private function getData($field){
  95.             // search in permission index
  96.             $query 'SELECT perm_type_id, '.$field.' FROM '.$this->ipbwi->board['sql_tbl_prefix'].'permission_index WHERE perm_type = "forum"';
  97.             $sql $this->ipbwi->ips_wrapper->DB->query($query);
  98.             $forums array();
  99.             while($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  100.                 if(strpos($row[$field],','.$this->ipbwi->member->myInfo['g_perm_id'].','!== false || $row[$field== '*'){
  101.                     $forums[$row['perm_type_id']]    $row['perm_type_id'];
  102.                 }
  103.             }
  104.             return $forums;
  105.         }
  106.         /**
  107.          * @desc            Returns whether a forum can be read by the current member.
  108.          * @param    int        $forumID Forum's ID
  109.          * @return    bool    Forum is readable
  110.          * @author            Matthias Reuter
  111.          * @sample
  112.          *  <code>
  113.          *  $ipbwi->forum->isReadable(55);
  114.          *  </code>
  115.          * @since            2.0
  116.          */
  117.         public function isReadable($forumID){
  118.             $readable $this->getReadable();
  119.             if(isset($readable[$forumID])){
  120.                 return true;
  121.             }else{
  122.                 return false;
  123.             }
  124.         }
  125.         /**
  126.          * @desc            Returns forums readable by the current member.
  127.          * @return    array    Readable Forum Details
  128.          * @author            Matthias Reuter
  129.          * @sample
  130.          *  <code>
  131.          *  $ipbwi->forum->getReadable();
  132.          *  </code>
  133.          * @since            2.0
  134.          */
  135.         public function getReadable(){
  136.             if($cache $this->ipbwi->cache->get('forumsGetReadable'$this->ipbwi->member->myInfo['member_id'])){
  137.                 return $cache;
  138.             }else{
  139.                 $forums $this->getData('perm_2');
  140.                 $this->ipbwi->cache->save('forumsGetReadable'$this->ipbwi->member->myInfo['member_id']$forums);
  141.                 return $forums;
  142.             }
  143.         }
  144.         /**
  145.          * @desc            Returns whether a forum can be posted in by the current member.
  146.          * @param    int        $forumID Forum's ID
  147.          * @return    bool    Forum is postable in
  148.          * @author            Matthias Reuter
  149.          * @sample
  150.          *  <code>
  151.          *  $ipbwi->forum->isPostable(55);
  152.          *  </code>
  153.          * @since            2.0
  154.          */
  155.         public function isPostable($forumID){
  156.             $postable $this->getPostable();
  157.             if(isset($postable[$forumID])){
  158.                 return true;
  159.             }else{
  160.                 return false;
  161.             }
  162.         }
  163.         /**
  164.          * @desc            Returns forums postable in by the current member.
  165.          * @return    array    Postable Forum Details
  166.          * @author            Matthias Reuter
  167.          * @sample
  168.          *  <code>
  169.          *  $ipbwi->forum->getPostable();
  170.          *  </code>
  171.          * @since            2.0
  172.          */
  173.         public function getPostable(){
  174.             if($cache $this->ipbwi->cache->get('forumsGetPostable'$this->ipbwi->member->myInfo['member_id'])){
  175.                 return $cache;
  176.             }else{
  177.                 $forums $this->getData('perm_3');
  178.                 $this->ipbwi->cache->save('forumsGetPostable'$this->ipbwi->member->myInfo['member_id']$forums);
  179.                 return $forums;
  180.             }
  181.         }
  182.         /**
  183.          * @desc            Returns whether a forum can start topics in.
  184.          * @param    int        $forumID Forum's ID
  185.          * @return    bool    Forum is startable in.
  186.          * @author            Matthias Reuter
  187.          * @sample
  188.          *  <code>
  189.          *  $ipbwi->forum->isStartable(55);
  190.          *  </code>
  191.          * @since            2.0
  192.          */
  193.         public function isStartable($forumID){
  194.             $startable $this->getStartable();
  195.             if(isset($startable[$forumID])){
  196.                 return true;
  197.             }else{
  198.                 return false;
  199.             }
  200.         }
  201.         /**
  202.          * @desc            Returns forums in which the current member can start new topics in.
  203.          * @return    array    Startable Forum Details
  204.          * @author            Matthias Reuter
  205.          * @sample
  206.          *  <code>
  207.          *  $ipbwi->forum->getStartable();
  208.          *  </code>
  209.          * @since            2.0
  210.          */
  211.         public function getStartable(){
  212.             if($cache $this->ipbwi->cache->get('forumsGetStartable'$this->ipbwi->member->myInfo['member_id'])){
  213.                 return $cache;
  214.             }else{
  215.                 $forums $this->getData('perm_4');
  216.                 $this->ipbwi->cache->save('forumsGetStartable'$this->ipbwi->member->myInfo['member_id']$forums);
  217.                 return $forums;
  218.             }
  219.         }
  220.         /**
  221.          * @desc            Returns whether a forum can have uploads in topics
  222.          * @param    int        $forumID Forum's ID
  223.          * @return    bool    Forum allows uploads.
  224.          * @author            Matthias Reuter
  225.          * @sample
  226.          *  <code>
  227.          *  $ipbwi->forum->isUploadable(55);
  228.          *  </code>
  229.          * @since            2.0
  230.          */
  231.         public function isUploadable($forumID){
  232.             $uploadable $this->getUploadable();
  233.             if(isset($uploadable[$forumID])){
  234.                 return true;
  235.             }else{
  236.                 return false;
  237.             }
  238.         }
  239.         /**
  240.          * @desc            Returns forums in which the current member can upload in topics.
  241.          * @return    array    Uploadable Forum Details
  242.          * @author            Matthias Reuter
  243.          * @sample
  244.          *  <code>
  245.          *  $ipbwi->forum->getUploadable();
  246.          *  </code>
  247.          * @since            2.0
  248.          */
  249.         public function getUploadable(){
  250.             if($cache $this->ipbwi->cache->get('forumsgetUploadable'$this->ipbwi->member->myInfo['member_id'])){
  251.                 return $cache;
  252.             }else{
  253.                 $forums $this->getData('perm_5');
  254.                 $this->ipbwi->cache->save('forumsgetUploadable'$this->ipbwi->member->myInfo['member_id']$forums);
  255.                 return $forums;
  256.             }
  257.         }
  258.         /**
  259.          * @desc            Returns whether a forum can have downloads in topics
  260.          * @param    int        $forumID Forum's ID
  261.          * @return    bool    Forum allows downloads.
  262.          * @author            Matthias Reuter
  263.          * @sample
  264.          *  <code>
  265.          *  $ipbwi->forum->isDownloadable(55);
  266.          *  </code>
  267.          * @since            2.0
  268.          */
  269.         public function isDownloadable($forumID){
  270.             $Downloadable $this->getDownloadable();
  271.             if(isset($Downloadable[$forumID])){
  272.                 return true;
  273.             }else{
  274.                 return false;
  275.             }
  276.         }
  277.         /**
  278.          * @desc            Returns forums in which the current member can download in topics.
  279.          * @return    array    Downloadable Forum Details
  280.          * @author            Matthias Reuter
  281.          * @sample
  282.          *  <code>
  283.          *  $ipbwi->forum->getDownloadable();
  284.          *  </code>
  285.          * @since            2.0
  286.          */
  287.         public function getDownloadable(){
  288.             if($cache $this->ipbwi->cache->get('forumsgetDownloadable'$this->ipbwi->member->myInfo['member_id'])){
  289.                 return $cache;
  290.             }else{
  291.                 $forums $this->getData('perm_5');
  292.                 $this->ipbwi->cache->save('forumsgetDownloadable'$this->ipbwi->member->myInfo['member_id']$forums);
  293.                 return $forums;
  294.             }
  295.         }
  296.         /**
  297.          * @desc            Returns all subforums of the delivered forums.
  298.          * @param    mixed    $forums Forum IDs as int or array
  299.          * @param    string    $outputType The following output types are supported:<br>
  300.          *                      'html_form' to get a list of <option>-tags<br>
  301.          *                      'array' (default) for an array-list<br>
  302.          *                      'array_ids_only' for an array-list with forum IDs only<br>
  303.          *                      'name_id_with_indent' for an array list of names with indent according to the forum structure
  304.          * @param    string    $indentString The string for indent, default is '-'
  305.          * @return    mixed    List of all subforums
  306.          * @author            Matthias Reuter
  307.          * @sample
  308.          *  <code>
  309.          *  $ipbwi->forum->getAllSubs(array(55,22,77),'html_form');
  310.          *  </code>
  311.          * @since            2.0
  312.          */
  313.         public function getAllSubs($forums,$outputType='array',$indentString='—',$indent=false,$selectedID=false){
  314.             $output false;
  315.             // get all categories, if needed
  316.             if(is_string($forums&& $forums == '*'){
  317.                 $forums $this->catList();
  318.             // get forum information of requested category
  319.             }elseif(is_string($forums|| is_int($forums)){
  320.                 $forums array($this->info($forums));
  321.             }
  322.             // save original indent string
  323.             if(isset($indent)){
  324.                 $orig_indent $indent;
  325.             }else{
  326.                 $orig_indent false;
  327.             }
  328.             // grab all forums from every delivered cat-id
  329.             if(is_array($forums&& count($forums0){
  330.                 foreach($forums as $i){
  331.                     if($outputType == 'html_form')// give every forum its own option-tag
  332.                         $select 'id,name';
  333.                         $output .= '<option'.(($selectedID == $i['id']' selected="selected"' '').(($i['parent_id'== '-1'' style="background-color:#2683AE;color:#FFF;font-weight:bold;"' ' style="color:#666;"').' value="'.$i['id'].'">&nbsp;&nbsp;'.$indent.'&nbsp;&nbsp;'.$i['name'].'</option>';
  334.                     }elseif($outputType == 'array')// merge all forum-data in one, big array
  335.                         $select '*';
  336.                         $output[$i['id']] $i;
  337.                     }elseif($outputType == 'array_ids_only')// merge all forum-data in one, big array
  338.                         $select 'id';
  339.                         if(is_array($i)){
  340.                             $output[$i['id']] $i['id'];
  341.                         }else{
  342.                             $output[$i$i;
  343.                         }
  344.                     }elseif($outputType == 'name_id_with_indent')// return name and id, with indent
  345.                         $select 'id,name';
  346.                         $output[$i['id']]['id'$i['id'];
  347.                         $output[$i['id']]['name'$indent.$i['name'];
  348.                     }
  349.                     // grab all subforums from each delivered cat-id
  350.                     $sql 'SELECT '.$select.' FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums WHERE parent_id = '.(isset($i['id']$i['id'$i).' ORDER BY position ASC';
  351.                     if($subqery $this->ipbwi->ips_wrapper->DB->query($sql)){
  352.                         // extend indent-string
  353.                         $indent $indent.$indentString;
  354.                         // get all subforums in an array
  355.                         while($row $this->ipbwi->ips_wrapper->DB->fetch($subqery)){
  356.                             if($outputType == 'array_ids_only'){
  357.                                 $subforums[$row['id']] $row;
  358.                             }elseif($outputType == 'name_id_with_indent'){
  359.                                 $subforums[$row['id']]['id'$row['id'];
  360.                                 $subforums[$row['id']]['name'$this->ipbwi->properXHTML($row['name']);
  361.                             }else{
  362.                                 $row['last_poster_name'$this->ipbwi->properXHTML($row['last_poster_name']);
  363.                                 $row['name'$this->ipbwi->properXHTML($row['name']);
  364.                                 $row['description'$this->ipbwi->properXHTML($row['description']);
  365.                                 $row['last_title'$this->ipbwi->properXHTML($row['last_title']);
  366.                                 $row['newest_title'$this->ipbwi->properXHTML($row['newest_title']);
  367.                                 $subforums[$row['id']] $row;
  368.                             }
  369.                         }
  370.                         // make it rekursive
  371.                         if(isset($subforums&& is_array($subforums&& count($subforums0){
  372.                             if($outputType == 'html_form'){
  373.                                 // give every forum its own option-tag
  374.                                 $output .= $this->getAllSubs($subforums,$outputType,$indentString,$indent,$selectedID);
  375.                             }elseif($outputType == 'array' || $outputType == 'array_ids_only'){
  376.                                 // merge all forum-data in one, big array
  377.                                 $output $output+$this->getAllSubs($subforums,$outputType,$indentString,$indent,$selectedID);
  378.                             }elseif($outputType == 'name_id_with_indent'){
  379.                                 $output $output+$this->getAllSubs($subforums,$outputType,$indentString,$indent,$selectedID);
  380.                             }
  381.                         }
  382.                         // reset the temp-values
  383.                         $subforums false;
  384.                         $indent $orig_indent;
  385.                     }
  386.                 }
  387.             }else{
  388.                 return false;
  389.             }
  390.             return $output;
  391.         }
  392.         /**
  393.          * @desc            Deletes the forum with delivered forum_id including all subforums, topics, polls and posts.
  394.          * @param    int        $forumID Forum's ID
  395.          * @return    bool    true or false
  396.          * @author            Matthias Reuter
  397.          * @sample
  398.          *  <code>
  399.          *  $ipbwi->forum->delete(55);
  400.          *  </code>
  401.          * @since            2.0
  402.          */
  403.         public function delete($forumID){
  404.             $forumsArray $this->getAllSubs($forumID);
  405.             if(isset($forumsArray&& is_array($forumsArray&& count($forumsArray0){
  406.                 $forumsString '"'.implode('","',array_keys($forumsArray)).'"';
  407.             }else{
  408.                 return false;
  409.             }
  410.             if($this->ipbwi->ips_wrapper->DB->query('SELECT tid FROM '.$this->ipbwi->board['sql_tbl_prefix'].'topics WHERE forum_id IN ('.$forumsString.')')){
  411.                 while($row $this->ipbwi->ips_wrapper->DB->fetch()){
  412.                     $topicsArray[$row['tid'];
  413.                 }
  414.                 if(isset($topicsArray&& is_array($topicsArray&& count($topicsArray0){
  415.                     $topicsString '"'.implode('","',$topicsArray).'"';
  416.                 }
  417.             }
  418.             // delete posts
  419.             if(isset($topicsString)){
  420.                 $this->ipbwi->ips_wrapper->DB->query('DELETE FROM '.$this->ipbwi->board['sql_tbl_prefix'].'posts WHERE topic_id IN ('.$topicsString.')');
  421.             }
  422.             // delete polls
  423.             if(isset($topicsString)){
  424.                 $this->ipbwi->ips_wrapper->DB->query('DELETE FROM '.$this->ipbwi->board['sql_tbl_prefix'].'polls WHERE tid IN ('.$topicsString.')');
  425.             }
  426.             // delete topics
  427.             if(isset($forumsString)){
  428.                 $this->ipbwi->ips_wrapper->DB->query('DELETE FROM '.$this->ipbwi->board['sql_tbl_prefix'].'topics WHERE forum_id IN ('.$forumsString.')');
  429.             }
  430.             // delete all subforums
  431.             if(isset($forumsString)){
  432.                 $this->ipbwi->ips_wrapper->DB->query('DELETE FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums WHERE id IN ('.$forumsString.')');
  433.             }
  434.             $this->ipbwi->ips_wrapper->update_forum_cache();
  435.             return true;
  436.         }
  437.         /**
  438.          * @desc            Creates a forum in the specified category
  439.          * @param    string    $forumName Forum's name
  440.          * @param    string    $forumDesc Forum's description
  441.          * @param    catID    $forumID Categories ID
  442.          * @param    perms    $forumID Forum's permissions as array
  443.          *  + int <b>$perms[startperms]:</b> Group IDs for Start posts permission
  444.          *  + int <b>$perms[replyperms]:</b> Group IDs for Reply-To posts permission
  445.          *  + int <b>$perms[readperms]:</b> Group IDs for Read posts permission
  446.          *  + int <b>$perms[uploadperms]:</b> Group IDs for Fileupload permission
  447.          *  + int <b>$perms[showperms]:</b> Group IDs for Show permission
  448.          * @return    long    new forum's ID or false
  449.          * @author            Matthias Reuter
  450.          * @sample
  451.          *  <code>
  452.          *  $ipbwi->forum->create('Forumname','Forum Description',2,array('show' => '*','read' => '*','start' => '*','reply' => '*','upload' => '*','download' => '*'));
  453.          *  </code>
  454.          * @since            2.0
  455.          */
  456.         public function create($forumName$forumDesc$catID$perms){
  457.             $forumName $this->ipbwi->makeSafe($forumName);
  458.             $forumDesc $this->ipbwi->makeSafe($forumDesc);
  459.             $this->ipbwi->ips_wrapper->DB->query('LOCK TABLE '.$this->ipbwi->board['sql_tbl_prefix'].'forums WRITE');
  460.             $this->ipbwi->ips_wrapper->DB->query('SELECT MAX(id) as max FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums');
  461.             $row $this->ipbwi->ips_wrapper->DB->fetch();
  462.             $max $row['max'];
  463.             $this->ipbwi->ips_wrapper->DB->query('UNLOCK TABLES');
  464.             if($max 1){
  465.                 $max 0;
  466.             }
  467.             ++$max;
  468.             // Check Cat Exists.
  469.             if($catID != '-1'){
  470.                 $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums WHERE id="'.intval($catID).'"');
  471.                 if(!$this->ipbwi->ips_wrapper->DB->fetch()){
  472.                     $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('catNotExist'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  473.                     return false;
  474.                 }
  475.             }
  476.             $this->ipbwi->ips_wrapper->DB->query('SELECT MAX(position) as pos FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums WHERE parent_id="'.intval($catID).'"');
  477.             $row $this->ipbwi->ips_wrapper->DB->fetch();
  478.             $pos $row['pos'];
  479.             if($pos 1$pos '0';
  480.             ++$pos;
  481.             // Permissions
  482.             $permissions array(
  483.                 'start_perms' => $perms['start'],
  484.                 'reply_perms' => $perms['reply'],
  485.                 'read_perms' => $perms['read'],
  486.                 'upload_perms' => $perms['upload'],
  487.                 'download_perms' => $perms['download'],
  488.                 'show_perms' => $perms['show']
  489.             );
  490.             $permsfinal array();
  491.             // Get Groups
  492.             $groups array();
  493.             $this->ipbwi->ips_wrapper->DB->query('SELECT perm_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forum_perms');
  494.             while($groupsr $this->ipbwi->ips_wrapper->DB->fetch()){
  495.                 $groups[$groupsr['perm_id'];
  496.             }
  497.             foreach($permissions as $i => $j){
  498.                 // if permission is to be set for category
  499.                 if($j == '*' && $catID == '-1'){
  500.                     $x array();
  501.                     foreach($groups as $l){
  502.                         $x[intval($l);
  503.                     }
  504.                     $permsfinal[$iimplode (','$x);
  505.                 // if permission is to be set for forum
  506.                 }elseif($j == '*'){
  507.                     // All Groups
  508.                     $permsfinal[$i'*';
  509.                 }else{
  510.                     $x array();
  511.                     foreach($j as $l){
  512.                         if(in_array($l$groups)){
  513.                             $x[intval($l);
  514.                         }
  515.                     }
  516.                     $permsfinal[$iimplode (','$x);
  517.                 }
  518.             }
  519.             $perm_array addslashes(serialize($permsfinal));
  520.             // Finally Add it to the Database
  521.             if($catID == '-1'){
  522.                 // category settings
  523.                 $DB_string $this->ipbwi->ips_wrapper->DB->compile_db_insert_string(
  524.                     array(
  525.                         'id' =>                        $max,
  526.                         'topics' =>                    0,
  527.                         'posts' =>                    0,
  528.                         'last_post' =>                0,
  529.                         'last_poster_id' =>            0,
  530.                         'last_poster_name' =>        '',
  531.                         'name' =>                    $forumName,
  532.                         'description' =>            $forumDesc,
  533.                         'position' =>                $pos,
  534.                         'use_ibc' =>                0,
  535.                         'use_html' =>                0,
  536.                         'status' =>                    0,
  537.                         'password' =>                '',
  538.                         'password_override' =>        '',
  539.                         'last_title' =>                'NULL',
  540.                         'last_id' =>                0,
  541.                         'sort_key' =>                'last_post',
  542.                         'sort_order' =>                'Z-A',
  543.                         'prune' =>                    0,
  544.                         'topicfilter' =>            'all',
  545.                         'show_rules' =>                'NULL',
  546.                         'preview_posts' =>            0,
  547.                         'allow_poll' =>                0,
  548.                         'allow_pollbump' =>            0,
  549.                         'inc_postcount' =>            0,
  550.                         'skin_id' =>                'NULL',
  551.                         'parent_id' =>                -1,
  552.                         'sub_can_post' =>            0,
  553.                         'quick_reply' =>            0,
  554.                         'redirect_url' =>            '',
  555.                         'redirect_on' =>            0,
  556.                         'redirect_hits' =>            0,
  557.                         'redirect_loc' =>            '',
  558.                         'rules_title' =>            '',
  559.                         'rules_text' =>                'NULL',
  560.                         'topic_mm_id' =>            '',
  561.                         'notify_modq_emails' =>        '',
  562.                         'permission_custom_error'=>    '',
  563.                         'permission_array' =>        $perm_array,
  564.                         'permission_showtopic' =>    1,
  565.                         'queued_topics' =>            0,
  566.                         'queued_posts' =>            0,
  567.                         'forum_last_deletion' =>    0,
  568.                         'forum_allow_rating' =>        0,
  569.                         'newest_title' =>            'NULL',
  570.                         'newest_id' =>                0,
  571.                     )
  572.                 );
  573.             }else{
  574.                 // forum settings
  575.                 $DB_string $this->ipbwi->ips_wrapper->DB->compile_db_insert_string(
  576.                     array(
  577.                         'id' =>                            $max,
  578.                         'topics' =>                        0,
  579.                         'posts' =>                        0,
  580.                         'last_post' =>                    0,
  581.                         'last_poster_id' =>                0,
  582.                         'last_poster_name' =>            '',
  583.                         'name' =>                        $forumName,
  584.                         'description' =>                $forumDesc,
  585.                         'position' =>                    $pos,
  586.                         'use_ibc' =>                    1,
  587.                         'use_html' =>                    0,
  588.                         'status' =>                        1,
  589.                         'password' =>                    '',
  590.                         'password_override' =>            '',
  591.                         'last_title' =>                    '',
  592.                         'last_id' =>                    0,
  593.                         'sort_key' =>                    'last_post',
  594.                         'sort_order' =>                    'Z-A',
  595.                         'prune' =>                        100,
  596.                         'topicfilter' =>                'all',
  597.                         'show_rules' =>                    'NULL',
  598.                         'preview_posts' =>                0,
  599.                         'allow_poll' =>                    1,
  600.                         'allow_pollbump' =>                0,
  601.                         'inc_postcount' =>                1,
  602.                         'skin_id' =>                    'NULL',
  603.                         'parent_id' =>                    intval($catID),
  604.                         'sub_can_post' =>                1,
  605.                         'quick_reply' =>                1,
  606.                         'redirect_url' =>                '',
  607.                         'redirect_on' =>                0,
  608.                         'redirect_hits' =>                0,
  609.                         'redirect_loc' =>                '',
  610.                         'rules_title' =>                '',
  611.                         'rules_text' =>                    'NULL',
  612.                         'topic_mm_id' =>                '',
  613.                         'notify_modq_emails' =>            '',
  614.                         'permission_custom_error' =>    '',
  615.                         'permission_array' =>            $perm_array,
  616.                         'permission_showtopic' =>        0,
  617.                         'queued_topics' =>                0,
  618.                         'queued_posts' =>                0,
  619.                         'forum_last_deletion' =>        0,
  620.                         'forum_allow_rating' =>            1,
  621.                         'newest_title' =>                '',
  622.                         'newest_id' =>                    0,
  623.                     )
  624.                 );
  625.             }
  626.             $this->ipbwi->ips_wrapper->DB->query('LOCK TABLE '.$this->ipbwi->board['sql_tbl_prefix'].'forums WRITE');
  627.             $this->ipbwi->ips_wrapper->DB->query('INSERT INTO '.$this->ipbwi->board['sql_tbl_prefix'].'forums ('.$DB_string['FIELD_NAMES'].') VALUES ('.$DB_string['FIELD_VALUES'].')');
  628.             $this->ipbwi->ips_wrapper->DB->query('UNLOCK TABLES');
  629.             $this->ipbwi->ips_wrapper->update_forum_cache();
  630.             return $max;
  631.         }
  632.         /**
  633.          * @desc            List categories.
  634.          * @return    array    Board's Categories
  635.          * @author            Matthias Reuter
  636.          * @sample
  637.          *  <code>
  638.          *  $ipbwi->forum->catList();
  639.          *  </code>
  640.          * @since            2.0
  641.          */
  642.         public function catList(){
  643.             if($cache $this->ipbwi->cache->get('listCategories''1')){
  644.                 return $cache;
  645.             }else{
  646.                 $query $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'forums WHERE parent_id = "-1"');
  647.                 $cat array();
  648.                 if($this->ipbwi->ips_wrapper->DB->getTotalRows(== 0return false;
  649.                 while($row $this->ipbwi->ips_wrapper->DB->fetch($query)){
  650.                     $row['last_poster_name'$this->ipbwi->properXHTML($row['last_poster_name']);
  651.                     $row['name'$this->ipbwi->properXHTML($row['name']);
  652.                     $row['description'$this->ipbwi->properXHTML($row['description']);
  653.                     $row['last_title'$this->ipbwi->properXHTML($row['last_title']);
  654.                     $row['newest_title'$this->ipbwi->properXHTML($row['newest_title']);
  655.                     $cat[$row['id']] $row;
  656.                 }
  657.                 $this->ipbwi->cache->save('listCategories''1'$cat);
  658.                 return $cat;
  659.             }
  660.         }
  661.         /**
  662.          * @desc            Get Information on a Category
  663.          * @param    int        $catID Unique ID of the category
  664.          * @return    array    Information of category categoryid
  665.          * @author            Matthias Reuter
  666.          * @sample
  667.          *  <code>
  668.          *  $ipbwi->forum->categoryInfo(5);
  669.          *  </code>
  670.          * @since            2.0
  671.          */
  672.         public function categoryInfo($catID){
  673.             $cats $this->catList();
  674.             if($cats[$catID]){
  675.                 return $cats[$catID];
  676.             }else{
  677.                 return false;
  678.             }
  679.         }
  680.     }
  681. ?>

Documentation generated on Sat, 23 Oct 2010 23:35:49 +0200 by phpDocumentor 1.4.3