Index: casetracker.module =================================================================== RCS file: /cvs/drupal/contributions/modules/casetracker/casetracker.module,v retrieving revision 1.111 diff -u -r1.111 casetracker.module --- casetracker.module 9 Jan 2007 16:35:16 -0000 1.111 +++ casetracker.module 29 Jan 2007 14:54:44 -0000 @@ -811,8 +811,34 @@ $node_types = node_get_types('names'); $rows = array(); while ($result = db_fetch_object($results)) { + + // providing preselected audience checkboxes for projects as groups (og) + // checking if project is group + $node_result = node_load($result->nid); + if ($node_result->type == 'group') { + $querystring = 'gids[]='.$node_result->nid; + //checking if group-project is part of another group + if ($node_result->og_groups) { + foreach ($node_result->og_groups as $group) { + $querystring .= '&gids[]='.$group; + } + } + } + //checking if project is part of a group + elseif ($node_result->og_groups && $node_result->type !== 'group') { + $n = 0; + foreach ($node_result->og_groups as $group) { + $n == 0 ? $querystring = 'gids[]='.$group : $querystring .= '&gids[]='.$group; + $n = $n + 1; + } + } + //leaving empty if project has nothing to do with groups + else { + $querystring = NULL; + } + $operations = array(l(t('view cases'), 'casetracker/cases/'.$result->nid.'/all')); - foreach ($case_types as $case_type) { $operations[] = l(t('add !name', array('!name' => $node_types[$case_type])), 'node/add/'.$case_type.'/'.$result->nid); } + foreach ($case_types as $case_type) { $operations[] = l(t('add !name', array('!name' => $node_types[$case_type])), 'node/add/'.$case_type.'/'.$result->nid, array(), $querystring); } $rows[] = array_merge(array($result->project_number, l($result->title, 'node/'.$result->nid)), $operations); } if (count($rows) == 0) { $rows[] = array(array('data' => t('No projects found.'), 'colspan' => 3 + $colspan_count)); } @@ -866,9 +892,33 @@ $rows[] = array(t('Opened on:'), format_date($project->created, 'large')); $rows[] = array(t('Last modified:'), format_date($project->changed, 'large')); + // providing preselected audience checkboxes for projects as groups (og) + // checking if project is group + if ($project->type == 'group') { + $querystring = 'gids[]='.$project->nid; + //checking if group-project is part of another group + if ($project->og_groups) { + foreach ($project->og_groups as $group) { + $querystring .= '&gids[]='.$group; + } + } + } + //checking if project is part of a group + elseif ($project->og_groups && $project->type !== 'group') { + $n = 0; + foreach ($project->og_groups as $group) { + $n == 0 ? $querystring = 'gids[]='.$group : $querystring .= '&gids[]='.$group; + $n = $n + 1; + } + } + //leaving empty if project has nothing to do with groups + else { + $querystring = NULL; + } + $operations = array(); $node_types = node_get_types('names'); foreach (array_filter(variable_get('casetracker_case_node_types', array('casetracker_basic_case'))) as $type) { - $operations[] = l(t('add !name', array('!name' => $node_types[$type])), 'node/add/'.$type.'/'.$project->nid); + $operations[] = l(t('add !name', array('!name' => $node_types[$type])), 'node/add/'.$type.'/'.$project->nid, array(), $querystring); } $operations = implode(' | ', $operations); // ready for printing in our Operations table cell - delimited by a pipe. nonstandard. $rows[] = array(t('Operations:'), $operations.' | '.l(t('view all project cases'), 'casetracker/cases/'.$project->nid.'/all'));