Index: cvs.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cvslog/cvs.module,v retrieving revision 1.106.2.19 diff -u -r1.106.2.19 cvs.module --- cvs.module 18 Sep 2006 10:37:43 -0000 1.106.2.19 +++ cvs.module 25 Sep 2006 10:47:02 -0000 @@ -383,6 +383,46 @@ * Implementation of hook_form_alter(). */ function cvs_form_alter($form_id, &$form) { + global $user; + + if ($user->uid && $form['#node']->pid && in_array($form_id, array('project_issue_node_form', 'project_comment_form'))) { + // Load and make sure we have a project to extract maintainer data from. + $project = node_load($form['#node']->pid); + if ($project->nid) { + // Only show maintainers and contributors who have been active in the last 180 days. + // TODO: move to setting? + $timestamp = time() - 180 * 24 * 60 * 60; + $options = array(); + + $result = db_query("SELECT u.name, u.uid, u.login FROM {users} u INNER JOIN {cvs_project_maintainers} cpm ON u.uid = cpm.uid WHERE cpm.nid = %d AND u.login > %d", $project->nid, $timestamp); + while ($maintainer = db_fetch_object($result)) { + $options[$maintainer->uid] = $maintainer->name; + } + + $result = db_query("SELECT f.uid, u.name FROM {cvs_files} f INNER JOIN {cvs_messages} m ON m.cid = f.cid INNER JOIN users u ON f.uid = u.uid WHERE f.uid != 0 AND f.nid = %d AND m.created > %d", $project->nid, $timestamp); + while ($maintainer = db_fetch_object($result)) { + $options[$maintainer->uid] = $maintainer->name; + } + + // Only let maintainers and administrators assign issues to others. + if ($options[$user->uid] || user_access('administer CVS')) { + asort($options); + switch ($form_id) { + case 'project_issue_node_form': + if ($form['issue_info']['assigned']) { + $form['issue_info']['assigned']['#options'] += array(t('Maintainers') => $options); + } + break; + case 'project_comment_form': + if ($form['project_issue_form']['issue_info']['assigned']) { + $form['project_issue_form']['issue_info']['assigned']['#options'] += array(t('Maintainers') => $options); + } + break; + } + } + } + } + if ($form_id == 'project_project_node_form') { $node = $form['#node']; $result = db_query("SELECT rid, name FROM {cvs_repositories}");