diff --git a/Pages/Admin/ManageResourcesPage.php b/Pages/Admin/ManageResourcesPage.php index ad15cbedc..3a1552aea 100644 --- a/Pages/Admin/ManageResourcesPage.php +++ b/Pages/Admin/ManageResourcesPage.php @@ -510,6 +510,9 @@ public function __construct() $url = $this->server->GetUrl(); $exportUrl = BookedStringHelper::Contains($url, '?') ? $url . '&dr=export' : $this->server->GetRequestUri() . '?dr=export'; $this->Set('ExportUrl', $exportUrl); + + // If the contact for a resource must be chosen from a list of registered users. + $this->Set('ResourceContactIsUser', Configuration::Instance()->GetKey(ConfigKeys::RESOURCE_CONTACT_IS_USER, new BooleanConverter())); } public function ProcessPageLoad() diff --git a/Pages/Ajax/AutoCompletePage.php b/Pages/Ajax/AutoCompletePage.php index e8900178a..b0eb4afe0 100644 --- a/Pages/Ajax/AutoCompletePage.php +++ b/Pages/Ajax/AutoCompletePage.php @@ -12,6 +12,7 @@ public function __construct() parent::__construct(); $this->listMethods[AutoCompleteType::User] = 'GetUsers'; + $this->listMethods[AutoCompleteType::XUser] = 'XGetUsers'; $this->listMethods[AutoCompleteType::MyUsers] = 'GetMyUsers'; $this->listMethods[AutoCompleteType::Group] = 'GetGroups'; $this->listMethods[AutoCompleteType::Organization] = 'GetOrganizations'; @@ -57,6 +58,10 @@ private function GetUsers($term) if ($term == 'group') { return $this->GetGroupUsers($this->GetQuerystring(QueryStringKeys::GROUP_ID)); } + if (empty($term)) { + $term = ''; + } + $onlyActive = false; $activeQS = $this->GetQuerystring(QueryStringKeys::ACCOUNT_STATUS); @@ -90,6 +95,22 @@ private function GetUsers($term) return $users; } + /** + * @param $term string + * @return array|XAutocompleteUser[] + */ + private function XGetUsers($term) + { + $users = $this->GetUsers($term); + + $outUsers = [new XAutocompleteUser("", "")]; + foreach ($users as $user) { + $value = $user->Name . " <" . $user->Email . ">"; + $outUsers[] = new XAutocompleteUser($value, $value); + } + return $outUsers; + } + private function GetGroups($term) { $filter = new SqlFilterLike(new SqlFilterColumn(TableNames::GROUPS_ALIAS, ColumnNames::GROUP_NAME), $term); @@ -167,6 +188,17 @@ private function GetOrganizations($term) } } +class XAutocompleteUser +{ + public $value; + public $text; + public function __construct($value, $text) + { + $this->value = $value; + $this->text = $text; + } +} + class AutocompleteUser { public $Id; @@ -195,6 +227,7 @@ public function __construct($userId, $firstName, $lastName, $email, $userName, $ class AutoCompleteType { public const User = 'user'; + public const XUser = 'xuser'; public const Group = 'group'; public const MyUsers = 'myUsers'; public const Organization = 'organization'; diff --git a/config/config.devel.php b/config/config.devel.php index de1ea5dae..b240f840c 100644 --- a/config/config.devel.php +++ b/config/config.devel.php @@ -36,6 +36,7 @@ $conf['settings']['home.url'] = ''; // the url to open when the logo is clicked $conf['settings']['logout.url'] = ''; // the url to be directed to after logging out $conf['settings']['default.homepage'] = '1'; // the default homepage to use when new users register (1 = Dashboard, 2 = Schedule, 3 = My Calendar, 4 = Resource Calendar) +$conf['settings']['resource.contact.is.user'] = 'false'; // If Resource contact must be a registered user $conf['settings']['schedule']['use.per.user.colors'] = 'false'; // color reservations by user $conf['settings']['schedule']['show.inaccessible.resources'] = 'true'; // whether or not resources that are inaccessible to the user are visible diff --git a/config/config.dist.php b/config/config.dist.php index fc8efc17e..52d0c48f2 100644 --- a/config/config.dist.php +++ b/config/config.dist.php @@ -36,6 +36,7 @@ $conf['settings']['home.url'] = ''; // the url to open when the logo is clicked $conf['settings']['logout.url'] = ''; // the url to be directed to after logging out $conf['settings']['default.homepage'] = '1'; // the default homepage to use when new users register (1 = Dashboard, 2 = Schedule, 3 = My Calendar, 4 = Resource Calendar) +$conf['settings']['resource.contact.is.user'] = 'false'; // If Resource contact must be a registered user $conf['settings']['schedule']['use.per.user.colors'] = 'false'; // color reservations by user $conf['settings']['schedule']['show.inaccessible.resources'] = 'true'; // whether or not resources that are inaccessible to the user are visible diff --git a/lib/Config/ConfigKeys.php b/lib/Config/ConfigKeys.php index 282bd9cfb..f0797f550 100644 --- a/lib/Config/ConfigKeys.php +++ b/lib/Config/ConfigKeys.php @@ -27,6 +27,7 @@ class ConfigKeys public const REGISTRATION_REQUIRE_ACTIVATION = 'registration.require.email.activation'; public const REGISTRATION_AUTO_SUBSCRIBE_EMAIL = 'registration.auto.subscribe.email'; public const REGISTRATION_NOTIFY = 'registration.notify.admin'; + public const RESOURCE_CONTACT_IS_USER = 'resource.contact.is.user'; public const VERSION = 'version'; diff --git a/tpl/Admin/Resources/manage_resources.tpl b/tpl/Admin/Resources/manage_resources.tpl index 883e49ae2..596f36b01 100644 --- a/tpl/Admin/Resources/manage_resources.tpl +++ b/tpl/Admin/Resources/manage_resources.tpl @@ -393,7 +393,11 @@