class Privileges (View source)

Privileges class

Properties

Template $template
DatabaseInterface $dbi
Relation $relation

Methods

__construct(Template $template, DatabaseInterface $dbi, Relation $relation, RelationCleanup $relationCleanup, Plugins $plugins)

No description

string
wildcardEscapeForGrant(string $dbname, string $tablename)

Escapes wildcard in a database+table specification before using it in a GRANT statement.

string
rangeOfUsers(string|null $initial = '')

Generates a condition on the user name

void
fillInTablePrivileges(array $row)

Parses privileges into an array, it modifies the array

array
extractPrivInfo(array|null $row = null, bool $enableHTML = false, bool $tablePrivs = false)

Extracts the privilege information of a priv table row

array
getTableGrantsArray()

Returns an array of table grants and their descriptions

array
getGrantsArray()

Get the grants array which contains all the privilege types and relevant grant messages

string
getSqlQueryForDisplayPrivTable(string $db, string $table, string $username, string $hostname)

Get sql query for display privileges table

void
setUserGroup(string $username, string $userGroup)

Sets the user group from request values

string
getHtmlToDisplayPrivilegesTable(string $db = '*', string $table = '*', bool $submit = true)

Displays the privileges form table

string
getHtmlForRoutineSpecificPrivileges(string $username, string $hostname, string $db, string $routine, string $urlDbname)

Get the HTML snippet for routine specific privileges

string
getHtmlForLoginInformationFields(string $mode = 'new', string $user = null, string $host = null)

Displays the fields used by the "new user" form as well as the "change login information / copy user" form.

array
getUsernameAndHostnameLength()

Get username and hostname length

string
getCurrentAuthenticationPlugin(string $mode = 'new', string $username = null, string $hostname = null)

Get current authentication plugin in use - for a user or globally

string
getGrants(string $user, string $host)

Returns all the grants for a certain user on a certain host Used in the export privileges for all users section

updatePassword(string $errorUrl, string $username, string $hostname)

Update password and get message for password updating

array
getMessageAndSqlQueryForPrivilegesRevoke(string $dbname, string $tablename, string $username, string $hostname, string $itemType)

Revokes privileges and get message and SQL query for privileges revokes

string
getRequireClause()

Get REQUIRE clause

string
getWithClauseForAddUserAndUpdatePrivs()

Get a WITH clause for 'update privileges' and 'add user'

string
getHtmlForAddUser(string $dbname)

Get HTML for addUsersForm, This function call if isset($_GET['adduser'])

array
getAllPrivileges(string $db, string $table = '')

No description

string
getHtmlForViewUsersError()

Get HTML error for View Users form For non superusers such as grant/create users

string
getUserLink(string $linktype, string $username, string $hostname, string $dbname = '', string $tablename = '', string $routinename = '', string $initial = '')

Returns edit, revoke or export link for a user.

int
getUserGroupCount()

Returns number of defined user groups

mixed|null
getUserGroupForUser(string $username)

Returns name of user group that user is part of

array
getExtraDataForAjaxBehavior(string $password, string $sqlQuery, string $hostname, string $username)

This function return the extra data array for the ajax behavior

array
getUserSpecificRights(string $username, string $hostname, string $type, string $dbname = '')

no db name given, so we want all privs for the given user db name was given, so we want all user specific rights for this db So this function returns user rights as an array

array
parseProcPriv(string $privs)

Parses Proc_priv data

string
getHtmlForAllTableSpecificRights(string $username, string $hostname, string $type, string $dbname = '')

Get a HTML table for display user's table specific or database specific rights

string
getUsersOverview(array $result, array $dbRights, string $textDir)

Get HTML for display the users overview (if less than 50 users, display them immediately)

string
getHtmlForInitials(array $arrayInitials)

Get HTML for Displays the initials

array
getDbRightsForUserOverview()

Get the database rights array for Display user overview

array
deleteUser(array $queries)

Delete user and get message and sql query for delete user in privileges

array
updatePrivileges(string $username, string $hostname, string $tablename, string $dbname, string $itemType)

Update the privileges and return the success or error message

array
getDataForChangeOrCopyUser()

Get List of information: Changes / copies a user

array
getDataForDeleteUsers(array $queries)

Update Data for information: Deletes users

Message|null
updateMessageForReload()

update Message For Reload

array
getDataForQueries(array $queries, array|null $queriesForDisplay)

update Data For Queries from queries_for_display

array
addUser(string|array|null $dbname, string $username, string $hostname, string|null $password, bool $isMenuwork)

update Data for information: Adds a user

void
setProperPasswordHashing(string $authPlugin)

Sets proper value of old_passwords according to the authentication plugin selected

array
getDataForDBInfo()

Update DB information: DB, Table, isWildcard

array
getListForExportUserDefinition(string $username, string $hostname)

Get title and textarea for export user definition in Privileges

string
getAddUserHtmlFieldset(string $db = '', string $table = '')

Get HTML for display Add userfieldset

string
getHtmlForUserOverview(string $textDir)

Get HTML snippet for display user overview page

string
getHtmlForUserProperties(bool $dbnameIsWildcard, string $urlDbname, string $username, string $hostname, string|array $dbname, string $tablename)

Get HTML snippet for display user properties

array
getTablePrivsQueriesForChangeOrCopyUser(string $userHostCondition, array $queries, string $username, string $hostname)

Get queries for Table privileges to change or copy user

array
getDbSpecificPrivsQueriesForChangeOrCopyUser(array $queries, string $username, string $hostname)

Get queries for database specific privileges for change or copy user

array
addUserAndCreateDatabase(bool $error, string $realSqlQuery, string $sqlQuery, string $username, string $hostname, string $dbname, string $alterRealSqlQuery, string $alterSqlQuery, bool $createDb1, bool $createDb2, bool $createDb3)

Prepares queries for adding users and also create database and return query and message

string
getHashedPassword(string $password)

Get the hashed string for password

bool
checkIfMariaDBPwdCheckPluginActive()

Check if MariaDB's 'simple_password_check' OR 'cracklib_password_check' is ACTIVE

array
getSqlQueriesForDisplayAndAddUser(string $username, string $hostname, string $password)

Get SQL queries for Display and Add user

string
getRoutineType(string $dbname, string $routineName)

Returns the type ('PROCEDURE' or 'FUNCTION') of the routine

string
getFormForChangePassword(string $username, string $hostname, bool $editOthers)

No description

Details

__construct(Template $template, DatabaseInterface $dbi, Relation $relation, RelationCleanup $relationCleanup, Plugins $plugins)

No description

Parameters

Template $template

Template object

DatabaseInterface $dbi

DatabaseInterface object

Relation $relation

Relation object

RelationCleanup $relationCleanup

RelationCleanup object

Plugins $plugins

string wildcardEscapeForGrant(string $dbname, string $tablename)

Escapes wildcard in a database+table specification before using it in a GRANT statement.

Escaping a wildcard character in a GRANT is only accepted at the global or database level, not at table level; this is why I remove the escaping character. Internally, in mysql.tables_priv.Db there are no escaping (for example test_db) but in mysql.db you'll see test_db for a db-specific privilege.

Parameters

string $dbname

Database name

string $tablename

Table name

Return Value

string

the escaped (if necessary) database.table

string rangeOfUsers(string|null $initial = '')

Generates a condition on the user name

Parameters

string|null $initial

the user's initial

Return Value

string

the generated condition

void fillInTablePrivileges(array $row)

Parses privileges into an array, it modifies the array

Parameters

array $row

Results row from

Return Value

void

array extractPrivInfo(array|null $row = null, bool $enableHTML = false, bool $tablePrivs = false)

Extracts the privilege information of a priv table row

Parameters

array|null $row

the row

bool $enableHTML

add tag with tooltips

bool $tablePrivs

whether row contains table privileges

Return Value

array

array getTableGrantsArray()

Returns an array of table grants and their descriptions

Return Value

array

array of table grants

array getGrantsArray()

Get the grants array which contains all the privilege types and relevant grant messages

Return Value

array

string getSqlQueryForDisplayPrivTable(string $db, string $table, string $username, string $hostname)

Get sql query for display privileges table

Parameters

string $db

the database

string $table

the table

string $username

username for database connection

string $hostname

hostname for database connection

Return Value

string

sql query

void setUserGroup(string $username, string $userGroup)

Sets the user group from request values

Parameters

string $username

username

string $userGroup

user group to set

Return Value

void

string getHtmlToDisplayPrivilegesTable(string $db = '*', string $table = '*', bool $submit = true)

Displays the privileges form table

Parameters

string $db

the database

string $table

the table

bool $submit

whether to display the submit button or not

Return Value

string

html snippet

string getHtmlForRoutineSpecificPrivileges(string $username, string $hostname, string $db, string $routine, string $urlDbname)

Get the HTML snippet for routine specific privileges

Parameters

string $username

username for database connection

string $hostname

hostname for database connection

string $db

the database

string $routine

the routine

string $urlDbname

url encoded db name

Return Value

string

string getHtmlForLoginInformationFields(string $mode = 'new', string $user = null, string $host = null)

Displays the fields used by the "new user" form as well as the "change login information / copy user" form.

Parameters

string $mode

are we creating a new user or are we just changing one? (allowed values: 'new', 'change')

string $user

User name

string $host

Host name

Return Value

string

a HTML snippet

array getUsernameAndHostnameLength()

Get username and hostname length

Return Value

array

username length and hostname length

string getCurrentAuthenticationPlugin(string $mode = 'new', string $username = null, string $hostname = null)

Get current authentication plugin in use - for a user or globally

Parameters

string $mode

are we creating a new user or are we just changing one? (allowed values: 'new', 'change')

string $username

User name

string $hostname

Host name

Return Value

string

authentication plugin in use

string getGrants(string $user, string $host)

Returns all the grants for a certain user on a certain host Used in the export privileges for all users section

Parameters

string $user

User name

string $host

Host name

Return Value

string

containing all the grants text

Message updatePassword(string $errorUrl, string $username, string $hostname)

Update password and get message for password updating

Parameters

string $errorUrl

error url

string $username

username

string $hostname

hostname

Return Value

Message

success or error message after updating password

array getMessageAndSqlQueryForPrivilegesRevoke(string $dbname, string $tablename, string $username, string $hostname, string $itemType)

Revokes privileges and get message and SQL query for privileges revokes

Parameters

string $dbname

database name

string $tablename

table name

string $username

username

string $hostname

host name

string $itemType

item type

Return Value

array

($message, $sql_query)

string getRequireClause()

Get REQUIRE clause

Return Value

string

REQUIRE clause

string getWithClauseForAddUserAndUpdatePrivs()

Get a WITH clause for 'update privileges' and 'add user'

Return Value

string

string getHtmlForAddUser(string $dbname)

Get HTML for addUsersForm, This function call if isset($_GET['adduser'])

Parameters

string $dbname

database name

Return Value

string

HTML for addUserForm

array getAllPrivileges(string $db, string $table = '')

No description

Parameters

string $db

database name

string $table

table name

Return Value

array

string getHtmlForViewUsersError()

Get HTML error for View Users form For non superusers such as grant/create users

Return Value

string

Returns edit, revoke or export link for a user.

Parameters

string $linktype

The link type (edit | revoke | export)

string $username

User name

string $hostname

Host name

string $dbname

Database name

string $tablename

Table name

string $routinename

Routine name

string $initial

Initial value

Return Value

string

HTML code with link

int getUserGroupCount()

Returns number of defined user groups

Return Value

int

mixed|null getUserGroupForUser(string $username)

Returns name of user group that user is part of

Parameters

string $username

User name

Return Value

mixed|null

usergroup if found or null if not found

array getExtraDataForAjaxBehavior(string $password, string $sqlQuery, string $hostname, string $username)

This function return the extra data array for the ajax behavior

Parameters

string $password

password

string $sqlQuery

sql query

string $hostname

hostname

string $username

username

Return Value

array

array getUserSpecificRights(string $username, string $hostname, string $type, string $dbname = '')

no db name given, so we want all privs for the given user db name was given, so we want all user specific rights for this db So this function returns user rights as an array

Parameters

string $username

username

string $hostname

host name

string $type

database or table

string $dbname

database name

Return Value

array

database rights

array parseProcPriv(string $privs)

Parses Proc_priv data

Parameters

string $privs

Proc_priv

Return Value

array

string getHtmlForAllTableSpecificRights(string $username, string $hostname, string $type, string $dbname = '')

Get a HTML table for display user's table specific or database specific rights

Parameters

string $username

username

string $hostname

host name

string $type

database, table or routine

string $dbname

database name

Return Value

string

string getUsersOverview(array $result, array $dbRights, string $textDir)

Get HTML for display the users overview (if less than 50 users, display them immediately)

Parameters

array $result

ran sql query

array $dbRights

user's database rights array

string $textDir

text directory

Return Value

string

HTML snippet

string getHtmlForInitials(array $arrayInitials)

Get HTML for Displays the initials

Parameters

array $arrayInitials

array for all initials, even non A-Z

Return Value

string

HTML snippet

array getDbRightsForUserOverview()

Get the database rights array for Display user overview

Return Value

array

database rights array

array deleteUser(array $queries)

Delete user and get message and sql query for delete user in privileges

Parameters

array $queries

queries

Return Value

array

Message

array updatePrivileges(string $username, string $hostname, string $tablename, string $dbname, string $itemType)

Update the privileges and return the success or error message

Parameters

string $username
string $hostname
string $tablename
string $dbname
string $itemType

Return Value

array

success message or error message for update

array getDataForChangeOrCopyUser()

Get List of information: Changes / copies a user

Return Value

array

array getDataForDeleteUsers(array $queries)

Update Data for information: Deletes users

Parameters

array $queries

queries array

Return Value

array

Message|null updateMessageForReload()

update Message For Reload

Return Value

Message|null

array getDataForQueries(array $queries, array|null $queriesForDisplay)

update Data For Queries from queries_for_display

Parameters

array $queries

queries array

array|null $queriesForDisplay

queries array for display

Return Value

array

array addUser(string|array|null $dbname, string $username, string $hostname, string|null $password, bool $isMenuwork)

update Data for information: Adds a user

Parameters

string|array|null $dbname

db name

string $username

user name

string $hostname

host name

string|null $password

password

bool $isMenuwork

is_menuwork set?

Return Value

array

void setProperPasswordHashing(string $authPlugin)

Sets proper value of old_passwords according to the authentication plugin selected

Parameters

string $authPlugin

authentication plugin selected

Return Value

void

array getDataForDBInfo()

Update DB information: DB, Table, isWildcard

Return Value

array

array getListForExportUserDefinition(string $username, string $hostname)

Get title and textarea for export user definition in Privileges

Parameters

string $username

username

string $hostname

host name

Return Value

array

($title, $export)

string getAddUserHtmlFieldset(string $db = '', string $table = '')

Get HTML for display Add userfieldset

Parameters

string $db

the database

string $table

the table name

Return Value

string

html output

string getHtmlForUserOverview(string $textDir)

Get HTML snippet for display user overview page

Parameters

string $textDir

text directory

Return Value

string

string getHtmlForUserProperties(bool $dbnameIsWildcard, string $urlDbname, string $username, string $hostname, string|array $dbname, string $tablename)

Get HTML snippet for display user properties

Parameters

bool $dbnameIsWildcard

whether database name is wildcard or not

string $urlDbname

url database name that urlencode() string

string $username

username

string $hostname

host name

string|array $dbname

database name

string $tablename

table name

Return Value

string

array getTablePrivsQueriesForChangeOrCopyUser(string $userHostCondition, array $queries, string $username, string $hostname)

Get queries for Table privileges to change or copy user

Parameters

string $userHostCondition

user host condition to select relevant table privileges

array $queries

queries array

string $username

username

string $hostname

host name

Return Value

array

array getDbSpecificPrivsQueriesForChangeOrCopyUser(array $queries, string $username, string $hostname)

Get queries for database specific privileges for change or copy user

Parameters

array $queries

queries array with string

string $username

username

string $hostname

host name

Return Value

array

array addUserAndCreateDatabase(bool $error, string $realSqlQuery, string $sqlQuery, string $username, string $hostname, string $dbname, string $alterRealSqlQuery, string $alterSqlQuery, bool $createDb1, bool $createDb2, bool $createDb3)

Prepares queries for adding users and also create database and return query and message

Parameters

bool $error

whether user create or not

string $realSqlQuery

SQL query for add a user

string $sqlQuery

SQL query to be displayed

string $username

username

string $hostname

host name

string $dbname

database name

string $alterRealSqlQuery

SQL query for ALTER USER

string $alterSqlQuery

SQL query for ALTER USER to be displayed

bool $createDb1
bool $createDb2
bool $createDb3

Return Value

array

string getHashedPassword(string $password)

Get the hashed string for password

Parameters

string $password

password

Return Value

string

bool checkIfMariaDBPwdCheckPluginActive()

Check if MariaDB's 'simple_password_check' OR 'cracklib_password_check' is ACTIVE

Return Value

bool

array getSqlQueriesForDisplayAndAddUser(string $username, string $hostname, string $password)

Get SQL queries for Display and Add user

Parameters

string $username

username

string $hostname

host name

string $password

password

Return Value

array

($create_user_real, $create_user_show, $real_sql_query, $sql_query $password_set_real, $password_set_show, $alter_real_sql_query, $alter_sql_query)

string getRoutineType(string $dbname, string $routineName)

Returns the type ('PROCEDURE' or 'FUNCTION') of the routine

Parameters

string $dbname

database

string $routineName

routine

Return Value

string

type

string getFormForChangePassword(string $username, string $hostname, bool $editOthers)

No description

Parameters

string $username
string $hostname
bool $editOthers

Return Value

string