public function getPasswordResetKey(\Gems_User_User $user)
    {
        $model = new \MUtil_Model_TableModel('gems__user_passwords');
        \Gems_Model::setChangeFieldsByPrefix($model, 'gup', $user->getUserId());

        $data['gup_id_user'] = $user->getUserLoginId();
        $filter = $data;

        if ((0 == ($this->hoursResetKeyIsValid % 24)) || \Zend_Session::$_unitTestEnabled) {
            $filter[] = 'ADDDATE(gup_reset_requested, ' . intval($this->hoursResetKeyIsValid / 24) . ') >= CURRENT_TIMESTAMP';
        } else {
            $filter[] = 'DATE_ADD(gup_reset_requested, INTERVAL ' . $this->hoursResetKeyIsValid . ' HOUR) >= CURRENT_TIMESTAMP';
        }
        $row = $model->loadFirst($filter);
        if ($row && $row['gup_reset_key']) {
            // Keep using the key.
            $data['gup_reset_key'] = $row['gup_reset_key'];
        } else {
            $data['gup_reset_key'] = hash('sha256', time() . $user->getEmailAddress());
        }
        $data['gup_reset_requested'] = new \MUtil_Db_Expr_CurrentTimestamp();

        // Loop for case when hash is not unique
        while (true) {
            try {
                $model->save($data);

                return $data['gup_reset_key'];

            } catch (\Zend_Db_Exception $zde) {
                $data['gup_reset_key'] = hash('sha256', time() . $user->getEmailAddress());
            }
        }
    }