Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class PrivilegesCache extends Cache {
$privs += $endpoint_object->generate_pfsense_privs();
}

# Obtain privileges for each Endpoint class
foreach (get_classes_from_namespace('\\RESTAPI\\Forms\\') as $endpoint_class) {
$endpoint_object = new $endpoint_class();
$privs += $endpoint_object->generate_pfsense_privs();
# Obtain privileges for each Form class
foreach (get_classes_from_namespace('\\RESTAPI\\Forms\\') as $form_class) {
$form_object = new $form_class();
$privs += $form_object->generate_pfsense_privs();
}

return $privs;
Expand Down
13 changes: 12 additions & 1 deletion pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core/Form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,17 @@ class Form {
private function generate_verbose_name(): string {
# Separate the class name's words with spaces, allow consecutive capital characters like 'DNS'
$form_name = $this->get_class_shortname();
return preg_replace('/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/', ': ', $form_name);
$verbose_name = preg_replace('/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/', ' ', $form_name);

# Add a colon after the first word if the class name is more than one word
if (str_contains($verbose_name, ' ')) {
$verbose_name = explode(' ', $verbose_name);
$verbose_name[0] .= ': ';
$verbose_name = implode(' ', $verbose_name);
}

# Return the verbose name with the 'Form' suffix removed
return str_replace(' Form', '', $verbose_name);
}

/**
Expand Down Expand Up @@ -513,6 +523,7 @@ class Form {
$this->get_priv_name() => [
'name' => 'WebCfg - ' . $this->verbose_name,
'descr' => "Allow access to the $this->url page.",
'match' => [substr($this->url, 1)],
],
];
}
Expand Down