Changeset 2313

Show
Ignore:
Timestamp:
12/18/10 13:21:10 (17 months ago)
Author:
nick_ramsay
Message:

[1.5] Removed most comments-related code from core - needs some testing.

Location:
branches/1.5
Files:
1 removed
8 modified

Legend:

Unmodified
Added
Removed
  • branches/1.5/Hotaru.php

    r2307 r2313  
    4040        protected $post;                            // Post object 
    4141        protected $avatar;                          // Avatar object 
    42         protected $comment;                         // Comment object 
    4342        protected $includes;                        // for CSS/JavaScript includes 
    4443        protected $pageHandling;                    // PageHandling object 
     
    20122011/* ************************************************************* 
    20132012 * 
    2014  *  COMMENT FUNCTIONS 
    2015  * 
    2016  * *********************************************************** */ 
    2017  
    2018         /** 
    2019          * Count comments 
    2020          * 
    2021          * @param bool $digits_only - return just the count (if false, returns "3 comments", etc.) 
    2022          * @param string $no_comments_text - e.g. "Leave a comment" or "No comments" 
    2023          * @return string - text to show, e.g. "3 comments" 
    2024          */ 
    2025         function countComments($digits_only = true, $no_comments_text = '') 
    2026         { 
    2027                 $comment = new Comment(); 
    2028                 return $comment->countComments($this, $digits_only, $no_comments_text); 
    2029         } 
    2030  
    2031  
    2032         /** 
    2033          * Count all user comments 
    2034          * 
    2035          * @param int $user_id 
    2036          * @return int 
    2037          */ 
    2038         function countUserComments($user_id = 0) 
    2039         { 
    2040                 $comment = new Comment(); 
    2041                 return $comment->countUserComments($this, $user_id); 
    2042         } 
    2043  
    2044  
    2045         /** 
    2046          * Physically delete all comments by a specified user (and responses) 
    2047          * 
    2048          * @param array $user_id 
    2049          * @return bool 
    2050          */ 
    2051         public function deleteComments($user_id) 
    2052         { 
    2053                 $comment = new Comment(); 
    2054                 return $comment->deleteComments($this, $user_id); 
    2055         } 
    2056  
    2057  
    2058         /** 
    2059          * Get comment from database 
    2060          * 
    2061          * @param int $comment_id 
    2062          * @return array|false 
    2063          */ 
    2064         function getComment($comment_id = 0) 
    2065         { 
    2066                 $comment = new Comment(); 
    2067                 return $comment->getComment($this, $comment_id); 
    2068         } 
    2069  
    2070  
    2071         /** 
    2072          * Read comment 
    2073          * 
    2074          * @param array $comment_row pulled from database 
    2075          */ 
    2076         function readComment($comment_row = array()) 
    2077         { 
    2078                 $comment = new Comment(); 
    2079                 return $comment->readComment($this, $comment_row); 
    2080         } 
    2081  
    2082  
    2083 /* ************************************************************* 
    2084  * 
    20852013 *  WIDGET FUNCTIONS 
    20862014 * 
  • branches/1.5/install/index.php

    r2308 r2313  
    499499        } else { 
    500500 
    501                 $tables = array('blocked', 'categories', 'comments', 'miscdata', 'plugins', 'pluginhooks', 'pluginsettings', 'posts', 'postvotes', 'settings', 'tags', 'tempdata', 'tokens', 'users', 'usermeta', 'widgets'); 
     501                $tables = array('blocked', 'categories', 'miscdata', 'plugins', 'pluginhooks', 'pluginsettings', 'posts', 'postvotes', 'settings', 'tags', 'tempdata', 'tokens', 'users', 'usermeta', 'widgets'); 
    502502 
    503503                // delete *all* tables in db: 
  • branches/1.5/install/install-upgrade.php

    r2309 r2313  
    260260                if (!$exists) { 
    261261                        // Alter the Users table to include user_lastvisit 
    262                         $sql = "ALTER TABLE " . TABLE_COMMENTS . " ADD comment_votes_down smallint(11) NOT NULL DEFAULT '0' AFTER comment_votes"; 
     262                        $sql = "ALTER TABLE ".DB_PREFIX."comments ADD comment_votes_down smallint(11) NOT NULL DEFAULT '0' AFTER comment_votes"; 
    263263                        $h->db->query($h->db->prepare($sql)); 
    264264                } 
     
    268268                if (!$exists) { 
    269269                        // Alter the Users table to include user_lastvisit 
    270                         $sql = "ALTER TABLE " . TABLE_COMMENTS . " CHANGE comment_votes comment_votes_up smallint(11) NOT NULL DEFAULT '0'"; 
     270                        $sql = "ALTER TABLE ".DB_PREFIX."comments CHANGE comment_votes comment_votes_up smallint(11) NOT NULL DEFAULT '0'"; 
    271271                        $h->db->query($h->db->prepare($sql)); 
    272272                } 
    273273                 
    274274                // move any negative comment vote counts to the down column 
    275                 $sql = "SELECT comment_id, comment_votes_up FROM " . TABLE_COMMENTS . " WHERE comment_votes_up < %d"; 
     275                $sql = "SELECT comment_id, comment_votes_up FROM ".DB_PREFIX."comments WHERE comment_votes_up < %d"; 
    276276                $negatives = $h->db->get_results($h->db->prepare($sql, 0)); 
    277277                if ($negatives) { 
    278278                        foreach ($negatives as $neg) { 
    279                                 $sql = "UPDATE " . TABLE_COMMENTS . " SET comment_votes_up = %d, comment_votes_down = %d WHERE comment_id = %d"; 
     279                                $sql = "UPDATE ".DB_PREFIX."comments SET comment_votes_up = %d, comment_votes_down = %d WHERE comment_id = %d"; 
    280280                                $h->db->query($h->db->prepare($sql, 0, abs($neg->comment_votes_up), $neg->comment_id)); 
    281281                        } 
  • branches/1.5/install/install_tables.php

    r2308 r2313  
    8383                $sql = "INSERT INTO " . DB_PREFIX . $table_name . " (category_name, category_safe_name) VALUES (%s, %s)"; 
    8484                $db->query($db->prepare($sql, urlencode('All'), urlencode('all'))); 
    85         } 
    86  
    87  
    88         // COMMENTS TABLE - comments 
    89          
    90         if ($table_name == "comments") { 
    91                 //echo "table doesn't exist. Stopping before creation."; exit; 
    92                 $sql = "CREATE TABLE `" . DB_PREFIX . $table_name . "` ( 
    93                         `comment_id` int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
    94                         `comment_archived` enum('Y','N') NOT NULL DEFAULT 'N', 
    95                         `comment_updatedts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
    96                         `comment_post_id` int(20) NOT NULL DEFAULT '0', 
    97                         `comment_user_id` int(20) NOT NULL DEFAULT '0', 
    98                         `comment_parent` int(20) DEFAULT '0', 
    99                         `comment_date` timestamp NULL, 
    100                         `comment_status` varchar(32) NOT NULL DEFAULT 'approved', 
    101                         `comment_content` text NULL, 
    102                         `comment_votes_up` smallint(11) NOT NULL DEFAULT '0', 
    103                         `comment_votes_down` smallint(11) NOT NULL DEFAULT '0', 
    104                         `comment_subscribe` tinyint(1) NOT NULL DEFAULT '0', 
    105                         `comment_updateby` int(20) NOT NULL DEFAULT 0, 
    106                         FULLTEXT (`comment_content`), 
    107                         INDEX  (`comment_archived`), 
    108                         INDEX  (`comment_post_id`), 
    109                         INDEX  (`comment_status`) 
    110                 ) ENGINE=" . DB_ENGINE . " DEFAULT CHARSET=" . DB_CHARSET . " COLLATE=" . DB_COLLATE . " COMMENT='Post Comments';"; 
    111                 echo $lang['install_step2_creating_table'] . ": '" . DB_PREFIX . $table_name . "'...<br />\n"; 
    112                 $db->query($sql);  
    11385        } 
    11486 
  • branches/1.5/libs/AdminPages.php

    r2312 r2313  
    385385                                DB_PREFIX.'usermeta', 
    386386                                DB_PREFIX.'categories', 
    387                                 DB_PREFIX.'comments', 
    388387                                DB_PREFIX.'miscdata', 
    389388                                DB_PREFIX.'posts', 
  • branches/1.5/libs/Caching.php

    r2309 r2313  
    204204                                break; 
    205205                        case 'comments': 
    206                                 $sql = "SELECT comment_updatedts FROM ".TABLE_COMMENTS." ORDER BY comment_updatedts DESC LIMIT 1"; 
     206                                $sql = "SELECT comment_updatedts FROM ".DB_PREFIX."comments ORDER BY comment_updatedts DESC LIMIT 1"; 
    207207                                break; 
    208208                        case 'commentvotes': 
  • branches/1.5/libs/Initialize.php

    r2309 r2313  
    114114                        'TABLE_BLOCKED' => 'blocked', 
    115115                        'TABLE_CATEGORIES' => 'categories', 
    116                         'TABLE_COMMENTS' => 'comments', 
    117116                        'TABLE_MISCDATA' => 'miscdata', 
    118117                        'TABLE_PLUGINS' => 'plugins', 
  • branches/1.5/libs/UserAuth.php

    r2249 r2313  
    327327                                $viewee->updatePermissions($h); 
    328328                                if ($role_check == 'killspammed' || $role_check == 'deleted') { 
    329                                         $h->deleteComments($viewee->id); // includes child comments from *other* users 
     329                                        if (isset($h->vars['comment'])) { 
     330                                                $h->vars['comment']->deleteComments($h, $viewee->id); // includes child comments from *other* users 
     331                                        } 
    330332                                        $h->deletePosts($viewee->id); // includes tags and votes for self-submitted posts 
    331333