Returns parent context ids of this context in reversed order, i.e. parent first,
then grand parent, etc.

@param bool $includeself true means include self too
@return array of context ids
494109
public function get_parent_context_ids($includeself = false) {
        if (empty($this->_path)) {
            return array();
        }

        $parentcontexts = trim($this->_path, '/'); // kill leading slash
        $parentcontexts = explode('/', $parentcontexts);
        if (!$includeself) {
            array_pop($parentcontexts); // and remove its own id
        }

        return array_reverse($parentcontexts);
    }
322976
public function createQueryBuilderWithParentRoot($parent_id, $include_parent = true)
    {
        $query = $this->createQueryBuilder();
        return $this->alterQueryBuilderWithParentRoot($query, $parent_id, $include_parent);
    }
1016866
public function parents(): array
    {
        if (!$this->_parent) {
            return array();
        }
        $nodes = $this->_parent->parents();
        $nodes[] = $this->_parent;
        return array_reverse($nodes);
    }
859952
public function ChildrenOf($parentRef)
    {
        $parent = SiteTree::get_by_link($parentRef);

        if (!$parent && is_numeric($parentRef)) {
            $parent = DataObject::get_by_id(SiteTree::class, $parentRef);
        }

        if ($parent) {
            return $parent->Children();
        }
        return null;
    }
836575
function( includeSelf, ignoreTextNode ) {
			var start = this.startContainer,
				end = this.endContainer,
				ancestor;

			if ( start.equals( end ) ) {
				if ( includeSelf && start.type == CKEDITOR.NODE_ELEMENT && this.startOffset == this.endOffset - 1 )
					ancestor = start.getChild( this.startOffset );
				else
					ancestor = start;
			} else {
				ancestor = start.getCommonAncestor( end );
			}

			return ignoreTextNode && !ancestor.is ? ancestor.getParent() : ancestor;
		}
1084720
protected function useParentMethodAndExternals($method, $parameters, $includeExternals = false, $returnOne = false)
    {
        $result = call_user_func_array([
            $this,
            sprintf('parent::%s', $method),
        ], $parameters);
        if ($includeExternals === true && (($returnOne === true && $result === null) || $returnOne === false)) {
            $result = $this->useExternalSchemas($method, $parameters, $result, $returnOne);
        }
        return $result;
    }
703110
public static function getAncestors($source,$idField,$pidField,$fieldValue,$includeSelf=true)
    {
        $returnValue=[];
        $current=null;
        foreach($source as $row){
            $idValue=Convert::getFieldValue($row, $idField,true);
            if($idValue==$fieldValue){
                $current=$row;
                if($includeSelf){
                    $returnValue[]=$current;
                }
                break;
            }
        }
        $pidValue=Convert::getFieldValue($current, $pidField,true);
        while($pidValue){
            $current=self::_getAncestors($source,$idField,$pidValue);
            if(!empty($current)){
                $returnValue[]=$current;
                $pidValue=Convert::getFieldValue($current, $pidField,true);
            }else{
                break;
            }
        }

        //echo $returnValue[1][$idField];
        return array_reverse($returnValue);
    }
1076316
protected function get_parent_context() : \context {
        global $PAGE;
        if ($this->parentcontext) {
            return $this->parentcontext;
        } else if ($PAGE->context && $PAGE->context instanceof \context_coursecat) {
            return $PAGE->context;
        }
        return \context_system::instance();
    }
1199157
public function getJointParent($model, $includeSelf = false)
    {
        if ( is_numeric($model) ) {
            $model = call_user_func("$this->ownerClassName::findOne", $model);
        }
        if ( $this->owner->{$this->parentIdField} == $model->{$this->parentIdField} ) {
            return $this->getParent();
        }
        $ownerParents = $this->owner->getParents($includeSelf)->all();
        $modelParents = $model->getParents($includeSelf)->all();
        $jointParent = false;
        foreach ( $ownerParents as $idx => $parent ) {
            if ( isset($modelParents[$idx]) && $parent->{$this->primaryKey} == $modelParents[$idx]->{$this->primaryKey} ) {
                $jointParent = $parent;
            } else {
                break;
            }
        }
        return $jointParent;
    }
267560
public function get_child_contexts() {
        global $DB;

        debugging('Fetching of system context child courses is strongly discouraged on production servers (it may eat all available memory)!');

        // Just get all the contexts except for CONTEXT_SYSTEM level
        // and hope we don't OOM in the process - don't cache
        $sql = "SELECT c.*
                  FROM {context} c
                 WHERE contextlevel > ".CONTEXT_SYSTEM;
        $records = $DB->get_records_sql($sql);

        $result = array();
        foreach ($records as $record) {
            $result[$record->id] = context::create_instance_from_record($record);
        }

        return $result;
    }
1050440
public function getTree($includeSelf = true, $includeParents = false)
    {
        return call_user_func("$this->ownerClassName::find")
            ->where([
                $this->primaryKey => $this->getTreeIds($includeSelf, $includeParents),
            ])
            ->orderBy([
                "$this->tableName.$this->parentIdField" => SORT_ASC,
                "$this->tableName.$this->sortField" => SORT_ASC,
                "$this->tableName.$this->primaryKey" => SORT_ASC,
            ]);
    }
489462
public function getAllAsSelectList($includeNull = false)
    {
        $models = $this->repository->all();

        return $this->convertToSelectList($includeNull, $models);
    }
258421
private static function base_options($includenotset = true, $includeinherit = true) {

        $options = [];

        if ($includenotset) {
            $options[\tool_dataprivacy\context_instance::NOTSET] = get_string('notset', 'tool_dataprivacy');
        }

        if ($includeinherit) {
            $options[\tool_dataprivacy\context_instance::INHERIT] = get_string('inherit', 'tool_dataprivacy');
        }

        return $options;
    }
193399
protected function getIncluded(ElementInterface $element, $includeParent = false)
    {
        $included = [];

        foreach ($element->getResources() as $resource) {
            if ($resource->isIdentifier()) {
                continue;
            }

            if ($includeParent) {
                $included = $this->mergeResource($included, $resource);
            } else {
                $type = $resource->getType();
                $id = $resource->getId();
            }

            foreach ($resource->getUnfilteredRelationships() as $relationship) {
                $includedElement = $relationship->getData();

                if (! $includedElement instanceof ElementInterface) {
                    continue;
                }

                foreach ($this->getIncluded($includedElement, true) as $child) {
                    // If this resource is the same as the top-level "data"
                    // resource, then we don't want it to show up again in the
                    // "included" array.
                    if (! $includeParent && $child->getType() === $type && $child->getId() === $id) {
                        continue;
                    }

                    $included = $this->mergeResource($included, $child);
                }
            }
        }

        $flattened = [];

        array_walk_recursive($included, function ($a) use (&$flattened) {
            $flattened[] = $a;
        });

        return $flattened;
    }
168472
public static function getStringOperands($includeSelector = false)
    {
        $values = array(
            self::STRING_STARTS,
            self::STRING_ENDS,
            self::STRING_EQUALS,
            self::STRING_CONTAINS,
        );

        if ($includeSelector) {
            $values[] = self::OPERAND_SELECTOR;
        }

        return $values;
    }
1344361
public static function parentID($menuLinkID)
    {
        $parentIDs = [];
        while($menuLinkID != null){
            $parentObj = MenuLink::all()->where('menuLinkID', $menuLinkID)->first();
            if ($parentObj) {
                $menuLinkID = $parentObj->parent;
                if ($menuLinkID) {
                    $parentIDs[] = $menuLinkID;
                }
            }
            if ($parentObj || !$menuLinkID) {
                $menuLinkID = null;
            }
        }
        return $parentIDs;
    }
1298499
public function getListDepartments($includeBlock = true) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.value',
		];
		$conditions = [];
		$blockExists = $this->hasField('block');
		if (!$includeBlock && $blockExists) {
			$conditions[$this->alias . '.block'] = false;
		}
		$order = [$this->alias . '.value' => 'asc'];
		$this->recursive = -1;

		return $this->find('list', compact('fields', 'conditions', 'order'));
	}