Process any future enrollments stored in the buffer.
@param progress_trace $trace
@return bool true if any data processed, false if not
978156
protected function process_buffer(progress_trace $trace) {
        global $DB;

        if (!$future_enrols = $DB->get_records_select('enrol_flatfile', "timestart < ?", array(time()))) {
            $trace->output("No enrolments to be processed in flatfile buffer");
            $trace->finished();
            return false;
        }

        $trace->output("Starting processing of flatfile buffer");
        foreach($future_enrols as $en) {
            $user = $DB->get_record('user', array('id'=>$en->userid));
            $course = $DB->get_record('course', array('id'=>$en->courseid));
            if ($user and $course) {
                $trace->output("buffer: $en->action $en->roleid $user->id $course->id $en->timestart $en->timeend", 1);
                $this->process_records($trace, $en->action, $en->roleid, $user, $course, $en->timestart, $en->timeend, false);
            }
            $DB->delete_records('enrol_flatfile', array('id'=>$en->id));
        }
        $trace->output("Finished processing of flatfile buffer");
        $trace->finished();

        return true;
    }
1128541
public function execute() {
        global $CFG;

        require_once($CFG->dirroot . '/enrol/flatfile/lib.php');

        if (!enrol_is_enabled('flatfile')) {
            return;
        }

        // Instance of enrol_flatfile_plugin.
        $plugin = enrol_get_plugin('flatfile');
        $result = $plugin->sync(new \null_progress_trace());
        return $result;

    }
230218
public function processRequest()
    {
        if(!$this->canProcessRequest())
        {
            return false;
        }
        if(count($_FILES) > 0)
        {
            $this->readFromHttpData();
        }
        elseif(($this->sTempFile))
        {
            $this->readFromTempFile();
        }
        return true;
    }
1021585
protected function processForm()
    {
        // Check job monitors as long as the login form is being processed
        $this->util->getMonitor()->checkMonitors();

        // Start the real work
        $this->loadForm();

        $orgId = null;
        if ($this->request->isPost()) {
            $orgId = $this->loginForm->getActiveOrganizationId();

            if ($orgId && ($this->currentUser->getCurrentOrganizationId() != $orgId)) {
                $this->currentUser->setCurrentOrganization($orgId);
            }
        }

        if ($this->loginForm->wasSubmitted()) {
            $user = $this->loginForm->getUser();

            if ($this->loginForm->isValid($this->request->getPost(), false)) {
                $user->switchLocale();

                $this->loginStatusTracker
                        ->setPasswordText($this->loginForm->getPasswordText())
                        ->setUser($user);

                return false;
            }

            $errors = \MUtil_Ra::flatten($this->loginForm->getMessages());
            // \MUtil_Echo::track($errors);

            // Also log the error to the log table  when the project has logging enabled
            $logErrors = join(' - ', $errors);
            $msg = sprintf(
                    'Failed login for : %s (%s) - %s',
                    $user->getLoginName(),
                    $user->getCurrentOrganizationId(),
                    $logErrors
                    );
            $this->accesslog->logChange($this->request, $msg);
        }

        return true;
    }
493045
public function trace()
    {
        foreach ($this->files as $file) {
            ($this->debug === true) ? $this->addTrace($file) : $this->removeTrace($file);
        }
    }
106139
public function execute() {
        if ($this->progress >= self::PROGRESS_EXECUTED) {
            throw new restore_ui_exception('restoreuialreadyexecuted');
        }
        if ($this->stage->get_stage() < self::STAGE_PROCESS) {
            throw new restore_ui_exception('restoreuifinalisedbeforeexecute');
        }
        if ($this->controller->get_target() == backup::TARGET_CURRENT_DELETING || $this->controller->get_target() == backup::TARGET_EXISTING_DELETING) {
            $options = array();
            $options['keep_roles_and_enrolments'] = $this->get_setting_value('keep_roles_and_enrolments');
            $options['keep_groups_and_groupings'] = $this->get_setting_value('keep_groups_and_groupings');
            restore_dbops::delete_course_content($this->controller->get_courseid(), $options);
        }
        $this->controller->execute_plan();
        $this->progress = self::PROGRESS_EXECUTED;
        $this->stage = new restore_ui_stage_complete($this, $this->stage->get_params(), $this->controller->get_results());
        return true;
    }
555270
public static function traceLeoCall(array $trace)
    {
        for ($i = count($trace) - 1; $i >= 0; --$i) {
            if (self::isLeoTraceEntry($trace[$i])) {
                return $trace[$i];
            }
        }

        return null;
    }
140794
public function sync(progress_trace $trace, $courseid = null) {
        global $DB;

        if (!enrol_is_enabled('self')) {
            $trace->finished();
            return 2;
        }

        // Unfortunately this may take a long time, execution can be interrupted safely here.
        core_php_time_limit::raise();
        raise_memory_limit(MEMORY_HUGE);

        $trace->output('Verifying self-enrolments...');

        $params = array('now'=>time(), 'useractive'=>ENROL_USER_ACTIVE, 'courselevel'=>CONTEXT_COURSE);
        $coursesql = "";
        if ($courseid) {
            $coursesql = "AND e.courseid = :courseid";
            $params['courseid'] = $courseid;
        }

        // Note: the logic of self enrolment guarantees that user logged in at least once (=== u.lastaccess set)
        //       and that user accessed course at least once too (=== user_lastaccess record exists).

        // First deal with users that did not log in for a really long time - they do not have user_lastaccess records.
        $sql = "SELECT e.*, ue.userid
                  FROM {user_enrolments} ue
                  JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'self' AND e.customint2 > 0)
                  JOIN {user} u ON u.id = ue.userid
                 WHERE :now - u.lastaccess > e.customint2
                       $coursesql";
        $rs = $DB->get_recordset_sql($sql, $params);
        foreach ($rs as $instance) {
            $userid = $instance->userid;
            unset($instance->userid);
            $this->unenrol_user($instance, $userid);
            $days = $instance->customint2 / 60*60*24;
            $trace->output("unenrolling user $userid from course $instance->courseid as they have did not log in for at least $days days", 1);
        }
        $rs->close();

        // Now unenrol from course user did not visit for a long time.
        $sql = "SELECT e.*, ue.userid
                  FROM {user_enrolments} ue
                  JOIN {enrol} e ON (e.id = ue.enrolid AND e.enrol = 'self' AND e.customint2 > 0)
                  JOIN {user_lastaccess} ul ON (ul.userid = ue.userid AND ul.courseid = e.courseid)
                 WHERE :now - ul.timeaccess > e.customint2
                       $coursesql";
        $rs = $DB->get_recordset_sql($sql, $params);
        foreach ($rs as $instance) {
            $userid = $instance->userid;
            unset($instance->userid);
            $this->unenrol_user($instance, $userid);
                $days = $instance->customint2 / 60*60*24;
            $trace->output("unenrolling user $userid from course $instance->courseid as they have did not access course for at least $days days", 1);
        }
        $rs->close();

        $trace->output('...user self-enrolment updates finished.');
        $trace->finished();

        $this->process_expirations($trace, $courseid);

        return 0;
    }
1023485
public function processRequirements()
    {
        foreach ($this->requirements as $requirement)
        {
            if ( ! call_user_func($requirement, $this->resource, $this))
            {
                return false;
            }
        }

        return true;
    }
896200
public function execute() {
        $manager = new \tool_dataprivacy\expired_contexts_manager(new \text_progress_trace());
        list($courses, $users) = $manager->process_approved_deletions();
        mtrace("Processed deletions for {$courses} course contexts, and {$users} user contexts as expired");
    }
308192
public function trace()
    {
        //====================================================================//
        // Safety Check
        if (!isset($this->debug) || !$this->debug) {
            return;
        }
        //====================================================================//
        // Build Error Trace
        $trace = (new Exception())->getTrace()[1];
        //====================================================================//
        //  Load Translation File
        Splash::translator()->load('main');
        //====================================================================//
        // Push Trace to Log
        return  self::deb("DebTraceMsg", $trace["class"], $trace["function"]);
    }
1133528
public function process()
    {
        if (!$this->_processed) {
            $this->_process();
            $this->_resolve();
        }
        $this->_processed = true;
        return $this->_passed !== false;
    }
238915
public function progress($progress = file_progress::INDETERMINATE, $max = file_progress::INDETERMINATE) {
        $reporter = $this->get_progress_reporter();

        // Start tracking progress if necessary.
        if (!$this->startedprogress) {
            $reporter->start_progress('extract_file_to_dir',
                    ($max == file_progress::INDETERMINATE) ? \core\progress\base::INDETERMINATE : $max);
            $this->startedprogress = true;
        }

        // Pass progress through to whatever handles it.
        $reporter->progress(
                ($progress == file_progress::INDETERMINATE) ? \core\progress\base::INDETERMINATE : $progress);
    }
1071607
public function process()
    {
        // Skip blank queues
        if (empty($this->batches)) {
            return true;
        }

        // Don't re-process completed queue
        if ($this->currentBatch >= count($this->batches)) {
            return true;
        }

        // Send current patch to indexes
        $this->prepareIndexes();

        // Advance to next batch if successful
        $this->setBatch($this->currentBatch + 1);
        return true;
    }
470006
public function save($trace = false)
    {
        $retval = parent::save($trace);

        $this->nb_attachment_list->iterate(
            function ($key, CNabuIContactProspectAttachment $nb_attachment) use ($retval) {
                $retval |= $nb_attachment->save();
                return true;
            }
        );

        return $retval;
    }
760015
public function saveCurrent()
    {
        if ($this->saveEnabled() && $this->isViewValid() && $this->isViewUnique())
        {
            $success = $this->saveCurrentModel();

            // Keep on only if the model save has succeeded
            if ($success)
            {
                $this->storeCurrentHash();

                $this->saveTrackables(
                    $this->getCurrent(),
                    $success
                );
            }

            return $success;
        }

        return false;
    }
1272985
public function isProcessRunning(bool $throwsException = false): bool
    {
        $running = false;
        try {
            $pid = $this->getPid();
            $isRunning = $this->process->isRunning($pid);
            if ($isRunning) {
                $this->logger->debug("Pid '${pid}' running.");
                $running = true;
            } else {
                $this->logger->debug("Pid '${pid}' not running.");
            }
        } catch (Exception\PidNotFoundException $e) {
            if ($throwsException) {
                throw $e;
            }
        }

        return $running;
    }