Code

Added mail functionality to support kolab distribution lists.
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 24 Jun 2005 13:42:42 +0000 (13:42 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 24 Jun 2005 13:42:42 +0000 (13:42 +0000)
TODO: Check if mail method is set to "kolab" before displaying this tab!

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@854 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/ogroups/class_mailogroup.inc [new file with mode: 0644]
plugins/admin/ogroups/class_termgroup.inc
plugins/admin/ogroups/mail.tpl [new file with mode: 0644]
plugins/admin/ogroups/tabs_ogroups.inc

diff --git a/plugins/admin/ogroups/class_mailogroup.inc b/plugins/admin/ogroups/class_mailogroup.inc
new file mode 100644 (file)
index 0000000..699934f
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+
+class mailogroup extends plugin
+{
+  /* plugin specific values */
+  var $mail= "";
+  var $cn= "";
+
+  /* attribute list for save action */
+  var $attributes= array("mail");
+  var $objectclasses= array("kolabGroupOfNames");
+
+  var $members= array();
+
+  function mailogroup ($config, $dn= NULL)
+  {
+    plugin::plugin($config, $dn);
+
+    /* Include config object */
+    $this->config= $config;
+  }
+
+  function execute()
+  {
+    /* Initialize templating engine */
+    $smarty= get_smarty();
+
+    /* Assign mail attribute */
+    $smarty->assign("mail", $this->mail);
+    $smarty->assign("mailACL", chkacl($this->acl, "mail"));
+
+    /* Show main page */
+    return ($smarty->fetch (get_template_path('mail.tpl', TRUE)));
+  }
+
+  /* Check formular input */
+  function check()
+  {
+    $ldap= $this->config->get_ldap_link();
+
+    $message= array();
+
+    /* Check if mail address is valid */
+    if (!is_email($this->mail)){
+      $message[]= _("Please enter a valid email address in 'Primary address' field.");
+    }
+
+    /* Check if mail address is already in use */
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search ("(&(!(objectClass=gosaUserTemplate))(|(mail=".$this->mail.         ")(gosaMailAlternateAddress=".$this->mail."))(!(cn=".$this->cn.")))", array("uid"));
+    if ($ldap->count() != 0){
+      $message[]= _("The primary address you've entered is already in use.");
+    }
+
+    return ($message);
+  }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index 76b54705a8f2c8a19d061719e5ae177be44759e1..fe7b1611f3ce549b39fe487976b2dbfaf681ff1b 100644 (file)
@@ -36,6 +36,10 @@ class termgroup extends plugin
     $this->config= $config;
   }
 
+  function check()
+  {
+  }
+
   function execute()
   {
 
diff --git a/plugins/admin/ogroups/mail.tpl b/plugins/admin/ogroups/mail.tpl
new file mode 100644 (file)
index 0000000..18c0e18
--- /dev/null
@@ -0,0 +1,23 @@
+<input type="hidden" name="mailedit" value="1">
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=0 border=0>
+
+ <!-- Headline container -->
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+   <h2><img alt="" align="middle" src="images/rightarrow.png"> {t}Mail distribution list{/t}</h2>
+   <table summary="">
+    <tr>
+     <td>{t}Primary address{/t}{$must}</td>
+     <td><input name="mail" size=25 maxlength=65 {$mailACL} value="{$mail}" title="{t}Primary mail address for this distribution list{/t}"></td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+  document.mainform.mail.focus();
+  -->
+</script>
index 96c190d349b6dd0946663efdd095434b8237855b..348e316d73ffa2fe07a580434faf4523d336818b 100644 (file)
@@ -20,6 +20,15 @@ class ogrouptabs extends tabs
           $this->by_object['termgroup']= new termgroup($this->config, $this->dn);
           $this->by_object['termgroup']->parent= &$this;
 
+          break;
+
+        case "U":
+          /* Add a user tab used for mail distribution lists */
+          require_once("class_mailogroup.inc");
+          $this->by_name['mailogroup']= _("Mail");
+          $this->by_object['mailogroup']= new mailogroup($this->config, $this->dn);
+          $this->by_object['mailogroup']->parent= &$this;
+
           break;
       }
     }
@@ -31,6 +40,29 @@ class ogrouptabs extends tabs
   }
 
 
+  function save_object($save_current= FALSE)
+  {
+    tabs::save_object($save_current);
+
+    /* Update reference, transfer variables */
+    $baseobject= $this->by_object['ogroup'];
+    foreach ($this->by_object as $name => $obj){
+
+      /* Don't touch base object */
+      if ($name != 'ogroup'){
+        $obj->parent= &$this;
+        $obj->uid= $baseobject->uid;
+        $obj->sn= $baseobject->uid;
+        $obj->givenName= $baseobject->uid;
+        $this->by_object[$name]= $obj;
+      }
+
+      /* Update parent in base object */
+      $this->by_object['ogroup']->parent= &$this;
+    }
+  }
+
+
   function save()
   {
     $baseobject= $this->by_object['ogroup'];
@@ -55,6 +87,7 @@ class ogrouptabs extends tabs
     if ($this->dn == "new"){
       $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
     }
+
     tabs::save(TRUE);
   }