Populates the form somewhat intelligently
@param SS_HTTPRequest $request Any request
@param Member $member Any member
@param array $required Any validation messages
@return $this
194880
public function populateFromSources(SS_HTTPRequest $request = null, Member $member = null, array $required = null) {
		$dataPath = "FormInfo.{$this->FormName()}.data";
		if(isset($member)) {
			$this->loadDataFrom($member);
		}
		else if(isset($request)) {
			$this->loadDataFrom($request->postVars());
		}
		// Hacky again :(
		else if(Session::get($dataPath)) {
			$this->loadDataFrom(Session::get($dataPath));
		}
		else if($failover = $this->getSessionData()) {
			$this->loadDataFrom($failover);
		}
		if(!empty($required)) {
			$this->setRequiredFields($required);
		}
		return $this;
	}
182633
public function addMembers(array $members)
    {
        $members = array_map(function ($member) {
            return $member instanceof Model
                ? $member->getDn()
                : $member;
        }, $members);

        $mod = $this->newBatchModification(
            $this->schema->member(),
            LDAP_MODIFY_BATCH_ADD,
            $members
        );

        return $this->addModification($mod)->save();
    }
748565
public function setRequired($required)
    {
        $this->required = (boolean) $required;
        if ($this->isRequired()) {
            $this->setAttribute('required');
            return $this;
        }

        if ($this->getAttributes()->containsKey('required')) {
                $this->getAttributes()->remove('required');
        }
        return $this;
    }
354189
public function confirm(HTTPRequest $request)
    {
        if ($this->EmailType !== 'Confirmation' &&
            $this->EmailType !== 'Validation') {
            return $this->httpError(400, 'No confirmation required.');
        }

        $currentMember = Member::currentUser();
        $id = (int)$request->param('ID');
        $key = $request->getVar('key');

        if ($currentMember) {
            if ($currentMember->ID == $id) {
                return Security::permissionFailure($this, _t(
                    'MemberProfiles.ALREADYCONFIRMED',
                    'Your account is already confirmed.'
                ));
            }
            return Security::permissionFailure($this, _t(
                'MemberProfiles.CANNOTCONFIRMLOGGEDIN',
                'You cannot confirm account while you are logged in.'
            ));
        }

        if (!$id ||
            !$key) {
            return $this->httpError(404);
        }

        $confirmationTitle = $this->data()->dbObject('ConfirmationTitle');

        /**
         * @var Member|null $member
         */
        $member = DataObject::get_by_id(Member::class, $id);
        if (!$member) {
            return $this->invalidRequest('Member #'.$id.' does not exist.');
        }
        if (!$member->NeedsValidation) {
            // NOTE(Jake): 2018-05-03
            //
            // You might be hitting this if you set your MemberProfilePage to use
            // Email Setting 'Confirmation' rather than 'Validation' and you didn't
            // edit the original Email template to not include the copy about confirmation.
            //
            return $this->invalidRequest('Member #'.$id.' does not need validation.');
        }
        if (!$member->ValidationKey) {
            return $this->invalidRequest('Member #'.$id.' does not have a validation key.');
        }
        if ($member->ValidationKey !== $key) {
            return $this->invalidRequest('Validation key does not match.');
        }

        // Allow member to login
        $member->NeedsValidation = false;
        $member->ValidationKey = null;

        $validationResult = $member->validateCanLogin();
        if (!$validationResult->isValid()) {
            $this->getResponse()->setStatusCode(500);
            $validationMessages = $validationResult->getMessages();
            return [
                'Title'   => $confirmationTitle,
                'Content' => $validationMessages ? $validationMessages[0]['message'] : _t('MemberProfiles.ERRORCONFIRMATION', 'An unexpected error occurred.'),
            ];
        }
        $member->write();

        $this->extend('onConfirm', $member);

        if ($member->canLogin()) {
            Injector::inst()->get(IdentityStore::class)->logIn($member);
        } else {
            throw new Exception('Permission issue occurred. Was the "$member->validateCanLogin" check above this code block removed?');
        }

        return [
            'Title'   => $this->data()->dbObject('ConfirmationTitle'),
            'Content' => $this->data()->dbObject('ConfirmationContent')
        ];
    }
1070185
public function edit(SS_HTTPRequest $request)
    {
        // Check form field state
        if ($this->parent->isDisabled() || $this->parent->isReadonly()) {
            return $this->httpError(403);
        }

        // Check item permissions
        $item = $this->getItem();
        if (!$item) {
            return $this->httpError(404);
        }

        $memberID = Member::currentUserID();

        $res = false;
        try {
            // Owner can always delete
            if ($memberID && $item->OwnerID == $memberID) {
                $res = true;
            } else {
                $res = $item->canEditFrontend();
            }
        } catch (Exception $ex) {

        }

        if (!$res) {
            return $this->httpError(403);
        }

        Requirements::css(FRAMEWORK_DIR . '/css/UploadField.css');

        return $this->customise(array(
                'Form' => $this->EditForm()
            ))->renderWith($this->parent->getTemplateFileEdit());
    }
1177781
protected function form(Request $request, Member $member)
    {
        $countries = collect(countries())->map(function ($country, $code) {
            return [
                'id' => $code,
                'text' => $country['name'],
                'emoji' => $country['emoji'],
            ];
        })->values();

        $tags = app('rinvex.tags.tag')->pluck('name', 'id');
        $languages = collect(languages())->pluck('name', 'iso_639_1');
        $genders = ['male' => trans('cortex/auth::common.male'), 'female' => trans('cortex/auth::common.female')];
        $abilities = $request->user($this->getGuard())->getManagedAbilities();
        $roles = $request->user($this->getGuard())->getManagedRoles();

        return view('cortex/auth::managerarea.pages.member', compact('member', 'abilities', 'roles', 'countries', 'languages', 'genders', 'tags'));
    }
715715
protected function populateRequest (CAS_Request_RequestInterface $request)
    {
        if (empty($this->_contentType) && !empty($this->_body)) {
            throw new CAS_ProxiedService_Exception(
                "If you pass a POST body, you must specify a content type via "
                .get_class($this).'->setContentType($contentType).'
            );
        }

        $request->makePost();
        if (!empty($this->_body)) {
            $request->addHeader('Content-Type: '.$this->_contentType);
            $request->addHeader('Content-Length: '.strlen($this->_body));
            $request->setPostBody($this->_body);
        }
    }
208322
public function submitForm(array &$form, FormStateInterface $form_state) {
    $operations = [
      [
        [
          '\Drupal\openy_campaign\Controller\MembersController',
          'deleteAllMembersProcessBatch',
        ],
        [],
      ],
    ];
    $batch = [
      'title' => t('Deleting members'),
      'operations' => $operations,
      'finished' => [
        '\Drupal\openy_campaign\Controller\MembersController',
        'deleteAllMembersFinishBatch',
      ],
    ];
    batch_set($batch);
  }
29410
public function setRequired($required)
    {
        if (is_string($required)) {
            $this->_required = new PhingFile($required);
        } else {
            $this->_required = $required;
        }
    }
1005243
public function setmember($member) 
    {
        if (!$this->_isNumericArray($member)) {
            $member =  array ($member);    
        }
        $this->_fields['member']['FieldValue'] = $member;
        return $this;
    }
958491
public function remove( $member )
    {
        if( false !== $key = array_search( $member, $this->members, true ) ) {
            unset( $this->members[$key] );
        }
        return $this;
    }
133367
public function requireDefaultRecords()
    {
        parent::requireDefaultRecords();

        $ssLoginUserName = Environment::getEnv('SS_DEFAULT_ADMIN_USERNAME');
        if(!$ssLoginUserName){
            return;
        }

        // Check for default admin user by matching email
        $member = Member::get()->find(
            Member::config()->get('unique_identifier_field'),
            $ssLoginUserName
        );

        // If no member is found at this stage.
        // Find member ID 1
        if(!$member){
            $member = DataObject::get_by_id(Member::class, 1);
        }

        $firstName = 'Default Admin';

        // // If there isn't one then make it
        if(!$member){
            $member = ExternalLoginMember::create();
            $member->FirstName = $firstName;
            $member->Email = $ssLoginUserName;
            $member->write();
            DB::alteration_message("Created admin '$member->Email'", 'created');
        } else {
            if ($member->ClassName != $this->ClassName || $member->Email != $ssLoginUserName) {
                $member->ClassName = $this->ClassName;
                $member->FirstName = $firstName;
                $member->Surname = null;
                $member->Email = $ssLoginUserName;
                $member->TempIDHash = null;
                $member->TempIDExpired = null;
                $member->Password = null;
                $member->write();
                DB::alteration_message("Modified admin '$member->Email'", 'modified');
            }
        }

        // Find or create ADMIN group
        Group::singleton()->requireDefaultRecords();
        $adminGroup = Permission::get_groups_by_permission('ADMIN')->First();

        // Ensure this user is in the admin group
        if(!$member->inGroup($adminGroup)) {
            // Add member to group instead of adding group to member
            // This bypasses the privilege escallation code in Member_GroupSet
            $adminGroup->DirectMembers()->add($member);
        }
    }
999135
public function update(Request $request, $id)
    {
        /** @noinspection PhpUndefinedMethodInspection */
        $request->validate([
            "name" => "required|max:36",
            "description" => "required|max:128",
        ]);
        $memberCategory = MemberCategory::findOrFail($id);
        $this->authorize('update', $memberCategory);
        $memberCategory->name = $request->name;
        $memberCategory->description = $request->description;
        $memberCategory->update();
        return fractal($memberCategory, new MemberCategoryTransformer())
            ->withResourceName('memberCategory')
            ->respond();
    }
1075775
public function canEdit($member = null)
    {
        $extended = $this->extendedCan(__FUNCTION__, $member);
        
        if ($extended !== null) {
            return $extended;
        }

        if (!$member) {
            $member = Member::currentUser();
        }

        if ($member &&
            Permission::checkMember($member->ID, ["ADMIN", "ORDERS_EDIT_INVOICES"]) &&
            in_array($this->Status, $this->config()->editable_statuses)
        ) {
            return true;
        }

        return false;
    }
334858
public function sendverification(SS_HTTPRequest $request)
    {
        // If we don't allow verification emails, return an error
        if (!Users::config()->send_verification_email) {
            return $this->httpError(400);
        }

        $sent = false;

        if (Member::currentUserID()) {
            $member = Member::currentUser();
        } else {
            $member = Member::get()->byID($this->getRequest()->param("ID"));
        }

        if ($member && !$member->isVerified()) {
            $sent = $this->send_verification_email($member);
        }

        $this->customise(
            array(
            "Title" => _t('Users.AccountVerification', 'Account Verification'),
            "MetaTitle" => _t('Users.AccountVerification', 'Account Verification'),
            "Content" => $this->renderWith(
                "UsersSendVerificationContent",
                array("Sent" => $sent)
            ),
            "Sent" => $sent
            )
        );

        $this->extend("updateSendVerificationAction");

        return $this->renderWith(
            array(
            "Users_Register_sendverification",
            "Users",
            "Page"
            )
        );
    }
262373
public function uploadsnapshot(SS_HTTPRequest $request) {
		// Performs canView permission check by limiting visible projects
		$project = $this->getCurrentProject();
		if(!$project) {
			return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
		}

		if(!$project->canUploadArchive()) {
			return new SS_HTTPResponse("Not allowed to upload", 401);
		}

		return $this->customise(array(
			'Project' => $project,
			'CurrentProject' => $project,
			'SnapshotsSection' => 1,
			'UploadLimit' => $maxSize = File::format_size(min(
				File::ini2bytes(ini_get('upload_max_filesize')),
				File::ini2bytes(ini_get('post_max_size'))
			)),
			'UploadSnapshotForm' => $this->getUploadSnapshotForm($request),
			'PostSnapshotForm' => $this->getPostSnapshotForm($request)
		))->renderWith(array('DNRoot_uploadsnapshot', 'DNRoot'));
	}
669610
public function sIsMember($key, $member) {
        return $this->send(['sismember', $key, $member], function ($response) {
            return (bool) $response;
        });
    }