Adding the table name with the caption in user permissions

I made a change to my template to load the Table Caption with the table name in parenthesis to make assigning user level permissions easier. I modified the page.

Changes to userpriv.php in the template to display the table name and caption in the user permissions page

Added the following in userpriv.php:

switch ($this->CurrentAction) {
        case "show":
            if (!$Security->setupUserLevelEx()) {
                $this->terminate("<#= userLevelListPage #>");
                return;
            }
            $ar = [];
            for ($i = 0; $i < $this->TableNameCount; $i++) {
                $table = $this->TableList[$i];
                $cnt = count($table);
                $tempPriv = $Security->getUserLevelPrivEx($table[4] . $table[0], $this-><#= userLevelIdFldParm #>->CurrentValue);
                
                // Retrieve the table caption
                $tableCaption = $this->getTableCaption($i);
                
                $ar[] = [
                    "table" => ConvertToUtf8($tableCaption . " (" . $table[1] . ")"), // Caption with table name in parentheses
                    "name" => $table[1],
                    "index" => $i,
                    "permission" => $tempPriv,
                    "allowed" => $table[$cnt - 1]
                ];
            }
            $this->Privileges["disabled"] = $this->Disabled;
            $this->Privileges["permissions"] = $ar;
            $this->Privileges["ids"] = PRIVILEGES;
            foreach (PRIVILEGES as $priv) {
                $this->Privileges[$priv] = GetPrivilege($priv);
            }
            break;

        case "update":
            if ($this->editRow()) {
                if ($this->getSuccessMessage() == "") {
                    $this->setSuccessMessage($Language->phrase("UpdateSuccess"));
                }
                $this->terminate("<#= userLevelListPage #>");
                return;
            }
    }

Now my user permissions looks like:

Caption (table name)

1 Like

This worked for PHPmaker 2024

v2025 always uses utf-8, there is no more ConvertToUtf8(). You better always turn on Debug during development.