The context name column.

@param stdClass $expiredctx The row data.
@return string
@throws coding_exception
424488
public function col_name($expiredctx) {
        global $OUTPUT;
        $context = context_helper::instance_by_id($expiredctx->get('contextid'));
        $parent = $context->get_parent_context();
        $contextdata = (object)[
            'name' => $context->get_context_name(false, true),
            'parent' => $parent->get_context_name(false, true),
        ];
        $fullcontexts = $context->get_parent_contexts(true);
        $contextsinpath = [];
        foreach ($fullcontexts as $contextinpath) {
            $contextsinpath[] = $contextinpath->get_context_name(false, true);
        }
        $infoicon = new pix_icon('i/info', implode(' / ', array_reverse($contextsinpath)));
        $infoiconhtml = $OUTPUT->render($infoicon);
        $name = html_writer::span(get_string('nameandparent', 'tool_dataprivacy', $contextdata), 'mr-1');

        return  $name . $infoiconhtml;
    }
885007
public function getTemporaryIdTableName() : string
    {
        $schema = $this->getSchemaName() === null
            ? ''
            : $this->getSchemaName() . '_';

        // replace dots with underscores because PostgreSQL creates temporary tables in a special schema
        return $schema . $this->getTableName() . '_id_tmp';
    }
512256
public function get_context_name($withprefix = true, $short = false) {
        global $DB;

        $name = '';
        if ($this->_instanceid == SITEID) {
            $name = get_string('frontpage', 'admin');
        } else {
            if ($course = $DB->get_record('course', array('id'=>$this->_instanceid))) {
                if ($withprefix){
                    $name = get_string('course').': ';
                }
                if ($short){
                    $name .= format_string($course->shortname, true, array('context' => $this));
                } else {
                    $name .= format_string(get_course_display_name_for_list($course));
               }
            }
        }
        return $name;
    }
907174
public function getMethodId($context_self = null)
    {
        if ($this->function instanceof ClassMethod) {
            $function_name = (string)$this->function->name;

            return ($context_self ?: $this->source->getFQCLN()) . '::' . strtolower($function_name);
        }

        if ($this->function instanceof Function_) {
            $namespace = $this->source->getNamespace();

            return ($namespace ? strtolower($namespace) . '\\' : '') . strtolower($this->function->name->name);
        }

        return $this->getFilePath()
            . ':' . $this->function->getLine()
            . ':' . (int)$this->function->getAttribute('startFilePos')
            . ':-:closure';
    }
1278821
public function getContext()
    {
        $context = [
            'log_cmd_insert'    => [$this, 'onInsert'],
            'log_cmd_delete'    => [$this, 'onDelete'],
            'log_cmd_update'    => [$this, 'onUpdate'],
            'log_insert'        => [$this, 'onInsert'],
            'log_delete'        => [$this, 'onDelete'],
            'log_update'        => [$this, 'onUpdate'],
            'log_batchinsert'   => [$this, 'onBatchInsert'],
            'log_write_batch'   => [$this, 'onBatchInsert'],
            'log_query'         => [$this, 'onQuery']
        ];
        return $context;
    }
629489
public function getSelectedContextAttribute()
    {
        if (isset($this->context)) {
            return $this->context;
        }
        switch ($this->selected_context_type) {
            case 'Member':
                return $this->context = new MemberContext($this);
            default:
                abort(401, 'Context not selected.');
        }
    }
875293
def context(self):
        """"""

        # Can't use self.columns b/c of recursion with resolved_url

        t = self.schema_term

        if not t:
            return {}

        sql_columns = []
        all_columns = []

        for i, c in enumerate(t.children):
            if c.term_is("Table.Column"):
                p = c.all_props

                if p.get('sqlselect'): # has a value for SqlSqlect
                    sql_columns.append(p.get('sqlselect'))

                all_columns.append(c.name)

        return {
            'SQL_COLUMNS': ', '.join(sql_columns),
            'ALL_COLUMNS': ', '.join(all_columns)
        }
918436
public function get_course_name(\context $context) {
        $courseid = $this->courseid;
        if (empty($courseid)) {
            return get_string('site');
        } else {
            try {
                $course = get_course($courseid);
                return format_string($course->fullname, true, array('context' => $context));
            } catch (\dml_exception $e) {
                return '-';
            }
        }
    }
404171
public function getDbName()
    {
        $indexes = DataObject::getSchema()->databaseIndexes($this->model);
        if (array_key_exists($this->getName(), $indexes)) {
            $index = $indexes[$this->getName()];
        } else {
            return parent::getDbName();
        }
        if (is_array($index) && array_key_exists('columns', $index)) {
            return $this->prepareColumns($index['columns']);
        } else {
            throw new Exception(sprintf(
                "Invalid fulltext index format for '%s' on '%s'",
                var_export($this->getName(), true),
                var_export($this->model, true)
            ));
        }
    }
821671
public function get_context_name($withprefix = true, $short = false) {
        global $DB;

        $name = '';
        if ($user = $DB->get_record('user', array('id'=>$this->_instanceid, 'deleted'=>0))) {
            if ($withprefix){
                $name = get_string('user').': ';
            }
            $name .= fullname($user);
        }
        return $name;
    }
1185976
public function getCorrectlyCasedMethodId($context_self = null)
    {
        if ($this->function instanceof ClassMethod) {
            $function_name = (string)$this->function->name;

            return ($context_self ?: $this->source->getFQCLN()) . '::' . $function_name;
        }

        if ($this->function instanceof Function_) {
            $namespace = $this->source->getNamespace();

            return ($namespace ? $namespace . '\\' : '') . $this->function->name;
        }

        return $this->getMethodId();
    }
401718
protected function get_role_users_for_expired_context(expired_context $expiredctx, \context $context) : \stdClass {
        $expiredroles = $expiredctx->get('expiredroles');
        $expiredroleusers = [];
        if (!empty($expiredroles)) {
            // Find the list of expired role users.
            $expiredroleuserassignments = get_role_users($expiredroles, $context, true, 'ra.id, u.id AS userid', 'ra.id');
            $expiredroleusers = array_map(function($assignment) {
                return $assignment->userid;
            }, $expiredroleuserassignments);
        }
        $expiredroleusers = array_unique($expiredroleusers);

        $unexpiredroles = $expiredctx->get('unexpiredroles');
        $unexpiredroleusers = [];
        if (!empty($unexpiredroles)) {
            // Find the list of unexpired role users.
            $unexpiredroleuserassignments = get_role_users($unexpiredroles, $context, true, 'ra.id, u.id AS userid', 'ra.id');
            $unexpiredroleusers = array_map(function($assignment) {
                return $assignment->userid;
            }, $unexpiredroleuserassignments);
        }
        $unexpiredroleusers = array_unique($unexpiredroleusers);

        if (!$expiredctx->get('defaultexpired')) {
            $tofilter = get_users_roles($context, $expiredroleusers);
            $tofilter = array_filter($tofilter, function($userroles) use ($expiredroles) {
                // Each iteration contains the list of role assignment for a specific user.
                // All roles that the user holds must match those in the list of expired roles.
                foreach ($userroles as $ra) {
                    if (false === array_search($ra->roleid, $expiredroles)) {
                        // This role was not found in the list of assignments.
                        return true;
                    }
                }

                return false;
            });
            $unexpiredroleusers = array_merge($unexpiredroleusers, array_keys($tofilter));
        }

        return (object) [
            'expired' => $expiredroleusers,
            'unexpired' => $unexpiredroleusers,
        ];
    }
52418
public function getCardholderName($orderIndex = 0)
    {
        $cardAuthInfo = $this->getCardAuthInfo($orderIndex);
        return array_key_exists('cardholderName', $cardAuthInfo) ? $cardAuthInfo['cardholderName'] : null;
    }
1120129
protected function get_column_type($columnname) {
        if (! class_exists($columnname)) {
            if (class_exists('core_question\\bank\\' . $columnname)) {
                $columnname = 'core_question\\bank\\' . $columnname;
            } else {
                throw new \coding_exception("No such class exists: $columnname");
            }
        }
        if (empty($this->requiredcolumns[$columnname])) {
            $this->requiredcolumns[$columnname] = new $columnname($this);
        }
        return $this->requiredcolumns[$columnname];
    }
1321164
public function getName(): string
    {
        if (!empty($this->name)) {
            return $this->name;
        }

        $name = ($this->isUnique() ? 'unique_' : 'index_') . join('_', $this->getColumns());

        return strlen($name) > 64 ? md5($name) : $name;
    }
868821
public function get_name() {
        // Grade scales can be created at site or course context, so set the filter context appropriately.
        $context = empty($this->courseid) ? context_system::instance() : context_course::instance($this->courseid);
        return format_string($this->name, false, ['context' => $context]);
    }
938062
public function flag_expired_contexts() : array {
        $this->trace->output('Checking requirements');
        if (!$this->check_requirements()) {
            $this->trace->output('Requirements not met. Cannot process expired retentions.', 1);
            return [0, 0];
        }

        // Clear old and stale records first.
        $this->trace->output('Clearing obselete records.', 0);
        static::clear_old_records();
        $this->trace->output('Done.', 1);

        $this->trace->output('Calculating potential course expiries.', 0);
        $data = static::get_nested_expiry_info_for_courses();

        $coursecount = 0;
        $this->trace->output('Updating course expiry data.', 0);
        foreach ($data as $expiryrecord) {
            if ($this->update_from_expiry_info($expiryrecord)) {
                $coursecount++;
            }
        }
        $this->trace->output('Done.', 1);

        $this->trace->output('Calculating potential user expiries.', 0);
        $data = static::get_nested_expiry_info_for_user();

        $usercount = 0;
        $this->trace->output('Updating user expiry data.', 0);
        foreach ($data as $expiryrecord) {
            if ($this->update_from_expiry_info($expiryrecord)) {
                $usercount++;
            }
        }
        $this->trace->output('Done.', 1);

        return [$coursecount, $usercount];
    }