Returns the subplugin information to attach to feedback element
@return backup_subplugin_element
554814
protected function define_grade_subplugin_structure() {

        // Create XML elements.
        $subplugin = $this->get_subplugin_element();
        $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
        $subpluginelementfiles = new backup_nested_element('feedback_editpdf_files', null, array('gradeid'));
        $subpluginelementannotations = new backup_nested_element('feedback_editpdf_annotations');
        $subpluginelementannotation = new backup_nested_element('annotation', null, array('gradeid', 'pageno', 'type', 'x', 'y', 'endx', 'endy', 'colour', 'path', 'draft'));
        $subpluginelementcomments = new backup_nested_element('feedback_editpdf_comments');
        $subpluginelementcomment = new backup_nested_element('comment', null, array('gradeid', 'pageno', 'x', 'y', 'width', 'rawtext', 'colour', 'draft'));
        $subpluginelementrotation = new backup_nested_element('feedback_editpdf_rotation');
        $subpluginelementpagerotation = new backup_nested_element('pagerotation', null,
            array('gradeid', 'pageno', 'pathnamehash', 'isrotated', 'degree'));

        // Connect XML elements into the tree.
        $subplugin->add_child($subpluginwrapper);
        $subpluginelementannotations->add_child($subpluginelementannotation);
        $subpluginelementcomments->add_child($subpluginelementcomment);
        $subpluginelementrotation->add_child($subpluginelementpagerotation);
        $subpluginwrapper->add_child($subpluginelementfiles);
        $subpluginwrapper->add_child($subpluginelementannotations);
        $subpluginwrapper->add_child($subpluginelementcomments);
        $subpluginwrapper->add_child($subpluginelementrotation);

        // Set source to populate the data.
        $subpluginelementfiles->set_source_sql('SELECT id AS gradeid from {assign_grades} where id = :gradeid', array('gradeid' => backup::VAR_PARENTID));
        $subpluginelementannotation->set_source_table('assignfeedback_editpdf_annot', array('gradeid' => backup::VAR_PARENTID));
        $subpluginelementcomment->set_source_table('assignfeedback_editpdf_cmnt', array('gradeid' => backup::VAR_PARENTID));
        $subpluginelementpagerotation->set_source_table('assignfeedback_editpdf_rot', array('gradeid' => backup::VAR_PARENTID));
        // We only need to backup the files in the final pdf area, and the readonly page images - the others can be regenerated.
        $subpluginelementfiles->annotate_files('assignfeedback_editpdf',
            \assignfeedback_editpdf\document_services::FINAL_PDF_FILEAREA, 'gradeid');
        $subpluginelementfiles->annotate_files('assignfeedback_editpdf',
            \assignfeedback_editpdf\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'gradeid');
        $subpluginelementfiles->annotate_files('assignfeedback_editpdf', 'stamps', 'gradeid');
        return $subplugin;
    }
516605
function getFeedback() {
        var out;
        out = this.textareaElement ?
            this.textareaElement.value : this._feedback;
        return out ? out.trim() : out;
    }
29302
protected function get_submission_plugin() {
        global $CFG;
        if (!$this->plugin || !$this->cmid) {
            return null;
        }

        require_once($CFG->dirroot . '/mod/assign/locallib.php');

        $context = context_module::instance($this->cmid);

        $assignment = new assign($context, null, null);
        return $assignment->get_submission_plugin_by_type($this->plugin);
    }
1244843
protected function define_workshop_subplugin_structure() {

        $paths = array();

        $elename = $this->get_namefor('setting');
        $elepath = $this->get_pathfor('/workshopeval_best_settings'); // we used get_recommended_name() so this works
        $paths[] = new restore_path_element($elename, $elepath);

        return $paths; // And we return the interesting paths
    }
623588
public function define_enrol_plugin_structure() {
        // Get the parent we will be adding these elements to.
        $plugin = $this->get_plugin_element();

        // Define our elements.
        $tool = new backup_nested_element('tool', array('id'), array(
            'enrolid', 'contextid', 'institution', 'lang', 'timezone', 'maxenrolled', 'maildisplay', 'city',
            'country', 'gradesync', 'gradesynccompletion', 'membersync', 'membersyncmode',  'roleinstructor',
            'rolelearner', 'secret', 'timecreated', 'timemodified'));

        $users = new backup_nested_element('users');

        $user = new backup_nested_element('user', array('id'), array(
            'userid', 'toolid', 'serviceurl', 'sourceid', 'consumerkey', 'consumersecret', 'membershipurl',
            'membershipsid'));

        // Build elements hierarchy.
        $plugin->add_child($tool);
        $tool->add_child($users);
        $users->add_child($user);

        // Set sources to populate the data.
        $tool->set_source_table('enrol_lti_tools',
            array('enrolid' => backup::VAR_PARENTID));

        // Users are only added only if users included.
        if ($this->task->get_setting_value('users')) {
            $user->set_source_table('enrol_lti_users', array('toolid' => backup::VAR_PARENTID));
        }
    }
614437
public function getPluginsInformation()
    {
        if (count($this->pluginsData) == 0) {
            $url = $this->_constructUrl(self::PLUGINS_SERVLET, ['wt' => 'json']);
            $pluginsInformation = $this->_sendRawGet($url);

            // access a random property to trigger response parsing
            $pluginsInformation->responseHeader;
            $this->pluginsData = $pluginsInformation;
        }

        return $this->pluginsData;
    }
1333452
protected function define_assessment_subplugin_structure() {

        $paths = array();

        $elename = $this->get_namefor('grade');
        $elepath = $this->get_pathfor('/workshopform_accumulative_grade'); // we used get_recommended_name() so this works
        $paths[] = new restore_path_element($elename, $elepath);

        return $paths; // And we return the interesting paths
    }
178459
protected function define_logstore_subplugin_structure() {
        $subplugin = $this->get_subplugin_element();
        $subpluginwrapper = new backup_nested_element($this->get_recommended_name());

        // Create the custom (base64 encoded, xml safe) 'other' final element.
        $otherelement = new base64_encode_final_element('other');

        $subpluginlog = new backup_logstore_database_nested_element('logstore_database_log', array('id'), array(
            'eventname', 'component', 'action', 'target', 'objecttable',
            'objectid', 'crud', 'edulevel', 'contextid', 'userid', 'relateduserid',
            'anonymous', $otherelement, 'timecreated', 'ip', 'realuserid'));

        $subplugin->add_child($subpluginwrapper);
        $subpluginwrapper->add_child($subpluginlog);

        // Get the details for the external database.
        $manager = new \tool_log\log\manager();
        $store = new \logstore_database\log\store($manager);
        $extdb = $store->get_extdb();

        if (!$extdb) {
            return false;
        }

        $subpluginlog->set_source_db($extdb);
        $subpluginlog->set_source_table($store->get_config_value('dbtable'), array('contextid' => backup::VAR_CONTEXTID));

        return $subplugin;
    }
1162173
public function getSubtitle()
    {
        return $this->getCachedProperty(
            'subtitle',
            function () {
                // No REQUIRED — no exception.
                $element = $this->query('atom:subtitle', Node::SINGLE);

                /** @var Element $this */
                return $element ? $this->getExtensions()->parseElement($this, $element) : null;
            }
        );
    }
47359
public function getCMSFields()
    {
        $this->beforeUpdateCMSFields(function (FieldList $fields) {
            $fields->removeByName('ElementPromos');

            $config = GridFieldConfig_RecordViewer::create();
            $fields->addFieldToTab(
                'Root.Elements',
                GridField::create(
                    'ElementPromos',
                    'Elements',
                    $this->ElementPromos(),
                    $config
                )
            );

            $fields->dataFieldByName('Image')
                ->setFolderName('Uploads/Elements/Promos');
        });

        return parent::getCMSFields();
    }
1107270
public function getFormElements()
    {
        $sm = $this->getServiceLocator();
        $formElements = array();
        $placeholders = $this->getPlaceholderParameters();
        $replacePlaceholderWithValues = array();
        foreach ($this->formElements as $element) {
            // Remove form element if it is available in the remove list
            if (in_array($element['name'], $this->removeElements)) {
                continue;
            }
            $formElement = $this->formatFormElement($element);
            // Replace placeholder with default values
            $replacePlaceholderWithValues = $sm->get($this->moduleService)->defaultConfig('placeholder');
            // Replace placeholder with global form values
            if (!empty($placeholders) && is_array($placeholders)) {
                // Replace placeholder with global values
                if (array_key_exists('global', $placeholders) &&  !empty($placeholders['global']) &&  is_array($placeholders['global'])) {
                    $replacePlaceholderWithValues = array_merge($replacePlaceholderWithValues, $placeholders['global']);
                }
                // Replace placeholder with element form values
                if (array_key_exists('element', $placeholders) &&  !empty($placeholders['element']) &&  is_array($placeholders['element'])) {
                    if (array_key_exists($element['name'], $placeholders['element'])) {
                        $replacePlaceholderWithValues = array_merge($replacePlaceholderWithValues, $placeholders['element'][$element['name']]);
                    }
                }
            }
            $formElement = $this->searchAndReplacePlaceHolders($formElement, $replacePlaceholderWithValues);
            $formElements[] = $formElement;
        }
        return $formElements;
    }
64343
protected function getMigrationStub()
	{
		$stub = $this->files->get(__DIR__.'/stubs/reminders.stub');

		return str_replace('password_reminders', $this->getTable(), $stub);
	}
1272527
public CmsUploadProgessInfo getInfo() {

        if (m_finished) {
            return new CmsUploadProgessInfo(
                getItem(),
                (int)getPercent(),
                UPLOAD_STATE.finished,
                getContentLength(),
                getBytesRead());
        }
        return new CmsUploadProgessInfo(
            getItem(),
            (int)getPercent(),
            UPLOAD_STATE.running,
            getContentLength(),
            getBytesRead());
    }
1240505
private function get_resource_link() {
        // Get activity context only for backups.
        if ($this->backuprec->type == 'activity' && $this->type == 'backup') {
            $context = context_module::instance($this->backuprec->itemid);
        } else { // Course or Section which have the same context getter.
            $context = context_course::instance($this->backuprec->itemid);
        }

        // Generate link based on operation type.
        if ($this->type == 'backup') {
            // For backups simply generate link to restore file area UI.
            $url = new moodle_url('/backup/restorefile.php', array('contextid' => $context->id));
        } else {
            // For restore generate link to the item itself.
            $url = $context->get_url();
        }

        return $url;
    }
1276127
protected function define_structure() {

        // To know if we are including userinfo
        $userinfo = $this->get_setting_value('userinfo');

        // Define the elements

        $areas = new backup_nested_element('areas');

        $area = new backup_nested_element('area', array('id'), array(
            'areaname', 'activemethod'));

        $definitions = new backup_nested_element('definitions');

        $definition = new backup_nested_element('definition', array('id'), array(
            'method', 'name', 'description', 'descriptionformat', 'status',
            'timecreated', 'timemodified', 'options'));

        $instances = new backup_nested_element('instances');

        $instance = new backup_nested_element('instance', array('id'), array(
            'raterid', 'itemid', 'rawgrade', 'status', 'feedback',
            'feedbackformat', 'timemodified'));

        // Build the tree including the method specific structures
        // (beware - the order of how gradingform plugins structures are attached is important)
        $areas->add_child($area);
        // attach local plugin stucture to $area element, multiple allowed
        $this->add_plugin_structure('local', $area, true);
        $area->add_child($definitions);
        $definitions->add_child($definition);
        $this->add_plugin_structure('gradingform', $definition, true);
        // attach local plugin stucture to $definition element, multiple allowed
        $this->add_plugin_structure('local', $definition, true);
        $definition->add_child($instances);
        $instances->add_child($instance);
        $this->add_plugin_structure('gradingform', $instance, false);
        // attach local plugin stucture to $instance element, multiple allowed
        $this->add_plugin_structure('local', $instance, true);

        // Define data sources

        $area->set_source_table('grading_areas', array('contextid' => backup::VAR_CONTEXTID,
            'component' => array('sqlparam' => 'mod_'.$this->get_task()->get_modulename())));

        $definition->set_source_table('grading_definitions', array('areaid' => backup::VAR_PARENTID));

        if ($userinfo) {
            $instance->set_source_table('grading_instances', array('definitionid' => backup::VAR_PARENTID));
        }

        // Annotate references
        $definition->annotate_files('grading', 'description', 'id');
        $instance->annotate_ids('user', 'raterid');

        // Return the root element
        return $areas;
    }
1037069
protected function define_assignment_subplugin_structure() {

        return false; // This subplugin restore is only one example. Skip it.

        $paths = array();

        $elename = $this->get_namefor('config');
        $elepath = $this->get_pathfor('/config'); // because we used get_recommended_name() in backup this works
        $paths[] = new restore_path_element($elename, $elepath);

        return $paths; // And we return the interesting paths
    }
693008
public function getPreferencesPane()
    {
        parent::getPreferencesPane();
        $group = new XMLElement('fieldset');
        $group->setAttribute('class', 'settings condensed pickable');
        $group->setAttribute('id', 'smtp');
        $group->appendChild(new XMLElement('legend', __('Email: SMTP')));

        $div = new XMLElement('div');

        $readonly = array('readonly' => 'readonly');

        $label = Widget::Label(__('HELO Hostname'));
        $label->appendChild(Widget::Input('settings[email_smtp][helo_hostname]', General::sanitize($this->_helo_hostname), 'text', $readonly));
        $div->appendChild($label);

        $group->appendChild($div);
        $group->appendChild(new XMLElement('p', __('A fully qualified domain name (FQDN) of your server, e.g. "www.example.com". If left empty, Symphony will attempt to find an IP address for the EHLO/HELO greeting.'), array('class' => 'help')));

        $div = new XMLElement('div');
        $div->setAttribute('class', 'two columns');

        $label = Widget::Label(__('From Name'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_smtp][from_name]', General::sanitize($this->_sender_name), 'text', $readonly));
        $div->appendChild($label);

        $label = Widget::Label(__('From Email Address'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_smtp][from_address]', General::sanitize($this->_sender_email_address), 'text', $readonly));
        $div->appendChild($label);

        $group->appendChild($div);

        $div = new XMLElement('div');
        $div->setAttribute('class', 'two columns');

        $label = Widget::Label(__('Host'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_smtp][host]', General::sanitize($this->_host), 'text', $readonly));
        $div->appendChild($label);

        $label = Widget::Label(__('Port'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_smtp][port]', General::sanitize((string) $this->_port), 'text', $readonly));
        $div->appendChild($label);
        $group->appendChild($div);

        $label = Widget::Label();
        $label->setAttribute('class', 'column');
        // To fix the issue with checkboxes that do not send a value when unchecked.
        $options = array(
            array('no',$this->_secure == 'no', __('No encryption')),
            array('ssl',$this->_secure == 'ssl', __('SSL encryption')),
            array('tls',$this->_secure == 'tls', __('TLS encryption')),
        );
        $select = Widget::Select('settings[email_smtp][secure]', $options, $readonly);
        $label->appendChild($select);
        $group->appendChild($label);

        $group->appendChild(new XMLElement('p', __('For a secure connection, SSL and TLS are supported. Please check the manual of your email provider for more details.'), array('class' => 'help')));

        $label = Widget::Label();
        $label->setAttribute('class', 'column');
        // To fix the issue with checkboxes that do not send a value when unchecked.
        $group->appendChild(Widget::Input('settings[email_smtp][auth]', '0', 'hidden'));
        $input = Widget::Input('settings[email_smtp][auth]', '1', 'checkbox', $readonly);

        if ($this->_auth === true) {
            $input->setAttribute('checked', 'checked');
        }

        $label->setValue(__('%s Requires authentication', array($input->generate())));
        $group->appendChild($label);

        $group->appendChild(new XMLElement('p', __('Some SMTP connections require authentication. If that is the case, enter the username/password combination below.'), array('class' => 'help')));

        $div = new XMLElement('div');
        $div->setAttribute('class', 'two columns');

        $label = Widget::Label(__('Username'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_smtp][username]', General::sanitize($this->_user), 'text', array_merge($readonly, array('autocomplete' => 'off'))));
        $div->appendChild($label);

        $label = Widget::Label(__('Password'));
        $label->setAttribute('class', 'column');
        $label->appendChild(Widget::Input('settings[email_smtp][password]', General::sanitize($this->_pass), 'password', array_merge($readonly, array('autocomplete' => 'off'))));
        $div->appendChild($label);
        $group->appendChild($div);

        return $group;
    }