deny (fail closed)
return false;
}
}
/*
* Enforce a capability at the top of a page or handler - bounce the contact out if they lack it.
*/
function enforceContactCan($capability) {
if (!contactCan($capability)) {
redirect("post.php?logout");
}
}
/*
* The empty state for the portal's list pages.
*
* Every list page here renders a header row and then a while loop, so a client
* with no assets, no quotes or no documents used to get a table with nothing
* under it - indistinguishable from a page that failed to load. This says so
* instead.
*
* Default is neutral, for a list that simply has nothing in it yet. Pass
* 'success' where empty is genuinely good news (nothing owed, nothing unpaid).
*/
function portalEmptyState($message, $icon = 'fa-inbox', $type = 'secondary') {
return '
' . $message . '
';
}
/*
* Returns appropriate FontAwesome icon for file extension
*/
function getFileIcon($file_extension) {
$file_extension = strtolower($file_extension);
// Document icons
if (in_array($file_extension, ['pdf'])) {
return 'file-pdf';
} elseif (in_array($file_extension, ['doc', 'docx'])) {
return 'file-word';
} elseif (in_array($file_extension, ['xls', 'xlsx'])) {
return 'file-excel';
} elseif (in_array($file_extension, ['ppt', 'pptx'])) {
return 'file-powerpoint';
} elseif (in_array($file_extension, ['txt', 'md', 'rtf'])) {
return 'file-alt';
} elseif (in_array($file_extension, ['zip', 'rar', '7z', 'tar', 'gz'])) {
return 'file-archive';
} elseif (in_array($file_extension, ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'])) {
return 'file-image';
} elseif (in_array($file_extension, ['mp4', 'avi', 'mov', 'wmv', 'flv'])) {
return 'file-video';
} elseif (in_array($file_extension, ['mp3', 'wav', 'ogg', 'flac'])) {
return 'file-audio';
} elseif (in_array($file_extension, ['html', 'htm', 'css', 'js', 'php', 'py', 'java'])) {
return 'file-code';
} else {
return 'file';
}
}