Code

Updated alternate fax number selection.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jan 2010 15:26:13 +0000 (15:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 27 Jan 2010 15:26:13 +0000 (15:26 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15385 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/gofax/gofax/faxaccount/class_gofaxAccount.inc
gosa-plugins/gofax/gofax/faxaccount/faxNumberSelect/class_faxNumberSelect.inc
gosa-plugins/gofax/gofax/faxaccount/faxNumberSelect/faxNumberSelect-filter.xml
gosa-plugins/gofax/gofax/faxaccount/faxNumberSelect/faxNumberSelect-list.xml

index 4deac179ff184bfa9fea6852c25967cdedfb8c48..f7d814e474842d338ef959b327a4e20e34e841e6 100644 (file)
@@ -29,7 +29,7 @@ class gofaxAccount extends plugin
   /* Internal variables */
   var $printerList= array();
   var $has_mailAccount= FALSE;
-  var $locals_dialog= FALSE;
+  var $faxNumberSelect= FALSE;
   var $in_blocklist_dialog= FALSE;
   var $out_blocklist_dialog= FALSE;
   var $current_blocklist= array();
@@ -184,19 +184,35 @@ class gofaxAccount extends plugin
     /* Trigger Add local fax alternatives dialog */
     if (isset($_POST['add_local_alternate'])){
       if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
-        $this->locals_dialog= TRUE;    
+        $this->faxNumberSelect = new faxNumberSelect($this->config, get_userinfo());
         $this->dialog= TRUE;   
       }
     }
 
+    if (isset($_POST['faxNumberSelect_cancel']) && $this->faxNumberSelect instanceOf faxNumberSelect){
+      $this->dialog = $this->faxNumberSelect = FALSE;
+    }
+
     /* Add alternatives from dialog */
-    if (isset($_POST['add_locals_finish']) && isset($_POST['local_list'])){
+    if (isset($_POST['faxNumberSelect_save']) && $this->faxNumberSelect instanceOf faxNumberSelect){
       if($this->acl_is_writeable("facsimileAlternateTelephoneNumber",$edit_mode)){
-        foreach ($_POST['local_list'] as $val){
-          $this->addAlternate($val);
+
+        $entries = $this->faxNumberSelect->save();
+        foreach ($entries as $entry){
+          $this->addAlternate($entry['facsimileTelephoneNumber'][0]);
           $this->is_modified= TRUE;
         }
       }
+      $this->dialog = $this->faxNumberSelect = FALSE;
+    }
+
+    if ($this->faxNumberSelect){
+
+      // Build up blocklist
+      $list = $this->facsimileAlternateTelephoneNumber;
+      $list[] = $this->facsimileTelephoneNumber;
+      session::set('filterBlacklist', array('facsimileTelephoneNumber' => $list));
+      return($this->faxNumberSelect->execute());
     }
 
     /* Add alternatives */
@@ -318,7 +334,7 @@ class gofaxAccount extends plugin
 
 
     /* Set departments */
-    if ($this->locals_dialog || $this->in_blocklist_dialog || $this->out_blocklist_dialog){
+    if ( $this->in_blocklist_dialog || $this->out_blocklist_dialog){
       
       $list= array ();
       $ldap= $this->config->get_ldap_link();
@@ -330,77 +346,15 @@ class gofaxAccount extends plugin
     }
 
     /* Cancel  dialogs */
-    if (isset($_POST['add_locals_cancel']) || isset($_POST['edit_blocklists_finish']) ||
-        isset($_POST['edit_blocklists_cancel']) || isset($_POST['add_locals_finish'])){
-
-      $this->locals_dialog= FALSE;
+    if (isset($_POST['edit_blocklists_finish']) || isset($_POST['edit_blocklists_cancel'])){
       $this->in_blocklist_dialog= FALSE;
       $this->out_blocklist_dialog= FALSE;
       $this->dialog= FALSE;
     }
 
     /* Manage locals dialog */
-    if ($this->locals_dialog){
-
-      /* Save data */
-      $faxfilter= session::get("faxfilter");
-      foreach( array("depselect", "fuser", "regex") as $type){
-        if (isset($_POST[$type])){
-          $faxfilter[$type]= $_POST[$type];
-        }
-      }
-      if (isset($_GET['search'])){
-        $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
-        if ($s == "**"){
-          $s= "*";
-        }
-        $faxfilter['fuser']= $s;
-      }
-
-      if ($faxfilter['regex'] != '*' && $faxfilter['regex'] != ""){
-        $regex= $faxfilter['regex'];
-        $filter= "(facimileTelephoneNumber=$regex)";
-      } else {
-        $filter= "";
-      }
-      if ($faxfilter['fuser'] != ""){
-        $user= $faxfilter['fuser'];
-        $filter= "$filter(|(uid=$user)(cn=$user)(givenName=$user)(sn=$user))";
-      }
-
-      $base= $faxfilter['depselect'];
-      $res= get_list("(&(objectClass=goFaxAccount)$filter)", "gofax", $base, 
-                     array("sn", "givenName", "facsimileTelephoneNumber"), GL_SIZELIMIT | GL_SUBSEARCH);
-
-      foreach ($res as $attrs){
-        $list[$attrs['facsimileTelephoneNumber'][0]]=
-          $attrs['sn'][0].", ".
-          $attrs['givenName'][0]." [".
-          $attrs['facsimileTelephoneNumber'][0]."]";
-      }
-
-      /* Show dialog */
-      $smarty->assign("search_image", get_template_path('images/lists/search.png'));
-      $smarty->assign("usearch_image", get_template_path('images/lists/search-user.png'));
-      $smarty->assign("tree_image", get_template_path('images/lists/search-subtree.png'));
-      $smarty->assign("infoimage", get_template_path('images/info.png'));
-      $smarty->assign("launchimage", get_template_path('images/lists/action.png'));
-      $smarty->assign("departments", $this->config->idepartments);
-      $smarty->assign("list", $list);
-      if (isset($_POST['depselect'])){
-        $smarty->assign("depselect", $_POST['depselect']);
-      }
-      $smarty->assign("deplist", $this->config->idepartments);
-      $smarty->assign("apply", apply_filter());
-      $smarty->assign("alphabet", generate_alphabet());
-      $smarty->assign("hint", print_sizelimit_warning());
-      foreach( array("depselect", "fuser", "regex") as $type){
-        $smarty->assign("$type", $faxfilter[$type]);
-      }
-      $smarty->assign("hint", print_sizelimit_warning());
-
-      $display.= $smarty->fetch (get_template_path('locals.tpl', TRUE, dirname(__FILE__)));
-      return ($display);
+    if ($this->faxNumberSelect){
+      return($this->faxNumberSelect->execute());
     }
 
 
index cd99e0320062fdb532f2b039330f341e71c5a869..1b023ac283081cf07dc98c81bf25466b2d9c9431 100644 (file)
@@ -46,6 +46,19 @@ class faxNumberSelect extends management
     $headpage->setFilter($filter);
     parent::__construct($config, $ui, "users", $headpage);
   }
+
+  function save()
+  {
+    $act = $this->detectPostActions();
+    $headpage = $this->getHeadpage();
+    if(!isset($act['targets'])) return(array());
+    $ret = array();
+    foreach($act['targets'] as $dn){
+      $ret[] = $headpage->getEntry($dn);
+    }
+    return($ret);
+  }
+
 } 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index d73c578f2f2880d2d23bff151156437467f3e47b..c5f7f1fafbb90cd40b9dabbfeb3db89bf55a10e4 100644 (file)
@@ -10,7 +10,7 @@
   <search>
     <query>
       <backend>LDAPBlacklist</backend>
-      <filter>(&amp;(objectClass=gosaAccount)$NAME)</filter>
+      <filter>(&amp;(objectClass=goFaxAccount)$NAME)</filter>
       <attribute>dn</attribute>
       <attribute>objectClass</attribute>
       <attribute>cn</attribute>
@@ -18,6 +18,7 @@
       <attribute>givenName</attribute>
       <attribute>uid</attribute>
       <attribute>description</attribute>
+      <attribute>facsimileTelephoneNumber</attribute>
     </query>
     <scope>auto</scope>
   </search>
     <maxlength>60</maxlength>
     <default></default>
     <unset></unset>
-    <set>(|(sn=*$*)(givenName=*$*)(cn=*$*))</set>
+    <set>(|(sn=*$*)(givenName=*$*)(cn=*$*)(facsimileTelephoneNumber=*$*))</set>
     <alphabet>true</alphabet>
     <autocomplete>
       <backend>LDAPBlacklist</backend>
-      <filter>(&amp;(objectClass=gosaAccount)(|(sn=*$NAME*)(givenName=*$NAME*)(cn=*$NAME*)))</filter>
+      <filter>(&amp;(objectClass=goFaxAccount)(|(sn=*$NAME*)(givenName=*$NAME*)(cn=*$NAME*)(facsimileTelephoneNumber=*$NAME*)))</filter>
       <attribute>cn</attribute>
       <frequency>0.5</frequency>
       <characters>3</characters>
index b13b7b7308047becb26248e78077f994bd3c4d21..47af88018a299f2326d729489df18f1688832a9b 100644 (file)
@@ -21,7 +21,7 @@
   </definition>
 
   <table>
-    <layout>|20px;c|||</layout>
+    <layout>|20px;c||||</layout>
 
     <department>
       <value>%{filter:objectType(dn,objectClass)}</value>
@@ -29,7 +29,7 @@
 
     <department>
       <value>%{filter:departmentLink(row,dn,description)}</value>
-      <span>1</span>
+      <span>2</span>
     </department>
 
     <column>
       <export>true</export>
     </column>
 
+    <column>
+      <label>Fax</label>
+      <sortAttribute>facsimileTelephoneNumber</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{facsimileTelephoneNumber}</value>
+      <export>true</export>
+    </column>
+
   </table>
 
   <actionmenu>