00001 <?php
00002
00003
00004
00005
00006
00007
00008 class CreatePermanentloginsCommand extends CommandComposite {
00009
00010
00011
00012 protected function do_execute() {
00013 $ret = new Status();
00014
00015 Load::commands('generics/massdelete', 'generics/create', 'generics/cookie.set');
00016 $this->append(new MassDeleteCommand('permanentlogins', new DBCondition('expirationdate', '<', time())));
00017
00018
00019 $user = $this->get_params();
00020 $salt = $user->creationdate . $user->password . $user->modificationdate;
00021 $code = Common::create_token($salt);
00022 $validtime = Cast::int(Config::get_value(ConfigUsermanagement::PERMANENT_LOGIN_DURATION)) * GyroDate::ONE_DAY;
00023 $params = array(
00024 'code' => $code,
00025 'expirationdate' => time() + $validtime,
00026 'id_user' => $user->id
00027 );
00028 $this->append(new CreateCommand('permanentlogins', $params));
00029
00030
00031 $this->append(new CookieSetCommand(PermanentLogins::COOKIE_NAME, $code, $validtime));
00032
00033 return $ret;
00034 }
00035 }