Should be able to convert to "Project Issues" node type

nicholas.alipaz - March 24, 2009 - 21:24
Project:Comment mover
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed
Description

I noticed that I cannot convert a comment to a "Project Issues" node type. This is because the "Project Issues" node type must have a project namespace specified in addition to the normal add/node/project-issues/xxx.

This said I attempted my hand at making it work. I would provide a patch but I don't feel the way I accomplished it to be worthy of a patch. If someone might be interested in modifying my code to be "patch-worthy" that would be cool.

The only thing I modified was the function comment_mover_promote_form. Please see below for the changes I made, I have provided my entire modified function.

<?php
/**
* Displays node type select in block
*
*/
function comment_mover_promote_form($form_state) {
 
$form = array();
 
$options = array();
  foreach (
node_get_types() as $node_type) {
   
$type = $node_type->type;
   
$name = $node_type->name;
    if (
node_access('create', $type) && variable_get("commentmover_promotion_$type", FALSE)) {
     
$options[$type] = $name;
    }
  }
 
// start modification to support "Project Issues" Node Type
 
$project_issue_options_raw = project_projects_select_options($uris); // get an array of id's for the projects
 
$project_issue_options_keys = array(); // set up key array
 
$project_issue_options_vals = array(); // set up vals array
 
foreach ($project_issue_options_raw as $type) { // each of the categories that projects reside in
   
foreach ($type as $key => $val) { // each of the projects
     
$node = node_load($key); // load the node to get to some of the info from each project
     
$uri = $node->project['uri']; // the namespace for the project
     
array_push($project_issue_options_keys, 'project_issue/'.$uri); // ex: "project_issue/my_project" make the keys
     
array_push($project_issue_options_vals, $val." Issue"); // this will be the project's name followed by the word " Issues"
   
}
  }
 
$project_issue_options = array_combine($project_issue_options_keys, $project_issue_options_vals); // combine the keys and vals into one array
 
$options = $options+$project_issue_options; // tack on our project issues array to the options array
 
foreach ($options as $opt) { // do this to assign a $type to each of the project issues items
   
if (variable_get("commentmover_promotion_$type", FALSE)) {
     
$options[$type] = 'Issue'; // all project issue items get the same $type ("Issue")
   
}
  }
 
// end modification to support "Project Issues" Node Type
 
if (!empty($options)) {
   
$form['type'] = array(
     
'#type' => 'select',
     
'#title' => t('Convert to'),
     
'#default_value' => 'forum',
     
'#options' => $options,
    );
   
$form['submit'] = array('#type' => 'submit', '#value' => t('Convert'));
  }
  return
$form;
}
?>

I am not sure what happens if the user does not have the "Project Issue" node type enabled in the comment mover settings. I am also not really sure what would happen if the location "project_issue/my_project" was somehow altered. Not really sure if that is possible either.

Hope someone can use what I have to assist in the addition of this feature to the module. Thanks.

#1

dragonwize - March 25, 2009 - 01:19
Status:active» postponed

Thanks for bringing this exception to out attention nicholas. I will keep this in mind when I am writing up 2.x series.

 
 

Drupal is a registered trademark of Dries Buytaert.