texxasrulez / calendar

GNU Affero General Public License v3.0
15 stars 14 forks source link

If $rcmail_config['username_domain'] needs to be used #1

Closed Bad-and-Mad closed 4 years ago

Bad-and-Mad commented 4 years ago

If $rcmail_config['username_domain'] needs to be used

In some cases (due to the IMAP server) a combination of user and domain name (a complete email address) is required to log on to Roundcube, but normally only the name is used to log on to Nextcloud.

Wouldn't it make sense to include a small extension that cuts the domain name off when you register.

I have introduced a parameter for this in my Caldav Calendar plugin configuration:

roundcubemail/plugins/calendar/config.inc.php:
==============================================

.
.
.

// cut 'username_domain' form username und URL
$config['cut_username_domain'] = true;

.
.
.

For the truncation, I then made a small change in the calendar.php file.

roundcubemail/plugins/calendar/calendar.php (Line 196):
=======================================================

.
.
.

          foreach ($preinstalled_calendars as $index => $cal){
              $url = $cal['caldav_url'];
              $user = $cal['caldav_user'];

              $url = str_replace('%u', $username, $url);
              $user = str_replace('%u', $username, $user);

              $url = str_replace('%l', $local, $url);
              $user = str_replace('%l', $local, $user);

              $url = str_replace('%d', $domain, $url);
              $user = str_replace('%d', $domain, $user);

              $preinstalled_calendars[$index]['caldav_url'] = $url;
              $preinstalled_calendars[$index]['caldav_user'] = $user;

              // by M.W.
              if ($this->rc->config->get('cut_username_domain', true)) {
                   $webmail_domain = '@' . $this->rc->config->get('username_domain', FALSE);
                   $preinstalled_calendars[$index]['caldav_url'] = str_replace($webmail_domain, '', $preinstalled_calendars[$index]['caldav_url']);
                   $preinstalled_calendars[$index]['caldav_user'] = str_replace($webmail_domain, '', $preinstalled_calendars[$index]['caldav_user']);
             }
          }

.
.
.
texxasrulez commented 4 years ago

I have added this to code. I work with folks who can't seem to remember usernames and the likes, so I make them use email address as username for both of our sanity at the office so I haven't used it but your earlier work stands. I do appreciate the assistance & a few other users here will like it as well. Getting back to work updating for latest sabre dav. Thank you again and have a good one ..