/**
  * Returns the events, that a user is allowed to access
  * The result is a list of associative arrays [column]=>[name]
  * The user must posess:
  * - correct mandant
  * - access to correct topics
  * - The event must be in future
  * 
  * @param int $userID
  */
 public static function getAvailableEventsForUser($userID)
 {
     global $wpdb;
     $mandantID = EventDatabaseManager::getMandantID($userID);
     $query = "SELECT * FROM datr_Events JOIN datr_User_has_Topics \n            ON datr_Events.topicID = datr_User_has_Topics.topicID \n            JOIN datr_Addresses ON datr_Addresses.addressID = datr_Events.addressID \n            JOIN datr_User_has_Locations ON datr_User_has_Locations.locationID = datr_Addresses.locationID \n            AND datr_User_has_Locations.userID = datr_User_has_Topics.userID \n            WHERE datr_User_has_Topics.userID = {$userID} \n                AND mandantID = {$mandantID} \n                    AND (date_time > NOW() OR eventType = 'elearning')\n                    AND event_visible = 1\n                ORDER BY eventType, title_long    \n                ";
     $res = $wpdb->get_results($query, ARRAY_A);
     return EventDatabaseManager::getEventFullValuesArray($res);
 }