2012-11-14 - [GRASE-Hotspot] Adjust a User’s expiry date

Header Data

From: Bob Hunt <bo***2@gmail.com>
Message Hash: 7d295f2cc10baab3410965a98a605dfbbbeb61625d1f1538dd8fd281323125be
Message ID: <CAA-jMMQZzVLxVsWYKZeCUp6VkFu=SRd2Fi=JnRH8iCNdu523-g@mail.gmail.com>
Reply To: N/A
UTC Datetime: 2012-11-14 21:21:24 UTC
Raw Date: Thu, 15 Nov 2012 15:21:24 +1100

Raw message

Hi Tim,

Many times I've wished that I could easily adjust a user's expiry-date.

 I use monthly expiry based accounts and sometimes users renew weeks before
expiry or book 2, 3 or 6 months ahead and there are many more instances
which cause issues.

There's  always the option of creating another group for the purpose, but
it gets ridiculous having many groups with single users.

So I decided to have a go at adding a function to the edit user page for
this purpose and it turned out to be fairly straightforward.

---------------------------------------------------------------------------------
Here is a handy function to make it easy for Grase Admin to set a user's
expiry-date to a specific date. Validation of the date entered is not done
but mis-entering the expiry-date simply results in it being set it to Jan
01 1970and an expired account. The date then just needs re-entering with
more care.

Two files need to have code inserted:

Insert into /usr/share/grase/www/radmin/
edituser.php around line 183:
/////////////////////////////////////CODE///////////////////////////////////////////
if(isset($_POST['Change_Expiry']))
    {
        $newExpiry = $_POST['Change_Expiry'];
        database_update_expirydate($username, $newExpiry)
;//expiry_for_group(getDBUserGroup($username)));
        $success[] = T_("Expiry updated");
        AdminLog::getInstance()->log("Expirydate for $username updated to
$newExpiry");
        $smarty->assign("error", $error);
        $smarty->assign("success", $success);
        require('display.php');
        die; // TODO: Recode so don't need die (too many nests?)
    }
////////////////////////////////////////////////////////////////////////////////////////

Insert into /usr/share/grase/www/radmin/templates/edituser.tpl around line
51:
///////////////////////////////////CODE//////////////////////////////////////////////
<div>
<label for='Change_Expiry'>{t}Change Expirydate (Use correct date
format){/t}</label>
<input type="text" class="default_swap" id="Change_Expiry"
name="Change_Expiry" value='{$user.Expiration}' {t}Enter a new expirydate
in the same format{/t}"/>
<span id='ChangeExpiryInfo'>{t}Entering wrong format will set expiry-date
to 1970! (Expiry-time is not needed){/t}</span>
</div>
/////////////////////////////////////////////////////////////////////////////////////////////////////


-- 
Bob Hunt
20 Clarke Street
Wyndham
NSW 2550
Australia

Phone/fax 61 (0)2 64942030

Thread