============================================================================================================================
Modification Title: Member Approval

Version: 1.0

Author: huskysgrl

Updated for 1.9.5 by : Ahmad
Properly Updated for 1.9.5 by: WormHole

Description:
This modification will not allow members to login until their status has been approved by a Super Administrator or Administrator.
Sends u2u to your choice of members informing them of the new registration and enable Super Administrator or Administrator to approve through the U2U.
This modification will e-mail the user when they are approved.

Compatability: XMB 1.9.5 SP1

Install Note: Before adding this modification to your forum, you should back up all files related to this modification.

License Note: This modification is released under the GPL License v3. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
============================================================================================================================
=======
Step 1:
=======
====================================
Go To Administration Panel --> Insert Raw SQL
====================================

Upload provided file named "SQL.txt" and submit.

============================================================================================================================
=======
Step 2:
=======
=================
Edit File: member.php
=================
==========
Find Code:
==========

        $self['status'] = ($count1 != 0) ? 'Member' : 'Super Administrator';

================
Replace Code With:
================

        // Member Approval Mod Begin
        if ($count1 != '0') {
            if ($SETTINGS['approval'] == 'on') {
                $self['status'] = 'Not Approved';
            } else {
                $self['status'] = 'Member';
            }
        } else {
            $self['status'] = 'Super Administrator';
        }
        // Member Approval Mod End

==========
Find Code:
==========

        if ($emailcheck == "on") {
            altMail($email, $lang['textyourpw'], $lang['textyourpwis']." \n\n$username\n$password2", "From: $bbname <$adminemail>");
        } else {
            $currtime = time() + (86400*30);
            put_cookie("xmbuser", $username, $currtime, $cookiepath, $cookiedomain);
            put_cookie("xmbpw", $password, $currtime, $cookiepath, $cookiedomain);
        }

================
Replace Code With:
================

        // Member Approval Mod Begin
        if ($SETTINGS['approval'] == 'on') {
            $adminmessage = "$username has just registered on $bbname.<br /><br /><strong>Registration Details:</strong><br /><br />Username: $username<br />E-mail: $email<br />Location: $locationnew<br />Site: $site<br />AIM: $aim<br />ICQ: $icq<br />MSN: $msn<br />Yahoo: $yahoo<br />Bio: $bio<br /> Sig: $sig<br /><br />Click to <a href=\"cp.php?action=approve&member=".rawurlencode($username)."\" target=\"blank\">Approve this user account</a>";
            $admin = explode(",", $SETTINGS['appmesslist']);
            for ($i = 0; $i < count($admin); $i++) {
                $admin[$i] = trim($admin[$i]);
                $adminquery = $db->query("SELECT * FROM $table_members WHERE username='$admin[$i]'");
                    while ($adminname = $db->fetch_array($adminquery)) {
                    $db->query("INSERT INTO $table_u2u (u2uid, msgto, msgfrom, type, owner, folder, subject, message, dateline, readstatus, sentstatus) VALUES ('', '$adminname[username]', '$bbname', 'incoming', '$adminname[username]', 'inbox', '$lang[newu2u_adminsubject]', '$adminmessage', '" . time() . "', 'no', 'no')");
                }
            }
        }

        if ($SETTINGS['emailcheck'] == 'on') {
            altMail($email, $lang['textyourpw'], $lang['textyourpwis']." \n\n$username\n$password2", "From: $bbname <$adminemail>");
        } elseif ($SETTINGS['emailcheck'] == 'off' && $SETTINGS['approval'] == 'off') {
            $currtime = time() + (86400*30);
            put_cookie("xmbuser", $username, $currtime, $cookiepath, $cookiedomain);
            put_cookie("xmbpw", $password, $currtime, $cookiepath, $cookiedomain);
        }
        // Member Approval Mod End

============================================================================================================================
=======
Step 3:
=======
===============
Edit File: post.php
===============
==========
Find Code:
==========

if ($self['status'] == "Banned") {
    error($lang['bannedmessage']);
}

===============
Add Code Below:
===============

// Member Approval Mod Begin
if ($self['status'] == 'Not Approved') {
    error($lang['notapprovedmessage']);
}
// Member Approval Mod End

==========
Find Code:
==========

            if ($self['status'] == "Banned") {
                error($lang['bannedmessage']);
            }

===============
Add Code Below:
===============

            // Member Approval Mod Begin
            if ($self['status'] == 'Not Approved') {
                error($lang['notapprovedmessage']);
            }
            // Member Approval Mod End

==========
Find Code:
==========

            if ($self['status'] == "Banned") {
                error($lang['bannedmessage']);
            }

===============
Add Code Below:
===============

            // Member Approval Mod Begin
            if ($self['status'] == 'Not Approved') {
                error($lang['notapprovedmessage']);
            }

==========
Find Code:
==========

        if ($self['status'] == "Banned") {
            error($lang['bannedmessage']);
        }

===============
Add Code Below:
===============

        // Member Approval Mod Begin
        if ($self['status'] == 'Not Approved') {
            error($lang['notapprovedmessage']);
        }
        // Member Approval Mod End

============================================================================================================================
=======
Step 4:
=======
==============
Edit File: cp.php
==============
==========
Find Code: 
==========

        $echeckon = $echeckoff = '';
        if ($SETTINGS['emailcheck'] == "on") {
            $echeckon = $selHTML;
        } else {
            $echeckoff = $selHTML;
        }

===============
Add Code Below:
===============

        // Member Approval Mod Begin
        $mapproveon = $mapproveoff = '';
        switch ($SETTINGS['approval']) {
            case 'on':
                $mapproveon = $selHTML;
                break;
            default:
                $mapproveoff = $selHTML;
                break;
        }
        // Member Approval Mod End

==========
Find Code: 
==========


        printsetting1($lang['doublee'], 'doubleenew', $doubleeon, $doubleeoff);
        ?>

================
Replace Code With:
================

        printsetting1($lang['doublee'], 'doubleenew', $doubleeon, $doubleeoff);
        // Member Approval Mod Begin
        printsetting1($lang['memberapproval'], 'approvalnew', $mapproveon, $mapproveoff);
        ?>
        <tr class="tablerow">
        <td bgcolor="<?php echo $altbg1?>"><?php echo $lang['appuserlist']?></td>
        <td bgcolor="<?php echo $altbg2?>"><textarea rows="4" cols="30" name="appuserlist"><?php echo $SETTINGS['appmesslist']?></textarea></td>
        </tr>
        <!-- Member Approval Mod End -->

==========
Find Code:
==========

        $resetSigNew = ($resetSigNew == 'on') ? 'on' : 'off';

==============
Add Code Below:
==============

        // Member Approval Mod Begin
        $approvalnew = ($approvalnew == 'on') ? 'on' : 'off';
        // Member Approval Mod End

==========
Find Code: 
==========


        $db->query("UPDATE $table_settings

=============================
Find Code In-Line In Above Statement: 
=============================

");

================
Replace Code With:
================

, approval='$approvalnew', appmesslist='$appuserlist'");

==========
Find Code: 
==========


            <option value="Member"><?php echo $lang['textmem']?></option>

===============
Add Code Below: 
===============

            <!-- Member Approval Mod Begin -->
            <option value="Not Approved"><?php echo $lang['textapproveselect']?></option>
            <!-- Member Approval Mod End -->

==========
Find Code: 
==========

                    case 'Member':
                        $memselect = $selHTML;
                        break;

==============
Add Code Below: 
==============

                    // Member Approval Mod Begin
                    case 'Not Approved':
                        $appselect = $selHTML;
                        break;
                    // Member Approval Mod End

==========
Find Code: 
==========

                <option value="Member" <?php echo $memselect?>><?php echo $lang['textmem']?></option>

===============
Add Code Below: 
===============

                <!-- Member Approval Mod Begin -->
                <option value="Not Approved" <?php echo $appselect; ?>><?php echo $lang['textapproveselect']; ?></option>
                <!-- Member Approval Mod End -->

==========
Find Code: 
==========

                $memselect = "";

===============
Add Code Below: 
===============

                // Member Approval Mod Begin
                $appselect = "";
                // Member Approval Mod End

==========
Find Code: 
==========

            $memselect = "";

===============
Add Code Below: 
===============

            // Member Approval Mod Begin
            $appselect = "";
            // Member Approval Mod End

==========
Find Code: 
==========

if ($action == "deleteposts") {

===============
Add Code Above:
===============

// Member Approval Mod Begin
if ($action == 'approve') {
    $query = $db->query("SELECT * FROM $table_members WHERE username='$member'");
    $mem = $db->fetch_array($query);
    if ($mem['status'] != 'Not Approved') {
        echo "<tr bgcolor=\"$altbg2\" class=\"ctrtablerow\"><td>$lang[alreadyapproved]</td></tr>";
        exit();
    } else {
        $subject = "Your registration has been approved!";
        $message = "Your registration at $bbname has been approved. You may now view and post in the forums! Look forward to seeing you there!";
        altMail($mem['email'], $subject, $message, "From: $bbname <$adminemail>");
        $db->query("UPDATE $table_members SET status='Member' WHERE username='$member'");
        echo "<tr bgcolor=\"$altbg2\" class=\"ctrtablerow\"><td>$lang[textapprovalsuccess]</td></tr>";
        exit();
    }
}
// Member Approval Mod End

============================================================================================================================
=======
Step 5:
=======
===============
Edit File: misc.php
===============
==========
Find Code: 
==========

                if ($query && $db->num_rows($query) == 1) {
                    $member = $db->fetch_array($query);

===============
Add Code Below:
===============

                // Member Approval Mod Begin
                if ($member['status'] == 'Not Approved') {
                    error($lang['notapprovedmessage']);
                }
                // Member Approval Mod End

============================================================================================================================
=======
Step 6:
=======
============
Edit File: header.php
============
=============================
Add Code To End Of File ABOVE  ?>
=============================

// Member Approval Mod Begin
if (X_MEMBER && $self['status'] == 'Not Approved') {
    error($lang['notapprovedmessage']);
}
// Member Approval Mod End

============================================================================================================================
=======
Step 7:
=======
=======================
Edit File: lang/English.lang.php
=======================
=============================
Add Code To End Of File ABOVE  ?>
=============================

// Member Approval Mod Begin
$lang['textapprovalsuccess'] = "Approval Successful!";
$lang['appuserlist'] = "Users that receive u2u with approval details: (separate with commas!)";
$lang['memberapproval'] = "Require new members to be approved?";
$lang['newu2u_adminsubject'] = "New Registration";
$lang['notapprovedmessage'] = "Your status has not yet been approved, or your approved status has been revoked";
$lang['textapproveselect'] = "Not Approved";
$lang['alreadyapproved'] = "This member has already been approved";
// Member Approval Mod End

============================================================================================================================
Enjoy!