Fix for modul-Zusatz

  1. /**
  2.  * Check if a user has a registration node and an event-registration node.
  3.  * @param $user
  4.  *   User object to check.
  5.  * @return
  6.  *   TRUE if the user has such nodes, otherwise FALSE.
  7.  */
  8. function user_has_unpublish_registration_nodes($account) {
  9.   if (!is_object($account) && !isset($account->uid)) {
  10.     watchdog('evlka', t('Checking for unpublished registrations failed.'), array(), WATCHDOG_ERROR);
  11.     return FALSE;
  12.   }
  13.   $has_registration = db_result(db_query("SELECT nid FROM {node} WHERE type = '%s' AND uid = %d AND status = %d", array('registration', $account->uid, 0)));
  14.   $has_event_registration = db_result(db_query("SELECT nid FROM {node} WHERE type = '%s' AND uid = %d AND status = %d", array('event_registration', $account->uid, 0)));
  15.   return ($has_registration && $has_event_registration);
  16. }
  17.  
  18. /**
  19.  * Get nid of user registration node.
  20.  *
  21.  * @param $user
  22.  *   User to get the node id from.
  23.  * @return
  24.  *   Node id of the user registration node for the given user.
  25.  */
  26. function get_user_registration_node_id($user) {
  27.   if (!is_object($account) && !isset($account->uid)) {
  28.     watchdog('evlka', t('Find registration node failed.'), array(), WATCHDOG_ERROR);
  29.     return FALSE;
  30.   }
  31.   return db_result(db_query("SELECT nid FROM {node} WHERE type = '%s' AND uid = %d", array('registration', $account->uid)));
  32. }
  33.  
  34. /**
  35.  * Get nid of user registration node.
  36.  *
  37.  * @param $user
  38.  *   User to get the node id from.
  39.  * @return
  40.  *   Node id of the user registration node for the given user.
  41.  */
  42. function get_event_registration_node_id($user) {
  43.   if (!is_object($account) && !isset($account->uid)) {
  44.     watchdog('evlka', t('Find event-registration node failed.'), array(), WATCHDOG_ERROR);
  45.     return FALSE;
  46.   }
  47.   return db_result(db_query("SELECT nid FROM {node} WHERE type = '%s' AND uid = %d", array('event_registration', $account->uid)));
  48. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.