|
1 <?php |
|
2 function ocmx_comment_options (){ |
|
3 if($_POST["startrow"]) : |
|
4 $startrow = $_POST["startrow"]; |
|
5 $endrow = ($_POST["startrow"] + 15); |
|
6 elseif($_GET["startrow"]) : |
|
7 $startrow = $_GET["startrow"]; |
|
8 $endrow = ($_GET["startrow"] + 15); |
|
9 else : |
|
10 $startrow = "0"; |
|
11 $endrow = 15; |
|
12 endif; |
|
13 global $options, $themename, $manualurl, $wpdb; |
|
14 $comment_table = $wpdb->prefix . "ocmx_comment_meta"; |
|
15 $count_subscribers = $wpdb->get_results("SELECT * FROM $comment_table"); |
|
16 $fetch_subscribers = $wpdb->get_results( |
|
17 "SELECT $wpdb->comments.*, $comment_table.* |
|
18 FROM $wpdb->comments INNER JOIN $comment_table |
|
19 ON $wpdb->comments.comment_ID = $comment_table.commentId |
|
20 ORDER BY $wpdb->comments.comment_post_ID ASC, $wpdb->comments.comment_author ASC, $wpdb->comments.comment_author_email ASC, $comment_table.twitter ASC, $comment_table.email_subscribe DESC |
|
21 LIMIT $startrow, $endrow"); |
|
22 |
|
23 if(isset($_POST["comment_changes"])) : |
|
24 $users_deleted = 0; |
|
25 $users_blocked = 0; |
|
26 $users_subs = 0; |
|
27 wp_cache_flush(); |
|
28 foreach($fetch_subscribers as $subscriber_details) : |
|
29 $delete_key = "delete_comment-".$subscriber_details->commentId; |
|
30 $block_key = "block_comment-".$subscriber_details->commentId; |
|
31 $subs_key = "mail_comment-".$subscriber_details->commentId; |
|
32 if(isset($_POST[$delete_key])) : |
|
33 $main_sql = "DELETE FROM $wpdb->comments WHERE comment_ID = ".$subscriber_details->commentId; |
|
34 $meta_sql = "DELETE FROM $comment_table WHERE commentId = '".$subscriber_details->commentId."'"; |
|
35 $check_post = get_post($subscriber_details->comment_post_ID); |
|
36 if($wpdb->query($main_sql) == "1" && $wpdb->query($meta_sql) == "1") : |
|
37 if($check_post->comment_count !== 0): |
|
38 $update_posts = "UPDATE $wpdb->posts SET comment_count = ".($check_post->comment_count - 1)." WHERE `ID` = ".$subscriber_details->comment_post_ID; |
|
39 $wpdb->query($update_posts); |
|
40 endif; |
|
41 $users_deleted += 1; |
|
42 endif; |
|
43 else : |
|
44 if(isset($_POST[$block_key])): $block_user = 1; else: $block_user = 0; endif; |
|
45 if(isset($_POST[$subs_key])): $subs_user = 1; else: $subs_user = 0; endif; |
|
46 $update_sql = "UPDATE $comment_table |
|
47 SET block_user = ".$block_user.", |
|
48 email_subscribe = ".$subs_user." |
|
49 WHERE commentId = ".$subscriber_details->commentId; |
|
50 $wpdb->query($update_sql); |
|
51 |
|
52 if(isset($_POST[$block_key])) : |
|
53 $users_blocked += 1; |
|
54 endif; |
|
55 if(isset($_POST[$subs_key])) : |
|
56 $users_subs += 1; |
|
57 endif; |
|
58 endif; |
|
59 endforeach; |
|
60 $fetch_subscribers = $wpdb->get_results( |
|
61 "SELECT $wpdb->comments.*, $comment_table.* |
|
62 FROM $wpdb->comments INNER JOIN $comment_table |
|
63 ON $wpdb->comments.comment_ID = $comment_table.commentId |
|
64 ORDER BY $wpdb->comments.comment_post_ID ASC, $wpdb->comments.comment_author ASC, $wpdb->comments.comment_author_email ASC, $comment_table.twitter ASC, $comment_table.email_subscribe DESC |
|
65 LIMIT $startrow, $endrow"); |
|
66 endif; |
|
67 |
|
68 ocmx_header(); |
|
69 ?> |
|
70 |
|
71 <h2>OCMX Comments</h2> |
|
72 <?php if(isset($_POST["comment_changes"])) : |
|
73 if($users_deleted !== 0 || $users_blocked !== 0 || $users_subs !== 0) : |
|
74 echo "<p class=\"success\">Your changes were successful. $users_deleted Deleted, $users_blocked Blocked, $users_subs Subscription Changes</p>"; |
|
75 else : |
|
76 echo "<p class=\"error\">Your changes were not successful.</p>"; |
|
77 endif; |
|
78 endif; ?> |
|
79 <form action="<?php echo $_SERVER['REQUEST_URI']; ?>&startrow=<?php echo $startrow; ?>" id="ocmx_comment_form" method="post" enctype="multipart/form-data"> |
|
80 <p class="submit"><input name="save" type="submit" value="Save changes" /></p> |
|
81 <input type="hidden" name="comment_changes" value="1" /> |
|
82 <input type="hidden" name="startrow" value="<?php echo $startrow; ?>" /> |
|
83 <?php |
|
84 $pages = (count($count_subscribers)/15); |
|
85 if($pages > 1) : |
|
86 echo "<p>Pages: "; |
|
87 for ($i = 1; $i < ($pages + 1); $i++) |
|
88 { |
|
89 if($startrow == ($i*15-15)) : |
|
90 echo "<a href=\"".$_SERVER['REQUEST_URI']."&startrow=".($i*15-15)."\"><strong>".$i."</strong></a>"; |
|
91 else : |
|
92 echo "<a href=\"".$_SERVER['REQUEST_URI']."&startrow=".($i*15-15)."\">".$i."</a>"; |
|
93 endif; |
|
94 if($i !== round($pages)) : |
|
95 echo " · "; |
|
96 endif; |
|
97 } |
|
98 echo "</p>"; |
|
99 endif; |
|
100 ?> |
|
101 <div id="container"> |
|
102 <div class="content_box"> |
|
103 <div class="ocmx-tabs"> |
|
104 <ul class="tabs clearfix"> |
|
105 <li class="selected"><a href="#">Manage</a></li> |
|
106 </ul> |
|
107 </div> |
|
108 <div class="ocmx-content"> |
|
109 <div class="header"><div></div></div> |
|
110 <div class="content clearfix"> |
|
111 <!-- <div class="tablenav clearfix"> --> |
|
112 <p></p> |
|
113 <table class="widefat post fixed"> |
|
114 <thead> |
|
115 <tr> |
|
116 <th>Full Name</th> |
|
117 <th>E-Mail</th> |
|
118 <th>Twitter ID</th> |
|
119 <th width="8%">View</th> |
|
120 <th width="8%">Mail</th> |
|
121 <th width="8%">Block</th> |
|
122 <th width="8%">Delete</th> |
|
123 </tr> |
|
124 </thead> |
|
125 <?php |
|
126 $last_post_id = "alternate"; |
|
127 foreach($fetch_subscribers as $subscriber_details) : |
|
128 $cId = $subscriber_details->commentId; |
|
129 if($last_post_id !== $subscriber_details->comment_post_ID) : |
|
130 if($use_class == "alternate") : |
|
131 $use_class = ""; |
|
132 else: |
|
133 $use_class = "alternate"; |
|
134 endif; |
|
135 ?> |
|
136 <tr class="<?php echo $use_class; ?>"> |
|
137 <td colspan="7"> |
|
138 <strong>Post Title: </strong> |
|
139 <a href="<?php echo get_permalink($subscriber_details->comment_post_ID); ?>" class="std_link" target="_blank"> |
|
140 <?php echo get_the_title($subscriber_details->comment_post_ID); ?> |
|
141 </a> |
|
142 </td> |
|
143 </tr> |
|
144 <?php |
|
145 endif; |
|
146 ?> |
|
147 <tr class="<?php echo $use_class; ?>"> |
|
148 <td><?php echo $subscriber_details->comment_author; ?></td> |
|
149 <td><?php echo $subscriber_details->comment_author_email; ?></td> |
|
150 <td> |
|
151 <input type="hidden" name="post_id-<?php echo $cId; ?>" value="1" /> |
|
152 <a href="http://twitter.com/<?php echo $subscriber_details->twitter; ?>" class="std_link" target="_blank"> |
|
153 <?php echo $subscriber_details->twitter; ?> |
|
154 </a> |
|
155 </td> |
|
156 <td class="t_center"> |
|
157 <a href="<?php echo $_SERVER['REQUEST_URI']; ?>&delete_comment=1&comment_id=<?php echo $cId; ?>" class="std_link" id="view-comment-<?php echo $cId; ?>" title="View Comment"> |
|
158 <img src="<?php bloginfo('template_directory'); ?>/ocmx/images/comment.gif" alt="view" /> |
|
159 </a> |
|
160 </td> |
|
161 <td class="t_center"> |
|
162 <?php if($subscriber_details->email_subscribe == 1): ?> |
|
163 <input type="checkbox" checked="checked" name="mail_comment-<?php echo $cId; ?>" id="mail_comment-<?php echo $cId; ?>"/> |
|
164 <?php else: ?> |
|
165 <input type="checkbox" name="mail_comment-<?php echo $cId; ?>" id="mail_comment-<?php echo $cId; ?>"/> |
|
166 <?php endif?> |
|
167 </td> |
|
168 <td class="t_center"> |
|
169 <?php if($subscriber_details->block_user == 1): ?> |
|
170 <input type="checkbox" checked="checked" name="block_comment-<?php echo $cId; ?>" id="block_comment-<?php echo $cId; ?>"/> |
|
171 <?php else : ?> |
|
172 <input type="checkbox" name="block_comment-<?php echo $cId; ?>" id="block_comment-<?php echo $cId; ?>"/> |
|
173 <?php endif?> |
|
174 </td> |
|
175 <td class="t_center"> |
|
176 <input type="checkbox" name="delete_comment-<?php echo $cId; ?>" id="delete_comment-<?php echo $cId; ?>"/> |
|
177 </td> |
|
178 </tr> |
|
179 <tr class="no_display" id="ocmx-comment-<?php echo $cId; ?>"> |
|
180 <td colspan="7"> |
|
181 <p> |
|
182 <?php |
|
183 $use_comment = apply_filters('wp_texturize', $subscriber_details->comment_content); |
|
184 $use_comment = str_replace("\n", "<br>", $use_comment); |
|
185 echo $use_comment; |
|
186 ?> |
|
187 </p> |
|
188 </td> |
|
189 </tr> |
|
190 <?php |
|
191 $last_post_id = $subscriber_details->comment_post_ID; |
|
192 endforeach; ?> |
|
193 </table> |
|
194 <!-- </div> --> |
|
195 </div> |
|
196 <div class="footer"><div></div></div> |
|
197 |
|
198 </div> |
|
199 </div> |
|
200 </div> |
|
201 <?php |
|
202 if($pages > 1) : |
|
203 echo "<p>Pages: "; |
|
204 for ($i = 1; $i < ($pages + 1); $i++) |
|
205 { |
|
206 if($startrow == ($i*15-15)) : |
|
207 echo "<a href=\"".$_SERVER['REQUEST_URI']."&startrow=".($i*15-15)."\"><strong>".$i."</strong></a>"; |
|
208 else : |
|
209 echo "<a href=\"".$_SERVER['REQUEST_URI']."&startrow=".($i*15-15)."\">".$i."</a>"; |
|
210 endif; |
|
211 if($i !== round($pages)) : |
|
212 echo " · "; |
|
213 endif; |
|
214 } |
|
215 echo "</p>"; |
|
216 endif; |
|
217 ?> |
|
218 <p class="submit"><input name="save" type="submit" value="Save changes" /></p> |
|
219 |
|
220 <div class="clearfix"></div> |
|
221 </form> |
|
222 |
|
223 <div class="clearfix"></div> |
|
224 |
|
225 <?php |
|
226 |
|
227 }; |
|
228 ?> |