Code

Moved plugins
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 15:00:12 +0000 (15:00 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 15:00:12 +0000 (15:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8469 594d385d-05f5-0310-b6e9-bd551577e9d8

14 files changed:
gosa-core/plugins/admin/ogroups/gofon/class_phonequeue.inc [deleted file]
gosa-core/plugins/admin/ogroups/gofon/phonequeue.tpl [deleted file]
gosa-core/plugins/admin/ogroups/goto/class_termgroup.inc [deleted file]
gosa-core/plugins/admin/ogroups/goto/termgroup.tpl [deleted file]
gosa-core/plugins/admin/ogroups/mail/class_mailogroup.inc [deleted file]
gosa-core/plugins/admin/ogroups/mail/mail.tpl [deleted file]
gosa-core/plugins/admin/ogroups/mail/paste_mail.tpl [deleted file]
gosa-plugins/gofon/admin/ogroups/gofon/class_phonequeue.inc [new file with mode: 0644]
gosa-plugins/gofon/admin/ogroups/gofon/phonequeue.tpl [new file with mode: 0644]
gosa-plugins/goto/admin/ogroups/goto/class_termgroup.inc [new file with mode: 0644]
gosa-plugins/goto/admin/ogroups/goto/termgroup.tpl [new file with mode: 0644]
gosa-plugins/mail/admin/ogroups/mail/class_mailogroup.inc [new file with mode: 0644]
gosa-plugins/mail/admin/ogroups/mail/mail.tpl [new file with mode: 0644]
gosa-plugins/mail/admin/ogroups/mail/paste_mail.tpl [new file with mode: 0644]

diff --git a/gosa-core/plugins/admin/ogroups/gofon/class_phonequeue.inc b/gosa-core/plugins/admin/ogroups/gofon/class_phonequeue.inc
deleted file mode 100644 (file)
index 05cd927..0000000
+++ /dev/null
@@ -1,958 +0,0 @@
-<?php
-
-class phonequeue extends plugin
-{
-  /* plugin specific values */
-  var $mail= "";
-  var $cn= "";
-  var $old_cn ="";
-
-  var $goFonTimeOut             ="20"; 
-  var $goFonMaxLen              ="20"; // 
-  var $goFonAnnounceFrequency   ="60"; // Annouce Frequency in seconds
-  var $goFonDialOptiont         ="";
-  var $goFonDialOptionT         ="";
-  var $goFonDialOptionh         ="";
-  var $goFonDialOptionr         ="";
-  var $goFonDialOptionH         ="";
-  var $goFonQueueAnnounce       ="gonicus-berlin-welcome";
-  var $goFonMusiconHold         ="default";
-  var $goFonWelcomeMusic        ="gonicus-berlin-welcome";
-  var $goFonQueueReportHold     ="yes";
-  var $goFonQueueYouAreNext     ="queue-youarenext";
-  var $goFonQueueThereAre       ="queue-thereare";
-  var $goFonQueueCallsWaiting   ="queue-callswaiting";
-  var $goFonQueueThankYou       ="queue-thankyou";
-  var $goFonQueueMinutes        ="queue-minutes"; 
-  var $goFonQueueSeconds        ="queue-seconds";
-  var $goFonQueueLessThan       ="queue-lessthan";
-  var $goFonQueueLanguage       ="queue-holdtime";
-  var $goFonQueueStrategy       ="ringall";
-  var $goFonQueueAnnounceHoldtime="yes";
-  var $telephoneNumber          =array();
-  var $goFonQueueMember         =array(); 
-  var $goFonDialOption          ="";
-  var $goFonQueueRetry          =5;
-
-  var $goFonQueueStrategyOptions=array();
-  var $goFonQueueStrategyOptionsR=array();
-  
-  var $old_phone_numbers        =array();
-
-  var $goFonHomeServer  = "0";
-  var $init_HomeServer  = "0";
-  var $goFonHomeServers = array();
-
-  var $view_logged = FALSE;
-
-  /* attribute list for save action */
-  var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOptiont","goFonDialOptionT",
-      "goFonDialOptionh","goFonDialOptionr","cn","goFonHomeServer",
-      "goFonDialOptionH","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext",
-      "goFonQueueThereAre","goFonQueueCallsWaiting","goFonQueueThankYou","goFonQueueMinutes","goFonQueueSeconds","goFonQueueLessThan",
-      "telephoneNumber","goFonQueueLanguage","goFonQueueStrategy","goFonQueueAnnounceHoldtime","goFonQueueAnnounce","goFonDialOption","goFonQueueRetry");
-
-  /* ObjectClass */
-  var $objectclasses= array("goFonQueue");
-
-
-
-  /* Pluigin initialization 
-   * - Check currently selected and available home server.
-   * - Set default home server if necessary
-   * - Parse phone options flags
-   * - Get phone numbers 
-   */
-  function phonequeue (&$config, $dn= NULL)
-  {
-    plugin::plugin($config, $dn);
-
-    /* Check server configurations
-     * Load all server configuration in $this->goFonHomeServers if available
-     *  and use first server as default if necessary.
-     */
-    if(isset($config->data['SERVERS']['FON']) && 
-       count($config->data['SERVERS']['FON']) &&
-       is_callable("mysql_connect")){
-
-      /* Set available server */
-      $this->goFonHomeServers = $config->data['SERVERS']['FON'];
-
-      /* Set default server */
-      if($this->dn == "new"){
-        $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
-      }
-
-      /* Remember inital home server, to be able to remove old entries */
-      $this->init_HomeServer = $this->goFonHomeServer;
-
-      /* get config */
-      if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){
-        print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."), preg_replace("/,/",", ",$this->goFonHomeServer), preg_replace("/,/",", ",$this->goFonHomeServers[0]['DN'])));
-        $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
-        $this->init_HomeServer = $this->goFonHomeServers[0]['DN'];
-      }
-      $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer];
-    }
-
-
-    /* Variable init  
-     *  Load phone nubmers and parse dial options 
-     */
-    if($this->is_account){
-      if(isset($this->attrs['telephoneNumber'])){
-        $this->telephoneNumber=$this->attrs['telephoneNumber'];
-        unset($this->telephoneNumber['count']); 
-      }
-      for($i = 0; $i < strlen($this->goFonDialOption); $i++){
-        $name = "goFonDialOption".$this->goFonDialOption[$i];
-        $this->$name=$this->goFonDialOption[$i];
-      }
-    }
-
-    /* Set Queue announce hold time to true/false */
-    if(preg_match("/no/i",$this->goFonQueueAnnounceHoldtime)){
-      $this->goFonQueueAnnounceHoldtime=false;
-    }else{
-      $this->goFonQueueAnnounceHoldtime=true;
-    }
-
-    /* Define all available ringdown types */
-    $types= array('ringall'    =>_("ring all"),
-        'roundrobin' =>_("round robin"),
-        'leastrecent'=>_("least recently called"),
-        'fewestcalls'=>_("fewest completed calls"),
-        'random'     =>_("random"),
-        'rrmemory'   =>_("round robin with memory"));
-    $i = 0;
-    foreach($types as $type => $name){
-      $i++;
-      $this->goFonQueueStrategyOptions[$i]    =$name;
-      $this->goFonQueueStrategyOptionsR[$i]   =$type;
-      $tmp[$type] = $i; 
-    }
-    $this->goFonQueueStrategy= $tmp[$this->goFonQueueStrategy];
-    $this->old_cn = $this->cn;
-    $this->old_phone_numbers = $this->telephoneNumber;
-  }
-
-
-  /* This function ensures that the selected home server 
-   * and the initially selected home server are reachable and accessible  
-   */
-  function check_database_accessibility()
-  {
-    /* Check if mysql extension is available */
-    if(!is_callable("mysql_pconnect")){
-      return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup."));
-    }
-
-    /********************
-     * Check currently selected home server
-     ********************/
-
-    $cfg_Current  = $this->goFonHomeServers[$this->goFonHomeServer];
-    $r_current    =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
-    if(!$r_current){
-      new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current));
-      return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
-            $cfg_Current['SERVER'],$cfg_Current['LOGIN']));
-    }
-    $db_current  =  @mysql_select_db($cfg_Current['DB'],$r_current);
-    if(!$db_current){
-      new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current));
-      mysql_close($r_current);
-      return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER']));
-    }
-
-    /********************
-     * Check init home server
-     ********************/
-
-    if($this->initially_was_account){
-      $cfg_Init  = $this->goFonHomeServers[$this->init_HomeServer] ;
-      $r_init    =  @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
-      if(!$r_init){
-        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init));
-        return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
-              $cfg_Init['SERVER'],$cfg_Init['LOGIN']));
-      }
-      $db_init  =  @mysql_select_db($cfg_Init['DB'],$r_init);
-      if(!$db_init){
-        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init));
-        mysql_close($r_init);
-        return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER']));
-      }
-    }
-  }
-
-  
-  /* Display plugin ui */
-  function execute()
-  {
-    /* Call parent execute */
-    plugin::execute();
-
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","ogroups/".get_class($this),$this->dn);
-    }
-
-    if(isset($_POST['modify_state'])){
-      if($this->is_account && $this->acl_is_removeable()){
-        $this->is_account= FALSE;
-      }elseif(!$this->is_account && $this->acl_is_createable()){
-        $this->is_account= TRUE;
-      }
-    }
-
-    /* Show tab dialog headers */
-    if ($this->parent !== NULL){
-      if ($this->is_account){
-        $display= $this->show_disable_header(_("Remove the phone queue from this Account"),
-            _("Phone queue is enabled for this group. You can disable it by clicking below."));
-      } else {
-        $display= $this->show_enable_header(_("Create phone queue"),
-            _("For this group the phone queues are disabled. You can enable them by clicking below."));
-        return ($display);
-      }
-    }
-
-    if($this->acl_is_writeable("telephoneNumber")){
-
-      /* Add queue number */ 
-      if(isset($_POST['add_phonenumber'])&&(isset($_POST['phonenumber']))&&(!empty($_POST['phonenumber']))){
-        if((!in_array($_POST['phonenumber'],$this->telephoneNumber))&&(is_numeric($_POST['phonenumber']))){
-          $this->telephoneNumber[]=$_POST['phonenumber'];
-        }
-      }
-
-      /* Delete queue number */ 
-      if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
-        unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]);
-      }
-
-      /* queue number up */ 
-      if(isset($_POST['up_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
-        if($_POST['goFonQueueNumber_List']>0){
-          $up   = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
-          $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1];
-          $this->telephoneNumber[$_POST['goFonQueueNumber_List']]    = $down;
-          $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1]  = $up;
-        }
-      }
-
-      /* Queuenumber down */
-      if(isset($_POST['down_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
-        if(isset($this->telephoneNumber[($_POST['goFonQueueNumber_List']+1)])){
-          $up   = $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1];
-          $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
-          $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1]    = $down;
-          $this->telephoneNumber[$_POST['goFonQueueNumber_List']]  = $up;
-        }
-        $this->telephoneNumber[$_POST['goFonQueueNumber_List']]  = $up;
-      }
-    }
-
-    $tmp = array();
-    foreach($this->telephoneNumber as $val){
-      if(!empty($val)){
-        $tmp[]= $val;
-      }
-    }  
-    $this->telephoneNumber=$tmp;
-
-    /* Assign samrty variables */
-    $smarty= get_smarty();
-    $smarty->assign("goFonQueueLanguageOptions",get_languages(FALSE,TRUE));
-    $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions);
-
-    /* Set acls */
-    $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translated){
-      $smarty->assign($name."ACL",$this->getacl($name));
-    }
-
-    foreach($this->attributes as $key => $val){
-      $smarty->assign($val,$this->$val);  
-      if($this->$val == false){
-        $smarty->assign($val."CHK","");
-      }else{
-        $smarty->assign($val."CHK"," checked ");
-      }
-    }
-    
-    /* Create array with goFonHomeServer */
-    $tmp = array();
-    foreach($this->goFonHomeServers as $dn => $val){
-      if(!is_numeric($dn)){
-        $tmp[$dn]  = $val['SERVER'];
-      }
-    }
-    $smarty->assign("goFonHomeServers",$tmp);
-
-    return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE,dirname(__FILE__))));
-  }
-
-
-  /* Check formular input */
-  function check()
-  {
-    /* Call common method to give check the hook */
-    $message= plugin::check();
-    if(!count($this->goFonHomeServers)){
-      $message[] = _("There must be at least one server with an asterisk database to create a phone queue.");
-    }
-    if(empty($this->goFonHomeServer)){
-      $message[] = _("Please select a valid goFonHomeServer.");
-    }
-    if($this->is_number_used()){
-      $message[] = $this->is_number_used();
-    }
-    if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){
-      $message[] = _("Timeout must be numeric");
-    }
-    if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){
-      $message[] = _("Retry must be numeric");
-    }
-    if(!((is_numeric($this->goFonMaxLen))||(empty($this->goFonMaxLen)))){
-      $message[] = _("Max queue length must be numeric");
-    }
-    if(!((is_numeric($this->goFonAnnounceFrequency))||(empty($this->goFonAnnounceFrequency)))){
-      $message[] = _("Announce frequency must be numeric");
-    }
-    if(count($this->telephoneNumber)==0){
-      $message[] = _("There must be least one queue number defined.");
-    }
-
-    /* check if add to database could be successfull  */
-    $str = $this->add_to_database();
-    if(!empty($str)){
-      $message[] = $str;
-    }
-    return $message;
-  }
-
-
-  /* This function removes the old database entries. 
-   * If this entry should be removed or the home server has changed
-   *  this function is called to ensure that all old entries will be deleted.
-   */
-  function remove_from_database($save = false)
-  {
-    /* Check if we must remove old entries */
-    if($this->initially_was_account){
-
-      /* Check if there is at least on server configuration */
-      if(!count($this->goFonHomeServers)){
-        return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database."));
-      }
-
-      /********************
-       * Get configuration and check it
-       ********************/
-
-      /* Check if databases are reachable, returns an error string if anything fails  */
-      $error_str = $this->check_database_accessibility();
-      if($error_str){
-        return($error_str);
-      }
-
-      /* Connect to current database to be able to add new entries */
-      $cfg_Current  = $this->goFonHomeServers[$this->init_HomeServer] ;
-      $res_cur      =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
-      $db_cur       =  @mysql_select_db($cfg_Current['DB'],$res_cur);
-
-      /* Create sql entries */
-      $delete[]=    "DELETE FROM ".$cfg_Current['EXT_TABLE']."    WHERE exten='".$this->old_cn."';\n";
-      $delete[]=    "DELETE FROM ".$cfg_Current['QUEUE_TABLE']."  WHERE name='".$this->old_cn."'; \n";
-      $delete[]=    "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';\n";
-      foreach($this->old_phone_numbers as $number){
-        $delete[]=    "DELETE FROM ".$cfg_Current['EXT_TABLE']."    WHERE exten='".$number."';\n";
-      }
-
-      /* Execute the queries */  
-      if($save){
-        foreach($delete as $sql){
-          $res = @mysql_query($sql,$res_cur);
-          if(!$res){
-            new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current));
-            return(_("Error while removing old queue entries from database.").
-                "&nbsp;"._("Please have a look a the gosa logfiles."));
-          }
-        }
-      }
-    }
-  }
-
-
-  /* This function handles the database entries for this 
-   *  queue. 
-   * Existing entries will be updated if possible.
-   */
-  function add_to_database($save = false)
-  {
-    /* Check if there is at least on server configuration */
-    if(!count($this->goFonHomeServers)){
-      return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database."));
-    }
-
-    /********************
-     * Get configuration and check it
-     ********************/
-
-    /* Check if databases are reachable, returns an error string if anything fails  */
-    $error_str = $this->check_database_accessibility();
-    if($error_str){
-      return($error_str);
-    }
-
-    /* Connect to current database to be able to add new entries */
-    $cfg_Current  = $this->goFonHomeServers[$this->goFonHomeServer] ;
-    $res_cur      =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
-    $db_cur       =  @mysql_select_db($cfg_Current['DB'],$res_cur);
-
-    /* Connect to old home server and remove old entries if necessary */
-    if(($this->initially_was_account) && ($this->init_HomeServer != $this->goFonHomeServer)){
-      $str = $this->remove_from_database($save); 
-      if(!empty($str)){
-        return($str);;
-      }
-    }
-
-    /* Ensure that we have the new cn in $this->cn and the old cn in $this->old_cn */
-    $this->cn = $this->parent->by_object['ogroup']->cn;
-
-    if($save){
-  
-      /*****************
-       * Create queue table entry 
-       *****************/
-      /* Check if QUEUE_TABLE entry exists.
-       * If this entry is missing - create it 
-       *  else update the entry with new values.
-       */
-      $query = "SELECT * FROM ".$cfg_Current['QUEUE_TABLE']."  WHERE name='".$this->old_cn."';";
-      $res   = mysql_query($query,$res_cur);
-      if(!$res){
-        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur));
-        return(_("Could not detect old queue entry, query failed.")."&nbsp;"._("Please have a look a the gosa logfiles."));
-      }
-      $cnt = mysql_affected_rows($res_cur);
-
-
-      /* Create queue table entry 
-       * Leave unused options empty. 
-       */
-      $queue["announce"]              = "";
-      $queue["monitor_join"]          = "";
-      $queue["monitor_format"]        = "";
-      $queue["announce_round_seconds"]= "";   
-      $queue["wrapuptime"]            = "";
-      $queue["servicelevel"]          = "";
-      $queue["eventmemberstatus"]     = "";
-      $queue["eventwhencalled"]       = "";
-      $queue["memberdelay"]           = "";
-      $queue["weight"]                = "";
-      $queue["timeoutrestart"]        = "";
-
-      $queue["queue_holdtime"]        = $this->goFonQueueAnnounce;
-      $queue["queue_lessthan"]        = $this->goFonQueueLessThan;   
-      $queue["retry"]                 = $this->goFonQueueRetry;
-      $queue["reportholdtime"]        = "1";
-      $queue["joinempty"]             = "no";
-      $queue["leavewhenempty"]        = "yes";   
-
-      $queue["context"]               = "default";
-      $queue["name"]                  = $this->cn;  
-      $queue["timeout"]               = $this->goFonTimeOut; 
-      $queue["maxlen"]                = $this->goFonMaxLen;
-      $queue["strategy" ]             = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy];
-      $queue["queue_thankyou"]        = $this->goFonQueueThankYou;   
-      $queue["queue_reporthold"]      = $this->goFonQueueReportHold; 
-      $queue["announce_frequency"]    = $this->goFonAnnounceFrequency;
-      $queue["queue_youarenext"]      = $this->goFonQueueYouAreNext;   
-      $queue["queue_thereare"]        = $this->goFonQueueThereAre;   
-      $queue["queue_callswaiting"]    = $this->goFonQueueCallsWaiting;
-      $queue["queue_minutes"]         = $this->goFonQueueMinutes;
-      $queue["queue_seconds"]         = $this->goFonQueueSeconds;   
-      $queue["announce_holdtime"]     = $this->goFonQueueAnnounceHoldtime;   
-      $queue["musiconhold"]           = $this->goFonMusiconHold;
-
-
-      /* Check if we must create a new queue entry 
-       *  or if we can update an existing entry 
-       *  $cnt contains the number of entries matching this cn
-       */
-
-      /* Create new queue table entry 
-       */
-      if($cnt == 0){
-
-        /* Parse and Add Queue */
-        $entries = "";
-        $values  = "";
-        foreach($queue as $attr=>$val){
-          if($val == "") continue;
-          $entries.= "`".$attr."`,";
-          $values .= "'".$val."',";
-        }
-        $values  = preg_replace("/,$/","",$values);
-        $entries = preg_replace("/,$/","",$entries );
-        $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_TABLE']." (".$entries.") VALUES (".$values.");";
-      }elseif($cnt == 1){
-
-        /* Update queue table entry 
-         */
-        $queue_old = @mysql_fetch_assoc($res);
-        foreach($queue_old as $name => $value){
-          if(isset($queue[$name]) && $queue[$name] == $value){
-            unset($queue[$name]);
-          }
-        }
-
-        /* Parse and Add Queue */
-        if(count($queue)){
-          $query = "UPDATE ".$cfg_Current['QUEUE_TABLE']." SET ";
-          foreach($queue as $key => $val){
-            $query.= "".$key."='".$val."',";
-          }
-          $query = preg_replace("/,$/","",$query);
-          $query.= " WHERE name='".$this->old_cn."';";
-          $SQL[] = $query;
-        }
-      }else{
-        return(sprintf(_("More than one entry in queue table found, that uses the name ('%s'). Please fix this issue manually first."),$this->cn));
-      }
-
-
-      /*****************
-       * Create queue member entries
-       *****************/
-      
-      /* Add the queue member entries 
-       * First we must remove all old user entries. 
-       * to be able to add a clean set of members.
-       */ 
-      $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->cn."';";
-      $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';";
-      
-      /* Append new Member for this queue */ 
-      $queueuser =array();
-      $i = 0;
-      $parent = $this->parent->by_object['ogroup'];
-
-      
-      $ldap = $this->config->get_ldap_link();
-      foreach($parent->memberList as $member => $mem_data){
-        $ldap->cat($member,array("goFonHomeServer","objectClass","dn","uid"));
-        if($ldap->count()){
-
-          $obj = $ldap->fetch();
-
-          /* Calculate server and account dependencies */
-          $is_acc = in_array("goFonAccount",$obj['objectClass']);
-          $is_home= isset($obj['goFonHomeServer'][0]) && $obj['goFonHomeServer'][0] == $this->goFonHomeServer; 
-
-          /* Append user to list of queue member,
-           *  only if user has phoneAccount extension && is on same home server */
-          if($is_acc && $is_home){
-            $i ++ ;
-            $queueuser[$i]['queue_name']  = $this->cn; 
-            $queueuser[$i]['interface']   = "SIP/".$obj['uid'][0]; 
-            $queueuser[$i]['penalty']     = 1; 
-          }
-        }
-      }
-
-      /* Parse and Add members to query Array */
-      if(is_array($queueuser)){
-        foreach($queueuser as $user){
-          $entries = "";
-          $values  = "";
-          foreach($user as $attr => $val){
-            $entries.= "`".$attr."`,"; 
-            $values .= "'".$val."',";
-          }
-          $values  = preg_replace("/,$/","",$values);
-          $entries = preg_replace("/,$/","",$entries );
-
-          $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; 
-        }
-      }
-      
-
-      /*****************
-       * Create extension entries
-       *****************/
-      
-      /* Add the extension entries 
-       * First we must remove all old entensions. 
-       */ 
-      $SQL[]=  "DELETE FROM ".$cfg_Current['EXT_TABLE']."  WHERE exten='".$this->cn."';\n";
-      $SQL[]=  "DELETE FROM ".$cfg_Current['EXT_TABLE']."  WHERE exten='".$this->old_cn."';\n";
-
-      /* Delete old enxtension entries for the old telephone nubmer  */
-      if(is_array($this->old_phone_numbers)){
-        foreach($this->old_phone_numbers as $phone){
-          $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n";
-        }
-      }
-      
-      /* Delete enxtension entries for telephone numbers  */
-      if(is_array($this->telephoneNumber)){
-        foreach($this->telephoneNumber as $phone){
-          $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n";
-        }
-      }
-
-      /* Create a extension entry fpr each telephoneNumber */
-      $i_insert_only_once = false;
-      $prio = 11;   // This represents the priority for each telephoneNumber 
-      foreach($this->telephoneNumber as $num){
-
-        /* The naming refrences */
-        if($i_insert_only_once == false){
-          $i_insert_only_once = true;
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $this->cn;
-          $a_ext[$i]['priority'] = 1;
-          $a_ext[$i]['app']      = "Goto";
-          $a_ext[$i]['appdata']  = $num."|1";
-          $i ++ ; 
-        }
-
-        /* If there is currently no user for this queue 
-         * Play no service sound file and return to default context.  
-         */
-        if(count($queueuser)==0){
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 1;
-          $a_ext[$i]['app']      = "SetLanguage";
-          $a_ext[$i]['appdata']  = "de";
-          $i ++ ; 
-
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 2;
-          $a_ext[$i]['app']      = "Playback";
-          $a_ext[$i]['appdata']  = "ss-noservice";
-          $i ++ ; 
-
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 3;
-          $a_ext[$i]['app']      = "Goto";
-          $a_ext[$i]['appdata']  = "default";
-          $i ++ ; 
-        }else{
-
-          /* Dcrement priority to avoid using same priority twice */
-          $prio --;
-
-          /* Wait for 2 seconds */
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 1;
-          $a_ext[$i]['app']      = "Wait";
-          $a_ext[$i]['appdata']  = "2";
-          $i ++ ; 
-    
-          /* Set language to queue language */
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 2;
-          $a_ext[$i]['app']      = "SetLanguage";
-          $a_ext[$i]['appdata']  = $this->goFonQueueLanguage;
-          $i ++ ; 
-  
-          /* Play welcome sound file */
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 3;
-          $a_ext[$i]['app']      = "Playback";
-          $a_ext[$i]['appdata']  = $this->goFonWelcomeMusic;
-          $i ++ ; 
-
-          /* Set CID name */
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 4;
-          $a_ext[$i]['app']      = "SetCIDName";
-          if(!empty($this->parent->by_object['ogroup']->description)){
-            $a_ext[$i]['appdata']  = $this->parent->by_object['ogroup']->description;
-          }else{
-            $a_ext[$i]['appdata']  = $this->cn." - ".$num;
-          }
-          $i ++ ; 
-
-          /* Set queue priority */
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 5;
-          $a_ext[$i]['app']      = "SetVar";
-          $a_ext[$i]['appdata']  = "QUEUE_PRIO=".$prio;
-          $i ++ ; 
-
-          /* Open queue */
-          $a_ext[$i]['context']  = 'GOsa';
-          $a_ext[$i]['exten']    = $num;
-          $a_ext[$i]['priority'] = 6;
-          $a_ext[$i]['app']      = "Queue";
-          $a_ext[$i]['appdata']  =  $this->cn;
-            "|".
-            $this->goFonDialOptiont.
-            $this->goFonDialOptionT.
-            $this->goFonDialOptionh.
-            $this->goFonDialOptionH.
-            $this->goFonDialOptionr;
-        }
-
-        $i++;
-      }
-
-      /* Parse and Add Extension entries */
-      foreach($a_ext as $ext){
-        $entries = "";
-        $values  = "";
-        foreach($ext as $attr => $val){
-          $entries.= "`".$attr."`,";
-          $values .= "'".$val."',";
-        }
-        $values  = preg_replace("/,$/","",$values);
-        $entries = preg_replace("/,$/","",$entries );
-        $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$entries.") VALUES (".$values.")";
-      }
-
-      /* Do all collected mysql queries 
-       */
-      foreach($SQL as $query)
-      $res   = mysql_query($query,$res_cur);
-      if(!$res){
-        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur));
-        return(_("Mysql query failed.")."&nbsp;"._("Please have a look a the gosa logfiles."));
-      }
-    }
-    @mysql_close($r_con);
-    return(false);
-  }
-
-
-  /* This function checks if the given phonenumbers 
-   *  are available or already in use
-   */
-  function is_number_used()
-  {
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(& (!(uid=".$this->cn."))
-                        (!(cn=".$this->cn.")))
-                     (| (objectClass=goFonAccount)
-                        (objectClass=goFonQueue)
-                        (objectClass=goFonConference)))", array("telephoneNumber","cn","uid"));
-    while($attrs = $ldap->fetch()) {
-      unset($attrs['telephoneNumber']['count']);
-      foreach($attrs['telephoneNumber'] as $tele){
-        if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
-        if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
-        $numbers[$tele]=$attrs;
-      }
-    }
-
-    foreach($this->telephoneNumber as $num){
-      if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!= $this->attrs['cn'][0]))){
-        if(isset($numbers[$num]['uid'][0])){
-          return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
-        }else{
-          return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
-        }
-      }
-    }
-  }
-
-
-  /* Get posted attributes */
-  function save_object()
-  {
-    plugin::save_object();  
-    if(isset($_POST['phonenumber'])){
-      foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionh","goFonDialOptionr","goFonDialOptionH","goFonMusiconHold") as $val){
-        if(isset($_POST[$val])){
-          $this->$val = $_POST[$val];
-        }else{
-          $this->$val = false;
-        }
-      }
-      if(isset($_POST['goFonQueueAnnounceHoldtime'])){
-        $this->goFonQueueAnnounceHoldtime = "yes";
-      }else{
-        $this->goFonQueueAnnounceHoldtime = false;
-      }
-    }
-  }
-
-
-  function save()
-  {
-    $ldap= $this->config->get_ldap_link();
-
-    plugin::save();
-
-    /* Create dial option attribute */
-    $this->attrs['goFonDialOption'] = "";
-    foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){
-      $this->attrs['goFonDialOption'].=$this->$val; 
-      unset($this->attrs[$val]); 
-    }
-    if(empty($this->attrs['goFonDialOption'])) {
-      $this->attrs['goFonDialOption']=array();
-    }
-
-    /* Set announce hold time to yes no .. */
-    if($this->goFonQueueAnnounceHoldtime != "no" ){
-      $this->attrs['goFonQueueAnnounceHoldtime'] = "yes";
-    }else{
-      $this->attrs['goFonQueueAnnounceHoldtime'] = "no";
-    }
-
-    /* Set strategy */
-    $this->attrs['goFonQueueStrategy'] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy];
-
-    /* Add database entry, display error and abort if this fails */
-    $str = $this->add_to_database(true);
-    if(!empty($str)){
-      print_red($str);
-    }
-
-    /* Save data to LDAP */
-    $ldap->cd($this->dn);
-    $this->cleanup();
-    $ldap->modify ($this->attrs); 
-
-    if($this->initially_was_account){
-      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    show_ldap_error($ldap->get_error(), _("Saving phone queue failed"));
-
-    /* Optionally execute a command after we're done */
-    if ($this->initially_was_account == $this->is_account){
-      if ($this->is_modified){
-        $this->handle_post_events("modify");
-      }
-    } else {
-      $this->handle_post_events("add");
-    }
-  }
-
-
-  /* remove object from parent */
-  function remove_from_parent()
-  {
-    /* Cancel if nothing is to do here */
-    if (!$this->initially_was_account){
-      return;
-    }
-
-    /* Remove database entries, 
-     *  if fails display errors and abort
-     */
-    $str = $this->remove_from_database(true);
-    if(!empty($str)){
-      print_red($str);
-      return false;
-    }
-  
-    /* Remove all temporary attributes */
-    $tmp = array_flip($this->attributes);
-    foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){
-      unset($this->$val);
-      unset($this->attrs[$val]);
-      unset($tmp[$val]);
-    }   
-    foreach(array_flip($tmp) as $key => $val){
-      $tmp2[]=$val;
-    } 
-    $this->attributes = $tmp2;
-
-    /* include global link_info */
-    $ldap= $this->config->get_ldap_link();
-
-    /* Remove and write to LDAP */
-    plugin::remove_from_parent();
-
-    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
-    $ldap->cd($this->dn);
-    $this->cleanup();
-    $ldap->modify ($this->attrs); 
-    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    show_ldap_error($ldap->get_error(), _("Removing phone queue failed"));
-  }
-
-  
-  function getCopyDialog()
-  {
-    $str  = "";
-    $str .= _("Phone number");
-    $str .= "&nbsp;<input type='text' name='telephoneNumber' value='".$this->telephoneNumber."'>";
-    return($str);
-  }
-
-
-  function saveCopyDialog()
-  {
-    if(isset($_POST['telephoneNumber'])){
-      $this->telephoneNumber = $_POST['telephoneNumber'];
-    }
-  }
-
-
-  static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("Phone"),
-          "plDescription" => _("Phone group"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 3,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("ogroups"),
-          "plProvidedAcls"=> array(
-
-            "goFonTimeOut"              => _("Timeout"),
-            "goFonMaxLen"               => _("Max queue length"),
-            "goFonHomeServer"           => _("Home server"),
-            "goFonAnnounceFrequency"    => _("Announce frequency"),
-            "goFonDialOptiont"          => _("Allow the called user to transfer his call"),
-            "goFonDialOptionT"          => _("Allows calling user to transfer call"),
-            "goFonDialOptionh"          => _("Allow the called to hangup by pressing *"),
-            "goFonDialOptionr"          => _("Ring instead of playing background music"),
-            "goFonDialOptionH"          => _("Allows calling to hangup by pressing *"),
-
-            "goFonMusiconHold"          => _("Music on hold"),
-            "goFonWelcomeMusic"         => _("Welcome music"),
-            "goFonQueueReportHold"      => _("Report hold time"),
-            "goFonQueueYouAreNext"      => _("'You are next' sound"),
-            "goFonQueueThereAre"        => _("'There are' sound"),
-            "goFonQueueCallsWaiting"    => _("'Call waiting' sound"),
-            "goFonQueueThankYou"        => _("'Thank you' sound"),
-            "goFonQueueMinutes"         => _("'Minutes' sound"),
-            "goFonQueueSeconds"         => _("'Seconds' sound"),
-            "goFonQueueLessThan"        => _("'Less than' sound"),
-            "telephoneNumber"           => _("Queue phone number"),
-            "goFonQueueLanguage"        => _("Language"),
-            "goFonQueueStrategy"        => _("Method"),
-            "goFonQueueAnnounceHoldtime"=> _("Announce holdtime"),
-            "goFonQueueAnnounce"        => _("Announce"),
-            "goFonQueueRetry"           => _("Retry"))
-              ));
-  }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/ogroups/gofon/phonequeue.tpl b/gosa-core/plugins/admin/ogroups/gofon/phonequeue.tpl
deleted file mode 100644 (file)
index 643b4a3..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-<p style='padding-left:7px;'>
- <img class='center' src='images/lamp.png' alt='!'>&nbsp;<b>{t}Only users with the same asterisk home server will be included to this queue.{/t}</b>
-</p>
-
-<table summary="{t}Queue Settings{/t}" style="width: 100%; vertical-align: top; text-align: left;" border="0" cellpadding="4">
-<tr>
-<td valign='top'>
-               <h2><img class="center" alt="" src="images/select_phone.png" align="middle">&nbsp;{t}Phone numbers{/t}</h2>
-               <table summary="">
-               <tr>
-               <td colspan=2>
-                 <table summary="{t}Generic queue Settings{/t}">
-                  <tr>
-                   <td>
-{render acl=$telephoneNumberACL}
-                       <select style="width:300px; height:60px;" name="goFonQueueNumber_List" size=6>
-                       {html_options options=$telephoneNumber}
-                       <option disabled>&nbsp;</option>
-                       </select>
-{/render}
-               </td>
-               <td style="vertical-align:center">
-{render acl=$telephoneNumberACL}
-                       <input type="submit" value="{t}Up{/t}"          name="up_phonenumber"><br>
-{/render}
-{render acl=$telephoneNumberACL}
-                       <input type="submit" value="{t}Down{/t}"        name="down_phonenumber">
-{/render}
-               </td>
-               </tr>
-               <tr>
-                <td colspan=2>
-{render acl=$telephoneNumberACL}
-                       <input name="phonenumber" size=20 align=middle maxlength=60 value="">
-{/render}
-{render acl=$telephoneNumberACL}
-                       <input type="submit" value="{t}Add{/t}"         name="add_phonenumber" >&nbsp;
-{/render}
-{render acl=$telephoneNumberACL}
-                       <input type="submit" value="{t}Delete{/t}"      name="delete_phonenumber" >
-{/render}
-            </td>
-               </tr>
-               </table>
-               </tr>
-               <tr>
-                 <td colspan=2><h2><img class="center" alt="" src="images/select_ogroup.png" align="middle">&nbsp;{t}Options{/t}</h2></td>
-               </tr>
-                <tr>
-                <td><LABEL for="goFonHomeServer">{t}Home server{/t}</LABEL>{$must}</td>
-                <td>
-{render acl=$goFonHomeServerACL}
-                        <select name='goFonHomeServer'>
-                         {html_options options=$goFonHomeServers selected=$goFonHomeServer}
-                        </select>
-{/render}
-                </td>
-                </tr>
-
-               <tr>
-               <td>
-                       {t}Language{/t} 
-               </td>
-               <td>
-{render acl=$goFonQueueLanguageACL}
-                       <select name="goFonQueueLanguage">
-                       {html_options options=$goFonQueueLanguageOptions selected=$goFonQueueLanguage}
-                       <option disabled>&nbsp;</option>
-                       </select>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Timeout{/t}
-               </td>
-               <td>
-{render acl=$goFonTimeOutACL}
-                       <input name='goFonTimeOut' value='{$goFonTimeOut}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Retry{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueRetryACL}
-                       <input name='goFonQueueRetry' value='{$goFonQueueRetry}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Strategy{/t} 
-               </td>
-               <td>
-{render acl=$goFonQueueStrategyACL}
-                       <select name="goFonQueueStrategy">
-            {html_options options=$goFonQueueStrategyOptions selected=$goFonQueueStrategy}
-            <option disabled>&nbsp;</option>
-            </select>
-{/render}
-       
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Max queue length{/t}
-               </td>
-               <td>
-{render acl=$goFonMaxLenACL}
-                       <input name='goFonMaxLen' value='{$goFonMaxLen}'>       
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Announce frequency{/t}
-               </td>
-               <td>
-{render acl=$goFonAnnounceFrequencyACL}
-                       <input name='goFonAnnounceFrequency' value='{$goFonAnnounceFrequency}'>
-{/render}
-                       {t}(in seconds){/t}     
-               </td>
-               </tr>
-               </table>
-</td>
-<td valign='top' style="border-left: 1px solid rgb(160, 160, 160);">
-       <h2>
-    <img class="center" alt="" src="images/sound.png" align="middle">
-    {t}Queue sound setup{/t}
-    </h2>
-       <table summary="{t}Generic queue Settings{/t}">
-               <!--<tr>
-               <td>
-                       {t}Use music on hold instead of ringing{/t}
-               </td>
-               <td>
-{render acl=goFonMusiconHoldACL}
-                       <input type="checkbox" name='goFonMusiconHold' value='1' {$goFonMusiconHoldCHK}>
-{/render}
-               </td>
-               </tr>
-               -->
-               <tr>
-               <td>
-                       {t}Music on hold{/t}
-               </td>
-               <td>
-{render acl=$goFonMusiconHoldACL}
-                       <input type="text" style='width:250px;' name='goFonMusiconHold' value='{$goFonMusiconHold}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Welcome sound file{/t}
-               </td>
-               <td>
-{render acl=$goFonWelcomeMusicACL}
-                       <input type="text" style='width:250px;' name='goFonWelcomeMusic' value='{$goFonWelcomeMusic}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Announce message{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueAnnounceACL}
-                       <input type="text" style='width:250px;' name='goFonQueueAnnounce' value='{$goFonQueueAnnounce}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Sound file for 'You are next ...'{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueYouAreNextACL}
-                       <input type="text" style='width:250px;' name='goFonQueueYouAreNext' value='{$goFonQueueYouAreNext}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}'There are ...'{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueThereAreACL}
-                       <input type="text" style='width:250px;' name='goFonQueueThereAre' value='{$goFonQueueThereAre}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}'... calls waiting'{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueCallsWaitingACL}
-                       <input type="text" style='width:250px;' name='goFonQueueCallsWaiting' value='{$goFonQueueCallsWaiting}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}'Thank you' message{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueThankYouACL}
-                       <input type="text" style='width:250px;' name='goFonQueueThankYou' value='{$goFonQueueThankYou}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}'minutes' sound file{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueMinutesACL}
-                       <input type="text" style='width:250px;' name='goFonQueueMinutes' value='{$goFonQueueMinutes}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}'seconds' sound file{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueSecondsACL}
-                       <input type="text" style='width:250px;' name='goFonQueueSeconds' value='{$goFonQueueSeconds}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Hold sound file{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueReportHoldACL}
-                       <input type="text" style='width:250px;' name='goFonQueueReportHold' value='{$goFonQueueReportHold}'>
-{/render}
-               </td>
-               </tr>
-               <tr>
-               <td>
-                       {t}Less Than sound file{/t}
-               </td>
-               <td>
-{render acl=$goFonQueueLessThanACL}
-                       <input type="text" style='width:250px;' name='goFonQueueLessThan' value='{$goFonQueueLessThan}'>
-{/render}
-               </td>
-               </tr>
-
-               </table>
-</td>
-</tr>
-<tr>
-       <td colspan=2>
-               <p class="seperator">
-       </td>
-</tr>
-<tr>
-<td colspan=2><h2 style='margin-bottom:0px;'><img class="center" alt="" src="images/select_ogroup.png" align="middle">&nbsp;{t}Phone attributes {/t}</h2></td>
-</tr>
-<tr>
-<td>
-               <table summary="" style="width: 100%; vertical-align: top; text-align: left;" border="0" cellpadding="0">
-        <tr>
-        <td colspan=2>
-{render acl=$goFonQueueAnnounceHoldtimeACL}
-            <input type="checkbox" name='goFonQueueAnnounceHoldtime' value='yes'  {$goFonQueueAnnounceHoldtimeCHK}>
-{/render}
-            {t}Announce holdtime{/t}
-        </td>
-        </tr>
-        <tr>
-        <td colspan=2>
-{render acl=$goFonDialOptiontACL}
-            <input type="checkbox" name='goFonDialOptiont' value='t'  {$goFonDialOptiontCHK}>
-{/render}
-            {t}Allow the called user to transfer his call{/t}
-        </td>
-        </tr>
-        <tr>
-        <td colspan=2>
-{render acl=$goFonDialOptionTACL}
-            <input type="checkbox" name='goFonDialOptionT' value='T' {$goFonDialOptionTCHK}>
-{/render}
-            {t}Allows calling user to transfer call{/t}
-        </td>
-        </table>
-
-</td>
-<td valign='top' style="border-left: 1px solid rgb(160, 160, 160);">
-               <table summary=""  style="width: 100%; vertical-align: top; text-align: left;" border="0" cellpadding="0">
-        <tr>
-        <td colspan=2>
-{render acl=$goFonDialOptionhACL}
-            <input type="checkbox" name='goFonDialOptionh' value='h' {$goFonDialOptionhCHK}>
-{/render}
-            {t}Allow the called to hangup by pressing *{/t}
-        </td>
-        </tr>
-        <tr>
-        <td colspan=2>
-{render acl=$goFonDialOptionHACL}
-            <input type="checkbox" name='goFonDialOptionH' value='H' {$goFonDialOptionHCHK}>
-{/render}
-            {t}Allows calling to hangup by pressing *{/t}
-        </td>
-        </tr>
-        <tr>
-        <td colspan=2>
-{render acl=$goFonDialOptionrACL}
-            <input type="checkbox" name='goFonDialOptionr' value='r' {$goFonDialOptionrCHK}>
-{/render}
-            {t}Ring instead of playing background music{/t}
-        </td>
-        </tr>
-        </table>
-</td>
-</tr>
-
-</table>
diff --git a/gosa-core/plugins/admin/ogroups/goto/class_termgroup.inc b/gosa-core/plugins/admin/ogroups/goto/class_termgroup.inc
deleted file mode 100644 (file)
index f819349..0000000
+++ /dev/null
@@ -1,432 +0,0 @@
-<?php
-
-class termgroup extends plugin
-{
-  /* attribute list for save action */
-  var $members= array();
-
-  var $gotoMode           = "locked";
-  var $gotoSyslogServer   = "";
-  var $gotoNtpServer      = array();
-  var $gotoNtpServers     = array();
-  var $modes              = array();
-  var $inheritTimeServer  = true;
-  var $is_account                    = true; 
-  var $orig_dn            = "";
-  var $didAction          = FALSE;
-  var $mapActions   = array("reboot"          => "localboot",
-                            "instant_update"  => "softupdate",
-                            "update"          => "sceduledupdate",
-                            "reinstall"       => "install",
-                            "rescan"          => "",
-                            "memcheck"        => "memcheck",
-                            "sysinfo"         => "sysinfo");
-
-  var $attributes     = array("gotoMode","gotoSyslogServer", "gotoNtpServer");
-  var $objectclasses  = array("gotoWorkstationTemplate");
-  var $CopyPasteVars  = array("gotoNtpServers","modes","inheritTimeServer","members");
-  var $view_logged    = FALSE;
-
-
-  function termgroup (&$config, $dn= NULL, $parent= NULL)
-  {
-    /***************
-      Some  initialisations
-     ***************/
-
-    plugin::plugin($config, $dn, $parent);
-
-    $ldap= $config->get_ldap_link();
-
-    $this->is_account = true;
-    $this->modes["active"]= _("Activated");
-    $this->modes["locked"]= _("Locked");
-//    $this->modes["memcheck"]= _("Memory test");
-//    $this->modes["sysinfo"]= _("System analysis");
-
-    $this->orig_dn =   $this->dn;
-
-    /*************** 
-      Get mac addresses from member objects  
-     ***************/
-
-    /* We're only interested in the terminal members here, evaluate
-       these... */
-    if(isset($this->attrs['member'])){
-      for ($i= 0; $i<$this->attrs['member']['count']; $i++){
-        $member= $this->attrs['member'][$i];
-        $ldap->cat($member, array('objectClass', 'macAddress', 'cn'));
-        if (preg_match("/success/i", $ldap->error)){
-          $attrs = $ldap->fetch();
-          if (in_array("gotoTerminal", $attrs['objectClass']) ||
-              in_array("gotoWorkstation", $attrs['objectClass'])){
-            if (isset($attrs['macAddress'])){
-              $this->members[$attrs['cn'][0]]= $attrs['macAddress'][0];
-            } else {
-              $this->members[$attrs['cn'][0]]= "";
-            }
-          }
-        }
-      }
-    }
-
-    /*************** 
-      Perpare NTP settings 
-     ***************/
-
-    /* Create used ntp server array */
-    $this->gotoNtpServer= array();
-    if(isset($this->attrs['gotoNtpServer'])){
-      $this->inheritTimeServer = false;
-      unset($this->attrs['gotoNtpServer']['count']);
-      foreach($this->attrs['gotoNtpServer'] as $server){
-        $this->gotoNtpServer[$server] = $server;
-      }
-    }
-
-    /* Set inherit checkbox state */
-    if(in_array("default",$this->gotoNtpServer)){
-      $this->inheritTimeServer = true;
-      $this->gotoNtpServer=array();
-    }
-
-    /* Create available ntp options */
-    $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
-    foreach($this->gotoNtpServers as $key => $server){
-      if($server == "default"){
-        unset($this->gotoNtpServers[$key]);
-      }
-    }
-  }
-
-  function check()
-  {
-     /* Call common method to give check the hook */
-    $message= plugin::check();
-
-    if (!$this->acl_is_createable() && $this->dn == "new"){
-      $message[]= _("You have no permissions to create a workstation on this 'Base'.");
-    }
-
-    /* Check for valid ntpServer selection */
-    if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
-      $message[]= _("There must be at least one NTP server selected.");
-    }
-    return($message);
-  }
-
-  function remove_from_parent()
-  {
-    /* Workstation startup is using gotoWorkstationTemplate too,
-        if we remove this oc all other not manged attributes will cause errors */
-    if(isset($this->attrs['gotoKernelParameters'])){
-      $this->objectclasses = array();
-    }
-
-    /* Remove acc */
-    plugin::remove_from_parent();
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->orig_dn);
-    $ldap->modify($this->attrs);
-    $this->handle_post_events("remove");
-    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-  }
-
-
-  function update_term_member_FAIstate($act)
-  {
-    /* Get required informations */
-    $og     = $this->parent->by_object['ogroup'];
-    $allobs = $og->objcache;
-
-    /* Get correct value for FAIstate */
-    $action = $this->mapActions[$act];
-
-    /* Get ldap connection */
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd ($this->config->current['BASE']);
-
-    /* Foreach member of mthis ogroup  ... */
-    foreach($og->member  as $key ){
-  
-      /* check objectClasses and create attributes array */
-      $attrs = array("FAIstate"=>$action);  
-      for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){
-        $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i];
-      }
-      if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
-        $attrs['objectClass'][] = "FAIobject";
-      }
-      if($attrs['FAIstate'] == ""){
-        $attrs['FAIstate'] = array();
-      }
-
-      /* If this objects is workstation,terminal or server upodate FAIstate */ 
-      if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){
-        $ldap->cd ($key);
-        $ldap->modify($attrs);
-        show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action));
-      }
-    }
-  }
-
-  function execute()
-  {
-    /* Call parent execute */
-    plugin::execute();
-
-    if(!$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","ogroups/".get_class($this),$this->dn);
-    }
-
-    /*************** 
-      Handle requested action
-     ***************/
-
-    /* Watch for events */
-    if (isset($_POST['action'])){
-      $macaddresses="";
-      $names="";
-      foreach ($this->members as $cn => $macAddress){
-        $macaddresses.= "$macAddress ";
-        $names.= "$cn ";
-      }
-
-      if (isset($_POST['action'])){
-  
-        /* Update members fai state */
-        $this->update_term_member_FAIstate(trim($_POST['saction']));
-
-        $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs'));
-
-        if ($cmd == ""){
-          print_red(_("No ACTIONCMD definition found in your gosa.conf"));
-        } else {
-          exec ($cmd." ".$macaddresses." ".escapeshellarg($_POST['saction']), $dummy, $retval);
-          if ($retval != 0){
-            print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
-          } else {
-            $this->didAction= TRUE;
-
-            /* Get dns from member objects. Create ldap object  */
-            $member = $this->parent->by_object['ogroup']->member;
-            $ldap = $this->config->get_ldap_link();
-            $ldap->cd($this->config->current['BASE']);
-
-            /* walk trough members and add FAIstate */ 
-            foreach($member as $dn =>  $object){
-
-              /* Get object */
-              $ldap->cat($dn,array("objectClass"));
-              $res                = $ldap->fetch();
-              $attrs              = array();
-
-              /* Add FAI state */
-              $attrs['FAIstate']  = "";
-              if(isset($this->mapActions[$_POST['saction']])){
-                $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
-              }
-
-              /* Fix objectClass index */
-              for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
-                $attrs['objectClass'][] = $res['objectClass'][$i];
-              }
-
-              /* Check if we must add the objectClass */
-              if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
-                $attrs['objectClass'][] = "FAIobject";
-              }
-
-              if($attrs['FAIstate'] == ""){
-                $attrs['FAIstate'] = array();
-              }
-
-              $ldap->cd($dn);
-              $ldap->modify($attrs);
-              show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$dn));
-            }
-            $this->didAction= TRUE;
-          }
-        }
-      }
-    }
-
-
-    /*************** 
-      Add remove NTP server
-     ***************/
-
-    /* Add new ntp Server to our list */
-    if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){
-      $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
-    }
-
-    /* Delete selected NtpServer for list of used servers  */
-    if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){
-      foreach($_POST['gotoNtpServerSelected'] as $name){
-        unset($this->gotoNtpServer[$name]);
-      }
-    }
-
-
-    /*************** 
-      Prepare smarty 
-     ***************/
-
-    /* Set government mode */
-    $smarty= get_smarty();
-
-    $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translated) {
-      $smarty->assign($name."ACL",$this->getacl($name));
-    }
-
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr,      $this->$attr);
-    }
-
-    /* Variables */
-    foreach(array("gotoMode","gotoNtpServer") as $val){
-      $smarty->assign($val."_select", $this->$val);
-    }
-
-    $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
-          "instant_update" => _("Instant update"),
-          "update" => _("Scheduled update"),
-          "reinstall" => _("Reinstall"),
-          "rescan" => _("Rescan hardware"),
-          "memcheck" => _("Memory test"),
-          "sysinfo"  => _("System analysis")));
-
-    $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
-    $smarty->assign("modes", $this->modes);
-
-    $tmp = array();
-    foreach($this->gotoNtpServers as $server){
-      if(!in_array($server,$this->gotoNtpServer)){
-        $tmp[$server] = $server;
-      }
-    }
-
-    $smarty->assign("gotoNtpServers",$tmp); 
-    $smarty->assign("syslogservers", $this->config->data['SERVERS']['SYSLOG']); 
-    $smarty->assign("gotoSyslogServer_select", $this->gotoSyslogServer); 
-
-    /* Show main page */
-    return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE, dirname(__FILE__))));
-  }
-
-  function save_object()
-  {
-    plugin::save_object();  
-    /* Set inherit mode */
-    if(isset($_POST['workgeneric_posted'])){
-      if(isset($_POST["inheritTimeServer"])){
-        $this->inheritTimeServer = true;
-      }else{
-        $this->inheritTimeServer = false;
-      }
-    }
-  }
-
-  /* Save to LDAP */
-  function save()
-  {
-    plugin::save();
-
-    /***************
-      Prepare special vars 
-     ***************/
-
-    /* Unset some special vars ... */
-    foreach (array("gotoSyslogServer") as $val){
-      if ($this->attrs[$val] == "default"){
-        $this->attrs[$val]= array();
-      }
-    }
-
-    /* Update ntp server settings */
-    if($this->inheritTimeServer){
-      $this->attrs['gotoNtpServer'] = "default";
-    }else{
-      /* Set ntpServers */
-      $this->attrs['gotoNtpServer'] = array();
-      foreach($this->gotoNtpServer as $server){
-        $this->attrs['gotoNtpServer'][] = $server;
-      }
-    }
-
-
-    /***************
-      Write to ldap 
-     ***************/
-
-    /* Write back to ldap */
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
-    $this->cleanup();
-    $ldap->modify ($this->attrs);
-
-    if($this->initially_was_account){
-      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    if(!$this->didAction){
-      $this->handle_post_events("modify");
-    }
-    show_ldap_error($ldap->get_error(), _("Saving workstation failed"));
-
-  }
-  
-  static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("System"),
-          "plDescription" => _("System group"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 5,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("ogroups"),
-          "plProvidedAcls"=> array(
-            "gotoMode"          => _("Mode"),     
-            "gotoSyslogServer"  => _("Syslog server"), 
-            "FAIstate"          => _("Action flag"), 
-            "gotoNtpServer"     => _("Ntp server"))
-          ));
-  }
-
-  function PrepareForCopyPaste($source)
-  {
-    /* Create used ntp server array */
-    $this->gotoNtpServer= array();
-
-    if(isset($source['gotoNtpServer'])){
-      $this->inheritTimeServer = false;
-      unset($source['gotoNtpServer']['count']);
-      foreach($source['gotoNtpServer'] as $server){
-        $this->gotoNtpServer[$server] = $server;
-      }
-    }
-
-    /* Set inherit checkbox state */
-    if(in_array("default",$this->gotoNtpServer)){
-      $this->inheritTimeServer = true;
-      $this->gotoNtpServer=array();
-    }
-
-    /* Create available ntp options */
-    $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
-    foreach($this->gotoNtpServers as $key => $server){
-      if($server == "default"){
-        unset($this->gotoNtpServers[$key]);
-      }
-    }
-  }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/ogroups/goto/termgroup.tpl b/gosa-core/plugins/admin/ogroups/goto/termgroup.tpl
deleted file mode 100644 (file)
index b35458c..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-<br>
-<b>{t}Warning{/t}:</b> {t}Actions you choose here influence all systems in this object group. Additionally, all values editable here can be inherited by the clients assigned to this object group.{/t}
-<br>
-<br>
-<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
-<h2><img class="center" alt="" align="middle" src="images/select_terminal.png"> {t}Generic{/t}</h2>
-
-<table width="100%">
-       <tr>
-               <td style='width:50%;'>
-               <!-- Upper left -->
-                          <table width="100%">
-                               <tr>
-                                <td colspan="2" style='padding-top:5px;'><LABEL for="gotoNtpServerSelected">{t}NTP server{/t}</LABEL><br>
-{render acl=$gotoNtpServerACL}
-                                 <select name="gotoNtpServerSelected[]" id="gotoNtpServerSelected" multiple size=5 style="width:100%;"
-                                               title="{t}Choose server to use for synchronizing time{/t}" {if $inheritTimeServer} disabled {/if}>
-                                  {html_options options=$gotoNtpServer_select}
-                                 </select>
-{/render}
-                                <br>
-{render acl=$gotoNtpServerACL}
-                                 <select name="gotoNtpServers" id="gotoNtpServers" {if $inheritTimeServer} disabled {/if} >
-                                  {html_options output=$gotoNtpServers values=$gotoNtpServers}
-                                 </select>
-{/render}
-{render acl=$gotoNtpServerACL}
-                                       <input type="submit" name="addNtpServer" value="{t}Add{/t}"     id="addNtpServer"
-                                        {if ($inheritTimeServer) || (!$gotoNtpServers)} disabled {/if}>
-{/render}
-
-{render acl=$gotoNtpServerACL}
-                                       <input type="submit" name="delNtpServer" value="{t}Delete{/t}"  id="delNtpServer"
-                                        {if ($inheritTimeServer) || (!$gotoNtpServer_select)} disabled {/if} >
-{/render}
-                                </td>
-                               </tr>
-                          </table>
-
-
-               </td>
-               <td style="vertical-align:top;border-left:1px solid #A0A0A0;">
-               <!-- Upper right -->
-                               
-                       <table summary="">
-                               <tr>
-                                <td>{t}Mode{/t}</td>
-                                <td>
-{render acl=$gotoModeACL}
-                                 <select name="gotoMode" title="{t}Select terminal mode{/t}">
-                                  {html_options options=$modes selected=$gotoMode_select}
-                                 </select>
-{/render}
-                                </td>
-                               </tr>
-                               <tr><td colspan="2">&nbsp;</td></tr>
-                               <tr>
-                                <td><LABEL for="gotoSyslogServer">{t}Syslog server{/t}</LABEL></td>
-                                <td>
-{render acl=$gotoSyslogServerACL}
-                                 <select id="gotoSyslogServer" name="gotoSyslogServer" title="{t}Choose server to use for logging{/t}">
-                                  {html_options values=$syslogservers output=$syslogservers selected=$gotoSyslogServer_select}
-                                 </select>
-{/render}
-                                </td>
-                               </tr>
-                               </table>
-               </td>
-       </tr>
-       <tr>
-               <td colspan=2>
-                       <p class="seperator">&nbsp;</p>
-               </td>
-       </tr>
-       <tr>
-               <td>
-               <!-- Bottom left -->                    
-
-               </td>
-               <td style="vertical-align:top;border-left:1px solid #A0A0A0;">
-               <!-- Bottom right -->                   
-               </td>
-       </tr>
-</table>
-<input name="workgeneric_posted" value="1" type="hidden">
-
-
-<h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
-                               <table summary="">
-                                <tr>
-                                 <td>
-{render acl=$FAIstateACL}
-                                  <select size="1" name="saction" {$FAIstateACL} title="{t}Select action to execute for this terminal{/t}">
-                                       <option>&nbsp;</option>
-                                       {html_options options=$actions}
-                                  </select>
-{/render}
-                                 </td>
-                                 <td>
-{render acl=$FAIstateACL}
-                                  <input type=submit name="action" value="{t}Execute{/t}">
-{/render}
-                                 </td>
-                                </tr>
-                               </table>
-       
-
-
-
-
diff --git a/gosa-core/plugins/admin/ogroups/mail/class_mailogroup.inc b/gosa-core/plugins/admin/ogroups/mail/class_mailogroup.inc
deleted file mode 100644 (file)
index 85aadf3..0000000
+++ /dev/null
@@ -1,199 +0,0 @@
-<?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();
-  var $view_logged = FALSE;
-
-  function mailogroup (&$config, $dn= NULL, $parent= NULL)
-  {
-    plugin::plugin($config, $dn, $parent);
-
-    /* Include config object */
-    $this->config= $config;
-
-    /* Save initial account state */
-    $this->initially_was_account= $this->is_account;
-  }
-
-
-  function execute()
-  {
-    /* Call parent execute */
-    plugin::execute();
-
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","ogroups/".get_class($this),$this->dn);
-    }
-
-
-    /* Do we need to flip is_account state? */
-    if(isset($_POST['modify_state'])){
-      if($this->is_account && $this->acl_is_removeable()){
-        $this->is_account= FALSE;
-      }elseif(!$this->is_account && $this->acl_is_createable()){
-        $this->is_account= TRUE;
-      }
-    }
-
-    /* Show tab dialog headers */
-    if ($this->parent !== NULL){
-      if ($this->is_account){
-        $display= $this->show_disable_header(_("Remove mail account"),
-            _("This group has mail features enabled. You can disable them by clicking below."));
-      } else {
-        $display= $this->show_enable_header(_("Create mail account"), _("This group has mail features disabled. You can enable them by clicking below."));
-        return ($display);
-      }
-    }
-    
-    /* Initialize templating engine */
-    $smarty= get_smarty();
-
-    $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translation){
-      $smarty->assign($name."ACL",$this->getacl("mail"));
-    }
-
-    /* Assign mail attribute */
-    $smarty->assign("mail", $this->mail);
-
-    /* Show main page */
-    return ($display.$smarty->fetch (get_template_path('mail.tpl', TRUE,dirname(__FILE__))));
-  }
-
-
-  /* Check formular input */
-  function check()
-  {
-    /* Call common method to give check the hook */
-    $message= plugin::check();
-
-    if ($this->is_account){
-      $ldap= $this->config->get_ldap_link();
-
-      /* Check if mail address is valid */
-      if (!tests::is_email($this->mail) || $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);
-  }
-
-
-  function save()
-  {
-    $ldap= $this->config->get_ldap_link();
-
-    /* Call parents save to prepare $this->attrs */
-    plugin::save();
-
-    /* Save data to LDAP */
-    $ldap->cd($this->dn);
-    $this->cleanup();
-    $ldap->modify ($this->attrs); 
-
-    if($this->initially_was_account){
-      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/mail with dn '%s' failed."),$this->dn));
-
-    /* Optionally execute a command after we're done */
-    if ($this->initially_was_account == $this->is_account){
-      if ($this->is_modified){
-        $this->handle_post_events("modify");
-      }
-    } else {
-      $this->handle_post_events("add");
-    }
-  }
-
-
-  /* remove object from parent */
-  function remove_from_parent()
-  {
-    /* Cancel if there's nothing to do here */
-    if (!$this->initially_was_account){
-      return;
-    }
-
-    /* include global link_info */
-    $ldap= $this->config->get_ldap_link();
-
-    /* Remove and write to LDAP */
-    plugin::remove_from_parent();
-
-    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
-        $this->attributes, "Save");
-    $ldap->cd($this->dn);
-    $this->cleanup();
-    $ldap->modify ($this->attrs); 
-
-    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/mail with dn '%s' failed."),$this->dn));
-  }
-
-
-  function getCopyDialog()
-  {
-    $str = "";
-    $smarty = get_smarty();
-    $smarty->assign("mail",     $this->mail);
-    $str = $smarty->fetch(get_template_path("paste_mail.tpl",TRUE,dirname(__FILE__)));
-    $ret = array();
-    $ret['string'] = $str;
-    $ret['status'] = "";
-    return($ret);
-  }
-
-
-  function saveCopyDialog()
-  {
-    if(isset($_POST['mail'])){
-      $this->mail = $_POST['mail'];
-    }
-  }
-
-
-   static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("Mail"),
-          "plDescription" => _("Mail group"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 4,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("ogroups"),
-          "plProvidedAcls"=> array(
-            "mail" => _("Mail address"))
-          ));
-  }
-
-
-
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/ogroups/mail/mail.tpl b/gosa-core/plugins/admin/ogroups/mail/mail.tpl
deleted file mode 100644 (file)
index a28d0ac..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<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 class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Mail distribution list{/t}</h2>
-   <table summary="">
-    <tr>
-     <td><LABEL for="mail">{t}Primary address{/t}</LABEL>{$must}</td>
-     <td>
-{render acl=$mailACL}
-       <input id="mail" name="mail" size=50 maxlength=65 value="{$mail}" title="{t}Primary mail address for this distribution list{/t}">
-{/render}
-     </td>
-    </tr>
-   </table>
-  </td>
- </tr>
-</table>
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
-  <!-- // First input field on page
-       focus_field('mail');
-  -->
-</script>
diff --git a/gosa-core/plugins/admin/ogroups/mail/paste_mail.tpl b/gosa-core/plugins/admin/ogroups/mail/paste_mail.tpl
deleted file mode 100644 (file)
index 737d707..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<table width='100%'>
-        <tr>
-                <td width='120'>
-                       <LABEL for="mail">{t}Mail{/t}</LABEL>{$must}
-               </td>
-               <td>
-                       <input type='text' id='main' name='mail' value='{$mail}' size='40' title='{t}Please enter a mail address{/t}'> 
-               </td>
-       </tr>
-</table>
-
-<script language="JavaScript" type="text/javascript">
-       focus_field('mail');
-</script>
diff --git a/gosa-plugins/gofon/admin/ogroups/gofon/class_phonequeue.inc b/gosa-plugins/gofon/admin/ogroups/gofon/class_phonequeue.inc
new file mode 100644 (file)
index 0000000..05cd927
--- /dev/null
@@ -0,0 +1,958 @@
+<?php
+
+class phonequeue extends plugin
+{
+  /* plugin specific values */
+  var $mail= "";
+  var $cn= "";
+  var $old_cn ="";
+
+  var $goFonTimeOut             ="20"; 
+  var $goFonMaxLen              ="20"; // 
+  var $goFonAnnounceFrequency   ="60"; // Annouce Frequency in seconds
+  var $goFonDialOptiont         ="";
+  var $goFonDialOptionT         ="";
+  var $goFonDialOptionh         ="";
+  var $goFonDialOptionr         ="";
+  var $goFonDialOptionH         ="";
+  var $goFonQueueAnnounce       ="gonicus-berlin-welcome";
+  var $goFonMusiconHold         ="default";
+  var $goFonWelcomeMusic        ="gonicus-berlin-welcome";
+  var $goFonQueueReportHold     ="yes";
+  var $goFonQueueYouAreNext     ="queue-youarenext";
+  var $goFonQueueThereAre       ="queue-thereare";
+  var $goFonQueueCallsWaiting   ="queue-callswaiting";
+  var $goFonQueueThankYou       ="queue-thankyou";
+  var $goFonQueueMinutes        ="queue-minutes"; 
+  var $goFonQueueSeconds        ="queue-seconds";
+  var $goFonQueueLessThan       ="queue-lessthan";
+  var $goFonQueueLanguage       ="queue-holdtime";
+  var $goFonQueueStrategy       ="ringall";
+  var $goFonQueueAnnounceHoldtime="yes";
+  var $telephoneNumber          =array();
+  var $goFonQueueMember         =array(); 
+  var $goFonDialOption          ="";
+  var $goFonQueueRetry          =5;
+
+  var $goFonQueueStrategyOptions=array();
+  var $goFonQueueStrategyOptionsR=array();
+  
+  var $old_phone_numbers        =array();
+
+  var $goFonHomeServer  = "0";
+  var $init_HomeServer  = "0";
+  var $goFonHomeServers = array();
+
+  var $view_logged = FALSE;
+
+  /* attribute list for save action */
+  var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOptiont","goFonDialOptionT",
+      "goFonDialOptionh","goFonDialOptionr","cn","goFonHomeServer",
+      "goFonDialOptionH","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext",
+      "goFonQueueThereAre","goFonQueueCallsWaiting","goFonQueueThankYou","goFonQueueMinutes","goFonQueueSeconds","goFonQueueLessThan",
+      "telephoneNumber","goFonQueueLanguage","goFonQueueStrategy","goFonQueueAnnounceHoldtime","goFonQueueAnnounce","goFonDialOption","goFonQueueRetry");
+
+  /* ObjectClass */
+  var $objectclasses= array("goFonQueue");
+
+
+
+  /* Pluigin initialization 
+   * - Check currently selected and available home server.
+   * - Set default home server if necessary
+   * - Parse phone options flags
+   * - Get phone numbers 
+   */
+  function phonequeue (&$config, $dn= NULL)
+  {
+    plugin::plugin($config, $dn);
+
+    /* Check server configurations
+     * Load all server configuration in $this->goFonHomeServers if available
+     *  and use first server as default if necessary.
+     */
+    if(isset($config->data['SERVERS']['FON']) && 
+       count($config->data['SERVERS']['FON']) &&
+       is_callable("mysql_connect")){
+
+      /* Set available server */
+      $this->goFonHomeServers = $config->data['SERVERS']['FON'];
+
+      /* Set default server */
+      if($this->dn == "new"){
+        $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
+      }
+
+      /* Remember inital home server, to be able to remove old entries */
+      $this->init_HomeServer = $this->goFonHomeServer;
+
+      /* get config */
+      if(!isset($this->goFonHomeServers[$this->goFonHomeServer])){
+        print_red(sprintf(_("The specified home server '%s' is not available in GOsa server configuration. Saving this account will create a new entry on the server '%s'. Use cancel if you do not want to create a new entry while ignoring old accounts."), preg_replace("/,/",", ",$this->goFonHomeServer), preg_replace("/,/",", ",$this->goFonHomeServers[0]['DN'])));
+        $this->goFonHomeServer = $this->goFonHomeServers[0]['DN'];
+        $this->init_HomeServer = $this->goFonHomeServers[0]['DN'];
+      }
+      $cur_cfg = $this->goFonHomeServers[$this->goFonHomeServer];
+    }
+
+
+    /* Variable init  
+     *  Load phone nubmers and parse dial options 
+     */
+    if($this->is_account){
+      if(isset($this->attrs['telephoneNumber'])){
+        $this->telephoneNumber=$this->attrs['telephoneNumber'];
+        unset($this->telephoneNumber['count']); 
+      }
+      for($i = 0; $i < strlen($this->goFonDialOption); $i++){
+        $name = "goFonDialOption".$this->goFonDialOption[$i];
+        $this->$name=$this->goFonDialOption[$i];
+      }
+    }
+
+    /* Set Queue announce hold time to true/false */
+    if(preg_match("/no/i",$this->goFonQueueAnnounceHoldtime)){
+      $this->goFonQueueAnnounceHoldtime=false;
+    }else{
+      $this->goFonQueueAnnounceHoldtime=true;
+    }
+
+    /* Define all available ringdown types */
+    $types= array('ringall'    =>_("ring all"),
+        'roundrobin' =>_("round robin"),
+        'leastrecent'=>_("least recently called"),
+        'fewestcalls'=>_("fewest completed calls"),
+        'random'     =>_("random"),
+        'rrmemory'   =>_("round robin with memory"));
+    $i = 0;
+    foreach($types as $type => $name){
+      $i++;
+      $this->goFonQueueStrategyOptions[$i]    =$name;
+      $this->goFonQueueStrategyOptionsR[$i]   =$type;
+      $tmp[$type] = $i; 
+    }
+    $this->goFonQueueStrategy= $tmp[$this->goFonQueueStrategy];
+    $this->old_cn = $this->cn;
+    $this->old_phone_numbers = $this->telephoneNumber;
+  }
+
+
+  /* This function ensures that the selected home server 
+   * and the initially selected home server are reachable and accessible  
+   */
+  function check_database_accessibility()
+  {
+    /* Check if mysql extension is available */
+    if(!is_callable("mysql_pconnect")){
+      return(_("Can't save any changes to asterisk database, there is currently no mysql extension available in your php setup."));
+    }
+
+    /********************
+     * Check currently selected home server
+     ********************/
+
+    $cfg_Current  = $this->goFonHomeServers[$this->goFonHomeServer];
+    $r_current    =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
+    if(!$r_current){
+      new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current));
+      return(sprintf(_("The MySQL home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
+            $cfg_Current['SERVER'],$cfg_Current['LOGIN']));
+    }
+    $db_current  =  @mysql_select_db($cfg_Current['DB'],$r_current);
+    if(!$db_current){
+      new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current));
+      mysql_close($r_current);
+      return( sprintf(_("Can't select database '%s' on home server '%s'."),$cfg_Current['DB'],$cfg_Current['SERVER']));
+    }
+
+    /********************
+     * Check init home server
+     ********************/
+
+    if($this->initially_was_account){
+      $cfg_Init  = $this->goFonHomeServers[$this->init_HomeServer] ;
+      $r_init    =  @mysql_pconnect($cfg_Init['SERVER'],$cfg_Init['LOGIN'],$cfg_Init['PASSWORD']);
+      if(!$r_init){
+        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init));
+        return(sprintf(_("The MySQL initial home server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
+              $cfg_Init['SERVER'],$cfg_Init['LOGIN']));
+      }
+      $db_init  =  @mysql_select_db($cfg_Init['DB'],$r_init);
+      if(!$db_init){
+        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_init));
+        mysql_close($r_init);
+        return( sprintf(_("Can't select database '%s' on initial home server '%s'."),$cfg_Init['DB'],$cfg_Init['SERVER']));
+      }
+    }
+  }
+
+  
+  /* Display plugin ui */
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","ogroups/".get_class($this),$this->dn);
+    }
+
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }
+
+    /* Show tab dialog headers */
+    if ($this->parent !== NULL){
+      if ($this->is_account){
+        $display= $this->show_disable_header(_("Remove the phone queue from this Account"),
+            _("Phone queue is enabled for this group. You can disable it by clicking below."));
+      } else {
+        $display= $this->show_enable_header(_("Create phone queue"),
+            _("For this group the phone queues are disabled. You can enable them by clicking below."));
+        return ($display);
+      }
+    }
+
+    if($this->acl_is_writeable("telephoneNumber")){
+
+      /* Add queue number */ 
+      if(isset($_POST['add_phonenumber'])&&(isset($_POST['phonenumber']))&&(!empty($_POST['phonenumber']))){
+        if((!in_array($_POST['phonenumber'],$this->telephoneNumber))&&(is_numeric($_POST['phonenumber']))){
+          $this->telephoneNumber[]=$_POST['phonenumber'];
+        }
+      }
+
+      /* Delete queue number */ 
+      if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
+        unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]);
+      }
+
+      /* queue number up */ 
+      if(isset($_POST['up_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
+        if($_POST['goFonQueueNumber_List']>0){
+          $up   = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
+          $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1];
+          $this->telephoneNumber[$_POST['goFonQueueNumber_List']]    = $down;
+          $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1]  = $up;
+        }
+      }
+
+      /* Queuenumber down */
+      if(isset($_POST['down_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
+        if(isset($this->telephoneNumber[($_POST['goFonQueueNumber_List']+1)])){
+          $up   = $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1];
+          $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
+          $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1]    = $down;
+          $this->telephoneNumber[$_POST['goFonQueueNumber_List']]  = $up;
+        }
+        $this->telephoneNumber[$_POST['goFonQueueNumber_List']]  = $up;
+      }
+    }
+
+    $tmp = array();
+    foreach($this->telephoneNumber as $val){
+      if(!empty($val)){
+        $tmp[]= $val;
+      }
+    }  
+    $this->telephoneNumber=$tmp;
+
+    /* Assign samrty variables */
+    $smarty= get_smarty();
+    $smarty->assign("goFonQueueLanguageOptions",get_languages(FALSE,TRUE));
+    $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions);
+
+    /* Set acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translated){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    foreach($this->attributes as $key => $val){
+      $smarty->assign($val,$this->$val);  
+      if($this->$val == false){
+        $smarty->assign($val."CHK","");
+      }else{
+        $smarty->assign($val."CHK"," checked ");
+      }
+    }
+    
+    /* Create array with goFonHomeServer */
+    $tmp = array();
+    foreach($this->goFonHomeServers as $dn => $val){
+      if(!is_numeric($dn)){
+        $tmp[$dn]  = $val['SERVER'];
+      }
+    }
+    $smarty->assign("goFonHomeServers",$tmp);
+
+    return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE,dirname(__FILE__))));
+  }
+
+
+  /* Check formular input */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+    if(!count($this->goFonHomeServers)){
+      $message[] = _("There must be at least one server with an asterisk database to create a phone queue.");
+    }
+    if(empty($this->goFonHomeServer)){
+      $message[] = _("Please select a valid goFonHomeServer.");
+    }
+    if($this->is_number_used()){
+      $message[] = $this->is_number_used();
+    }
+    if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){
+      $message[] = _("Timeout must be numeric");
+    }
+    if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){
+      $message[] = _("Retry must be numeric");
+    }
+    if(!((is_numeric($this->goFonMaxLen))||(empty($this->goFonMaxLen)))){
+      $message[] = _("Max queue length must be numeric");
+    }
+    if(!((is_numeric($this->goFonAnnounceFrequency))||(empty($this->goFonAnnounceFrequency)))){
+      $message[] = _("Announce frequency must be numeric");
+    }
+    if(count($this->telephoneNumber)==0){
+      $message[] = _("There must be least one queue number defined.");
+    }
+
+    /* check if add to database could be successfull  */
+    $str = $this->add_to_database();
+    if(!empty($str)){
+      $message[] = $str;
+    }
+    return $message;
+  }
+
+
+  /* This function removes the old database entries. 
+   * If this entry should be removed or the home server has changed
+   *  this function is called to ensure that all old entries will be deleted.
+   */
+  function remove_from_database($save = false)
+  {
+    /* Check if we must remove old entries */
+    if($this->initially_was_account){
+
+      /* Check if there is at least on server configuration */
+      if(!count($this->goFonHomeServers)){
+        return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database."));
+      }
+
+      /********************
+       * Get configuration and check it
+       ********************/
+
+      /* Check if databases are reachable, returns an error string if anything fails  */
+      $error_str = $this->check_database_accessibility();
+      if($error_str){
+        return($error_str);
+      }
+
+      /* Connect to current database to be able to add new entries */
+      $cfg_Current  = $this->goFonHomeServers[$this->init_HomeServer] ;
+      $res_cur      =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
+      $db_cur       =  @mysql_select_db($cfg_Current['DB'],$res_cur);
+
+      /* Create sql entries */
+      $delete[]=    "DELETE FROM ".$cfg_Current['EXT_TABLE']."    WHERE exten='".$this->old_cn."';\n";
+      $delete[]=    "DELETE FROM ".$cfg_Current['QUEUE_TABLE']."  WHERE name='".$this->old_cn."'; \n";
+      $delete[]=    "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';\n";
+      foreach($this->old_phone_numbers as $number){
+        $delete[]=    "DELETE FROM ".$cfg_Current['EXT_TABLE']."    WHERE exten='".$number."';\n";
+      }
+
+      /* Execute the queries */  
+      if($save){
+        foreach($delete as $sql){
+          $res = @mysql_query($sql,$res_cur);
+          if(!$res){
+            new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($r_current));
+            return(_("Error while removing old queue entries from database.").
+                "&nbsp;"._("Please have a look a the gosa logfiles."));
+          }
+        }
+      }
+    }
+  }
+
+
+  /* This function handles the database entries for this 
+   *  queue. 
+   * Existing entries will be updated if possible.
+   */
+  function add_to_database($save = false)
+  {
+    /* Check if there is at least on server configuration */
+    if(!count($this->goFonHomeServers)){
+      return( _("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). Your settings can't be saved to asterisk database."));
+    }
+
+    /********************
+     * Get configuration and check it
+     ********************/
+
+    /* Check if databases are reachable, returns an error string if anything fails  */
+    $error_str = $this->check_database_accessibility();
+    if($error_str){
+      return($error_str);
+    }
+
+    /* Connect to current database to be able to add new entries */
+    $cfg_Current  = $this->goFonHomeServers[$this->goFonHomeServer] ;
+    $res_cur      =  @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']);
+    $db_cur       =  @mysql_select_db($cfg_Current['DB'],$res_cur);
+
+    /* Connect to old home server and remove old entries if necessary */
+    if(($this->initially_was_account) && ($this->init_HomeServer != $this->goFonHomeServer)){
+      $str = $this->remove_from_database($save); 
+      if(!empty($str)){
+        return($str);;
+      }
+    }
+
+    /* Ensure that we have the new cn in $this->cn and the old cn in $this->old_cn */
+    $this->cn = $this->parent->by_object['ogroup']->cn;
+
+    if($save){
+  
+      /*****************
+       * Create queue table entry 
+       *****************/
+      /* Check if QUEUE_TABLE entry exists.
+       * If this entry is missing - create it 
+       *  else update the entry with new values.
+       */
+      $query = "SELECT * FROM ".$cfg_Current['QUEUE_TABLE']."  WHERE name='".$this->old_cn."';";
+      $res   = mysql_query($query,$res_cur);
+      if(!$res){
+        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur));
+        return(_("Could not detect old queue entry, query failed.")."&nbsp;"._("Please have a look a the gosa logfiles."));
+      }
+      $cnt = mysql_affected_rows($res_cur);
+
+
+      /* Create queue table entry 
+       * Leave unused options empty. 
+       */
+      $queue["announce"]              = "";
+      $queue["monitor_join"]          = "";
+      $queue["monitor_format"]        = "";
+      $queue["announce_round_seconds"]= "";   
+      $queue["wrapuptime"]            = "";
+      $queue["servicelevel"]          = "";
+      $queue["eventmemberstatus"]     = "";
+      $queue["eventwhencalled"]       = "";
+      $queue["memberdelay"]           = "";
+      $queue["weight"]                = "";
+      $queue["timeoutrestart"]        = "";
+
+      $queue["queue_holdtime"]        = $this->goFonQueueAnnounce;
+      $queue["queue_lessthan"]        = $this->goFonQueueLessThan;   
+      $queue["retry"]                 = $this->goFonQueueRetry;
+      $queue["reportholdtime"]        = "1";
+      $queue["joinempty"]             = "no";
+      $queue["leavewhenempty"]        = "yes";   
+
+      $queue["context"]               = "default";
+      $queue["name"]                  = $this->cn;  
+      $queue["timeout"]               = $this->goFonTimeOut; 
+      $queue["maxlen"]                = $this->goFonMaxLen;
+      $queue["strategy" ]             = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy];
+      $queue["queue_thankyou"]        = $this->goFonQueueThankYou;   
+      $queue["queue_reporthold"]      = $this->goFonQueueReportHold; 
+      $queue["announce_frequency"]    = $this->goFonAnnounceFrequency;
+      $queue["queue_youarenext"]      = $this->goFonQueueYouAreNext;   
+      $queue["queue_thereare"]        = $this->goFonQueueThereAre;   
+      $queue["queue_callswaiting"]    = $this->goFonQueueCallsWaiting;
+      $queue["queue_minutes"]         = $this->goFonQueueMinutes;
+      $queue["queue_seconds"]         = $this->goFonQueueSeconds;   
+      $queue["announce_holdtime"]     = $this->goFonQueueAnnounceHoldtime;   
+      $queue["musiconhold"]           = $this->goFonMusiconHold;
+
+
+      /* Check if we must create a new queue entry 
+       *  or if we can update an existing entry 
+       *  $cnt contains the number of entries matching this cn
+       */
+
+      /* Create new queue table entry 
+       */
+      if($cnt == 0){
+
+        /* Parse and Add Queue */
+        $entries = "";
+        $values  = "";
+        foreach($queue as $attr=>$val){
+          if($val == "") continue;
+          $entries.= "`".$attr."`,";
+          $values .= "'".$val."',";
+        }
+        $values  = preg_replace("/,$/","",$values);
+        $entries = preg_replace("/,$/","",$entries );
+        $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_TABLE']." (".$entries.") VALUES (".$values.");";
+      }elseif($cnt == 1){
+
+        /* Update queue table entry 
+         */
+        $queue_old = @mysql_fetch_assoc($res);
+        foreach($queue_old as $name => $value){
+          if(isset($queue[$name]) && $queue[$name] == $value){
+            unset($queue[$name]);
+          }
+        }
+
+        /* Parse and Add Queue */
+        if(count($queue)){
+          $query = "UPDATE ".$cfg_Current['QUEUE_TABLE']." SET ";
+          foreach($queue as $key => $val){
+            $query.= "".$key."='".$val."',";
+          }
+          $query = preg_replace("/,$/","",$query);
+          $query.= " WHERE name='".$this->old_cn."';";
+          $SQL[] = $query;
+        }
+      }else{
+        return(sprintf(_("More than one entry in queue table found, that uses the name ('%s'). Please fix this issue manually first."),$this->cn));
+      }
+
+
+      /*****************
+       * Create queue member entries
+       *****************/
+      
+      /* Add the queue member entries 
+       * First we must remove all old user entries. 
+       * to be able to add a clean set of members.
+       */ 
+      $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->cn."';";
+      $SQL[]= "DELETE FROM ".$cfg_Current['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$this->old_cn."';";
+      
+      /* Append new Member for this queue */ 
+      $queueuser =array();
+      $i = 0;
+      $parent = $this->parent->by_object['ogroup'];
+
+      
+      $ldap = $this->config->get_ldap_link();
+      foreach($parent->memberList as $member => $mem_data){
+        $ldap->cat($member,array("goFonHomeServer","objectClass","dn","uid"));
+        if($ldap->count()){
+
+          $obj = $ldap->fetch();
+
+          /* Calculate server and account dependencies */
+          $is_acc = in_array("goFonAccount",$obj['objectClass']);
+          $is_home= isset($obj['goFonHomeServer'][0]) && $obj['goFonHomeServer'][0] == $this->goFonHomeServer; 
+
+          /* Append user to list of queue member,
+           *  only if user has phoneAccount extension && is on same home server */
+          if($is_acc && $is_home){
+            $i ++ ;
+            $queueuser[$i]['queue_name']  = $this->cn; 
+            $queueuser[$i]['interface']   = "SIP/".$obj['uid'][0]; 
+            $queueuser[$i]['penalty']     = 1; 
+          }
+        }
+      }
+
+      /* Parse and Add members to query Array */
+      if(is_array($queueuser)){
+        foreach($queueuser as $user){
+          $entries = "";
+          $values  = "";
+          foreach($user as $attr => $val){
+            $entries.= "`".$attr."`,"; 
+            $values .= "'".$val."',";
+          }
+          $values  = preg_replace("/,$/","",$values);
+          $entries = preg_replace("/,$/","",$entries );
+
+          $SQL[]="INSERT INTO ".$cfg_Current['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; 
+        }
+      }
+      
+
+      /*****************
+       * Create extension entries
+       *****************/
+      
+      /* Add the extension entries 
+       * First we must remove all old entensions. 
+       */ 
+      $SQL[]=  "DELETE FROM ".$cfg_Current['EXT_TABLE']."  WHERE exten='".$this->cn."';\n";
+      $SQL[]=  "DELETE FROM ".$cfg_Current['EXT_TABLE']."  WHERE exten='".$this->old_cn."';\n";
+
+      /* Delete old enxtension entries for the old telephone nubmer  */
+      if(is_array($this->old_phone_numbers)){
+        foreach($this->old_phone_numbers as $phone){
+          $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n";
+        }
+      }
+      
+      /* Delete enxtension entries for telephone numbers  */
+      if(is_array($this->telephoneNumber)){
+        foreach($this->telephoneNumber as $phone){
+          $SQL[]= "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE exten='".$phone."';\n";
+        }
+      }
+
+      /* Create a extension entry fpr each telephoneNumber */
+      $i_insert_only_once = false;
+      $prio = 11;   // This represents the priority for each telephoneNumber 
+      foreach($this->telephoneNumber as $num){
+
+        /* The naming refrences */
+        if($i_insert_only_once == false){
+          $i_insert_only_once = true;
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $this->cn;
+          $a_ext[$i]['priority'] = 1;
+          $a_ext[$i]['app']      = "Goto";
+          $a_ext[$i]['appdata']  = $num."|1";
+          $i ++ ; 
+        }
+
+        /* If there is currently no user for this queue 
+         * Play no service sound file and return to default context.  
+         */
+        if(count($queueuser)==0){
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 1;
+          $a_ext[$i]['app']      = "SetLanguage";
+          $a_ext[$i]['appdata']  = "de";
+          $i ++ ; 
+
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 2;
+          $a_ext[$i]['app']      = "Playback";
+          $a_ext[$i]['appdata']  = "ss-noservice";
+          $i ++ ; 
+
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 3;
+          $a_ext[$i]['app']      = "Goto";
+          $a_ext[$i]['appdata']  = "default";
+          $i ++ ; 
+        }else{
+
+          /* Dcrement priority to avoid using same priority twice */
+          $prio --;
+
+          /* Wait for 2 seconds */
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 1;
+          $a_ext[$i]['app']      = "Wait";
+          $a_ext[$i]['appdata']  = "2";
+          $i ++ ; 
+    
+          /* Set language to queue language */
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 2;
+          $a_ext[$i]['app']      = "SetLanguage";
+          $a_ext[$i]['appdata']  = $this->goFonQueueLanguage;
+          $i ++ ; 
+  
+          /* Play welcome sound file */
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 3;
+          $a_ext[$i]['app']      = "Playback";
+          $a_ext[$i]['appdata']  = $this->goFonWelcomeMusic;
+          $i ++ ; 
+
+          /* Set CID name */
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 4;
+          $a_ext[$i]['app']      = "SetCIDName";
+          if(!empty($this->parent->by_object['ogroup']->description)){
+            $a_ext[$i]['appdata']  = $this->parent->by_object['ogroup']->description;
+          }else{
+            $a_ext[$i]['appdata']  = $this->cn." - ".$num;
+          }
+          $i ++ ; 
+
+          /* Set queue priority */
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 5;
+          $a_ext[$i]['app']      = "SetVar";
+          $a_ext[$i]['appdata']  = "QUEUE_PRIO=".$prio;
+          $i ++ ; 
+
+          /* Open queue */
+          $a_ext[$i]['context']  = 'GOsa';
+          $a_ext[$i]['exten']    = $num;
+          $a_ext[$i]['priority'] = 6;
+          $a_ext[$i]['app']      = "Queue";
+          $a_ext[$i]['appdata']  =  $this->cn;
+            "|".
+            $this->goFonDialOptiont.
+            $this->goFonDialOptionT.
+            $this->goFonDialOptionh.
+            $this->goFonDialOptionH.
+            $this->goFonDialOptionr;
+        }
+
+        $i++;
+      }
+
+      /* Parse and Add Extension entries */
+      foreach($a_ext as $ext){
+        $entries = "";
+        $values  = "";
+        foreach($ext as $attr => $val){
+          $entries.= "`".$attr."`,";
+          $values .= "'".$val."',";
+        }
+        $values  = preg_replace("/,$/","",$values);
+        $entries = preg_replace("/,$/","",$entries );
+        $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$entries.") VALUES (".$values.")";
+      }
+
+      /* Do all collected mysql queries 
+       */
+      foreach($SQL as $query)
+      $res   = mysql_query($query,$res_cur);
+      if(!$res){
+        new log("debug","ogroups/".get_class($this),"",array(),@mysql_error($res_cur));
+        return(_("Mysql query failed.")."&nbsp;"._("Please have a look a the gosa logfiles."));
+      }
+    }
+    @mysql_close($r_con);
+    return(false);
+  }
+
+
+  /* This function checks if the given phonenumbers 
+   *  are available or already in use
+   */
+  function is_number_used()
+  {
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(& (!(uid=".$this->cn."))
+                        (!(cn=".$this->cn.")))
+                     (| (objectClass=goFonAccount)
+                        (objectClass=goFonQueue)
+                        (objectClass=goFonConference)))", array("telephoneNumber","cn","uid"));
+    while($attrs = $ldap->fetch()) {
+      unset($attrs['telephoneNumber']['count']);
+      foreach($attrs['telephoneNumber'] as $tele){
+        if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
+        if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
+        $numbers[$tele]=$attrs;
+      }
+    }
+
+    foreach($this->telephoneNumber as $num){
+      if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!= $this->attrs['cn'][0]))){
+        if(isset($numbers[$num]['uid'][0])){
+          return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
+        }else{
+          return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
+        }
+      }
+    }
+  }
+
+
+  /* Get posted attributes */
+  function save_object()
+  {
+    plugin::save_object();  
+    if(isset($_POST['phonenumber'])){
+      foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionh","goFonDialOptionr","goFonDialOptionH","goFonMusiconHold") as $val){
+        if(isset($_POST[$val])){
+          $this->$val = $_POST[$val];
+        }else{
+          $this->$val = false;
+        }
+      }
+      if(isset($_POST['goFonQueueAnnounceHoldtime'])){
+        $this->goFonQueueAnnounceHoldtime = "yes";
+      }else{
+        $this->goFonQueueAnnounceHoldtime = false;
+      }
+    }
+  }
+
+
+  function save()
+  {
+    $ldap= $this->config->get_ldap_link();
+
+    plugin::save();
+
+    /* Create dial option attribute */
+    $this->attrs['goFonDialOption'] = "";
+    foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){
+      $this->attrs['goFonDialOption'].=$this->$val; 
+      unset($this->attrs[$val]); 
+    }
+    if(empty($this->attrs['goFonDialOption'])) {
+      $this->attrs['goFonDialOption']=array();
+    }
+
+    /* Set announce hold time to yes no .. */
+    if($this->goFonQueueAnnounceHoldtime != "no" ){
+      $this->attrs['goFonQueueAnnounceHoldtime'] = "yes";
+    }else{
+      $this->attrs['goFonQueueAnnounceHoldtime'] = "no";
+    }
+
+    /* Set strategy */
+    $this->attrs['goFonQueueStrategy'] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy];
+
+    /* Add database entry, display error and abort if this fails */
+    $str = $this->add_to_database(true);
+    if(!empty($str)){
+      print_red($str);
+    }
+
+    /* Save data to LDAP */
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    if($this->initially_was_account){
+      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    show_ldap_error($ldap->get_error(), _("Saving phone queue failed"));
+
+    /* Optionally execute a command after we're done */
+    if ($this->initially_was_account == $this->is_account){
+      if ($this->is_modified){
+        $this->handle_post_events("modify");
+      }
+    } else {
+      $this->handle_post_events("add");
+    }
+  }
+
+
+  /* remove object from parent */
+  function remove_from_parent()
+  {
+    /* Cancel if nothing is to do here */
+    if (!$this->initially_was_account){
+      return;
+    }
+
+    /* Remove database entries, 
+     *  if fails display errors and abort
+     */
+    $str = $this->remove_from_database(true);
+    if(!empty($str)){
+      print_red($str);
+      return false;
+    }
+  
+    /* Remove all temporary attributes */
+    $tmp = array_flip($this->attributes);
+    foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){
+      unset($this->$val);
+      unset($this->attrs[$val]);
+      unset($tmp[$val]);
+    }   
+    foreach(array_flip($tmp) as $key => $val){
+      $tmp2[]=$val;
+    } 
+    $this->attributes = $tmp2;
+
+    /* include global link_info */
+    $ldap= $this->config->get_ldap_link();
+
+    /* Remove and write to LDAP */
+    plugin::remove_from_parent();
+
+    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    show_ldap_error($ldap->get_error(), _("Removing phone queue failed"));
+  }
+
+  
+  function getCopyDialog()
+  {
+    $str  = "";
+    $str .= _("Phone number");
+    $str .= "&nbsp;<input type='text' name='telephoneNumber' value='".$this->telephoneNumber."'>";
+    return($str);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['telephoneNumber'])){
+      $this->telephoneNumber = $_POST['telephoneNumber'];
+    }
+  }
+
+
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Phone"),
+          "plDescription" => _("Phone group"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 3,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("ogroups"),
+          "plProvidedAcls"=> array(
+
+            "goFonTimeOut"              => _("Timeout"),
+            "goFonMaxLen"               => _("Max queue length"),
+            "goFonHomeServer"           => _("Home server"),
+            "goFonAnnounceFrequency"    => _("Announce frequency"),
+            "goFonDialOptiont"          => _("Allow the called user to transfer his call"),
+            "goFonDialOptionT"          => _("Allows calling user to transfer call"),
+            "goFonDialOptionh"          => _("Allow the called to hangup by pressing *"),
+            "goFonDialOptionr"          => _("Ring instead of playing background music"),
+            "goFonDialOptionH"          => _("Allows calling to hangup by pressing *"),
+
+            "goFonMusiconHold"          => _("Music on hold"),
+            "goFonWelcomeMusic"         => _("Welcome music"),
+            "goFonQueueReportHold"      => _("Report hold time"),
+            "goFonQueueYouAreNext"      => _("'You are next' sound"),
+            "goFonQueueThereAre"        => _("'There are' sound"),
+            "goFonQueueCallsWaiting"    => _("'Call waiting' sound"),
+            "goFonQueueThankYou"        => _("'Thank you' sound"),
+            "goFonQueueMinutes"         => _("'Minutes' sound"),
+            "goFonQueueSeconds"         => _("'Seconds' sound"),
+            "goFonQueueLessThan"        => _("'Less than' sound"),
+            "telephoneNumber"           => _("Queue phone number"),
+            "goFonQueueLanguage"        => _("Language"),
+            "goFonQueueStrategy"        => _("Method"),
+            "goFonQueueAnnounceHoldtime"=> _("Announce holdtime"),
+            "goFonQueueAnnounce"        => _("Announce"),
+            "goFonQueueRetry"           => _("Retry"))
+              ));
+  }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/gofon/admin/ogroups/gofon/phonequeue.tpl b/gosa-plugins/gofon/admin/ogroups/gofon/phonequeue.tpl
new file mode 100644 (file)
index 0000000..643b4a3
--- /dev/null
@@ -0,0 +1,328 @@
+<p style='padding-left:7px;'>
+ <img class='center' src='images/lamp.png' alt='!'>&nbsp;<b>{t}Only users with the same asterisk home server will be included to this queue.{/t}</b>
+</p>
+
+<table summary="{t}Queue Settings{/t}" style="width: 100%; vertical-align: top; text-align: left;" border="0" cellpadding="4">
+<tr>
+<td valign='top'>
+               <h2><img class="center" alt="" src="images/select_phone.png" align="middle">&nbsp;{t}Phone numbers{/t}</h2>
+               <table summary="">
+               <tr>
+               <td colspan=2>
+                 <table summary="{t}Generic queue Settings{/t}">
+                  <tr>
+                   <td>
+{render acl=$telephoneNumberACL}
+                       <select style="width:300px; height:60px;" name="goFonQueueNumber_List" size=6>
+                       {html_options options=$telephoneNumber}
+                       <option disabled>&nbsp;</option>
+                       </select>
+{/render}
+               </td>
+               <td style="vertical-align:center">
+{render acl=$telephoneNumberACL}
+                       <input type="submit" value="{t}Up{/t}"          name="up_phonenumber"><br>
+{/render}
+{render acl=$telephoneNumberACL}
+                       <input type="submit" value="{t}Down{/t}"        name="down_phonenumber">
+{/render}
+               </td>
+               </tr>
+               <tr>
+                <td colspan=2>
+{render acl=$telephoneNumberACL}
+                       <input name="phonenumber" size=20 align=middle maxlength=60 value="">
+{/render}
+{render acl=$telephoneNumberACL}
+                       <input type="submit" value="{t}Add{/t}"         name="add_phonenumber" >&nbsp;
+{/render}
+{render acl=$telephoneNumberACL}
+                       <input type="submit" value="{t}Delete{/t}"      name="delete_phonenumber" >
+{/render}
+            </td>
+               </tr>
+               </table>
+               </tr>
+               <tr>
+                 <td colspan=2><h2><img class="center" alt="" src="images/select_ogroup.png" align="middle">&nbsp;{t}Options{/t}</h2></td>
+               </tr>
+                <tr>
+                <td><LABEL for="goFonHomeServer">{t}Home server{/t}</LABEL>{$must}</td>
+                <td>
+{render acl=$goFonHomeServerACL}
+                        <select name='goFonHomeServer'>
+                         {html_options options=$goFonHomeServers selected=$goFonHomeServer}
+                        </select>
+{/render}
+                </td>
+                </tr>
+
+               <tr>
+               <td>
+                       {t}Language{/t} 
+               </td>
+               <td>
+{render acl=$goFonQueueLanguageACL}
+                       <select name="goFonQueueLanguage">
+                       {html_options options=$goFonQueueLanguageOptions selected=$goFonQueueLanguage}
+                       <option disabled>&nbsp;</option>
+                       </select>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Timeout{/t}
+               </td>
+               <td>
+{render acl=$goFonTimeOutACL}
+                       <input name='goFonTimeOut' value='{$goFonTimeOut}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Retry{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueRetryACL}
+                       <input name='goFonQueueRetry' value='{$goFonQueueRetry}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Strategy{/t} 
+               </td>
+               <td>
+{render acl=$goFonQueueStrategyACL}
+                       <select name="goFonQueueStrategy">
+            {html_options options=$goFonQueueStrategyOptions selected=$goFonQueueStrategy}
+            <option disabled>&nbsp;</option>
+            </select>
+{/render}
+       
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Max queue length{/t}
+               </td>
+               <td>
+{render acl=$goFonMaxLenACL}
+                       <input name='goFonMaxLen' value='{$goFonMaxLen}'>       
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Announce frequency{/t}
+               </td>
+               <td>
+{render acl=$goFonAnnounceFrequencyACL}
+                       <input name='goFonAnnounceFrequency' value='{$goFonAnnounceFrequency}'>
+{/render}
+                       {t}(in seconds){/t}     
+               </td>
+               </tr>
+               </table>
+</td>
+<td valign='top' style="border-left: 1px solid rgb(160, 160, 160);">
+       <h2>
+    <img class="center" alt="" src="images/sound.png" align="middle">
+    {t}Queue sound setup{/t}
+    </h2>
+       <table summary="{t}Generic queue Settings{/t}">
+               <!--<tr>
+               <td>
+                       {t}Use music on hold instead of ringing{/t}
+               </td>
+               <td>
+{render acl=goFonMusiconHoldACL}
+                       <input type="checkbox" name='goFonMusiconHold' value='1' {$goFonMusiconHoldCHK}>
+{/render}
+               </td>
+               </tr>
+               -->
+               <tr>
+               <td>
+                       {t}Music on hold{/t}
+               </td>
+               <td>
+{render acl=$goFonMusiconHoldACL}
+                       <input type="text" style='width:250px;' name='goFonMusiconHold' value='{$goFonMusiconHold}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Welcome sound file{/t}
+               </td>
+               <td>
+{render acl=$goFonWelcomeMusicACL}
+                       <input type="text" style='width:250px;' name='goFonWelcomeMusic' value='{$goFonWelcomeMusic}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Announce message{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueAnnounceACL}
+                       <input type="text" style='width:250px;' name='goFonQueueAnnounce' value='{$goFonQueueAnnounce}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Sound file for 'You are next ...'{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueYouAreNextACL}
+                       <input type="text" style='width:250px;' name='goFonQueueYouAreNext' value='{$goFonQueueYouAreNext}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}'There are ...'{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueThereAreACL}
+                       <input type="text" style='width:250px;' name='goFonQueueThereAre' value='{$goFonQueueThereAre}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}'... calls waiting'{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueCallsWaitingACL}
+                       <input type="text" style='width:250px;' name='goFonQueueCallsWaiting' value='{$goFonQueueCallsWaiting}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}'Thank you' message{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueThankYouACL}
+                       <input type="text" style='width:250px;' name='goFonQueueThankYou' value='{$goFonQueueThankYou}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}'minutes' sound file{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueMinutesACL}
+                       <input type="text" style='width:250px;' name='goFonQueueMinutes' value='{$goFonQueueMinutes}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}'seconds' sound file{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueSecondsACL}
+                       <input type="text" style='width:250px;' name='goFonQueueSeconds' value='{$goFonQueueSeconds}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Hold sound file{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueReportHoldACL}
+                       <input type="text" style='width:250px;' name='goFonQueueReportHold' value='{$goFonQueueReportHold}'>
+{/render}
+               </td>
+               </tr>
+               <tr>
+               <td>
+                       {t}Less Than sound file{/t}
+               </td>
+               <td>
+{render acl=$goFonQueueLessThanACL}
+                       <input type="text" style='width:250px;' name='goFonQueueLessThan' value='{$goFonQueueLessThan}'>
+{/render}
+               </td>
+               </tr>
+
+               </table>
+</td>
+</tr>
+<tr>
+       <td colspan=2>
+               <p class="seperator">
+       </td>
+</tr>
+<tr>
+<td colspan=2><h2 style='margin-bottom:0px;'><img class="center" alt="" src="images/select_ogroup.png" align="middle">&nbsp;{t}Phone attributes {/t}</h2></td>
+</tr>
+<tr>
+<td>
+               <table summary="" style="width: 100%; vertical-align: top; text-align: left;" border="0" cellpadding="0">
+        <tr>
+        <td colspan=2>
+{render acl=$goFonQueueAnnounceHoldtimeACL}
+            <input type="checkbox" name='goFonQueueAnnounceHoldtime' value='yes'  {$goFonQueueAnnounceHoldtimeCHK}>
+{/render}
+            {t}Announce holdtime{/t}
+        </td>
+        </tr>
+        <tr>
+        <td colspan=2>
+{render acl=$goFonDialOptiontACL}
+            <input type="checkbox" name='goFonDialOptiont' value='t'  {$goFonDialOptiontCHK}>
+{/render}
+            {t}Allow the called user to transfer his call{/t}
+        </td>
+        </tr>
+        <tr>
+        <td colspan=2>
+{render acl=$goFonDialOptionTACL}
+            <input type="checkbox" name='goFonDialOptionT' value='T' {$goFonDialOptionTCHK}>
+{/render}
+            {t}Allows calling user to transfer call{/t}
+        </td>
+        </table>
+
+</td>
+<td valign='top' style="border-left: 1px solid rgb(160, 160, 160);">
+               <table summary=""  style="width: 100%; vertical-align: top; text-align: left;" border="0" cellpadding="0">
+        <tr>
+        <td colspan=2>
+{render acl=$goFonDialOptionhACL}
+            <input type="checkbox" name='goFonDialOptionh' value='h' {$goFonDialOptionhCHK}>
+{/render}
+            {t}Allow the called to hangup by pressing *{/t}
+        </td>
+        </tr>
+        <tr>
+        <td colspan=2>
+{render acl=$goFonDialOptionHACL}
+            <input type="checkbox" name='goFonDialOptionH' value='H' {$goFonDialOptionHCHK}>
+{/render}
+            {t}Allows calling to hangup by pressing *{/t}
+        </td>
+        </tr>
+        <tr>
+        <td colspan=2>
+{render acl=$goFonDialOptionrACL}
+            <input type="checkbox" name='goFonDialOptionr' value='r' {$goFonDialOptionrCHK}>
+{/render}
+            {t}Ring instead of playing background music{/t}
+        </td>
+        </tr>
+        </table>
+</td>
+</tr>
+
+</table>
diff --git a/gosa-plugins/goto/admin/ogroups/goto/class_termgroup.inc b/gosa-plugins/goto/admin/ogroups/goto/class_termgroup.inc
new file mode 100644 (file)
index 0000000..f819349
--- /dev/null
@@ -0,0 +1,432 @@
+<?php
+
+class termgroup extends plugin
+{
+  /* attribute list for save action */
+  var $members= array();
+
+  var $gotoMode           = "locked";
+  var $gotoSyslogServer   = "";
+  var $gotoNtpServer      = array();
+  var $gotoNtpServers     = array();
+  var $modes              = array();
+  var $inheritTimeServer  = true;
+  var $is_account                    = true; 
+  var $orig_dn            = "";
+  var $didAction          = FALSE;
+  var $mapActions   = array("reboot"          => "localboot",
+                            "instant_update"  => "softupdate",
+                            "update"          => "sceduledupdate",
+                            "reinstall"       => "install",
+                            "rescan"          => "",
+                            "memcheck"        => "memcheck",
+                            "sysinfo"         => "sysinfo");
+
+  var $attributes     = array("gotoMode","gotoSyslogServer", "gotoNtpServer");
+  var $objectclasses  = array("gotoWorkstationTemplate");
+  var $CopyPasteVars  = array("gotoNtpServers","modes","inheritTimeServer","members");
+  var $view_logged    = FALSE;
+
+
+  function termgroup (&$config, $dn= NULL, $parent= NULL)
+  {
+    /***************
+      Some  initialisations
+     ***************/
+
+    plugin::plugin($config, $dn, $parent);
+
+    $ldap= $config->get_ldap_link();
+
+    $this->is_account = true;
+    $this->modes["active"]= _("Activated");
+    $this->modes["locked"]= _("Locked");
+//    $this->modes["memcheck"]= _("Memory test");
+//    $this->modes["sysinfo"]= _("System analysis");
+
+    $this->orig_dn =   $this->dn;
+
+    /*************** 
+      Get mac addresses from member objects  
+     ***************/
+
+    /* We're only interested in the terminal members here, evaluate
+       these... */
+    if(isset($this->attrs['member'])){
+      for ($i= 0; $i<$this->attrs['member']['count']; $i++){
+        $member= $this->attrs['member'][$i];
+        $ldap->cat($member, array('objectClass', 'macAddress', 'cn'));
+        if (preg_match("/success/i", $ldap->error)){
+          $attrs = $ldap->fetch();
+          if (in_array("gotoTerminal", $attrs['objectClass']) ||
+              in_array("gotoWorkstation", $attrs['objectClass'])){
+            if (isset($attrs['macAddress'])){
+              $this->members[$attrs['cn'][0]]= $attrs['macAddress'][0];
+            } else {
+              $this->members[$attrs['cn'][0]]= "";
+            }
+          }
+        }
+      }
+    }
+
+    /*************** 
+      Perpare NTP settings 
+     ***************/
+
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+    if(isset($this->attrs['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($this->attrs['gotoNtpServer']['count']);
+      foreach($this->attrs['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if(in_array("default",$this->gotoNtpServer)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+
+    /* Create available ntp options */
+    $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
+    foreach($this->gotoNtpServers as $key => $server){
+      if($server == "default"){
+        unset($this->gotoNtpServers[$key]);
+      }
+    }
+  }
+
+  function check()
+  {
+     /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    if (!$this->acl_is_createable() && $this->dn == "new"){
+      $message[]= _("You have no permissions to create a workstation on this 'Base'.");
+    }
+
+    /* Check for valid ntpServer selection */
+    if((!$this->inheritTimeServer) && (!count($this->gotoNtpServer))){
+      $message[]= _("There must be at least one NTP server selected.");
+    }
+    return($message);
+  }
+
+  function remove_from_parent()
+  {
+    /* Workstation startup is using gotoWorkstationTemplate too,
+        if we remove this oc all other not manged attributes will cause errors */
+    if(isset($this->attrs['gotoKernelParameters'])){
+      $this->objectclasses = array();
+    }
+
+    /* Remove acc */
+    plugin::remove_from_parent();
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->orig_dn);
+    $ldap->modify($this->attrs);
+    $this->handle_post_events("remove");
+    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+  }
+
+
+  function update_term_member_FAIstate($act)
+  {
+    /* Get required informations */
+    $og     = $this->parent->by_object['ogroup'];
+    $allobs = $og->objcache;
+
+    /* Get correct value for FAIstate */
+    $action = $this->mapActions[$act];
+
+    /* Get ldap connection */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd ($this->config->current['BASE']);
+
+    /* Foreach member of mthis ogroup  ... */
+    foreach($og->member  as $key ){
+  
+      /* check objectClasses and create attributes array */
+      $attrs = array("FAIstate"=>$action);  
+      for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){
+        $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i];
+      }
+      if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+        $attrs['objectClass'][] = "FAIobject";
+      }
+      if($attrs['FAIstate'] == ""){
+        $attrs['FAIstate'] = array();
+      }
+
+      /* If this objects is workstation,terminal or server upodate FAIstate */ 
+      if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){
+        $ldap->cd ($key);
+        $ldap->modify($attrs);
+        show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action));
+      }
+    }
+  }
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if(!$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","ogroups/".get_class($this),$this->dn);
+    }
+
+    /*************** 
+      Handle requested action
+     ***************/
+
+    /* Watch for events */
+    if (isset($_POST['action'])){
+      $macaddresses="";
+      $names="";
+      foreach ($this->members as $cn => $macAddress){
+        $macaddresses.= "$macAddress ";
+        $names.= "$cn ";
+      }
+
+      if (isset($_POST['action'])){
+  
+        /* Update members fai state */
+        $this->update_term_member_FAIstate(trim($_POST['saction']));
+
+        $cmd = $this->config->search("workgeneric", "ACTIONCMD",array('tabs'));
+
+        if ($cmd == ""){
+          print_red(_("No ACTIONCMD definition found in your gosa.conf"));
+        } else {
+          exec ($cmd." ".$macaddresses." ".escapeshellarg($_POST['saction']), $dummy, $retval);
+          if ($retval != 0){
+            print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+          } else {
+            $this->didAction= TRUE;
+
+            /* Get dns from member objects. Create ldap object  */
+            $member = $this->parent->by_object['ogroup']->member;
+            $ldap = $this->config->get_ldap_link();
+            $ldap->cd($this->config->current['BASE']);
+
+            /* walk trough members and add FAIstate */ 
+            foreach($member as $dn =>  $object){
+
+              /* Get object */
+              $ldap->cat($dn,array("objectClass"));
+              $res                = $ldap->fetch();
+              $attrs              = array();
+
+              /* Add FAI state */
+              $attrs['FAIstate']  = "";
+              if(isset($this->mapActions[$_POST['saction']])){
+                $attrs['FAIstate'] = $this->mapActions[$_POST ['saction']];
+              }
+
+              /* Fix objectClass index */
+              for($i = 0; $i < $res['objectClass']['count'] ; $i ++){
+                $attrs['objectClass'][] = $res['objectClass'][$i];
+              }
+
+              /* Check if we must add the objectClass */
+              if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+                $attrs['objectClass'][] = "FAIobject";
+              }
+
+              if($attrs['FAIstate'] == ""){
+                $attrs['FAIstate'] = array();
+              }
+
+              $ldap->cd($dn);
+              $ldap->modify($attrs);
+              show_ldap_error($ldap->get_error(), sprintf(_("Saving of system workstation/generic (FAIstate) with dn '%s' failed."),$dn));
+            }
+            $this->didAction= TRUE;
+          }
+        }
+      }
+    }
+
+
+    /*************** 
+      Add remove NTP server
+     ***************/
+
+    /* Add new ntp Server to our list */
+    if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){
+      $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
+    }
+
+    /* Delete selected NtpServer for list of used servers  */
+    if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){
+      foreach($_POST['gotoNtpServerSelected'] as $name){
+        unset($this->gotoNtpServer[$name]);
+      }
+    }
+
+
+    /*************** 
+      Prepare smarty 
+     ***************/
+
+    /* Set government mode */
+    $smarty= get_smarty();
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translated) {
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr,      $this->$attr);
+    }
+
+    /* Variables */
+    foreach(array("gotoMode","gotoNtpServer") as $val){
+      $smarty->assign($val."_select", $this->$val);
+    }
+
+    $smarty->assign("actions", array("halt" => _("Switch off"), "reboot" => _("Reboot"),
+          "instant_update" => _("Instant update"),
+          "update" => _("Scheduled update"),
+          "reinstall" => _("Reinstall"),
+          "rescan" => _("Rescan hardware"),
+          "memcheck" => _("Memory test"),
+          "sysinfo"  => _("System analysis")));
+
+    $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
+    $smarty->assign("modes", $this->modes);
+
+    $tmp = array();
+    foreach($this->gotoNtpServers as $server){
+      if(!in_array($server,$this->gotoNtpServer)){
+        $tmp[$server] = $server;
+      }
+    }
+
+    $smarty->assign("gotoNtpServers",$tmp); 
+    $smarty->assign("syslogservers", $this->config->data['SERVERS']['SYSLOG']); 
+    $smarty->assign("gotoSyslogServer_select", $this->gotoSyslogServer); 
+
+    /* Show main page */
+    return ($smarty->fetch (get_template_path('termgroup.tpl', TRUE, dirname(__FILE__))));
+  }
+
+  function save_object()
+  {
+    plugin::save_object();  
+    /* Set inherit mode */
+    if(isset($_POST['workgeneric_posted'])){
+      if(isset($_POST["inheritTimeServer"])){
+        $this->inheritTimeServer = true;
+      }else{
+        $this->inheritTimeServer = false;
+      }
+    }
+  }
+
+  /* Save to LDAP */
+  function save()
+  {
+    plugin::save();
+
+    /***************
+      Prepare special vars 
+     ***************/
+
+    /* Unset some special vars ... */
+    foreach (array("gotoSyslogServer") as $val){
+      if ($this->attrs[$val] == "default"){
+        $this->attrs[$val]= array();
+      }
+    }
+
+    /* Update ntp server settings */
+    if($this->inheritTimeServer){
+      $this->attrs['gotoNtpServer'] = "default";
+    }else{
+      /* Set ntpServers */
+      $this->attrs['gotoNtpServer'] = array();
+      foreach($this->gotoNtpServer as $server){
+        $this->attrs['gotoNtpServer'][] = $server;
+      }
+    }
+
+
+    /***************
+      Write to ldap 
+     ***************/
+
+    /* Write back to ldap */
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs);
+
+    if($this->initially_was_account){
+      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    if(!$this->didAction){
+      $this->handle_post_events("modify");
+    }
+    show_ldap_error($ldap->get_error(), _("Saving workstation failed"));
+
+  }
+  
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("System"),
+          "plDescription" => _("System group"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 5,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("ogroups"),
+          "plProvidedAcls"=> array(
+            "gotoMode"          => _("Mode"),     
+            "gotoSyslogServer"  => _("Syslog server"), 
+            "FAIstate"          => _("Action flag"), 
+            "gotoNtpServer"     => _("Ntp server"))
+          ));
+  }
+
+  function PrepareForCopyPaste($source)
+  {
+    /* Create used ntp server array */
+    $this->gotoNtpServer= array();
+
+    if(isset($source['gotoNtpServer'])){
+      $this->inheritTimeServer = false;
+      unset($source['gotoNtpServer']['count']);
+      foreach($source['gotoNtpServer'] as $server){
+        $this->gotoNtpServer[$server] = $server;
+      }
+    }
+
+    /* Set inherit checkbox state */
+    if(in_array("default",$this->gotoNtpServer)){
+      $this->inheritTimeServer = true;
+      $this->gotoNtpServer=array();
+    }
+
+    /* Create available ntp options */
+    $this->gotoNtpServers = $this->config->data['SERVERS']['NTP'];
+    foreach($this->gotoNtpServers as $key => $server){
+      if($server == "default"){
+        unset($this->gotoNtpServers[$key]);
+      }
+    }
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/admin/ogroups/goto/termgroup.tpl b/gosa-plugins/goto/admin/ogroups/goto/termgroup.tpl
new file mode 100644 (file)
index 0000000..b35458c
--- /dev/null
@@ -0,0 +1,110 @@
+<br>
+<b>{t}Warning{/t}:</b> {t}Actions you choose here influence all systems in this object group. Additionally, all values editable here can be inherited by the clients assigned to this object group.{/t}
+<br>
+<br>
+<p class="plugbottom" style="margin-bottom:0px; padding:0px;">&nbsp;</p>
+<h2><img class="center" alt="" align="middle" src="images/select_terminal.png"> {t}Generic{/t}</h2>
+
+<table width="100%">
+       <tr>
+               <td style='width:50%;'>
+               <!-- Upper left -->
+                          <table width="100%">
+                               <tr>
+                                <td colspan="2" style='padding-top:5px;'><LABEL for="gotoNtpServerSelected">{t}NTP server{/t}</LABEL><br>
+{render acl=$gotoNtpServerACL}
+                                 <select name="gotoNtpServerSelected[]" id="gotoNtpServerSelected" multiple size=5 style="width:100%;"
+                                               title="{t}Choose server to use for synchronizing time{/t}" {if $inheritTimeServer} disabled {/if}>
+                                  {html_options options=$gotoNtpServer_select}
+                                 </select>
+{/render}
+                                <br>
+{render acl=$gotoNtpServerACL}
+                                 <select name="gotoNtpServers" id="gotoNtpServers" {if $inheritTimeServer} disabled {/if} >
+                                  {html_options output=$gotoNtpServers values=$gotoNtpServers}
+                                 </select>
+{/render}
+{render acl=$gotoNtpServerACL}
+                                       <input type="submit" name="addNtpServer" value="{t}Add{/t}"     id="addNtpServer"
+                                        {if ($inheritTimeServer) || (!$gotoNtpServers)} disabled {/if}>
+{/render}
+
+{render acl=$gotoNtpServerACL}
+                                       <input type="submit" name="delNtpServer" value="{t}Delete{/t}"  id="delNtpServer"
+                                        {if ($inheritTimeServer) || (!$gotoNtpServer_select)} disabled {/if} >
+{/render}
+                                </td>
+                               </tr>
+                          </table>
+
+
+               </td>
+               <td style="vertical-align:top;border-left:1px solid #A0A0A0;">
+               <!-- Upper right -->
+                               
+                       <table summary="">
+                               <tr>
+                                <td>{t}Mode{/t}</td>
+                                <td>
+{render acl=$gotoModeACL}
+                                 <select name="gotoMode" title="{t}Select terminal mode{/t}">
+                                  {html_options options=$modes selected=$gotoMode_select}
+                                 </select>
+{/render}
+                                </td>
+                               </tr>
+                               <tr><td colspan="2">&nbsp;</td></tr>
+                               <tr>
+                                <td><LABEL for="gotoSyslogServer">{t}Syslog server{/t}</LABEL></td>
+                                <td>
+{render acl=$gotoSyslogServerACL}
+                                 <select id="gotoSyslogServer" name="gotoSyslogServer" title="{t}Choose server to use for logging{/t}">
+                                  {html_options values=$syslogservers output=$syslogservers selected=$gotoSyslogServer_select}
+                                 </select>
+{/render}
+                                </td>
+                               </tr>
+                               </table>
+               </td>
+       </tr>
+       <tr>
+               <td colspan=2>
+                       <p class="seperator">&nbsp;</p>
+               </td>
+       </tr>
+       <tr>
+               <td>
+               <!-- Bottom left -->                    
+
+               </td>
+               <td style="vertical-align:top;border-left:1px solid #A0A0A0;">
+               <!-- Bottom right -->                   
+               </td>
+       </tr>
+</table>
+<input name="workgeneric_posted" value="1" type="hidden">
+
+
+<h2><img class="center" alt="" align="middle" src="images/rocket.png"> {t}Action{/t}</h2>
+                               <table summary="">
+                                <tr>
+                                 <td>
+{render acl=$FAIstateACL}
+                                  <select size="1" name="saction" {$FAIstateACL} title="{t}Select action to execute for this terminal{/t}">
+                                       <option>&nbsp;</option>
+                                       {html_options options=$actions}
+                                  </select>
+{/render}
+                                 </td>
+                                 <td>
+{render acl=$FAIstateACL}
+                                  <input type=submit name="action" value="{t}Execute{/t}">
+{/render}
+                                 </td>
+                                </tr>
+                               </table>
+       
+
+
+
+
diff --git a/gosa-plugins/mail/admin/ogroups/mail/class_mailogroup.inc b/gosa-plugins/mail/admin/ogroups/mail/class_mailogroup.inc
new file mode 100644 (file)
index 0000000..85aadf3
--- /dev/null
@@ -0,0 +1,199 @@
+<?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();
+  var $view_logged = FALSE;
+
+  function mailogroup (&$config, $dn= NULL, $parent= NULL)
+  {
+    plugin::plugin($config, $dn, $parent);
+
+    /* Include config object */
+    $this->config= $config;
+
+    /* Save initial account state */
+    $this->initially_was_account= $this->is_account;
+  }
+
+
+  function execute()
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","ogroups/".get_class($this),$this->dn);
+    }
+
+
+    /* Do we need to flip is_account state? */
+    if(isset($_POST['modify_state'])){
+      if($this->is_account && $this->acl_is_removeable()){
+        $this->is_account= FALSE;
+      }elseif(!$this->is_account && $this->acl_is_createable()){
+        $this->is_account= TRUE;
+      }
+    }
+
+    /* Show tab dialog headers */
+    if ($this->parent !== NULL){
+      if ($this->is_account){
+        $display= $this->show_disable_header(_("Remove mail account"),
+            _("This group has mail features enabled. You can disable them by clicking below."));
+      } else {
+        $display= $this->show_enable_header(_("Create mail account"), _("This group has mail features disabled. You can enable them by clicking below."));
+        return ($display);
+      }
+    }
+    
+    /* Initialize templating engine */
+    $smarty= get_smarty();
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl("mail"));
+    }
+
+    /* Assign mail attribute */
+    $smarty->assign("mail", $this->mail);
+
+    /* Show main page */
+    return ($display.$smarty->fetch (get_template_path('mail.tpl', TRUE,dirname(__FILE__))));
+  }
+
+
+  /* Check formular input */
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    if ($this->is_account){
+      $ldap= $this->config->get_ldap_link();
+
+      /* Check if mail address is valid */
+      if (!tests::is_email($this->mail) || $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);
+  }
+
+
+  function save()
+  {
+    $ldap= $this->config->get_ldap_link();
+
+    /* Call parents save to prepare $this->attrs */
+    plugin::save();
+
+    /* Save data to LDAP */
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    if($this->initially_was_account){
+      new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/mail with dn '%s' failed."),$this->dn));
+
+    /* Optionally execute a command after we're done */
+    if ($this->initially_was_account == $this->is_account){
+      if ($this->is_modified){
+        $this->handle_post_events("modify");
+      }
+    } else {
+      $this->handle_post_events("add");
+    }
+  }
+
+
+  /* remove object from parent */
+  function remove_from_parent()
+  {
+    /* Cancel if there's nothing to do here */
+    if (!$this->initially_was_account){
+      return;
+    }
+
+    /* include global link_info */
+    $ldap= $this->config->get_ldap_link();
+
+    /* Remove and write to LDAP */
+    plugin::remove_from_parent();
+
+    @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
+        $this->attributes, "Save");
+    $ldap->cd($this->dn);
+    $this->cleanup();
+    $ldap->modify ($this->attrs); 
+
+    new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/mail with dn '%s' failed."),$this->dn));
+  }
+
+
+  function getCopyDialog()
+  {
+    $str = "";
+    $smarty = get_smarty();
+    $smarty->assign("mail",     $this->mail);
+    $str = $smarty->fetch(get_template_path("paste_mail.tpl",TRUE,dirname(__FILE__)));
+    $ret = array();
+    $ret['string'] = $str;
+    $ret['status'] = "";
+    return($ret);
+  }
+
+
+  function saveCopyDialog()
+  {
+    if(isset($_POST['mail'])){
+      $this->mail = $_POST['mail'];
+    }
+  }
+
+
+   static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Mail"),
+          "plDescription" => _("Mail group"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 4,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("ogroups"),
+          "plProvidedAcls"=> array(
+            "mail" => _("Mail address"))
+          ));
+  }
+
+
+
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/mail/admin/ogroups/mail/mail.tpl b/gosa-plugins/mail/admin/ogroups/mail/mail.tpl
new file mode 100644 (file)
index 0000000..a28d0ac
--- /dev/null
@@ -0,0 +1,27 @@
+<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 class="center" alt="" align="middle" src="images/rightarrow.png"> {t}Mail distribution list{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="mail">{t}Primary address{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$mailACL}
+       <input id="mail" name="mail" size=50 maxlength=65 value="{$mail}" title="{t}Primary mail address for this distribution list{/t}">
+{/render}
+     </td>
+    </tr>
+   </table>
+  </td>
+ </tr>
+</table>
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+  <!-- // First input field on page
+       focus_field('mail');
+  -->
+</script>
diff --git a/gosa-plugins/mail/admin/ogroups/mail/paste_mail.tpl b/gosa-plugins/mail/admin/ogroups/mail/paste_mail.tpl
new file mode 100644 (file)
index 0000000..737d707
--- /dev/null
@@ -0,0 +1,14 @@
+<table width='100%'>
+        <tr>
+                <td width='120'>
+                       <LABEL for="mail">{t}Mail{/t}</LABEL>{$must}
+               </td>
+               <td>
+                       <input type='text' id='main' name='mail' value='{$mail}' size='40' title='{t}Please enter a mail address{/t}'> 
+               </td>
+       </tr>
+</table>
+
+<script language="JavaScript" type="text/javascript">
+       focus_field('mail');
+</script>