X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fogroups%2Fclass_phonequeue.inc;h=0b3ec303e9e235a4f5fbdcedfd276ba11ebea2db;hb=2738e56e22f23c43e980dea2d34a3c21baa645e9;hp=6ffb446fcd0d04a519f1d566a40fb01104ede0d2;hpb=19acde255ec127db011798224949c2d481ded0b3;p=gosa.git diff --git a/plugins/admin/ogroups/class_phonequeue.inc b/plugins/admin/ogroups/class_phonequeue.inc index 6ffb446fc..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,33 +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; + } } /* 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"), + $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(); @@ -137,27 +148,35 @@ 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(); + /* 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); @@ -169,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))); } @@ -183,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(); @@ -408,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) { @@ -536,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{ @@ -563,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]); } @@ -579,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"); @@ -624,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]); @@ -675,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: