Helper Functions

Community Auth has a form helper extensions and custom serialization helper and auth helper files, providing an enhanced form_open function, and adding some new functions for you to use.

The serialization helper is autoloaded, but you do need to load the form helper or auth helper to use them.

Is Role?

// Check if logged in user is an admin
$bool = is_role('admin');

The is_role() function allows you to check if a logged in user is a specific role.

Location: /application/third_party/community_auth/helpers/auth_helper.php


ACL Permits?

// Check if logged in has permission to do something
$bool = acl_permits('administration.delete_users');

The acl_permits() function allows you to check if a logged in user has a specific ACL permission. For more information, see: ACL (Access Control List)

Location: /application/third_party/community_auth/helpers/auth_helper.php


DB Table

// Retrieve the true name of a database table,
// As long as it is listed in the db_tables.php config
$db_table_name = db_table('users');

The db_table() function will automatically apply your CodeIgniter DB prefix, should you be using one. If the table you are calling for does not exist, CI should throw an error.

Location: /application/third_party/community_auth/helpers/auth_helper.php


Form Open

// Formatted for narrow screens
$open_tag = form_open( 
	$action     = '', 
	$attributes = array(), 
	$hidden     = array() 
);

The form_open() function modifies CodeIgniter’s form_open() function. It provides support for https, as well as injecting a hidden input for the Tokens library.

Location: /application/third_party/community_auth/helpers/MY_form_helper.php


Is Serialized?

$bool = is_serialized( $data );

Borrowed from WordPress, the is_serialized() function will test whether or not the data passed to it is serialized. This is handy to use before calling any unserialization function, because PHP fails hard when you attempt to unserialize data that has not been serialized.

Location: /application/third_party/community_auth/helpers/serialization_helper.php


Serialize Data

$data = serialize_data( $data );

Borrowed from CodeIgniter 2.X, the serialize_data() function provides a string replacement for backslashes.

Location: /application/third_party/community_auth/helpers/serialization_helper.php


Unserialize Data

$data = unserialize_data( $data );

Borrowed from CodeIgniter 2.X, the unserialize_data() function provides a way to unserialize data that was serialized with the serialize_data() function.

Location: /application/third_party/community_auth/helpers/serialization_helper.php