User login

Allow users to assign issues to other people in the project group (organic groups and project module integration)

Client requests began immediately with the launch of MyAgaric.com running Project module with Organic Groups:

How do I assign a bug to someone else? I would like to assign the "vol in bold" issue to [P].

Here is a first draft of a function used in our project module and organic groups integration.

Following this model which was proposed to add assignment to other CVS account holders on Drupal.org itself:

http://drupal.org/node/253825
http://drupal.org/files/issues/253825_12_drupalorg.patch

We at Agaric wrote this function, which uses the hooks already built into project.module and which will be released as its own or into some other project and organic groups integration module.

<?php
/**
 *
 *
 * From the issue "Allow project co-maintainers to assign issues to each other"
 * http://drupal.org/node/253825
 * http://drupal.org/files/issues/253825_12_drupalorg.patch
 * Adapted.
 */
function organic_project_project_issue_assignees(&$assigned, $node) {
  global $user;
  if (empty($user->uid) || empty($node->pid)) {
    return;
  }
  $project = node_load($node->pid);
  if (!isset($project) || $project->type != 'project_project') {
    return;
  }

// @TODO -get user list from URL path

  // this is what we add
  $og_members = array();
  $sql = og_list_users_sql(1);
  $res = db_query($sql, $project->nid);
  while ($row = db_fetch_object($res)) {
    $og_members[$row->uid] = $row->name;
  }
 
  $maintainers = array();
  // This is from the patch to the drupalorg module, no reason not to keep this functionality
  // Determine if the user has CVS access at all.  If not, the user can't be a maintainer
  // of the current project and thus we can skip the next, more expensive query.
  if (project_use_cvs($node->pid)) {
    if (db_result(db_query("SELECT COUNT(*) FROM {cvs_accounts} WHERE uid = %d AND status = %d", $user->uid, CVS_APPROVED))) {
      // Make an array with all maintainers of the current project.
      $result = db_query("SELECT cpm.uid, u.name FROM {cvs_project_maintainers} cpm INNER JOIN {users} u ON cpm.uid = u.uid WHERE cpm.nid = %d", $node->pid);
      $maintainers = array($project->uid => $project->name);  // this line confuses me
      while ($row = db_fetch_object($result)) {
        $maintainers[$row->uid] = $row->name;
      }

      // Determine if the current user is one of the maintainers of the project.
      if (isset($maintainers[$user->uid])) {
        unset($maintainers[$user->uid]);
      }
      else {
        return;
      }
    }
  }
// note to self --- the problem is that array_unique or merge is dumping the user ids
//  $new_assignees = array_unique(array_merge($maintainers, $og_members));
  // Add any maintainers of this project who are not already
  // in the $assigned array to the array.
//drupal_set_message('<pre>'. var_export($new_assignees,TRUE) .'</pre>'); 
  foreach ($maintainers as $uid => $name) {
    if (!isset($assigned[$uid])) {
      $assigned[$uid] = $name;
    }
  }
  foreach ($og_members as $uid => $name) {
    if (!isset($assigned[$uid])) {
      $assigned[$uid] = $name;
    }
  }
}
?>

For other integration, see http://agaricdesign.com/note/adding-and-modifying-organic-group-action-create-content-links

Resolution

Searched words: 
Organic groups project og gid

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.