You are here

gdpr_tasks.pages.inc in General Data Protection Regulation 7

Page callbacks for the GDPR Tasks module.

File

modules/gdpr_tasks/gdpr_tasks.pages.inc
View source
<?php

/**
 * @file
 * Page callbacks for the GDPR Tasks module.
 */

/**
 * Request page for user.
 */
function gdpr_task_user_request($user) {
  return array(
    'message' => array(
      '#markup' => 'Make data access requests.',
    ),
  );
}

/**
 * Request page for user.
 */
function gdpr_tasks_request($account, $gdpr_task_type) {
  $tasks = gdpr_tasks_get_user_tasks($account, $gdpr_task_type);
  $pending = FALSE;
  if ($tasks) {
    foreach ($tasks as $task) {
      if (in_array($task->status, array(
        'requested',
        'processed',
      ), TRUE)) {
        $pending = TRUE;
      }
    }
  }
  if ($pending) {
    drupal_set_message(t('You already have a pending task.'), 'warning');
  }
  else {
    global $user;
    $values = array(
      'type' => $gdpr_task_type,
      'user_id' => $account->uid,
      'requested_by' => $user->uid,
    );
    $task = entity_create('gdpr_task', $values);
    $task
      ->save();

    // Send confirmation email to user.
    if ($task->requested_by == $task->user_id) {
      gdpr_tasks_send_mail('task_requested_self', $task);
    }
    else {
      gdpr_tasks_send_mail('task_requested_other', $task);
    }
    drupal_set_message(t('Your request has been logged.'));
  }
  drupal_goto("user/{$account->uid}/gdpr/requests");
}

Functions

Namesort descending Description
gdpr_tasks_request Request page for user.
gdpr_task_user_request Request page for user.