aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2025-01-31 13:07:21 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2025-01-31 14:53:52 +0100
commitfe71c29ba01175aca965ba2ef8ec24fed8a03847 (patch)
tree098e59b4242049b9168ba25e2e022281ddf841e0
parentf7cf89243fb16c77512d4d762df4dc721fcc842c (diff)
make elements on user privacy settings page translatable, fixes #5205
Closes #5205 Merge request studip/studip!3891
-rw-r--r--app/views/settings/privacy.php19
-rw-r--r--lib/classes/visibility/UserPrivacy.php2
-rw-r--r--lib/classes/visibility/User_Visibility_Settings.php59
-rw-r--r--lib/classes/visibility/VisibilityAbstract.php17
-rw-r--r--lib/classes/visibility/VisibilitySettings.php2
-rw-r--r--lib/classes/visibility/visibilitySettings/Buddies.php13
-rw-r--r--lib/classes/visibility/visibilitySettings/Domain.php10
-rw-r--r--lib/classes/visibility/visibilitySettings/Extern.php25
-rw-r--r--lib/classes/visibility/visibilitySettings/Me.php25
-rw-r--r--lib/classes/visibility/visibilitySettings/Studip.php11
10 files changed, 115 insertions, 68 deletions
diff --git a/app/views/settings/privacy.php b/app/views/settings/privacy.php
index fd1f776..3d44d68 100644
--- a/app/views/settings/privacy.php
+++ b/app/views/settings/privacy.php
@@ -1,7 +1,20 @@
-<?
-# Lifter010: TODO
-use Studip\Button, Studip\LinkButton;
+<?php
+use Studip\Button;
+/**
+ * @var Settings_PrivacyController $controller
+ * @var string $global_visibility
+ * @var string $user_perm
+ * @var UserDomain[] $user_domains
+ * @var User $user
+ * @var bool $online_visibility
+ * @var bool $search_visibility
+ * @var bool $email_visibility
+ * @var string[] $visibilities
+ * @var int $colCount
+ * @var array $homepage_elements
+ * @var string $default_homepage_visibility
+ */
?>
<form method="post" action="<?= $controller->url_for('settings/privacy/global') ?>" class="default">
<?= CSRFProtection::tokenTag() ?>
diff --git a/lib/classes/visibility/UserPrivacy.php b/lib/classes/visibility/UserPrivacy.php
index 1cfbcda..a904e0b 100644
--- a/lib/classes/visibility/UserPrivacy.php
+++ b/lib/classes/visibility/UserPrivacy.php
@@ -38,7 +38,7 @@ class UserPrivacy
/**
* Returns all the categorys and it's items
- * @return array categorys and it's items
+ * @return User_Visibility_Settings[] categorys and it's items
*/
public function getProfileSettings()
{
diff --git a/lib/classes/visibility/User_Visibility_Settings.php b/lib/classes/visibility/User_Visibility_Settings.php
index bd16910..317d80b 100644
--- a/lib/classes/visibility/User_Visibility_Settings.php
+++ b/lib/classes/visibility/User_Visibility_Settings.php
@@ -2,6 +2,8 @@
/**
* PrivacySetting.php - Represents ONE User_Visibility_Settings
*
+ * The PrivacySetting class is one privacySettings in the UserPrivacyTree
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
@@ -10,13 +12,29 @@
* @author Florian Bieringer <florian.bieringer@uni-passau.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
- */
-
-/**
- * The PrivacySetting class is one privacySettings in the UserPrivacyTree
+ *
+ * @property int $id
+ * @property int $visibility_id
+ * @property int $parent_id
+ * @property string $category
+ * @property string $name
+ * @property int|null $state
+ * @property int|null $plugin
+ * @property string $identifier
*/
class User_Visibility_Settings extends SimpleORMap
{
+ protected static function configure($config = [])
+ {
+ $config['db_table'] = 'user_visibility_settings';
+
+ $config['belongs_to']['user'] = [
+ 'class_name' => User::class,
+ 'foreign_key' => 'user_id',
+ ];
+
+ parent::configure($config);
+ }
// parent of the Visibility
public $parent;
@@ -30,7 +48,7 @@ class User_Visibility_Settings extends SimpleORMap
/**
* Find a User_Visibility_Setting by an id or an identifier and a user
*
- * @param type $id
+ * @param ?string $id
*/
public static function find($id = null, $userid = null) {
@@ -93,11 +111,35 @@ class User_Visibility_Settings extends SimpleORMap
/**
* Returns the needed Arguments to build up the Interface
- * @param type $result the given array where the setting stores its data
- * @param type $depth the depth of the setting in the settingstree
+ * @param array $result the given array where the setting stores its data
+ * @param int $depth the depth of the setting in the settingstree
*/
public function getHTMLArgs(&$result, $depth = 0)
{
+ $mapping = [
+ 'commondata' => _('Allgemeine Daten'),
+ 'privatedata' => _('Private Daten'),
+ 'studdata' => _('Studien-/Einrichtungsdaten'),
+ 'additionaldata' => _('Zusätzliche Datenfelder'),
+ 'owncategory' => _('Eigene Kategorien'),
+
+ 'picture' => _('Eigenes Bild'),
+ 'motto' => _('Motto'),
+ 'skype_name' => _('Skype Name'),
+ 'private_phone' => _('Private Telefonnummer'),
+ 'private_cell' => _('Private Handynummer'),
+ 'privadr' => _('Private Adresse'),
+ 'homepage' => _('Homepage-Adresse'),
+ 'news' => _('Ankündigungen'),
+ 'termine' => _('Termine'),
+ 'votes' => _('Fragebögen'),
+ 'studying' => _('Wo ich studiere'),
+ 'lebenslauf' => _('Lebenslauf'),
+ 'hobby' => _('Hobbys'),
+ 'publi' => _('Publikationen'),
+ 'schwerp' => _('Schwerpunkte'),
+ ];
+
if ($this->displayed) {
$entry = [];
$entry['is_header'] = $this->category == 0 && $this->parent_id == 0;
@@ -105,7 +147,7 @@ class User_Visibility_Settings extends SimpleORMap
$entry['id'] = $this->visibilityid;
$entry['state'] = $this->state;
$entry['padding'] = ($depth * 20) . "px";
- $entry['name'] = $this->name ?? '';
+ $entry['name'] = $mapping[$this->identifier] ?? $this->name ?? '';
$result[] = $entry;
// Now add the html args for the children
@@ -115,4 +157,3 @@ class User_Visibility_Settings extends SimpleORMap
}
}
}
-?>
diff --git a/lib/classes/visibility/VisibilityAbstract.php b/lib/classes/visibility/VisibilityAbstract.php
index 71c87ee..2eb5172 100644
--- a/lib/classes/visibility/VisibilityAbstract.php
+++ b/lib/classes/visibility/VisibilityAbstract.php
@@ -14,12 +14,9 @@
/**
* Defines basic attributes and functions a visibilitySetting needs
- *
- * @abstract
*/
abstract class VisibilityAbstract
{
-
protected $activated;
protected $int_representation;
protected $display_name;
@@ -36,8 +33,8 @@ abstract class VisibilityAbstract
/**
* Returns if a visibiltySetting is activated
- *
- * @return boolean true if the visibilitySetting is activated
+ *
+ * @return boolean true if the visibilitySetting is activated
*/
public function isActivated()
{
@@ -46,8 +43,8 @@ abstract class VisibilityAbstract
/**
* Returns the int representation of the visibilitySetting in the database
- *
- * @return int the visibilitySetting in the database
+ *
+ * @return int the visibilitySetting in the database
*/
public function getIntRepresentation()
{
@@ -56,8 +53,8 @@ abstract class VisibilityAbstract
/**
* Returns the displayname of a visibilitySetting
- *
- * @return string the displayname
+ *
+ * @return string the displayname
*/
public function getDisplayName()
{
@@ -66,7 +63,7 @@ abstract class VisibilityAbstract
/**
* Returns the description of a visibilitySetting
- *
+ *
* @return string description of the visibilitySetting
*/
public function getDescription()
diff --git a/lib/classes/visibility/VisibilitySettings.php b/lib/classes/visibility/VisibilitySettings.php
index 01c98cb..61f7858 100644
--- a/lib/classes/visibility/VisibilitySettings.php
+++ b/lib/classes/visibility/VisibilitySettings.php
@@ -67,7 +67,7 @@ class VisibilitySettings
* On first construct we scan the visibilitySettings folder and load all
* applied visibilitySettings
*/
- function __construct()
+ public function __construct()
{
foreach (self::$CLASSES as $classname) {
$tmp = new $classname;
diff --git a/lib/classes/visibility/visibilitySettings/Buddies.php b/lib/classes/visibility/visibilitySettings/Buddies.php
index 6d03dc3..5b20ef2 100644
--- a/lib/classes/visibility/visibilitySettings/Buddies.php
+++ b/lib/classes/visibility/visibilitySettings/Buddies.php
@@ -20,14 +20,14 @@ class Visibility_Buddies extends VisibilityAbstract
// What number does this state get in the database?
protected $int_representation = 2;
- // How is the state displayed in the settings?
- protected $display_name = 'Kontakte';
-
- // Description for the state
- protected $description = "nur für meine Kontakte sichtbar";
+ public function __construct()
+ {
+ $this->display_name = _('Kontakte');
+ $this->description = _('nur für meine Kontakte sichtbar');
+ }
// When do two users have this state
- function verify($user_id, $other_id)
+ public function verify($user_id, $other_id)
{
if ($other_id === 'nobody') {
return false;
@@ -36,4 +36,3 @@ class Visibility_Buddies extends VisibilityAbstract
return $user_id == $other_id || Contact::CountBySQL('owner_id=? AND user_id=?', [$user_id, $other_id]);
}
}
-?>
diff --git a/lib/classes/visibility/visibilitySettings/Domain.php b/lib/classes/visibility/visibilitySettings/Domain.php
index ff05d3a..54b01a0 100644
--- a/lib/classes/visibility/visibilitySettings/Domain.php
+++ b/lib/classes/visibility/visibilitySettings/Domain.php
@@ -20,11 +20,11 @@ class Visibility_Domain extends VisibilityAbstract
// What number does this state get in the database?
protected $int_representation = 3;
- // How is the state displayed in the settings?
- protected $display_name = "Domain";
-
- // Description for the state
- protected $description = "nur für meine Nutzerdomäne sichtbar";
+ public function __construct()
+ {
+ $this->display_name = _('Domäne');
+ $this->description = _('nur für meine Nutzerdomäne sichtbar');
+ }
// When do two users have this state
public function verify($user_id, $other_id)
diff --git a/lib/classes/visibility/visibilitySettings/Extern.php b/lib/classes/visibility/visibilitySettings/Extern.php
index c28a351..c6832ca 100644
--- a/lib/classes/visibility/visibilitySettings/Extern.php
+++ b/lib/classes/visibility/visibilitySettings/Extern.php
@@ -1,7 +1,7 @@
<?php
/**
* Visibility_Extern.php - Verifies if an user may see the extern visibilities
- *
+ *
* By now everything that is marked as visible extern is visible
*
* This program is free software; you can redistribute it and/or
@@ -14,23 +14,22 @@
* @category Stud.IP
*/
class Visibility_Extern extends VisibilityAbstract{
-
+
// Should this state be used?
protected $activated = true;
-
+
// What number does this state get in the database?
protected $int_representation = 5;
-
- // How is the state displayed in the settings?
- protected $display_name = "externe Seiten";
-
- // Description for the state
- protected $description = "auf externen Seiten sichtbar";
-
+
+ public function __construct()
+ {
+ $this->display_name = _('externe Seiten');
+ $this->description = _('auf externen Seiten sichtbar');
+ }
+
// When do two users have this state
- function verify($user_id, $other_id)
+ public function verify($user_id, $other_id)
{
return true;
- }
+ }
}
-?> \ No newline at end of file
diff --git a/lib/classes/visibility/visibilitySettings/Me.php b/lib/classes/visibility/visibilitySettings/Me.php
index 3d3bb90..8b365c2 100644
--- a/lib/classes/visibility/visibilitySettings/Me.php
+++ b/lib/classes/visibility/visibilitySettings/Me.php
@@ -1,7 +1,7 @@
<?php
/**
* Visibility_Me.php - Verifies if the visibility belongs to me
- *
+ *
* For all other users (except root) it is not possible to see the content
*
* This program is free software; you can redistribute it and/or
@@ -13,24 +13,23 @@
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
-class Visibility_Me extends VisibilityAbstract {
-
+class Visibility_Me extends VisibilityAbstract
+{
// Should this state be used?
protected $activated = true;
-
+
// What number does this state get in the database?
protected $int_representation = 1;
-
- // How is the state displayed in the settings?
- protected $display_name = "nur mich selbst";
-
- // Description for the state
- protected $description = "nur für mich sichtbar";
+
+ public function __construct()
+ {
+ $this->display_name = _('nur mich selbst');
+ $this->description = _('nur für mich sichtbar');
+ }
// When do two users have this state
- function verify($user_id, $other_id)
+ public function verify($user_id, $other_id)
{
- return $user_id == $other_id;
+ return $user_id === $other_id;
}
}
-?> \ No newline at end of file
diff --git a/lib/classes/visibility/visibilitySettings/Studip.php b/lib/classes/visibility/visibilitySettings/Studip.php
index 8834c6b..5d08f8c 100644
--- a/lib/classes/visibility/visibilitySettings/Studip.php
+++ b/lib/classes/visibility/visibilitySettings/Studip.php
@@ -20,11 +20,11 @@ class Visibility_Studip extends VisibilityAbstract {
// What number does this state get in the database?
protected $int_representation = 4;
- // How is the state displayed in the settings?
- protected $display_name = "Stud.IP-intern";
-
- // Description for the state
- protected $description = "für alle Stud.IP-Nutzenden sichtbar";
+ public function __construct()
+ {
+ $this->display_name = _('Stud.IP-intern');
+ $this->description = _('für alle Stud.IP-Nutzenden sichtbar');
+ }
// When do two users have this state
public function verify($user_id, $other_id)
@@ -32,4 +32,3 @@ class Visibility_Studip extends VisibilityAbstract {
return $other_id != "nobody";
}
}
-?>