[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 function task_delayedmoderation($task) 12 { 13 global $db, $lang, $plugins; 14 15 require_once MYBB_ROOT."inc/class_moderation.php"; 16 $moderation = new Moderation; 17 18 require_once MYBB_ROOT."inc/class_custommoderation.php"; 19 $custommod = new CustomModeration; 20 21 // Iterate through all our delayed moderation actions 22 $query = $db->simple_select("delayedmoderation", "*", "delaydateline <= '".TIME_NOW."'"); 23 while($delayedmoderation = $db->fetch_array($query)) 24 { 25 if(is_object($plugins)) 26 { 27 $args = array( 28 'task' => &$task, 29 'delayedmoderation' => &$delayedmoderation, 30 ); 31 $plugins->run_hooks('task_delayedmoderation', $args); 32 } 33 34 $tids = explode(',', $delayedmoderation['tids']); 35 $input = my_unserialize($delayedmoderation['inputs']); 36 37 if(my_strpos($delayedmoderation['type'], "modtool") !== false) 38 { 39 list(, $custom_id) = explode('_', $delayedmoderation['type'], 2); 40 $custommod->execute($custom_id, $tids); 41 } 42 else 43 { 44 switch($delayedmoderation['type']) 45 { 46 case "openclosethread": 47 $closed_tids = $open_tids = array(); 48 $query2 = $db->simple_select("threads", "tid,closed", "tid IN({$delayedmoderation['tids']})"); 49 while($thread = $db->fetch_array($query2)) 50 { 51 if($thread['closed'] == 1) 52 { 53 $closed_tids[] = $thread['tid']; 54 } 55 else 56 { 57 $open_tids[] = $thread['tid']; 58 } 59 } 60 61 if(!empty($closed_tids)) 62 { 63 $moderation->open_threads($closed_tids); 64 } 65 66 if(!empty($open_tids)) 67 { 68 $moderation->close_threads($open_tids); 69 } 70 break; 71 case "deletethread": 72 foreach($tids as $tid) 73 { 74 $moderation->delete_thread($tid); 75 } 76 break; 77 case "move": 78 foreach($tids as $tid) 79 { 80 $moderation->move_thread($tid, $input['new_forum']); 81 } 82 break; 83 case "stick": 84 $unstuck_tids = $stuck_tids = array(); 85 $query2 = $db->simple_select("threads", "tid,sticky", "tid IN({$delayedmoderation['tids']})"); 86 while($thread = $db->fetch_array($query2)) 87 { 88 if($thread['sticky'] == 1) 89 { 90 $stuck_tids[] = $thread['tid']; 91 } 92 else 93 { 94 $unstuck_tids[] = $thread['tid']; 95 } 96 } 97 98 if(!empty($stuck_tids)) 99 { 100 $moderation->unstick_threads($stuck_tids); 101 } 102 103 if(!empty($unstuck_tids)) 104 { 105 $moderation->stick_threads($unstuck_tids); 106 } 107 break; 108 case "merge": 109 // $delayedmoderation['tids'] should be a single tid 110 if(count($tids) != 1) 111 { 112 continue 2; 113 } 114 115 // explode at # sign in a url (indicates a name reference) and reassign to the url 116 $realurl = explode("#", $input['threadurl']); 117 $input['threadurl'] = $realurl[0]; 118 119 // Are we using an SEO URL? 120 if(substr($input['threadurl'], -4) == "html") 121 { 122 // Get thread to merge's tid the SEO way 123 preg_match("#thread-([0-9]+)?#i", $input['threadurl'], $threadmatch); 124 preg_match("#post-([0-9]+)?#i", $input['threadurl'], $postmatch); 125 126 if($threadmatch[1]) 127 { 128 $parameters['tid'] = $threadmatch[1]; 129 } 130 131 if($postmatch[1]) 132 { 133 $parameters['pid'] = $postmatch[1]; 134 } 135 } 136 else 137 { 138 // Get thread to merge's tid the normal way 139 $splitloc = explode(".php", $input['threadurl']); 140 $temp = explode("&", my_substr($splitloc[1], 1)); 141 142 if(!empty($temp)) 143 { 144 for($i = 0; $i < count($temp); $i++) 145 { 146 $temp2 = explode("=", $temp[$i], 2); 147 $parameters[$temp2[0]] = $temp2[1]; 148 } 149 } 150 else 151 { 152 $temp2 = explode("=", $splitloc[1], 2); 153 $parameters[$temp2[0]] = $temp2[1]; 154 } 155 } 156 157 if($parameters['pid'] && !$parameters['tid']) 158 { 159 $post = get_post($parameters['pid']); 160 $mergetid = $post['tid']; 161 } 162 else if($parameters['tid']) 163 { 164 $mergetid = $parameters['tid']; 165 } 166 167 $mergetid = (int)$mergetid; 168 $mergethread = get_thread($mergetid); 169 170 if(!$mergethread) 171 { 172 continue 2; 173 } 174 175 if($mergetid == $delayedmoderation['tids']) 176 { 177 // sanity check 178 continue 2; 179 } 180 181 if($input['subject']) 182 { 183 $subject = $input['subject']; 184 } 185 else 186 { 187 $query = $db->simple_select("threads", "subject", "tid='{$delayedmoderation['tids']}'"); 188 $subject = $db->fetch_field($query, "subject"); 189 } 190 191 $moderation->merge_threads($mergetid, $delayedmoderation['tids'], $subject); 192 break; 193 case "removeredirects": 194 foreach($tids as $tid) 195 { 196 $moderation->remove_redirects($tid); 197 } 198 break; 199 case "removesubscriptions": 200 $moderation->remove_thread_subscriptions($tids, true); 201 break; 202 case "approveunapprovethread": 203 $approved_tids = $unapproved_tids = array(); 204 $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})"); 205 while($thread = $db->fetch_array($query2)) 206 { 207 if($thread['visible'] == 1) 208 { 209 $approved_tids[] = $thread['tid']; 210 } 211 else 212 { 213 $unapproved_tids[] = $thread['tid']; 214 } 215 } 216 217 if(!empty($approved_tids)) 218 { 219 $moderation->unapprove_threads($approved_tids); 220 } 221 222 if(!empty($unapproved_tids)) 223 { 224 $moderation->approve_threads($unapproved_tids); 225 } 226 break; 227 case "softdeleterestorethread": 228 $delete_tids = $restore_tids = array(); 229 $query2 = $db->simple_select("threads", "tid,visible", "tid IN({$delayedmoderation['tids']})"); 230 while($thread = $db->fetch_array($query2)) 231 { 232 if($thread['visible'] == -1) 233 { 234 $restore_tids[] = $thread['tid']; 235 } 236 else 237 { 238 $delete_tids[] = $thread['tid']; 239 } 240 } 241 242 if(!empty($restore_tids)) 243 { 244 $moderation->restore_threads($restore_tids); 245 } 246 247 if(!empty($delete_tids)) 248 { 249 $moderation->soft_delete_threads($delete_tids); 250 } 251 break; 252 } 253 } 254 255 $db->delete_query("delayedmoderation", "did='{$delayedmoderation['did']}'"); 256 } 257 258 add_task_log($task, $lang->task_delayedmoderation_ran); 259 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |