fetchObject(); //used for development only //menu_rebuild(); } /** * Implementation of hook_permission(). * D7 done. */ function booking_permission() { return array( 'access booking form' => array( 'title' => t('Access the booking form'), ), 'access lists' => array( 'title' => t('Access the coming and waiting lists'), ), 'access booking summary' => array( 'title' => t('Access the summary of booking forms'), ), 'access reports' => array( 'title' => t('Access booking reports'), ), 'create bookings' => array( 'title' => t('Create a booking'), ), 'view bookings' => array( 'title' => t('Access all bookings'), ), 'edit bookings' => array( 'title' => t('Edit all bookings'), ), ); } /** * Implementation of hook_menu(). */ function booking_menu() { global $event; booking_init(); //handle the case where the event hasn't been defined yet $bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event'; $items = array(); $items['admin/config/booking'] = array( /* 'title' => 'Booking module configuration', 'description' => 'Configure the Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_admin'), 'access arguments' => array('access administration pages'), */ 'title' => 'Booking module configuration', 'description' => 'Configure the Booking module', 'position' => 'left', 'weight' => -100, 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('administer site configuration'), 'file' => 'system.admin.inc', 'file path' => drupal_get_path('module', 'system'), //'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/config/booking/general'] = array( 'title' => 'Booking module general configuration', 'description' => 'Configure general settings for Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_admin'), 'access arguments' => array('administer site configuration'), //'type' => MENU_DEFAULT_LOCAL_TASK, //'position' => 'left', 'weight' => -100, ); //http://www.akchauhan.com/create-drupal-form-using-theme_table-like-module-list-form/ $items['admin/config/booking/text'] = array( 'title' => 'Booking module text definitions', 'description' => 'Configure text used in the CYC Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_tokens_admin'), 'access arguments' => array('administer site configuration'), //'type' => MENU_LOCAL_TASK, ); $items['admin/config/booking/prices'] = array( 'title' => 'Booking module price settings', 'description' => 'Configure prices for the Event Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_price_admin'), 'access arguments' => array('administer site configuration'), //'type' => MENU_LOCAL_TASK, ); $items['admin/config/booking/events'] = array( 'title' => 'Booking module event settings', 'description' => 'Configure events for the Event Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_event_admin'), 'access arguments' => array('administer site configuration'), //'type' => MENU_LOCAL_TASK, ); $items['admin/config/booking/variety'] = array( 'title' => 'Booking module variety sessions', 'description' => 'Configure variety sessions for the Event Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_variety_admin'), 'access arguments' => array('administer site configuration'), //'type' => MENU_LOCAL_TASK, ); $items['booking'] = array( 'title' => $bookingTitle . ' Booking Form', 'page callback' => 'booking_register_page', 'access arguments' => array('access booking form'), 'type' => MENU_NORMAL_ITEM, ); $items['confirm/%'] = array( 'title' => 'Booking Payment', 'page callback' => 'booking_confirm_page', 'page arguments' => array(3), //include the temporary id 'access arguments' => array('access booking form'), 'type' => MENU_CALLBACK, ); $items['balance/%'] = array( 'title' => 'Registration Final Payment', 'page callback' => 'booking_balance_page', 'page arguments' => array(3), //include the temporary id 'access arguments' => array('access booking form'), 'type' => MENU_CALLBACK, ); //Various reports $items['admin/booking/summary'] = array( 'title' => 'Booking Summary', 'description' => 'List people and their payments for the current event', 'page callback' => 'booking_report_summary', 'access arguments' => array('access reports'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/booking/paypal'] = array( 'title' => 'Booking Paypal Summary', 'description' => 'List paypal payments', 'page callback' => 'booking_report_paypal_payments', 'access arguments' => array('access reports'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/booking/manual-email'] = array( 'title' => 'Manually Email People', 'description' => 'Send manual email to registered people', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_manual_email'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/booking/manual-payments'] = array( 'title' => 'Manual Payment Processing', 'description' => 'Manually process peoples payments', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_manual_payment_admin'), 'access arguments' => array('edit bookings'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/booking/csv'] = array( 'title' => 'Booking Report', 'description' => 'Download a csv of people registered for the current event', 'page callback' => 'booking_csv_report', 'access arguments' => array('access reports'), 'type' => MENU_NORMAL_ITEM, ); $items['admin/booking/import-data'] = array( 'title' => 'Booking Upload Data', 'description' => 'Upload a csv of containing payment data', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_import_data_admin'), 'access arguments' => array('edit bookings'), 'type' => MENU_NORMAL_ITEM, ); $items['coming'] = array( 'title' => "Who's Coming?", 'page callback' => 'booking_coming_page', 'access arguments' => array("access lists"), 'type' => MENU_NORMAL_ITEM, ); $items['waitinglist'] = array( 'title' => "Who's on the waiting list?", 'page callback' => 'booking_waitinglist_page', 'access arguments' => array("access lists"), 'type' => MENU_NORMAL_ITEM, ); //The administration menu $items['admin/config/booking/prices/create'] = array( 'title' => 'Add New Price Entry', 'description' => 'Add priceentry for the Booking module', 'page callback' => 'drupal_get_form', //'page arguments' => array('booking_price_create'), 'page arguments' => array('booking_price_form', true), 'access arguments' => array('access administration pages'), 'type' => MENU_LOCAL_ACTION, ); $items['admin/config/booking/prices/%/edit'] = array( 'title' => 'Edit Price', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_price_form', false, 4), 'access arguments' => array('access administration pages'), 'type' => MENU_CALLBACK, ); $items['admin/config/booking/events/create'] = array( 'title' => 'Add New Event', 'description' => 'Add event for the Booking module', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_event_form', true), 'access arguments' => array('access administration pages'), 'type' => MENU_LOCAL_ACTION, ); $items['admin/config/booking/events/%/edit'] = array( 'title' => 'Edit Event', //'page callback' => 'booking_event_create', //'page arguments' => array(3), 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_event_form', false, 4), 'access arguments' => array('access administration pages'), 'type' => MENU_CALLBACK, ); $items['admin/config/booking/variety/create'] = array( 'title' => 'Add New Variety Session', 'description' => 'Add variety session for the Booking module', 'page callback' => 'drupal_get_form', //'page arguments' => array('booking_price_create'), 'page arguments' => array('booking_variety_form', true), 'access arguments' => array('access administration pages'), 'type' => MENU_LOCAL_ACTION, ); $items['admin/config/booking/variety/%/edit'] = array( 'title' => 'Edit Variety Session', 'page callback' => 'drupal_get_form', 'page arguments' => array('booking_variety_form', false, 4), 'access arguments' => array('access administration pages'), 'type' => MENU_CALLBACK, ); //the paypal IPN $items[BOOKING_PAYPAL_IPN_PATH] = array( 'type' => MENU_CALLBACK, 'page callback' => 'booking_paypal_ipn', 'access callback' => TRUE ); return $items; } /** * Describe the nodes we are going to define to model content specific to the booking module * D7 done */ function booking_node_info() { return array( 'booking' => array( 'name' => t('Registration'), 'base' => 'booking', 'description' => t('This node represents a booking into an event.'), ) ); } /** * Implementation of access related hooks for booking_registration node type. */ function booking_node_access($node, $op, $account) { $type = is_string($node) ? $node : $node->type; if ($type == 'booking' && in_array($type, node_permissions_get_configured_types())) { //watchdog('booking', "Booking node_access processing user id '!account' performing operation !op for node type !type. @info", // array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE))); if ($op == 'view') { //watchdog('booking', 'Booking node_access checking permissions for view operation.'); if (user_access('view bookings', $account)) return NODE_ACCESS_ALLOW; } elseif ($op == 'create') { //watchdog('booking', 'Booking node_access checking permissions for create operation.'); if (user_access('create bookings', $account)) return NODE_ACCESS_ALLOW; //create is a special case, since typically anonymous users will be creating a booking node via the form anyway //rather than logging a denied message for each registration, return denied here else return NODE_ACCESS_DENY; } elseif ($op == 'update' || $op == 'delete') { if (user_access('edit bookings', $account)) return NODE_ACCESS_ALLOW; } //no permission to view this information //watchdog('booking', "Booking node_access denying uid !account performing operation !op. @info", // array('!account' => $account->uid, '!op' => $op, '@info' => var_export($account, TRUE))); watchdog('booking', "Booking node_access denying user id '!account' performing operation !op for node type !type. @info", array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE))); return NODE_ACCESS_DENY; } /* else { watchdog('booking', "hook_node_access processing uid !account performing operation !op for node type !type. @info", array('!account' => $account->uid, '!op' => $op, '!type' => $type, '@info' => var_export($account, TRUE))); } */ /* if ($op == 'view') return user_access('view all bookings', $account); if ($op == 'create') return user_access('create bookings', $account); if ($op == 'update' || $op == 'delete') return user_access('edit bookings', $account); */ } /** * Implementation of hook_theme(). */ function booking_theme() { return array( 'booking_details' => array('arguments' => array('node' => NULL)), //'booking_price_admin' => array('arguments' => array('form' => NULL)) ); } /** * Implementation of hook_mail(). */ function booking_mail($key, &$message, $params) { $message['subject'] = $params['subject']; $message['body'][] = $params['body']; } /** * Registration node modification hooks for booking nodes. */ function booking_insert($node) { //moved to booking.register.inc watchdog('booking', 'Inserting person: @info', array('@info' => var_export($node, TRUE))); _booking_insert($node); } function booking_update($node) { //moved to booking.register.inc _booking_update($node); } function booking_delete($node) { //moved to booking.register.inc _booking_delete($node); } //Update node table specific attributes before hook_update is called function booking_node_presave($node) { global $event; if($node->type == 'booking') { $node->title = t('!event registration: !name', array('!event' => $event->booking_eventname, '!name' => $node->booking_firstname . ' ' . $node->booking_lastname)); //watchdog('booking', 'Presave of person: @info', array('@info' => var_export($node, TRUE))); } }