X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fogroups%2Fclass_phonequeue.inc;h=0b3ec303e9e235a4f5fbdcedfd276ba11ebea2db;hb=2738e56e22f23c43e980dea2d34a3c21baa645e9;hp=9cefb8574b3283e19ce12fcb5ffbb70706ebe028;hpb=e6b50b96a4b383a85b2114dcc54372e656b64b0d;p=gosa.git diff --git a/plugins/admin/ogroups/class_phonequeue.inc b/plugins/admin/ogroups/class_phonequeue.inc index 9cefb8574..0b3ec303e 100644 --- a/plugins/admin/ogroups/class_phonequeue.inc +++ b/plugins/admin/ogroups/class_phonequeue.inc @@ -10,12 +10,12 @@ class phonequeue extends plugin var $goFonTimeOut ="20"; var $goFonMaxLen ="20"; // var $goFonAnnounceFrequency ="60"; // Annouce Frequency in seconds - var $goFonDialOption_t =""; - var $goFonDialOption_T =""; - var $goFonDialOption_h =""; - var $goFonDialOption_r =""; + var $goFonDialOptiont =""; + var $goFonDialOptionT =""; + var $goFonDialOptionh =""; + var $goFonDialOptionr =""; var $goFonQueueAnnounce ="gonicus-berlin-welcome"; - var $goFonDialOption_H =""; + var $goFonDialOptionH =""; var $goFonMusiconHold ="default"; var $goFonWelcomeMusic ="gonicus-berlin-welcome"; var $goFonQueueReportHold ="yes"; @@ -41,9 +41,9 @@ class phonequeue extends plugin var $old_phone_numbers =array(); /* attribute list for save action */ - var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOption_t","goFonDialOption_T", - "goFonDialOption_h","goFonDialOption_r","cn", - "goFonDialOption_H","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext", + var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOptiont","goFonDialOptionT", + "goFonDialOptionh","goFonDialOptionr","cn", + "goFonDialOptionH","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext", "goFonQueueThereAre","goFonQueueCallsWaiting","goFonQueueThankYou","goFonQueueMinutes","goFonQueueSeconds","goFonQueueLessThan", "telephoneNumber","goFonQueueLanguage","goFonQueueStrategy","goFonQueueAnnounceHoldtime","goFonQueueAnnounce","goFonDialOption","goFonQueueRetry"); /* ObjectClass */ @@ -66,7 +66,7 @@ class phonequeue extends plugin } for($i = 0; $i < strlen($this->goFonDialOption); $i++){ - $name = "goFonDialOption_".$this->goFonDialOption[$i]; + $name = "goFonDialOption".$this->goFonDialOption[$i]; $this->$name=$this->goFonDialOption[$i]; } } @@ -99,34 +99,44 @@ class phonequeue extends plugin function execute() { + /* Call parent execute */ + plugin::execute(); + /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])){ - $this->is_account= !$this->is_account; + 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; + } } - unset($_SESSION['config']->data['SERVERS']['FON']); - /* Show tab dialog headers */ if ($this->parent != NULL){ if ($this->is_account){ - $display= $this->show_header(_("Remove the phone queue from this 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_header(_("Create phone queue"), _("For this group the phone queues are disabled. You can enable them by clicking below.")); + $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); } } /* 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']; + if($this->acl_is_writeable("telephoneNumber")){ + 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']]); + if($this->acl_is_writeable("telephoneNumber")){ + if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){ + unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]); + } } $tmp = array(); @@ -138,28 +148,36 @@ class phonequeue extends plugin $this->telephoneNumber=$tmp; /* 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; + if($this->acl_is_writeable("telephoneNumber")){ + 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; + /* 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; + } } } $smarty= get_smarty(); - $smarty->assign("goFonQueueLanguageOptions",array('de'=>_('German'),'ur'=>_('Uruguai'))); + /* Set acls */ + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + $smarty->assign("goFonQueueLanguageOptions",array('de'=>_('German'))); $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions); foreach($this->attributes as $key => $val){ @@ -170,12 +188,6 @@ class phonequeue extends plugin }else{ $smarty->assign($val."CHK"," checked "); } - - if(chkacl($this->acl,$key)==""){ - $smarty->assign($val."ACL",""); - }else{ - $smarty->assign($val."ACL"," disabled "); - } } return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE))); } @@ -184,9 +196,8 @@ class phonequeue extends plugin /* Check formular input */ function check() { - $message= array(); - #fixme workaround : Tab is not initialised correct - if(!$this->is_account) return($message); + /* Call common method to give check the hook */ + $message= plugin::check(); if($this->is_number_used()){ $message[] = $this->is_number_used(); @@ -223,8 +234,7 @@ class phonequeue extends plugin $SQL = array(); if(!isset($_SESSION['config']->data['SERVERS']['FON'])){ - return(_("There is currently no asterisk server defined. Possibly you are missing a server that handles the asterisk management (goFonServer). \n Your Settings can't be saved to asterisk Database. ")); - return(false); + return(_("There is currently no asterisk server defined. Your settings can't be saved.")); } // Get Configuration for Mysql database Server @@ -237,7 +247,7 @@ class phonequeue extends plugin // Check if we are connected correctly if(!$r_con){ gosa_log(mysql_error()); - return (sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), + return (sprintf(_("The MySQL server '%s' isn't reachable as user '%s', check GOsa log for mysql error."), $a_SETUP['SERVER'],$a_SETUP['LOGIN'])); } @@ -288,11 +298,13 @@ class phonequeue extends plugin $i = 0; $queueuser =array(); foreach($this->parent->by_object['ogroup']->memberList as $member){ - if(in_array("goFonAccount",$member['objectClass'])){ - $i ++ ; - $queueuser[$i]['queue_name'] = $this->attrs['cn'][0]; - $queueuser[$i]['interface'] = "SIP/".$member['uid'][0]; - $queueuser[$i]['penalty'] = 1; + if(isset($member['objectClass'])){ + if(in_array("goFonAccount",$member['objectClass'])){ + $i ++ ; + $queueuser[$i]['queue_name'] = $this->attrs['cn'][0]; + $queueuser[$i]['interface'] = "SIP/".$member['uid'][0]; + $queueuser[$i]['penalty'] = 1; + } } } @@ -316,13 +328,18 @@ class phonequeue extends plugin $queueusers=0; foreach($this->parent->by_object['ogroup']->memberList as $member){ - if(in_array("goFonAccount",$member['objectClass'])){ - $queueusers++; + if(isset($member['objectClass'])){ + if(in_array("goFonAccount",$member['objectClass'])){ + $queueusers++; + } } } $i = 0; + + $i_insert_only_once = false; + foreach($this->telephoneNumber as $num){ // If there are no member in a Queue @@ -330,12 +347,15 @@ class phonequeue extends plugin // A Queue is not deleted directly, it is stored until the o group is deleted - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $this->attrs['cn'][0]; - $a_ext[$i]['priority'] = 1; - $a_ext[$i]['app'] = "Goto"; - $a_ext[$i]['appdata'] = $num."|1"; - $i ++ ; + if($i_insert_only_once == false){ + $i_insert_only_once = true; + $a_ext[$i]['context'] = 'GOsa'; + $a_ext[$i]['exten'] = $this->attrs['cn'][0]; + $a_ext[$i]['priority'] = 1; + $a_ext[$i]['app'] = "Goto"; + $a_ext[$i]['appdata'] = $num."|1"; + $i ++ ; + } if($queueusers == 0){ $a_ext[$i]['context'] = 'GOsa'; @@ -400,11 +420,11 @@ class phonequeue extends plugin $a_ext[$i]['app'] = "Queue"; $a_ext[$i]['appdata'] = $this->attrs['cn'][0]. "|". - $this->goFonDialOption_t. - $this->goFonDialOption_T. - $this->goFonDialOption_h. - $this->goFonDialOption_H. - $this->goFonDialOption_r; + $this->goFonDialOptiont. + $this->goFonDialOptionT. + $this->goFonDialOptionh. + $this->goFonDialOptionH. + $this->goFonDialOptionr; } if($this->goFonQueueAnnounceHoldtime != false) { @@ -528,7 +548,7 @@ class phonequeue extends plugin { plugin::save_object(); if(isset($_POST['phonenumber'])){ - foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_h","goFonDialOption_r","goFonDialOption_H","goFonMusiconHold") as $val){ + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionh","goFonDialOptionr","goFonDialOptionH","goFonMusiconHold") as $val){ if(isset($_POST[$val])){ $this->$val = $_POST[$val]; }else{ @@ -555,7 +575,7 @@ class phonequeue extends plugin plugin::save(); $this->attrs['goFonDialOption'] = ""; - foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_r","goFonDialOption_h","goFonDialOption_H","cn") as $val){ + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ $this->attrs['goFonDialOption'].=$this->$val; unset($this->attrs[$val]); } @@ -571,14 +591,15 @@ class phonequeue extends plugin /* Save data to LDAP */ $ldap->cd($this->dn); - $ldap->modify($this->attrs); + $this->cleanup(); + $ldap->modify ($this->attrs); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/phone queue 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("mofify"); + $this->handle_post_events("modify"); } } else { $this->handle_post_events("add"); @@ -616,7 +637,7 @@ class phonequeue extends plugin /* Remove all temporary attributes */ $tmp = array_flip($this->attributes); - foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_r","goFonDialOption_h","goFonDialOption_H","cn") as $val){ + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ unset($this->$val); unset($this->attrs[$val]); unset($tmp[$val]); @@ -667,10 +688,72 @@ class phonequeue extends plugin @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->attributes, "Save"); $ldap->cd($this->dn); - $ldap->modify($this->attrs); - show_ldap_error($ldap->get_error()); + $this->cleanup(); + $ldap->modify ($this->attrs); + + show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/phone queue with dn '%s' failed."),$this->dn)); + } + + + function getCopyDialog() + { + $str = ""; + $str .= _("Phone number"); + $str .= " "; + return($str); + } + + + function saveCopyDialog() + { + if(isset($_POST['telephoneNumber'])){ + $this->telephoneNumber = $_POST['telephoneNumber']; + } + } + + + 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"), + "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: