diff --git a/app/contacts/contact_attachment.php b/app/contacts/contact_attachment.php
index 3701728cbf..11b7bac938 100644
--- a/app/contacts/contact_attachment.php
+++ b/app/contacts/contact_attachment.php
@@ -34,6 +34,7 @@
//get attachment uuid
$contact_attachment_uuid = $_GET['id'] ?? '';
$action = $_GET['action'] ?? '';
+ $session_id = $_GET['sid'] ?? '';
//get media
if (!empty($contact_attachment_uuid) && is_uuid($contact_attachment_uuid)) {
@@ -45,14 +46,13 @@
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$attachment = $database->select($sql, $parameters ?? null, 'row');
- // view_array($database->message);
unset($sql, $parameters);
$attachment_type = strtolower(pathinfo($attachment['attachment_filename'] ?? '', PATHINFO_EXTENSION));
//determine mime type
$content_type = 'application/octet-stream'; //set default
- $allowed_attachment_types = json_decode($_SESSION['contacts']['allowed_attachment_types']['text'] ?? '', true);
+ $allowed_attachment_types = json_decode($_SESSION['contact']['allowed_attachment_types']['text'] ?? '', true);
if (!empty($allowed_attachment_types)) {
if ($allowed_attachment_types[$attachment_type] != '') {
$content_type = $allowed_attachment_types[$attachment_type];
@@ -64,6 +64,10 @@
header("Content-type: ".$content_type."; charset=utf-8");
header("Content-Disposition: attachment; filename=\"".$attachment['attachment_filename']."\"");
header("Content-Length: ".strlen(base64_decode($attachment['attachment_content'])));
+ if (!empty($session_id)) {
+ header("Cache-Control: max-age=86400"); // 24h
+ header("Expires: ". gmdate('D, d M Y H:i:s \G\M\T', time() + 86400)); // 24h
+ }
echo base64_decode($attachment['attachment_content']);
break;
case 'display':
diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php
index 11c8e08122..605f7045fc 100644
--- a/app/contacts/contact_edit.php
+++ b/app/contacts/contact_edit.php
@@ -496,19 +496,17 @@
$y = 0;
if (!empty($contact_attachments)) {
foreach ($contact_attachments as $row) {
- if (!empty($row['attachment_description'])) {
- $array['contacts'][0]['contact_attachments'][$y]['contact_attachment_uuid'] = $row["contact_attachment_uuid"];
- $array['contacts'][0]['contact_attachments'][$y]['domain_uuid'] = $row["domain_uuid"];
- $array['contacts'][0]['contact_attachments'][$y]['contact_uuid'] = $row["contact_uuid"];
- $array['contacts'][0]['contact_attachments'][$y]['attachment_primary'] = $row["attachment_primary"];
- //$array['contacts'][0]['contact_attachments'][$y]['attachment_filename'] = $row["attachment_filename"];
- //$array['contacts'][0]['contact_attachments'][$y]['attachment_content'] = $row["attachment_content"];
- $array['contacts'][0]['contact_attachments'][$y]['attachment_description'] = $row["attachment_description"];
- //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_date'] = $row["attachment_uploaded_date"];
- //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_user_uuid'] = $row["attachment_uploaded_user_uuid"];
- //$array['contacts'][0]['contact_attachments'][$y]['attachment_size'] = $row["attachment_size"];
- $y++;
- }
+ $array['contacts'][0]['contact_attachments'][$y]['contact_attachment_uuid'] = $row["contact_attachment_uuid"];
+ $array['contacts'][0]['contact_attachments'][$y]['domain_uuid'] = $row["domain_uuid"];
+ $array['contacts'][0]['contact_attachments'][$y]['contact_uuid'] = $row["contact_uuid"];
+ $array['contacts'][0]['contact_attachments'][$y]['attachment_primary'] = $row["attachment_primary"];
+ //$array['contacts'][0]['contact_attachments'][$y]['attachment_filename'] = $row["attachment_filename"];
+ //$array['contacts'][0]['contact_attachments'][$y]['attachment_content'] = $row["attachment_content"];
+ $array['contacts'][0]['contact_attachments'][$y]['attachment_description'] = $row["attachment_description"] ?? null;
+ //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_date'] = $row["attachment_uploaded_date"];
+ //$array['contacts'][0]['contact_attachments'][$y]['attachment_uploaded_user_uuid'] = $row["attachment_uploaded_user_uuid"];
+ //$array['contacts'][0]['contact_attachments'][$y]['attachment_size'] = $row["attachment_size"];
+ $y++;
}
}
@@ -2622,7 +2620,7 @@ if (permission_exists('contact_attachment_view')) {
echo " \n";
echo " \n";
- echo "
\n";
+ echo "
\n";
echo " ".$text['label-description']."\n";
echo "
\n";
echo "
\n";
diff --git a/core/authentication/resources/classes/authentication.php b/core/authentication/resources/classes/authentication.php
index f2199f9b1b..f2995de820 100644
--- a/core/authentication/resources/classes/authentication.php
+++ b/core/authentication/resources/classes/authentication.php
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane
- Portions created by the Initial Developer are Copyright (C) 2008-2023
+ Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -78,6 +78,9 @@ class authentication {
$_SESSION['authentication']['methods'][] = 'database';
}
+ //check if contacts app exists
+ $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/contacts/') ? true : false;
+
//use the authentication plugins
foreach ($_SESSION['authentication']['methods'] as $name) {
//already processed the plugin move to the next plugin
@@ -118,6 +121,12 @@ class authentication {
$result['username'] = $array["username"];
$result['user_uuid'] = $array["user_uuid"];
$result['contact_uuid'] = $array["contact_uuid"];
+ if ($contacts_exists) {
+ $result["contact_organization"] = $array["contact_organization"];
+ $result["contact_name_given"] = $array["contact_name_given"];
+ $result["contact_name_family"] = $array["contact_name_family"];
+ $result["contact_image"] = $array["contact_image"];
+ }
$result['domain_uuid'] = $array["domain_uuid"];
$result['authorized'] = $array["authorized"];
@@ -256,6 +265,13 @@ class authentication {
$_SESSION["user"]["user_uuid"] = $result["user_uuid"];
$_SESSION["user"]["username"] = $result["username"];
$_SESSION["user"]["contact_uuid"] = $result["contact_uuid"];
+ if ($contacts_exists) {
+ $_SESSION["user"]["contact_organization"] = $result["contact_organization"] ?? null;
+ $_SESSION["user"]["contact_name"] = trim(($result["contact_name_given"] ?? '').' '.($result["contact_name_family"] ?? ''));
+ $_SESSION["user"]["contact_name_given"] = $result["contact_name_given"] ?? null;
+ $_SESSION["user"]["contact_name_family"] = $result["contact_name_family"] ?? null;
+ $_SESSION["user"]["contact_image"] = !empty($result["contact_image"]) && is_uuid($result["contact_image"]) ? $result["contact_image"] : null;
+ }
//empty the permissions
if (isset($_SESSION['permissions'])) {
diff --git a/core/authentication/resources/classes/plugins/database.php b/core/authentication/resources/classes/plugins/database.php
index bd684f6df7..26966d88d8 100644
--- a/core/authentication/resources/classes/plugins/database.php
+++ b/core/authentication/resources/classes/plugins/database.php
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane
- Portions created by the Initial Developer are Copyright (C) 2008-2023
+ Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -38,6 +38,10 @@ class plugin_database {
public $domain_uuid;
public $user_uuid;
public $contact_uuid;
+ public $contact_organization;
+ public $contact_name_given;
+ public $contact_name_family;
+ public $contact_image;
public $username;
public $password;
public $key;
@@ -101,7 +105,7 @@ class plugin_database {
$view->assign("project_path", PROJECT_PATH);
$view->assign("login_destination_url", $login_destination);
$view->assign("login_domain_name_visible", $login_domain_name_visible);
- $view->assign("login_domain_names", $login_domain_name);
+ $view->assign("login_domain_names", $login_domain_name);
$view->assign("favicon", $theme_favicon);
$view->assign("login_logo_width", $theme_login_logo_width);
$view->assign("login_logo_height", $theme_login_logo_height);
@@ -166,12 +170,40 @@ class plugin_database {
//set the default status
$user_authorized = false;
+ //check if contacts app exists
+ $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/contacts/') ? true : false;
+
//check the username and password if they don't match then redirect to the login
- $sql = "select u.user_uuid, u.contact_uuid, u.username, u.password, ";
- $sql .= "u.user_email, u.salt, u.api_key, u.domain_uuid, d.domain_name ";
- $sql .= "from v_users as u, v_domains as d ";
- $sql .= "where u.domain_uuid = d.domain_uuid ";
- $sql .= "and (user_type = 'default' or user_type is null) ";
+ $sql = "select ";
+ $sql .= " d.domain_name, ";
+ $sql .= " u.user_uuid, ";
+ $sql .= " u.contact_uuid, ";
+ $sql .= " u.username, ";
+ $sql .= " u.password, ";
+ $sql .= " u.user_email, ";
+ $sql .= " u.salt, ";
+ $sql .= " u.api_key, ";
+ $sql .= " u.domain_uuid ";
+ if ($contacts_exists) {
+ $sql .= ",";
+ $sql .= "c.contact_organization, ";
+ $sql .= "c.contact_name_given, ";
+ $sql .= "c.contact_name_family, ";
+ $sql .= "a.contact_attachment_uuid ";
+ }
+ $sql .= "from ";
+ $sql .= " v_domains as d, ";
+ $sql .= " v_users as u ";
+ if ($contacts_exists) {
+ $sql .= "left join v_contacts as c on u.contact_uuid = c.contact_uuid and u.contact_uuid is not null ";
+ $sql .= "left join v_contact_attachments as a on u.contact_uuid = a.contact_uuid and u.contact_uuid is not null and a.attachment_primary = 1 and a.attachment_filename is not null and a.attachment_content is not null ";
+ }
+ $sql .= "where ";
+ $sql .= " u.domain_uuid = d.domain_uuid ";
+ $sql .= " and (";
+ $sql .= " user_type = 'default' ";
+ $sql .= " or user_type is null";
+ $sql .= " ) ";
if (isset($this->key) && strlen($this->key) > 30) {
$sql .= "and u.api_key = :api_key ";
$parameters['api_key'] = $this->key;
@@ -236,6 +268,12 @@ class plugin_database {
$this->username = $row['username'];
$this->user_email = $row['user_email'];
$this->contact_uuid = $row['contact_uuid'];
+ if ($contacts_exists) {
+ $this->contact_organization = $row['contact_organization'];
+ $this->contact_name_given = $row['contact_name_given'];
+ $this->contact_name_family = $row['contact_name_family'];
+ $this->contact_image = $row['contact_attachment_uuid'];
+ }
//debug info
//echo "user_uuid ".$this->user_uuid."
\n";
@@ -308,6 +346,12 @@ class plugin_database {
$result["user_uuid"] = $this->user_uuid;
$result["domain_uuid"] = $_SESSION['domain_uuid'];
$result["contact_uuid"] = $this->contact_uuid;
+ if ($contacts_exists) {
+ $result["contact_organization"] = $this->contact_organization;
+ $result["contact_name_given"] = $this->contact_name_given;
+ $result["contact_name_family"] = $this->contact_name_family;
+ $result["contact_image"] = $this->contact_image;
+ }
$result["user_email"] = $this->user_email;
$result["sql"] = $sql;
$result["authorized"] = $valid_password;
diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php
index ad14d65d01..dc822d7a01 100644
--- a/core/authentication/resources/classes/plugins/email.php
+++ b/core/authentication/resources/classes/plugins/email.php
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane
- Portions created by the Initial Developer are Copyright (C) 2008-2023
+ Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -403,14 +403,35 @@ class plugin_email {
//clear posted authentication code
unset($_POST['authentication_code']);
+ //check if contacts app exists
+ $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/contacts/') ? true : false;
+
//get the user details
if ($auth_valid) {
//get user data from the database
- $sql = "select user_uuid, username, user_email, contact_uuid from v_users ";
- $sql .= "where user_uuid = :user_uuid ";
+ $sql = "select ";
+ $sql .= " u.user_uuid, ";
+ $sql .= " u.username, ";
+ $sql .= " u.user_email, ";
+ $sql .= " u.contact_uuid ";
+ if ($contacts_exists) {
+ $sql .= ",";
+ $sql .= "c.contact_organization, ";
+ $sql .= "c.contact_name_given, ";
+ $sql .= "c.contact_name_family, ";
+ $sql .= "a.contact_attachment_uuid ";
+ }
+ $sql .= "from ";
+ $sql .= " v_users as u ";
+ if ($contacts_exists) {
+ $sql .= "left join v_contacts as c on u.contact_uuid = c.contact_uuid and u.contact_uuid is not null ";
+ $sql .= "left join v_contact_attachments as a on u.contact_uuid = a.contact_uuid and u.contact_uuid is not null and a.attachment_primary = 1 and a.attachment_filename is not null and a.attachment_content is not null ";
+ }
+ $sql .= "where ";
+ $sql .= " u.user_uuid = :user_uuid ";
if ($settings['users']['unique'] != "global") {
//unique username per domain (not globally unique across system - example: email address)
- $sql .= "and domain_uuid = :domain_uuid ";
+ $sql .= "and u.domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
}
$parameters['user_uuid'] = $_SESSION["user_uuid"];
@@ -472,7 +493,13 @@ class plugin_email {
$result["username"] = $_SESSION["username"];
$result["user_uuid"] = $_SESSION["user_uuid"];
$result["domain_uuid"] = $_SESSION["domain_uuid"];
- $result["contact_uuid"] = $_SESSION["contact_uuid"];
+ if ($contacts_exists) {
+ $result["contact_uuid"] = $_SESSION["contact_uuid"];
+ $result["contact_organization"] = $row["contact_organization"];
+ $result["contact_name_given"] = $row["contact_name_given"];
+ $result["contact_name_family"] = $row["contact_name_family"];
+ $result["contact_image"] = $row["contact_attachment_uuid"];
+ }
$result["authorized"] = $auth_valid ? true : false;
//add the failed login to user logs
diff --git a/core/authentication/resources/classes/plugins/totp.php b/core/authentication/resources/classes/plugins/totp.php
index d170355df0..5bb5134857 100644
--- a/core/authentication/resources/classes/plugins/totp.php
+++ b/core/authentication/resources/classes/plugins/totp.php
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane
- Portions created by the Initial Developer are Copyright (C) 2008-2023
+ Portions created by the Initial Developer are Copyright (C) 2008-2024
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -327,15 +327,35 @@ class plugin_totp {
//clear posted authentication code
unset($_POST['authentication_code']);
+ //check if contacts app exists
+ $contacts_exists = file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/contacts/') ? true : false;
+
//get the user details
if ($auth_valid) {
//get user data from the database
- $sql = "select user_uuid, username, user_email, contact_uuid ";
- $sql .= "from v_users ";
- $sql .= "where user_uuid = :user_uuid ";
+ $sql = "select ";
+ $sql .= " u.user_uuid, ";
+ $sql .= " u.username, ";
+ $sql .= " u.user_email, ";
+ $sql .= " u.contact_uuid ";
+ if ($contacts_exists) {
+ $sql .= ",";
+ $sql .= "c.contact_organization, ";
+ $sql .= "c.contact_name_given, ";
+ $sql .= "c.contact_name_family, ";
+ $sql .= "a.contact_attachment_uuid ";
+ }
+ $sql .= "from ";
+ $sql .= " v_users as u ";
+ if ($contacts_exists) {
+ $sql .= "left join v_contacts as c on u.contact_uuid = c.contact_uuid and u.contact_uuid is not null ";
+ $sql .= "left join v_contact_attachments as a on u.contact_uuid = a.contact_uuid and u.contact_uuid is not null and a.attachment_primary = 1 and a.attachment_filename is not null and a.attachment_content is not null ";
+ }
+ $sql .= "where ";
+ $sql .= " u.user_uuid = :user_uuid ";
if ($settings['users']['unique'] != "global") {
//unique username per domain (not globally unique across system - example: email address)
- $sql .= "and domain_uuid = :domain_uuid ";
+ $sql .= "and u.domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
}
$parameters['user_uuid'] = $_SESSION["user_uuid"];
@@ -392,6 +412,12 @@ class plugin_totp {
$result["user_uuid"] = $_SESSION["user_uuid"];
$result["domain_uuid"] = $_SESSION["domain_uuid"];
$result["contact_uuid"] = $_SESSION["contact_uuid"];
+ if ($contacts_exists) {
+ $result["contact_organization"] = $row["contact_organization"];
+ $result["contact_name_given"] = $row["contact_name_given"];
+ $result["contact_name_family"] = $row["contact_name_family"];
+ $result["contact_image"] = $row["contact_attachment_uuid"];
+ }
$result["authorized"] = $auth_valid ? true : false;
//add the failed login to user logs
diff --git a/resources/classes/menu.php b/resources/classes/menu.php
index 0424c8b690..01e72a33eb 100644
--- a/resources/classes/menu.php
+++ b/resources/classes/menu.php
@@ -1098,6 +1098,10 @@ if (!class_exists('menu')) {
*/
public function menu_vertical($menu_array) {
+ //add multi-lingual support
+ $language = new text;
+ $text = $language->get();
+
//menu brand image and/or text
$html .= "