PunBB Mod
Complete Management of the posts

Mod translated from French

MOD (adapted for 1.2.6)

Modulate management complete of the posts in mass or individual (function moderator/administrator) :

SCREENSHOTS (from CtrlAltSuppr.com)



SOURCE CODE

VIEWTOPIC.PHP

Line 186, replace :
$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts'], true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
By :
$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id LEFT JOIN '.$db->prefix.'online AS o ON (o.user_id=u.id AND o.user_id!=1 AND o.idle=0) WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$pun_user['disp_posts']) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
Line 311, after :
			$signature = parse_signature($cur_post['signature']);
			$signature_cache[$cur_post['poster_id']] = $signature;
		}
	}
Add :
	$resultb = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$id.' ORDER BY posted LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
	$topic_post_id = $db->result($resultb);
	$is_topic_post = ($cur_post['id'] == $topic_post_id) ? true : false;
Line 314, replace :
	<h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?> </span><a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
By :
	<h2><span><span class="conr">#<?php echo ($start_from + $post_count) ?> </span><?php if($is_admmod && !$is_topic_post) : ?><input type="checkbox" name="ps<?php echo $cur_post['id'] ?>" class="postselection" /><?php endif; ?><a href="viewtopic.php?pid=<?php echo $cur_post['id'].'#p'.$cur_post['id'] ?>"><?php echo format_time($cur_post['posted']) ?></a></span></h2>
Line 350, after :
		<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
Add :
		<?php if($is_admmod) : ?>
		<p class="postlink conr" style="width:50%">
		<?php echo $lang_topic['Select label'] ?> :
		<select name="postselection_action" onchange="var urlget='';var chps=document.getElementsByTagName('input');for(var i=0;i<chps.length;++i){if(chps[i].className=='postselection'&&chps[i].checked==true) urlget+='&p'+chps[i].name.substring(2)} document.location='moderate.php?fid=<?php echo $cur_topic['forum_id'] ?>&ptid=<?php echo $id ?>&actionposts='+this.value+urlget">
		<optgroup label="<?php echo $lang_topic['Select label groupe'] ?>">
			<option style="font-style:italic"><?php echo $lang_topic['Select Action'] ?></option>
			<option value="move"><?php echo $lang_topic['Select Deplacer'] ?></option>
			<option value="delete"><?php echo $lang_topic['Select Supprimer'] ?></option>
			<option value="fusion"><?php echo $lang_topic['Select Fusionner'] ?></option>
		</optgroup>
		</select></p>
		<?php endif; ?>

MODERATE.PHP

Line 451, after :
			<p><input type="submit" name="delete_topics_comply" value="<?php echo $lang_misc['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
		</form>
	</div>
</div>
<?php

	require PUN_ROOT.'footer.php';
}
Add :
// Traitement de posts en masse
else if (isset($_GET['actionposts']))
{

	// Recuperation et serialization des posts concernés
	if(!isset($_POST['confirm'])) {
		foreach($_GET as $key => $value) {
			if(empty($value))
				$aposts[] = substr($key,1,strlen($key));
		}
		if(!isset($aposts))
			message($lang_misc['Erreur posts selection']);
		$posts = serialize($aposts);
	}

	switch($_GET['actionposts']) {

		// Déplacement de posts
		case 'move' :

			if(!isset($_POST['confirm'])) {

				//confirm_referrer('viewtopic.php'); // Bug IE
				$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
				require PUN_ROOT.'header.php';

				?> <div class="blockform">
					<h2><?php echo $lang_misc['Deplacer posts'] ?></h2>
					<div class="box">
						<form method="post" action="moderate.php?fid=<?php echo $fid ?>&ptid=<?php echo $_GET['ptid'] ?>&actionposts=move">
							<input type="hidden" name="posts" value="<?php echo urlencode($posts) ?>" />
							<div class="inform">
								<fieldset>
									<legend><?php echo $lang_misc['Choisir topic'] ?></legend>
									<div class="infldset">
										<p><?php echo $lang_misc['Topic destination'] ?><br />
										<input type="text" style="width:50%" name="postsmoveto" /><br />
										<br />
										<input type="checkbox" name="anterieurs" value="1" /> <?php echo $lang_misc['Avertissement date'] ?></p>
									</div>
								</fieldset>
							</div>
							<p><input type="submit" name="confirm" value="<?php echo $lang_misc['Deplacer posts ok'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
						</form>
					</div>
				</div> <?

				require PUN_ROOT.'footer.php';
				break;

			} else {

				confirm_referrer('moderate.php');
				require PUN_ROOT.'include/search_idx.php';

				// Extraction de l'id du topic de destination
				preg_match('/id=([0-9]+)/',$_POST['postsmoveto'], $postsmoveto);
				if(empty($postsmoveto[1]))
					message($lang_misc['Erreur topic destination']);
				$posts = unserialize(urldecode(stripslashes($_POST['posts'])));

				$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$postsmoveto[1].' ORDER BY posted LIMIT 1');
				$topic_post_id = $db->result($result);
				for($i=0; $i < count($posts); $i++) {
					// On réécrit les messages qui sont plus anciens que le topic ou tous si anterieurs a été coché pour avoir un id récent
					if($posts[$i] < $topic_post_id || isset($_POST['anterieurs'])) {
						$post = $db->fetch_assoc($db->query('SELECT * FROM '.$db->prefix.'posts WHERE id='.$posts[$i]));
						$db->query('INSERT INTO '.$db->prefix.'posts(poster,poster_id,poster_ip,poster_email,message,hide_smilies,posted,edited,edited_by,topic_id) VALUES("'.$post['poster'].'", "'.$post['poster_id'].'", "'.$post['poster_ip'].'", '.(!isset($post['poster_email']) ? 'NULL' : '"'.$post['poster_email'].'"').', "'.$post['message'].'", "'.$post['hide_smilies'].'", "'.time().'", '.(!isset($post['edited']) ? 'NULL' : '"'.$post['edited'].'"').', '.(!isset($post['edited_by']) ? 'NULL' : '"'.$post['edited_by'].'"').', "'.$postsmoveto[1].'")');
						// On supprime les doublons qui comportent l'ancienne date
						delete_post($posts[$i], $_GET['ptid']);
						// On supprime la clé du topic qui n'est plus à écrire
						unset($posts[$i]);
					}
				}

				// Si il reste des topic qui sont à insérer avec leur date initiale
				if(!empty($posts))
					$db->query('UPDATE '.$db->prefix.'posts SET topic_id='.$postsmoveto[1].' WHERE id='.implode(' OR id=',$posts));

				redirect('viewtopic.php?id='.$postsmoveto[1], $lang_misc['Posts deplaces']);
				break;

			}


		// Supprimer des posts
		case 'delete' :

			if(!isset($_POST['confirm'])) {

				//confirm_referrer('viewtopic.php'); // Bug IE
				$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
				require PUN_ROOT.'header.php';

				?> <div class="blockform">
					<h2><?php echo $lang_misc['Supprimer posts'] ?></h2>
					<div class="box">
						<form method="post" action="moderate.php?fid=<?php echo $fid ?>&ptid=<?php echo $_GET['ptid'] ?>&actionposts=delete">
							<input type="hidden" name="posts" value="<?php echo urlencode($posts) ?>" />
							<div class="inform">
								<fieldset>
									<legend><?php echo $lang_misc['Confirmer'] ?></legend>
									<div class="infldset">
										<p><?php echo $lang_misc['Confirmer suppression'] ?><br />
									</div>
								</fieldset>
							</div>
							<p><input type="submit" name="confirm" value="<?php echo $lang_misc['Supprimer posts ok'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
						</form>
					</div>
				</div> <?

				require PUN_ROOT.'footer.php';
				break;

			} else {

				confirm_referrer('moderate.php');
				require PUN_ROOT.'include/search_idx.php';

				$posts = unserialize(urldecode(stripslashes($_POST['posts'])));

				// On vérifie que le post initial du topic ne fait pas partie de la sélection
				$result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$_GET['ptid'].' ORDER BY posted LIMIT 1');
				$topic_post_id = $db->result($result);
				if(isset($posts[$topic_post_id]))
					unset($posts[$topic_post_id]);

				// On supprime les topics concernés
				foreach($posts AS $post)
					delete_post($post, $_GET['ptid']);

				redirect('viewtopic.php?id='.$_GET['ptid'], $lang_misc['Posts supprimes']);
				break;

			}


		// Fusionner des posts
		case 'fusion' :

			if(!isset($_POST['confirm'])) {

				//confirm_referrer('viewtopic.php'); // Bug IE
				$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / '.$lang_misc['Moderate'];
				require PUN_ROOT.'header.php';

				?> <div class="blockform">
					<h2><?php echo $lang_misc['Fusionner posts'] ?></h2>
					<div class="box">
						<form method="post" action="moderate.php?fid=<?php echo $fid ?>&ptid=<?php echo $_GET['ptid'] ?>&actionposts=fusion">
							<input type="hidden" name="posts" value="<?php echo urlencode($posts) ?>" />
							<div class="inform">
								<fieldset>
									<legend><?php echo $lang_misc['Confirmer'] ?></legend>
									<div class="infldset">
										<p><?php echo $lang_misc['Separer fusion'] ?><br />
										<textarea name="fusion_sep"></textarea><br />
										<br />
										<?php echo $lang_misc['Avertissement fusion'] ?>
									</div>
								</fieldset>
							</div>
							<p><input type="submit" name="confirm" value="<?php echo $lang_misc['Fusionner posts ok'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
						</form>
					</div>
				</div> <?

				require PUN_ROOT.'footer.php';
				break;

			} else {

				confirm_referrer('moderate.php');
				require PUN_ROOT.'include/search_idx.php';

				$posts = unserialize(urldecode(stripslashes($_POST['posts'])));
				sort($posts);
				reset($posts);

				// On récupére et on concatène les différents messages
				$message_add = '';
				for($i=0; $i < count($posts); $i++)
					$message_add .= $db->result($db->query('SELECT message FROM '.$db->prefix.'posts WHERE id='.$posts[$i])).$_POST['fusion_sep'];

				// On écrit la concaténation à la place du message du plus ancien post
				$db->query('UPDATE '.$db->prefix.'posts SET message="'.$message_add.'" WHERE id='.$posts[0]);

				// On supprime tous les messages sauf le plus ancien
				unset($posts[0]);
				foreach($posts AS $post)
					delete_post($post, $_GET['ptid']);

				redirect('viewtopic.php?id='.$_GET['ptid'], $lang_misc['Posts fusionnes']);
				break;

			}


		// Destination par défaut - Erreur
		default :
			message($lang_misc['Erreur action']);

	}
}

LANG/ENGLISH/MISC.PHP

At the end, replace :
);
By :
,
// Mass post management
'Erreur action'			=>	'Error: The wished action isn\'t available',
'Erreur posts selection'	=>	'Error: You haven't select any post',
'Deplacer posts'		=>	'Move posts',
'Choisir topic'			=>	'Choose the destination topic',
'Topic destination'		=>	'Destination topic URL',
'Avertissement date'		=>	'Apply the current date to display the posts at the bottom (in the contrary case, the order of publication will be respected)<br /><br /><strong>Caution</strong>, the oldest posts than the topic destination will be automatically placed at the end of this one.',
'Deplacer posts ok'		=>	'Move',
'Erreur topic destination'	=>	'Error: The destination topic URL isn't valid',
'Posts deplaces'		=>	'The posts were indeed moved',
'Supprimer posts'		=>	'Delete posts',
'Confirmer'			=>	'Confirm',
'Confirmer suppression'		=>	'Confirm to delete the selected posts ?',
'Supprimer posts ok'		=>	'Delete',
'Posts supprimes'		=>	'The posts were indeed deleted',
'Fusionner posts'		=>	'Amalgamate posts',
'Separer fusion'		=>	'Separate the posts by',
'Avertissement fusion'		=>	'<strong>Note :</strong> The finally post will have the most older post informormations.',
'Fusionner posts ok'		=>	'Amalgamate',
'Posts fusionnes'		=>	'The posts were indeed amalgamated'
);

LANG/ENGLISH/TOPIC.PHP

At the end, replace :
);
By :
,
'Select label'			=>	'For the selection',
'Select label groupe'		=>	'Selection management',
'Select Action'			=>	'Action',
'Select Deplacer'		=>	'Move posts',
'Select Supprimer'		=>	'Delete posts',
'Select Fusionner'		=>	'Amalgamate posts'
);

STYLE/IMPORTS/BASE.CSS

At the end, add :
INPUT.postselection {
	MARGIN-TOP: -5px;
	MARGIN-RIGHT: 5px
}

Save the files and upload (overwrite).
CtrlAltSuppr.com