[ Index ]

MailPress 7.2

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/ -> MP_Mail_lock.class.php (source)

   1  <?php
   2  class MP_Mail_lock
   3  {
   4  	public static function set( $id ) 
   5      {
   6          global $current_user;
   7          if ( !$mail = MP_Mail::get( $id ) )        return false;
   8          if ( !$current_user || !$current_user->ID )    return false;
   9  
  10          $now = time();
  11  
  12          if ( !MP_Mail_meta::add(     $mail->id, '_edit_lock', $now, true ) )
  13              MP_Mail_meta::update( $mail->id, '_edit_lock', $now );
  14          if ( !MP_Mail_meta::add(     $mail->id, '_edit_last', $current_user->ID, true ) )
  15              MP_Mail_meta::update( $mail->id, '_edit_last', $current_user->ID );
  16      }
  17  
  18  	public static function check( $id ) 
  19      {
  20          global $current_user;
  21  
  22          if ( !$mail = MP_Mail::get( $id ) ) return false;
  23  
  24          $lock = MP_Mail_meta::get( $id, '_edit_lock' );
  25          $last = MP_Mail_meta::get( $id, '_edit_last' );
  26          $time_window = AUTOSAVE_INTERVAL * 2 ;
  27  
  28          if ( $lock && $lock > time() - $time_window && $last != $current_user->ID )    return $last;
  29          return false;
  30      }
  31  }


Generated: Tue May 19 15:55:14 2020 Cross-referenced by PHPXref 0.7.1