Helper Functions

Community Auth has a form helper extensions and a custom serialization helper, 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 to use it.

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.

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)

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.

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.

Serialize Data

$data = serialize_data( $data );

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

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.