contributions/usermanagement/model/classes/permanentlogins.facade.php
Go to the documentation of this file.00001 <?php 00002 /** 00003 * Helper functions around permant logins 00004 * 00005 * @author Gerd Riesselmann 00006 * @ingroup Usermanagement 00007 */ 00008 class PermanentLogins { 00009 const COOKIE_NAME = 'C128'; 00010 00011 /** 00012 * Returns current, if any 00013 * 00014 * @return DAOPermanentlogins 00015 */ 00016 public static function get_current() { 00017 $ret = false; 00018 $code = Cookie::get_cookie_value(self::COOKIE_NAME); 00019 if ($code) { 00020 $tmp = DB::get_item('permanentlogins', 'code', $code); 00021 if ($tmp && $tmp->expirationdate > time()) { 00022 $ret = $tmp; 00023 } 00024 } 00025 return $ret; 00026 } 00027 00028 /** 00029 * Enable permanent login for given user 00030 */ 00031 public static function enable_permanent_login($user) { 00032 $cmd = CommandsFactory::create_command('permanentlogins', 'create', $user); 00033 $cmd->execute(); 00034 } 00035 00036 /** 00037 * Ends permanent login for current user 00038 */ 00039 public static function end_permanent_login() { 00040 $cmd = CommandsFactory::create_command('permanentlogins', 'end', false); 00041 $cmd->execute(); 00042 } 00043 }