Builds an array with the member information
@param Member $member An optional member to use. If null, will use the current logged in member
@return array
18535
public function getMemberFields(Member $member = null)
    {
        if (!$member) {
            $member = Security::getCurrentUser();
        }
        $result = array();

        if ($member) {
            foreach ($member->summaryFields() as $field => $title) {
                $result[$field] = $member->$field;
            }
        }

        if ($member && !array_key_exists('Name', $result)) {
            $result['Name'] = $member->getName();
        }

        return $result;
    }
14752
public function updateMemberGroups($data, Member $member)
    {
        if (isset($data['memberof'])) {
            $ldapGroups = is_array($data['memberof']) ? $data['memberof'] : [$data['memberof']];
            foreach ($ldapGroups as $groupDN) {
                foreach (LDAPGroupMapping::get() as $mapping) {
                    if (!$mapping->DN) {
                        $this->getLogger()->debug(
                            sprintf(
                                'LDAPGroupMapping ID %s is missing DN field. Skipping',
                                $mapping->ID
                            )
                        );
                        continue;
                    }

                    // the user is a direct member of group with a mapping, add them to the SS group.
                    if ($mapping->DN == $groupDN) {
                        $group = $mapping->Group();
                        if ($group && $group->exists()) {
                            $group->Members()->add($member, [
                                'IsImportedFromLDAP' => '1'
                            ]);
                            $mappedGroupIDs[] = $mapping->GroupID;
                        }
                    }

                    // the user *might* be a member of a nested group provided the scope of the mapping
                    // is to include the entire subtree. Check all those mappings and find the LDAP child groups
                    // to see if they are a member of one of those. If they are, add them to the SS group
                    if ($mapping->Scope == 'Subtree') {
                        $childGroups = $this->getNestedGroups($mapping->DN, ['dn']);
                        if (!$childGroups) {
                            continue;
                        }

                        foreach ($childGroups as $childGroupDN => $childGroupRecord) {
                            if ($childGroupDN == $groupDN) {
                                $group = $mapping->Group();
                                if ($group && $group->exists()) {
                                    $group->Members()->add($member, [
                                        'IsImportedFromLDAP' => '1'
                                    ]);
                                    $mappedGroupIDs[] = $mapping->GroupID;
                                }
                            }
                        }
                    }
                }
            }
        }

        // Lookup the previous mappings and see if there is any mappings no longer present.
        $unmappedGroups = $member->Groups()->alterDataQuery(function (DataQuery $query) {
            // join with the Group_Members table because we only want those group members assigned by this module.
            $query->leftJoin("Group_Members", '"Group_Members"."GroupID" = "Group"."ID"');
            $query->where('"Group_Members"."IsImportedFromLDAP" = 1');
        });

        // Don't remove associations which have just been added and we know are already correct!
        if (!empty($mappedGroupIDs)) {
            $unmappedGroups = $unmappedGroups->filter("GroupID:NOT", $mappedGroupIDs);
        }

        // Remove the member from any previously mapped groups, where the mapping
        // has since been removed in the LDAP data source
        if ($unmappedGroups->count()) {
            foreach ($unmappedGroups as $group) {
                $group->Members()->remove($member);
            }
        }
    }
1264099
public function merge(NestedMember $member) : NestedMember
    {
        $parts = $this->parts;

        $isNullable = $this->getResultingType()->isNullable();
        foreach ($member->getParts() as $part) {
            $parts[] = $isNullable ? $part->asNullable() : $part;
        }

        return new self($parts);
    }
917269
public function add($member)
    {
        if (is_array($member)) {
            foreach ($member as $item) {
                $this->add($item);
            }

            return $this;
        }

        if (!is_callable($member)) {
            throw new InvalidChainMember();
        }

        $this->members[] = $member;

        return $this;
    }
494554
public function hasStaticMember($member)
    {
        if (is_string($this->$member)) {
            $tokens = token_get_all('<?php '.$this->$member);

            return
                count($tokens) === 2 &&
                is_array($tokens[1]) &&
                in_array($tokens[1][0], [T_CONSTANT_ENCAPSED_STRING, T_DNUMBER, T_LNUMBER]);
        }

        return false;
    }
1041417
public function can($perm, $member = null)
    {
        if (!$member) {
            $member = Security::getCurrentUser();
        }
        if (is_array($perm)) {
            $perm = array_map(array($this, 'can'), $perm, array_fill(0, count($perm), $member));
            return min($perm);
        }
        if ($this->hasMethod($methodName = 'can' . $perm)) {
            return $this->$methodName($member);
        } else {
            return true;
        }
    }
646093
private function getMembershipTypeName(\stdClass $membership_type) {
    $map = [
      [
        'needle' => '*Program Member',
        'replace' => 'Program Member',
      ],
      [
        'needle' => '1 Adult (30-64)',
        'replace' => '1 Adult',
      ],
      [
        'needle' => '1 Adult with Kids',
        'replace' => '1 Adult with Kids',
      ],
      [
        'needle' => '2 Adults (30-64)',
        'replace' => '2 Adults',
      ],
      [
        'needle' => '2 Adults with Kids',
        'replace' => '2 Adults with Kids',
      ],
      [
        'needle' => 'College Student',
        'replace' => 'College Student',
      ],
      [
        'needle' => 'Complimentary',
        'replace' => 'Complimentary',
      ],
      [
        'needle' => 'Military Adult',
        'replace' => 'Military Adult',
      ],
      [
        'needle' => 'Military Family',
        'replace' => 'Military Family',
      ],
      [
        'needle' => 'Senior 1 Adult',
        'replace' => '1 Senior',
      ],
      [
        'needle' => 'Senior 2 Adults',
        'replace' => '2 Seniors',
      ],
      [
        'needle' => 'Student',
        'replace' => 'Student',
      ],
      [
        'needle' => 'Young Adult',
        'replace' => 'Young Adult',
      ],
    ];

    foreach ($map as $item) {
      if (strpos($membership_type->name, $item['needle']) !== FALSE) {
        return $item['replace'];
      }
    }

    throw new \Exception(sprintf('Failed to get membership type name for type "%s"', $membership_type->name));
  }
1035464
public function canView($member = null)
    {
        if (!$member && $member !== false) {
            $member = Security::getCurrentUser();
        }

        if (!parent::canView($member)) {
            return false;
        }

        foreach ($this->Reports() as $report) {
            if ($report->canView($member)) {
                return true;
            }
        }

        return false;
    }
1063211
public function getAssignedMembers()
    {
        $members = ArrayList::create($this->Users()->toArray());
        $groups  = $this->Groups();

        foreach ($groups as $group) {
            $members->merge($group->Members());
        }

        $members->removeDuplicates();
        return $members;
    }
760815
public function getMembershipTypes() {
    $types = [];
    $membership_ids = $this->queryFactory->get('node')
      ->condition('type', 'membership')
      ->condition('status', 1)
      ->execute();

    if (!$membership_ids) {
      return $types;
    }

    $storage = $this->entityTypeManager->getStorage('node');
    $builder = $this->entityTypeManager->getViewBuilder('node');
    $memberships = $storage->loadMultiple($membership_ids);

    foreach ($memberships as $membership) {
      $membership_id = $membership->id();
      $types[$membership_id] = [
        'title' => $membership->title->value,
        'description' => $builder->view($membership, 'calc_preview'),
      ];
    }

    return $types;
  }
524257
public function RoleOf($member = null)
    {
        $member = $this->getMember($member);

        if (!$member) {
            return null;
        }

        if ($this->isAuthor($member)) {
            return _t(__CLASS__ . '.AUTHOR', 'Author');
        }

        $parent = $this->Parent();

        if ($parent instanceof Blog) {
            return $parent->RoleOf($member);
        }

        return null;
    }
770626
public function SpamLink($member = null)
    {
        if ($this->canEdit($member) && !$this->IsSpam) {
            return $this->actionLink('spam', $member);
        }
    }
549449
public function getMembershipTypes() {
    $types = [];

    foreach ($this->getMembershipPriceMatrix() as $membership_type) {
      $types[$membership_type['id']] = [
        'title' => $membership_type['title'],
        'description' => $membership_type['description'],
      ];
    }

    return $types;
  }
647878
public static function indexArrayOfObjectsByMember($member, $objects) {

        $returnValues = array();

        foreach ($objects as $object) {
            if ($object instanceof SerialisableObject) {
                $returnValues[$object->__getSerialisablePropertyValue($member)] = $object;
            } else {
                throw new ClassNotSerialisableException(get_class($object));
            }
        }

        return $returnValues;

    }
1008343
public function zRem($key, $member, ...$members) {
        return $this->send(array_merge(['zrem', $key], (array) $member, $members));
    }
833688
public function canView($member = null)
    {
        $extended = $this->extendedCan(__FUNCTION__, $member);

        if ($extended !== null) {
            return $extended;
        }

        if ($this->Parent()) {
            return $this->Parent()->canView($member);
        }

        return parent::canView($member);
    }
1179813
public function getFkListDetails($member, $className, $list) {
		$element = $this->jquery->semantic ()->htmlList ( "list-" . $className . "." . $member );
		$element->setMaxVisible ( 15 );

		return $element->addClass ( "animated divided celled" );
	}