Changeset 1041:ffd8fd14003c for inc/core
- Timestamp:
- 11/25/12 22:38:00 (13 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.blog.php
r1030 r1041 2055 2055 public function updCommentStatus($id,$status) 2056 2056 { 2057 $this->updCommentsStatus($id,$status); 2058 } 2059 2060 /** 2061 Updates comments status. 2062 2063 @param ids <b>mixed</b> Comment(s) ID(s) 2064 @param status <b>integer</b> Comment status 2065 */ 2066 public function updCommentsStatus($ids,$status) 2067 { 2057 2068 if (!$this->core->auth->check('publish,contentadmin',$this->id)) { 2058 2069 throw new Exception(__("You are not allowed to change this comment's status")); 2059 2070 } 2060 2071 2061 $cur = $this->con->openCursor($this->prefix.'comment'); 2062 $cur->comment_status = (integer) $status; 2063 $this->updComment($id,$cur); 2072 $co_ids = dcUtils::cleanIds($ids); 2073 $status = (integer) $status; 2074 2075 $strReq = 2076 'UPDATE '.$this->prefix.'comment tc '; 2077 2078 # mySQL uses "JOIN" synthax 2079 if ($this->con->driver() == 'mysql') { 2080 $strReq .= 2081 'JOIN '.$this->prefix.'post tp ON tc.post_id = tp.post_id '; 2082 } 2083 2084 $strReq .= 2085 'SET comment_status = '.$status.' '; 2086 2087 # pgSQL uses "FROM" synthax 2088 if ($this->con->driver() != 'mysql') { 2089 $strReq .= 2090 'FROM '.$this->prefix.'post tp '; 2091 } 2092 2093 $strReq .= 2094 "WHERE blog_id = '".$this->con->escape($this->id)."' ". 2095 'AND comment_id'.$this->con->in($co_ids); 2096 2097 # add pgSQL "WHERE" clause 2098 if ($this->con->driver() != 'mysql') { 2099 $strReq .= 2100 'AND tc.post_id = tp.post_id '; 2101 } 2102 2103 #If user is only usage, we need to check the post's owner 2104 if (!$this->core->auth->check('contentadmin',$this->id)) 2105 { 2106 $strReq .= 2107 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 2108 } 2109 2110 $this->con->execute($strReq); 2111 2112 foreach($co_ids as $id) { 2113 $this->triggerComment($id); 2114 } 2115 $this->triggerBlog(); 2064 2116 } 2065 2117 … … 2070 2122 */ 2071 2123 public function delComment($id) 2124 { 2125 $this->delComments($id); 2126 } 2127 2128 /** 2129 Delete comments 2130 2131 @param ids <b>mixed</b> Comment(s) ID(s) 2132 */ 2133 public function delComments($ids) 2072 2134 { 2073 2135 if (!$this->core->auth->check('delete,contentadmin',$this->id)) { … … 2075 2137 } 2076 2138 2077 $ id = (integer) $id;2078 2079 if (empty($id )) {2139 $co_ids = dcUtils::cleanIds($ids); 2140 2141 if (empty($ids)) { 2080 2142 throw new Exception(__('No such comment ID')); 2081 2143 } 2144 2145 # mySQL uses "INNER JOIN" synthax 2146 if ($this->con->driver() == 'mysql') { 2147 $strReq = 2148 'DELETE FROM tc '. 2149 'USING '.$this->prefix.'comment tc '. 2150 'INNER JOIN '.$this->prefix.'post tp '; 2151 } 2152 # pgSQL uses nothing special 2153 else { 2154 $strReq = 2155 'DELETE FROM '.$this->prefix.'comment tc '. 2156 'USING '.$this->prefix.'post tp '; 2157 } 2158 2159 $strReq .= 2160 'WHERE tc.post_id = tp.post_id '. 2161 "AND tp.blog_id = '".$this->con->escape($this->id)."' ". 2162 'AND comment_id'.$this->con->in($co_ids); 2082 2163 2083 2164 #If user can only delete, we need to check the post's owner 2084 2165 if (!$this->core->auth->check('contentadmin',$this->id)) 2085 2166 { 2086 $strReq = 'SELECT P.post_id '. 2087 'FROM '.$this->prefix.'post P, '.$this->prefix.'comment C '. 2088 'WHERE P.post_id = C.post_id '. 2089 "AND P.blog_id = '".$this->con->escape($this->id)."' ". 2090 'AND comment_id = '.$id.' '. 2091 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 2092 2093 $rs = $this->con->select($strReq); 2094 2095 if ($rs->isEmpty()) { 2096 throw new Exception(__('You are not allowed to delete this comment')); 2097 } 2098 } 2099 2100 $strReq = 'DELETE FROM '.$this->prefix.'comment '. 2101 'WHERE comment_id = '.$id.' '; 2102 2103 $this->triggerComment($id,true); 2167 $strReq .= 2168 "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 2169 } 2170 2104 2171 $this->con->execute($strReq); 2172 2173 foreach($co_ids as $id) { 2174 $this->triggerComment($id,true); 2175 } 2105 2176 $this->triggerBlog(); 2106 2177 }
Note: See TracChangeset
for help on using the changeset viewer.