[debian-edu-commits] debian-edu/upstream/ 01/04: mailAccount: Add multi-edit support.

Mike Gabriel sunweaver at debian.org
Wed Aug 26 19:06:14 UTC 2015


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository gosa-plugin-mailaddress.

commit 23ab94e55f8fec946356d50ee75857843dc8fcc3
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Aug 26 16:20:45 2015 +0200

    mailAccount: Add multi-edit support.
---
 personal/mailaddress/class_mailAccount.inc | 56 +++++++++++++++++++++++++++++-
 personal/mailaddress/generic.tpl           | 29 +++++++++++++++-
 2 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/personal/mailaddress/class_mailAccount.inc b/personal/mailaddress/class_mailAccount.inc
index 6784b28..a8e6b35 100644
--- a/personal/mailaddress/class_mailAccount.inc
+++ b/personal/mailaddress/class_mailAccount.inc
@@ -56,6 +56,7 @@ class mailAccount extends plugin
       "gosaMailDeliveryMode",
   );
   var $objectclasses= array("gosaMailAccount");
+  var $multiple_support = TRUE;
 
   var $uid = "";
   var $cn  = "";
@@ -143,11 +144,14 @@ class mailAccount extends plugin
       $smarty->assign($attr,set_post($this->$attr));
     }
 
+    $smarty->assign("multiple_support",$this->multiple_support_active);
+    if($this->multiple_support-active){
+      $smarty->assign("multi_mail",array_slice($this->multi_attrs_all['mail'],1));
+    }
     return($display.$smarty->fetch(get_template_path("generic.tpl",TRUE,dirname(__FILE__))));
   }
 
 
-
   /* Save data to object */
   function save_object()
   {
@@ -357,6 +361,56 @@ class mailAccount extends plugin
       }
   }
 
+  function multiple_execute()
+  {
+    return($this->execute());
+  }
+
+  function multiple_check()
+  {
+    $message = plugin::multiple_check();
+
+    if(empty($this->gosaMailServer) && in_array_strict("gosaMailServer",$this->multi_boxes)){
+      $message[]= msgPool::noserver(_("Mail"));
+    }
+
+    /* Mail address checks */
+    $mail_pattern = $this->mail;
+
+    if (empty($mail_pattern)){
+      $message[]= msgPool::required(_("Mail address pattern"))."<br><br><b>"._("Examples").":</b> <i>{%givenName}.{%sn}@your-domain.com</i> "._("or")." <i>{%uid}@your-domain.com</i>";
+    }
+    if ((!tests::is_email($mail_pattern, TRUE)) || (!preg_match('/^.*({%uid}|{%givenName}|{%sn}|{%cn}).*@.*$/i', $mail_pattern))){
+      $message[]= msgPool::invalid(_("Mail address pattern"),"","","{%givenName}.{%sn}@your-domain.com")."<br><br><br>"._("Please make use of placeholders for the user part of the mail address.");
+    }
+
+    return($message);
+  }
+
+  function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    $ret['mail'] = $this->mail;
+    return $ret;
+  }
+
+  function set_multi_edit_values($attrs)
+  {
+    /* Replace placeholders in mail address patterns */
+    $mail_pattern = $attrs['mail'];
+
+    foreach (array("sn", "givenName", "uid") as $repl){
+      $value= $this->$repl;
+      if (preg_match("/{%$repl}/", $mail_pattern)){
+        $attrs['mail']= str_replace("{%$repl}", $value, $mail_pattern);
+        $mail_pattern=$attrs['mail'];
+      }
+    }
+
+    plugin::set_multi_edit_values($attrs);
+  }
+
+
   /*! \brief  ACL settings 
    */
   static function plInfo()
diff --git a/personal/mailaddress/generic.tpl b/personal/mailaddress/generic.tpl
index 74f9b25..d72b17c 100644
--- a/personal/mailaddress/generic.tpl
+++ b/personal/mailaddress/generic.tpl
@@ -2,8 +2,8 @@
  <tr>
   <td style='width:50%; '>  
 
+   {if !$multiple_support}
    <h3>{t}User Mail Address{/t}</h3>
-
    <table summary="{t}Mail address{/t}">
     <tr>
      <td><label for="mail">{t}Mail address{/t}</label>{$must}</td>
@@ -14,6 +14,33 @@
      </td>
     </tr>
    </table>
+   {else}
+   <h3>{t}User Mail Addresses{/t}</h3>
+   <table summary="{t}Mail addresses{/t}">
+    <tr>
+    <td colspan="2">{t}You are about to replace the below mail addresses for the selected users{/t}
+      <ul>
+      {foreach from=$multi_mail item=this_mail}
+       <li><b>{$this_mail}</b></li>
+      {/foreach}
+      </ul>
+    </td>
+    </tr>
+    <tr>
+    <td colspan="2"><i>{t}Please specify a mail address pattern (e.g., {ldelim}%uid{rdelim}@your-domain.com). Valid placeholders are: {ldelim}%uid{rdelim}, {ldelim}%givenName{rdelim} and {ldelim}%sn{rdelim}.{/t}</i>
+    </td>
+    </tr>
+    <tr><td> </td></tr>
+    <tr>
+     <td><label for="mail">{t}Mail address pattern{/t}</label>{$must}</td>
+     <td>
+      {render acl=$mailACL}
+      <input type='text' id="mail" name="mail" size=35 maxlength=65 value="{$mail}">
+      {/render}
+     </td>
+    </tr>
+   </table>
+   {/if}
   </td>
 </tr>
 </table>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/gosa-plugin-mailaddress.git



More information about the debian-edu-commits mailing list