class Privileges

Privileges class

Properties

Template $template
DatabaseInterface $dbi
Relation $relation

Methods

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

Privileges constructor.

string
getHtmlForUserGroupDialog(string $username, bool $is_menuswork)

Get Html for User Group Dialog

string
wildcardEscapeForGrant(string $dbname, string $tablename)

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

string
rangeOfUsers(string $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, boolean $enableHTML = false, boolean $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

string
getHtmlToChooseUserGroup(string $username)

Displays a dropdown to select the user group with menu items configured to each of them.

void
setUserGroup(string $username, string $userGroup)

Sets the user group from request values

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

Displays the privileges form table

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

Get the HTML snippet for routine specific privileges

string
getHtmlForAuthPluginsDropdown(string $orig_auth_plugin, string $mode = 'new', string $versions = 'new')

Gets the currently active authentication plugins

array
getActiveAuthPlugins()

Gets the currently active authentication plugins

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 $err_url, 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 cluase

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.

integer
getUserGroupCount()

Returns number of defined user groups

mixed
getUserGroupForUser(string $username)

Returns name of user group that user is part of

array
getExtraDataForAjaxBehavior(string $password, string $sql_query, 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 tabel specific or database specific rights

string
getUsersOverview(array $result, array $db_rights, string $pmaThemeImage, string $text_dir)

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

string
getHtmlForInitials(array $array_initials)

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 $queries_for_display)

update Data For Queries from queries_for_display

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

update Data for information: Adds a user

void
setProperPasswordHashing(string $auth_plugin)

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 $pmaThemeImage, string $text_dir)

Get HTML snippet for display user overview page

string
getHtmlForUserProperties(boolean $dbname_is_wildcard, string $url_dbname, string $username, string $hostname, string|array $dbname, string $tablename)

Get HTML snippet for display user properties

array
getTablePrivsQueriesForChangeOrCopyUser(string $user_host_condition, 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(boolean $_error, string $real_sql_query, string $sql_query, string $username, string $hostname, string $dbname, string $alter_real_sql_query, string $alter_sql_query)

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

string
getHashedPassword(string $password)

Get the hashed string for password

boolean
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

Details

at line 57
__construct(Template $template, DatabaseInterface $dbi, Relation $relation, RelationCleanup $relationCleanup)

Privileges constructor.

Parameters

Template $template Template object
DatabaseInterface $dbi DatabaseInterface object
Relation $relation Relation object
RelationCleanup $relationCleanup RelationCleanup object

at line 77
string getHtmlForUserGroupDialog(string $username, bool $is_menuswork)

Get Html for User Group Dialog

Parameters

string $username username
bool $is_menuswork Is menuswork set in configuration

Return Value

string html

at line 109
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

at line 133
string rangeOfUsers(string $initial = '')

Generates a condition on the user name

Parameters

string $initial the user's initial

Return Value

string the generated condition

at line 156
void fillInTablePrivileges(array $row)

Parses privileges into an array, it modifies the array

Parameters

array $row Results row from

Return Value

void

at line 198
array extractPrivInfo(array|null $row = null, boolean $enableHTML = false, boolean $tablePrivs = false)

Extracts the privilege information of a priv table row

Parameters

array|null $row the row
boolean $enableHTML add tag with tooltips
boolean $tablePrivs whether row contains table privileges

Return Value

array

at line 280
array getTableGrantsArray()

Returns an array of table grants and their descriptions

Return Value

array array of table grants

at line 332
array getGrantsArray()

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

Return Value

array

at line 509
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

at line 538
string getHtmlToChooseUserGroup(string $username)

Displays a dropdown to select the user group with menu items configured to each of them.

Parameters

string $username username

Return Value

string html to select the user group

at line 583
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

at line 634
string getHtmlToDisplayPrivilegesTable(string $db = '*', string $table = '*', boolean $submit = true)

Displays the privileges form table

Parameters

string $db the database
string $table the table
boolean $submit whether to display the submit button or not

Return Value

string html snippet

at line 754
string getHtmlForRoutineSpecificPrivileges(string $username, string $hostname, string $db, string $routine, string $url_dbname)

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 $url_dbname url encoded db name

Return Value

string

at line 785
string getHtmlForAuthPluginsDropdown(string $orig_auth_plugin, string $mode = 'new', string $versions = 'new')

Gets the currently active authentication plugins

Parameters

string $orig_auth_plugin Default Authentication plugin
string $mode are we creating a new user or are we just changing one? (allowed values: 'new', 'edit', 'change_pw')
string $versions Is MySQL version newer or older than 5.5.7

Return Value

string

at line 820
array getActiveAuthPlugins()

Gets the currently active authentication plugins

Return Value

array array of plugin names and descriptions

at line 854
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

at line 944
array getUsernameAndHostnameLength()

Get username and hostname length

Return Value

array username length and hostname length

at line 980
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

at line 1028
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

at line 1051
Message updatePassword(string $err_url, string $username, string $hostname)

Update password and get message for password updating

Parameters

string $err_url error url
string $username username
string $hostname hostname

Return Value

Message success or error message after updating password

at line 1224
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)

at line 1264
string getRequireClause()

Get REQUIRE cluase

Return Value

string REQUIRE clause

at line 1302
string getWithClauseForAddUserAndUpdatePrivs()

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

Return Value

string

at line 1349
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

at line 1373
array getAllPrivileges(string $db, string $table = '')

Parameters

string $db database name
string $table table name

Return Value

array

at line 1575
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

at line 1664
integer getUserGroupCount()

Returns number of defined user groups

Return Value

integer

at line 1687
mixed getUserGroupForUser(string $username)

Returns name of user group that user is part of

Parameters

string $username User name

Return Value

mixed usergroup if found or null if not found

at line 1727
array getExtraDataForAjaxBehavior(string $password, string $sql_query, string $hostname, string $username)

This function return the extra data array for the ajax behavior

Parameters

string $password password
string $sql_query sql query
string $hostname hostname
string $username username

Return Value

array

at line 1823
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

at line 1936
array parseProcPriv(string $privs)

Parses Proc_priv data

Parameters

string $privs Proc_priv

Return Value

array

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

Get a HTML table for display user's tabel 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

at line 2147
string getUsersOverview(array $result, array $db_rights, string $pmaThemeImage, string $text_dir)

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

Parameters

array $result ran sql query
array $db_rights user's database rights array
string $pmaThemeImage a image source link
string $text_dir text directory

Return Value

string HTML snippet

at line 2224
string getHtmlForInitials(array $array_initials)

Get HTML for Displays the initials

Parameters

array $array_initials array for all initials, even non A-Z

Return Value

string HTML snippet

at line 2262
array getDbRightsForUserOverview()

Get the database rights array for Display user overview

Return Value

array database rights array

at line 2319
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

at line 2366
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 username
string $hostname host name
string $tablename table name
string $dbname database name
string $itemType item type

Return Value

array success message or error message for update

at line 2437
array getDataForChangeOrCopyUser()

Get List of information: Changes / copies a user

Return Value

array

at line 2513
array getDataForDeleteUsers(array $queries)

Update Data for information: Deletes users

Parameters

array $queries queries array

Return Value

array

at line 2556
Message|null updateMessageForReload()

update Message For Reload

Return Value

Message|null

at line 2582
array getDataForQueries(array $queries, array|null $queries_for_display)

update Data For Queries from queries_for_display

Parameters

array $queries queries array
array|null $queries_for_display queries array for display

Return Value

array

at line 2611
array addUser(string|array|null $dbname, string $username, string $hostname, string|null $password, bool $is_menuwork)

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 $is_menuwork is_menuwork set?

Return Value

array

at line 2780
void setProperPasswordHashing(string $auth_plugin)

Sets proper value of old_passwords according to the authentication plugin selected

Parameters

string $auth_plugin authentication plugin selected

Return Value

void

at line 2798
array getDataForDBInfo()

Update DB information: DB, Table, isWildcard

Return Value

array

at line 2919
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)

at line 2974
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

at line 3008
string getHtmlForUserOverview(string $pmaThemeImage, string $text_dir)

Get HTML snippet for display user overview page

Parameters

string $pmaThemeImage a image source link
string $text_dir text directory

Return Value

string

at line 3187
string getHtmlForUserProperties(boolean $dbname_is_wildcard, string $url_dbname, string $username, string $hostname, string|array $dbname, string $tablename)

Get HTML snippet for display user properties

Parameters

boolean $dbname_is_wildcard whether database name is wildcard or not
string $url_dbname 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

at line 3322
array getTablePrivsQueriesForChangeOrCopyUser(string $user_host_condition, array $queries, string $username, string $hostname)

Get queries for Table privileges to change or copy user

Parameters

string $user_host_condition user host condition to select relevant table privileges
array $queries queries array
string $username username
string $hostname host name

Return Value

array

at line 3411
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

at line 3459
array, addUserAndCreateDatabase(boolean $_error, string $real_sql_query, string $sql_query, string $username, string $hostname, string $dbname, string $alter_real_sql_query, string $alter_sql_query)

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

Parameters

boolean $_error whether user create or not
string $real_sql_query SQL query for add a user
string $sql_query SQL query to be displayed
string $username username
string $hostname host name
string $dbname database name
string $alter_real_sql_query SQL query for ALTER USER
string $alter_sql_query SQL query for ALTER USER to be displayed

Return Value

array, $message

at line 3557
string getHashedPassword(string $password)

Get the hashed string for password

Parameters

string $password password

Return Value

string

at line 3573
boolean checkIfMariaDBPwdCheckPluginActive()

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

Return Value

boolean if atleast one of the plugins is ACTIVE

at line 3609
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)

at line 3856
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