Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Pages/Admin/ManageResourcesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
33 changes: 33 additions & 0 deletions Pages/Ajax/AutoCompletePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions config/config.devel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/config.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/Config/ConfigKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
15 changes: 13 additions & 2 deletions tpl/Admin/Resources/manage_resources.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,11 @@
<div>
<label
class="inline fw-bold">{translate key='Contact'}</label>
<span class="propertyValue contactValue" data-type="text"
{if $ResourceContactIsUser}
<span class="propertyValue contactValue" data-type="select"
{else}
<span class="propertyValue contactValue" data-type="text"
{/if}
data-pk="{$id}" data-value="{$resource->GetContact()}"
data-name="{FormKeys::RESOURCE_CONTACT}">
{if $resource->HasContact()}
Expand Down Expand Up @@ -2180,6 +2184,7 @@
};

var updateUrl = '{$smarty.server.SCRIPT_NAME}?action=';
var xUserAutocompleteUrl = "../ajax/autocomplete.php?type={AutoCompleteType::XUser}";

$('.resourceNameField').editable({
url: updateUrl + '{ManageResourcesActions::ActionRename}', validate: function (value) {
Expand Down Expand Up @@ -2222,7 +2227,13 @@
});

$('.contactValue').editable({
url: updateUrl + '{ManageResourcesActions::ActionChangeContact}', emptytext: "{translate key='NoContactLabel'|escape:'javascript'}"
url: updateUrl + '{ManageResourcesActions::ActionChangeContact}',
{if $ResourceContactIsUser}
emptytext: "{translate key='NoContactLabel'|escape:'javascript'}",
source: xUserAutocompleteUrl,
{else}
emptytext: "{translate key='NoContactLabel'|escape:'javascript'}"
{/if}
});

$('.descriptionValue').editable({
Expand Down