示例#1
0
 function initialise_booking()
 {
     // Assign the user id to the property model
     $user = wp_get_current_user();
     $this->booking->set_userid($user->ID);
     // Set permissions if they haven't already been set
     $role = get_role('author');
     if (!$role->has_cap('confirm_booking')) {
         $role->add_cap('read_booking');
         $role->add_cap('edit_booking');
         $role->add_cap('delete_booking');
         // Needed so they can upload files - well duh
         $role->add_cap('upload_files');
         // Author
         $role = get_role('author');
         $role->add_cap('read_booking');
         $role->add_cap('edit_booking');
         $role->add_cap('delete_booking');
         $role->add_cap('confirm_booking');
         // Editor
         $role = get_role('editor');
         $role->add_cap('read_booking');
         $role->add_cap('edit_booking');
         $role->add_cap('delete_booking');
         $role->add_cap('edit_bookings');
         $role->add_cap('edit_others_bookings');
         $role->add_cap('confirm_booking');
         // Administrator
         $role = get_role('administrator');
         $role->add_cap('read_booking');
         $role->add_cap('edit_booking');
         $role->add_cap('delete_booking');
         $role->add_cap('edit_bookings');
         $role->add_cap('edit_others_bookings');
         $role->add_cap('confirm_booking');
     }
     if (!post_type_exists(STAYPRESS_CONTACT_POST_TYPE)) {
         register_post_type(STAYPRESS_CONTACT_POST_TYPE, array('singular_label' => __('Contact', 'property'), 'label' => __('Contacts', 'property'), 'public' => true, 'show_ui' => false, 'publicly_queryable' => false, 'exclude_from_search' => true, 'hierarchical' => true, 'capability_type' => 'contact', 'edit_cap' => 'edit_contact', 'edit_type_cap' => 'edit_contacts', 'edit_others_cap' => 'edit_others_contacts', 'publish_others_cap' => 'publish_contacts', 'read_cap' => 'read_contact', 'delete_cap' => 'delete_contact'));
     }
     $defaultoptions = array('checkintext' => 'Check in', 'checkouttext' => 'Check out');
     $this->bookingoptions = SPBCommon::get_option('sp_booking_options', $defaultoptions);
     // Register shortcodes
     $this->register_shortcodes();
     // restrict search to only the available properties
     add_filter('staypress_process_search_negative', array(&$this, 'get_fullsearch_results_negative'), 10, 2);
     add_filter('staypress_process_list_negative', array(&$this, 'get_fullsearch_results_negative'), 10, 2);
     add_filter('staypress_process_tag_negative', array(&$this, 'get_fullsearch_results_negative'), 10, 2);
     add_filter('staypress_process_dest_negative', array(&$this, 'get_fullsearch_results_negative'), 10, 2);
     add_filter('staypress_process_near_negative', array(&$this, 'get_fullsearch_results_negative'), 10, 2);
     add_filter('staypress_process_unavailable_properties', array(&$this, 'process_unavailability_search'));
     add_filter('staypress_search_redirect_url', array(&$this, 'keep_availability_args'));
     add_filter('staypress_extend_short_search_form', array(&$this, 'append_availability_fields'), 10, 2);
     add_filter('staypress_extend_widget_search_form', array(&$this, 'append_availability_fields'), 10, 2);
     add_filter('staypress_extend_widget_advsearch_form', array(&$this, 'append_availability_fields'), 10, 2);
     add_filter('staypress_extend_shortadv_search_form', array(&$this, 'append_availability_fields'), 10, 3);
     // Headings which I may remove or move at a later date
     if (has_action('staypress_override_picker_cssjs')) {
         do_action('staypress_override_picker_cssjs');
     } else {
         if (!current_theme_supports('staypress_booking_script')) {
             wp_enqueue_script('jquery-widgetjs', SPBCommon::booking_url('js/jquery-ui-dates.min.js'), array('jquery'), $this->build);
             wp_enqueue_script('bookingpublicjs', SPBCommon::booking_url('js/public.js'), array('jquery'), $this->build);
             wp_localize_script('bookingpublicjs', 'booking', array('calendarimage' => SPBCommon::booking_url('images/calendar.png')));
         }
         if (!current_theme_supports('staypress_booking_style')) {
             wp_enqueue_style('jquery-datepickercss', SPBCommon::booking_url('css/jquery.ui.datepicker.css'), array(), $this->build);
             wp_enqueue_style('jquery-smoothnesscss', SPBCommon::booking_url('css/smoothness/datepicker.smoothness.css'), array(), $this->build);
         }
     }
 }
 function show_options_panel()
 {
     global $action, $page;
     $defaultoptions = array('checkintext' => 'Check in', 'checkouttext' => 'Check out');
     $bookingoptions = SPBCommon::get_option('sp_booking_options', $defaultoptions);
     $messages = array();
     $messages[1] = __('Your options have been updated.', 'membership');
     echo "<div class='wrap nosubsub'>";
     echo "<div class='innerwrap'>\n";
     echo "<h2><a href='' class='selected'>" . __('Edit Options', 'property') . "</a></h2>";
     echo "<div class='wrapcontents'>\n";
     if (isset($_GET['msg'])) {
         echo '<div id="upmessage" class="updatedmessage"><p>' . $messages[(int) $_GET['msg']];
         echo '<a href="#close" id="closemessage">' . __('close', 'property') . '</a>';
         echo '</p></div>';
         $_SERVER['REQUEST_URI'] = remove_query_arg(array('msg'), $_SERVER['REQUEST_URI']);
     }
     echo "<form action='" . admin_url("admin.php?page=" . $page) . "' method='post'>";
     echo "<input type='hidden' name='action' value='updateoptions' />";
     wp_nonce_field('update-booking-options');
     echo "<p>";
     echo __('The options below control the settings, text and urls of your StayPress installation. For multi-site installs, these may change the settings for <strong>all</strong> your sites, depending on your configuration.', 'booking');
     echo "</p>";
     echo "<h3>" . __('Search form labels', 'booking') . "</h3>";
     echo "<p>" . __('Use the settings options below to change the labels on the main search forms.', 'booking') . "</p>";
     echo "<table class='form-table'>";
     echo "<tbody>";
     echo "<tr valign='top'>";
     // Un translated for now
     echo "<th scope='row'>" . __('Check in label', 'booking') . "</th>";
     echo "<td>";
     echo "<input type='text' name='checkintext' value='" . esc_attr($bookingoptions['checkintext']) . "' class='narrow' />";
     echo "</td>";
     echo "</tr>";
     echo "<tr valign='top'>";
     // Un translated for now
     echo "<th scope='row'>" . __('Check out label', 'booking') . "</th>";
     echo "<td>";
     echo "<input type='text' name='checkouttext' value='" . esc_attr($bookingoptions['checkouttext']) . "' class='narrow' />";
     echo "</td>";
     echo "</tr>";
     echo "</tbody>";
     echo "</table>";
     do_action('staypress_booking_options_form', $bookingoptions);
     echo "<br style='clear:both;' />";
     echo "<p class='submit'>";
     echo "<input type='submit' name='Submit' class='button-primary' value='" . esc_attr('Update Options') . "' />";
     echo "</p>";
     echo "</form>\n";
     echo "</div> <!-- wrapcontents -->\n";
     echo "</div> <!-- innerwrap -->\n";
     // Start sidebar here
     echo "<div class='rightwrap'>";
     $this->show_options_rightpanel();
     echo "</div> <!-- rightwrap -->";
     echo "</div> <!-- wrap -->\n";
 }