Class WPDA_Dictionary_Access

Check if access to a given table is granted. The existence of the table name (and schema name for back-end) is not checked in this class. The class presumes that the table name (and schema name for back-end) is valid.

The argument $done, which is used throughout the class, indicates whether the access check confirms the existence of the table or whether no access is granted anyway and therefor no further checks are needed. In some situations this saves us a query.

For example:

If table $wpdb->options is provided as an argument and access to WordPress tables is allowed we are done. If only selected tables are allowed and the table provided as an argument is either in or not in the list we done as well. When calling WPDA_Dictionary_Access functions check the return value as well as $done.

author Peter Schulz
since 1.0.0
package WPDataAccess\Data_Dictionary

 Methods

Check if user has CREATE (database) privilege

can_create_db() : boolean
Static
since 2.7.2

Returns

boolean

Check if user has DROP (database) privilege

can_drop_db() : boolean
Static
since 2.7.2

Returns

boolean

Check back-end table access

check_table_access_backend(string $schema_name, string $table_name, boolean $done) : boolean
Static

Checks if access to a given schema and table is granted for back-end usage.

The schema name must be provided as an argument. This argument is mainly added to support a clean access check for the data explorer view which uses the view TABLES from MySQL schema INFORMATION_SCHEMA (see \WPDataAccess\List_Table\WPDA_List_Table::LIST_BASE_TABLE). This is the only table/view outside the WordPress schema to which access is granted.

since 1.0.0
see \WPDataAccess\List_Table\WPDA_List_Table::LIST_BASE_TABLE

Parameters

$schema_name

string

Schema name in which the table or view is located.

$table_name

string

Table or view name.

$done

boolean

TRUE = no futher checks needed, FALSE = still need to check table name.

Returns

booleanTRUE = access granted, FALSE = access denied.

Check front-end table access

check_table_access_frontend(string $schema_name, string $table_name, boolean $done) : boolean
Static

Checks if access to a given table is granted for front-end usage.

The schema name is not reflected in this check. It presumed that the schema name if the schema in which WordPress is installed.

since 1.0.0

Parameters

$schema_name

string

Schema name in which the table or view is located.

$table_name

string

Table or view name.

$done

boolean

TRUE = no futher checks needed, FALSE = still need to check table name.

Returns

booleanTRUE = access granted, FALSE = access denied.

Check tables access

check_table_access(string $schema_name, string $table_name, string $table_access, string $table_access_selected, boolean $done) : boolean
Static

Checks if access to a given table is granted for back-end or front-end usage. Whether the check is performed for the back-end or front-end depends on the arguments $table_access and $table_access_selected.

The schema name is not reflected in this check. It presumed that the schema name if the schema in which WordPress is installed.

This function is code which is shared between \WPDataAccess\Data_Dictionary\WPDA_Dictionary_Access::check_table_access_backend() and \WPDataAccess\Data_Dictionary\WPDA_Dictionary_Access::check_table_access_frontend().

see \WPDataAccess\Data_Dictionary\WPDA_Dictionary_Access::check_table_access_frontend()
see \WPDataAccess\Data_Dictionary\WPDA_Dictionary_Access::check_table_access_backend()
since 1.0.0

Parameters

$schema_name

string

Schema name in which the table or view is located.

$table_name

string

Table or view name.

$table_access

string

Option value for table access as stored in wp_options.

$table_access_selected

string

Option value for tables selected access as stored in wp_options.

$done

boolean

TRUE = no futher checks needed, FALSE = still need to check table name.

Returns

booleanTRUE = access granted, FALSE = access denied.