Extend "Email Mailbox" with a new Tab

Discussion in 'Developers' Forum' started by CubAfull, Jul 30, 2024.

  1. CubAfull

    CubAfull Member

    Hello @till and other dev users.
    I want to extend the Mail module and add a new tab inside "Email Mailbox" with additional options to use with an external APP, in this case Nextcloud, but I want to do this without modifying the core files, so, mi question is:

    Is it possible to do that? I can't find any info/tutorial in the ISPConfig documentation or hook in the code to do that. I know I can make a new module outside the Mail module and implement this functions, but what I want is a tab inside the Email Mailbox, so when I create a new email for a user I can add options like cloud quota etc. and get that information using the remote API with a modded version of the Nextcloud-ISPConfig module developed by @theWeird

    Thank you!
     
    ahrasis likes this.
  2. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    There is a custom module created by our member that eases a creation of new sites in a single tab without modifying ISPConfig core but I think it was quite old and was added to the main menu tab instead of any sub menu tab. However, I can't remember where the module thread is for now as I am on mobile, but may be other can help you to find it.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

  4. CubAfull

    CubAfull Member

    ahrasis and till like this.
  5. CubAfull

    CubAfull Member

    Update. The plugin is finished and work ok. Some SS at the end. I'm going to post the plugin when I finish the Nextcloud part (working right now in this).
    Continuing with the core files and my comment here:
    https://forum.howtoforge.com/thread...-integrated-upstream.92752/page-2#post-459307

    This isn't true, all the custom fields are loaded from the db and sent to the remote API call, so, no problem here, but I modded the loadFormDef function in the core file remoting_lib.inc.php to allow the plugins "fields" to be loaded. I don't see where this fields are used, but if the code say it must be loaded, well, the custom fields must be loaded to, right?
    Captura desde 2024-08-11 02-34-31.png Captura desde 2024-08-11 02-36-42.png Captura desde 2024-08-11 02-37-08.png
    PHP:
        //* Load the form definition from file. - special version for remoting
        // module parameter is only for compatibility with base class
        
    function loadFormDef($file$module '') {
            global 
    $app;

            include 
    $file;

            
    // Search for module name by path because $_SESSION['s']['module']['name']
            // isn't set in a remote call.
            
    $module_path array_reverse(explode('/'$file));
            
    $module_name = isset($module_path[2]) && $module_path[1] == 'form' && preg_match("/^[a-z]{2,20}$/i"$module_path[2]) ? $module_path[2] : '';

            
    // Allow plugins to be loaded
            
    if ($module_name) {
                
    $app->plugin->raiseEvent($module_name.':'.$form['name'] . ':on_remote_before_formdef'$this);
            }

            
    $this->formDef $form;

            unset(
    $this->formDef['tabs']);

            
    //* Copy all fields from all tabs into one form definition
            
    foreach($form['tabs'] as $tab) {
                foreach(
    $tab['fields'] as $key => $value) {
                    
    $this->formDef['fields'][$key] = $value;
                }
            }
            unset(
    $form);

            
    // Allow plugins to be loaded
            
    if ($module_name) {
                
    $app->plugin->raiseEvent($module_name.':'.$this->formDef['name'] . ':on_remote_after_formdef'$this);
            }

            
    $this->dateformat 'Y-m-d'//$app->lng('conf_format_dateshort');
            
    $this->datetimeformat 'Y-m-d H:i:s'//$app->lng('conf_format_datetime');

            
    return true;
        }
     
    ahrasis likes this.
  6. CubAfull

    CubAfull Member

    till and ahrasis like this.
  7. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    Thank you for sharing.
     
    CubAfull likes this.
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    By the way, I find it a bit sad that you have chosen a license that is incompatible with ISPConfig's BSD license. GPL infects other code with its license policy, so it is incompatible with more free licenses like the BSD license, which ISPConfig uses. I hope you consider to change the license of your code to BSD too.
     
    ahrasis likes this.
  9. till

    till Super Moderator Staff Member ISPConfig Developer

  10. CubAfull

    CubAfull Member

    @till I did not pay attention to the license. :(
    Sure I can change it. I think I must do this just for the ISPConfig plug-in, or both?

    Thank you for the blog post!!!
     
    till likes this.
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    This would be great if you could change it just for the ISPConfig plugin.
     
  12. CubAfull

    CubAfull Member

    Perfect. I do this today.

    @till I made a lot of changes before release. Please update the images in the blog with this:
    Captura desde 2024-09-06 10-15-11.png Captura desde 2024-09-06 10-17-11.png Captura desde 2024-09-06 10-17-30.png
     
    till likes this.
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Thanks for the new screenshots. I'll update the blog post.
     
    CubAfull likes this.
  14. CubAfull

    CubAfull Member

    pyte and till like this.
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    CubAfull likes this.
  16. CubAfull

    CubAfull Member

    Hi @remkoh,
    I can't reply to you in this thread: https://forum.howtoforge.com/threads/acme-sh-dns-challenge.94445/
    If you want to install the Nextcloud plugin, you must give the ALTER privilege to the ISPConfig user because this is the only way it can modify the mail_user table, at last this is the only option when I write the plugin. After the install, you can disable this privilege again. The only thing the plugin does with that privilege is add additional fields to the mail_user table, nothing more.
     
  17. till

    till Super Moderator Staff Member ISPConfig Developer

    It would be better if the plugin would do the alter table at install time of the plugin in the way ISPConfig is doing it, by using the MySQL root user and the password from server/lib/classes/mysql_clientdb.conf file in an install script that the admin has to run as root user. That#s the way I do it e.g. for the Billing Module too.
     
  18. remkoh

    remkoh Well-Known Member HowtoForge Supporter

    A simple bash script to install the plugin would make everyones life a whole lot easier.
    Then you can't forget to change privileges like I did, leave behind unnecessary extended privileges and would be made sure every install step is executed.
    - Verify script is executed on the master/panel server
    - Copy files to the appropiate location
    - Change ownership
    - Look up MySQL master database host, master database name and root credentials
    - Alter 'mail_domain' and 'mail_user' tables using found info
    - Finish

    Though still no explanation is given on why an effort would be made to alter the mail_user table while something totally unrelated is executed. That doesn't seem right.
     
    Last edited: Jul 23, 2025
  19. remkoh

    remkoh Well-Known Member HowtoForge Supporter

    Installation steps seem to be missing steps for multi node environments.
    Tables 'mail_user' and 'mail_domain' not only need to be altered in the master node's db but also in db('s) of the mail node(s).
     
  20. CubAfull

    CubAfull Member

    Ok. I'm not here to argue... You have the full source code. Have a nice day.
     

Share This Page