Generates the fields array for the message attachment.

@param  Vulnerabilities $vulnerabilities List of vulnerabilities.

@return array
6790
protected function build_attachment_fields( Vulnerabilities $vulnerabilities ) {
		$fields = [];

		foreach ( $vulnerabilities as $vulnerability ) {
			$fixed_in = $vulnerability->fixed_in
				? 'Fixed in v' . $vulnerability->fixed_in
				: 'Not fixed yet';
			$wpvdb_url = "https://wpvulndb.com/vulnerabilities/{$vulnerability->id}";

			$fields[] = [
				'title' => $vulnerability->title,
				'value' => "{$fixed_in} - <{$wpvdb_url}|More info>",
			];
		}

		return $fields;
	}
109685
protected function getEmailRecipientRequiredFields()
    {
        $requiredFields = [];
        $recipientFieldsMap = [
            'EmailAddress' => 'SendEmailToField',
            'EmailSubject' => 'SendEmailSubjectField',
            'EmailReplyTo' => 'SendEmailFromField'
        ];

        foreach ($this->getController()->data()->EmailRecipients() as $recipient) {
            foreach ($recipientFieldsMap as $textField => $dynamicFormField) {
                if (empty($recipient->$textField) && $recipient->getComponent($dynamicFormField)->exists()) {
                    $requiredFields[] = $recipient->getComponent($dynamicFormField)->Name;
                }
            }
        }

        return $requiredFields;
    }
869446
public function attachmentMessages()
    {
        $result = [];
        foreach ($this->entries as $entry) {
            foreach ($entry->messages as $entryMessage) {
                if ($entryMessage->isMessage) {
                    if ($entryMessage->message->hasAttachments) {
                        $result[] = $entryMessage->message;
                    }
                }
            }
        }
        return collect($result);
    }
211436
public function fliterFields($fields = null){

        if (is_string($fields)){ // Comma Seperated List (eg Url Param)
            $fields = explode(',', $fields);
        }

        if(empty($fields)){
            $this->hidden = [];
        } else {
            $this->hidden = ['id','parent_id','left','right','depth','name','alternames','country','level','population','lat','long'];
            foreach ($fields as $field) {
                $index = array_search($field, $this->hidden);
                if($index !== false){
                    unset($this->hidden[$index]);
                }
            };
            $this->hidden = array_values($this->hidden);
        }

        return $this;
    }
797447
public function buildEntityFields($fields)
    {
        $aliases = [];
        $dottedFields = [];

        if (!$this->isArray($fields)) {
            $cacheKey = $fields;
            if (array_key_exists($cacheKey, self::$cache)) {
                return self::$cache[$cacheKey];
            }

            $fields = $this->str($fields);

            if ($fields->contains('[')) {
                $fields = $this->parseGroupedNestedFields($fields);
            }

            $fields = $fields->explode(',')->filter()->map('trim')->val();
        } else {
            $cacheKey = serialize($fields);
            if (array_key_exists($cacheKey, self::$cache)) {
                return self::$cache[$cacheKey];
            }

            // Check if asterisk is present and replace it with actual attribute names
            if ($this->arr($fields)->keyExists('*')) {
                unset($fields['*']);
                $defaultFields = $this->str($this->getDefaultAttributes())->explode(',')->filter()->map('trim')->flip()->val();
                $fields = $this->arr($fields)->merge($defaultFields)->val();
            }

            return self::$cache[$cacheKey] = [
                'fields'       => $fields,
                'aliases'      => $aliases,
                'dottedFields' => $dottedFields
            ];
        }

        $parsedFields = $this->arr(['id' => true]);
        $unsetFields = [];

        foreach ($fields as $f) {
            $f = $this->str($f);

            if ($f->contains('@')) {
                list($f, $alias) = $f->explode('@')->val();
                $aliases[$f] = $alias;
                $f = $this->str($f);
            }

            $dottedFields[] = $f->val();

            if ($f->startsWith('!')) {
                $unsetFields[] = $f->trimLeft('!')->val();
                continue;
            }

            if ($f->val() == '*') {
                $defaultFields = $this->str($this->getDefaultAttributes())->explode(',')->filter()->map('trim')->val();
                foreach ($defaultFields as $df) {
                    $this->buildFields($parsedFields, $this->str($df));
                }
                continue;
            }
            $this->buildFields($parsedFields, $f);
        }

        foreach ($unsetFields as $field) {
            $parsedFields->removeKey($field);
        }

        return self::$cache[$cacheKey] = [
            'fields'       => $parsedFields->val(),
            'aliases'      => $aliases,
            'dottedFields' => $dottedFields
        ];
    }
362598
protected function getRespondentMailfields()
    {
        if ($this->respondent) {
            $result = array();
            $result['bcc']          = $this->mailFields['project_bcc'];
            $result['email']        = $this->respondent->getEmailAddress();
            $result['from']         = '';
            $result['first_name']   = $this->respondent->getFirstName();
            $result['full_name']    = $this->respondent->getFullName();
            $result['greeting']     = $this->respondent->getGreeting();
            $result['last_name']    = $this->respondent->getLastName();
            $result['name']         = $this->respondent->getName();
        } else {
            $result = array(
                'email'     => '',
                'from'      => '',
                'first_name'=> '',
                'full_name' => '',
                'greeting'  => '',
                'last_name' => '',
                'name'      => ''
            );
        }

        $result['reply_to']       = $result['from'];
        $result['to']             = $result['email'];
        $result['reset_ask']      = '';
        if ($this->mailFields['organization_login_url']) {
            $result['reset_ask']      = $this->mailFields['organization_login_url'] . '/index/resetpassword';
        }
        return $result;
    }
575614
public function getAttachments($mail)
    {
        /** @noinspection IsEmptyFunctionUsageInspection */
        if(empty($mail->getId())) {
            return [];
        }
        
        $folderFileList = $this->getMailLocalFolderFileList($mail);

        $attachments = [];
        
        foreach ($folderFileList as $filePath => $fileMetaData) {

            $filePath = $fileMetaData['path'];

            /** @var \Shockwavemk\Mail\Base\Model\Mail\Attachment $attachment */
            $attachment = $this->_objectManager
                ->create('\Shockwavemk\Mail\Base\Model\Mail\Attachment');

            $attachment->setFilePath($filePath);
            $attachment->setMail($mail);

            // transfer all meta data into attachment object
            foreach ($fileMetaData as $attributeKey => $attributeValue) {
                $attachment->setData($attributeKey, $attributeValue);
            }

            $attachments[$filePath] = $attachment;
        }

        return $attachments;
    }
1012535
public function transform($fieldOptions)
    {
        $result = array();
        if (is_array($fieldOptions)) {
            foreach ($fieldOptions as $fieldOption) {
                if($fieldOption instanceof FieldOptionInterface) {
                    $result[$fieldOption->getKey()] = $fieldOption->getValue();
                }
            }
        }

        return $result;
    }
448591
public function getFieldList($options = [])
    {
        $_options = [
            'normalize' => true,
        ];

        $options = Hash::merge($_options, $options);

        $list = [];

        foreach ($this->config() as $key => $value) {
            if (!in_array($key, $this->_presetConfigKeys) || is_integer($key)) {
                if (is_integer($key)) {
                    $field = $value;
                } else {
                    $field = $key;
                }

                if ($options['normalize']) {
                    $fieldConfig = $this->_normalizeField($field);
                } else {
                    $fieldConfig = (($this->config($field) == null) ? [] : $this->config($field));
                }

                $list[$field] = $fieldConfig;
            }
        }
        return $list;
    }
253049
public function descendantFieldKeys(): array
    {
        $keys = [];

        foreach ($this->children() as $key => $node) {

            if ($node instanceof ModelFormLayoutNodeInterface) {
                $keys = array_merge($keys, $node->descendantFieldKeys());
                continue;
            }

            $keys[] = $node;
        }

        return $keys;
    }
146472
public function notify( Vulnerabilities $vulnerabilities ) {
		if ( ! $this->should_notify( $vulnerabilities ) ) {
			return;
		}

		foreach ( $this->notifiers as $notifier ) {
			if ( $notifier->is_enabled() ) {
				$notifier->notify( $vulnerabilities );
			}
		}
	}
944093
public function getSanitizedValues(&$values = [])
    {
        array_walk($this->fields, function ($field, $index) use (&$values) {
            if (is_array($field)) {
                return $this->sanitizeConditionalValues($values, $field, $index);
            }

            return $this->sanitizeValues($values[$field->getSlug()], $field);
        });

        return $values;
    }
90676
protected function prepare_form_fields(array $fields) {

        $formdata = new stdclass();
        $key = 0;
        foreach ($fields as $field) {
            $formdata->{'dimensionid__idx_' . $key}             = $field->id;
            $formdata->{'description__idx_' . $key}             = $field->description;
            $formdata->{'description__idx_' . $key.'format'}    = $field->descriptionformat;
            $formdata->{'numoflevels__idx_' . $key}             = count($field->levels);
            $lev = 0;
            foreach ($field->levels as $level) {
                $formdata->{'levelid__idx_' . $key . '__idy_' . $lev} = $level->id;
                $formdata->{'grade__idx_' . $key . '__idy_' . $lev} = $level->grade;
                $formdata->{'definition__idx_' . $key . '__idy_' . $lev} = $level->definition;
                $formdata->{'definition__idx_' . $key . '__idy_' . $lev . 'format'} = $level->definitionformat;
                $lev++;
            }
            $key++;
        }
        return $formdata;
    }
1170707
public function getAddressStrings(): array
    {
        $strings = [];
        foreach ($this->addresses as $address) {
            $str = $address->getEncodedAddress();
            if ($address instanceof NamedAddress && $name = $address->getName()) {
                $str = $this->createPhrase($this, $name, $this->getCharset(), empty($strings)).' <'.$str.'>';
            }
            $strings[] = $str;
        }

        return $strings;
    }
892087
private function _getPreparedFields(array $pFields)
    {
        $fields = array();
        $keys   = array_keys($pFields);
        foreach ($keys as $key) {
            $fields[] = "`$key` = ?";
        }

        return implode(', ', $fields);
    }
1372304
public static Field[] getDeclaredFields(Class<?> clazz) throws SecurityException {
		if (null == clazz) {
			return null;
		}
		return clazz.getDeclaredFields();
	}
981770
public function buildMessages(
        string $fieldName,
        ValidationResult $validationResult,
        array $messages = [],
        array $options = []
    ): array {
        if ($validationResult instanceof ValidationResultFields) {
            $options[Field::KEY_FIELD_NAME] = $fieldName;
            $subMessages = $this->buildMessagesValidationFields(
                $validationResult->getFieldResults(),
                [],
                $options
            );

            $messages = $this->flattenSubMessages(
                $fieldName,
                $subMessages,
                $messages
            );

            return $messages;
        }

        $options[Field::KEY_FIELD_NAME] = $fieldName;
        $messages[$fieldName] = $this->getMessagesValidationResult->__invoke(
            $validationResult,
            $options
        );

        return $messages;
    }