Old syntax of class constructor. Deprecated in PHP7.

@deprecated since Moodle 3.1
356176
public function moodleform($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($action, $customdata, $method, $target, $attributes, $editable);
    }
1317359
public function compile()
    {
        $indent         = '    ';
        $caseStatements = array();
        $getters        = array();
        $instances      = $this->dumper->getAllInjectedDefinitions();

        /* @var $instance GeneratorInstance */
        foreach ($instances as $name => $instance) {
            $getter = $this->normalizeAlias($name);
            $constructor = $instance->getConstructor();
            $instantiatorParams = $this->buildParams($instance->getParams());

            if ('__construct' !== $constructor) {
                // Constructor callback
                if (is_callable($constructor)) {
                    $callback = $constructor;

                    if (is_array($callback)) {
                        $class = (is_object($callback[0])) ? get_class($callback[0]) : $callback[0];
                        $method = $callback[1];
                    } elseif (is_string($callback) && strpos($callback, '::') !== false) {
                        list($class, $method) = explode('::', $callback, 2);
                    }

                    $callback = var_export(array($class, $method), true);

                    if (count($instantiatorParams)) {
                        $creation = sprintf('$object = call_user_func(%s, %s);', $callback, implode(', ', $instantiatorParams));
                    } else {
                        $creation = sprintf('$object = call_user_func(%s);', $callback);
                    }
                } else if (is_string($constructor) && strpos($constructor, '->') !== false) {
                    list($class, $method) = explode('->', $constructor, 2);

                    if (!class_exists($class)) {
                        throw new InvalidArgumentException('No class found: ' . $class);
                    }

                    $factoryGetter = $this->normalizeAlias($class);

                    if (count($instantiatorParams)) {
                        $creation = sprintf('$object = $this->' . $factoryGetter . '()->%s(%s);', $method, implode(', ', $instantiatorParams));
                    } else {
                        $creation = sprintf('$object = $this->' . $factoryGetter . '()->%s();', $method);
                    }
                } else {
                    throw new InvalidArgumentException('Invalid instantiator supplied for class: ' . $name);
                }
            } else {
                $className = '\\' . trim($this->reduceAlias($name), '\\');

                if (count($instantiatorParams)) {
                    $creation = sprintf('$object = new %s(%s);', $className, implode(', ', $instantiatorParams));
                } else {
                    $creation = sprintf('$object = new %s();', $className);
                }
            }


            // Create method call code
            if ($instance->isShared()) {
                $creation .= "\n\nif (\$isShared) {\n" . $indent
                    . '$this->instanceManager->addSharedInstance($object, \'' . $instance->getName() . '\');'
                    . "\n}\n";
            }
            $methods = '';

            foreach ($instance->getMethods() as $methodData) {
                $methodName   = $methodData['method'];
                $methodParams = $methodData['params'];
                // Create method parameter representation
                $params = $this->buildParams($methodParams);

                if (count($params)) {
                    $methods .= sprintf("\$object->%s(%s);\n", $methodName, implode(', ', $params));
                }
            }

            $storage = '';

            // Start creating getter
            $getterBody = '';

            // Creation and method calls
            $getterBody .= sprintf("%s\n", $creation);
            $getterBody .= $methods;

            // Stored service
            $getterBody .= $storage;

            // End getter body
            $getterBody .= "return \$object;\n";

            $getterDef = new MethodGenerator();
            $getterDef->setName($getter);
            $getterDef->setParameter('isShared');
            $getterDef->setVisibility(MethodGenerator::VISIBILITY_PROTECTED);
            $getterDef->setBody($getterBody);
            $getters[] = $getterDef;

            // Build case statement and store
            $statement = '';
            $statement .= sprintf("%scase '%s':\n", $indent, $name);
            $statement .= sprintf("%sreturn \$this->%s(%s);\n", str_repeat($indent, 2), $getter, '$isShared');

            $caseStatements[] = $statement;
        }

        // Build switch statement
        $switch = sprintf(
            "if (%s) {\n%sreturn parent::newInstance(%s, %s, %s);\n}\n",
            '$params',
            $indent,
            '$name',
            '$params',
            '$isShared'
        );
        $switch .= sprintf(
            "switch (%s) {\n%s\n", '$name', implode("\n", $caseStatements)
        );
        $switch .= sprintf(
            "%sdefault:\n%sreturn parent::newInstance(%s, %s, %s);\n",
            $indent,
            str_repeat($indent, 2),
            '$name',
            '$params',
            '$isShared'
        );
        $switch .= "}\n\n";

        // Build newInstance() method
        $nameParam   = new ParameterGenerator();
        $nameParam->setName('name');

        $paramsParam = new ParameterGenerator();
        $paramsParam
            ->setName('params')
            ->setType('array')
            ->setDefaultValue(array());

        $isSharedParam = new ParameterGenerator();
        $isSharedParam
            ->setName('isShared')
            ->setDefaultValue(true);

        $get = new MethodGenerator();
        $get->setName('newInstance');
        $get->setParameters(array(
            $nameParam,
            $paramsParam,
            $isSharedParam,
        ));
        $get->setBody($switch);

        // Create class code generation object
        $container = $this->getClassGenerator();
        $container
            ->setName($this->containerClass)
            ->setExtendedClass('Di')
            ->addMethods(array($get))
            ->addMEthods($getters);

        // Create PHP file code generation object
        $classFile = $this->getFileGenerator();

        $classFile->setClass($container);
        $classFile->setUse('Zend\Di\Di');

        if (null !== $this->namespace) {
            $classFile->setNamespace($this->namespace);
        }

        return $classFile;
    }
1296768
public function user_filter_profilefield($name, $label, $advanced) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($name, $label, $advanced);
    }
679826
public function MoodleQuickForm_wikifiletable($elementName = null, $elementLabel = null, $attributes = null, $fileinfo = null, $format = null) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($elementName, $elementLabel, $attributes, $fileinfo, $format);
    }
922202
private function prepareClassDeclaration()
    {
        $this->getDocument()->addUse('\nabu\db\CNabuDBInternalObject');
        $this->setExtends('CNabuDBInternalObject');

        if ($this->is_customer_child || $this->is_customer_foreign) {
            $this->getDocument()->addUse('\nabu\data\customer\traits\TNabuCustomerChild');
            $this->addUse('TNabuCustomerChild');
        }

        if ($this->is_commerce_child || $this->is_commerce_foreign) {
            $this->getDocument()->addUse('\nabu\data\commerce\traits\TNabuCommerceChild');
            $this->addUse('TNabuCommerceChild');
        }

        if ($this->is_catalog_child || $this->is_catalog_foreign) {
            $this->getDocument()->addUse('\nabu\data\catalog\traits\TNabuCatalogChild');
            $this->addUse('TNabuCatalogChild');
        }

        if ($this->is_site_child || $this->is_site_foreign) {
            $this->getDocument()->addUse('\nabu\data\site\traits\TNabuSiteChild');
            $this->addUse('TNabuSiteChild');
        }

        if ($this->is_site_target_child || $this->is_site_target_foreign) {
            $this->getDocument()->addUse('\nabu\data\site\traits\TNabuSiteTargetChild');
            $this->addUse('TNabuSiteTargetChild');
        }

        if ($this->is_medioteca_child || $this->is_medioteca_foreign) {
            $this->getDocument()->addUse('\nabu\data\medioteca\traits\TNabuMediotecaChild');
            $this->addUse('TNabuMediotecaChild');
        }

        if ($this->is_messaging_child || $this->is_messaging_foreign) {
            $this->getDocument()->addUse('\nabu\data\messaging\traits\TNabuMessagingChild');
            $this->addUse('TNabuMessagingChild');
        }

        if ($this->is_messaging_service_child || $this->is_messaging_service_foreign) {
            $this->getDocument()->addUse('nabu\data\messaging\traits\TNabuMessagingServiceChild');
            $this->addUse('TNabuMessagingServiceChild');
        }

        if ($this->is_project_child || $this->is_project_foreign) {
            $this->getDocument()->addUse('nabu\data\project\traits\TNabuProjectChild');
            $this->addUse('TNabuProjectChild');
        }

        if ($this->is_role_child || $this->is_role_foreign) {
            $this->getDocument()->adduse('\nabu\data\security\traits\TNabuRoleChild');
            $this->addUse('TNabuRoleChild');
        }

        if ($this->checkForTranslatedTable()) {
            $this->addInterface('INabuTranslated');
            $this->getDocument()->addUse('\nabu\data\lang\interfaces\INabuTranslated');
            $this->getDocument()->addUse('\nabu\data\lang\traits\TNabuTranslated');
            $this->addUse('TNabuTranslated');
        }

        if ($this->checkForTranslationTable()) {
            $this->addInterface('INabuTranslation');
            $this->getDocument()->addUse('\nabu\data\lang\interfaces\INabuTranslation');
            $this->getDocument()->addUse('\nabu\data\lang\traits\TNabuTranslation');
            $this->addUse('TNabuTranslation');
        }

        if ($this->isHashed()) {
            $this->addInterface('INabuHashed');
            $this->getDocument()->addUse('\nabu\core\interfaces\INabuHashed');
            $this->getDocument()->addUse('\nabu\core\traits\TNabuHashed');
            $this->addUse('TNabuHashed');
        }
    }
241034
public function initialise_javascript(moodle_page $page) {

        $options = new stdClass;
        $options->client_id   = $this->cid;
        $options->commentarea = $this->commentarea;
        $options->itemid      = $this->itemid;
        $options->page        = 0;
        $options->courseid    = $this->courseid;
        $options->contextid   = $this->contextid;
        $options->component   = $this->component;
        $options->notoggle    = $this->notoggle;
        $options->autostart   = $this->autostart;

        $page->requires->js_init_call('M.core_comment.init', array($options), true);

        return true;
    }
420324
function todoWriter(&$doclet) {

        parent::MDWriter($doclet);

        $rootDoc = & $this->_doclet->rootDoc();

        $todoClasses = array();
        $classes = & $rootDoc->classes();
        $todoFields = array();
        $todoMethods = array();
        if ($classes) {
            foreach ($classes as $class) {
                if ($class->tags("@todo")) {
                    $todoClasses[] = $class;
                }
                $fields = & $class->fields();
                if ($fields) {
                    foreach ($fields as $field) {
                        if ($field->tags("@todo")) {
                            $todoFields[] = $field;
                        }
                    }
                }
                $classes = & $class->methods();
                if ($classes) {
                    foreach ($classes as $method) {
                        if ($method->tags("@todo")) {
                            $todoMethods[] = $method;
                        }
                    }
                }
            }
        }
        $todoGlobals = array();
        $globals = & $rootDoc->globals();
        if ($globals) {
            foreach ($globals as $global) {
                if ($global->tags("@todo")) {
                    $todoGlobals[] = $global;
                }
            }
        }
        $todoFunctions = array();
        $functions = & $rootDoc->functions();
        if ($functions) {
            foreach ($functions as $function) {
                if ($function->tags("@todo")) {
                    $todoFunctions[] = $function;
                }
            }
        }

        ob_start();

        echo "- - -\n\n";

        echo "#Todo#";

        echo "\n\n- - -\n\n";

        if ($todoClasses || $todoFields || $todoMethods || $todoGlobals || $todoFunctions) {
            echo "##Contents##\n\n";

            echo "<ul>\n";
            if ($todoClasses) {
                echo "<li><a href=\"#todo_class\">Todo Classes</a></li>";
            }
            if ($todoFields) {
                echo "<li><a href=\"#todo_field\">Todo Fields</a></li>";
            }
            if ($todoMethods) {
                echo "<li><a href=\"#todo_method\">Todo Methods</a></li>";
            }
            if ($todoGlobals) {
                echo "<li><a href=\"#todo_global\">Todo Globals</a></li>";
            }
            if ($todoFunctions) {
                echo "<li><a href=\"#todo_function\">Todo Functions</a></li>";
            }
            echo "</ul>\n";
        }

        if ($todoClasses) {
            echo "<table id=\"todo_class\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Classes</th></tr>", "\n";
            foreach ($todoClasses as $class) {
                $todoTag = & $class->tags("@todo");
                echo "<tr><td class=\"name\"><a href=\"", $this->_asURL($class), "\">", $class->qualifiedName(), "</a></td>";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td></tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoFields) {
            echo "<table id=\"todo_field\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Fields</th></tr>", "\n";
            foreach ($todoFields as $field) {
                $todoTag = & $field->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($field), "\">", $field->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoMethods) {
            echo "<table id=\"todo_method\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Methods</th></tr>", "\n";
            foreach ($todoMethods as $method) {
                $todoTag = & $method->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($method), "\">", $method->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoGlobals) {
            echo "<table id=\"todo_global\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Globals</th></tr>", "\n";
            foreach ($todoGlobals as $global) {
                $todoTag = & $global->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($global), "\">", $global->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        if ($todoFunctions) {
            echo "<table id=\"todo_function\" class=\"detail\">", "\n";
            echo "<tr><th colspan=\"2\" class=\"title\">Todo Functions</th></tr>", "\n";
            foreach ($todoFunctions as $function) {
                $todoTag = & $function->tags("@todo");
                echo "<tr>\n";
                echo "<td class=\"name\"><a href=\"", $this->_asURL($function), "\">", $function->qualifiedName(), "</a></td>\n";
                echo "<td class=\"description\">";
                if ($todoTag)
                    echo strip_tags($this->_processInlineTags($todoTag, TRUE), "<a><b>**<u><em>");
                echo "</td>\n";
                echo "</tr>\n";
            }
            echo "</table>\n\n";
        }

        $this->_output = ob_get_contents();
        ob_end_clean();

        $this->_write("todo-list.md");
    }
986860
public function initialise() {
        global $PAGE, $USER, $OUTPUT, $CFG;
        if (during_initial_install()) {
            return;
        }

        $current = false;

        $course = $PAGE->course;

        $this->page->navigation->initialise();

        // First walk the nav tree looking for "flat_navigation" nodes.
        if ($course->id > 1) {
            // It's a real course.
            $url = new moodle_url('/course/view.php', array('id' => $course->id));

            $coursecontext = context_course::instance($course->id, MUST_EXIST);
            // This is the name that will be shown for the course.
            $coursename = empty($CFG->navshowfullcoursenames) ?
                format_string($course->shortname, true, array('context' => $coursecontext)) :
                format_string($course->fullname, true, array('context' => $coursecontext));

            $flat = new flat_navigation_node(navigation_node::create($coursename, $url), 0);
            $flat->set_collectionlabel($coursename);
            $flat->key = 'coursehome';
            $flat->icon = new pix_icon('i/course', '');

            $courseformat = course_get_format($course);
            $coursenode = $PAGE->navigation->find_active_node();
            $targettype = navigation_node::TYPE_COURSE;

            // Single activity format has no course node - the course node is swapped for the activity node.
            if (!$courseformat->has_view_page()) {
                $targettype = navigation_node::TYPE_ACTIVITY;
            }

            while (!empty($coursenode) && ($coursenode->type != $targettype)) {
                $coursenode = $coursenode->parent;
            }
            // There is one very strange page in mod/feedback/view.php which thinks it is both site and course
            // context at the same time. That page is broken but we need to handle it (hence the SITEID).
            if ($coursenode && $coursenode->key != SITEID) {
                $this->add($flat);
                foreach ($coursenode->children as $child) {
                    if ($child->action) {
                        $flat = new flat_navigation_node($child, 0);
                        $this->add($flat);
                    }
                }
            }

            $this->page->navigation->build_flat_navigation_list($this, true, get_string('site'));
        } else {
            $this->page->navigation->build_flat_navigation_list($this, false, get_string('site'));
        }

        $admin = $PAGE->settingsnav->find('siteadministration', navigation_node::TYPE_SITE_ADMIN);
        if (!$admin) {
            // Try again - crazy nav tree!
            $admin = $PAGE->settingsnav->find('root', navigation_node::TYPE_SITE_ADMIN);
        }
        if ($admin) {
            $flat = new flat_navigation_node($admin, 0);
            $flat->set_showdivider(true, get_string('sitesettings'));
            $flat->key = 'sitesettings';
            $flat->icon = new pix_icon('t/preferences', '');
            $this->add($flat);
        }

        // Add-a-block in editing mode.
        if (isset($this->page->theme->addblockposition) &&
                $this->page->theme->addblockposition == BLOCK_ADDBLOCK_POSITION_FLATNAV &&
                $PAGE->user_is_editing() && $PAGE->user_can_edit_blocks() &&
                ($addable = $PAGE->blocks->get_addable_blocks())) {
            $url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]);
            $addablock = navigation_node::create(get_string('addblock'), $url);
            $flat = new flat_navigation_node($addablock, 0);
            $flat->set_showdivider(true, get_string('blocksaddedit'));
            $flat->key = 'addblock';
            $flat->icon = new pix_icon('i/addblock', '');
            $this->add($flat);
            $blocks = [];
            foreach ($addable as $block) {
                $blocks[] = $block->name;
            }
            $params = array('blocks' => $blocks, 'url' => '?' . $url->get_query_string(false));
            $PAGE->requires->js_call_amd('core/addblockmodal', 'init', array($params));
        }
    }
851083
public static function debug()
    {
        $vars = func_get_args();

        $cloner = new VarCloner();

        $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();

        $dumper->setStyles([
            'default' => 'background-color:#fff; color:#FF8400; line-height:1.2em; 
                font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; 
                white-space: pre-wrap; position:relative; z-index:99999; word-break: normal',
            'num' => 'font-weight:bold; color:#1299DA',
            'const' => 'font-weight:bold',
            'str' => 'color:#111111',
            'note' => 'color:#1299DA',
            'ref' => 'color:#A0A0A0',
            'public' => 'color:blue',
            'protected' => 'color:#111',
            'private' => 'color:#478',
            'meta' => 'color:#B729D9',
            'key' => 'color:#212',
            'index' => 'color:#1200DA',
        ]);

        $handler = function ($vars) use ($cloner, $dumper) {
            if (!is_array($vars)) {
                $vars = [$vars];
            }

            foreach ($vars as $var) {
                $dumper->dump($cloner->cloneVar($var));
            }
        };

        call_user_func_array($handler, [$vars]);
    }
358831
function db_init() {
        if ($this->is_configured() === false) {
            throw new moodle_exception('auth_dbcantconnect', 'auth_db');
        }

        // Connect to the external database (forcing new connection).
        $authdb = ADONewConnection($this->config->type);
        if (!empty($this->config->debugauthdb)) {
            $authdb->debug = true;
            ob_start(); //Start output buffer to allow later use of the page headers.
        }
        $authdb->Connect($this->config->host, $this->config->user, $this->config->pass, $this->config->name, true);
        $authdb->SetFetchMode(ADODB_FETCH_ASSOC);
        if (!empty($this->config->setupsql)) {
            $authdb->Execute($this->config->setupsql);
        }

        return $authdb;
    }
224437
function definition () {
        global $USER, $CFG, $COURSE;
        $coursecontext = context_course::instance($COURSE->id);

        $mform =& $this->_form;
        $editoroptions = $this->_customdata['editoroptions'];

        $mform->addElement('header', 'general', get_string('general', 'form'));

        $mform->addElement('text','name', get_string('groupname', 'group'),'maxlength="254" size="50"');
        $mform->addRule('name', get_string('required'), 'required', null, 'client');
        $mform->setType('name', PARAM_TEXT);

        $mform->addElement('text','idnumber', get_string('idnumbergroup'), 'maxlength="100" size="10"');
        $mform->addHelpButton('idnumber', 'idnumbergroup');
        $mform->setType('idnumber', PARAM_RAW);
        if (!has_capability('moodle/course:changeidnumber', $coursecontext)) {
            $mform->hardFreeze('idnumber');
        }

        $mform->addElement('editor', 'description_editor', get_string('groupdescription', 'group'), null, $editoroptions);
        $mform->setType('description_editor', PARAM_RAW);

        $mform->addElement('passwordunmask', 'enrolmentkey', get_string('enrolmentkey', 'group'), 'maxlength="254" size="24"', get_string('enrolmentkey', 'group'));
        $mform->addHelpButton('enrolmentkey', 'enrolmentkey', 'group');
        $mform->setType('enrolmentkey', PARAM_RAW);

        // Group conversation messaging.
        if (\core_message\api::can_create_group_conversation($USER->id, $coursecontext)) {
            $mform->addElement('selectyesno', 'enablemessaging', get_string('enablemessaging', 'group'));
            $mform->addHelpButton('enablemessaging', 'enablemessaging', 'group');
        }

        $mform->addElement('static', 'currentpicture', get_string('currentpicture'));

        $mform->addElement('checkbox', 'deletepicture', get_string('delete'));
        $mform->setDefault('deletepicture', 0);

        $options = array(get_string('no'), get_string('yes'));
        $mform->addElement('select', 'hidepicture', get_string('hidepicture'), $options);

        $mform->addElement('filepicker', 'imagefile', get_string('newpicture', 'group'));
        $mform->addHelpButton('imagefile', 'newpicture', 'group');

        $mform->addElement('hidden','id');
        $mform->setType('id', PARAM_INT);

        $mform->addElement('hidden','courseid');
        $mform->setType('courseid', PARAM_INT);

        $this->add_action_buttons();
    }
1297583
public function moodleform_mod($current, $section, $cm, $course) {
        debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
        self::__construct($current, $section, $cm, $course);
    }
189534
public function _construct()
    {
        $this->_controller = 'adminhtml_rules';
        $this->_blockGroup = 'Dotdigitalgroup_Email';
        $this->_headerText = 'Email Exclusion Rule(s)';
        parent::_construct();
        $this->_addButtonLabel = 'Add New Rule';
    }
1230455
function enrol_page_hook(stdClass $instance) {
        global $CFG, $USER, $OUTPUT, $PAGE, $DB;

        ob_start();

        if ($DB->record_exists('user_enrolments', array('userid'=>$USER->id, 'enrolid'=>$instance->id))) {
            return ob_get_clean();
        }

        if ($instance->enrolstartdate != 0 && $instance->enrolstartdate > time()) {
            return ob_get_clean();
        }

        if ($instance->enrolenddate != 0 && $instance->enrolenddate < time()) {
            return ob_get_clean();
        }

        $course = $DB->get_record('course', array('id'=>$instance->courseid));
        $context = context_course::instance($course->id);

        $shortname = format_string($course->shortname, true, array('context' => $context));
        $strloginto = get_string("loginto", "", $shortname);
        $strcourses = get_string("courses");

        // Pass $view=true to filter hidden caps if the user cannot see them
        if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC',
                                             '', '', '', '', false, true)) {
            $users = sort_by_roleassignment_authority($users, $context);
            $teacher = array_shift($users);
        } else {
            $teacher = false;
        }

        if ( (float) $instance->cost <= 0 ) {
            $cost = (float) $this->get_config('cost');
        } else {
            $cost = (float) $instance->cost;
        }

        if (abs($cost) < 0.01) { // no cost, other enrolment methods (instances) should be used
            echo '<p>'.get_string('nocost', 'enrol_paypal').'</p>';
        } else {

            // Calculate localised and "." cost, make sure we send PayPal the same value,
            // please note PayPal expects amount with 2 decimal places and "." separator.
            $localisedcost = format_float($cost, 2, true);
            $cost = format_float($cost, 2, false);

            if (isguestuser()) { // force login only for guest user, not real users with guest role
                $wwwroot = $CFG->wwwroot;
                echo '<div class="mdl-align"><p>'.get_string('paymentrequired').'</p>';
                echo '<p><b>'.get_string('cost').": $instance->currency $localisedcost".'</b></p>';
                echo '<p><a href="'.$wwwroot.'/login/">'.get_string('loginsite').'</a></p>';
                echo '</div>';
            } else {
                //Sanitise some fields before building the PayPal form
                $coursefullname  = format_string($course->fullname, true, array('context'=>$context));
                $courseshortname = $shortname;
                $userfullname    = fullname($USER);
                $userfirstname   = $USER->firstname;
                $userlastname    = $USER->lastname;
                $useraddress     = $USER->address;
                $usercity        = $USER->city;
                $instancename    = $this->get_instance_name($instance);

                include($CFG->dirroot.'/enrol/paypal/enrol.html');
            }

        }

        return $OUTPUT->box(ob_get_clean());
    }
142334
function class_export( $classname, array $commentData = array() ){
		echo 
		"/**\n * Auto-generated file containing class $classname";
		foreach( $commentData as $tag => $value ){
			echo "\n * @$tag $value";
		}
		echo 
		"\n */\n",
		"\n",
		"import('PLUG.parsing.Lex');\n",
		"\n";
		// hard-define integer symbols
		// excluding re-definitions or existing symbols
		ksort( $this->names );
		foreach( $this->names as $i => $c ){
			if( ! is_int($i) ){
				continue;
			}
			if( isset($this->redefinitions[$i]) ){
				//echo "// redefinition: $c = $i \n";
			}
			else {
				echo "define( ",var_export($c,1),", $i );\n";
			}
		}
		// define subclass with overloaded members
		$i = var_export( $this->i, 1 );
		echo 
		"\n",
		"/**\n * Auto-generated Lex subclass";
		// unset page level doc block tags we don't want against the class
		unset (
			$commentData['author'], $commentData['version']
		);
		foreach( $commentData as $tag => $value ){
			echo "\n * @$tag $value";
		}
		echo 
		"\n */\n",
		"class $classname extends Lex {\n",
		"\n",
		// overload $i
		"/** @var int */\n",
		"protected \$i = $i;\n",
		"\n",
		// overload names, parent class's $names array will not need to be consulted
		"/** @var array */\n",
		"protected \$names = ",var_export( $this->names, 1 ),";\n",
		// overload literals, parent class's $literals array will not need to be consulted
		"/** @var array */\n",
		"protected \$literals = ",var_export( $this->literals, 1 ),";\n",
		"\n",
		// end class
		"}\n";
	}
294319
public function init() {
        global $CFG, $DB;

        $this->close();

        export_verify_grades($this->course->id);
        $course_item = grade_item::fetch_course_item($this->course->id);
        if ($course_item->needsupdate) {
            // Can not calculate all final grades - sorry.
            return false;
        }

        $coursecontext = context_course::instance($this->course->id);

        list($relatedctxsql, $relatedctxparams) = $DB->get_in_or_equal($coursecontext->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'relatedctx');
        list($gradebookroles_sql, $params) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
        list($enrolledsql, $enrolledparams) = get_enrolled_sql($coursecontext, '', 0, $this->onlyactive);

        $params = array_merge($params, $enrolledparams, $relatedctxparams);

        if ($this->groupid) {
            $groupsql = "INNER JOIN {groups_members} gm ON gm.userid = u.id";
            $groupwheresql = "AND gm.groupid = :groupid";
            // $params contents: gradebookroles
            $params['groupid'] = $this->groupid;
        } else {
            $groupsql = "";
            $groupwheresql = "";
        }

        if (empty($this->sortfield1)) {
            // We must do some sorting even if not specified.
            $ofields = ", u.id AS usrt";
            $order   = "usrt ASC";

        } else {
            $ofields = ", u.$this->sortfield1 AS usrt1";
            $order   = "usrt1 $this->sortorder1";
            if (!empty($this->sortfield2)) {
                $ofields .= ", u.$this->sortfield2 AS usrt2";
                $order   .= ", usrt2 $this->sortorder2";
            }
            if ($this->sortfield1 != 'id' and $this->sortfield2 != 'id') {
                // User order MUST be the same in both queries,
                // must include the only unique user->id if not already present.
                $ofields .= ", u.id AS usrt";
                $order   .= ", usrt ASC";
            }
        }

        $userfields = 'u.*';
        $customfieldssql = '';
        if ($this->allowusercustomfields && !empty($CFG->grade_export_customprofilefields)) {
            $customfieldscount = 0;
            $customfieldsarray = grade_helper::get_user_profile_fields($this->course->id, $this->allowusercustomfields);
            foreach ($customfieldsarray as $field) {
                if (!empty($field->customid)) {
                    $customfieldssql .= "
                            LEFT JOIN (SELECT * FROM {user_info_data}
                                WHERE fieldid = :cf$customfieldscount) cf$customfieldscount
                            ON u.id = cf$customfieldscount.userid";
                    $userfields .= ", cf$customfieldscount.data AS customfield_{$field->customid}";
                    $params['cf'.$customfieldscount] = $field->customid;
                    $customfieldscount++;
                }
            }
        }

        $users_sql = "SELECT $userfields $ofields
                        FROM {user} u
                        JOIN ($enrolledsql) je ON je.id = u.id
                             $groupsql $customfieldssql
                        JOIN (
                                  SELECT DISTINCT ra.userid
                                    FROM {role_assignments} ra
                                   WHERE ra.roleid $gradebookroles_sql
                                     AND ra.contextid $relatedctxsql
                             ) rainner ON rainner.userid = u.id
                         WHERE u.deleted = 0
                             $groupwheresql
                    ORDER BY $order";
        $this->users_rs = $DB->get_recordset_sql($users_sql, $params);

        if (!$this->onlyactive) {
            $context = context_course::instance($this->course->id);
            $this->suspendedusers = get_suspended_userids($context);
        } else {
            $this->suspendedusers = array();
        }

        if (!empty($this->grade_items)) {
            $itemids = array_keys($this->grade_items);
            list($itemidsql, $grades_params) = $DB->get_in_or_equal($itemids, SQL_PARAMS_NAMED, 'items');
            $params = array_merge($params, $grades_params);

            $grades_sql = "SELECT g.* $ofields
                             FROM {grade_grades} g
                             JOIN {user} u ON g.userid = u.id
                             JOIN ($enrolledsql) je ON je.id = u.id
                                  $groupsql
                             JOIN (
                                      SELECT DISTINCT ra.userid
                                        FROM {role_assignments} ra
                                       WHERE ra.roleid $gradebookroles_sql
                                         AND ra.contextid $relatedctxsql
                                  ) rainner ON rainner.userid = u.id
                              WHERE u.deleted = 0
                              AND g.itemid $itemidsql
                              $groupwheresql
                         ORDER BY $order, g.itemid ASC";
            $this->grades_rs = $DB->get_recordset_sql($grades_sql, $params);
        } else {
            $this->grades_rs = false;
        }

        return true;
    }
666088
private function validateConstructor(Node $constructor, Node $classNode)
    {
        if ($constructor->isStatic()) {
            // For PHP Parser 4.x
            $className = $classNode->name instanceof Identifier ? $classNode->name->toString() : $classNode->name;

            $msg = \sprintf(
                'Constructor %s::%s() cannot be static',
                \implode('\\', \array_merge($this->namespace, (array) $className)),
                $constructor->name
            );
            throw new FatalErrorException($msg, 0, E_ERROR, null, $classNode->getLine());
        }

        if (\method_exists($constructor, 'getReturnType') && $constructor->getReturnType()) {
            // For PHP Parser 4.x
            $className = $classNode->name instanceof Identifier ? $classNode->name->toString() : $classNode->name;

            $msg = \sprintf(
                'Constructor %s::%s() cannot declare a return type',
                \implode('\\', \array_merge($this->namespace, (array) $className)),
                $constructor->name
            );
            throw new FatalErrorException($msg, 0, E_ERROR, null, $classNode->getLine());
        }
    }