Public Member Functions | |
_instantiate_record ( $in_db_result) | |
__construct ( $in_pdo_object, $in_access_object) | |
execute_query ( $in_sql, $in_parameters=NULL, $exec_only=false) | |
get_db_backup () | |
get_access_class_by_id ( $in_id) | |
can_i_see_this_record ( $in_id) | |
get_single_raw_row_by_id ( $in_id, $and_write=false) | |
get_single_record_by_id ( $in_id, $and_write=false) | |
get_multiple_records_by_id ( $in_id_array, $and_write=false) | |
get_all_readable_records ( $open_only=false, $in_this_id=NULL) | |
get_all_writeable_records ( $in_this_id=NULL) | |
lock_record ( $in_record_id) | |
write_record ( $params_associative_array) | |
delete_record ( $id) | |
Public Attributes | |
$access_object | |
$class_description | |
$error | |
$table_name | |
Protected Member Functions | |
_create_read_security_predicate () | |
_create_write_security_predicate () | |
_create_security_predicate ( $write=false) | |
Protected Attributes | |
$_pdo_object | |
$_existing_record_objects | |
Private Member Functions | |
_execute_query ( $in_sql, $in_parameters=NULL, $exec_only=false) | |
This is the abstract base class for both Badger databases. The bulk of database access, and most of the security, appears in this class.
The key to security is in the two protected _predicate methods (one for read, and one for write). These analyze the logged-in user's list of IDs (using the access class' get_security_ids() method, which reloads the security item), and construct an SQL predicate for calls that prevent records from being considered that do not match the security profile. This means the records are never even read into the object from the database. They are excluded by SQL.
Definition at line 50 of file a_co_db.class.php.
A_CO_DB::__construct | ( | $in_pdo_object, | |
$in_access_object | |||
) |
The initializer
$in_pdo_object | This is the PDO object used to access the database. It should be initialized and connected at the time this method is called. |
$in_access_object | This is the access instance used to handle the login. |
Reimplemented in CO_Security_DB, and CO_Main_Data_DB.
Definition at line 271 of file a_co_db.class.php.
|
protected |
This function creates an SQL predicate that limits the query to only those records to which the current logged-in user has read rights.
Definition at line 104 of file a_co_db.class.php.
Referenced by _create_security_predicate(), CO_Security_DB\get_all_visible_logins(), CO_Main_Data_DB\get_all_visible_users(), and CO_Main_Data_DB\item_exists().
|
protected |
This creates the appropriate security predicate.
$write | This should be true, if we need a write predicate. Default is false. |
Definition at line 167 of file a_co_db.class.php.
References _create_read_security_predicate(), and _create_write_security_predicate().
Referenced by CO_Main_Data_DB\_build_sql_query(), CO_Main_Data_DB\_location_predicate(), can_i_see_this_record(), delete_record(), get_access_class_by_id(), CO_Security_DB\get_all_login_objects(), CO_Security_DB\get_all_login_objects_with_access(), get_all_readable_records(), get_all_writeable_records(), get_multiple_records_by_id(), CO_Security_DB\get_multiple_records_by_login_id(), get_single_raw_row_by_id(), lock_record(), and write_record().
|
protected |
This function creates an SQL predicate that limits the query to only those records to which the current logged-in user has modification rights.
Definition at line 135 of file a_co_db.class.php.
Referenced by _create_security_predicate().
|
private |
This executes an SQL query, using the PDO instance. It uses PDO prepared statements to apply the query.
This is a "bottleneck" method. All access to the database needs to go through here.
$in_sql | This is the SQL portion of the prepared statement. |
$in_parameters | This is an array of values to be used in the prepared statement. |
$exec_only | If true, then this means we do not expect a response. Default is false. |
Definition at line 67 of file a_co_db.class.php.
References CO_Lang_Common\$pdo_error_code_failed_to_open_security_db, CO_Lang\$pdo_error_desc_failed_to_open_security_db, and CO_Lang\$pdo_error_name_failed_to_open_security_db.
Referenced by execute_query().
A_CO_DB::_instantiate_record | ( | $in_db_result | ) |
This creates a new record, based upon the class stored in the database.
$in_db_result | This is an associative array, with the results of the row, read from the database. |
Definition at line 181 of file a_co_db.class.php.
References CO_Lang_Common\$db_error_code_class_file_not_found, CO_Lang_Common\$db_error_code_class_not_created, CO_Lang\$db_error_desc_class_file_not_found, CO_Lang\$db_error_desc_class_not_created, CO_Lang\$db_error_name_class_file_not_found, and CO_Lang\$db_error_name_class_not_created.
Referenced by CO_Main_Data_DB\generic_search(), CO_Security_DB\get_all_login_objects(), CO_Security_DB\get_all_login_objects_with_access(), get_all_readable_records(), get_all_writeable_records(), CO_Security_DB\get_credentials_by_api_key(), CO_Security_DB\get_initial_record_by_id(), CO_Security_DB\get_initial_record_by_login_id(), get_multiple_records_by_id(), and CO_Security_DB\get_multiple_records_by_login_id().
A_CO_DB::can_i_see_this_record | ( | $in_id | ) |
This returns true, if the current user at least has read access to the record whose ID is provided..
This is "security safe," so that means that if the user does not have rights to the row, or the row does not exist, they will get false.
$in_id | This is the ID of the record to check. |
Definition at line 358 of file a_co_db.class.php.
References _create_security_predicate(), and execute_query().
A_CO_DB::delete_record | ( | $id | ) |
This deletes a record, based on its unique ID in the table. The logged-in user must have write permission for the record.
This double-checks after the delete, just to make sure the record was, indeed, deleted.
This is properly "screened" for security.
Definition at line 750 of file a_co_db.class.php.
References CO_Lang_Common\$pdo_error_code_failed_delete_attempt, CO_Lang_Common\$pdo_error_code_illegal_delete_attempt, CO_Lang\$pdo_error_desc_failed_delete_attempt, CO_Lang\$pdo_error_desc_illegal_delete_attempt, CO_Lang\$pdo_error_name_failed_delete_attempt, CO_Lang\$pdo_error_name_illegal_delete_attempt, _create_security_predicate(), and execute_query().
A_CO_DB::execute_query | ( | $in_sql, | |
$in_parameters = NULL , |
|||
$exec_only = false |
|||
) |
This is an accessor for the query execution method.
$in_sql | This is the SQL portion of the prepared statement. |
$in_parameters | This is an array of values to be used in the prepared statement. |
$exec_only | If true, then this means we do not expect a response. Default is false. |
Definition at line 292 of file a_co_db.class.php.
References _execute_query().
Referenced by CO_Security_DB\add_personal_token_from_current_login(), can_i_see_this_record(), CO_Security_DB\count_all_login_objects_with_access(), delete_record(), CO_Main_Data_DB\generic_search(), get_access_class_by_id(), CO_Security_DB\get_all_login_ids(), CO_Security_DB\get_all_login_objects(), CO_Security_DB\get_all_login_objects_with_access(), CO_Security_DB\get_all_personal_ids_except_for_id(), get_all_readable_records(), CO_Security_DB\get_all_tokens(), CO_Security_DB\get_all_user_objects_with_access(), CO_Security_DB\get_all_visible_logins(), CO_Main_Data_DB\get_all_visible_users(), get_all_writeable_records(), CO_Security_DB\get_credentials_by_api_key(), get_db_backup(), CO_Security_DB\get_initial_record_by_id(), CO_Security_DB\get_initial_record_by_login_id(), CO_Security_DB\get_logins_that_have_any_of_my_ids(), CO_Security_DB\get_logins_with_personal_ids(), get_multiple_records_by_id(), CO_Security_DB\get_multiple_records_by_login_id(), CO_Security_DB\get_personal_ids_for_id(), CO_Security_DB\get_security_ids_for_id(), get_single_raw_row_by_id(), CO_Security_DB\i_have_all_ids(), CO_Main_Data_DB\item_exists(), lock_record(), CO_Security_DB\remove_personal_token_from_this_login(), and write_record().
A_CO_DB::get_access_class_by_id | ( | $in_id | ) |
This returns the access class for the given ID.
This is "security safe," so that means that if the user does not have rights to the row, they will get NULL.
$in_id | This is the ID of the record to fetch. |
Definition at line 327 of file a_co_db.class.php.
References _create_security_predicate(), and execute_query().
A_CO_DB::get_all_readable_records | ( | $open_only = false , |
|
$in_this_id = NULL |
|||
) |
This returns instances of every readable record in the database readable by the logged-in user (or only "open" records, if no login).
This is properly "screened" for security.
$open_only | If true, then we will look for ONLY records with a NULL or 0 read_security_id, even if we are logged in. |
$in_this_id | If we are in "god mode," we can look for particular IDs. |
Definition at line 502 of file a_co_db.class.php.
References _create_security_predicate(), _instantiate_record(), and execute_query().
A_CO_DB::get_all_writeable_records | ( | $in_this_id = NULL | ) |
This returns instances of every writeable record in the database readable by the logged-in user (cannot be used by non-logged-in-users).
This is properly "screened" for security.
$in_this_id | If we are in "god mode," we can look for particular IDs. |
Definition at line 547 of file a_co_db.class.php.
References _create_security_predicate(), _instantiate_record(), and execute_query().
A_CO_DB::get_db_backup | ( | ) |
This is a special "God Mode-Only" method that dumps the entire table. It is used to generate a CSV backup file.
The user must be logged in as "God."
Definition at line 307 of file a_co_db.class.php.
References execute_query().
A_CO_DB::get_multiple_records_by_id | ( | $in_id_array, | |
$and_write = false |
|||
) |
This function returns one or more record instances, by their unique IDs in the table.
This is properly "screened" for security.
$in_id_array | This is an array of integers, each of which is the ID of a record to fetch. |
$and_write | If this is true, then we need modify permission for the record. |
Definition at line 444 of file a_co_db.class.php.
References _create_security_predicate(), _instantiate_record(), and execute_query().
Referenced by get_single_record_by_id().
A_CO_DB::get_single_raw_row_by_id | ( | $in_id, | |
$and_write = false |
|||
) |
This is a special method that does not apply a security predicate. It is used to force-reload record instances.
This should ONLY be called from the database reloader functions.
$in_id | This is the ID of the record to fetch. |
$and_write | If this is true, then we need modify permission for the record. |
Definition at line 391 of file a_co_db.class.php.
References _create_security_predicate(), and execute_query().
A_CO_DB::get_single_record_by_id | ( | $in_id, | |
$and_write = false |
|||
) |
This function returns a single record instance, by its unique ID in the table.
This is properly "screened" for security.
$in_id | This is the ID of the record to fetch. |
$and_write | If this is true, then we need modify permission for the record. |
Definition at line 422 of file a_co_db.class.php.
References get_multiple_records_by_id().
A_CO_DB::lock_record | ( | $in_record_id | ) |
This "locks" a given record by setting its read_security_id to -2.
$in_record_id | This is the unique ID of the record to be "locked." |
Definition at line 592 of file a_co_db.class.php.
References _create_security_predicate(), and execute_query().
A_CO_DB::write_record | ( | $params_associative_array | ) |
This updates or creates a database record (row), based on an associative array of parameters passed in.
If the 'id' column is 0 or NULL, then this will be a new record.
This is properly "screened" for security.
$params_associative_array | This is an associative array of parameters, where the key is the database column name. |
Definition at line 636 of file a_co_db.class.php.
References CO_Lang_Common\$pdo_error_code_illegal_write_attempt, CO_Lang\$pdo_error_desc_illegal_write_attempt, CO_Lang\$pdo_error_name_illegal_write_attempt, _create_security_predicate(), and execute_query().
|
protected |
Definition at line 52 of file a_co_db.class.php.
|
protected |
Definition at line 51 of file a_co_db.class.php.
A_CO_DB::$access_object |
Definition at line 53 of file a_co_db.class.php.
Referenced by CO_Security_DB\get_all_user_objects_with_access().
A_CO_DB::$class_description |
Definition at line 54 of file a_co_db.class.php.
A_CO_DB::$error |
Definition at line 55 of file a_co_db.class.php.
A_CO_DB::$table_name |
Definition at line 56 of file a_co_db.class.php.