You are here

function pmtask_token_values in Drupal PM (Project Management) 7

Implements hook_token_values().

File

pmtask/pmtask.module, line 771

Code

function pmtask_token_values($type, $object = NULL) {
  $values = array();
  $node = $object;
  if (($type == 'node' || $type == 'all') && $node->type === 'pmtask') {
    $values['pmtask-stepno'] = $node->stepno;
    $values['pmtask-organization-nid'] = $node->organization_nid;
    $values['pmtask-organization-title'] = $node->organization_title;
    $values['pmtask-project-nid'] = $node->project_nid;
    $values['pmtask-project-title'] = $node->project_title;
    $values['pmtask-parent-nid'] = $node->parent_nid;
    $values['pmtask-taskstatus'] = $node->taskstatus;
    $values['pmtask-taskpriority'] = $node->taskpriority;
    $values['pmtask-taskcategory'] = $node->taskcategory;
    $values['pmtask-durationunit'] = $node->durationunit;
    $values['pmtask-duration'] = $node->duration;
    $values['pmtask-price'] = $node->price;
    $values['pmtask-pricemode'] = $node->pricemode;
    if (module_exists('pmperson')) {

      // Project Assignee(s) e-mail
      if ($node->assigned_nid) {
        $values['pmtask-assigned-title'] = $node->assigned_title;
        $assignees_node = node_load($node->assigned_nid);

        // Assigned to one person
        if ($assignees_node->type === 'pmperson') {
          $values['pmtask-assigned-to-email'] = pmperson_primary_email($assignees_node);
        }
        else {
          $assignees_array = $assignees_node->members_array;
          $assignees = array();
          foreach ($assignees_array as $nid => $name) {
            $assignee = node_load($nid);
            $assignees[] = pmperson_primary_email($assignee);
          }
          $assigned = implode(", ", $assignees);

          // Return comma separated list of emails
          $values['pmtask-assigned-to-email'] = $assigned;
        }
      }
      else {
        $values['pmtask-assigned-to-email'] = NULL;
      }
    }
  }
  return $values;
}