Changeset 1104

Show
Ignore:
Timestamp:
05/21/08 02:01:39 (6 months ago)
Author:
so1o
Message:

fixed the defect on the dashboard
added option to reject user

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • approve-user-registration/trunk/approve-user-registration.php

    r1092 r1104  
    66Author: Aditya Naik 
    77Author URI: http://www.adityanaik.com/ 
    8 Version: 0.2 
     8Version: 0.3 
    99*/ 
    1010if (!function_exists('bb_new_user')) : 
     
    120120                bb_update_option('approve_user_registration_options',$options); 
    121121        } 
    122         //print_r($options); 
    123122} 
    124123 
     
    223222               <p class="submit"> 
    224223                  <input type="submit" name="approve_user_registration_button_approve" value="Approve" /> 
     224                  <input type="submit" name="approve_user_registration_button_reject" value="Reject" /> 
    225225                </p> 
    226226                </form> 
     
    236236                        approve_user_registration_approve_user($user); 
    237237                } 
    238         } 
     238        } elseif (isset($_POST['approve_user_registration_button_reject'])) { 
     239                $users = $_POST['userids']; 
     240                if ($users) 
     241                foreach($users as $user) { 
     242                        approve_user_registration_reject_user($user); 
     243                } 
     244        } 
     245         
    239246} 
    240247 
     
    273280} 
    274281 
     282function approve_user_registration_reject_user($user_id) { 
     283        global $bbdb;  
     284         
     285        $user = new BB_User($user_id); 
     286        $user->remove_cap('waitingapproval'); 
     287        $user->remove_cap('member'); 
     288        $user->add_cap('blocked'); 
     289         
     290        $user = bb_get_user($user_id); 
     291         
     292        $message = __("Your user %1\$s has been rejected by the administrator."); 
     293 
     294        return bb_mail( 
     295                bb_get_user_email( $user->ID ), 
     296                bb_get_option('name') . ': ' . __('User Rejected'), 
     297                sprintf( $message, $user->user_login ) 
     298        ); 
     299} 
     300 
    275301add_action('bb_admin-footer.php','approve_user_registration_dashboard');  
    276302function approve_user_registration_dashboard() { 
    277303        global $page,$bb_current_menu; 
    278         $waiting_user = $bb_waiting_users = new BB_Users_By_Role( 'waitingapproval', $_GET['userspage'] ); 
    279         if($bb_current_menu[0] == 'Dashboard' && $waiting_user ) : 
     304        $waiting_user = new BB_Users_By_Role( 'waitingapproval' ); 
     305        if($bb_current_menu[0] == 'Dashboard' && $waiting_user->total_users_for_query > 0 ) : 
    280306                ?> 
    281307                <h3><?php _e('Users waiting for approval'); ?></h3> 
    282308                <ul> 
    283                  <li><a href="<?php echo bb_get_option('path') . 'bb-admin/' . bb_get_admin_tab_link('approve_user_registration_admin_page') ; ?>"><?php echo count($waiting_user) . ((count($waiting_user) == 1) ? ' user' : ' users') . ' waiting for approval'; ?></a> </li> 
     309                 <li><a href="<?php echo bb_get_option('path') . 'bb-admin/' . bb_get_admin_tab_link('approve_user_registration_admin_page') ; ?>"><?php echo $waiting_user->total_users_for_query . (($waiting_user->total_users_for_query == 1) ? ' user' : ' users') . ' waiting for approval'; ?></a> </li> 
    284310                </ul> 
    285311                <?php