You are here

function hosting_task_dangerous_task_is_allowed in Hosting 7.4

Same name and namespace in other branches
  1. 7.3 task/hosting_task.module \hosting_task_dangerous_task_is_allowed()

Guard against destructive tasks running on guarded Aegir entities.

1 call to hosting_task_dangerous_task_is_allowed()
hosting_add_task in task/hosting_task.module
Helper function to generate new task node

File

task/hosting_task.module, line 2045
Web server node type is defined here.

Code

function hosting_task_dangerous_task_is_allowed($task_type, $nid) {
  $allowed = TRUE;
  $guarded_nids = hosting_task_get_guarded_nodes();
  if (in_array($nid, $guarded_nids)) {
    $dangerous_tasks = hosting_task_get_dangerous_tasks();
    if (in_array($task_type, $dangerous_tasks)) {
      $node = node_load($nid);
      $map = array(
        ':task' => $task_type,
        ':title' => $node->title,
        ':type' => $node->type,
      );
      drupal_set_message(t('You cannot run dangerous :task task on guarded :type :title.', $map), 'warning');
      watchdog('hostmaster', 'Detected attempt to run dangerous :task task on guarded :type :title.', $map, WATCHDOG_WARNING);
      $allowed = FALSE;
    }
  }
  return $allowed;
}