Browse Source

Merge branch 'feature/admin_create_resources' into develop

develop
Sam Black 1 year ago
parent
commit
e72f10df96
Signed by: samwwwblack GPG Key ID: 0FF0223994EA47D8
  1. 271
      admin/class-bespokomatic-ebs-admin.php
  2. 9
      admin/css/bespokomatic-ebs-admin.css
  3. 29
      admin/partials/bespokomatic-ebs-admin-resources.php
  4. 2
      bespokomatic-ebs.php
  5. 3
      includes/booked/Domain/Access/IResourceRepository.php
  6. 4
      includes/booked/Domain/Access/ResourceRepository.php
  7. 8
      includes/booked/Pages/Admin/ManageResourceGroupsPage.php
  8. 8
      includes/booked/Pages/Admin/ManageResourceStatusPage.php
  9. 7
      includes/booked/Pages/Admin/ManageResourceTypesPage.php
  10. 14
      includes/booked/Pages/Admin/ManageResourcesPage.php
  11. 2
      includes/booked/Pages/Page.php
  12. 2
      includes/booked/Presenters/Admin/ManageResourceGroupsPresenter.php
  13. 11
      includes/booked/Web/css/booked.css
  14. 12
      includes/booked/Web/scripts/admin/resource-groups.js
  15. 1
      includes/booked/Web/scripts/admin/resource-status.js
  16. 1
      includes/booked/Web/scripts/admin/resource-types.js
  17. 12
      includes/booked/Web/scripts/admin/resource.js
  18. 22
      includes/booked/Web/scripts/ajax-helpers.js
  19. 18
      includes/booked/lib/Application/Admin/ImageUploadDirectory.php
  20. 93
      includes/booked/lib/Common/SmartyPage.php
  21. 2
      includes/booked/lib/external/Smarty/Smarty.class.php
  22. 11
      includes/booked/tpl/Admin/Resources/manage_resource_groups.tpl
  23. 11
      includes/booked/tpl/Admin/Resources/manage_resource_status.tpl
  24. 16
      includes/booked/tpl/Admin/Resources/manage_resource_types.tpl
  25. 119
      includes/booked/tpl/Admin/Resources/manage_resources.tpl
  26. 4
      includes/booked/tpl/Admin/Resources/manage_resources_public.tpl
  27. 68
      includes/booked/tpl/Admin/Resources/manage_resources_set_editables.tpl
  28. 4
      includes/booked/tpl/Admin/Resources/resources_csv.tpl
  29. 17
      includes/class-bespokomatic-ebs-activator.php
  30. 80
      includes/class-bespokomatic-ebs.php
  31. 110
      includes/templates/Admin/Resources/manage_resources_set_editables.tpl
  32. 8
      includes/templates/globalfooter.tpl
  33. 1
      includes/templates/globalheader.tpl
  34. 14
      public/class-bespokomatic-ebs-public.php
  35. 2891
      public/css/booked-custom.css
  36. 7233
      public/css/bootstrap-custom.css
  37. BIN
      public/fonts/glyphicons-halflings-regular.eot
  38. 288
      public/fonts/glyphicons-halflings-regular.svg
  39. BIN
      public/fonts/glyphicons-halflings-regular.ttf
  40. BIN
      public/fonts/glyphicons-halflings-regular.woff
  41. BIN
      public/fonts/glyphicons-halflings-regular.woff2

271
admin/class-bespokomatic-ebs-admin.php

@ -74,7 +74,6 @@ class Bespokomatic_Ebs_Admin {
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
$this->page_name = $plugin_name . '-settings';
@ -82,14 +81,33 @@ class Bespokomatic_Ebs_Admin {
$this->plugin_options = array();
}
/**
* Define the Booked Scheduler ROOT_DIR if not already set.
*
* @since 0.1
*/
private function define_root_dir() {
if ( ! defined( 'ROOT_DIR' ) ) {
define( 'ROOT_DIR', BESPOKOMATIC_EBS_BOOKED_PATH );
}
}
/**
* Register the stylesheets for the admin area.
*
* @since 0.1
*/
public function enqueue_styles() {
$css_admin_prefix = $this->plugin_name . '-css-admin';
$css_admin_booked_prefix = $css_admin_prefix . '-booked';
$css_prefix = $this->plugin_name . '-css';
$css_booked_prefix = $css_prefix . '-booked';
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/bespokomatic-ebs-admin.css', array(), $this->version, 'all' );
wp_enqueue_style( $css_admin_prefix, plugin_dir_url( __FILE__ ) . 'css/bespokomatic-ebs-admin.css', array(), $this->version, 'all' );
// booked styles
wp_enqueue_style( $css_admin_booked_prefix . '_jquery_contextui', BESPOKOMATIC_EBS_BOOKED_URL . 'scripts/css/jquery.contextMenu.css', array( $css_booked_prefix . '_jqueryui' ), $this->version, 'all' );
wp_enqueue_style( $css_admin_booked_prefix . '_jquery_tree', BESPOKOMATIC_EBS_BOOKED_URL . 'scripts/css/jqtree.css', array( $css_booked_prefix . '_jqueryui' ), $this->version, 'all' );
}
@ -110,7 +128,7 @@ class Bespokomatic_Ebs_Admin {
* @since 0.1
*/
public function settings_setup() {
// General settings
// General settings.
$general_settings_name = $this->options_name . '_general';
register_setting(
@ -181,18 +199,29 @@ class Bespokomatic_Ebs_Admin {
array( $this, 'admin_main' )
);
add_submenu_page(
$this->plugin_name,
'Booked Scheduler Resources',
'Resources',
'manage_options',
$this->plugin_name . '-resources',
array( $this, 'admin_resources' )
);
add_submenu_page(
$this->plugin_name,
'Booked Scheduler Settings',
'Settings',
'manage_options',
$this->options_name,
$this->page_name,
array( $this, 'admin_settings' )
);
}
/**
* Admin main page
*
* @since 0.1
*/
public function admin_main() {
require_once plugin_dir_path( __FILE__ ) . 'partials/bespokomatic-ebs-admin-display.php';
@ -200,10 +229,244 @@ class Bespokomatic_Ebs_Admin {
/**
* Admin settings page
*
* @since 0.1
*/
public function admin_settings() {
$this->plugin_options['general'] = get_option( $this->options_name . '_general' );
require_once plugin_dir_path( __FILE__ ) . 'partials/bespokomatic-ebs-admin-settings.php';
}
/**
* Admin AJAX autocomplete
*/
public function ajax_admin_autocomplete() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Pages/Ajax/AutoCompletePage.php';
$page = new AutoCompletePage();
$page->PageLoad();
wp_die();
}
/**
* Admin resources page
*
* @since 0.1
*/
public function admin_resources() {
$tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : 'manage';
switch ( $tab ) {
case 'groups':
$page = $this->admin_resources_groups();
break;
case 'types':
$page = $this->admin_resources_types();
break;
case 'statuses':
$page = $this->admin_resources_statuses();
break;
case 'manage':
default:
$page = $this->admin_resources_manage();
break;
}
$page_name = $this->plugin_name . '-resources';
require_once plugin_dir_path( __FILE__ ) . 'partials/bespokomatic-ebs-admin-resources.php';
}
/**
* Admin manage resources page
*/
public function admin_resources_manage() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Pages/Admin/ManageResourcesPage.php';
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourcesPresenter.php';
$page = new ManageResourcesPage();
return $page;
}
/**
* Admin resources page POST
*
* @since 0.1
*/
public function post_admin_resources_manage() {
$page = $this->admin_resources_manage();
$page->PageLoad();
}
/**
* Admin resources AJAX
*
* @since 0.1
*/
public function ajax_admin_resources_manage() {
// booked's ActionPage understands `action=`, so remove WordPress's one
unset( $_GET['action'] );
$page = $this->admin_resources_manage();
$page->PageLoad();
wp_die();
}
/**
* Admin resource POST endpoints
*
* @since 0.1
*/
public function admin_resource_manage_post_endpoints() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourcesPresenter.php';
return new reflectionClass( 'ManageResourcesActions' );
}
/**
* Admin resource groups
*/
public function admin_resources_groups() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Pages/Admin/ManageResourceGroupsPage.php';
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourceGroupsPresenter.php';
// TODO: This should use WordPress role settings, for now assume admin
//$page = new RoleRestrictedPageDecorator(new ManageResourceGroupsPage(), array(RoleLevel::APPLICATION_ADMIN, RoleLevel::SCHEDULE_ADMIN, RoleLevel::RESOURCE_ADMIN));
$page = new ManageResourceGroupsPage();
return $page;
}
/**
* Admin resources groups page POST
*
* @since 0.1
*/
public function post_admin_resources_groups() {
$page = $this->admin_resources_groups();
$page->PageLoad();
}
/**
* Admin resources groups AJAX
*
* @since 0.1
*/
public function ajax_admin_resources_groups() {
// booked's ActionPage understands `action=`, so remove WordPress's one
unset( $_GET['action'] );
$page = $this->admin_resources_groups();
$page->PageLoad();
wp_die();
}
/**
* Admin resource groups POST endpoints
*
* @since 0.1
*/
public function admin_resource_groups_post_endpoints() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourceGroupsPresenter.php';
return new reflectionClass( 'ManageResourceGroupsActions' );
}
/**
* Admin resource types
*/
public function admin_resources_types() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Pages/Admin/ManageResourceTypesPage.php';
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourceTypesPresenter.php';
// TODO: This should use WordPress role settings, for now assume admin
//$page = new RoleRestrictedPageDecorator(new ManageResourceTypesPage(), array(RoleLevel::APPLICATION_ADMIN, RoleLevel::SCHEDULE_ADMIN, RoleLevel::RESOURCE_ADMIN));
$page = new ManageResourceTypesPage();
return $page;
}
/**
* Admin resources types page POST
*
* @since 0.1
*/
public function post_admin_resources_types() {
$page = $this->admin_resources_types();
$page->PageLoad();
}
/**
* Admin resources types AJAX
*
* @since 0.1
*/
public function ajax_admin_resources_types() {
// booked's ActionPage understands `action=`, so remove WordPress's one
unset( $_GET['action'] );
$page = $this->admin_resources_types();
$page->PageLoad();
wp_die();
}
/**
* Admin resource types POST endpoints
*
* @since 0.1
*/
public function admin_resource_types_post_endpoints() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourceTypesPresenter.php';
return new reflectionClass( 'ManageResourceTypesActions' );
}
/**
* Admin resource statuses
*/
public function admin_resources_statuses() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Pages/Admin/ManageResourceStatusPage.php';
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourceStatusPresenter.php';
// TODO: This should use WordPress role settings, for now assume admin
//$page = new RoleRestrictedPageDecorator(new ManageResourceStatusPage(), array(RoleLevel::APPLICATION_ADMIN, RoleLevel::SCHEDULE_ADMIN, RoleLevel::RESOURCE_ADMIN));
$page = new ManageResourceStatusPage();
return $page;
}
/**
* Admin resources status page POST
*
* @since 0.1
*/
public function post_admin_resources_statuses() {
$page = $this->admin_resources_statuses();
$page->PageLoad();
}
/**
* Admin resources status AJAX
*
* @since 0.1
*/
public function ajax_admin_resources_statuses() {
// booked's ActionPage understands `action=`, so remove WordPress's one
unset( $_GET['action'] );
$page = $this->admin_resources_statuses();
$page->PageLoad();
wp_die();
}
/**
* Admin resource status POST endpoints
*
* @since 0.1
*/
public function admin_resource_statuses_post_endpoints() {
$this->define_root_dir();
require_once BESPOKOMATIC_EBS_BOOKED_PATH . 'Presenters/Admin/ManageResourceStatusPresenter.php';
return new reflectionClass( 'ManageResourceStatusActions' );
}
}

9
admin/css/bespokomatic-ebs-admin.css

@ -1,4 +1,11 @@
/**
* All of the CSS for your admin-specific functionality should be
* included in this file.
*/
*/
.no-show {
display: none !important;
}
.wrap .bebs-wp {
margin-top: 1rem;
}

29
admin/partials/bespokomatic-ebs-admin-resources.php

@ -0,0 +1,29 @@
<?php
/**
* Provide resource settings
*
* @link https://www.bespokomatic.co.uk
* @since 0.1
*
* @package Bespokomatic_Ebs
* @subpackage Bespokomatic_Ebs/admin/partials
*/
$active_tab = 'manage';
if ( isset( $_GET['tab'] ) ) {
$active_tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : 'manage';
}
?>
<div class="wrap">
<h2>Resources</h2>
<h2 class="nav-tab-wrapper">
<a href="?page=<?php echo $page_name; ?>&tab=manage" class="nav-tab <?php echo $active_tab === 'manage' ? 'nav-tab-active' : ''; ?>">Manage</a>
<a href="?page=<?php echo $page_name; ?>&tab=groups" class="nav-tab <?php echo $active_tab === 'groups' ? 'nav-tab-active' : ''; ?>">Groups</a>
<a href="?page=<?php echo $page_name; ?>&tab=types" class="nav-tab <?php echo $active_tab === 'types' ? 'nav-tab-active' : ''; ?>">Types</a>
<a href="?page=<?php echo $page_name; ?>&tab=statuses" class="nav-tab <?php echo $active_tab === 'statuses' ? 'nav-tab-active' : ''; ?>">Statuses</a>
</h2>
<?php $page->PageLoad(); ?>
</div>

2
bespokomatic-ebs.php

@ -30,11 +30,13 @@ if ( ! defined( 'WPINC' ) ) {
}
define( 'BESPOKOMATIC_EBS_NAME', 'bespokomatic-ebs' );
define( 'BESPOKOMATIC_EBS_AJAX_PREFIX', 'bespokomatic_ebs' );
define( 'BESPOKOMATIC_EBS_VERSION', '0.1' );
define( 'BESPOKOMATIC_EBS_BOOKED_VERSION', '2.8.4' );
define( 'BESPOKOMATIC_EBS_BOOKED_MAJOR_VERSION', '2.8' );
define( 'BESPOKOMATIC_EBS_BOOKED_PATH', plugin_dir_path( __FILE__ ) . 'includes/booked/' );
define( 'BESPOKOMATIC_EBS_BOOKED_URL', plugins_url( 'includes/booked/Web/', __FILE__ ) );
define( 'BESPOKOMATIC_EBS_TEMPLATES_DIR', plugin_dir_path( __FILE__ ) . 'includes/templates/' );
define( 'BESPOKOMATIC_EBS_BOOKED_DB_VERSION', '2.8.4.20200810' );
define( 'BESPOKOMATIC_EBS_BOOKED_DB_PREFIX', 'bebs' );
define( 'BESPOKOMATIC_EBS_CONFIG_DB_VERSION', 'bebs_db_version' );

3
includes/booked/Domain/Access/IResourceRepository.php

@ -87,9 +87,10 @@ interface IResourceRepository
/**
* @param int|null $scheduleId
* @param IResourceFilter|null $resourceFilter
* @param bool|null $includeHidden
* @return ResourceGroupTree
*/
public function GetResourceGroups($scheduleId = null, $resourceFilter = null);
public function GetResourceGroups($scheduleId = null, $resourceFilter = null, $includeHidden = false);
/**
* @param int $resourceId

4
includes/booked/Domain/Access/ResourceRepository.php

@ -317,7 +317,7 @@ class ResourceRepository implements IResourceRepository
return $accessories;
}
public function GetResourceGroups($scheduleId = ResourceRepository::ALL_SCHEDULES, $resourceFilter = null)
public function GetResourceGroups($scheduleId = ResourceRepository::ALL_SCHEDULES, $resourceFilter = null, $includeHidden = false)
{
if (empty($scheduleId))
{
@ -352,7 +352,7 @@ class ResourceRepository implements IResourceRepository
while ($row = $resources->GetRow())
{
if ($row[ColumnNames::RESOURCE_STATUS_ID] == ResourceStatus::HIDDEN)
if ($row[ColumnNames::RESOURCE_STATUS_ID] == ResourceStatus::HIDDEN && !$includeHidden)
{
continue;
}

8
includes/booked/Pages/Admin/ManageResourceGroupsPage.php

@ -91,6 +91,14 @@ class ManageResourceGroupsPage extends ActionPage implements IManageResourceGrou
parent::__construct('ManageResourceGroups', 1);
$this->_presenter = new ManageResourceGroupsPresenter($this, ServiceLocator::GetServer()
->GetUserSession(), new ResourceRepository());
if ( $this->smarty->GetWordPressEmbed() ) {
$this->Set('WP_ADMIN_POST_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_groups');
$this->Set('WP_ADMIN_AJAX_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_groups');
$this->Set('WP_ADMIN_AJAX_PAGE_REQUESTS', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_groups');
$this->smarty->SetBookedScript('admin/manage_resource_groups.php');
}
}
public function ProcessPageLoad()

8
includes/booked/Pages/Admin/ManageResourceStatusPage.php

@ -45,6 +45,14 @@ class ManageResourceStatusPage extends ActionPage implements IManageResourceStat
$this->presenter = new ManageResourceStatusPresenter($this,
ServiceLocator::GetServer()->GetUserSession(),
new ResourceRepository());
if ( $this->smarty->GetWordPressEmbed() ) {
$this->Set('WP_ADMIN_POST_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_statuses');
$this->Set('WP_ADMIN_AJAX_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_statuses');
$this->Set('WP_ADMIN_AJAX_PAGE_REQUESTS', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_statuses');
$this->smarty->SetBookedScript('admin/manage_resource_status.php');
}
}
public function ProcessPageLoad()

7
includes/booked/Pages/Admin/ManageResourceTypesPage.php

@ -84,6 +84,13 @@ class ManageResourceTypesPage extends ActionPage implements IManageResourceTypes
->GetUserSession(),
new ResourceRepository(),
new AttributeService(new AttributeRepository()));
if ( $this->smarty->GetWordPressEmbed() ) {
$this->Set('WP_ADMIN_POST_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_types');
$this->Set('WP_ADMIN_AJAX_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_types');
$this->Set('WP_ADMIN_AJAX_PAGE_REQUESTS', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_types');
$this->smarty->SetBookedScript('admin/manage_resource_types.php');
}
}
public function ProcessPageLoad()

14
includes/booked/Pages/Admin/ManageResourcesPage.php

@ -498,7 +498,17 @@ class ManageResourcesPage extends ActionPage implements IManageResourcesPage
$url = $this->server->GetUrl();
$exportUrl = BookedStringHelper::Contains($url, '?') ? $url . '&dr=export' : $this->server->GetRequestUri() . '?dr=export';
$this->Set('ExportUrl', $exportUrl);
$this->Set('ExportUrl', $exportUrl);
if ( $this->smarty->GetWordPressEmbed() ) {
$this->Set('WP_ADMIN_POST_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_manage');
$this->Set('WP_ADMIN_AJAX_PREFIX', BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_manage');
$this->Set('WP_ADMIN_AJAX_PAGE_REQUESTS', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_manage');
$this->smarty->SetBookedScript('admin/manage_resources.php');
$this->Set('ExportUrl', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_resources_manage&dr=export');
}
}
public function ProcessPageLoad()
@ -1123,7 +1133,7 @@ class ManageResourcesPage extends ActionPage implements IManageResourcesPage
public function DisplayPublicSettings($resource)
{
$this->Set('resource', $resource);
$this->Set('resource', $resource);
$this->Display('Admin/Resources/manage_resources_public.tpl');
}

2
includes/booked/Pages/Page.php

@ -138,7 +138,7 @@ abstract class Page implements IPage
$this->Set('IsTablet', $this->IsTablet);
$this->Set('IsDesktop', $this->IsDesktop);
$this->Set('GoogleAnalyticsTrackingId', Configuration::Instance()->GetSectionKey(ConfigSection::GOOGLE_ANALYTICS, ConfigKeys::GOOGLE_ANALYTICS_TRACKING_ID));
$this->Set('ShowNewVersion', $this->ShouldShowNewVersion());
$this->Set('ShowNewVersion', false);
}

2
includes/booked/Presenters/Admin/ManageResourceGroupsPresenter.php

@ -65,7 +65,7 @@ class ManageResourceGroupsPresenter extends ActionPresenter
public function PageLoad()
{
$this->page->BindResourceGroups($this->resourceRepository->GetResourceGroups());
$this->page->BindResourceGroups($this->resourceRepository->GetResourceGroups(null, null, true));
$this->page->BindResources($this->resourceRepository->GetResourceList());
}

11
includes/booked/Web/css/booked.css

@ -1233,14 +1233,19 @@ table.reservations.mobile div.reservable {
max-width: 1px;
overflow: hidden;
}
.event {
.event,
.buffer {
overflow: hidden;
position: absolute;
background-color: #000;
height: 40px;
z-index: 2;
border-bottom: solid 1px #36648B;
border-right: solid 1px #36648B;
border-bottom: solid 0.5px #36648B;
border-right: solid 0.5px #36648B;
border-collapse: separate;
}
.buffer {
z-index: 1;
}
.unreservable,
.buffer {

12
includes/booked/Web/scripts/admin/resource-groups.js

@ -201,7 +201,9 @@ function ResourceGroupManagement(opts)
{
PerformAsyncPost(getResourceActionUrl(targetNode.id, resourceId, opts.actions.addResource), {done: function (data)
{
}});
},
wp_post_prefix: options.wp_post_prefix,
wp_post_type: options.actions.addResource});
elements.groupDiv.tree(
'appendNode',
@ -220,7 +222,9 @@ function ResourceGroupManagement(opts)
var resourceId = resourceNode.resource_id;
PerformAsyncPost(getResourceActionUrl(resourceNode.group_id, resourceId, opts.actions.removeResource), {done: function (data)
{
}});
},
wp_post_prefix: options.wp_post_prefix,
wp_post_type: options.actions.removeResource});
elements.groupDiv.tree('removeNode', resourceNode);
}
@ -306,7 +310,9 @@ function ResourceGroupManagement(opts)
var previousId = previousNode.id;
PerformAsyncPost(getMoveNodeUrl(targetNodeId, movedId, previousId, movedNode.type, opts.actions.moveNode), {done: function (data)
{
}});
},
wp_post_prefix: options.wp_post_prefix,
wp_post_type: options.actions.moveNode});
}
var getResourceActionUrl = function (targetGroupId, resourceId, action)

1
includes/booked/Web/scripts/admin/resource-status.js

@ -41,6 +41,7 @@ function ResourceStatusManagement(opts) {
$('.add-link').click(function (e) {
e.preventDefault();
$('#add-reason-status').val($(this).attr('add-to'));
$('#add-reason-description').val('');
showAddPrompt(e);
});

1
includes/booked/Web/scripts/admin/resource-types.js

@ -58,6 +58,7 @@ function ResourceTypeManagement(opts) {
$(".save").click(function () {
$(this).closest('form').submit();
$(this).closest('form').trigger('reset');
});
$(".cancel").click(function () {

12
includes/booked/Web/scripts/admin/resource.js

@ -303,9 +303,9 @@ function ResourceManagement(opts) {
elements.clearFilterButton.click(function (e) {
e.preventDefault();
elements.filterTable.find('input,select,textarea').val('');
elements.filterTable.find('input:not([type=hidden]),select,textarea').val('');
filterResources();
$('#filterForm').submit();
});
wireUpCheckboxToggle(elements.bulkUpdateDialog);
@ -915,7 +915,7 @@ function ResourceManagement(opts) {
var changeUserPermissions = function () {
var resourceId = getActiveResourceId();
$.get(opts.permissionsUrl + '?dr=users', {rid: resourceId}, function (data) {
$.get(opts.permissionsUrl + 'dr=users', {rid: resourceId}, function (data) {
elements.resourceUserList.html(data);
$('.user-permission-spinner').addClass('no-show');
});
@ -933,7 +933,7 @@ function ResourceManagement(opts) {
elements.allUsersList.empty();
var resourceId = getActiveResourceId();
$.get(opts.permissionsUrl + '?dr=usersAll', {rid: resourceId}, function (data) {
$.get(opts.permissionsUrl + 'dr=usersAll', {rid: resourceId}, function (data) {
elements.allUsersList.html(data);
});
@ -942,7 +942,7 @@ function ResourceManagement(opts) {
var changeGroupPermissions = function () {
var resourceId = getActiveResourceId();
$.get(opts.permissionsUrl + '?dr=groups', {rid: resourceId}, function (data) {
$.get(opts.permissionsUrl + 'dr=groups', {rid: resourceId}, function (data) {
elements.resourceGroupList.html(data);
$('.group-permission-spinner').addClass('no-show');
});
@ -960,7 +960,7 @@ function ResourceManagement(opts) {
elements.allGroupsList.empty();
var resourceId = getActiveResourceId();
$.get(opts.permissionsUrl + '?dr=groupsAll', {rid: resourceId}, function (data) {
$.get(opts.permissionsUrl + 'dr=groupsAll', {rid: resourceId}, function (data) {
elements.allGroupsList.html(data);
});

22
includes/booked/Web/scripts/ajax-helpers.js

@ -225,11 +225,19 @@ function BeforeSerialize(jqForm, options) {
}
function PerformAsyncAction(element, urlCallback, indicator, successCallback) {
var data = null;
var data = {};
var csrf_token = $('#csrf_token');
var wp_post_type = $(element).data('wp-post-type'),
wp_post_prefix = $(element).data('wp-post-prefix');
if (csrf_token.length != 0)
{
data = csrf_token.serialize();
data.CSRF_TOKEN = csrf_token.val();
}
if (wp_post_type.length != 0)
{
data.action = wp_post_prefix + '_' + wp_post_type;
}
if (indicator)
@ -275,15 +283,23 @@ function PerformAsyncPost(url, options) {
data: {}
}, options);
var csrf_token = $('#csrf_token');
if (csrf_token.length != 0)
{
opts.data = csrf_token.serialize();
opts.data.CSRF_TOKEN = csrf_token.val();
}
if (opts.wp_post_prefix && opts.wp_post_type)
{
opts.data.action = opts.wp_post_prefix + '_' + opts.wp_post_type;
}
if (opts.indicator)
{
opts.element.after(opts.indicator);
opts.indicator.removeClass('no-show');
}
$.post(url, opts.data)
.done(
function (data) {

18
includes/booked/lib/Application/Admin/ImageUploadDirectory.php

@ -43,7 +43,23 @@ class ImageUploadDirectory
public function GetPath()
{
return Configuration::Instance()->GetScriptUrl() . '/' . Configuration::Instance()->GetKey(ConfigKeys::IMAGE_UPLOAD_URL);
$image_upload_url = Configuration::Instance()->GetKey(ConfigKeys::IMAGE_UPLOAD_URL);
if (BookedStringHelper::StartsWith($image_upload_url, '//')) {
$isHttps = ServiceLocator::GetServer()->GetIsHttps();
if ($isHttps) {
$image_upload_url = "https:$image_upload_url";
}
else {
$image_upload_url = "http:$image_upload_url";
}
}
elseif ( ! BookedStringHelper::StartsWith($image_upload_url, 'http') ) {
$image_upload_url = Configuration::Instance()->GetScriptUrl() . '/' . ltrim( $image_upload_url, '/' );
}
return $image_upload_url;
}
}

93
includes/booked/lib/Common/SmartyPage.php

@ -48,6 +48,13 @@ class SmartyPage extends Smarty
*/
private $IsValid = true;
/**
* Is this running under WordPress?
*
* @var bool
*/
private $WordPressEmbed = false;
/**
*
* @param Resources $resources
@ -60,6 +67,26 @@ class SmartyPage extends Smarty
$base = dirname(__FILE__) . '/../../';
$this->debugging = isset($_GET['debug']);
$this->WordPressEmbed = $this->CheckWordPressEmbed();
if ($this->WordPressEmbed) {
$this->assign( 'WP_EMBED', true);
// This is to ensure any form POSTs go to wp-admin where we can deal with it
$this->assign( 'WP_ADMIN_POST', admin_url('admin-post.php') );
$this->assign( 'WP_ADMIN_POST_PREFIX', '' );
// And for AJAX calls
$this->assign( 'WP_ADMIN_AJAX', admin_url('admin-ajax.php') );
$this->assign( 'WP_ADMIN_AJAX_PREFIX', '' );
// Autocomplete calls
$this->assign( 'WP_ADMIN_AJAX_AUTOCOMPLETE', admin_url('admin-ajax.php') . '?action=' . BESPOKOMATIC_EBS_AJAX_PREFIX . '_autocomplete&' );
$this->assign( 'WP_ADMIN_PAGE', $_GET['page'] );
// Insert our own template directory to override booked's if required
$this->AddTemplateDirectory(BESPOKOMATIC_EBS_TEMPLATES_DIR);
}
$this->AddTemplateDirectory($base . 'tpl');
$this->compile_dir = $base . 'tpl_c';
$this->config_dir = $base . 'configs';
@ -79,13 +106,42 @@ class SmartyPage extends Smarty
}
$this->Resources = &$resources;
$this->RootPath = $rootPath;
if ($this->WordPressEmbed) {
$this->RootPath = BESPOKOMATIC_EBS_BOOKED_URL;
}
else {
$this->RootPath = $rootPath;
}
$this->AddTemplateDirectory($base . 'lang/' . $this->Resources->CurrentLanguage);
$this->RegisterFunctions();
}
/**
* Check if this page is running under WordPress or has been requested under WordPress.
*
* @return bool
*/
private function CheckWordPressEmbed() {
return (
($_SERVER['SCRIPT_NAME'] == '/wp-admin/admin.php' && isset($_GET['page']) && strstr( $_GET['page'], BESPOKOMATIC_EBS_NAME ))
|| $_SERVER['SCRIPT_NAME'] == '/wp-admin/admin-post.php'
|| $_SERVER['SCRIPT_NAME'] == '/wp-admin/admin-ajax.php'
);
}
public function GetWordPressEmbed() {
return $this->WordPressEmbed;
}
public function SetBookedScript( $BookedScript ) {
if ( $this->WordPressEmbed ) {
$this->assign( 'BEBS_BOOKED_SCRIPT', BESPOKOMATIC_EBS_BOOKED_URL . $BookedScript );
}
}
public function AddTemplateDirectory($templateDirectory)
{
$this->addTemplateDir($templateDirectory);
@ -825,8 +881,9 @@ class SmartyPage extends Smarty
{
$key = isset($params['key']) ? $params['key'] : 'Cancel';
$class = isset($params['class']) ? $params['class'] : '';
echo '<button type="button" class="btn btn-default cancel ' . $class . '" data-dismiss="modal" ' . $this->GetButtonAttributes($params) . '>' .
Resources::GetInstance()->GetString($key) . '</button>';
echo '<button type="button" class="btn btn-default cancel ' . $class . '" data-dismiss="modal" '
. $this->GetButtonAttributes($params) . '>' .
Resources::GetInstance()->GetString($key) . '</button>';
}
public function UpdateButton($params, &$smarty)
@ -836,8 +893,9 @@ class SmartyPage extends Smarty
$type = isset($params['submit']) ? 'submit' : 'button';
$save = $type == 'submit' ? '' : ' save ';
echo '<button type="' . $type . '" class="btn btn-success' . $save . $class . '" ' . $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-ok-circle"></span> ' . Resources::GetInstance()
->GetString($key) . '</button>';
echo '<button type="' . $type . '" class="btn btn-success' . $save . $class . '" '
. $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-ok-circle"></span> '
. Resources::GetInstance()->GetString($key) . '</button>';
}
public function AddButton($params, &$smarty)
@ -851,8 +909,9 @@ class SmartyPage extends Smarty
$type = 'submit';
}
echo '<button type="' . $type . '" class="btn btn-success save ' . $class . '" ' . $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-ok-circle"></span> ' . Resources::GetInstance()
->GetString($key) . '</button>';
echo '<button type="' . $type . '" class="btn btn-success save ' . $class . '" '
. $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-ok-circle"></span> '
. Resources::GetInstance()->GetString($key) . '</button>';
}
public function DeleteButton($params, &$smarty)
@ -865,32 +924,36 @@ class SmartyPage extends Smarty
{
$type = 'submit';
}
echo '<button type="' . $type . '" class="btn btn-danger save ' . $class . '" ' . $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-trash"></span> ' . Resources::GetInstance()
->GetString($key) . '</button>';
echo '<button type="' . $type . '" class="btn btn-danger save ' . $class . '" '
. $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-trash"></span> '
. Resources::GetInstance()->GetString($key) . '</button>';
}
public function ResetButton($params, &$smarty)
{
$key = isset($params['key']) ? $params['key'] : 'Reset';
$class = isset($params['class']) ? $params['class'] : '';
echo '<button type="reset" class="btn btn-default ' . $class . '" ' . $this->GetButtonAttributes($params) . '>' . Resources::GetInstance()
->GetString($key) . '</button>';
echo '<button type="reset" class="btn btn-default ' . $class . '" '
. $this->GetButtonAttributes($params) . '>'
. Resources::GetInstance()->GetString($key) . '</button>';
}
public function FilterButton($params, &$smarty)
{
$key = isset($params['key']) ? $params['key'] : 'Filter';
$class = isset($params['class']) ? $params['class'] : '';
echo '<button type="search" class="btn btn-primary ' . $class . '" ' . $this->GetButtonAttributes($params) . '> <span class="glyphicon glyphicon-search"></span> ' . Resources::GetInstance()
->GetString($key) . '</button>';
echo '<button type="search" class="btn btn-primary ' . $class . '" '
. $this->GetButtonAttributes($params) . '> <span class="glyphicon glyphicon-search"></span> '
. Resources::GetInstance()->GetString($key) . '</button>';
}
public function OkButton($params, &$smarty)
{
$key = isset($params['key']) ? $params['key'] : 'OK';
$class = isset($params['class']) ? $params['class'] : '';
echo '<button type="button" class="btn btn-success ' . $class . '" ' . $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-ok-circle"></span> ' . Resources::GetInstance()
->GetString($key) . '</button>';
echo '<button type="button" class="btn btn-success ' . $class . '" '
. $this->GetButtonAttributes($params) . '><span class="glyphicon glyphicon-ok-circle"></span> '
. Resources::GetInstance()->GetString($key) . '</button>';
}
public function ShowHideIcon($params, &$smarty)

2
includes/booked/lib/external/Smarty/Smarty.class.php

@ -1201,7 +1201,7 @@ class Smarty extends Smarty_Internal_TemplateBase
public function _realpath($path, $realpath = null)
{
$nds = DS == '/' ? '\\' : '/';
// normalize DS
// normalize DS
$path = str_replace($nds, DS, $path);
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%',
$path, $parts);

11
includes/booked/tpl/Admin/Resources/manage_resource_groups.tpl

@ -20,13 +20,16 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="page-manage-resource-groups" class="admin-page">
{if ! $WP_EMBED}
{include file='Admin/Resources/manage_resource_menu.tpl' ResourcePageTitleKey='ManageResourceGroups'}
{/if}
<div id="globalError" class="alert alert-danger no-show"></div>
<div id="manage-resource-groups-container">
<div id="new-group">
<form method="post" id="addGroupForm" ajaxAction="{ManageResourceGroupsActions::AddGroup}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceGroupsActions::AddGroup}"/>
<div class="form-group">
<label for="groupName" class="no-show">{translate key=AddNewGroup}</label>
<input type="text" name="{FormKeys::GROUP_NAME}" class="form-control new-group inline" size="30"
@ -54,6 +57,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="renameDialog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="renameGroupDialogLabel"
aria-hidden="true">
<form id="renameForm" method="post" ajaxAction="{ManageResourceGroupsActions::RenameGroup}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceGroupsActions::RenameGroup}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -80,6 +84,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="deleteDialog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="deleteDialogLabel"
aria-hidden="true">
<form id="deleteForm" method="post" ajaxAction="{ManageResourceGroupsActions::DeleteGroup}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceGroupsActions::DeleteGroup}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -104,6 +109,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="addChildDialog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addGroupDialogLabel"
aria-hidden="true">
<form id="addChildForm" method="post" ajaxAction="{ManageResourceGroupsActions::AddGroup}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceGroupsActions::AddGroup}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -158,12 +164,13 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
};
var groupOptions = {
submitUrl: '{$smarty.server.SCRIPT_NAME}',
submitUrl: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
actions: actions,
renameText: '{translate key=Rename|escape:'javascript'}',
addChildText: '{translate key=AddGroup|escape:'javascript'}',
deleteText: '{translate key=Delete|escape:'javascript'}',
exitText: '{translate key=Close|escape:'javascript'}'
exitText: '{translate key=Close|escape:'javascript'}',
wp_post_prefix: '{$WP_ADMIN_POST_PREFIX|default:""}'
};
var groupManagement = new ResourceGroupManagement(groupOptions);

11
includes/booked/tpl/Admin/Resources/manage_resource_status.tpl

@ -32,7 +32,11 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
</div>
{/function}
{if ! $WP_EMBED}
{include file='Admin/Resources/manage_resource_menu.tpl' ResourcePageTitleKey='ManageResourceStatus'}
{else}
<div class="clear"></div>
{/if}
<div id="globalError" class="error" style="display:none"></div>
@ -84,6 +88,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<div class="modal-dialog">
<form id="addForm" method="post" ajaxAction="{ManageResourceStatusActions::Add}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceStatusActions::Add}"/>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
@ -113,6 +118,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<div class="modal-dialog">
<form id="editForm" method="post" ajaxAction="{ManageResourceStatusActions::Update}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceStatusActions::Update}"/>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
@ -142,6 +148,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<div class="modal-dialog">
<form id="deleteForm" method="post" ajaxAction="{ManageResourceStatusActions::Delete}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceStatusActions::Delete}"/>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
@ -172,8 +179,8 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
$(document).ready(function () {
var opts = {
submitUrl: '{$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$smarty.server.SCRIPT_NAME}'
submitUrl: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}'
};
var resourceStatus = new ResourceStatusManagement(opts);

16
includes/booked/tpl/Admin/Resources/manage_resource_types.tpl

@ -20,11 +20,16 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="page-manage-resource-types" class="admin-page">
{include file='Admin/Resources/manage_resource_menu.tpl' ResourcePageTitleKey='ManageResourceTypes'}
{if ! $WP_EMBED}
{include file='Admin/Resources/manage_resource_menu.tpl' ResourcePageTitleKey='ManageResourceStatus'}
{else}
<div class="clear"></div>
{/if}
<div id="globalError" class="error" style="display:none"></div>
<form id="addForm" ajaxAction="{ManageResourceTypesActions::Add}" class="form-inline" role="form" method="post">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceTypesActions::Add}"/>
<div class="panel panel-default" id="add-resource-type-panel">
<div class="panel-heading">{translate key="AddResourceType"} {showhide_icon}</div>
<div class="panel-body add-contents">
@ -93,6 +98,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<div class="modal-dialog">
<form id="editForm" method="post" ajaxAction="{ManageResourceTypesActions::Update}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceTypesActions::Update}"/>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
@ -127,6 +133,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<div class="modal-dialog">
<form id="deleteForm" method="post" ajaxAction="{ManageResourceTypesActions::Delete}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourceTypesActions::Delete}"/>
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
@ -195,10 +202,11 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
$.fn.editable.defaults.emptyclass = '';
$.fn.editable.defaults.params = function(params) {
params.CSRF_TOKEN = $('#csrf_token').val();
params.action = '{$WP_ADMIN_POST_PREFIX}_{ManageResourceTypesActions::ChangeAttribute}';
return params;
};
var updateUrl = '{$smarty.server.SCRIPT_NAME}?action=';
var updateUrl = '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}?action=';
$('.inlineAttribute').editable({
url: updateUrl + '{ManageResourceTypesActions::ChangeAttribute}',
@ -212,8 +220,8 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
setUpEditables();
var opts = {
submitUrl: '{$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$smarty.server.SCRIPT_NAME}'
submitUrl: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}'
};
var resourceTypes = new ResourceTypeManagement(opts);

119
includes/booked/tpl/Admin/Resources/manage_resources.tpl

@ -20,7 +20,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
{include file='globalheader.tpl' InlineEdit=true Owl=true}
<div id="page-manage-resources" class="admin-page">
<div>
<div style="padding-top:1rem;">
<div class="dropdown admin-header-more pull-right">
<button class="btn btn-default" type="button" id="moreResourceActions" data-toggle="dropdown">
<span class="no-show">More</span>
@ -28,7 +28,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="moreResourceActions">
{if ! $WP_EMBED}
<li role="presentation">
<a role="menuitem" href="{$Path}admin/manage_resource_groups.php">{translate key="ManageResourceGroups"}</a>
</li>
@ -39,6 +39,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<a role="menuitem" href="{$Path}admin/manage_resource_status.php">{translate key="ManageResourceStatus"}</a>
</li>
<li role="presentation" class="divider"></li>
{/if}
<li role="presentation">
<a role="menuitem" href="#" class="import-resources" id="import-resources">
{translate key="ImportResources"}
@ -70,13 +71,13 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
</ul>
</div>
<h1>{translate key='ManageResources'}</h1>
{if ! WP_EMBED}<h1>{translate key='ManageResources'}</h1>{/if}
</div>
<div class="panel panel-default filterTable" id="filter-resources-panel">
<form id="filterForm" class="horizontal-list" role="form" method="get">
<div class="panel-heading"><span
class="glyphicon glyphicon-filter"></span> {translate key="Filter"} {showhide_icon}
<div class="panel panel-default filterTable" id="filter-resources-panel" {if $WP_EMBED}style="margin-right:5rem;"{/if}>
<form id="filterForm" class="horizontal-list" role="form" method="get" action="{$smarty.server.SCRIPT_NAME}">
<input type="hidden" name="page" value="{$WP_ADMIN_PAGE}"/>
<div class="panel-heading"><span class="glyphicon glyphicon-filter"></span> {translate key="Filter"} {showhide_icon}
</div>
<div class="panel-body">
@ -366,7 +367,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
{/if}
</div>
<div>
<a href="{$smarty.server.SCRIPT_NAME}?action={ManageResourcesActions::ActionPrintQR}&rid={$id}"
<a href="{$BEBS_BOOKED_SCRIPT|default:$smarty.server.SCRIPT_NAME}?action={ManageResourcesActions::ActionPrintQR}&rid={$id}"
target="_blank">{translate key=PrintQRCode} <i class="fa fa-qrcode"></i></a>
</div>
</div>
@ -472,6 +473,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<form id="addResourceForm" class="form" role="form" method="post"
ajaxAction="{ManageResourcesActions::ActionAdd}" enctype="multipart/form-data">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionAdd}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -540,6 +542,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="imageDialog" class="modal" tabindex="-1" role="dialog" aria-labelledby="imageModalLabel"
aria-hidden="true">
<form id="imageForm" method="post" enctype="multipart/form-data" ajaxAction="{ManageResourcesActions::ActionChangeImage}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeImage}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -578,16 +581,19 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<form id="removeImageForm" method="post" ajaxAction="{ManageResourcesActions::ActionRemoveImage}">
<input type="hidden" id="removeImageName" {formname key=RESOURCE_IMAGE} />
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionRemoveImage}"/>
</form>
<form id="defaultImageForm" method="post" ajaxAction="{ManageResourcesActions::ActionDefaultImage}">
<input type="hidden" id="defaultImageName" {formname key=RESOURCE_IMAGE} />
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionDefaultImage}"/>
</form>
<div id="copyDialog" class="modal" tabindex="-1" role="dialog" aria-labelledby="copyModalLabel"
aria-hidden="true">
<form id="copyForm" method="post" enctype="multipart/form-data"
ajaxAction="{ManageResourcesActions::ActionCopyResource}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionCopyResource}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -618,6 +624,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="durationDialog" class="modal" tabindex="-1" role="dialog" aria-labelledby="durationModalLabel"
aria-hidden="true">
<form id="durationForm" method="post" role="form" ajaxAction="{ManageResourcesActions::ActionChangeDuration}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeDuration}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -722,6 +729,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="capacityDialog" class="modal" tabindex="-1" role="dialog" aria-labelledby="capacityModalLabel"
aria-hidden="true">
<form id="capacityForm" method="post" role="form" ajaxAction="{ManageResourcesActions::ActionChangeCapacity}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeCapacity}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -759,6 +767,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="accessDialog" class="modal" tabindex="-1" role="dialog" aria-labelledby="accessModalLabel"
aria-hidden="true">
<form id="accessForm" method="post" role="form" ajaxAction="{ManageResourcesActions::ActionChangeAccess}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeAccess}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -927,6 +936,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="statusDialog" class="hide">
<form class="statusForm" method="post" ajaxAction="{ManageResourcesActions::ActionChangeStatus}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeStatus}"/>
<div class="control-group form-group">
<div class="form-group">
<label>{translate key=Status}
@ -977,6 +987,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<div id="deletePrompt" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="deleteResourceDialogLabel"
aria-hidden="true">
<form id="deleteForm" method="post" ajaxAction="{ManageResourcesActions::ActionDelete}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionDelete}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -1010,6 +1021,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<form id="bulkUpdateForm" method="post" ajaxAction="{ManageResourcesActions::ActionBulkUpdate}"
class="form-vertical"
role="form">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionBulkUpdate}"/>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
@ -1406,6 +1418,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<form id="bulkDeleteForm" method="post" ajaxAction="{ManageResourcesActions::ActionBulkDelete}"
class="form-vertical"
role="form">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionBulkDelete}"/>
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
@ -1479,6 +1492,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<form id="changeUserForm" method="post" ajaxAction="{ManageResourcesActions::ActionChangeUserPermission}">
<input type="hidden" id="changeUserId" {formname key=USER_ID} />
<input type="hidden" id="changeUserType" {formname key=PERMISSION_TYPE} />
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeUserPermission}"/>
</form>
<div id="groupDialog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="browseGroupsDialogLabel"
@ -1520,12 +1534,14 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<form id="changeGroupForm" method="post" ajaxAction="{ManageResourcesActions::ActionChangeGroupPermission}">
<input type="hidden" id="changeGroupId" {formname key=GROUP_ID} />
<input type="hidden" id="changeGroupType" {formname key=PERMISSION_TYPE} />
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeGroupPermission}"/>
</form>
<div class="modal fade" id="resourceGroupDialog" tabindex="-1" role="dialog"
aria-labelledby="resourceGroupsModalLabel"
aria-hidden="true">
<form id="resourceGroupForm" method="post" ajaxAction="{ManageResourcesActions::ActionChangeResourceGroups}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeResourceGroups}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -1547,11 +1563,13 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
<form id="colorForm" method="post" ajaxAction="{ManageResourcesActions::ActionChangeColor}">
<input type="hidden" id="reservationColor" {formname key=RESERVATION_COLOR} />
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeColor}"/>
</form>
<div id="creditsDialog" class="modal" tabindex="-1" role="dialog" aria-labelledby="creditsModalLabel"
aria-hidden="true">
<form id="creditsForm" method="post" role="form" ajaxAction="{ManageResourcesActions::ActionChangeCredits}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ActionChangeCredits}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -1592,6 +1610,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
aria-hidden="true">
<form id="importForm" class="form" role="form" method="post" enctype="multipart/form-data"
ajaxAction="{ManageResourcesActions::ImportResources}">
<input type="hidden" name="action" value="{$WP_ADMIN_POST_PREFIX}_{ManageResourcesActions::ImportResources}"/>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -1662,7 +1681,7 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
function setUpPopovers() {
$('[rel="popover"]').popover({
container: 'body', html: true, placement: 'top', content: function () {
container: '#main', html: true, placement: 'top', content: function () {
var popoverId = $(this).data('popover-content');
return $(popoverId).html();
}
@ -1688,76 +1707,8 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
return params;
};
var updateUrl = '{$smarty.server.SCRIPT_NAME}?action=';
$('.resourceName').editable({
url: updateUrl + '{ManageResourcesActions::ActionRename}', validate: function (value) {
if ($.trim(value) == '')
{
return '{translate key=RequiredValue}';
}
}
});
$('.scheduleName').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeSchedule}', source: [
{foreach from=$Schedules item=scheduleName key=scheduleId}
{
value:{$scheduleId}, text: '{$scheduleName|escape:'javascript'}'
},
{/foreach}
]
});
$('.resourceTypeName').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeResourceType}',
emptytext: '{{translate key=NoResourceTypeLabel}|escape:'javascript'}',
source: [{
value: '0', text: '' //'-- {translate key=None} --'
},
{foreach from=$ResourceTypes item=resourceType key=id}
{
value:{$id}, text: '{$resourceType->Name()|escape:'javascript'}'
},
{/foreach}
]
});
$('.sortOrderValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeSort}', emptytext: '0', min: 0, max: 999
});
$('.locationValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeLocation}', emptytext: '{{translate key='NoLocationLabel'}|escape:'javascript'}'
});
$('.contactValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeContact}', emptytext: '{{translate key='NoContactLabel'}|escape:'javascript'}}'
});
$('.descriptionValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeDescription}', emptytext: '{{translate key='NoDescriptionLabel'}|escape:'javascript'}'
});
$('.notesValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeNotes}', emptytext: '{{translate key='NoDescriptionLabel'}|escape:'javascript'}'
});
$('.resourceAdminValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeAdmin}', emptytext: '{{translate key=None}|escape:'javascript'}', source: [{
value: '0', text: ''
},
{foreach from=$AdminGroups item=group key=scheduleId}
{
value:{$group->Id()}, text: '{$group->Name()|escape:'javascript'}'
},
{/foreach}
]
});
$('.inlineAttribute').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeAttribute}', emptytext: '-'
});
var updateUrl = '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}?action=';
{include file='Admin/Resources/manage_resources_set_editables.tpl' resource=$resource}
}
@ -1777,12 +1728,12 @@ along with Booked Scheduler. If not, see <http://www.gnu.org/licenses/>.
};
var opts = {
submitUrl: '{$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$smarty.server.SCRIPT_NAME}',
submitUrl: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
saveRedirect: '{$WP_ADMIN_POST|default:$smarty.server.SCRIPT_NAME}',
actions: actions,
userAutocompleteUrl: "../ajax/autocomplete.php?type={AutoCompleteType::User}",
groupAutocompleteUrl: "../ajax/autocomplete.php?type={AutoCompleteType::Group}",
permissionsUrl: '{$smarty.server.SCRIPT_NAME}',
userAutocompleteUrl: "{$WP_ADMIN_AJAX_AUTOCOMPLETE|default:'../ajax/autocomplete.php?'}type={AutoCompleteType::User}",
groupAutocompleteUrl: "{$WP_ADMIN_AJAX_AUTOCOMPLETE|default:'../ajax/autocomplete.php?'}type={AutoCompleteType::Group}",
permissionsUrl: '{"$WP_ADMIN_AJAX_PAGE_REQUESTS&"|default:"$smarty.server.SCRIPT_NAME?"}',
copyText: '{{translate key=Copy}|escape:"javascript"}'
};

4
includes/booked/tpl/Admin/Resources/manage_resources_public.tpl

@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with phpScheduleIt. If not, see <http://www.gnu.org/licenses/>.
*}
{if $resource->GetIsCalendarSubscriptionAllowed()}
<div><a class="update disableSubscription subscriptionButton"
<div><a class="update disableSubscription subscriptionButton" data-wp-post-prefix="{$WP_ADMIN_POST_PREFIX}" data-wp-post-type="{ManageResourcesActions::ActionDisableSubscription}"
href="#">{translate key=TurnOffSubscription}</a>
</div>
<div>
@ -36,7 +36,7 @@ along with phpScheduleIt. If not, see <http://www.gnu.org/licenses/>.
</div>
{else}
<div>
<a class="update enableSubscription subscriptionButton"
<a class="update enableSubscription subscriptionButton" data-wp-post-prefix="{$WP_ADMIN_POST_PREFIX}" data-wp-post-type="{ManageResourcesActions::ActionEnableSubscription}"
href="#">{translate key=TurnOnSubscription}</a>
</div>
{/if}

68
includes/booked/tpl/Admin/Resources/manage_resources_set_editables.tpl

@ -0,0 +1,68 @@
$('.resourceName').editable({
url: updateUrl + '{ManageResourcesActions::ActionRename}', validate: function (value) {
if ($.trim(value) == '')
{
return '{translate key=RequiredValue}';
}
}
});
$('.scheduleName').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeSchedule}', source: [
{foreach from=$Schedules item=scheduleName key=scheduleId}
{
value:{$scheduleId}, text: '{$scheduleName|escape:'javascript'}'
},
{/foreach}
]