function cf_convert_to_crud in Common Functionality 7
Same name and namespace in other branches
- 7.2 cf.module \cf_convert_to_crud()
Converts the passed arguments into a single number.
The passed arguments are booleans.
Crud works in the same way that the linux filesystem permissions tend to be:
- create = 1
- read = 2
- update = 4
- delete = 8
Why: For efficiency reasons it may make more sense to store these boolean values into a single database column similar to how the unix permission umask works.
Parameters
bool $create: Boolean that represents whether or not the CREATE flag is set to TRUE or FALSE.
bool $read: Boolean that represents whether or not the READ flag is set to TRUE or FALSE.
bool $update: Boolean that represents whether or not the UPDATE flag is set to TRUE or FALSE.
bool delete: Boolean that represents whether or not the DELETE flag is set to TRUE or FALSE.
array $function_history: (optional) An array of function names, ie: array('0' => 'my_function_name').
Return value
A single numerical value that represents all 4 permissions.
File
- ./
cf.module, line 205
Code
function cf_convert_to_crud($create, $read, $update, $delete, array $function_history = array()) {
$crud = 0;
if ($create) {
$crud += 1;
}
if ($read) {
$crud += 2;
}
if ($update) {
$crud += 4;
}
if ($delete) {
$crud += 8;
}
return $crud;
}