protected function checkNotConfirmedUserAccounts() { global $ilDB; $this->log->write('Cron: Start ' . __METHOD__); require_once 'Services/Registration/classes/class.ilRegistrationSettings.php'; $oRegSettigs = new ilRegistrationSettings(); $query = 'SELECT usr_id FROM usr_data ' . 'WHERE reg_hash IS NOT NULL ' . 'AND active = %s ' . 'AND create_date < %s'; $res = $ilDB->queryF($query, array('integer', 'timestamp'), array(0, date('Y-m-d H:i:s', time() - (int) $oRegSettigs->getRegistrationHashLifetime()))); while ($row = $ilDB->fetchAssoc($res)) { $oUser = ilObjectFactory::getInstanceByObjId((int) $row['usr_id']); $oUser->delete(); $this->log->write('Cron: Deleted ' . $oUser->getLogin() . ' [' . $oUser->getId() . '] ' . __METHOD__); } $this->log->write('Cron: End ' . __METHOD__); }
/** * Verifies a registration hash * * @throws ilRegistrationHashExpiredException * @throws ilRegistrationHashNotFoundException * @param string $a_hash hashcode * @return integer user id of the user */ public static function _verifyRegistrationHash($a_hash) { global $ilDB; $res = $ilDB->queryf(' SELECT usr_id, create_date FROM usr_data WHERE reg_hash = %s', array('text'), array($a_hash)); while ($row = $ilDB->fetchAssoc($res)) { require_once 'Services/Registration/classes/class.ilRegistrationSettings.php'; $oRegSettigs = new ilRegistrationSettings(); if ((int) $oRegSettigs->getRegistrationHashLifetime() != 0 && time() - (int) $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) { require_once 'Services/Registration/exceptions/class.ilRegConfirmationLinkExpiredException.php'; throw new ilRegConfirmationLinkExpiredException('reg_confirmation_hash_life_time_expired', $row['usr_id']); } $ilDB->manipulateF(' UPDATE usr_data SET reg_hash = %s WHERE usr_id = %s', array('text', 'integer'), array('', (int) $row['usr_id'])); return (int) $row['usr_id']; } require_once 'Services/Registration/exceptions/class.ilRegistrationHashNotFoundException.php'; throw new ilRegistrationHashNotFoundException('reg_confirmation_hash_not_found'); }
/** * * Method for soap webservice: deleteExpiredDualOptInUserObjects * * This service will run in background. The client has not to wait for response. * * @param string $sid Session id + client id, separated by :: * @param integer $usr_id User id of the actuator * @return boolean true or false * @access public * */ public function deleteExpiredDualOptInUserObjects($sid, $usr_id) { $this->initAuth($sid); $this->initIlias(); // Session check not possible -> anonymous user is the trigger global $ilDB, $ilLog; $ilLog->write(__METHOD__ . ': Started deletion of inactive user objects with expired confirmation hash values (dual opt in) ...'); require_once 'Services/Registration/classes/class.ilRegistrationSettings.php'; $oRegSettigs = new ilRegistrationSettings(); $query = ''; /* * Fetch the current actuator user object first, because this user will try to perform very probably * a new registration with the same login name in a few seconds ;-) * */ if ((int) $usr_id > 0) { $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data ' . 'WHERE active = 0 ' . 'AND reg_hash IS NOT NULL ' . 'AND usr_id = ' . $ilDB->quote($usr_id, 'integer') . ' '; $query .= 'UNION '; } $query .= 'SELECT usr_id, create_date, reg_hash FROM usr_data ' . 'WHERE active = 0 ' . 'AND reg_hash IS NOT NULL ' . 'AND usr_id != ' . $ilDB->quote($usr_id, 'integer') . ' '; $res = $ilDB->query($query); $ilLog->write(__METHOD__ . ': ' . $ilDB->numRows($res) . ' inactive user objects with confirmation hash values (dual opt in) found ...'); /* * mjansen: 15.12.2010: * I perform the expiration check in php because of multi database support (mysql, postgresql). * I did not find an oracle equivalent for mysql: UNIX_TIMESTAMP() */ $num_deleted_users = 0; while ($row = $ilDB->fetchAssoc($res)) { if ($row['usr_id'] == ANONYMOUS_USER_ID || $row['usr_id'] == SYSTEM_USER_ID) { continue; } if (!strlen($row['reg_hash'])) { continue; } if ((int) $oRegSettigs->getRegistrationHashLifetime() > 0 && $row['create_date'] != '' && time() - $oRegSettigs->getRegistrationHashLifetime() > strtotime($row['create_date'])) { $user = ilObjectFactory::getInstanceByObjId($row['usr_id'], false); if ($user instanceof ilObjUser) { $ilLog->write(__METHOD__ . ': User ' . $user->getLogin() . ' (obj_id: ' . $user->getId() . ') will be deleted due to an expired registration hash ...'); $user->delete(); ++$num_deleted_users; } } } $ilLog->write(__METHOD__ . ': ' . $num_deleted_users . ' inactive user objects with expired confirmation hash values (dual opt in) deleted ...'); $ilLog->write(__METHOD__ . ': Finished deletion of inactive user objects with expired confirmation hash values (dual opt in) ...'); return true; }