IsPredefined()) { # print entry and increment index $TextFormEntries[] = [ getHtmlForPrivilegeEntry( "F_PermissionText".$Index, $Privilege->Name(), $Privilege->Id() ) ]; $Index++; } } # Print remaining blank entries for ($Index; $Index < $NumberOfEntries; $Index++) { $IsLast = ($Index + 1 == $NumberOfEntries) ? true : false; $TextFormEntries[] = [getHtmlForPrivilegeEntry("F_PermissionText".$Index, "", "", $IsLast)]; } return $TextFormEntries; } /** * Return privilege edit row, with text entry and delete button. * @param string $TextInputName Name to use for input field * @param string $TextInputValue Initial value to use for input field * @param string $TextInputId Privilege ID * @param boolean $IsLast If this is the last privilege field * @return string HTML to edit a single privilege. */ function getHtmlForPrivilegeEntry( string $TextInputName, string $TextInputValue, string $TextInputId, bool $IsLast = false ): string { $DeleteButton = new HtmlButton("Delete"); $DeleteButton->setIcon("Delete.svg"); $DeleteButton->setSize(HtmlButton::SIZE_SMALL); $DeleteButton->addClass("DeletePrivilege"); $DeleteButton->setName($TextInputName . "_Delete"); $Html = "" ; if ($IsLast !== true) { $Html .= $DeleteButton->getHtml(); } $Html .= "" ; return $Html; } /** * Calculate how many privilege entries to print. * @param int $Default The default number to print if user is logged-out or has no privileges. * @param array $Privileges Array of privilege objects for the logged-in user. * @return int */ function getCorrectNumFormEntries(int $Default, array $Privileges) { if (User::getCurrentUser()->isLoggedIn() && count($Privileges)) { $PrivFactory = new PrivilegeFactory(); return count($Privileges) - count($PrivFactory->getPredefinedPrivilegeConstants()) + 1; } return $Default; } /** * function to print any error messages at top of the page * @param array|null $ErrorMessages */ function printErrorMessages($ErrorMessages): void { # if error messages were passed from PreferencesComplete if (isset($ErrorMessages) && is_array($ErrorMessages) && count($ErrorMessages) > 0) { # print error messages print("

\n"); foreach ($ErrorMessages as $Message) { printf("
- %s
\n", $Message); } print("

\n"); } } # ----- SETUP ---------------------------------------------------------------- if (!isset($H_ErrorMessages)) { $H_ErrorMessages = []; } if (!isset($H_Privileges)) { throw new Exception("Required variable \$H_Privileges was not initialized"); } $SaveButton = new HtmlButton("Save"); $SaveButton->setIcon("Disk.svg"); $CancelButton = new HtmlButton("Cancel"); $CancelButton->setIcon("Cross.svg"); $CancelButton->addSemanticClass("btn-danger"); $AddPrivilegeButton = new HtmlButton("Add another privilege"); $AddPrivilegeButton->setIcon("Plus.svg"); $AddPrivilegeButton->setId("AddField"); $AddPrivilegeButton->hide(); $AddPrivilegeButton->setOnclick("window.location='#TableBottom';return false;"); $PrivilegeTable = new HtmlTable(); $PrivilegeTable->setTableClass("table table-striped"); $PrivilegeTable->addHeaderRow(["Privilege Name"], "table-dark"); $PrivilegeTable->addRows( getHtmlForPrivilegeEntries(getCorrectNumFormEntries(10, $H_Privileges), $H_Privileges) ); # ----- DISPLAY -------------------------------------------------------------- ?>

# Custom Privilege Names

The Edit Custom Privilege Flags page allows system administrators to add, update, and remove site-specific privilege flags. Custom privilege flags can be used anywhere the default privilege flags are used and are intended to provide finer-grained control of the collection development workflow or to provide new functionality.

getHtml(); ?> getHtml(); ?> getHtml(); ?> getHtml(); ?>