Sets the Site SignIn Lock Delay attribute value.
@param int $signin_lock_delay New value for attribute
@return CNabuDataObject Returns self instance to grant chained setters call.
482509
public function setSignInLockDelay(int $signin_lock_delay = 0) : CNabuDataObject
    {
        if ($signin_lock_delay === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$signin_lock_delay")
            );
        }
        $this->setValue('nb_site_signin_lock_delay', $signin_lock_delay);
        
        return $this;
    }
779005
public function setServerHostId(int $nb_server_host_id) : CNabuDataObject
    {
        if ($nb_server_host_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_server_host_id")
            );
        }
        $this->setValue('nb_server_host_id', $nb_server_host_id);
        
        return $this;
    }
163787
public function setRequirePoliciesAfterLogin(string $require_policies_after_login = "F") : CNabuDataObject
    {
        if ($require_policies_after_login === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$require_policies_after_login")
            );
        }
        $this->setValue('nb_site_require_policies_after_login', $require_policies_after_login);
        
        return $this;
    }
1326341
public function setSiteAliasId(int $nb_site_alias_id) : CNabuDataObject
    {
        if ($nb_site_alias_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_alias_id")
            );
        }
        $this->setValue('nb_site_alias_id', $nb_site_alias_id);
        
        return $this;
    }
395788
public function setUseSSL(string $use_ssl = "F") : CNabuDataObject
    {
        if ($use_ssl === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$use_ssl")
            );
        }
        $this->setValue('nb_cluster_group_service_use_ssl', $use_ssl);
        
        return $this;
    }
701078
public function isSignInLocked()
    {
        $nb_session = $this->nb_application->getSession();
        if ($nb_session === null || !($nb_session instanceof CNabuHTTPSession)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SESSION_NOT_FOUND);
        }

        $nb_site = $this->nb_application->getHTTPServer()->getSite();
        if ($nb_site === null || !($nb_site instanceof CNabuSite)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SITE_NOT_FOUND);
        }

        $max_signin_retries = $nb_site->getMaxSignInRetries();
        $signin_locked_delay = $nb_site->getSignInLockDelay();
        $signin_retries = $nb_session->getVariable('signin_retries', 0);
        $signin_last_fail_timestamp = $nb_session->getVariable('signin_last_fail_timestamp', 0);
        $now = time() - $signin_last_fail_timestamp;

        if ($now > $signin_locked_delay) {
            $this->resetSignInLock();
            $retval = false;
        } else {
            $retval = $max_signin_retries > 0 && $signin_retries >= $max_signin_retries && $now < $signin_locked_delay;
        }

        return $retval;
    }
1081631
public function setLockMode($lockMode)
    {
        if (in_array($lockMode, array(LockMode::NONE, LockMode::PESSIMISTIC_READ, LockMode::PESSIMISTIC_WRITE), true)) {
            if ( ! $this->_em->getConnection()->isTransactionActive()) {
                throw TransactionRequiredException::transactionRequired();
            }
        }

        $this->setHint(self::HINT_LOCK_MODE, $lockMode);

        return $this;
    }
1343306
public function get_session_lock($rowid, $timeout) {
        parent::get_session_lock($rowid, $timeout);

        $fullname = $this->dbname.'-'.$this->prefix.'-session-'.$rowid;
        $sql = 'SELECT MOODLELIB.GET_LOCK(:lockname, :locktimeout) FROM DUAL';
        $params = array('lockname' => $fullname , 'locktimeout' => $timeout);
        $this->query_start($sql, $params, SQL_QUERY_AUX);
        $stmt = $this->parse_query($sql);
        $this->bind_params($stmt, $params);
        $result = oci_execute($stmt, $this->commit_status);
        if ($result === false) { // Any failure in get_lock() raises error, causing return of bool false
            throw new dml_sessionwait_exception();
        }
        $this->query_end($result, $stmt);
        oci_free_statement($stmt);
    }
656071
public function setUseCommerce(string $use_commerce = "F") : CNabuDataObject
    {
        if ($use_commerce === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$use_commerce")
            );
        }
        $this->setValue('nb_site_target_use_commerce', $use_commerce);
        
        return $this;
    }
177295
public function setSiteId(int $nb_site_id) : CNabuDataObject
    {
        if ($nb_site_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_id")
            );
        }
        $this->setValue('nb_site_id', $nb_site_id);
        
        return $this;
    }
55788
public function lockSignIn()
    {
        $retval = false;

        $nb_session = $this->nb_application->getSession();
        if ($nb_session === null || !($nb_session instanceof CNabuHTTPSession)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SESSION_NOT_FOUND);
        }

        $nb_response = $this->nb_application->getResponse();
        if ($nb_response === null || !($nb_response instanceof CNabuHTTPResponse)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_RESPONSE_NOT_FOUND);
        }

        $nb_site = $this->nb_application->getHTTPServer()->getSite();
        if ($nb_site === null || !($nb_site instanceof CNabuSite)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_SITE_NOT_FOUND);
        }

        try {
            $lang = $this->nb_application->getRequest()->getLanguage()->getId();
        } catch (Exception $e) {
            $lang = null;
        }
        if ($lang === null) {
            $lang = $nb_site->getDefaultLanguageId();
        }

        $max_signin_retries = $nb_site->getMaxSignInRetries();
        $signin_locked_delay = $nb_site->getSignInLockDelay();
        $signin_retries = $nb_session->getVariable('signin_retries', 0);
        $signin_last_fail_timestamp = $nb_session->getVariable('signin_last_fail_timestamp', 0);
        $now = time() - $signin_last_fail_timestamp;

        if ($max_signin_retries > 0) {
            if ($this->isSignInLocked()) {
            } else {
                $nb_session->setVariable('signin_retries', $signin_retries < $max_signin_retries ? ++$signin_retries : $max_signin_retries);
                $nb_session->setVariable('signin_last_fail_timestamp', time());
            }
            if ($this->isSignInLocked()) {
                if (is_string($link = $nb_site->getLoginMaxFailsTargetLink()->getBestQualifiedURL(array($lang => $lang)))) {
                    $nb_response->redirect($nb_site->getLoginMaxFailsErrorCode(), $link);
                } else {
                    $retval = true;
                }
            }
        }

        return $retval;
    }
1274582
private function acquire_lock($acquire_timeout = 10) {
		$identifier = (string)Uuid::uuid4();

		$end = time() + $acquire_timeout;
		while (time() < $end) {
			$res = $this->client->setnx('lock:' . $this->name, $identifier);
			if ($res) {
				return $identifier;
			}
			sleep(0.001);
		}
		return false;
	}
994051
public function setConnectionTimeout($connectionTimeout) {
		if (!is_numeric($connectionTimeout) || $connectionTimeout < 0) {
			throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
		}

		$this->connectionTimeout = $connectionTimeout;
		return $this;
	}
98044
public function get_session_lock($rowid, $timeout) {
        // NOTE: there is a potential locking problem for database running
        //       multiple instances of moodle, we could try to use pg_advisory_lock(int, int),
        //       luckily there is not a big chance that they would collide
        if (!$this->session_lock_supported()) {
            return;
        }

        parent::get_session_lock($rowid, $timeout);

        $timeoutmilli = $timeout * 1000;

        $sql = "SET statement_timeout TO $timeoutmilli";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = pg_query($this->pgsql, $sql);
        $this->query_end($result);

        if ($result) {
            pg_free_result($result);
        }

        $sql = "SELECT pg_advisory_lock($rowid)";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $start = time();
        $result = pg_query($this->pgsql, $sql);
        $end = time();
        try {
            $this->query_end($result);
        } catch (dml_exception $ex) {
            if ($end - $start >= $timeout) {
                throw new dml_sessionwait_exception();
            } else {
                throw $ex;
            }
        }

        if ($result) {
            pg_free_result($result);
        }

        $sql = "SET statement_timeout TO DEFAULT";
        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = pg_query($this->pgsql, $sql);
        $this->query_end($result);

        if ($result) {
            pg_free_result($result);
        }
    }
1063833
public function setCommerceId(int $nb_commerce_id) : CNabuDataObject
    {
        if ($nb_commerce_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_commerce_id")
            );
        }
        $this->setValue('nb_commerce_id', $nb_commerce_id);
        
        return $this;
    }
663102
public function setDynamicCacheControl(string $dynamic_cache_control = "S") : CNabuDataObject
    {
        if ($dynamic_cache_control === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$dynamic_cache_control")
            );
        }
        $this->setValue('nb_site_target_dynamic_cache_control', $dynamic_cache_control);
        
        return $this;
    }
602200
public function setOpenPopup(string $open_popup = "F") : CNabuDataObject
    {
        if ($open_popup === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$open_popup")
            );
        }
        $this->setValue('nb_site_map_open_popup', $open_popup);
        
        return $this;
    }