예제 #1
0
 /**
  * construct the HTML for the existing user portion of the admin page
  *
  * @param  string  $role      which subset of users to get based on user role (current or expired)
  *
  * @return html               the HTML of the new user form portion
  */
 public static function existing_user_list($role = 'administrator')
 {
     // get my users
     $users = TempAdminUser_Utilities::get_temp_users($role, 'all');
     // we have users. start building a table
     $table = '';
     // start the table wrapper markup
     $table .= '<table class="wp-list-table widefat fixed users">';
     // set my table header
     $table .= '<thead>';
     $table .= self::user_head_foot_row();
     $table .= '</thead>';
     // set my table footer
     $table .= '<tfoot>';
     $table .= self::user_head_foot_row();
     $table .= '</tfoot>';
     // set the table body
     $table .= '<tbody>';
     // if no users, just show an empty row
     if (empty($users)) {
         $table .= self::empty_user_row();
     } else {
         // set a counter
         $i = 1;
         // loop the users
         foreach ($users as $user) {
             // get my alternating class
             $class = $i & 1 ? 'alternate' : 'standard';
             // pull the row markup
             $table .= self::single_user_row($user, $class);
             // and increment our counter
             $i++;
         }
     }
     $table .= '</tbody>';
     // close the table wrapper
     $table .= '</table>';
     // return the table
     return $table;
 }
예제 #2
0
 /**
  * loop through all the temporary users and check
  * the expiration time against the current server time
  * and update user status if need be
  *
  * @return null
  */
 public function check_user_statuses()
 {
     // check for transient, run every hour (for now)
     if (false === get_transient('tempadmin_status_check')) {
         // get my users
         $users = TempAdminUser_Utilities::get_temp_users();
         // if none exist, set the transient and bail
         if (empty($users)) {
             // write the transient
             set_transient('tempadmin_status_check', 1, HOUR_IN_SECONDS);
             // and bail
             return;
         }
         // we have users. loop and send them over to be updated
         foreach ($users as $user_id) {
             // get their expiration time
             $expire = get_user_meta($user_id, '_tempadmin_expire', true);
             // if that time has passed, reset their status
             if (empty($expire) || time() > $expire) {
                 self::reset_user_status($user_id);
             }
         }
         set_transient('tempadmin_status_check', 1, HOUR_IN_SECONDS);
     }
 }