Returns a prediction

@param int $predictionid
@param bool $requirelogin
@return array array($model, $prediction, $context)
4743
public static function get_prediction($predictionid, $requirelogin = false) {
        global $DB;

        if (!$predictionobj = $DB->get_record('analytics_predictions', array('id' => $predictionid))) {
            throw new \moodle_exception('errorpredictionnotfound', 'analytics');
        }

        $context = \context::instance_by_id($predictionobj->contextid, IGNORE_MISSING);
        if (!$context) {
            throw new \moodle_exception('errorpredictioncontextnotavailable', 'analytics');
        }

        if ($requirelogin) {
            list($context, $course, $cm) = get_context_info_array($predictionobj->contextid);
            require_login($course, false, $cm);
        }

        self::check_can_list_insights($context);

        $model = new \core_analytics\model($predictionobj->modelid);
        $sampledata = $model->prediction_sample_data($predictionobj);
        $prediction = new \core_analytics\prediction($predictionobj, $sampledata);

        return array($model, $prediction, $context);
    }
267984
public static function loginUser( $login, $password, $authenticationMatch = false )
    {
        $user = self::_loginUser( $login, $password, $authenticationMatch );

        if ( is_object( $user ) )
        {
            self::loginSucceeded( $user );
            return $user;
        }
        else
        {
            self::loginFailed( $user, $login );
            return false;
        }
    }
1346681
public function login($login, $password)
    {
        $this->_db->query(
            'SELECT * FROM '.$this->_dbConfig['table']
            .' WHERE '.$this->_dbConfig['login'].' = :lg 
               AND '.$this->_dbConfig['password'].' = :pw',
            [':lg'=>$login, ':pw'=>$password]
        );

        $row = $this->_db->result();
        if (isset($row[0])) {
            $row = $row[0]->getAll();

            foreach ($this->_data as $i => $d) {
                if (isset($row[$this->_dbConfig[$i]])) {
                    $this->_data[$i] = $row[$this->_dbConfig[$i]];
                }
            }
            $this->_login = true;
            return true;
        }
        $this->_login = false;
        return false;
    }
290635
public function login(array $data, $check_password = true)
    {
        $result = array();
        $this->hook->attach('user.login.before', $data, $check_password, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (empty($data['email'])) {
            return $this->getResultErrorLogin();
        }

        $user = $this->user->getByEmail($data['email']);

        if (empty($user['status'])) {
            return $this->getResultErrorLogin();
        }

        if ($check_password && (!isset($data['password']) || !$this->user->passwordMatches($data['password'], $user))) {
            return $this->getResultErrorLogin();
        }

        $this->session->regenerate(true);
        $this->session->set('user', $user);

        $result = $this->getResultLogin($user);
        $this->hook->attach('user.login.after', $data, $check_password, $result, $this);

        return (array) $result;
    }
490710
public function doTwoFactorAuthLogin($userId) {

        // Get the 2FA code
        $codeToInput = $this->getCodeToInput();

        // Update the user's database record wtih the 2FA code & timestamp
        $this->updateUserRecordWithTwoFactorAuthCode($codeToInput, $userId);

        // Put together the SMS message
        $message  = config('lasallecmsfrontend.site_name');
        $message .= ". Your two factor authorization login code is ";
        $message .= $codeToInput;

        $this->shortMessageService->sendSMS($this->getUserPhoneCountryCode($userId), $this->getUserPhoneNumber($userId), $message);
    }
836032
public function loginUsingId($id, $remember = false)
    {
        if (! is_null($user = $this->provider->retrieveById($id))) {
            $this->login($user, $remember);

            return $user;
        }

        return false;
    }
747945
public static function read_user_evidence($id) {
        static::require_enabled();
        $userevidence = new user_evidence($id);

        if (!$userevidence->can_read()) {
            $context = $userevidence->get_context();
            throw new required_capability_exception($context, 'moodle/competency:userevidenceview', 'nopermissions', '');
        }

        return $userevidence;
    }
377261
private function validateUser($user, $requireValue = false)
    {
        // If we're passed something falsy, just return null
        if (!$user && !$requireValue) {
            return null;
        }

        // If we have a known supported type, resolve the id and return it
        if ($user instanceof User || $user instanceof UserInfo) {
            return (int) $user->getUserID();
        }

        // If what we're left with is numeric, return it as an int
        if (is_numeric($user)) {
            return (int) $user;
        }

        throw new \InvalidArgumentException('Invalid user value passed, must be User instance or int');
    }
996157
public double[] getPrediction(Instance instance) {
        int predictionMode = this.getLearnerToUse(instance, this.predictionFunction);
        return getPrediction(instance, predictionMode);
    }
558999
public function prediction_actions(\core_analytics\prediction $prediction, $includedetailsaction = false,
            $isinsightuser = false) {
        global $USER;

        $actions = array();

        $sampledata = $prediction->get_sample_data();
        $studentid = $sampledata['user']->id;

        $attrs = array('target' => '_blank');

        // Send a message.
        $url = new \moodle_url('/message/index.php', array('user' => $USER->id, 'id' => $studentid));
        $pix = new \pix_icon('t/message', get_string('sendmessage', 'message'));
        $actions[] = new \core_analytics\prediction_action('studentmessage', $prediction, $url, $pix,
                get_string('sendmessage', 'message'), false, $attrs);

        // View outline report.
        $url = new \moodle_url('/report/outline/user.php', array('id' => $studentid, 'course' => $sampledata['course']->id,
                'mode' => 'outline'));
        $pix = new \pix_icon('i/report', get_string('outlinereport'));
        $actions[] = new \core_analytics\prediction_action('viewoutlinereport', $prediction, $url, $pix,
                get_string('outlinereport'), false, $attrs);

        return array_merge($actions, parent::prediction_actions($prediction, $includedetailsaction));
    }
750984
final protected function mandatoryUserOrInlineMessageId(array &$return): array
    {
        if (empty($this->chat_id) && empty($this->message_id)) {
            $return[] = 'inline_message_id';
        }

        // On the other hand, chat_id and message_id are mandatory if inline_message_id is not filled in
        if (empty($this->inline_message_id)) {
            $return[] = 'chat_id';
            $return[] = 'message_id';
        }

        return $return;
    }
1342293
static function failedLoginAttemptsByUserID( $userID )
    {
        $db = eZDB::instance();
        $contentObjectID = (int) $userID;

        $userVisitArray = $db->arrayQuery( "SELECT failed_login_attempts FROM ezuservisit WHERE user_id=$contentObjectID" );

        $failedLoginAttempts = isset( $userVisitArray[0] ) ? $userVisitArray[0]['failed_login_attempts'] : 0;
        return $failedLoginAttempts;
    }
1295376
public function getCommentsRequireLogin()
    {
        if ($this->owner->getCommentsOption('require_login_cms')) {
            return (bool) $this->owner->getField('CommentsRequireLogin');
        }
        return (bool) $this->owner->getCommentsOption('require_login');
    }
663206
public function loadUserByLogin( $login )
    {
        /** @var \eZ\Publish\API\Repository\Repository $repository */
        $repository = $this->getRepository();
        $userService = $repository->getUserService();

        $user = $repository->sudo(
            function() use( $login, $userService )
            {
                return $userService->loadUserByLogin( $login );
            }
        );

        return $user;
    }
26890
public function getUsersLogin()
    {
        $db = $this->getDb();
        $users = $db->fetchAll("SELECT login FROM " . $this->table . " ORDER BY login ASC");

        $return = array();
        foreach ($users as $login) {
            $return[] = $login['login'];
        }

        return $return;
    }
203902
public function makeLogin( $vData, $bKeepAlive = false, & $sCkString = '' )
        {
		if ( UCProLib::isValidXTArray( $vData ) )
		{
			return $this->m_cUCProMain->makeLoginByXTArray( $vData, $bKeepAlive, $sCkString );
		}
		else if ( CLib::IsExistingString( $vData ) )
		{
			return $this->m_cUCProMain->makeLoginByCookieString( $vData, $bKeepAlive, true );
		}
		else
		{
			return UCProError::UCLIENTPRO_MAKELOGIN_FAILURE;
		}
	}
71651
public static function set_fixed_prediction($predictionid) {

        $params = self::validate_parameters(self::set_fixed_prediction_parameters(), array('predictionid' => $predictionid));

        list($model, $prediction, $context) = self::validate_prediction($params['predictionid']);

        $prediction->action_executed(\core_analytics\prediction::ACTION_FIXED, $model->get_target());

        $success = true;
        return array('success' => $success, 'warnings' => array());
    }