The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Contentment::SPOPS - This is the base class for all SPOPS DBI objects in Contentment

DESCRIPTION

All Contentment objects that use the SPOPS persistence framework are based from this object.

This class also heavily modifies the SPOPS security model. The last "S" of "SPOPS" is supposed to be for "Security," but I think their security model stinks. However, the SPOPS security model is relatively easy to replace, which is neat. Anyway, this class changes most of the way the SPOPS security model works, so if you've read SPOPS::Manual::Security, most of that knowledge doesn't apply here.

$dbh = Contentment::SPOPS::global_datasource_handle

Returns a database handle as configured in the main configuration file.

Contentment::SPOPS->_create_table($format, $table_name, $sql)

This is a helper method for creating tables on the fly. This first checks to see if $table_name exists in the database and does nothing if it does. Otherwise, this method will attempt to create the named table. The $format variable is used to state which RDBMS the given SQL was written for. If the format given differs from the database in use, then SQL::Translator is used to get the $sql into the appropriate format. Finally, the $sql is run in the database to create the table.

This is handy, but it's not very well tested. It is meant to give Contentment the ability to move to another database with very little overhead, but I haven't used it on anything but MySQL yet, so this is still all speculation.

$test = $obj->check_create($p)

This method is called to see if the user has permission to create instances of this object. It returns true if they may or false otherwise.

The implementation first checks to see if the current session belongs to a superuser or member of a supergroup. If so, access is immediately granted. Otherwise, it checks to see if a "can_create" method is defined in the configuration and returns whatever value is defined there if it is. Finally, it will fall back on the can_create method defined for the class (which should fallback to the one defined in Contentment::SPOPS if one isn't defined in the subclass).

$test = $obj->can_create($p)

Do not call this method directly to check security. Use check_create instead. This is used to define local creation policies.

This method checks Contentment::Security::Permission to see if the current user or one of the current groups qualifies for the "create" capability. If so, we return true. Otherwise, we return false.

$test = $obj->check_action_security($p)

This method is overridden to hook in the check_create method.

This method is called every time the user attempts to create, read, or write the object. If the action is a create action, then check_create is called. Otherwise, SPOPS own check_action_security is called.

$test = $obj->get_security($p)

This method is called either to check to see which permissions the user is granted to read or write a record or by SPOPS to check to see whether a given session should be granted those permissions.

This method checks to see what the maximum ability available to the current user and current groups and returns that level. The Contentment::Security::Permission class is checked to see if any general permission exists to give the user the "read" or "write" capabilities.

$test = $obj->is_superuser

Checks to see if the security model set in the Contentment configuration provides a method named is_superuser. If so, returns the value returned by that method. If not, returns false.

$test = $obj->is_supergroup

Checks to see if the security model set in the Contentment configuration provides a method named is_supergroup. If so, returns the value returned by that method. If not, returns false.

$user = $obj->global_current_user

Returns the object representing the current user if such an object can be found in the current session.

$groups = $obj->global_current_group

Returns the a reference to an array of objects representing the current groups if a user is defined for the current session. (I.e., If global_current_user returns undef, then so will this.)

SEE ALSO

SPOPS, SPOPS::Manual::Security, Contentment::Security

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>

COPYRIGHT AND LICENSE

Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.

Contentment is distributed and licensed under the same terms as Perl itself.