00001 <?php
00002
00003
00004
00005 class Tokens {
00006
00007
00008
00009
00010
00011
00012 public static function create_token($seed = false) {
00013 self::clear();
00014
00015 $dao = new DAOTokens();
00016 $token = '';
00017 do {
00018 $token = Common::create_token($seed);
00019 $dao->token = $token;
00020 } while ($dao->count() > 0);
00021
00022 $cmd = CommandsFactory::create_command('tokens', 'create', array('token' => $token));
00023 $cmd->execute();
00024
00025 return $token;
00026 }
00027
00028 private static function clear() {
00029 $dao = new DAOTokens();
00030 $dao->add_where('creationdate', '<', time() - 10 * GyroDate::ONE_DAY);
00031 $dao->delete(DataObjectBase::WHERE_ONLY);
00032 }
00033 }