summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-19 14:05:07 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-19 14:05:07 +0100
commit5d3e672dd7f35c348a98fd149c02c5c9d79cb520 (patch)
treeaeb54fdb20f2e5c60cf2ee1f1952f6f604248909 /includes
parent53bb19704b1e99245b755caf2d573a4406066902 (diff)
downloadcontact-5d3e672dd7f35c348a98fd149c02c5c9d79cb520.tar.gz
contact-5d3e672dd7f35c348a98fd149c02c5c9d79cb520.tar.bz2
contact-5d3e672dd7f35c348a98fd149c02c5c9d79cb520.zip
Map contact persons to registered users via contact.role_id
contact.role_id stores the user_id of the linked registered user (NULL = no account). load() joins users_users on role_id to expose linked_user_login and linked_user_name. verify() accepts user_id from the edit form and writes it to contact_store['role_id']. getList() now filters by user_id key (was role_id). Edit form shows the user_id field to admins with current login shown inline; display template shows the linked user when set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/classes/Contact.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/includes/classes/Contact.php b/includes/classes/Contact.php
index 3423c0d..a9bab4b 100755
--- a/includes/classes/Contact.php
+++ b/includes/classes/Contact.php
@@ -130,11 +130,13 @@ class Contact extends LibertyContent {
x00.`xkey_ext` as name, lc.`title` as organisation,
xhL.`xkey` as x_coordinate, xhL.`xkey_ext` as y_coordinate,
uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,
- uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name
+ uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,
+ uu.`login` AS linked_user_login, uu.`real_name` AS linked_user_name
FROM `".BIT_DB_PREFIX."contact` con
LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.content_id = con.content_id
LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)
LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = lc.`user_id`)
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uu ON uu.`user_id` = con.`role_id`
LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` img ON img.`content_id` = con.`content_id` AND img.`item` = 'IMG'
LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x00 ON x00.`content_id` = con.`content_id` AND x00.`item` = 'P01'
LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND xhA.`item` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP )
@@ -222,6 +224,9 @@ class Contact extends LibertyContent {
}
$pParamHash['title'] = trim( $pParamHash['title'] );
$pParamHash['contact_store']['xkey'] = $pParamHash['xkey'];
+ if( array_key_exists( 'user_id', $pParamHash ) ) {
+ $pParamHash['contact_store']['role_id'] = $pParamHash['user_id'] ? (int)$pParamHash['user_id'] : null;
+ }
return count( $this->mErrors ) == 0;
}
@@ -378,7 +383,7 @@ class Contact extends LibertyContent {
/**
* Return a paged list of contacts matching filter criteria.
*
- * Recognised keys in $pParamHash: role_id, contact_type_guid, find_xref,
+ * Recognised keys in $pParamHash: user_id (filters by linked user; stored in con.role_id), contact_type_guid, find_xref,
* find_title, find_location, find_postcode, active, sort_mode, max_records, offset.
* Sets $pParamHash['cant'] and $pParamHash['listInfo'] on return.
*
@@ -396,11 +401,11 @@ class Contact extends LibertyContent {
$whereSql = '';
$bindVars = [];
- if ( isset( $pParamHash['role_id'] ) ) {
+ if ( isset( $pParamHash['user_id'] ) ) {
array_push( $bindVars, $this->mContentTypeGuid );
- if ( $pParamHash['role_id'] > 0 ) {
+ if ( $pParamHash['user_id'] > 0 ) {
$whereSql .= " AND con.`role_id` = ? ";
- $bindVars[] = $pParamHash['role_id'];
+ $bindVars[] = (int)$pParamHash['user_id'];
}
}
elseif ( isset( $pParamHash['contact_type_guid'][0] ) ) {
@@ -417,7 +422,7 @@ class Contact extends LibertyContent {
$pParamHash["listInfo"]["ihash"]["find_xref"] = $find_xref;
}
- if ( !isset( $pParamHash['role_id'] ) ) {
+ if ( !isset( $pParamHash['user_id'] ) ) {
array_push( $bindVars, $this->mContentTypeGuid );
}