aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2024-09-17 21:41:45 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2024-09-17 22:20:36 +0200
commit26abc86eca7cf6ae95f20e1dc180774d11892aab (patch)
treec646582f842066e92b8cce3ddc593e3bef0a24b7 /apps/user_ldap
parentdc71cb7c3a94eeea69f647f248f3bcbfcecdbe2b (diff)
downloadnextcloud-server-26abc86eca7cf6ae95f20e1dc180774d11892aab.tar.gz
nextcloud-server-26abc86eca7cf6ae95f20e1dc180774d11892aab.zip
feat: add profile pronouns
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/Configuration.php6
-rw-r--r--apps/user_ldap/lib/Connection.php1
-rw-r--r--apps/user_ldap/lib/User/Manager.php1
-rw-r--r--apps/user_ldap/lib/User/User.php6
-rw-r--r--apps/user_ldap/templates/settings.php1
5 files changed, 15 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php
index d436c5c4240..9de180cad76 100644
--- a/apps/user_ldap/lib/Configuration.php
+++ b/apps/user_ldap/lib/Configuration.php
@@ -80,6 +80,8 @@ use Psr\Log\LoggerInterface;
* @property string $ldapAttributeHeadline
* @property string $ldapAttributeBiography
* @property string $ldapAdminGroup
+ * @property string $ldapAttributeBirthDate
+ * @property string $ldapAttributePronouns
*/
class Configuration {
public const AVATAR_PREFIX_DEFAULT = 'default';
@@ -179,6 +181,7 @@ class Configuration {
'ldapAdminGroup' => '',
'ldapAttributeBirthDate' => null,
'ldapAttributeAnniversaryDate' => null,
+ 'ldapAttributePronouns' => null,
];
public function __construct(string $configPrefix, bool $autoRead = true) {
@@ -315,6 +318,7 @@ class Configuration {
case 'ldapAttributeBiography':
case 'ldapAttributeBirthDate':
case 'ldapAttributeAnniversaryDate':
+ case 'ldapAttributePronouns':
$readMethod = 'getLcValue';
break;
case 'ldapUserDisplayName':
@@ -559,6 +563,7 @@ class Configuration {
'ldap_admin_group' => '',
'ldap_attr_birthdate' => '',
'ldap_attr_anniversarydate' => '',
+ 'ldap_attr_pronouns' => '',
];
}
@@ -638,6 +643,7 @@ class Configuration {
'ldap_admin_group' => 'ldapAdminGroup',
'ldap_attr_birthdate' => 'ldapAttributeBirthDate',
'ldap_attr_anniversarydate' => 'ldapAttributeAnniversaryDate',
+ 'ldap_attr_pronouns' => 'ldapAttributePronouns',
];
return $array;
}
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php
index 54dba6d858a..b74c964eb72 100644
--- a/apps/user_ldap/lib/Connection.php
+++ b/apps/user_ldap/lib/Connection.php
@@ -85,6 +85,7 @@ use Psr\Log\LoggerInterface;
* @property string $ldapAttributeBiography
* @property string $ldapAdminGroup
* @property string $ldapAttributeBirthDate
+ * @property string $ldapAttributePronouns
*/
class Connection extends LDAPUtility {
private ?\LDAP\Connection $ldapConnectionRes = null;
diff --git a/apps/user_ldap/lib/User/Manager.php b/apps/user_ldap/lib/User/Manager.php
index 227990401c2..bf1da54823c 100644
--- a/apps/user_ldap/lib/User/Manager.php
+++ b/apps/user_ldap/lib/User/Manager.php
@@ -142,6 +142,7 @@ class Manager {
$this->access->getConnection()->ldapAttributeHeadline,
$this->access->getConnection()->ldapAttributeBiography,
$this->access->getConnection()->ldapAttributeBirthDate,
+ $this->access->getConnection()->ldapAttributePronouns,
];
$homeRule = (string)$this->access->getConnection()->homeFolderNamingRule;
diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php
index 3423455e819..f2a9ba49f2f 100644
--- a/apps/user_ldap/lib/User/User.php
+++ b/apps/user_ldap/lib/User/User.php
@@ -320,6 +320,12 @@ class User {
]);
}
}
+ //User Profile Field - pronouns
+ $attr = strtolower($this->connection->ldapAttributePronouns);
+ if (!empty($attr)) {
+ $profileValues[\OCP\Accounts\IAccountManager::PROPERTY_PRONOUNS]
+ = $ldapEntry[$attr][0] ?? '';
+ }
// check for changed data and cache just for TTL checking
$checksum = hash('sha256', json_encode($profileValues));
$this->connection->writeToCache($cacheKey, $checksum // write array to cache. is waste of cache space
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 4fb24655000..4be24095e99 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -139,6 +139,7 @@ style('user_ldap', 'settings');
<p><label for="ldap_attr_headline"> <?php p($l->t('Headline Field')); ?></label><input type="text" id="ldap_attr_headline" name="ldap_attr_headline" title="<?php p($l->t('User profile Headline will be set from the specified attribute')); ?>" data-default="<?php p($_['ldap_attr_headline_default']); ?>"></p>
<p><label for="ldap_attr_biography"> <?php p($l->t('Biography Field')); ?></label><input type="text" id="ldap_attr_biography" name="ldap_attr_biography" title="<?php p($l->t('User profile Biography will be set from the specified attribute')); ?>" data-default="<?php p($_['ldap_attr_biography_default']); ?>"></p>
<p><label for="ldap_attr_birthdate"> <?php p($l->t('Birthdate Field')); ?></label><input type="text" id="ldap_attr_birthdate" name="ldap_attr_birthdate" title="<?php p($l->t('User profile Date of birth will be set from the specified attribute')); ?>" data-default="<?php p($_['ldap_attr_birthdate_default']); ?>"></p>
+ <p></p><label for="ldap_attr_pronouns"> <?php p($l->t('Pronouns Field')); ?></label><input type="text" id="ldap_attr_pronouns" name="ldap_attr_pronouns" title="<?php p($l->t('User profile Pronouns will be set from the specified attribute')); ?>" data-default="<?php p($_['ldap_attr_pronouns_default']); ?>"></p>
</div>
</div>
<?php print_unescaped($_['settingControls']); ?>