public static function findByTemporalEncodedId($nb_customer, string $key, int $expires = NABU_TEMP_ENC_ID_EXPIRATION_TIME)
    {
        $retval = null;

        if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID)) &&
            strlen($key) > 0
        ) {
            $hash_left = $hash_time = null;
            sscanf($key, "%32s%x", $hash_left, $hash_time);
            if ($hash_time >= time()) {
                $retval = CNabuUser::buildObjectFromSQL(
                    'select * '
                    . 'from nb_user u, nb_customer c '
                   . 'where u.nb_customer_id=c.nb_customer_id '
                     . 'and c.nb_customer_id=%cust_id$d '
                     . "and md5(concat('%pref\$s', u.nb_user_id, '%suff\$s'))='%key\$s'",
                     array(
                         'pref' => NABU_ENC_ID_PREF,
                         'suff' => NABU_ENC_ID_SUFF,
                         'cust_id' => $nb_customer_id,
                         'key' => $hash_left
                     )
                );
                if ($nb_customer instanceof CNabuCustomer && $retval !== null) {
                    $retval->setCustomer($nb_customer);
                }
            }
        }

        return $retval;
    }
public static function findByTemporalEncodedId($nb_customer, string $key, int $expires = NABU_TEMP_ENC_ID_EXPIRATION_TIME)
    {
        $retval = null;

        if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID)) &&
            strlen($key) > 0
        ) {
            $hash_left = $hash_time = null;
            sscanf($key, "%32s%x", $hash_left, $hash_time);
            if ($hash_time >= time()) {
                $retval = CNabuUser::buildObjectFromSQL(
                    'select * '
                    . 'from nb_user u, nb_customer c '
                   . 'where u.nb_customer_id=c.nb_customer_id '
                     . 'and c.nb_customer_id=%cust_id$d '
                     . "and md5(concat('%pref\$s', u.nb_user_id, '%suff\$s'))='%key\$s'",
                     array(
                         'pref' => NABU_ENC_ID_PREF,
                         'suff' => NABU_ENC_ID_SUFF,
                         'cust_id' => $nb_customer_id,
                         'key' => $hash_left
                     )
                );
                if ($nb_customer instanceof CNabuCustomer && $retval !== null) {
                    $retval->setCustomer($nb_customer);
                }
            }
        }

        return $retval;
    }
public static function findByTemporalEncodedId ( $ nb_customer , string $ key , int $ expires = NABU_TEMP_ENC_ID_EXPIRATION_TIME ) { $ retval = null ; if ( is_numeric ( $ nb_customer_id = nb_getMixedValue ( $ nb_customer , NABU_CUSTOMER_FIELD_ID ) ) && strlen ( $ key ) > 0 ) { $ hash_left = $ hash_time = null ; sscanf ( $ key , "%32s%x" , $ hash_left , $ hash_time ) ; if ( $ hash_time >= time ( ) ) { $ retval = CNabuUser :: buildObjectFromSQL ( 'select * ' . 'from nb_user u, nb_customer c ' . 'where u.nb_customer_id=c.nb_customer_id ' . 'and c.nb_customer_id=%cust_id$d ' . "and md5(concat('%pref\$s', u.nb_user_id, '%suff\$s'))='%key\$s'" , array ( 'pref' => NABU_ENC_ID_PREF , 'suff' => NABU_ENC_ID_SUFF , 'cust_id' => $ nb_customer_id , 'key' => $ hash_left ) ) ; if ( $ nb_customer instanceof CNabuCustomer && $ retval !== null ) { $ retval -> setCustomer ( $ nb_customer ) ; } } } return $ retval ; }
Find a User by a temporal encoded key.
@param mixed $nb_customer A Customer ID, a Data Object containing a field nb_customer_id or a Customer instance.
@param string $key Key encoded string value to find the User.
@param int $expires Time in seconds of the validity interval of encoded ID.
@return mixed Returns a User instance if $key matches and is in time, or null if not.
Find a User by a temporal encoded key .