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

Created on 24 March 2009, over 15 years ago
Updated 22 May 2023, about 1 year ago

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.

/**
 * 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.

✨ Feature request
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇺🇸United States nicholas.alipaz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024