Sponsored Content
Top Forums Web Development Notes with Ravinder on Badging System Development Part II Post 303028303 by Neo on Friday 4th of January 2019 12:04:37 AM
Old 01-04-2019
Note, I'm jumping on a plane in a few hours, so I don't have time to check this properly, but I'm thinking:

Code:
<?php
$day = 60 * 60 * 24;
$dayago = time() - $day;
$incrementseq = "UPDATE user SET lastdayactive = (UNIX_TIMESTAMP()/(60*60*24)), daysinsequence =  daysinsequence +1 WHERE userid =" . $uid;
$selectday = "SELECT lastdayactive AS lastactive FROM user WHERE userid =" . $uid;
$resetday = "UPDATE user SET lastdayactive = (UNIX_TIMESTAMP()/(60*60*24)), daysinsequence =  1 WHERE userid =" . $uid;

$day = $vbulletin->db->query_first($selectday);

if ($day['lastactive'] > $dayago && $day['lastactive'] <= $dayago * 2) {
    $status = $vbulletin->db->query_write($incrementseq);
} elseif ($day['lastactive'] > $dayago * 2) {
    $status = $vbulletin->db->query_write($resetday);
}

$getseq = "SELECT daysinsequence AS daysactive FROM user WHERE userid =" . $uid;
$days = $vbulletin->db->query_first($getseq);
if ($days['daysactive'] > 14) {
    $color['fahistory'] == 'black';
} elseif ($days['daysactive'] > 7) {
    $color['fahistory'] == 'indigo';
} elseif ($days['daysactive'] > 3) {
    $color['fahistory'] == 'blue';
} elseif ($days['daysactive'] > 1) {
    $color['fahistory'] == 'limegreen';
} else {
    $color['fahistory'] == 'lightgray';
}
$badgejs .= 'badge["fahistory"] = "' . $color['fahistory'] . '";';
$badgejs .= 'badge["fahistoryval"] = "' . number_format($days['daysactive']) . '";';

Please take a look and let me know what you think Ravinder!

Thanks

PS: I have not debugged that code above yet and realize that we need to add logic to not query the DB after we reset; because we already have the value (1) so no reason to do the extra query, etc.
This User Gave Thanks to Neo For This Post:
 

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

New Badging System - Badges Prototype Beta 1 (Badges Only)

Today I mapped out the new badging system using FA icons, Beta 1 in no particular order except a 6 x 8 grid: https://www.unix.com/members/1-albums215-picture991.png The prototype HTML code for this layout: <style> .fa-badge-grid { font-size: 1.5em; } .row { ... (38 Replies)
Discussion started by: Neo
38 Replies

2. What is on Your Mind?

Status of Badging System - Beta 1

Dear All, Here is the current status of the badging system: The Beta 1 phase of the new badging system is close to completion. 42 prototype badges have been "allocated" 6 prototype badge slots are held in reserve The "alert you have new badges" prototype is running and is currently... (4 Replies)
Discussion started by: Neo
4 Replies

3. What is on Your Mind?

Badging System: UNIX.COM Bug Hunter Badge (New)

I have moved the bug badge out of reserve and into the main stream. Basically, I will assign a color level like the others, based on who has made a good actionable bug report for UNIX.COM. "Good" means screenshots, links, and even details from web dev tools our the HTML source code. So far,... (0 Replies)
Discussion started by: Neo
0 Replies
LEAVE(1)						    BSD General Commands Manual 						  LEAVE(1)

NAME
leave -- remind you when you have to leave SYNOPSIS
leave [[+]hhmm] DESCRIPTION
leave waits until the specified time (within the next 12 hours), then reminds you that you have to leave by writing to the TTY that you exe- cuted leave on. You are reminded 5 minutes and 1 minute before the actual time, at the time, and every minute thereafter. When you log off, leave exits just before it would have printed the next message. OPTIONS
hhmm The time of day is in the form hhmm where hh is a time in hours (on a 12 or 24 hour clock), and mm are minutes. However, all times are converted to a 12 hour clock, and assumed to be in the next 12 hours. An attempt to set an alarm for farther into the future will be truncated to within the next 12 hours. + If the time is preceded by '+', the alarm will go off in hours and minutes from the current time. If no argument is given, leave prompts with "When do you have to leave?". A reply of newline causes leave to exit, otherwise the reply is assumed to be a time. This form is suitable for inclusion in a ~/.login or ~/.profile. SEE ALSO
calendar(1), csh(1), sh(1) HISTORY
The leave command appeared in 3.0BSD. BUGS
In the modern age with X(7) and window multiplexing programs like window(1) and screen(1), the leave command's reminders and admonitions might not be seen if the user has the window where leave was started minimized or obscured. This all begs for a more general user notifications system to be implemented. BSD
January 19, 2002 BSD
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy