init commit

This commit is contained in:
2025-02-23 20:52:25 +01:00
parent 5b272d6536
commit 9971cd719b
1719 changed files with 281982 additions and 2 deletions

View File

@ -0,0 +1,8 @@
* text=auto
*.sql text
*.php text
*.inc text
*.js text
*.md text
*.php.dist text

View File

@ -0,0 +1,276 @@
# Changelog identity switch plugin
## Release 1.1.12
- Added: Additional interegre cast when loading parameter "refresh_interval" from RC
- Chaged: Removing # of unread mail from selected identity when switching
## Release 1.1.11
- Changed: Active identity is now also show in list of selctable identities
## Release 1.1.10
- Changed: Updates to menu bar
## Release 1.1.9
- Fixed: Typo in identity_switch_newmails.php:88
## Release 1.1.8
- Fixed: Typo in identity_switch_newmails.php:88
- Added: Object check in identity_switch.php:523
- Added: Sleep() call to create_menu() - was too fast
## Release 1.1.7
- Update: Mariadb version 10.6.19 support
## Release 1.1.6
- Fixed: Typo in identity_switch.php
## Release 1.1.5
- Added: Debug section in README.MD
- Added: Configuration parameter 'wait'
## Release 1.1.4
- Fixed: Closing stream error
- Added: Update of unseen couter from leaving identity
- Added: Cast 'newmail_check' variable to integer
## Release 1.1.3
- Changed: Updating newmail count on identity switch improved
## Release 1.1.2
- Fixed: Typo in catch_newmails()
## Release 1.1.1
- Added: Possibility to create/edit default identity label for drop down menu
- Fixed: Saving notification mode for default identity
## Release 1.1.0
- Changed: README.MD
- Changed: SQL scripts
## Release 1.1
- Changed: Preconfiguration of identity settings modified
- Fixed: Disabled identities now ignored
- Fixed: Unseen count sometimes wrong, when switching identity
- Fixed: Some typos in code
- Changed renamed from identy_switch to identity_switch
- Fixed: Modification / deletion of default identity in setting handled properly
## Release 1.0.45
- Fixed: 'Delay' not set in identity_switch_newmail.php
## Release 1.0.44
- Added: New mail check delay configuration parameter
- Fixed: Logging in identity_switch_newmail.php
## Release 1.0.43
- Fixed: php8.1-fpm.sock break down resulting in missing return records
## Release 1.0.41
- Fixed: PHP warning regarding missing special folders
## Release 1.0.40
- Fixed: PHP warning regarding missing special folders
## Release 1.0.39
- Fixed: PHP warning regarding missing special folders
## Release 1.0.38
- Fixed: Unssen counter return from catch casted to integer.
## Release 1.0.37
- Fixed: INSTALL_PATH in identity_switch_newmails.php
## Release 1.0.36
- Fixed: In classic skin, selection list of identities was not in foreground
## Release 1.0.35
- Fixed: INSTALL_PATH in identity_switch_newmails.php
- Changed: Position of dropdown in classic skin
## Release 1.0.34
- Added: Some more comments in config.inc.php.dist
- Fixed: In some cases "special folders" were empty. Fix will handle.
## Release 1.0.33
- Fixed: PHP Warning in identity_switch.php:363
## Release 1.0.32
- Changed: "imap_pwd" now 128 bytes long
## Release 1.0.31
- Fixed: Hostname instead of identity label in desktop test notification shown
## Release 1.0.30
- Added: Debug support extended
- Added: New mail check now waiting for data file
## Release 1.0.29
- Fixed: Loop error in ident_switch_newmail.php
- Fixed: Usage of special characters '%' for SMTP hosts in config/config.inc.php
## Release 1.0.28
- Added: Mentioning limitiations in README.md
## Release 1.0.27
- Fixed: 'interval' not loaded when creating new identity
- Fixed: Some config.php.dist parameter not set as default for identity
## Release 1.0.26
- Added: IMAP folder delimiter configuration parameter
- Added: Wildcard for domain in configuration parameter
- Fixed: Typo in README.md
## Release 1.0.25
- French translation provided by @rglemaire
## Release 1.0.24
- Fixed: Bug in preferences (identity edit)
- Fixed: Bug when trying to send mails with default identity
## Release 1.0.23
- Skipped
## Release 1.0.22
- Skipped
## Release 1.0.21
- Fixed: Minor bug in refresh interval
- Added: Debug configuration option
## Release 1.0.20
- Fixed: Special folder handling
- Fxied: "Check all folders" flag not accepted
## Release 1.0.19
- Fixed isse #14: Bug in composer.json
## Release 1.0.18
- Fixed issue #8: CodeShakingSheep pull request merged to fix MySQL DB table creation for migration from ident_switch plugin
- Fixed issue #9: Protocol selection for SMTP now possible
- Fixed issue #10: CodeShakingSheep pull request merged to fix ident_switch migration DB INSERT statement
- Fixed issue #13: PHP 8.1 warnings for 'show_real_foldernames'
- Fixed issue #13: PHP 8.1 warnings for unknown special folder names
## Release 1.0.17
- identityswitch menu is now automatically closed if user clicks somewhere on screen
## Release 1.0.15
- Bug fixed for 'show_real_foldernames'.
- Special message before record has been created added.
## Release 1.0.14
- Error message prefixed by "idsw".
- If identity is set as default, hen disable identity_switch handling.
- If a new record is created, it is not possible to return any error message due to RoundCube design.
- Fixed some error messages.
## Release 1.0.13
- Thank to https://github.com/HLFH .
- type 'tsl' fixed to 'tls'.
- some README.MD types fixed.
- support for SMTP array in config.inc.php ($config['smtp_host']).
## Release 1.0.12
- 'dont_override' option documented.
- Bug fixed when changing standard identity name.
- Some bugs fixed when trying to edit identity record.
## Release 1.0.11
- Some typos fixed.
## Release 1.0.10
- When switching identity unseen counter update is forced.
## Release 1.0.9
- Notification handling slightly modified.
## Release 1.0.8
- Some fixes to README.md.
## Release 1.0.7
- Unseen count on active account moved to identity_switch_do_switch().
## Release 1.0.6
- Fixing some unread counter problems.
- Bug in SQlite and postgres SQL files.
## Release 1.0.5
- Some more changes to CSS file.
- Changed CSS and JS compressor.
- Creation of identity selection menu restricted to mail template.
## Release 1.0.4
- Function create_menu() moved back to identity_switch.php.
## Release 1.0.3
- Updates to CSS files.
## Release 1.0.2
- Updates to CSS files.
## Release 1.0.1
- SMTP not working properly for default account.
## Release 1.0.0
- Code completly rewritten.
- New-mail check added.
- Ntification about new mail added.

View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -0,0 +1,127 @@
# identity switch plugin for Roundcube
![](https://img.shields.io/packagist/v/toteph42/identity_switch.svg)
![](https://img.shields.io/packagist/l/toteph42/identity_switch.svg)
![](https://img.shields.io/packagist/dt/toteph42/identity_switch.svg)
This plugin is based on the [ident_switch](https://github.com/dougluce/ident_switch "ident_switch") plugin. It is completly rewritten and additional features have been added.
This plugin allows users to switch between different accounts in a single Roundcube session like this:
![Screenshot example](./assets/Pic01.png "Identity selection")
### Where to start ###
* In settings interface create new identity.
* For all identities except default you will see new section of settings - "Data of your identity" (see screenshot below). Enter data required to connect to remote server. Don't forget to check **Enabled** check box.
* After you have created at least one identity with active plugin you will see combobox in the top right corner instead of plain text field with account name. It will allows you to switch to another account.
### Settings ###
![Plugin settings](./assets/Pic02.png "Connection settings")
* **Enabled** - Enables plugin (i.e. account switching) for this identity.
* **Label** - Text that will be displayed in drop down list for this identity.
* **IMAP**
* **Server host name** - Host name for imap server. If left blank 'localhost' will be used.
* **Encryption** - Connection security (None, SSL or TLS).
* **Port** - Port on server to connect to. If left blank 143 will be used.
* **Username** - Login used *for IMAP and SMTP servers*.
* **Password** - Password used *for IMAP and SMTP servers*. It's stored encrypted in database.
* **Delimiter** - IMAP folder delimiter.
* **SMTP**
* **Server host name** - Host name for imap server. If left blank 'localhost' will be used.
* **Encryption** - Connection security (None, SSL or TLS).
* **Port** - Port on server to connect to. If left blank 25 will be used.
### Settings for active identity ###
![Plugin settings](./assets/Pic04.png "New mail checking")
If you've selected an identity (or use the default identity), you may change settings for new-mail check cycle in `Settings` -> `Preference` -> `User Interface`.
![Plugin settings](./assets/Pic05.png "Notification settings")
If you've selected an identity (or use the default identity), you may change settings for notification settings in `Settings` -> `Preference` -> `Mailbox view`.
### Additional settings ###
![Plugin settings](./assets/Pic03.png "Notification settings")
* **Check all folders...** - Select this option, if you want all folders to be check for new mails.
* **Display browser notification...** - Select this option, if you want to get a changed icon for this site. Please be aware, that the icon will change only one time, even if there a new mails for multiple identities available (until next new-mail check-cycle is started).
* **Display desktop notification...** - Select this option, if you want to get a desktop notification about how many new mails were available. Please be aware, you need to allow your mail server site in your browser configuration to send notifications to your desktop.
* **Close desktop notification** - Specify how many seconds should be visible before it is automatically been closed.
* **Play sound...** - Select this option, if you want a sound notification. Please be aware, that only sound will be played one time only, even if there are new mails for multiple identities available (until next new-mail check cycle is started). If you hear no sound playing, please check your browser settings, if auto-play of sound files is enabled.
* **Refresh...** - Specify the new-mail check cycle in minutes.
![Plugin settings](./assets/Pic06.png "E-Mail notification")
If you receive new mails, the number of new mails will be shown in identity selection menue.
### Configuration ###
There is a file `config.inc.php.dist` in the plugin directory available with mutiple configuration parameters. This file can be used to specify some configuration settings. Please copy file to `config.inc.php` and change there your settings.
If you want to change sound, icon or desktop icon, please checkout `alert.mp3`, `alert.ico` and `alert.gif` in sub-directory `assets`.
### Locking configuration ###
You may use the `dont_override` configuration option in your **RoundCube** configuration file `config/config.inc.php` to lock some options from being overriden. This plugins supports the following options to be protected:
* `draft_mbox`, `sent_mbox`, `junk_mbox`, `trash_mbox` - User cannot override preconfigured special folder name.
* `check_all_folders` - User cannot override preconfigured flag to check all folders.
* `newmail_notifier_basic`, `newmail_notifier_desktop`, `newmail_notifier_sound` - User cannot override preconfigured notification setting.
### Performance ###
New mail checking is performed in background asynchronously. This has the effect that the new mail counter is not always updated immediately after login - it may take some time before this has been performed. It heavily depends on the number of identities you're using.
If you've select **Check all folders**, this has a huge impact on the time new-mail checking need to collect information. If you have hundreds of folders in your mail box, each of the boxes will be check for new mails.
Please don't forget to set `Special Folders` in `Settings` -> `Preferences`. All folders specified there (and their sub-folders) will be excluded from new-mail checking.
### Version compatibility ###
* Versions 1.x - for Roundcube v1.6. Requires PHP version >= 8.0.0.
### Limitations ###
This plugin only supports `Classic`, `Elatic`, `Larry` and `Hivemail` skin. If you wan't to get another skin to be supoorted, then please contact me. I can add support for other skin if you buy for it.
### Migration from ident_switch plugin ###
If you've installed the `ident_switch` plugin, there is a migration file available in `SQL` subdirectory which copies the content of the old table to the new table and deletes the `ident_switch` table. To make this happen, you should first install this plugin (during installation a table `identity_switch` will automatically be created) and then you should appy `SQL/migrate.sql`.
### Upgrade ###
If you want to upgrade to this plugin, please be aware, the name of the data base table has changed. In subdirectoy `SQL` ther
are scrpst avaibale to ugrade your installation. These scriüps must called manually (look for `20241122.sql`). This script must be called after installation of `identity_switch` plugin, but before removing `identy_switch` plugin.
### License ###
This plugin is released under the [GNU General Public License v3.0](./LICENSE).
### Debugging ###
If you encounter problems with plugin, take a look at the option available in `config.inc.php`.
If you encounter **connection problems**, it is a good idea to enable **RoundCube** available debugging options:
```php
// Log IMAP conversation to <log_dir>/imap.log or to syslog
$config['imap_debug'] = true;
// Log sent messages to <log_dir>/sendmail.log or to syslog
$config['smtp_log'] = true;
// Log SMTP conversation to <log_dir>/smtp or to syslog
$config['smtp_debug'] = true;
```
Then switch to the identity which does not work as expected. In log files you'll see how **RoundCube** is trying to establish connection.
### Donation ###
If you like this software and you want support my work, feel free to send me a donation:
<a href="https://www.paypal.com/donate/?hosted_button_id=DS6VK49NAFHEQ" target="_blank" rel="noopener"> <img src="https://www.paypalobjects.com/en_US/DK/i/btn/btn_donateCC_LG.gif" alt="Donate with PayPal"/> </a>
[[List of changes](./Changes.md)]

View File

@ -0,0 +1,46 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with phpmyadmin
INSERT INTO identity_switch(
`id`,
`user_id`,
`iid`,
`label`,
`flags`,
`imap_user`,
`imap_pwd`,
`imap_host`,
`imap_port`,
`imap_delim`,
`smtp_host`,
`smtp_port`,
`drafts`,
`sent`,
`junk`,
`trash`
)
SELECT
`id`,
`user_id`,
`iid`,
`label`,
`flags`,
`username`,
`password`,
`imap_host`,
`imap_port`,
`imap_delimiter`,
`smtp_host`,
`smtp_port`,
`drafts_mbox`,
`sent_mbox`,
`junk_mbox`,
`trash_mbox`
FROM
ident_switch;
DROP TABLE IF EXISTS ident_switch;

View File

@ -0,0 +1,42 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with phpmyadmin
CREATE TABLE IF NOT EXISTS `identity_switch`(
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` INT(10) UNSIGNED NOT NULL,
`iid` INT(10) UNSIGNED NOT NULL,
`label` VARCHAR(32) NOT NULL,
`flags` INT NOT NULL DEFAULT 0,
`imap_user` VARCHAR(64),
`imap_pwd` VARCHAR(128),
`imap_host` VARCHAR(64),
`imap_port` SMALLINT DEFAULT NULL,
`imap_delim` CHAR(1),
`newmail_check` SMALLINT DEFAULT 300,
`notify_timeout` SMALLINT DEFAULT 10,
`smtp_host` VARCHAR(64),
`smtp_port` SMALLINT DEFAULT NULL,
`drafts` VARCHAR(64) DEFAULT '',
`sent` VARCHAR(64) DEFAULT '',
`junk` VARCHAR(64) DEFAULT '',
`trash` VARCHAR(64) DEFAULT '',
UNIQUE `user_id_label`(`user_id`, `label`),
CONSTRAINT `fk_identity_user_id`
FOREIGN KEY(`user_id`)
REFERENCES `users`(`user_id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_identity_identity_id`
FOREIGN KEY(`iid`)
REFERENCES `identities`(`identity_id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
PRIMARY KEY(`id`),
INDEX `IX_identity_switch_user_id`(`user_id`),
INDEX `IX_identity_switch_iid`(`iid`)
);

View File

@ -0,0 +1,12 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with phpmyadmin
DROP TABLE IF EXISTS `identity_switch`;
RENAME TABLE
`identy_switch` TO `identity_switch`;

View File

@ -0,0 +1,35 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with: https://sqliteonline.com/
CREATE TABLE IF NOT EXISTS identity_switch(
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL
REFERENCES users(user_id)
ON DELETE CASCADE ON UPDATE CASCADE,
iid INTEGER NOT NULL
REFERENCES identities(identity_id)
ON DELETE CASCADE ON UPDATE CASCADE UNIQUE,
label VARCHAR(32),
flags INTEGER NOT NULL DEFAULT 0,
imap_user VARCHAR(64),
imap_pwd VARCHAR(128),
imap_host VARCHAR(64),
imap_port SMALLINT DEFAULT 0,
imap_delim CHAR(1),
newmail_check SMALLINT DEFAULT 300,
notify_timeout SMALLINT DEFAULT 10,
smtp_host VARCHAR(64),
smtp_port SMALLINT DEFAULT 0,
drafts VARCHAR(64) DEFAULT '',
sent VARCHAR(64) DEFAULT '',
junk VARCHAR(64) DEFAULT '',
trash VARCHAR(64) DEFAULT '',
UNIQUE (user_id, label)
);
CREATE INDEX IX_identity_switch_user_id ON identity_switch(user_id);

View File

@ -0,0 +1,12 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with: https://sqliteonline.com/
DROP TABLE IF EXISTS identity_switch;
ALTER TABLE
identy_switch
RENAME TO identity_switch;

View File

@ -0,0 +1,36 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with: https://sqliteonline.com/
CREATE TABLE IF NOT EXISTS `identity_switch`(
`id` INTEGER NOT NULL ,
`user_id` INTEGER NOT NULL
REFERENCES users(user_id)
ON DELETE CASCADE ON UPDATE CASCADE,
`iid` INTEGER NOT NULL
REFERENCES identities(identity_id)
ON DELETE CASCADE ON UPDATE CASCADE UNIQUE,
`label` TEXT,
`flags` INT NOT NULL DEFAULT 0,
`imap_user` TEXT,
`imap_pwd` TEXT,
`imap_host` TEXT,
`imap_port` SMALLINT DEFAULT 0,
`imap_delim` CHAR(1),
`newmail_check` SMALLINT DEFAULT 300,
`notify_timeout` SMALLINT DEFAULT 10,
`smtp_host` TEXT,
`smtp_port` SMALLINT DEFAULT 0,
`drafts` TEXT DEFAULT '',
`sent` TEXT DEFAULT '',
`junk` TEXT DEFAULT '',
`trash` TEXT DEFAULT '',
UNIQUE (user_id, label)
);
CREATE INDEX IX_identity_switch_user_id ON identity_switch(user_id);
CREATE INDEX IX_identity_switch_iid on identity_switch(iid);

View File

@ -0,0 +1,12 @@
--
-- Identity switch RoundCube Bundle
--
-- @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
-- @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
--
-- Created with: https://sqliteonline.com/
DROP TABLE IF EXISTS `identity_switch`;
ALTER TABLE
`identy_switch` RENAME TO `identity_switch`;

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

View File

@ -0,0 +1,71 @@
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$(function() {
// Reformat tables
var fld = $('table[class="propform"]');
fld.attr('class', 'propform cols-sm-6-6');
var fld = $('td[class="title col-sm-4"]');
fld.attr('class', 'title col-sm-6');
var fld = $('td[class="col-sm-8"]');
fld.attr('class', 'col-sm-6');
var fld = $('input[name="_enabled"]');
if (fld.prop('value') == 0)
fld.prop('checked', false);
identity_switch_enabled();
});
function identity_switch_enabled() {
var fld = $('input[name="_enabled"]');
if (fld.prop('value') == undefined)
return;
if (!fld.is(':checked')) {
var val = 0;
var dis = true;
} else {
var val = 1;
var dis = false;
}
fld.prop('value', val);
$('input[name="_label"]').attr('disabled', dis);
$('input[name="_imap_host"]').attr('disabled', dis);
$('input[name="_imap_port"]').attr('disabled', dis);
$('select[name="_imap_auth"]').attr('disabled', dis);
$('input[name="_imap_user"]').attr('disabled', dis);
$('input[name="_imap_pwd"]').attr('disabled', dis);
$('input[name="_imap_delim"]').attr('disabled', dis);
$('input[name="_smtp_host"]').attr('disabled', dis);
$('input[name="_smtp_port"]').attr('disabled', dis);
$('select[name="_smtp_auth"]').attr('disabled', dis);
$('input[name="_check_all_folder"]').attr('disabled', dis);
$('input[name="_notify_basic"]').attr('disabled', dis);
$('input[name="_notify_desktop"]').attr('disabled', dis);
$('select[name="_notify_timeout"]').attr('disabled', dis);
$('input[name="_notify_sound"]').attr('disabled', dis);
$('select[name="_refresh_interval"]').attr('disabled', dis);
// Disable all links
$('a[name^="_notify"]').each(function(i, obj) {
if (dis) {
obj.setAttribute('save', obj.getAttribute('onclick'));
obj.removeAttribute('href');
obj.removeAttribute('onclick');
} else {
if (obj.getAttribute('save'))
obj.setAttribute('onclick', obj.getAttribute('save'));
obj.setAttribute('href', '#');
}
});
}

View File

@ -0,0 +1,2 @@
$(function(){var fld=$('table[class="propform"]');fld.attr('class','propform cols-sm-6-6');var fld=$('td[class="title col-sm-4"]');fld.attr('class','title col-sm-6');var fld=$('td[class="col-sm-8"]');fld.attr('class','col-sm-6');var fld=$('input[name="_enabled"]');if(fld.prop('value')==0)fld.prop('checked',false);identity_switch_enabled();});function identity_switch_enabled(){var fld=$('input[name="_enabled"]');if(fld.prop('value')==undefined)return;if(!fld.is(':checked')){var val=0;var dis=true;}else{var val=1;var dis=false;}fld.prop('value',val);$('input[name="_label"]').attr('disabled',dis);$('input[name="_imap_host"]').attr('disabled',dis);$('input[name="_imap_port"]').attr('disabled',dis);$('select[name="_imap_auth"]').attr('disabled',dis);$('input[name="_imap_user"]').attr('disabled',dis);$('input[name="_imap_pwd"]').attr('disabled',dis);$('input[name="_imap_delim"]').attr('disabled',dis);$('input[name="_smtp_host"]').attr('disabled',dis);$('input[name="_smtp_port"]').attr('disabled',dis);$('select[name="_smtp_auth"]').attr('disabled',dis);$('input[name="_check_all_folder"]').attr('disabled',dis);$('input[name="_notify_basic"]').attr('disabled',dis);$('input[name="_notify_desktop"]').attr('disabled',dis);$('select[name="_notify_timeout"]').attr('disabled',dis);$('input[name="_notify_sound"]').attr('disabled',dis);$('select[name="_refresh_interval"]').attr('disabled',dis);$('a[name^="_notify"]').each(function(i,obj){if(dis){obj.setAttribute('save',obj.getAttribute('onclick'));obj.removeAttribute('href');obj.removeAttribute('onclick');}else{if(obj.getAttribute('save'))obj.setAttribute('onclick',obj.getAttribute('save'));obj.setAttribute('href','#');}});}

View File

@ -0,0 +1,131 @@
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
#identity_switch_menu {
margin-right: 0px;
overflow: hidden;
text-overflow: ellipsis;
margin-top: -65px;
font-weight: bold;
padding-left: 2rem;
text-align: left;
width: 240px;
border: 1px solid #ccc !important;
border-radius: .4em;
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
top: 10px;
left: 200px;
position: relative;
float: inline-start;
}
#identity_switch_dropdown {
position: fixed;
z-index: 1;
padding: 0 .5rem 0 0;
min-width: 240px;
max-width: 240px;
will-change: transform;
top: 0;
left: 168px;
margin-left: 0;
margin-top: 18px;
width: 240px;
transform: translate3d(63px, 49px, 0px);
border-bottom-color: rgb(212, 219, 222);
box-shadow: 3px 3px 5px #414141;
max-height: 150px;
overflow-x: hidden;
color: #212529;
display: none;
margin-left: -.5rem;
border-color: #d4dbde;
border-radius: .4rem;
border-bottom: 1px solid #f7f7f7;
background-color: rgba(255, 255, 255);
font-weight: 400;
line-height: 35px;
}
#identity_switch_dropdown ul {
list-style: none;
margin: 0;
padding: 0;
}
#identity_switch_dropdown li {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
position: relative;
left: 0px;
width: 220px;
}
#identity_switch_dropdown a {
padding: 0 .5rem;
white-space: nowrap;
color: #2c363a;
background: none;
}
#identity_switch_dropdown li:hover {
background-color: rgb(236, 236, 236);
}
#identity_switch_dropdown a:hover {
text-decoration: none;
}
#identity_switch_dropdown .unseen {
position: absolute;
top: 0;
right: 0;
min-width: 2em;
line-height: 1.4rem;
margin: 7.7px 0px 7.7px 0px;
padding: 0 .3em;
border-radius: .4em;
background: #37beff;
color: #fff;
text-align: center;
font-weight: 700;
}
html.dark-mode #identity_switch_menu {
margin-right: 0px;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 5px;
font-weight: bold;
padding-left: 2rem;
text-align: left;
width: 240px;
border: 1px solid #ccc !important;
border-radius: .4em;
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='beige' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
top: 10px;
left: inherit;
position: relative;
float: inline-start;
}
html.dark-mode #identity_switch_dropdown {
background-color: #343a40;
border-color: #4d6066;
box-shadow: 3px 3px 5px #374549;
}
html.dark-mode #identity_switch_dropdown a {
color: #c5d1d3;
}
html.dark-mode #identity_switch_dropdown li:hover {
background-color: #374549;
}

View File

@ -0,0 +1,241 @@
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$(function() {
$sw = $('#identity_switch_menu');
isOk = false;
switch (rcmail.env['skin']) {
case 'larry':
isOk = identity_switch_addCbLarry($sw);
break;
case 'classic':
isOk = identity_switch_addCbClassic($sw);
break;
case 'elastic':
case 'hivemail':
isOk = identity_switch_addCbElastic($sw);
default:
break;
}
if (isOk)
$sw.show();
});
// Catch all mouse clicks
$(document).click(function(event) {
// Check for left button
if (event.button == 0) {
var id = event.target.id;
var d = $('#identity_switch_dropdown');
if (id != 'identity_switch_menu' && !d.is(':hidden'))
d.hide();
}
});
// Plugin initialization
function identity_switch_init() {
rcmail.addEventListener('plugin.identity_switch_notify', identity_switch_notify)
.addEventListener('init', function() {
// Bind to messages list select event, so favicon will be reverted on message preview too
if (rcmail.message_list)
rcmail.message_list.addEventListener('select', identity_switch_stop_notify);
});
}
// Set menu position
function identity_switch_addCbLarry($sw) {
var $truName = $('.topright .username');
if ($truName.length > 0) {
if ($sw.length > 0) {
$sw.prependTo('#taskbar');
$truName.hide();
// Move our selection menu a bit to the right
$('#identity_switch_menu').css('padding-top', '4px').css('padding-bottom', '4px');
$('#identity_switch_dropdown').css('margin-left', '-92px');
return true;
}
}
return false;
}
// Set menu position
function identity_switch_addCbClassic($sw) {
var $taskBar = $('#taskbar');
if ($taskBar.length > 0) {
$taskBar.prepend($sw);
// Move our selection menu a bit to the right
$('#identity_switch_menu').css('left', '-10px')
.css('top', '-5px');
$('#identity_switch_dropdown')
.css('left', '190px')
.css('top', '-40px');
return true;
}
return false;
}
// Set menu position
function identity_switch_addCbElastic($sw) {
var $taskBar = $('.header-title.username');
$sw.css('background-color', 'transparent').css('padding','4px 0 0 2rem');
if ($taskBar.length > 0) {
$taskBar.prepend($sw);
$taskBar.css('margin-left', '20px');
// Remove text from <span>
var $node = $('.header-title.username');
var newNode = $('<' + $node[0].nodeName + '/>');
$.each( $node[0].attributes, function ( i, attribute ) {
newNode.attr(attribute.name, attribute.value);
});
$node.children().each(function(){
newNode.append(this);
});
$node.replaceWith(newNode);
// Move our selection menu a bit to the bottom
$('#identity_switch_menu')
.css('height', '30px')
.css('width', '180px');
$('#identity_switch_dropdown')
.css('left', '9px')
.css('margin-top', '0');
return true;
}
return false;
}
// Change userid in composer window to select proper identity
function identity_switch_fixIdent(iid) {
if (parseInt(iid) > 0)
$("#_from").val(iid);
}
// Open/close menu
function identity_switch_toggle_menu() {
var d = $('#identity_switch_dropdown');
if (d.is(':hidden')) {
// reload window to show new mail counter in menu
d.load(location.href + ' #identity_switch_dropdown > *', '');
d.show();
$('#messagelist-fixedcopy').css('z-index', 'auto');
} else
d.hide();
}
// Switch identity
function identity_switch_run(iid) {
rcmail.env.unread_counts = {};
rcmail.http_post('plugin.identity_switch_do', { 'identity_switch_iid': iid });
}
// Perform notification
function identity_switch_notify(ctl) {
var autoplay = decodeURI(ctl[0].autoplay);
var notification = decodeURI(ctl[0].notification);
var title = decodeURI(ctl[0].title);
for (var i = 1; i < ctl.length; i++) {
var e = $('#identity_switch_opt_' + ctl[i].iid);
if (ctl[i].unseen == '0')
e.text('');
else
e.text(ctl[i].unseen);
if (ctl[i].basic !== undefined)
identity_switch_basic();
if (ctl[i].desktop !== undefined)
identity_switch_desktop(title, ctl[i].desktop.text, ctl[i].desktop.timeout, notification);
if (ctl[i].sound !== undefined)
identity_switch_sound(autoplay);
}
}
// Stop notification
function identity_switch_stop_notify(prop)
{
// Revert original favicon
if (rcmail.env.favicon_href && rcmail.env.favicon_changed && (!prop || prop.action != 'check-recent')) {
$('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[rel="shortcut icon"]');
rcmail.env.favicon_changed = 0;
}
}
// Browser notification: window.focus and favicon change
function identity_switch_basic()
{
var w = rcmail.is_framed() ? window.parent : window;
w.focus();
var src = rcmail.assets_path('plugins/identity_switch/assets');
// We cannot simply change a href attribute, we must to replace the link element (at least in FF)
var link = $('<link rel="shortcut icon">').attr('href', src + '/alert.ico');
var olink = $('link[rel="shortcut icon"]', w.document);
if (!rcmail.env.favicon_href)
rcmail.env.favicon_href = olink.attr('href');
rcmail.env.favicon_changed = 1;
link.replaceAll(olink);
}
// Desktop notification
// - Require window.Notification API support (Chrome 22+ or Firefox 22+)
function identity_switch_desktop(title, msg, timeout, errmsg)
{
if (!('Notification' in window) || window.Notification.permission !== "granted") {
alert(decodeURIComponent(errmsg));
window.Notification.requestPermission();
return;
}
var popup = new window.Notification(decodeURIComponent(title), {
dir: "auto",
lang: "",
body: decodeURIComponent(msg),
icon: rcmail.assets_path('plugins/identity_switch/assets/alert.gif')
});
popup.onclick = function() { this.close(); };
setTimeout(function() { popup.close(); }, timeout * 1000);
}
// Sound notification
function identity_switch_sound(errmsg) {
var src = rcmail.assets_path('plugins/identity_switch/assets/alert');
if (!('Notification' in window) || window.Notification.silent) {
alert(decodeURIComponent(errmsg));
return;
}
if (!('Navigator' in window) && window.Navigator.getAutoplayPolicy &&
window.Navigator.getAutoplayPolicy('mediaelement') != 'allowed') {
alert(decodeURIComponent(errmsg));
window.Notification.requestPermission();
return;
}
new Audio(src + '.mp3').play();
}

View File

@ -0,0 +1,123 @@
#identity_switch_menu {
margin-right: 0;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 5px;
font-weight: 700;
padding-left: 2rem;
text-align: left;
width: 240px;
height: 21px;
border: 1px solid #ccc !important;
border-radius: .4em;
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='%23343a40' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
top: -65px;
left: 240px;
position: relative;
float: inline-start
}
#identity_switch_dropdown {
position: fixed;
z-index: 1;
padding: 0 .5rem 0 0;
/* min-width: 250px; */
max-width: 260px;
width: 260px;
will-change: transform;
top: 14px;
left: 178px;
margin-left: 0;
margin-top: 0;
transform: translate3d(63px, 49px, 0);
border-bottom-color: #78b3cc;
box-shadow: 0px 3px 5px #414141a1 !important;
max-height: 150px;
overflow-x: hidden;
color: #212529;
display: none;
border-color: #d4dbde;
border-radius: .4rem;
border-bottom: 1px solid #f7f7f7;
background-color: rgba(255, 255, 255);
font-weight: 400;
line-height: 35px
}
#identity_switch_dropdown ul {
list-style: none;
margin: 0;
padding: 0
}
#identity_switch_dropdown li {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
position: relative;
left: 0;
width: 100%
}
#identity_switch_dropdown a {
padding: 0 .5rem;
white-space: nowrap;
color: #2c363a;
background: 0 0;
text-decoration: none;
}
#identity_switch_dropdown li:hover {
background-color: #bbe6f8
}
#identity_switch_dropdown a:hover {
text-decoration: none
}
#identity_switch_dropdown .unseen {
position: absolute;
top: 0;
right: 0;
min-width: 2em;
line-height: 1.4rem;
margin: 7.7px 0 7.7px 0;
padding: 0 .3em;
border-radius: .4em;
background: #37beff;
color: #fff;
text-align: center;
font-weight: 700
}
html.dark-mode #identity_switch_menu {
margin-right: 0;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 5px;
font-weight: 700;
padding-left: 2rem;
text-align: left;
width: 240px;
border: 1px solid #ccc !important;
border-radius: .4em;
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='beige' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") no-repeat left .75rem center/8px 10px;
top: 10px;
left: inherit;
position: relative;
float: inline-start
}
html.dark-mode #identity_switch_dropdown {
background-color: #343a40;
border-color: #4d6066;
box-shadow: 3px 3px 5px #374549
}
html.dark-mode #identity_switch_dropdown a {
color: #c5d1d3
}
html.dark-mode #identity_switch_dropdown li:hover {
background-color: #374549
}

View File

@ -0,0 +1,4 @@
$(function(){$sw=$('#identity_switch_menu');isOk=false;switch(rcmail.env['skin']){case'larry':isOk=identity_switch_addCbLarry($sw);break;case'classic':isOk=identity_switch_addCbClassic($sw);break;case'elastic':case'hivemail':isOk=identity_switch_addCbElastic($sw);default:break;}if(isOk)$sw.show();});$(document).click(function(event){if(event.button==0){var id=event.target.id;var d=$('#identity_switch_dropdown');if(id!='identity_switch_menu'&&!d.is(':hidden'))d.hide();}});function identity_switch_init(){rcmail.addEventListener('plugin.identity_switch_notify',identity_switch_notify).addEventListener('init',function(){if(rcmail.message_list)rcmail.message_list.addEventListener('select',identity_switch_stop_notify);});}function identity_switch_addCbLarry($sw){var $truName=$('.topright .username');if($truName.length>0){if($sw.length>0){$sw.prependTo('#taskbar');$truName.hide();$('#identity_switch_menu').css('padding-top','4px').css('padding-bottom','4px');$('#identity_switch_dropdown').css('margin-left','-92px');return true;}}return false;}function identity_switch_addCbClassic($sw){var $taskBar=$('#taskbar');if($taskBar.length>0){$taskBar.prepend($sw);$('#identity_switch_menu').css('left','-10px').css('top','-5px');$('#identity_switch_dropdown').css('left','190px').css('top','-40px');return true;}return false;}function identity_switch_addCbElastic($sw){var $taskBar=$('.header-title.username');$sw.css('background-color','transparent').css('padding','4px 0 0 2rem');if($taskBar.length>0){$taskBar.prepend($sw);$taskBar.css('margin-left','20px');var $node=$('.header-title.username');var newNode=$('<'+$node[0].nodeName+'/>');$.each($node[0].attributes,function(i,attribute){newNode.attr(attribute.name,attribute.value);});$node.children().each(function(){newNode.append(this);});$node.replaceWith(newNode);$('#identity_switch_menu').css('height','30px').css('width','180px');$('#identity_switch_dropdown').css('left','9px').css('margin-top','0');return true;}return false;}function identity_switch_fixIdent(iid){if(parseInt(iid)>0)$("#_from").val(iid);}function identity_switch_toggle_menu(){var d=$('#identity_switch_dropdown');if(d.is(':hidden')){d.load(location.href+' #identity_switch_dropdown > *','');d.show();$('#messagelist-fixedcopy').css('z-index','auto');}else
d.hide();}function identity_switch_run(iid){rcmail.env.unread_counts={};rcmail.http_post('plugin.identity_switch_do',{'identity_switch_iid':iid});}function identity_switch_notify(ctl){var autoplay=decodeURI(ctl[0].autoplay);var notification=decodeURI(ctl[0].notification);var title=decodeURI(ctl[0].title);for(var i=1;i<ctl.length;i++){var e=$('#identity_switch_opt_'+ctl[i].iid);if(ctl[i].unseen=='0')e.text('');else
e.text(ctl[i].unseen);if(ctl[i].basic!==undefined)identity_switch_basic();if(ctl[i].desktop!==undefined)identity_switch_desktop(title,ctl[i].desktop.text,ctl[i].desktop.timeout,notification);if(ctl[i].sound!==undefined)identity_switch_sound(autoplay);}}function identity_switch_stop_notify(prop){if(rcmail.env.favicon_href&&rcmail.env.favicon_changed&&(!prop||prop.action!='check-recent')){$('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[rel="shortcut icon"]');rcmail.env.favicon_changed=0;}}function identity_switch_basic(){var w=rcmail.is_framed()?window.parent:window;w.focus();var src=rcmail.assets_path('plugins/identity_switch/assets');var link=$('<link rel="shortcut icon">').attr('href',src+'/alert.ico');var olink=$('link[rel="shortcut icon"]',w.document);if(!rcmail.env.favicon_href)rcmail.env.favicon_href=olink.attr('href');rcmail.env.favicon_changed=1;link.replaceAll(olink);}function identity_switch_desktop(title,msg,timeout,errmsg){if(!('Notification'in window)||window.Notification.permission!=="granted"){alert(decodeURIComponent(errmsg));window.Notification.requestPermission();return;}var popup=new window.Notification(decodeURIComponent(title),{dir:"auto",lang:"",body:decodeURIComponent(msg),icon:rcmail.assets_path('plugins/identity_switch/assets/alert.gif')});popup.onclick=function(){this.close();};setTimeout(function(){popup.close();},timeout*1000);}function identity_switch_sound(errmsg){var src=rcmail.assets_path('plugins/identity_switch/assets/alert');if(!('Notification'in window)||window.Notification.silent){alert(decodeURIComponent(errmsg));return;}if(!('Navigator'in window)&&window.Navigator.getAutoplayPolicy&&window.Navigator.getAutoplayPolicy('mediaelement')!='allowed'){alert(decodeURIComponent(errmsg));window.Notification.requestPermission();return;}new Audio(src+'.mp3').play();}

View File

@ -0,0 +1,51 @@
{
"name" : "toteph42/identity_switch",
"type" : "roundcube-plugin",
"description" : "This plugin allows users to switch between different accounts (and check for new mails) in a single Roundcube session.",
"homepage" : "https://github.com/totep42/identity_switch",
"keywords" : [
"identity",
"select identity",
"imap",
"smtp",
"mail",
"switch",
"new mail check",
"notify new mail"
],
"license" : "GPL-3.0+",
"authors" : [{
"name" : "Florian Däumling",
"email" : "toteph42@github.com",
"role" : "Developer"
}
],
"repositories" : [{
"type" : "composer",
"url" : "https://plugins.roundcube.net"
}
],
"require" : {
"php" : ">=8.0.0",
"roundcube/plugin-installer" : ">=0.1.3",
"ext-ctype" : "*"
},
"conflict" : {
"elm/identity_smtp" : "*",
"dougluce/ident_switch" : "*"
},
"support" : {
"issues" : "https://github.com/totep42/identity_switch/issues"
},
"extra" : {
"roundcube" : {
"min-version" : "1.6",
"sql-dir" : "SQL"
}
},
"config": {
"allow-plugins": {
"roundcube/plugin-installer": true
}
}
}

View File

@ -0,0 +1,81 @@
<?php
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$config['identity_switch.config'] = [
// Preconfigured settings for different mail domains.
// Appropriate set of values is searched by mapping domain of email (from identity) to array key.
// Please note:
// - Using config.inc.php is only done, when you enter identity_switch configuration panel!
// - On Startup of RoundCube all configuration parameters were loaded from data base, so changes to this
// configuration file does not apply.
// Domain part of email address
// If you use '*' as wild card, the domain and tld of the identity is used
'domain.tld' => [
// IMAP host name, use ssl:// or tls:// notation if needed, for no security use imap://
// Must always start with scheme.
// If you use '*' as wild card, the domain and tld of the identity is used
// Defaults to 'not specified'
'imap' => 'imap://imap.domain.tld:447',
// Folder delimiter
// Defaults to 'not specified'
'delimiter' => '.',
// Login name, can be 'email' (full address from identity), 'mbox' (only mailbox part).
// Any other value is treated as 'not specified' (default).
'user' => 'email',
// SMTP host name, use ssl:// or tls:// notation if needed, for no security use imap://
// Must always start with scheme.
// If you use '*' as wild card, the domain and tld of the identity is used
// Defaults to 'not specified'
'smtp' => 'imap://smtp.domain.tld:130',
],
// 'another.tld' => [
// 'imap' => 'tls://imap.another.tld',
// 'smtp' => 'tls://smtp.another.tld',
// 'user' => 'mbox',
// ],
// Catch all (if you specify multiple 'catch all', then only first one is used)
//
// '*' => [
// 'imap' => 'ssl://imap.*',
// 'smtp' => 'tls://smtp.*',
// 'delimiter' => '/',
// ],
// Allow logging to 'logs/identity_switch.log'. Default is false.
'logging' => false,
// Allow new mail checking. Default is true.
'check' => true,
// Specify interval for checking of new mails. Default is 5 min. (5 * 60 sec.)
'interval' => 300,
// Specify number of microseconds between each new mail check. Default is 0 micoseconds.
// If value is greater than 1000000 (1 second) delay time is rounded to seconds.
'delay' => 0,
// Specify no. of retries for reading data from mail server. Default is 10 times.
'retries' => 10,
// Max. number of seconds to wait for response from identity_switch_newmails.php
// Defaults to 60 seconds
'wait' => 60,
// Enable some debugging messges saved in log file. Default is false
'debug' => false,
];

View File

@ -0,0 +1,81 @@
<?php
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$config['identity_switch.config'] = [
// Preconfigured settings for different mail domains.
// Appropriate set of values is searched by mapping domain of email (from identity) to array key.
// Please note:
// - Using config.inc.php is only done, when you enter identity_switch configuration panel!
// - On Startup of RoundCube all configuration parameters were loaded from data base, so changes to this
// configuration file does not apply.
// Domain part of email address
// If you use '*' as wild card, the domain and tld of the identity is used
'domain.tld' => [
// IMAP host name, use ssl:// or tls:// notation if needed, for no security use imap://
// Must always start with scheme.
// If you use '*' as wild card, the domain and tld of the identity is used
// Defaults to 'not specified'
'imap' => 'imap://imap.domain.tld:447',
// Folder delimiter
// Defaults to 'not specified'
'delimiter' => '.',
// Login name, can be 'email' (full address from identity), 'mbox' (only mailbox part).
// Any other value is treated as 'not specified' (default).
'user' => 'email',
// SMTP host name, use ssl:// or tls:// notation if needed, for no security use imap://
// Must always start with scheme.
// If you use '*' as wild card, the domain and tld of the identity is used
// Defaults to 'not specified'
'smtp' => 'imap://smtp.domain.tld:130',
],
// 'another.tld' => [
// 'imap' => 'tls://imap.another.tld',
// 'smtp' => 'tls://smtp.another.tld',
// 'user' => 'mbox',
// ],
// Catch all (if you specify multiple 'catch all', then only first one is used)
//
// '*' => [
// 'imap' => 'ssl://imap.*',
// 'smtp' => 'tls://smtp.*',
// 'delimiter' => '/',
// ],
// Allow logging to 'logs/identity_switch.log'. Default is false.
'logging' => false,
// Allow new mail checking. Default is true.
'check' => true,
// Specify interval for checking of new mails. Default is 5 min. (5 * 60 sec.)
'interval' => 300,
// Specify number of microseconds between each new mail check. Default is 0 micoseconds.
// If value is greater than 1000000 (1 second) delay time is rounded to seconds.
'delay' => 0,
// Specify no. of retries for reading data from mail server. Default is 10 times.
'retries' => 10,
// Max. number of seconds to wait for response from identity_switch_newmails.php
// Defaults to 60 seconds
'wait' => 60,
// Enable some debugging messges saved in log file. Default is false
'debug' => false,
];

View File

@ -0,0 +1,655 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
/**
*
* Data structure
*
* config configuration data
* logging allow logging to 'logs/identity_switch.log'
* debug log debug message to 'logs/identity_switch.log'
* check allow new mail checking
* interval specify interval for checking of new mails
* delay delay between each new mail check
* retries specify no. of retries for reading data from mail server
* wait max. number of seconds to wait for response from identity_switch_newmails.php
* language language used
* cache all session variables used by identity switch
* data unseen exchange data file
* fp file pointer
* iid active identity
* lock lock all activities
* [n] cached identity data
* label label
* flags glags
* imap_user IMAP user
* imap_pwd IMAP password
* imap_host IMAP host
* imap_delim golder delimiter
* imap_port IMAP port
* smtp_host SMTP host
* smtp_port SMTP port
* notify_timeout notification timeout
* newmail_check new mail check interval
* folders special folder name array
* unseen # of unseen messages
* checked_last last time checked
* notify notify user flag
*
*/
require_once INSTALL_PATH.'plugins/identity_switch/identity_switch_prefs.php';
require_once INSTALL_PATH.'plugins/identity_switch/identity_switch_newmails.php';
class identity_switch extends identity_switch_prefs
{
/**
* Initialize Plugin
*
* {@inheritDoc}
* @see rcube_plugin::init()
*/
function init(): void
{
$rc = rcmail::get_instance();
// identity switch hooks and actions
$this->add_hook('startup', [ $this, 'on_startup' ]);
$this->add_hook('render_page', [ $this, 'on_render_page' ]);
$this->add_hook('smtp_connect', [ $this, 'on_smtp_connect' ]);
$this->add_hook('template_object_composeheaders', [ $this, 'on_object_composeheaders' ]);
$this->register_action('identity_switch_do', [ $this, 'identity_switch_do_switch' ]);
// preference hooks and actions
parent::init();
// notification hooks and action
if ($rc->output instanceof rcmail_output_html) {
$rc->output->add_script('identity_switch_init();', 'head_top');
$rc->output->include_script('../../plugins/identity_switch/assets/identity_switch.js');
}
// new mail hooks and action
$this->add_hook('new_messages', [ $this, 'catch_newmails' ]);
$this->add_hook('refresh', [ $this, 'check_newmails' ]);
$this->add_hook('ready', [ $this, 'check_newmails' ]);
// LDAP hooks
if ($rc->config->get('ldapAliasSync', null))
$this->add_hook('storage_connect', [ $this, 'override_ldap_password' ]);
$this->include_stylesheet('assets/identity_switch.css');
}
/**
* Startup script
*
* @param array $args
* @return array
*/
function on_startup(array $args): array
{
$rc = rcmail::get_instance();
// not default user?
if (isset($_SESSION['username']) && strcasecmp($rc->user->data['username'], $_SESSION['username']) !== 0)
{
// we are impersonating
$rc->config->set('imap_cache', null);
$rc->config->set('messages_cache', false);
if ($args['task'] == 'mail')
{
$this->add_texts('localization/');
$rc->config->set('create_default_folders', false);
}
}
return $args;
}
/**
* Dispatch action
*
* @param array $args
* @return array
*/
function on_render_page(array $args): array
{
$rc = rcmail::get_instance();
switch ($rc->task)
{
case 'mail':
$this->add_texts('localization');
if (self::get('iid') > 0)
{
if ($args['template'] == 'mail')
{
while (self::get('lock'))
usleep(100);
self::create_menu();
}
break;
}
$iid = $rc->user->get_identity();
$iid = $iid['identity_id'];
// create defaults for default user
self::get($iid);
// set default user number
self::set('iid', $iid);
// collect data for default identity
$i = $rc->user->get_identity();
self::set($iid, 'label', $i['name']);
self::set($iid, 'flags', self::ENABLED);
// swap IMAP data
self::set($iid, 'imap_user', $_SESSION['username']);
self::set($iid, 'imap_pwd', $_SESSION['password']);
self::set($iid, 'imap_host', $_SESSION['storage_host']);
self::set($iid, 'imap_port', $_SESSION['storage_port']);
if ($_SESSION['storage_ssl'] == 'ssl')
self::set($iid, 'flags', self::get($iid, 'flags') | self::IMAP_SSL);
if ($_SESSION['storage_ssl'] == 'tls')
self::set($iid, 'flags', self::get($iid, 'flags') | self::IMAP_TLS);
self::set($iid, 'imap_delim', $_SESSION['imap_delimiter']);
// Sswap SMTP data
$hosts = $rc->config->get('smtp_host');
if (!is_array ($hosts))
$hosts = [ $_SESSION['storage_host'] => $hosts ];
$host = null;
foreach ($hosts as $imap => $smtp)
{
if (!strcmp($imap, $_SESSION['storage_host']))
{
$host = $smtp;
break;
}
}
if (!$host)
{
self::write_log('Cannot discover associated SMTP host to IMAP server "'.$_SESSION['storage_host'].'" '.
'- substituting with "localhost"');
$host = 'localhost';
}
// parse host name for special characters
$host = rcube_utils::parse_host($host);
if (substr($host, 3, 1) == ':')
{
if (strtolower(substr($host, 0, 3)) == 'ssl')
{
self::set($iid, 'flags', self::get($iid, 'flags') | self::SMTP_SSL);
$host = substr($host, 6);
self::set($iid, 'smtp_port', 465);
}
elseif (strtolower(substr($host, 0, 3)) == 'tls')
{
self::set($iid, 'flags', self::get($iid, 'flags') | self::SMTP_TLS);
$host = substr($host, 6);
self::set($iid, 'smtp_port', 587);
}
// Unknown protocoll
if (($p = strpos($host, ':')) !== false)
{
self::set($iid, 'smtp_port', substr($host, $p + 1));
$host = substr($host, 0, $p);
}
}
self::set($iid, 'smtp_host', $host);
$prefs = $rc->user->get_prefs();
// swap nofication data
$p = 'newmail_notifier_';
if (isset($prefs['check_all_folders']) && $prefs['check_all_folders'])
self::set($iid, 'flags', self::get($iid, 'flags') | self::CHECK_ALLFOLDER);
foreach ([ 'basic' => self::NOTIFY_BASIC,
'desktop' => self::NOTIFY_DESKTOP,
'sound' => self::NOTIFY_SOUND] as $k => $v)
{
if (isset($prefs[$p.$k]) && $prefs[$p.$k] == 1)
self::set($iid, 'flags', self::get($iid, 'flags') | $v);
}
if (isset($prefs[$p.'_desktop_timeout']))
self::set($iid, 'notify_timeout', $prefs[$p.'_desktop_timeout']);
// swap new mail check interval
self::set($iid, 'newmail_check', (int)(isset($prefs['refresh_interval']) ? $prefs['refresh_interval'] :
$rc->config->get('refresh_interval')));
// swap special folder names
$box = [];
foreach (rcube_storage::$folder_types as $mbox)
$box[$mbox] = isset($prefs[$mbox.'_mbox']) ? $prefs[$mbox.'_mbox'] : '';
self::set($iid, 'folders', $box);
if (isset($prefs['show_real_foldernames']) && $prefs['show_real_foldernames'] == 'true')
self::set($iid, 'flags', self::get($iid, 'flags') | self::SHOW_REAL_FOLDER);
self::set($iid, 'flags', self::get($iid, 'flags') | (isset($prefs['lock_special_folders']) &&
$prefs['lock_special_folders'] == true ? self::LOCK_SPECIAL_FOLDER : 0));
// swap data of alternate accounts
$sql = 'SELECT isw.* '.
'FROM '.$rc->db->table_name(self::TABLE).' isw '.
'INNER JOIN '.$rc->db->table_name('identities').' ii ON isw.iid=ii.identity_id '.
'WHERE isw.user_id = ?';
$q = $rc->db->query($sql, $rc->user->data['user_id']);
while ($r = $rc->db->fetch_assoc($q))
{
// is it default identity?
if ($iid == $r['iid'])
self::set($iid, 'label', $r['label']);
else {
// load default settings
self::get($r['iid']);
// swap saved data
foreach ($r as $k => $v)
{
// skip some fields
if ($k == 'id' || $k == 'user_id' || $k == 'iid')
continue;
if ($k == 'folders')
$v = is_null($v) ? [] : json_decode($v);
self::set($r['iid'], $k, $v);
}
}
}
if ($args['template'] == 'mail')
self::create_menu();
break;
case 'settings':
$this->include_script('assets/identity_switch-form.js');
break;
}
return $args;
}
/**
* Create selection menu
*/
protected function create_menu(): void
{
// build identity table
$acc = [];
foreach (self::get() as $iid => $rec)
{
// identity switch enabled?
if (is_numeric($iid) && is_array($rec) && ($rec['flags'] & self::ENABLED))
$acc[rcube::Q($rec['label'])] = [ 'iid' => $iid, 'unseen' => $rec['unseen'] ];
}
// sort identities
ksort($acc);
// render UI if user has extra accounts
if (count($acc) > 1)
{
$iid = self::get('iid');
$div = '<div id="identity_switch_menu" '.
'class="form-control" '.
'onclick="identity_switch_toggle_menu()">'.
rcube::Q(self::get($iid, 'label')).
'<div id="identity_switch_dropdown"><ul>';
foreach ($acc as $name => $rec)
$div .= '<li onclick="identity_switch_run('.$rec['iid'].');"><a href="#">'.$name.
'<span id="identity_switch_opt_'.$rec['iid'].'" class="unseen">'.
($rec['iid'] == $iid ? 0 : ($rec['unseen'] > 0 ? $rec['unseen'] : '')).'</span></a></li>';
rcmail::get_instance()->output->add_footer($div.'</ul></div></div>');
}
}
/**
* Perform identity switch
*/
function identity_switch_do_switch(): void
{
$rc = rcmail::get_instance();
$rc->session->remove('folders');
$rc->session->remove('unseen_count');
// update current unseen counter
self::set('lock', 1);
$iid = self::get('iid');
$folders = [ 'INBOX' ];
$storage = $rc->get_storage();
if (self::get($iid, 'flags') & identity_switch_prefs::CHECK_ALLFOLDER)
$folders += $storage->list_folders_subscribed('', '*'. null, null, true);
$unseen = 0;
foreach ($folders as $mbox)
$unseen += $storage->count($mbox, 'UNSEEN', true, false);
self::set($iid, 'unseen', $unseen);
self::set($iid, 'checked_last', time());
// get new account
$rec = self::get($iid = rcube_utils::get_input_value('identity_switch_iid', rcube_utils::INPUT_POST));
// swap data
self::swap($iid, $rec);
self::set('lock', 0);
$this->write_log('Switching to identity "'.$rec['imap_user'].'"');
$rc->output->redirect(
[
'_task' => 'mail',
'_mbox' => 'INBOX',
]
);
}
/**
* Send mail
*
* @param array $args
* @return array
*/
function on_smtp_connect(array $args): array
{
$rc = rcmail::get_instance();
$rec = self::get(self::get('iid'));
$args['smtp_user'] = $rec['imap_user'];
$args['smtp_pass'] = $rec['imap_pwd'] && ($rec['flags'] & (self::SMTP_SSL|self::SMTP_TLS)) ?
$rc->decrypt($rec['imap_pwd']) : '';
$args['smtp_host'] = $rec['smtp_host'].':'.$rec['smtp_port'];
if ($rec['flags'] & (self::SMTP_SSL|self::SMTP_TLS))
$args['smtp_host'] = ($rec['flags'] & self::SMTP_SSL ? 'ssl' : 'tls').'://'.$args['smtp_host'];
return $args;
}
/**
* Change userid in composer window to select proper identity
*
* @param array $args
*/
function on_object_composeheaders(array $args): void
{
if ($args['id'] == '_from')
{
$rc = rcmail::get_instance();
if (strcasecmp($_SESSION['username'], $rc->user->data['username']) !== 0)
$rc->output->add_script('identity_switch_fixIdent('.self::get('iid').');', 'docready');
}
}
/**
* Override LDAP password
*
* @param array $args
* @return array
*/
function override_ldap_password(array $args): array
{
$rc = rcmail::get_instance();
// do not do anything for default identity
if (strcasecmp($args['user'], $rc->user->data['username']) === 0)
return $args;
$sql = 'SELECT imap_pwd FROM '.$rc->db->table_name(self::TABLE).' WHERE imap_user = ?';
$q = $rc->db->query($sql, $args['user']);
$r = $rc->db->fetch_assoc($q);
if(is_array($r))
{
if($r['imap_pwd'])
{
$this->write_log('Override IMAP password for user "' .$args['user'].'"');
// replace 'password' with the password you want to use
$args['pass'] = $rc->decrypt($r['imap_pwd']);
}
}
return $args;
}
/**
* Catch new mail notification for default user
*/
function catch_newmails(array $args): array
{
// unexpected input?
if (empty($args['diff']['new']))
return $args;
$iid = self::get('iid');
$n = 0;
foreach (explode(':', $args['diff']['new']) as $id)
if (strlen($id) > 1)
$n++;
self::set($iid, 'unseen', (int)(self::get($iid, 'unseen')) + $n);
self::set($iid, 'checked_last', time());
self::set($iid, 'notify', true);
self::do_notify();
return $args;
}
/**
* Check for number of new mails
*/
function check_newmails($args) {
// get configuration
if(!is_array($cfg = self::get('config')))
return $args;
// new mail check disabled?
if (!self::get('config', 'check'))
{
self::write_log('New mail check disabled - stop checking', true);
return $args;
}
// only allow call under special conditions
if (!isset($args['action']) || ($args['action'] != 'refresh' && $args['action'] != 'getunread'))
return $args;
self::write_log('Starting new mail check with arguments "'.serialize($args).'"."', true);
self::write_log('Configuration loaded "'.serialize($cfg).'".', true);
// make a copy of our cached data
$cache = self::get();
// check if we're outside waiting window
$chk = 0;
foreach ($cache as $iid => $rec)
{
if (!is_integer($iid))
continue;
if ((int)$rec['flags'] & identity_switch_prefs::ENABLED && (int)$rec['checked_last'] + $cfg['interval'] < time())
$chk++;
else
unset($cache[$iid]);
}
if (!$chk)
{
if (!$chk)
self::write_log('No accounts to check - stop checking', true);
return $args;
}
self::write_log('Check allowed for '.$chk.' account(s)', true);
if ($chk && !file_exists($cfg['cache']))
{
// The host, we want to reach out
if (!is_resource($cfg['fp']))
{
$host = ($_SERVER['SERVER_PORT'] != '80' ? 'ssl://' : '').$_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'];
self::set('config', 'fp', $cfg['fp'] = new identity_switch_rpc());
if (is_string($cfg['fp']->open($host)))
{
$this->write_log('Cannot open connection - '.$cfg['fp'].' for '.$host.' - stop checking');
return $args;
}
self::write_log('Host "'.$host.'" connected', true);
}
// save data for background sharing
file_put_contents($cfg['cache'], serialize($cache));
self::write_log('Cache file "'.$cfg['cache'].'" created');
// prepare request (no fopen() usage because "allow_url_fopen=FALSE" may be set in PHP.INI)
$req = '/plugins/identity_switch/identity_switch_newmails.php?iid=0&cache='.urlencode($cfg['cache']);
if (!$cfg['fp']->write($req))
{
if (is_resource($cfg['fp']))
fclose($cfg['fp']);
self::set('config', 'fp', $cfg['fp'] = 0);
$this->write_log('Cannot write to "'.$host.'" Request: "'.$req.'" - stop checking');
return $args;
}
self::write_log('Starting request "'.$req.'"', true);
}
// check for data file
$n = 0;
while (!file_exists($cfg['data']))
{
if ($n++ > self::get('wait'))
{
self::write_log('No data file exist - stop checking', true);
return $args;
}
sleep (1);
}
// load data file
self::write_log('Loading and deleting data file', true);
$wrk = file_get_contents($cfg['data']);
@unlink($cfg['data']);
// process data lines
if (is_string($wrk))
{
foreach (explode('###', $wrk) as $line)
{
if (!$line)
continue;
$r = explode('##', $line);
// #35 bad formatted returned string
if (!is_array($r))
continue;
// Check for error message
if (!$r[1] && isset($r[2]))
{
$this->write_log('NewMail error: '.$r[2]);
continue;
}
$rec = &self::get($r[1]);
if ($r[2] != $rec['unseen'])
{
if ($r[2] > $rec['unseen'])
{
// Allow to notify
if (!($rec['flags'] & self::UNSEEN))
self::set($r[1], 'notify', true);
else
self::set($r[1], 'flags', $rec['flags'] & ~self::UNSEEN);
}
self::set($r[1], 'unseen', $r[2]);
}
self::set($r[1], 'checked_last', $r[0]);
}
self::write_log('Starting notification.', true);
self::do_notify();
}
return $args;
}
/**
* Do notification
*/
function do_notify(): void
{
$rc = rcmail::get_instance();
$this->add_texts('localization');
// control array
$ctl = [];
$ctl[0] = [
'autoplay' => rawurlencode($this->gettext('notify.err.autoplay')),
'notification' => rawurlencode($this->gettext('notify.err.notification')),
'title' => rawurlencode($this->gettext('notify.title')),
];
$cnt = 1;
$sound = false;
$basic = false;
foreach (self::get() as $iid => $rec)
{
// skip unwanted entries
if (!is_numeric($iid))
continue;
// set unseen to provide to browser
$ctl[$cnt]['iid'] = $iid;
$ctl[$cnt]['unseen'] = $rec['unseen'];
// should we notify?
if ($rec['notify'])
{
self::set($iid, 'notify', false);
if ($rec['flags'] & self::NOTIFY_BASIC && !$basic)
{
$basic = true;
$ctl[$cnt]['basic'] = 1;
}
if ($rec['flags'] & self::NOTIFY_DESKTOP)
$ctl[$cnt]['desktop'] = [
'text' => rawurlencode(sprintf($this->gettext('notify.msg'), $rec['unseen'],
$rec['label'])),
'timeout' => $rec['notify_timeout'],
];
if ($rec['flags'] & self::NOTIFY_SOUND && !$sound)
{
$sound = true;
$ctl[$cnt]['sound'] = 1;
}
}
$cnt++;
}
$rc->output->command('plugin.identity_switch_notify', $ctl);
}
}

View File

@ -0,0 +1,224 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
// include environment
if (!defined('INSTALL_PATH'))
define('INSTALL_PATH', strpos($_SERVER['DOCUMENT_ROOT'], 'public_html') ?
realpath(__DIR__.'/../..').'/' : $_SERVER['DOCUMENT_ROOT'].'/');
require_once INSTALL_PATH.'program/include/iniset.php';
require_once INSTALL_PATH.'plugins/identity_switch/identity_switch_rpc.php';
require_once INSTALL_PATH.'plugins/identity_switch/identity_switch_prefs.php';
class identity_switch_newmails extends identity_switch_rpc {
private $file;
private $cache;
private $fp;
/**
* Run the controller.
*/
public function run(): void
{
$rc = rcmail::get_instance();
// get Identity id
if (is_null($iid = rcube_utils::get_input_value('iid', rcube_utils::INPUT_GET)))
{
identity_switch_prefs::write_log('Cannot load identity id - stop checking', true);
return;
}
// get cache file name
if (is_null($this->file = rcube_utils::get_input_value('cache', rcube_utils::INPUT_GET)))
{
identity_switch_prefs::write_log('Cannot get cache file name - stop checking');
return;
} else
identity_switch_prefs::write_log('Cache file name "'.$this->file.'"', true);
// get cached data
if (!file_exists($this->file))
{
identity_switch_prefs::write_log('Cache file "'.$this->file.'" does not exists - stop checking');
return;
} else
identity_switch_prefs::write_log('Cache file loaded', true);
// storage initialization hook
$rc->plugins->register_hook('storage_init', [ $this, 'set_language' ]);
$this->cache = unserialize(file_get_contents($this->file));
// save logging configuration
$_SESSION[identity_switch_prefs::TABLE]['config'] = [
'logging' => $this->cache['config']['logging'],
'debug' => $this->cache['config']['debug'],
];
if (!$iid)
{
$res = [];
foreach ($this->cache as $iid => $rec)
{
if (!is_numeric($iid))
continue;
$host = ($_SERVER['SERVER_PORT'] != '80' ? 'ssl://' : '').$_SERVER['HTTP_HOST'].
':'.$_SERVER['SERVER_PORT'];
$res[$iid] = new identity_switch_rpc();
if (!$res[$iid]->open($host))
{
self::write_data($iid.'##'.$res[$iid]);
identity_switch_prefs::write_log('Cannot open host "'.$host.'" - stop checking', true);
return;
}
// prepare request (no fopen() usage because "allow_url_fopen=FALSE" may be set in PHP.INI)
$req = '/plugins/identity_switch/identity_switch_newmails.php?iid='.$iid.
'&cache='.urlencode($this->file);
if (!$res[$iid]->write($req))
{
if (is_resource($res[$iid]))
fclose($res[$iid]);
self::write_data('0##Identity: '.$iid.' Cannot write to "'.$host.'" Request: "'.$req.'" - stop checking');
return;
}
// delay execution?
if (count($this->cache) > 1 && isset($this->cache['config']['delay']) && $this->cache['config']['delay'] > 0)
{
if ($this->cache['config']['delay'] > 1000000)
{
identity_switch_prefs::write_log('Delay execution by "'.$this->cache['config']['delay'].'" seconds', true);
sleep ($this->cache['config']['delay'] / 1000000);
}
else
{
identity_switch_prefs::write_log('Delay execution by "'.$this->cache['config']['delay'].'" microseconds', true);
usleep ($this->cache['config']['delay']);
}
}
}
// collect data
$cnt = 0;
while (count($res) && $cnt++ < $this->cache['config']['retries'])
{
foreach ($res as $iid => $obj)
{
if ($wrk = $res[$iid]->read())
self::write_data('0##'.$wrk);
unset($res[$iid]);
$cnt = 0;
}
$obj; // Disable Eclipse warning
}
if ($cnt >= $this->cache['config']['retries'])
self::write_data('0##Number of retries exceeded for identity '.$iid.' - stop checking');
// delete cache data
@unlink($this->file);
identity_switch_prefs::write_log('Cache file "'.$this->file.'" deleted', true);
return;
} else {
$rec = $this->cache[$iid];
// must delete storage object, to get SSL status reset
$rc->storage = null;
// connect
$storage = $rc->get_storage();
if (substr($rec['imap_host'], 4, 1) == ':')
$rec['imap_enc'] = '';
else
$rec['imap_enc'] = $rec['flags'] & identity_switch_prefs::IMAP_SSL ? 'ssl' :
($rec['flags'] & identity_switch_prefs::IMAP_TLS ? 'tls' : '');
if (!$storage->connect($rec['imap_host'], $rec['imap_user'],
$rc->decrypt($rec['imap_pwd']), $rec['imap_port'], $rec['imap_enc']))
{
self::write_data('0##Identity '.$iid.': Cannot connect to "'.($rec['imap_enc'] ?
$rec['imap_enc'].'://' : '').$rec['imap_host'].':'.$rec['imap_port'].
'" for user "'.$rec['imap_user'].'" - stop checking');
return;
}
// get list of all subscribed folders
$storage = $rc->get_storage();
$folders = [ 'INBOX' ];
if ($rec['flags'] & identity_switch_prefs::CHECK_ALLFOLDER)
$folders += $storage->list_folders_subscribed('', '*'. null, null, true);
// drop exception folders (and their subfolders)
foreach ($rec['folders'] as $val)
if (($k = array_search($val, $folders)) !== false)
unset($folders[$k]);
// count unseen
$unseen = 0;
foreach($folders as $mbox)
{
unset($storage->conn->data['STATUS:'.$mbox]);
$unseen += $storage->count($mbox, 'UNSEEN', true, false);
}
$storage->close();
self::write_data($iid.'##'.$unseen);
identity_switch_prefs::write_log('Setting unseen count to '.$unseen.' for identity id '.$iid, true);
return;
}
}
/**
* Set language for IMAP connection
*
* @param array $args
* @return array
*/
function set_language (array $args): array
{
$args['language'] = $this->cache['config']['language'];
return $args;
}
/**
* Write record to data file
*
* @param string $msg
* @return bool
*/
private function write_data (string $msg): bool
{
if (!$this->fp || fwrite($this->fp, $msg) === false)
{
if (is_resource($this->fp))
fclose($this->fp);
// open output file
if (!($this->fp = @fopen($this->cache['config']['data'], 'a')))
{
identity_switch_prefs::write_log('Error opening data file "'.$this->cache['config']['data'].'"');
return false;
}
return fwrite($this->fp, time().'##'.$msg.'###') !== false ? true : false;
}
return true;
}
}
$obj = new identity_switch_newmails();
$obj->run();

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
class identity_switch_rpc {
private $host = null;
private $req = null;
private $fp = null;
/**
* Open asynchronous communication channel
*
* @param string $host
* @return string|resource
*/
function open(string $host): mixed
{
$errno = $errmsg = null;
$ctx = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => false,
],
]);
// open async connection
if (!($this->fp = stream_socket_client($host, $errno, $errmsg, 30,STREAM_CLIENT_ASYNC_CONNECT, $ctx)))
return 'Cannot connect to "'.$host.'" - ['.$errno.'] '.$errmsg;
// set timeout
stream_set_timeout($this->fp, 30);
// save host name
if ($p = strpos($host, '://'))
$host = substr($host, 3 + $p);
if ($p = strpos($host, ':'))
$host = substr($host, 0, $p);
$this->host = $host;
return $this->fp;
}
/**
* Write to asynchroneous communication channel
*
* @param string $req
* @return bool
*/
function write(string $req): bool
{
$this->req = $req;
// finalize request
$req = 'GET '.$req." HTTP/1.0\r\nHost: ".$this->host."\r\n\r\n";
return (bool)fwrite($this->fp, $req);
}
/**
* Read from asynchroneous communication channel
*
* @return string
*/
function read(): string
{
if (!($wrk = fread($this->fp, 8192)))
return 'Errror reading from "'.$this->host.'" Request: "'.$this->req.'"';
$head = explode("\r\n", substr($wrk, 0, $pos = strpos($wrk, "\r\n\r\n")));
$wrk = substr($wrk, $pos + 4);
// we use this approach to get "HTTP/1.0 200 OK" as well as "HTTP/1.1 200 OK"
if (count($head) && strpos($head[0], '200 OK') === false)
return '"'.$head[0].'" for "'.$this->host.'" Request: "'.$this->req.'"';
else {
if (is_string($wrk) && strlen($wrk) > 1)
return $wrk;
}
return $wrk;
}
}

View File

@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$labels = [];
$labels['idsw.common.caption'] = 'Daten der Identität';
$labels['idsw.common.noedit'] = 'Informationen zur Identität können vor dem ersten Speichern nicht eingegeben werden';
$labels['idsw.common.enabled'] = 'Aktiviert';
$labels['idsw.common.label'] = 'Bezeichnung';
$labels['idsw.imap.caption'] = 'IMAP';
$labels['idsw.imap.host'] = 'Servername';
$labels['idsw.imap.auth'] = 'Verschlüsselung';
$labels['idsw.imap.auth.none'] = 'Keine';
$labels['idsw.imap.auth.ssl'] = 'SSL';
$labels['idsw.imap.auth.tls'] = 'TLS';
$labels['idsw.imap.port'] = 'Port';
$labels['idsw.imap.delim'] = 'Verzeichnistrenner';
$labels['idsw.imap.user'] = 'Benutzername';
$labels['idsw.imap.pwd'] = 'Passwort';
$labels['idsw.smtp.caption'] = 'SMTP';
$labels['idsw.smtp.host'] = 'Servername';
$labels['idsw.smtp.tls'] = 'Sichere Verbindung (TLS)';
$labels['idsw.smtp.port'] = 'Port';
$labels['idsw.smtp.auth'] = 'Verschlüsselung';
$labels['idsw.smtp.auth.none'] = 'Keine';
$labels['idsw.smtp.auth.ssl'] = 'SSL';
$labels['idsw.smtp.auth.tls'] = 'TLS';
$labels['idsw.notify.caption'] = 'Neue Nachrichten';
$labels['idsw.notify.allfolder'] = 'Alle Ordner auf neue Nachrichten prüfen';
$labels['idsw.notify.basic'] = 'Benachrichtigung im Browser bei neuer Nachricht';
$labels['idsw.notify.desktop'] = 'Desktop-Benachrichtigung bei neuer Nachricht';
$labels['idsw.notify.timeout'] = 'Desktop-Benachrichtigung schließen';
$labels['idsw.notify.sound'] = 'Akustische Meldung bei neuer Nachricht';
$labels['idsw.notify.test'] = 'Test';
$labels['idsw.err.imap.host.miss'] = 'Der Wert im Feld \'IMAP Server host name\' fehlt.';
$labels['idsw.err.imap.port.num'] = 'Der Wert in \'IMAP Port\' muss eine Zahl sein.';
$labels['idsw.err.imap.port.range'] = 'Der Wert in \'IMAP Port\' muss zwischen 1 und 65535 liegen.';
$labels['idsw.err.imap.delim.miss'] = 'Der Wert im Feld \'IMAP Verzeichnistrenner\' fehlt.';
$labels['idsw.err.imap.user.miss'] = 'Der Wert im Feld \'IMAP Benutzername\' fehlt.';
$labels['idsw.err.imap.pwd.miss'] = 'Der Wert im Feld \'IMAP Password\' fehlt.';
$labels['idsw.err.smtp.host.miss'] = 'Der Wert im Feld \'SMTP Servername\' fehlt.';
$labels['idsw.err.smtp.port.num'] = 'Der Wert in \'SMTP Port\' muss eine Zahl sein.';
$labels['idsw.err.smtp.port.range'] = 'Der Wert in \'SMTP Port\' muss zwischen 1 und 65535 liegen.';
$labels['identity'] = 'Identität';
$labels['notify.title'] = 'Neue E-Mails';
$labels['notify.msg'] = '%d für %s';
$labels['notify.err.autoplay'] = 'Kann Musik nicht abspielen!'."\r\n".
'Bitte überprüfen Sie die Einstellungen der "Automatische Wiedergabe" für diese Seite in Ihrem Browser.';
$labels['notify.err.notification'] = 'Kann Benachrichtigung nicht senden!.'."\r\n".
'Bitte überprüfen Sie die Einstellungen der "Benachrichtigungen" für diese Seite in Ihrem Browser.';

View File

@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$labels = [];
$labels['idsw.common.caption'] = 'Data of your identity';
$labels['idsw.common.noedit'] = 'Informationen about identity cannot being entered until record has been saved the first time';
$labels['idsw.common.enabled'] = 'Enabled';
$labels['idsw.common.label'] = 'Label';
$labels['idsw.imap.caption'] = 'IMAP';
$labels['idsw.imap.host'] = 'Server host name';
$labels['idsw.imap.port'] = 'Port';
$labels['idsw.imap.auth'] = 'Encryption';
$labels['idsw.imap.auth.none'] = 'None';
$labels['idsw.imap.auth.ssl'] = 'SSL';
$labels['idsw.imap.auth.tls'] = 'TLS';
$labels['idsw.imap.delim'] = 'Folder hierarchy delimiter';
$labels['idsw.imap.user'] = 'Username';
$labels['idsw.imap.pwd'] = 'Password';
$labels['idsw.smtp.caption'] = 'SMTP';
$labels['idsw.smtp.host'] = 'Server host name';
$labels['idsw.smtp.tls'] = 'Secure connection (TLS)';
$labels['idsw.smtp.port'] = 'Port';
$labels['idsw.smtp.auth'] = 'Encryption';
$labels['idsw.smtp.auth.none'] = 'None';
$labels['idsw.smtp.auth.ssl'] = 'SSL';
$labels['idsw.smtp.auth.tls'] = 'TLS';
$labels['idsw.notify.caption'] = 'New messages';
$labels['idsw.notify.allfolder'] = 'Check all folders for new messages';
$labels['idsw.notify.basic'] = 'Display browser notifications on new message';
$labels['idsw.notify.desktop'] = 'Display desktop notifications on new message';
$labels['idsw.notify.timeout'] = 'Close desktop notification';
$labels['idsw.notify.sound'] = 'Play sound on new message';
$labels['idsw.notify.test'] = 'Test';
$labels['idsw.err.imap.host.miss'] = 'Value in \'IMAP Server host name\' missing.';
$labels['idsw.err.imap.port.num'] = 'Value in \'IMAP Port\' field must be a number.';
$labels['idsw.err.imap.port.range'] = 'Value in \'IMAP Port\' field must be between 1 and 65535.';
$labels['idsw.err.imap.delim.miss'] = 'Value in \'IMAP Folder hierarchy delimiter\' missing.';
$labels['idsw.err.imap.user.miss'] = 'Value in \'IMAP User name\' missing.';
$labels['idsw.err.imap.pwd.miss'] = 'Value in \'IMAP Password\' missing.';
$labels['idsw.err.smtp.host.miss'] = 'Value in \'SMTP Server host name\' missing.';
$labels['idsw.err.smtp.port.num'] = 'Value in \'SMTP Port\' field must be a number.';
$labels['idsw.err.smtp.port.range'] = 'Value in \'SMTP Port\' field must be between 1 and 65535.';
$labels['identity'] = 'Identity';
$labels['notify.title'] = 'New Emails';
$labels['notify.msg'] = '%d for %s';
$labels['notify.err.autoplay'] = 'Cannot play sound file!'."\r\n".
'Please check your "Autoplay" settings for this page in your browser.';
$labels['notify.err.notification'] = 'Cannot send notification!'."\r\n".
'Please check your "Notification" settings for this page in your browser.';

View File

@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$labels = [];
$labels['idsw.common.caption'] = 'Données de votre identité';
$labels['idsw.common.noedit'] = 'Les informations liées à l\'identité ne peuvent être saisies qu\'après le premier enregistrement';
$labels['idsw.common.enabled'] = 'Activer';
$labels['idsw.common.label'] = 'Nom à afficher';
$labels['idsw.imap.caption'] = 'IMAP';
$labels['idsw.imap.host'] = 'Nom du serveur IMAP';
$labels['idsw.imap.port'] = 'Port IMAP';
$labels['idsw.imap.auth'] = 'Chiffrement';
$labels['idsw.imap.auth.none'] = 'None';
$labels['idsw.imap.auth.ssl'] = 'SSL';
$labels['idsw.imap.auth.tls'] = 'TLS';
$labels['idsw.imap.delim'] = 'Séparateur de dossier';
$labels['idsw.imap.user'] = 'Nom d\'utilisateur';
$labels['idsw.imap.pwd'] = 'Mot de passe';
$labels['idsw.smtp.caption'] = 'SMTP';
$labels['idsw.smtp.host'] = 'Nom du serveur SMTP';
$labels['idsw.smtp.tls'] = 'Connexion sécurisée (TLS)';
$labels['idsw.smtp.port'] = 'Port SMTP';
$labels['idsw.smtp.auth'] = 'Encryption';
$labels['idsw.smtp.auth.none'] = 'None';
$labels['idsw.smtp.auth.ssl'] = 'SSL';
$labels['idsw.smtp.auth.tls'] = 'TLS';
$labels['idsw.notify.caption'] = 'Nouveaux messages';
$labels['idsw.notify.allfolder'] = 'Vérifier la présence de nouveaux messages dans tous les dossiers';
$labels['idsw.notify.basic'] = 'Afficher les notifications du navigateur en cas de nouveau message';
$labels['idsw.notify.desktop'] = 'Afficher les notifications sur le bureau en cas de nouveau message';
$labels['idsw.notify.timeout'] = 'Fermeture de la notification du bureau';
$labels['idsw.notify.sound'] = 'Diffusion d\'un son lors de la réception d\'un nouveau message';
$labels['idsw.notify.test'] = 'Test';
$labels['idsw.err.imap.host.miss'] = 'La valeur du champ "Serveur IMAP" est manquante.';
$labels['idsw.err.imap.port.num'] = 'La valeur du champ "Port IMAP" doit être un nombre.';
$labels['idsw.err.imap.port.range'] = 'La valeur du champ "Port IMAP" doit être comprise entre 1 et 65535.';
$labels['idsw.err.imap.delim.miss'] = 'La valeur du champ "Séparateur de dossier" est manquante.';
$labels['idsw.err.imap.user.miss'] = 'La valeur du champ "Nom d\'utilisateur" est manquante.';
$labels['idsw.err.imap.pwd.miss'] = 'La valeur du champ "Mot de passe" est manquante.';
$labels['idsw.err.smtp.host.miss'] = 'La valeur du champ "Serveur SMTP" est manquante.';
$labels['idsw.err.smtp.port.num'] = 'La valeur du champ "Port SMTP" doit être un nombre.';
$labels['idsw.err.smtp.port.range'] = 'La valeur du champ "Port SMTP" doit être comprise entre 1 et 65535.';
$labels['identity'] = 'Identité';
$labels['notify.title'] = 'Nouveaux messages';
$labels['notify.msg'] = '%d pour %s';
$labels['notify.err.autoplay'] = 'Le fichier son ne peut pas être joué !'."\r\n".
'Vérifier vos paramètres "Autoplay" pour cette page de votre navigateur.';
$labels['notify.err.notification'] = 'La notification ne peut être envoyée !'."\r\n".
'Vérifier vos paramètres "Notification" pour cette page de votre navigateur.';

View File

@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
/*
* Identity switch RoundCube Bundle
*
* @copyright (c) 2024 Forian Daeumling, Germany. All right reserved
* @license https://github.com/toteph42/identity_switch/blob/master/LICENSE
*/
$labels = [];
$labels['idsw.common.caption'] = 'Ваши идентификационные данные';
$labels['idsw.common.noedit'] = 'Идентификационные данные нельзя ввести, пока запись не будет сначала сохранена';
$labels['idsw.common.enabled'] = 'Включено';
$labels['idsw.common.label'] = 'Метка';
$labels['idsw.imap.caption'] = 'IMAP';
$labels['idsw.imap.host'] = 'Имя сервера';
$labels['idsw.imap.port'] = 'Порт';
$labels['idsw.imap.auth'] = 'Шифрование';
$labels['idsw.imap.auth.none'] = 'Нет';
$labels['idsw.imap.auth.ssl'] = 'SSL';
$labels['idsw.imap.auth.tls'] = 'TLS';
$labels['idsw.imap.delim'] = 'Разделитель папок';
$labels['idsw.imap.user'] = 'Имя пользователя';
$labels['idsw.imap.pwd'] = 'Пароль';
$labels['idsw.smtp.caption'] = 'SMTP';
$labels['idsw.smtp.host'] = 'Имя сервера';
$labels['idsw.smtp.tls'] = 'Защищенное соединение (TLS)';
$labels['idsw.smtp.port'] = 'Порт';
$labels['idsw.smtp.auth'] = 'Шифрование';
$labels['idsw.smtp.auth.none'] = 'Нет';
$labels['idsw.smtp.auth.ssl'] = 'SSL';
$labels['idsw.smtp.auth.tls'] = 'TLS';
$labels['idsw.notify.caption'] = 'Новые письма';
$labels['idsw.notify.allfolder'] = 'Проверить все папки на новые письма';
$labels['idsw.notify.basic'] = 'Показывать уведомления в браузере при новом письме';
$labels['idsw.notify.desktop'] = 'Показывать уведомления на рабочем столе при новом письме';
$labels['idsw.notify.timeout'] = 'Закрыть уведомление на рабочем столе';
$labels['idsw.notify.sound'] = 'Проиграть звук при новом письме';
$labels['idsw.notify.test'] = 'Тест';
$labels['idsw.err.imap.host.miss'] = 'Значение в \'IMAP Server host name\' отсутствует.';
$labels['idsw.err.imap.port.num'] = 'Значение в \'IMAP Port\' должно быть числом.';
$labels['idsw.err.imap.port.range'] = 'Значение в \'IMAP Port\' должно быть между 1 и 65535.';
$labels['idsw.err.imap.delim.miss'] = 'Значение в \'IMAP Folder hierarchy delimiter\' отсутствует.';
$labels['idsw.err.imap.user.miss'] = 'Значение в \'IMAP User name\' отсутствует.';
$labels['idsw.err.imap.pwd.miss'] = 'Значение в \'IMAP Password\' отсутствует.';
$labels['idsw.err.smtp.host.miss'] = 'Значение в \'SMTP Server host name\' отсутствует.';
$labels['idsw.err.smtp.port.num'] = 'Значение в \'SMTP Port\' должно быть числом.';
$labels['idsw.err.smtp.port.range'] = 'Значение в \'SMTP Port\' должно быть между 1 и 65535.';
$labels['identity'] = 'Личность';
$labels['notify.title'] = 'Новые письма';
$labels['notify.msg'] = '%d для %s';
$labels['notify.err.autoplay'] = 'Не могу проиграть звуковой файл!'."\r\n".
'Пожалуйста, проверьте настройки "Автовоспроизведение" для этой страницы в вашем браузере.';
$labels['notify.err.notification'] = 'Не могу отправить уведомление!'."\r\n".
'Пожалуйста, проверьте настройки "Уведомление" для этой страницы в вашем браузере.';