function _fillpdf_add_publish_completed_orders_permission in FillPDF 7
Same name and namespace in other branches
- 7.2 fillpdf.install \_fillpdf_add_publish_completed_orders_permission()
Allow anyone to fill Completed orders by default.
This is subject to having other required permissions such as view own orders. Only do this once, ever.
3 calls to _fillpdf_add_publish_completed_orders_permission()
- fillpdf_install in ./
fillpdf.install - Implements hook_install().
- fillpdf_modules_enabled in ./
fillpdf.module - Implements hook_modules_enabled().
- fillpdf_update_7102 in ./
fillpdf.install - Let all roles use completed order data to fill PDFs by default.
File
- ./
fillpdf.install, line 141 - Install.
Code
function _fillpdf_add_publish_completed_orders_permission() {
if (module_exists('uc_order') && module_exists('user') && !variable_get('fillpdf_uc_order_initialized', FALSE)) {
$order_statuses = uc_order_status_list();
$completed_status = NULL;
foreach ($order_statuses as $order_status) {
if ($order_status['id'] == 'completed') {
$completed_status = $order_status['id'];
}
}
if ($completed_status) {
$roles = user_roles();
foreach ($roles as $rid => $title) {
user_role_grant_permissions($rid, array(
"publish {$completed_status} order data",
));
}
variable_set('fillpdf_uc_order_initialized', TRUE);
$fillpdf_permissions = fillpdf_permission();
drupal_set_message(t('FillPDF has automatically given all the roles the @permission permission. You can disable this from the Permissions page. This is the only time FillPDF will do this automatically.', array(
'@permission' => $fillpdf_permissions["publish {$completed_status} order data"]['title'],
)));
}
}
}