You are here

function course_uc_token_values in Course 6

Implements hook_token_values().

File

modules/course_uc/course_uc.module, line 333

Code

function course_uc_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  if ($type == 'order') {
    foreach ($object->products as $product) {
      $node = node_load($product->nid);
      if (course_node_is_course($node)) {
        $line = $node->title . ' - ' . l('View course page', "node/{$node->nid}");

        // @todo should we be using a menu access callback like this? Why not
        // use course_take_course_access() instead?
        if (course_node_is_course($node) && course_take_course_menu_access($node)) {
          $line .= ' or ' . l('Take course now', "node/{$node->nid}/takecourse");
        }
        $courses[] = $line;
        $show_header = 1;
      }
      $items[] = l($node->title, "node/{$node->nid}");
    }
    if ($show_header) {
      $values['course-products-header'] = t("Here are the courses you have purchased:");
    }
    $values['course-products'] = theme('item_list', $courses);
    $values['all-products'] = theme('item_list', $items);
  }
  return $values;
}