X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fogroups%2Fclass_phonequeue.inc;h=07ab713d35716059d4fd17a3edcba63a9f21a41b;hb=f1ca520daf95525953d6e03c5bb0abf7c2648171;hp=d524a7bb29ea3504506effb18c32621f0112667e;hpb=a0ff4bf3e9d97ee8dd7e933b4342907914edfa2e;p=gosa.git diff --git a/plugins/admin/ogroups/class_phonequeue.inc b/plugins/admin/ogroups/class_phonequeue.inc index d524a7bb2..07ab713d3 100644 --- a/plugins/admin/ogroups/class_phonequeue.inc +++ b/plugins/admin/ogroups/class_phonequeue.inc @@ -7,37 +7,45 @@ class phonequeue extends plugin var $cn= ""; - var $goFonTimeOut =""; - var $goFonMaxLen =""; - var $goFonAnnounceFrequency =""; - var $goFonDialOption_t =""; - var $goFonDialOption_T =""; - var $goFonDialOption_h =""; - var $goFonAnnounce =""; - var $goFonDialOption_H =""; - var $goFonMusiconHold =""; - var $goFonWelcomeMusic =""; - var $goFonQueueReportHold =""; - var $goFonQueueYouAreNext =""; - var $goFonQueueThereAre =""; - var $goFonQueueCallsWaiting =""; - var $goFonQueueThankYou =""; - var $goFonQueueMinutes =""; - var $goFonQueueSeconds =""; - var $goFonLanguage =""; - var $goFonStrategy =""; - var $goFonAnnounceHoldtime =""; + var $goFonTimeOut ="20"; + var $goFonMaxLen ="20"; // + var $goFonAnnounceFrequency ="60"; // Annouce Frequency in seconds + var $goFonDialOptiont =""; + var $goFonDialOptionT =""; + var $goFonDialOptionh =""; + var $goFonDialOptionr =""; + var $goFonQueueAnnounce ="gonicus-berlin-welcome"; + var $goFonDialOptionH =""; + 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(); /* attribute list for save action */ - var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOption_t","goFonDialOption_T","goFonDialOption_h", - "goFonDialOption_H","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext", - "goFonQueueThereAre","goFonQueueCallsWaiting","goFonQueueThankYou","goFonQueueMinutes","goFonQueueSeconds", - "telephoneNumber","goFonLanguage","goFonStrategy","goFonAnnounceHoldtime","goFonAnnounce","goFonDialOption"); + 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 */ var $objectclasses= array("goFonQueue"); @@ -51,47 +59,84 @@ class phonequeue extends plugin /* Save initial account state */ $this->initially_was_account= $this->is_account; - $this->telephoneNumber=$this->attrs['telephoneNumber']; - unset($this->telephoneNumber['count']); + 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]; + } + } - for($i = 0; $i < strlen($this->goFonDialOption); $i++){ - $name = "goFonDialOption_".$this->goFonDialOption[$i]; - $this->$name=$this->goFonDialOption[$i]; + if($this->goFonQueueAnnounceHoldtime == "no"){ + $this->goFonQueueAnnounceHoldtime=false; } - $this->old_phone_numbers = $this->telephoneNumber; + + $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]; + + } 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; + } } /* 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(); @@ -103,36 +148,37 @@ 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("goFonLanguageOptions",array('de'=>_('Germany'),'ur'=>_('Uruguai'))); - $smarty->assign("goFonAnnounceHoldtimeOptions",array('no'=>_("No"),'yes'=>_('Yes'))); - $smarty->assign("goFonStrategyOptions",array('ringall' =>_("ring all available channels until one answers"), - 'roundrobin' =>_("take turns ringing each available interface"), - 'leastrecent'=>_("ring interface which was least recently called by this queue"), - 'fewestcalls'=>_("ring the one with fewest completed calls from this queue"), - 'random' =>_("ring random interface"), - 'rrmemory' =>_("round robin with memory, remember where we left off last ring pass"))); + /* 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){ $smarty->assign($val,$this->$val); @@ -142,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))); } @@ -156,23 +196,27 @@ class phonequeue extends plugin /* Check formular input */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); if($this->is_number_used()){ $message[] = $this->is_number_used(); } - if($this->generate_mysql_entension_entries()){ - $message[] = $this->generate_mysql_entension_entries(); + if($this->generate_mysql_table_entries()){ + $message[] = $this->generate_mysql_table_entries(); } - if(!is_numeric($this->goFonTimeOut)){ + if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){ $message[] = _("Timeout must be numeric"); } - if(!is_numeric($this->goFonMaxLen)){ - $message[] = _("Queue length must be numeric"); + if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){ + $message[] = _("Retry must be numeric"); } - if(!is_numeric($this->goFonAnnounceFrequency)){ + 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){ @@ -184,11 +228,15 @@ class phonequeue extends plugin - function generate_mysql_entension_entries($save = false) + function generate_mysql_table_entries($save = false) { $SQL = array(); - + + if(!isset($_SESSION['config']->data['SERVERS']['FON'])){ + return(_("There is currently no asterisk server defined. Your settings can't be saved.")); + } + // Get Configuration for Mysql database Server $a_SETUP = $_SESSION['config']->data['SERVERS']['FON']; $s_parameter =""; @@ -199,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'])); } @@ -212,29 +260,29 @@ class phonequeue extends plugin return( sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER'])); } - - if($save){ $i = 0; $prio = 11; - if(empty($this->cn)){ - $this->cn = $this->parent->by_object['ogroup']->cn; - $this->attrs['cn'][0] = $this->parent->by_object['ogroup']->cn; + $delete = array(); + if(!empty($this->parent->by_object['ogroup'])){ + $new_cn = $this->parent->by_object['ogroup']->cn; } + $old_cn = $this->cn; + + $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$new_cn."';\n"; + $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name='".$new_cn."'; \n"; + $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$new_cn."';\n"; + $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$old_cn."';\n"; + $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name='".$old_cn."'; \n"; + $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name='".$old_cn."';\n"; - if(empty($this->description)){ - $this->description = $this->parent->by_object['ogroup']->description; - $this->attrs['description'][0] = $this->parent->by_object['ogroup']->description; - } - // Delete old Entries - $delete = array(); - foreach($this->old_phone_numbers as $phone){ - $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n"; + if(is_array($this->old_phone_numbers)){ + foreach($this->old_phone_numbers as $phone){ + $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n"; + } } - $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name=\"".$this->attrs['cn'][0]."\"; \n"; - $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name=\"".$this->attrs['cn'][0]."\";\n"; /* Perform queries to delte old entries */ foreach($delete as $query){ @@ -244,101 +292,172 @@ class phonequeue extends plugin } } + $this->attrs['cn'][0] = $new_cn; + /* Append new Member for this queue */ $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; + } } } /* Parse and Add members to query Array */ - foreach($queueuser as $user){ - $entries = ""; - $values = ""; - foreach($user as $attr => $val){ - $entries.= "`".$attr."`,"; - $values .= "'".$val."',"; + 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 ".$a_SETUP['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; } - $values = preg_replace("/,$/","",$values); - $entries = preg_replace("/,$/","",$entries ); - - $SQL[]="INSERT INTO ".$a_SETUP['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; } - /* generate Extension entries, with priority */ + + $queueusers=0; + foreach($this->parent->by_object['ogroup']->memberList as $member){ + if(isset($member['objectClass'])){ + if(in_array("goFonAccount",$member['objectClass'])){ + $queueusers++; + } + } + } + + $i = 0; + + $i_insert_only_once = false; + foreach($this->telephoneNumber as $num){ - $prio --; - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 1; - $a_ext[$i]['app'] = "SetLanguage"; - $a_ext[$i]['appdata'] = $this->goFonLanguage; - $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'] = $this->goFonWelcomeMusic; - $i ++ ; - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 3; - $a_ext[$i]['app'] = "SetCIDName"; - $a_ext[$i]['appdata'] = $this->attrs['description'][0]; - $i ++ ; - $a_ext[$i]['context'] = 'GOsa'; - $a_ext[$i]['exten'] = $num; - $a_ext[$i]['priority'] = 4; - $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. - "|". // Optionalurl egal - "|". // announceoverride - "|". // Timeout - $this->goFonTimeOut; - - $i ++ ; - $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 ++ ; + + // If there are no member in a Queue + // Play sound an quit + + // A Queue is not deleted directly, it is stored until the o group is deleted + + 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'; + $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{ + $prio --; + $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 ++ ; + $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 ++ ; + $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 ++ ; + $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->attrs['cn'][0]." - ".$num; + } + $i ++ ; + $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 ++ ; + $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->attrs['cn'][0]. + "|". + $this->goFonDialOptiont. + $this->goFonDialOptionT. + $this->goFonDialOptionh. + $this->goFonDialOptionH. + $this->goFonDialOptionr; + } + + if($this->goFonQueueAnnounceHoldtime != false) { + $this->goFonQueueAnnounceHoldtime = "yes"; + }else{ + $this->goFonQueueAnnounceHoldtime = "no"; + } + /* Generate Priority Entry */ $queue["announce"] = ""; $queue["monitor_join"] = ""; $queue["monitor_format"] = ""; - $queue["queue_holdtime"] = $this->goFonAnnounce; - $queue["queue_lessthan"] = ""; + $queue["queue_holdtime"] = $this->goFonQueueAnnounce; + $queue["queue_lessthan"] = $this->goFonQueueLessThan; $queue["announce_round_seconds"]= ""; - $queue["retry"] = ""; + $queue["retry"] = $this->goFonQueueRetry; $queue["wrapuptime"] = ""; $queue["servicelevel"] = ""; - $queue["joinempty"] = ""; - $queue["leavewhenempty"] = ""; + $queue["joinempty"] = "no"; + $queue["leavewhenempty"] = "yes"; $queue["eventmemberstatus"] = ""; $queue["eventwhencalled"] = ""; - $queue["reportholdtime"] = ""; + $queue["reportholdtime"] = "yes"; $queue["memberdelay"] = ""; $queue["weight"] = ""; $queue["timeoutrestart"] = ""; $queue["context"] = "default"; $queue["name"] = $this->attrs['cn'][0]; - $queue["timeout"] = $this->goFonTimeOut; + $queue["timeout"] = $this->goFonTimeOut; $queue["maxlen"] = $this->goFonMaxLen; - $queue["strategy" ] = $this->goFonStrategy; + $queue["strategy" ] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy]; $queue["queue_thankyou"] = $this->goFonQueueThankYou; $queue["queue_reporthold"] = $this->goFonQueueReportHold; $queue["announce_frequency"] = $this->goFonAnnounceFrequency; @@ -347,7 +466,7 @@ class phonequeue extends plugin $queue["queue_callswaiting"] = $this->goFonQueueCallsWaiting; $queue["queue_minutes"] = $this->goFonQueueMinutes; $queue["queue_seconds"] = $this->goFonQueueSeconds; - $queue["announce_holdtime"] = $this->goFonAnnounceHoldtime; + $queue["announce_holdtime"] = $this->goFonQueueAnnounceHoldtime; $queue["musiconhold"] = $this->goFonMusiconHold; $i++; @@ -388,25 +507,30 @@ class phonequeue extends plugin } } + @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->search("(objectClass=goFonAccount)", array("telephoneNumber","uid","cn")); + $ldap->cd($this->config->current['BASE']); + $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid")); while($attrs = $ldap->fetch()) { unset($attrs['telephoneNumber']['count']); - $usednumber[$attrs['uid'][0]]= $attrs['telephoneNumber']; 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->cn)||($numbers[$num]['uid'][0]!=$this->uid))){ + 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{ @@ -424,40 +548,58 @@ class phonequeue extends plugin { plugin::save_object(); if(isset($_POST['phonenumber'])){ - foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_h","goFonDialOption_H","goFonMusiconHold") as $val){ + 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() { + #fixme workaround : Tab is not initialised correct + if(!$this->is_account) return; $ldap= $this->config->get_ldap_link(); + $this->generate_mysql_table_entries(true); + plugin::save(); $this->attrs['goFonDialOption'] = ""; - foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_h","goFonDialOption_H") as $val){ + foreach(array("goFonDialOptiont","goFonDialOptionT","goFonDialOptionr","goFonDialOptionh","goFonDialOptionH","cn") as $val){ $this->attrs['goFonDialOption'].=$this->$val; unset($this->attrs[$val]); } - $this->generate_mysql_entension_entries(true); if($this->attrs['goFonDialOption']=="") $this->attrs['goFonDialOption']=array(); + + if($this->goFonQueueAnnounceHoldtime != "no" ){ + $this->attrs['goFonQueueAnnounceHoldtime'] = "yes"; + }else{ + $this->attrs['goFonQueueAnnounceHoldtime'] = "no"; + } + + $this->attrs['goFonQueueStrategy'] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy]; /* 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"); @@ -493,6 +635,18 @@ class phonequeue extends plugin return( sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER'])); } + /* 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; + $i = 0; $prio = 11; @@ -501,16 +655,12 @@ class phonequeue extends plugin $this->attrs['cn'][0] = $this->parent->by_object['ogroup']->cn; } - if(empty($this->description)){ - $this->description = $this->parent->by_object['ogroup']->description; - $this->attrs['description'][0] = $this->parent->by_object['ogroup']->description; - } - // Delete old Entries $delete = array(); foreach($this->old_phone_numbers as $phone){ $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n"; } + $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->attrs['cn'][0]."';\n"; $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name=\"".$this->attrs['cn'][0]."\"; \n"; $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name=\"".$this->attrs['cn'][0]."\";\n"; @@ -538,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" => 0, + "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: