OpenCraft
Follow OC!
  • Home
  • About
  • Solutions
  • Portfolio
  • Clients
  • Blog
  • Contact

How to associate default users with projects in 'Case Tracker' module?

Sun, 2008-03-16 16:51
Tags:
  • coding
  • drupal
By: 
Ahmed Mowafy

To associate default user in case tracker project:

1-Add a CCK user reference field "Default assignee" in the project content type.

2-Create ajax function on .js file :

function get_default_assignee(path, field_id) {
   var field = $('#'+ field_id).val();
   $.ajax({
    async:true,
    type:"GET",
    url:path + "get/default/assignee/" + field,
    success:function(data) {
     $("input[@id=edit-assign-to]").attr('value',data);
    }
  });
 }

3-In your .module file create menu item :

$items[] = array(
   'path'     => 'get/default/assignee',
   'title'    => t('Get default assignee'),
   'callback' => 'your_function_name',
   'access'   => TRUE,
   'type'     => MENU_CALLBACK,
 );

4-Create the callback for ajax function also in .module file:

function your_function_name() {
   $field_id = arg(3);
   $node = node_load(array('nid' => $field_id));
   $default_user = user_load(array('uid' => $node->field_default_assignee[0]['uid']));
   print $default_user->name;
   exit;
 }

5-In form_alter call the ajax function in 'Project' field:

if ($form['casetracker_case_information']['assign_to']['#default_value'] == 'Anonymous') {
   drupal_set_html_head("<script type=\"text/javascript\"> 
   $(document).ready(function(){
   get_default_assignee('".base_path() ."','edit-pid')}) 
     </script>");
 }

The End

  • amowafy's blog

Our work

Reuters Intranet

Reuters Business Direct team approached OpenCraft to propose an...

AUC Google Apps Migration

Google and AUC formed a partnership to enhance the services...

View our complete portfolio

Related posts

  • Beware PHP $_REQUEST!
  • Run webinject (nagios plugin) for drupal projects
  • Coloring 1pixelout flash player in audio module
  • Apache MultiViews automatically appends file extensions
  • Enabling clean URLs for Drupal on a clean Ubuntu

More posts by this author

  • Run webinject (nagios plugin) for drupal projects

OpenCraft

  • About
  • Team
  • Process
  • Community
  • Media Kit
  • Portfolio
  • Clients
  • Industries
    • Social economic development
    • Multimedia culture
  • Services
    • Drupal development
    • Information architecture
    • Open source software development
    • Social network engineering
  • Request quote
  • Contact
  • Search
Blog

Our profiles at:

Drupal Google
rss

Creative Commons License
search