function cf_convert_to_crud in Common Functionality 7.2
Same name and namespace in other branches
- 7 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
Justification: 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.
Return value
int A single numerical value that represents all 4 permissions.
Related topics
File
- ./
cf.module, line 134 - Common Functionality module.
Code
function cf_convert_to_crud($create, $read, $update, $delete) {
$crud = 0;
if ($create) {
$crud += 1;
}
if ($read) {
$crud += 2;
}
if ($update) {
$crud += 4;
}
if ($delete) {
$crud += 8;
}
return $crud;
}