2015-02-14, 02:07 AM
Anyone have any ideas for some fairly (preferably no template) simple plugins I could make? I've already submitted one I made which is pending approval (and I think some people would find useful albeit not everyone).
(2015-02-14, 06:28 AM)Omar G. Wrote: [ -> ]A system that would allow developers to switch/flag/fake usergroups to test as different usergrous without login in and out every five minutes.
I'm sure one was coded some time ago but didn't find it.
Bumping `````` - Seriously, I will try to create any plugins that don't require template changes or, new pages.(2015-02-14, 03:44 PM)Ben_Conway Wrote: [ -> ]A plugin which gives a user 1 rep point for every 30 posts they make?
$plugins->add_hook( "newreply_do_newreply_end", "ircher_check_posts" );
$plugins->add_hook("newthread_do_newthread_end", "ircher_check_posts" );
function ircher_check_posts() {
global $db, $mybb;
$posts = $mybb->setting['ircher_post_rep_posts'];
$rep = $mybb->setting['ircher_post_rep_rep'];
$threadnum = $mybb->user['threadnum'];
$postnum = $mybb->user['postnum'];
$user_id = $mybb->user['uid'];
if ( (($postnum + $threadnum) % $posts) == 0) {
$query = $db->simple_select( 'users', 'ircher_received_rep', "uid = $user_id" );
$current_extra_rep = $db->fetch_field( $query, 'ircher_received_rep' );
$required_rep = $rep * ((int) (($postnum + $threadnum) / $posts ));
// Loop until we reach the total rep needed
for (; $current_extra_rep < $required_rep; $current_extra_rep += $rep) {
$db->update_query( 'users', "ircher_received_rep = $current_extra_rep + $rep", "uid = $user_id" );
$mybb->user['reputation'] += $rep;
}
}
}