WordPress.org

Plugin Directory

Changeset 565673


Ignore:
Timestamp:
06/30/12 04:02:59 (22 months ago)
Author:
ryanimel
Message:

3.1 update brings bug fix and admin override for forgetful users.

Location:
p2-check-in/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • p2-check-in/trunk/p2-check-in.css

    r563796 r565673  
    108108    opacity: 0.4; 
    109109} 
     110 
     111/* Admin override */ 
     112.checkedin { 
     113    position: relative; 
     114} 
     115 
     116.p2checkin-adminoverride { 
     117    position: absolute; 
     118    right: 0; 
     119    top: 0;  
     120} 
     121 
     122.p2checkin-adminoverride a { 
     123    background: #eee; 
     124    color: #ccc; 
     125    display: block; 
     126    padding: 0 3px; 
     127} 
     128 
     129.p2checkin-adminoverride a:hover { 
     130    color: #D54E21; 
     131} 
     132 
  • p2-check-in/trunk/p2-check-in.php

    r563796 r565673  
    44Plugin URI: http://wordpress.org/extend/plugins/p2-check-in 
    55Description: This plugin adds the ability for users to "check in" to the P2 theme when they're active. Once activated you'll find a new "Who is Checked In" widget that you can add to your sidebar, and a "Log In/I'm here!/I'm leaving!" button will automatically be added to your P2's header. 
    6 Version: 0.3 
     6Version: 0.3.1 
    77Author: Ryan Imel 
    88Author URI: http://wpcandy.com 
     
    1414// Adds the CSS to the front end. 
    1515function p2checkinwidget_enqueue() { 
    16     wp_enqueue_style(  'p2checkinwidget_css', plugins_url('p2-check-in.css', __FILE__), null, '0.3' ); 
     16    wp_enqueue_style(  'p2checkinwidget_css', plugins_url('p2-check-in.css', __FILE__), null, '0.5' ); 
    1717} 
    1818add_action('wp_enqueue_scripts', 'p2checkinwidget_enqueue'); 
     
    114114 */ 
    115115function p2checkinwidget_user( $last_online_ts, $user ) { 
     116     
    116117    $avatar = '<a class="user-img" href="' . get_author_posts_url( $user->ID, $user->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $user->display_name) ) . '">' . get_avatar( $user->user_email, 52 ) . '</a>'; 
    117118    $name = $user->display_name; 
     
    128129    $p2checkin_totaltimedisplay = get_user_meta( $user->ID, 'p2checkin_totaltime', true ); 
    129130    $p2time_readable = number_format( ( $p2checkin_totaltimedisplay / 60 / 60 ), 2, '.', '' ); 
    130  
     131     
    131132    if ( $rwi_checkedin ) { 
    132133         
     
    136137        $timephrase = '<p><strong>Checked in for ' . human_time_diff( $timein, $timenow ) . '</strong></p><p class="minor">Total: ' . $p2time_readable_temp . ' hours<p>'; 
    137138         
     139        // Add the god action if the current user is an admin 
     140        $admincheckout = ''; 
     141         
     142        // Get logged in user info 
     143        global $current_user; 
     144        get_currentuserinfo(); 
     145         
     146        $loggedinuser = $current_user->ID; 
     147        $displayuser = $user->ID; 
     148         
     149        if ( current_user_can('manage_options') && ( $displayuser != $loggedinuser ) ) { 
     150             
     151            // Give the admins a god card 
     152            $admincheckout .= '<p class="p2checkin-adminoverride"><a href="?checkout=true&p2checkinuser=' . $user->ID . '">x</a></p>'; 
     153             
     154        } 
     155         
    138156        // If there's data, woot 
    139         $checkedin_output = $avatar . $link . $timephrase; 
     157        $checkedin_output = $avatar . $link . $timephrase . $admincheckout; 
    140158         
    141159    } else if ( !($rwi_checkedin ) AND ( ( $timenow - $rwi_checkedouttime ) < $timetoshow ) )  { 
     
    159177    get_currentuserinfo(); 
    160178     
     179    // To enable us to prevent cheatin' 
     180    $rwi_checkedin = get_user_meta( $current_user->ID, 'p2checkin_time_checked_in', true ); 
     181    $rwi_checkedouttime = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
     182     
    161183    // Now, is the current user checked in or not? 
    162184    if ( $current_user->ID AND isset( $_GET[checkin] ) ) { 
    163185         
    164         // So we know they're in 
    165         update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', true ); 
    166          
    167         // So we know what time they showed up 
    168         update_user_meta( $current_user->ID , 'p2checkin_time_checked_in', current_time( 'timestamp' , 1 ) ); 
     186        if ( $rwi_checkedin > $rwi_checkedouttime ) { 
     187             
     188            // Do nothing, this person has already checked in. (They just refreshed and queued this up again.) 
     189             
     190        } else { 
     191         
     192            // So we know they're in 
     193            update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', true ); 
     194         
     195            // So we know what time they showed up 
     196            update_user_meta( $current_user->ID , 'p2checkin_time_checked_in', current_time( 'timestamp' , 1 ) ); 
     197         
     198        } 
    169199         
    170200    } else if ( $current_user->ID AND isset( $_GET[checkout] ) ) { 
    171201         
    172         // Prevent cheatin' 
    173         $rwi_checkedin = get_user_meta( $current_user->ID, 'p2checkin_time_checked_in', true ); 
    174         $rwi_checkedouttime = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
    175          
    176202        if ( $rwi_checkedouttime > $rwi_checkedin ) { 
    177203             
    178             echo '<p>Cheating? Tsk tsk.</p>'; 
     204            // Removed, since it would be confusing for 99% of users to see this message. 
     205            //echo '<p>Cheating? Tsk tsk.</p>'; 
    179206         
    180207        } else { 
    181208             
    182             // So we know they're out 
    183             update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', false ); 
    184  
    185             // So we know what time they left 
    186             update_user_meta( $current_user->ID , 'p2checkin_time_checked_out', current_time( 'timestamp', 1 ) ); 
    187  
    188             // Keep a running total of checked in time. Why not? 
    189             $rwi_checkedouttime_realz = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
    190             $p2checkin_timesofar = get_user_meta( $current_user->ID, 'p2checkin_totaltime', true ); 
    191             $p2checkin_sessiontime = ( $rwi_checkedouttime_realz - $rwi_checkedin ); 
    192             $p2checkin_timesofar += $p2checkin_sessiontime; 
    193  
    194             update_user_meta( $current_user->ID, 'p2checkin_totaltime', $p2checkin_timesofar ); 
     209            if ( isset( $_GET[p2checkinuser] )  && current_user_can( 'manage_options' ) ) { 
     210                 
     211                // Set the user variable for who's being forcibly checked out 
     212                $usercheckedoutbyforce = $_GET[p2checkinuser]; 
     213                 
     214                // To enable us to prevent cheatin' 
     215                $rwi_forced_checkedin = get_user_meta( $usercheckedoutbyforce, 'p2checkin_time_checked_in', true ); 
     216                $rwi_forced_checkedouttime = get_user_meta( $usercheckedoutbyforce, 'p2checkin_time_checked_out', true ); 
     217                 
     218                if ( $rwi_forced_checkedouttime < $rwi_forced_checkedin ) { 
     219                 
     220                    // So we know they're out 
     221                    update_user_meta( $usercheckedoutbyforce , 'p2checkin_currently_checked_in', false ); 
     222                 
     223                    // So we know what time they left 
     224                    update_user_meta( $usercheckedoutbyforce , 'p2checkin_time_checked_out', current_time( 'timestamp', 1 ) ); 
     225                 
     226                    // Keep a running total of checked in time. Why not? 
     227                    $rwi_forced_checkedouttime_realz = get_user_meta( $usercheckedoutbyforce, 'p2checkin_time_checked_out', true ); 
     228                    $p2checkin_forced_timesofar = get_user_meta( $usercheckedoutbyforce, 'p2checkin_totaltime', true ); 
     229                    $p2checkin_forced_sessiontime = ( $rwi_forced_checkedouttime_realz - $rwi_forced_checkedin ); 
     230                    $p2checkin_forced_timesofar += $p2checkin_forced_sessiontime; 
     231                 
     232                    update_user_meta( $usercheckedoutbyforce, 'p2checkin_totaltime', $p2checkin_forced_timesofar ); 
     233                 
     234                } 
     235                 
     236            } else { 
     237             
     238                // So we know they're out 
     239                update_user_meta( $current_user->ID , 'p2checkin_currently_checked_in', false ); 
     240 
     241                // So we know what time they left 
     242                update_user_meta( $current_user->ID , 'p2checkin_time_checked_out', current_time( 'timestamp', 1 ) ); 
     243 
     244                // Keep a running total of checked in time. Why not? 
     245                $rwi_checkedouttime_realz = get_user_meta( $current_user->ID, 'p2checkin_time_checked_out', true ); 
     246                $p2checkin_timesofar = get_user_meta( $current_user->ID, 'p2checkin_totaltime', true ); 
     247                $p2checkin_sessiontime = ( $rwi_checkedouttime_realz - $rwi_checkedin ); 
     248                $p2checkin_timesofar += $p2checkin_sessiontime; 
     249                 
     250                update_user_meta( $current_user->ID, 'p2checkin_totaltime', $p2checkin_timesofar ); 
     251             
     252            } 
    195253             
    196254        } 
  • p2-check-in/trunk/readme.txt

    r563796 r565673  
    44Requires at least: 3.0 
    55Tested up to: 3.4 
    6 Stable tag: 0.3 
     6Stable tag: 0.3.1 
    77License: GPLv2 or later 
    88 
     
    1717The language in this plugin is purposefully left a big vague so you can use it for your own purposes. Checking in could mean literally checking into a building to show you're there (the purpose I developed the plugin for) or it could mean that you are simply available, and actively watching the P2. 
    1818 
    19 In addition, the total amount of time someone has logged when "checked in" is displayed 
     19In addition, the total amount of time someone has logged when "checked in" is displayed underneath a user's name in the sidebar.  
     20 
     21If a user ever forgets to check out, admin users (or those that can manage_options) can click the x button next to their name and check them out for them. 
    2022 
    2123#### Kudos 
     
    3638 
    3739== Changelog == 
     40 
     41= 0.3.1 = 
     42* Feature: Logged in admins can now check out users. Ideally this should only be done when someone forgets to check out or something. Use with caution. 
     43* Fix: closed the cheating loophole on login. 
     44* Removed the cheating messages, since they're confusing and unneeded for folks on the front end. 
     45* Updated the stylesheet to support the new subtle x buttons for checking folks out. 
    3846 
    3947= 0.3 = 
Note: See TracChangeset for help on using the changeset viewer.