2

I have 2 content types:

  • Organisation (Name, address, tel, places)

  • Internship (Reference to Organisation , Student, Mentor, ...)

Now for example I have an organisation with 2 places for students. So when this organisation is selected as a refernce in Internship node creation, it must check for the available places. If the pace is available then it needs to save the node else it should give an error message.

I have tried node limit module but it is not a solution.

Thanks.

  • for Which version of drupal? – Mathankumar Sep 26 '12 at 15:12
  • Drupal 6 - Open atrium install profile – kim.kaho Sep 27 '12 at 8:27
0

My point of view this can be done at node submission time

Alter the access callback for the menu callback:

function custom_module_menu_alter(&$items){
    $items['node/add/internship']['access callback'] = 'my_custom_access_callback'
    // Next line needed for Drupal 7
    unset($items['node/add/review-sites']['access arguments']);
}

Add a function as your custom access callback:

function my_custom_access_callback() {
   global $user;

   /*Now check the selected organization which you are selecting from dropdown of entity reference and call it as $no_of_places. Also check the existing internship with same referenced organization and call it as $occupied_seats*/

   if ($no_of_places > $occupied_seats && user_access("create internship")) {
     return TRUE;
   }
   else{
     drupal_set_message('Print message about exceeded limit and/or user permissions.');
     return FALSE;
   }
}
  • Thanks for the reply. So the access callback is executed at the moment of selecting a organisation at the internship creation form? I will check this out. – kim.kaho Sep 27 '12 at 8:36
  • Any idea how to ged the selected refernce id? – kim.kaho Sep 28 '12 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.