Browse Source

Import from osinet internal server.

Frederic G. Marand 15 years ago
commit
a41e69be04
2 changed files with 81 additions and 0 deletions
  1. 11 0
      project_issue_extend.info
  2. 70 0
      project_issue_extend.module

+ 11 - 0
project_issue_extend.info

@@ -0,0 +1,11 @@
+; $Id: project_issue_extend.info,v 1.1 2009-12-03 20:55:33 root Exp $
+name = Project issue extend
+description = Provides the ability to assign issues to designated users
+dependencies = project project_issue
+package = Project
+
+; Information added by drupal.org packaging script on 2007-08-19
+version = "5.x-1.0"
+project = "project_issue_extend"
+datestamp = "1187567710"
+

+ 70 - 0
project_issue_extend.module

@@ -0,0 +1,70 @@
+<?php
+/**
+ * A small module to assign issues to users
+ * Derived from Nedjo Rogers' module for 4.7
+ * See http://drupal.org/node/4354 for the discussion
+ *
+ * @version $Id: project_issue_extend.module,v 1.1 2009-12-03 20:55:33 root Exp $
+ * @license GPL 2.0
+ *
+ */
+
+define(PROJECT_ISSUE_PERM_SETTER, 'assign project issues to others');
+define(PROJECT_ISSUE_PERM_GETTER, 'be assigned project issues');
+
+/**
+ * Implementation of hook_help().
+ */
+function project_issue_extend_help($section) {
+  switch ($section) {
+    case 'admin/modules#description':
+      return t('Allow assigning of issues to any member with appropriate permissions.');
+  }
+}
+
+/**
+ * Implementation of hook_perm().
+ */
+function project_issue_extend_perm() {
+  return array(
+    PROJECT_ISSUE_PERM_SETTER,
+    PROJECT_ISSUE_PERM_GETTER,
+  );
+}
+
+/**
+ * Implementation of hook_form_alter().
+ *
+ * Add all users to select for assigning issues.
+ */
+function project_issue_extend_form_alter($form_id, &$form) {
+  if (in_array($form_id, array('project_issue_node_form', 'comment_form', /* was 'project_comment_form' */))
+    && user_access(PROJECT_ISSUE_PERM_SETTER)) {
+    $options = array();
+    $result = db_query(
+        "SELECT DISTINCT u.uid, u.name "
+      . "FROM {users} u "
+      . "INNER JOIN {users_roles} ur ON u.uid  = ur.uid "
+      . "INNER JOIN {role}        r  ON ur.rid = r.rid "
+      . "INNER JOIN {permission}  p  ON p.rid  = r.rid "
+      . "WHERE p.perm like '%%%s%%' "
+      . "ORDER BY u.name",
+      PROJECT_ISSUE_PERM_GETTER);
+    while ($user = db_fetch_object($result)) {
+      $options[$user->uid] = $user->name;
+    }
+
+    switch ($form_id) {
+      case 'project_issue_node_form':
+        if ($form['issue_info']['assigned']) {
+          $form['issue_info']['assigned']['#options'] += $options;
+        }
+        break;
+      case 'comment_form': // project_comment_form
+        if ($form['original_issue']['issue_info']['assigned']) {
+          $form['original_issue']['issue_info']['assigned']['#options'] += $options;
+        }
+        break;
+    }
+  }
+}