/*
+-------------------------------------------------------
| Promote Member For A Certain Time Limit 1.0.0
| ======================================================
| by Dzung Nguyen (ntd1712)
| © 2006 Vietnamese - Invision Resources
|
http://www.invisionviet.net/
| ======================================================
| Date Started: Tue, 22 Aug 2006 23:45 (GMT+7)
| Last Updated: Mon, 18 Dec 2006 12:45 (GMT+7)
| License Info:
http://www.invisionv...net/license.php
+-------------------------------------------------------
*/
Compatibility: IPB v2.2.x
Description :
- Promote member temporarily, then auto demote.
File to edit:
./sources/action_admin/groups.php
./sources/classes/class_session.php
./sources/classes/post/class_post.php
---------------------------------------------------------------------------------------------
First, run the queries below in ACP - SQL Toolbox (step-by-step):
ALTER TABLE `ibf_groups` MODIFY `g_promotion` varchar(22) default '-1&-1&-1';
ALTER TABLE `ibf_members` ADD `pgroup` varchar(15) default '-1&-1';
---------------------------------------------------------------------------------------------
Open: ./sources/action_admin/groups.php
Find: [ function do_delete() ]
//-----------------------------------------
// Look for promotions in case we have members to be promoted to this group...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'g_id', 'from' => 'groups', 'where' => "g_promotion LIKE '{$this->ipsclass->input['id']}&%'" ) );
$prq = $this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row($prq) )
{
$this->ipsclass->DB->do_update( 'groups', array( 'g_promotion' => '-1&-1' ), 'g_id='.$row['g_id'] );
}
Replace with:
//-----------------------------------------
// Look for promotions in case we have members to be promoted to this group...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'g_id', 'from' => 'groups', 'where' => "g_promotion LIKE '{$this->ipsclass->input['id']}&%'" ) );
$prq = $this->ipsclass->DB->simple_exec();
while ( $row = $this->ipsclass->DB->fetch_row($prq) )
{
$this->ipsclass->DB->do_update( 'groups', array( 'g_promotion' => '-1&-1&-1' ), 'g_id='.$row['g_id'] );
}
===============================================
Find: [ function save_group($type='edit') ]
$promotion_a = '-1'; //id
$promotion_b = '-1'; // posts
if (isset($this->ipsclass->input['g_promotion_id']) AND $this->ipsclass->input['g_promotion_id'] > 0)
{
$promotion_a = $this->ipsclass->input['g_promotion_id'];
$promotion_b = $this->ipsclass->input['g_promotion_posts'];
}
Replace with:
$promotion_a = '-1'; //id
$promotion_b = '-1'; // posts
$promotion_c = '-1'; // hours
if (isset($this->ipsclass->input['g_promotion_id']) && $this->ipsclass->input['g_promotion_id'] > 0)
{
$promotion_a = $this->ipsclass->input['g_promotion_id'];
$promotion_b = $this->ipsclass->input['g_promotion_posts'];
if ($this->ipsclass->input['g_promotion_time'] > 0)
{
$promotion_c = $this->ipsclass->input['g_promotion_time'];
}
}
===============================================
Find: [ function save_group($type='edit') ]
'g_promotion' => $promotion_a.'&'.$promotion_b,
Replace with:
'g_promotion' => $promotion_a.'&'.$promotion_b.'&'.$promotion_c,
===============================================
Find: [ function save_group($type='edit') ]
$this->ipsclass->DB->do_update( 'groups', $db_string, 'g_id='.$this->ipsclass->input['id'] );
Add below:
$pgroup = ($promotion_c > 0) ? (time() + $promotion_c * 3600) : '-1&-1';
$this->ipsclass->DB->do_update( 'members', array( 'pgroup' => $pgroup ), 'mgroup='.$this->ipsclass->input['id'] );
===============================================
Find: [ function group_form($type='edit') ]
//-----------------------------------------
// sort out the promotion stuff
//-----------------------------------------
list($group['g_promotion_id'], $group['g_promotion_posts']) = explode( '&', $group['g_promotion'] );
if ($group['g_promotion_posts'] < 1)
{
$group['g_promotion_posts'] = '';
}
Replace with:
//-----------------------------------------
// sort out the promotion stuff
//-----------------------------------------
list($group['g_promotion_id'], $group['g_promotion_posts'], $group['g_promotion_time']) = explode( '&', $group['g_promotion'] );
if ($group['g_promotion_posts'] < 1)
{
$group['g_promotion_posts'] = '';
}
if ($group['g_promotion_time'] < 1)
{
$group['g_promotion_time'] = '';
}
===========================================
Find: [ function group_form($type='edit') ]
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Choose 'Don't Promote' to disable promotions</b>$guest_legend<br>".$this->ipsclass->adskin->js_help_link('mg_promote') ,
'Promote members of this group to: '.$this->ipsclass->adskin->form_dropdown("g_promotion_id", $all_groups, $group['g_promotion_id'] )
.'<br>when they reach '.$this->ipsclass->adskin->form_simple_input('g_promotion_posts', $group['g_promotion_posts'] ).' posts'
) );
Replace with:
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "<b>Choose 'Don\'t Promote' to disable promotions</b>$guest_legend<br />".$this->ipsclass->adskin->js_help_link('mg_promote') ,
'Promote members of this group to: '.$this->ipsclass->adskin->form_dropdown("g_promotion_id", $all_groups, $group['g_promotion_id'] )
.'<br />when they reach '.$this->ipsclass->adskin->form_simple_input('g_promotion_posts', $group['g_promotion_posts'] ).' posts'
.' for '.$this->ipsclass->adskin->form_simple_input('g_promotion_time', $group['g_promotion_time'] ).' hours'
) );
---------------------------------------------------------------------------------------------
Open: ./sources/classes/class_session.php
Find: [ function authorise() ]
//-----------------------------------------
// Check ban status
//-----------------------------------------
Add above:
//-----------------------------------------
// Are we checking for auto demotion?
//-----------------------------------------
if ($this->member['pgroup'] != '-1&-1')
{
list($gid, $gtime) = explode( '&', $this->member['pgroup'] );
if ($gid > 0 && $gtime > 0)
{
if (time() >= $gtime && $this->member['mgroup'] != $gid)
{
# Update this member's profile
$this->ipsclass->DB->simple_construct(array('update' => 'members',
'set' => 'mgroup='.$gid,
'where' => 'id='.$this->member['id']
) );
$this->ipsclass->DB->simple_shutdown_exec();
if (USE_MODULES == 1)
{
require_once ROOT_PATH."modules/ipb_member_sync.php";
$modules = new ipb_member_sync;
$modules->ipsclass = &$this->ipsclass;
$modules->register_class($this);
$modules->on_group_change($this->member['id'], $gid);
}
}
}
}
===========================================
Find: [ function load_member($member_id=0) ]
mgroup_others, temp_ban, sub_end,
Add after:
pgroup,
---------------------------------------------------------------------------------------------
Open: ./sources/classes/post/class_post.php
Find: [ function pf_increment_user_post_count() ]
// Are we checking for auto promotion?
if ($this->ipsclass->member['g_promotion'] != '-1&-1')
{
list($gid, $gposts) = explode( '&', $this->ipsclass->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 )
{
if ( $this->ipsclass->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
if ( USE_MODULES == 1 )
{
$this->modules->register_class($this);
$this->modules->on_group_change($this->ipsclass->member['id'], $gid);
}
}
}
}
Replace with:
// Are we checking for auto promotion?
if ($this->ipsclass->member['g_promotion'] != '-1&-1' || $this->ipsclass->member['g_promotion'] != '-1&-1&-1')
{
list($gid, $gposts, $gtime) = explode( '&', $this->ipsclass->member['g_promotion'] );
if ( $gid > 0 and $gposts > 0 and ( $gtime < 0 or $gtime > time() ) )
{
if ( $this->ipsclass->member['posts'] + 1 >= $gposts )
{
$mgroup = "mgroup='$gid', ";
if ( USE_MODULES == 1 )
{
$this->modules->register_class($this);
$this->modules->on_group_change($this->ipsclass->member['id'], $gid);
}
}
}
}
---------------------------------------------------------------------------------------------
That's all!

©2006 ntd1712