Setup solr stuff required by moodle.

@param  bool $checkexisting Whether to check if the fields already exist or not
@return bool
979635
public function setup($checkexisting = true) {
        $fields = \search_solr\document::get_default_fields_definition();

        // Field id is already there.
        unset($fields['id']);

        $this->check_index();

        $return = $this->add_fields($fields, $checkexisting);

        // Tell the engine we are now using the latest schema version.
        $this->engine->record_applied_schema_version(document::SCHEMA_VERSION);

        return $return;
    }
157329
public function is_valid($password, $check_rehash=true) {
	if (password_verify($password, $this->data['hash']) == false) {
		return false;
	}
	
	if ($check_rehash && password_needs_rehash($this->data['hash'], PASSWORD_DEFAULT)) {
		$new_hash = self::hash_password($password);
		$this->set_new_hash($this->data['user_id'], $this->data['email_address'], $new_hash);
	}
	
	return true;
}
573335
public function checkIntegrity($check=true,$schema='')
	{
		$enable=$check ? 'CHECK' : 'NOCHECK';
		if(!isset($this->_normalTables[$schema]))
			$this->_normalTables[$schema]=$this->findTableNames($schema,false);
		$db=$this->getDbConnection();
		foreach($this->_normalTables[$schema] as $tableName)
		{
			$tableName=$this->quoteTableName($tableName);
			$db->createCommand("ALTER TABLE $tableName $enable CONSTRAINT ALL")->execute();
		}
	}
1265945
public function exists($sOXID = null)
    {
        if (!$sOXID) {
            $sOXID = $this->getId();
        }
        //#5901 if physical record exists return true unconditionally
        if (parent::exists($sOXID)) {
            $this->setId($sOXID);
            return true;
        }

        //additional username check
        //This part is used by not yet saved user object, to detect the case when such username exists in db.
        //Basically it is called when anonymous visitor enters existing username for newsletter subscription
        //see Newsletter::send()
        //TODO: transfer this validation to newsletter part
        $sShopSelect = '';
        if (!$this->_blMallUsers && $this->oxuser__oxrights->value != 'malladmin') {
            $sShopSelect = ' AND oxshopid = "' . \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId() . '" ';
        }

        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        $sSelect = 'SELECT oxid FROM ' . $this->getViewName() . '
                    WHERE ( oxusername = ' . $masterDb->quote($this->oxuser__oxusername->value) . ' ) ';
        $sSelect .= $sShopSelect;

        if (($sOxid = $masterDb->getOne($sSelect))) {
            // update - set oxid
            $this->setId($sOxid);

            return true;
        }

        return false;
    }
1139939
public function setRequired(bool $flag = null): QuestionPrompt
    {
        $this->required = $flag ?? true;

        return $this;
    }
1114543
public function findById($id, $existCheck = false)
    {
        $record = $this->prepareQuery($this->model)->find($id);

        if ($existCheck) {
            return ! empty($record);
        }

        return $record;
    }
324036
public function delete($condition, $check = true)
    {
        $result = null;
        $this->hook->attach('file.delete.before', $condition, $check, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        if (!is_array($condition)) {
            $condition = array('file_id' => $condition);
        }

        if ($check && isset($condition['file_id']) && !$this->canDelete($condition['file_id'])) {
            return false;
        }

        $result = (bool) $this->db->delete('file', $condition);

        if ($result && isset($condition['file_id'])) {
            $this->deleteLinked($condition['file_id']);
        }

        $this->hook->attach('file.delete.after', $condition, $check, $result, $this);
        return (bool) $result;
    }
422876
public function setRequired(bool $required = true)
    {
        if ($required) {
            $this->field->addProp('required');
        } else {
            $this->field->removeProp('required');
        }

        return $this;
    }
1198326
public function _has($el, $eq = false)
    {
        if (is_int($el)) {
            $e = end($this->ids);
            if ($el >= $e) {
                return self::$_fl_;
            }

            foreach ($this->ids as $b => $e) {
                if ($el < $b) {
                    return self::$_fl_;
                }

                if ($el == $b) {
                    return $eq;
                }

                if ($el < $e) {
                    return self::$_tr_;
                }

            }
            return self::$_fl_;
        }
        if ($el instanceof self) {
            if ($el === $this) {
                return self::$_fl_;
            }

            $el = $el->ids;} else {
            $el = $this->_ctx_ids($this->_doc_ids($el, true));
        }

        foreach ($el as $b => $e) {
            if (!$this->_has($b)) {
                return self::$_fl_;
            }
        }

        return self::$_tr_;
    }
541026
public function exists($password = null, $since = null)
	{
		$db = \App::get('db');

		if (empty($db))
		{
			return false;
		}

		$query = "SELECT `passhash` FROM `#__users_password_history` WHERE user_id = " . $db->quote($this->user_id);

		if (!empty($since))
		{
			$query .= " AND invalidated >= " . $db->quote($since);
		}

		$db->setQuery($query);

		$results = $db->loadObjectList();

		if ($results && count($results) > 0)
		{
			foreach ($results as $result)
			{
				$compare = \Hubzero\User\Password::comparePasswords($result->passhash, $password);
				if ($compare)
				{
					return true;
				}
			}
		}

		return false;
	}
368937
public function isListed($isListed = true)
    {
        //====================================================================//
        // Safety Checks ==> Verify a new Field Exists
        if (empty($this->new)) {
            Splash::log()->err("ErrFieldsNoNew");
        } else {
            //====================================================================//
            // Update New Field structure
            $this->new->inlist = (bool) $isListed;
        }

        return $this;
    }
661759
public static function extensionExists($ext)
    {
        if (!isset(self::$_cache[$ext])) {
            self::$_cache[$ext] = extension_loaded($ext);
        }

        return self::$_cache[$ext];
    }
943172
public function can_setup_server() {

        $status = $this->engine->is_server_configured();
        if ($status !== true) {
            return $status;
        }

        // At this stage we know that the server is properly configured with a valid host:port and indexname.
        // We're not too concerned about repeating the SolrClient::system() call (already called in
        // is_server_configured) because this is just a setup script.
        if ($this->engine->get_solr_major_version() < 5) {
            // Schema setup script only available for 5.0 onwards.
            return get_string('schemasetupfromsolr5', 'search_solr');
        }

        return true;
    }
332707
public function validate_setup() {
        $fields = \search_solr\document::get_default_fields_definition();

        // Field id is already there.
        unset($fields['id']);

        $this->check_index();
        $this->validate_fields($fields, true);
    }
1259102
protected function getData($check = false)
    {
        $data = parent::getData($check);
        $data['login'] = UserHelper::getUserLogin(\common_session_SessionManager::getSession()->getUser());

        if ($this->hasRequestParameter('workstation')) {
            $data[PaginatedSqlStorage::DIAGNOSTIC_WORKSTATION] = \tao_helpers_Display::sanitizeXssHtml(trim($this->getRequestParameter('workstation')));
        }

        return $data;
    }
695612
protected function _createdb($check = false) {
		$this->out(__d('cake_installer', 'Creating database and initializing data'));
		$this->hr();

		$resultCheck = $this->InstallerCheck->checkDbTableExists();
		if ($resultCheck) {
			if ($check) {
				$this->out('<success>' . __d('cake_installer', 'This action has already been successfully completed. Skipped.') . '</success>');

				return true;
			} elseif ($this->useActionNotify) {
				if (!$this->_checkSure(__d('cake_installer', 'All schemas exists. Re-create?'))) {
					return true;
				}
			}
		}

		$this->out(__d('cake_installer', 'Create schema of application'));
		$this->hr();
		$yesArg = '';
		if (!empty($this->param('yes'))) {
			$yesArg = ' --yes';
		}
		$defaultSchemaArgs = 'schema create --quiet' . $yesArg;
		$this->dispatchShell($defaultSchemaArgs);
		$this->hr();
		$this->nl(1);
		$schemaList = $this->ConfigInstaller->getListSchemaCreation();
		if (empty($schemaList)) {
			return true;
		}

		$this->out(__d('cake_installer', 'Create additional schemes'));
		foreach ($schemaList as $schemaName) {
			if (empty($schemaName)) {
				continue;
			}

			$this->hr();
			$this->out(__d('cake_installer', 'Create additional scheme: \'%s\'', $schemaName));
			$this->hr();
			$this->nl(1);
			$additionalSchemaArgs = 'schema create ' . $schemaName . ' --quiet' . $yesArg;
			$this->dispatchShell($additionalSchemaArgs);
		}
		$this->hr();
		$this->out('<info>' . __d('cake_installer', 'Creating additional schemes completed.') . '</info>');

		return true;
	}
1191321
public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = true)
    {
        if (is_array($name)) {
            $name = $name[1];
        }

        if (strpos($name, '://') === false) {
            return false;
        }

        list($manager, $service) = explode('://', $name, 2);
        if (!$manager || !$service) {
            return false;
        }

        $parent = $this->getParentLocator();
        $services = ($parent->has($manager, false, false))? $parent->get($manager) : false;
        return (($services instanceof ServiceLocatorInterface)
            && $services->has($service));
    }