Преглед на файлове

Side Menu - Body Header: Show User's assigned primary Contact Attachment image, if exists.

fusionate преди 11 месеца
родител
ревизия
2fa41b76d9
променени са 2 файла, в които са добавени 44 реда и са изтрити 2 реда
  1. 28 2
      resources/classes/menu.php
  2. 16 0
      themes/default/app_config.php

+ 28 - 2
resources/classes/menu.php

@@ -1192,13 +1192,39 @@ if (!class_exists('menu')) {
 			//header: right
 				$html .= "<div class='float-right' style='white-space: nowrap;'>";
 				//current user
+					$user_graphic = "<i class='".(!empty($_SESSION['theme']['body_header_icon_user']['text']) ? $_SESSION['theme']['body_header_icon_user']['text'] : 'fa-solid fa-user-circle')." fa-lg fa-fw' style='margin-right: 5px;'></i>";
+					//determine usage of icon or image
+					if ($_SESSION['theme']['body_header_user_image']['boolean'] == true && !empty($_SESSION['user']['contact_uuid']) && is_uuid($_SESSION['user']['contact_uuid'])) {
+						//load if not already in session
+						if (empty($_SESSION['user']['image'])) {
+							$sql = "select attachment_filename, attachment_content from v_contact_attachments where contact_uuid = :contact_uuid and attachment_primary = 1 and attachment_filename is not null and attachment_content is not null";
+							$parameters['contact_uuid'] = $_SESSION['user']['contact_uuid'];
+							$contact_attachment = $this->database->select($sql, $parameters, 'row');
+							if (!empty($contact_attachment) && is_array($contact_attachment)) {
+								$contact_attachment_extension = pathinfo($contact_attachment['attachment_filename'], PATHINFO_EXTENSION);
+								if (in_array($contact_attachment_extension,['jpg','jpeg','png'])) {
+									$_SESSION['user']['image']['filename'] = $contact_attachment['attachment_filename'];
+									$_SESSION['user']['image']['base64'] = $contact_attachment['attachment_content'];
+									$_SESSION['user']['image']['mime'] = mime_content_type($contact_attachment['attachment_filename']);
+								}
+							}
+							unset($sql, $parameters);
+						}
+						if (!empty($_SESSION['user']['image'])) {
+							$user_graphic_size = str_replace(['px','%'], '', ($_SESSION['theme']['body_header_user_image_size']['numeric'] ?? 18));
+							$user_graphic = "<span style=\"display: inline-block; vertical-align: middle; width: ".$user_graphic_size."px; height: ".$user_graphic_size."px; border-radius: 50%; margin-right: 7px; margin-top: ".($user_graphic_size > 18 ? '-'.(ceil(($user_graphic_size - 18) / 2) - 4) : '-4')."px; background-image: url('data:".$_SESSION['user']['image']['mime'].";base64,".$_SESSION['user']['image']['base64']."'); background-repeat: no-repeat; background-size: cover; background-position: center;\"></span>";
+						}
+					}
+					else {
+						$user_graphic_size = 18;
+					}
 					$html .= "<span style='display: inline-block; padding-right: 20px; font-size: 90%;'>\n";
-					$html .= "	<a href='".PROJECT_PATH."/core/users/user_edit.php?id=user' title=\"".$this->text['theme-label-user']."\"><i class='".(!empty($_SESSION['theme']['body_header_icon_user']['text']) ? $_SESSION['theme']['body_header_icon_user']['text'] : 'fa-solid fa-user-circle')." fa-lg fa-fw' style='margin-top: 6px; margin-right: 5px;'></i>".$_SESSION['username']."</a>";
+					$html .= "	<a href='".PROJECT_PATH."/core/users/user_edit.php?id=user' title=\"".$this->text['theme-label-user']."\">".($user_graphic ?? null).$_SESSION['username']."</a>";
 					$html .= "</span>\n";
 				//domain name/selector (sm+)
 					if (!empty($_SESSION['username']) && permission_exists('domain_select') && count($_SESSION['domains']) > 1 && $_SESSION['theme']['domain_visible']['text'] == 'true') {
 						$html .= "<span style='display: inline-block; padding-right: 10px; font-size: 90%;'>\n";
-						$html .= "	<a href='#' id='header_domain_selector_domain' title='".$this->text['theme-label-open_selector']."'><i class='".(!empty($_SESSION['theme']['body_header_icon_domain']['text']) ? $_SESSION['theme']['body_header_icon_domain']['text'] : 'fa-solid fa-earth-americas')." fa-lg fa-fw' style='margin-top: 6px; margin-right: 5px;'></i>".escape($_SESSION['domain_name'])."</a>";
+						$html .= "	<a href='#' id='header_domain_selector_domain' title='".$this->text['theme-label-open_selector']."'><i class='".(!empty($_SESSION['theme']['body_header_icon_domain']['text']) ? $_SESSION['theme']['body_header_icon_domain']['text'] : 'fa-solid fa-earth-americas')." fa-fw' style='vertical-align: middle; font-size: ".($user_graphic_size - 1)."px; margin-top: ".($user_graphic_size > 18 ? '-'.(ceil(($user_graphic_size - 18) / 2) - 4) : '-3')."px; margin-right: 3px; line-height: 40%;'></i>".escape($_SESSION['domain_name'])."</a>";
 						$html .= "</span>\n";
 					}
 				//logout icon

+ 16 - 0
themes/default/app_config.php

@@ -424,6 +424,22 @@
 		$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
 		$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the icon to use next to the current domain in the body header (Side Menu only).";
 		$y++;
+		$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "93ec46b9-741c-4789-8a0d-182b6bed626b";
+		$apps[$x]['default_settings'][$y]['default_setting_category'] = "theme";
+		$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "body_header_user_image";
+		$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
+		$apps[$x]['default_settings'][$y]['default_setting_value'] = "true";
+		$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true";
+		$apps[$x]['default_settings'][$y]['default_setting_description'] = "Whether to display the primary Contact Attachment image assigned to the User (if any) in the body header.";
+		$y++;
+		$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "5a26aa8e-e35c-4f55-a339-28b3c64c2e45";
+		$apps[$x]['default_settings'][$y]['default_setting_category'] = "theme";
+		$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "body_header_user_image_size";
+		$apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric";
+		$apps[$x]['default_settings'][$y]['default_setting_value'] = "18";
+		$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
+		$apps[$x]['default_settings'][$y]['default_setting_description'] = "Set the pixel size of the User's Contact Attachment image displayed in the body header (default: 18).";
+		$y++;
 		$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "2eb360bc-7d11-4aa3-8540-221bd0a560cd";
 		$apps[$x]['default_settings'][$y]['default_setting_category'] = "theme";
 		$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "body_header_text_link_color";