Skip to content

Commit

Permalink
fix prefix expansion function
Browse files Browse the repository at this point in the history
  • Loading branch information
bennet0496 committed Feb 23, 2024
1 parent 5341f68 commit 80ea9e8
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions nextcloud_attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

const VERSION = "1.2.1";

function _(string $val) : string {
function __(string $val) : string {
return NC_PREFIX."_".$val;
}

Expand Down Expand Up @@ -62,10 +62,10 @@ private static function log($line): void

private function is_disabled() : bool
{
$ex = $this->rcmail->config->get(_("exclude_users"), []);
$exg = $this->rcmail->config->get(_("exclude_users_in_addr_books"), []);
$exa = $this->rcmail->config->get(_("exclude_users_with_addr_book_value"), []);
$exag = $this->rcmail->config->get(_("exclude_users_in_addr_book_group"), []);
$ex = $this->rcmail->config->get(__("exclude_users"), []);
$exg = $this->rcmail->config->get(__("exclude_users_in_addr_books"), []);
$exa = $this->rcmail->config->get(__("exclude_users_with_addr_book_value"), []);
$exag = $this->rcmail->config->get(__("exclude_users_in_addr_book_group"), []);

// exclude directly denylisted users
if (is_array($ex) && (in_array($this->rcmail->get_user_name(), $ex) || in_array($this->resolve_username(), $ex) || in_array($this->rcmail->get_user_email(), $ex))) {
Expand Down Expand Up @@ -160,7 +160,7 @@ public function init(): void
'User-Agent' => 'Roundcube Nextcloud Attachment Connector/'.VERSION,
],
'http_errors' => false,
'verify' => $this->rcmail->config->get(_("verify_https"), true)
'verify' => $this->rcmail->config->get(__("verify_https"), true)
]);


Expand Down Expand Up @@ -207,10 +207,10 @@ public function init(): void
$this->include_script("client.js");
$this->include_stylesheet("client.css");

$softllimit = parse_bytes($rcmail->config->get(_("softlimit"), null));
$softllimit = parse_bytes($rcmail->config->get(__("softlimit"), null));
$limit = parse_bytes($rcmail->config->get('max_message_size'));
$rcmail->output->set_env(_("softlimit"), $softllimit > $limit ? null : $softllimit);
$rcmail->output->set_env(_("behavior"), $rcmail->config->get(_("behavior"), "prompt"));
$rcmail->output->set_env(__("softlimit"), $softllimit > $limit ? null : $softllimit);
$rcmail->output->set_env(__("behavior"), $rcmail->config->get(__("behavior"), "prompt"));
}
});

Expand Down Expand Up @@ -283,7 +283,7 @@ public function add_preferences(array $param): array
$prefs = $this->rcmail->user->get_prefs();
// $this->load_config();

$server = $this->rcmail->config->get(_("server"));
$server = $this->rcmail->config->get(__("server"));
$blocks = $param["blocks"];

$username = isset($prefs["nextcloud_login"]) ? $prefs["nextcloud_login"]["loginName"] : $this->resolve_username($this->rcmail->get_user_name());
Expand Down Expand Up @@ -409,7 +409,7 @@ public function poll($ignore): void
*/
public function login() : void
{
$server = $this->rcmail->config->get(_("server"));
$server = $this->rcmail->config->get(__("server"));

if(empty($server)) {
return;
Expand Down Expand Up @@ -452,7 +452,7 @@ public function logout() : void
$password = $prefs["nextcloud_login"]["appPassword"];

if (isset($password)) {
$server = $this->rcmail->config->get(_("server"));
$server = $this->rcmail->config->get(__("server"));

if (!empty($server)) {
try {
Expand Down Expand Up @@ -488,7 +488,7 @@ private function resolve_username(string $user = ""): string
$user = $this->rcmail->user->get_username();
}

$username_tmpl = $this->rcmail->config->get(_("username"));
$username_tmpl = $this->rcmail->config->get(__("username"));

$mail = $this->rcmail->user->get_username("mail");
$mail_local = $this->rcmail->user->get_username("local");
Expand All @@ -510,7 +510,7 @@ private function __check_login(): array

$prefs = $this->rcmail->user->get_prefs();

$server = $this->rcmail->config->get(_("server"));
$server = $this->rcmail->config->get(__("server"));

$username = $this->resolve_username($this->rcmail->get_user_name());

Expand All @@ -520,7 +520,7 @@ private function __check_login(): array
}

//always prompt for app password, as mail passwords are determined to not work regardless
if ($this->rcmail->config->get(_("dont_try_mail_password"), false)) {
if ($this->rcmail->config->get(__("dont_try_mail_password"), false)) {
if (!isset($prefs["nextcloud_login"]) ||
empty($prefs["nextcloud_login"]["loginName"])||
empty($prefs["nextcloud_login"]["appPassword"])) {
Expand Down Expand Up @@ -635,7 +635,7 @@ public function upload(array $data) : array
$prefs = $this->rcmail->user->get_prefs();

// we are not logged in, and know mail password won't work, so we are not trying anything
if ($this->rcmail->config->get(_("dont_try_mail_password"), false)) {
if ($this->rcmail->config->get(__("dont_try_mail_password"), false)) {
if (!isset($prefs["nextcloud_login"]) ||
empty($prefs["nextcloud_login"]["loginName"])||
empty($prefs["nextcloud_login"]["appPassword"])) {
Expand All @@ -647,8 +647,8 @@ public function upload(array $data) : array
$username = isset($prefs["nextcloud_login"]) ? $prefs["nextcloud_login"]["loginName"] : $this->resolve_username($this->rcmail->get_user_name());
$password = isset($prefs["nextcloud_login"]) ? $prefs["nextcloud_login"]["appPassword"] : $this->rcmail->get_user_password();

$server = $this->rcmail->config->get(_("server"));
$checksum = $this->rcmail->config->get(_("checksum"), "sha256");
$server = $this->rcmail->config->get(__("server"));
$checksum = $this->rcmail->config->get(__("checksum"), "sha256");

//server not configured
if (empty($server) || $username === false) {
Expand All @@ -657,7 +657,7 @@ public function upload(array $data) : array
}

// we are not logged in, and know mail password won't work, so we are not trying anything
if ($this->rcmail->config->get(_("dont_try_mail_password"), false)) {
if ($this->rcmail->config->get(__("dont_try_mail_password"), false)) {
if (!isset($prefs["nextcloud_login"]) ||
empty($prefs["nextcloud_login"]["loginName"])||
empty($prefs["nextcloud_login"]["appPassword"])) {
Expand All @@ -667,8 +667,8 @@ public function upload(array $data) : array

// $rcmail->get_user_language()
//get the attachment sub folder
$folder = $this->rcmail->config->get(_("folder"), "Mail Attachments");
$tr_folder = $this->rcmail->config->get(_("folder_translate_name"), false);
$folder = $this->rcmail->config->get(__("folder"), "Mail Attachments");
$tr_folder = $this->rcmail->config->get(__("folder_translate_name"), false);
if (is_array($folder)) {
if($tr_folder && key_exists($this->rcmail->get_user_language(), $folder)) {
$folder = $folder[$this->rcmail->get_user_language()];
Expand Down

0 comments on commit 80ea9e8

Please sign in to comment.