Title: Edit Time For Posts v3.1

Author: Jonathon

Description:
 - Allows you to control how long - after being posted - someone can edit their posts.
 - You can control the length in : Days, Hours or Minutes.
 - If it is past the time length set; only Admins and Moderators can edit a post.
 - Also makes it so that no matter whether this feature is enabled or disabled anyone that isn't logged in won't see the "Edit" button.
 - By default this modification is turn Off.

Copyright:  2006 jonathon@jdmnet.org. All rights reserved.

Compatability: XMB 1.9.8 SP3

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. 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 Admin Panel -> Insert Raw SQL -> Paste Code Below & Click Submit:
=======================================================

ALTER TABLE `$table_settings` ADD `edittime` int(6) NOT NULL default '0';
ALTER TABLE `$table_settings` ADD `editlength` int(5) NOT NULL default '0';
ALTER TABLE `$table_settings` ADD `editstatus` set('on','off') NOT NULL default 'OFF';

=============================================================================================================================
=======
Step 2:
=======
=======================
Edit File: lang/English.lang.php
=======================
=======================
Add To End Of File Above ?>
=======================

// Edit Time For Posts Mod Begin
$lang['etime_edit'] = "How long can users edit their own posts?<br /><small>(<em>after making a post</em>)</small>";
$lang['etime_disable'] = "Disable Edit Post Time Feature?";
$lang['etime_offnote'] = "<small><em>If you \"disable\" this feature, users will be able to edit their posts any time they want.</em></small>";
$lang['etime_day'] = "Day(s)";
$lang['etime_hour'] = "Hour(s)";
$lang['etime_min'] = "Minute(s)";
// Edit Time For Posts Mod End

=============================================================================================================================
=======
Step 3:
=======
==============
Edit File: cp.php
==============
======
Find:
======

        $avchecked[0] = $avchecked[1] = $avchecked[2] = false;
        if (!empty($avatarlist)) {
            $avchecked[1] = true;
        } else if (!empty($avataroff)) {
            $avchecked[2] = true;
        } else {
            $avchecked[0] = true;
        }

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

        // Edit Time For Posts Mod Begin
        $etime1 = $etime2 = $etime3 = '';
        switch ( $SETTINGS['editlength'] ) {
            case '86400':
                $etime1 = $selHTML;
                break;
            case '3600':
                $etime2 = $selHTML;
                break;
            default:
                $etime3 = $selHTML;
                break;
        }

        $etime4 = $etime5 = '';
        switch ( $SETTINGS['editstatus'] ) {
            case 'off':
                $etime4 = $selHTML;
                break;
            default:
                $etime5 = $selHTML;
                break;
        }
        // Edit Time For Posts Mod End

======
Find:
======

        printsetting2($lang['pruneusers'], 'pruneusersnew', ((int)$SETTINGS['pruneusers']), 3);
        ?>

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

        <!-- Edit Time For Posts Mod Begin -->
        <tr class="tablerow">
        <td bgcolor="<?php echo $THEME['altbg1']?>"><?php echo $lang['etime_edit']?></td>
        <td bgcolor="<?php echo $THEME['altbg2']?>">
        <input type="text" size="5" value="<?php echo $SETTINGS['edittime']?>" name="edittimenew" maxlength="5" />&nbsp;&nbsp;
        <select name="editlengthnew">
        <option value="86400" <?php echo $etime1 ?>><?php echo $lang['etime_day']?></option>
        <option value="3600" <?php echo $etime2 ?>><?php echo $lang['etime_hour']?></option>
        <option value="60" <?php echo $etime3 ?>><?php echo $lang['etime_min']?></option>
        </select>
        </td>
        </tr>
        <tr class="tablerow">
        <td bgcolor="<?php echo $THEME['altbg1']?>"><?php echo $lang['etime_disable']?></td>
        <td bgcolor="<?php echo $THEME['altbg2']?>">
        <select name="editstatusnew">
        <option value="off" <?php echo $etime4 ?>><?php echo $lang['textyes']?></option>
        <option value="on" <?php echo $etime5 ?>><?php echo $lang['textno']?></option>
        </select>
        <br /><br /><?php echo $lang['etime_offnote'] ?></p>
        </td>
        </tr>
        <!-- Edit Time For Posts Mod End -->

======
Find: 
======

        $smileyinsertnew = formOnOff('smileyinsertnew');

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

        // Edit Time For Posts Mod Begin
        $edittimenew = formInt('edittimenew');
        $editlengthnew = ($editlengthnew == 0 ? '86400' : ($editlengthnew * 3600));
        $editstatusnew = formOnOff('editstatusnew');
        // Edit Time For Posts Mod End

======
Find:
======

        $db->query("UPDATE ".X_PREFIX."settings SET

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

        $db->query("UPDATE ".X_PREFIX."settings SET
            edittime='$edittimenew',
            editlength='$editlengthnew',
            editstatus='$editstatusnew',

=============================================================================================================================
=======
Step 4:
=======
===================
Edit File: viewthread.php
===================
======
Find:
======

        $edit = '';
        if (X_ADMIN || $status1 == 'Moderator' || ($thread['closed'] != 'yes' && $post['author'] == $xmbuser)) {
            eval('$edit = "'.template('viewthread_post_edit').'";');
        }

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

        // Edit Time For Posts Mod Begin
        $edit = '';
        switch ($SETTINGS['editstatus']) {
            case 'off':
                if (X_ADMIN || $status1 == 'Moderator' || (X_MEMBER && $thread['closed'] != 'yes' && $post['author'] == $xmbuser)) {
                    eval('$edit = "'.template('viewthread_post_edit').'";');
                }
                break;
            case 'on':
                if ($onlinetime > ($post['dateline'] + ($SETTINGS['edittime'] * $SETTINGS['editlength']))) {
                    if (X_ADMIN || $status1 == 'Moderator') {
                        eval('$edit = "'.template('viewthread_post_edit').'";');
                    }
                } else {
                    if (X_ADMIN || $status1 == 'Moderator' || (X_MEMBER && $thread['closed'] != 'yes' && $post['author'] == $xmbuser)) {
                        eval('$edit = "'.template('viewthread_post_edit').'";');
                    }
                }
                break;
            default:
                $edit = '';
                break;
        }
        // Edit Time For Posts Mod End

=============================================================================================================================
=======
Step 5:
=======

NOW UPLOAD THE CHANGED FILES; WHICH ARE : 

    - YOUR LANG FILE
    - cp.php
    - viewthread.php

YOU WILL FIND THE NEW SETTINGS LISTED UNDER "User Control" IN THE ADMIN PANEL/"Settings" AREA

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