Code

Changed "goFonQueueAnnounceHoldtime" into chkbox,
[gosa.git] / plugins / admin / ogroups / class_phonequeue.inc
1 <?php
3 class phonequeue extends plugin
4 {
5   /* plugin specific values */
6   var $mail= "";
7   var $cn= "";
10   var $goFonTimeOut             ="20"; 
11   var $goFonMaxLen              ="20"; // 
12   var $goFonAnnounceFrequency   ="60"; // Annouce Frequency in seconds
13   var $goFonDialOption_t        ="";
14   var $goFonDialOption_T        ="";
15   var $goFonDialOption_h        ="";
16   var $goFonDialOption_r        ="";
17   var $goFonQueueAnnounce       ="gonicus-berlin-welcome";
18   var $goFonDialOption_H        ="";
19   var $goFonMusiconHold         ="default";
20   var $goFonWelcomeMusic        ="gonicus-berlin-welcome";
21   var $goFonQueueReportHold     ="yes";
22   var $goFonQueueYouAreNext     ="queue-youarenext";
23   var $goFonQueueThereAre       ="queue-thereare";
24   var $goFonQueueCallsWaiting   ="queue-callswaiting";
25   var $goFonQueueThankYou       ="queue-thankyou";
26   var $goFonQueueMinutes        ="queue-minutes"; 
27   var $goFonQueueSeconds        ="queue-seconds";
28   var $goFonQueueLanguage       ="queue-holdtime";
29   var $goFonQueueStrategy       ="ringall";
30   var $goFonQueueAnnounceHoldtime="yes";
31   var $telephoneNumber          =array();
32   var $goFonQueueMember         =array(); 
33   var $goFonDialOption          ="tThH";
34   var $goFonQueueRetry          =5;
36   var $old_phone_numbers        =array();
38   /* attribute list for save action */
39   var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOption_t","goFonDialOption_T",
40       "goFonDialOption_h","goFonDialOption_r",
41       "goFonDialOption_H","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext",
42       "goFonQueueThereAre","goFonQueueCallsWaiting","goFonQueueThankYou","goFonQueueMinutes","goFonQueueSeconds",
43       "telephoneNumber","goFonQueueLanguage","goFonQueueStrategy","goFonQueueAnnounceHoldtime","goFonQueueAnnounce","goFonDialOption","goFonQueueRetry");
44   /* ObjectClass */
45   var $objectclasses= array("goFonQueue");
47   function phonequeue ($config, $dn= NULL)
48   {
49     plugin::plugin($config, $dn);
51     /* Include config object */
52     $this->config= $config;
54     /* Save initial account state */
55     $this->initially_was_account= $this->is_account;
57     if($this->is_account){
58       if(isset($this->attrs['telephoneNumber'])){
59         $this->telephoneNumber=$this->attrs['telephoneNumber'];
60         unset($this->telephoneNumber['count']); 
61       }
63       for($i = 0; $i < strlen($this->goFonDialOption); $i++){
64         $name = "goFonDialOption_".$this->goFonDialOption[$i];
65         $this->$name=$this->goFonDialOption[$i];
66       }
67     }
69     if($this->goFonQueueAnnounceHoldtime == "no"){
70       $this->goFonQueueAnnounceHoldtime=false;
71     }
72     $this->old_phone_numbers = $this->telephoneNumber;
73   }
76   function execute()
77   {
78     /* Do we need to flip is_account state? */
79     if (isset($_POST['modify_state'])){
80       $this->is_account= !$this->is_account;
81     }
83     /* Show tab dialog headers */
84     if ($this->parent != NULL){
85       if ($this->is_account){
86         $display= $this->show_header(_("Remove the phone queue from this Account"),
87             _("Phone queue is enabled for this group. You can disable it by clicking below."));
88       } else {
89         $display= $this->show_header(_("Create phone queue"), _("For this group the phone queues are disabled. You can enable them by clicking below."));
90         return ($display);
91       }
92     }
94     /* Add queue number */ 
95     if(isset($_POST['add_phonenumber'])&&(isset($_POST['phonenumber']))&&(!empty($_POST['phonenumber']))){
96       if((!in_array($_POST['phonenumber'],$this->telephoneNumber))&&(is_numeric($_POST['phonenumber']))){
97         $this->telephoneNumber[]=$_POST['phonenumber'];
98       }
99     }
101     /* Delete queue number */ 
102     if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
103       unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]);
104     }
105   
106     $tmp = array();
107     foreach($this->telephoneNumber as $val){
108       if(!empty($val)){
109         $tmp[]= $val;
110       }
111     }  
112     $this->telephoneNumber=$tmp;
114     /* queue number up */ 
115     if(isset($_POST['up_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
116       if($_POST['goFonQueueNumber_List']>0){
117         $up   = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
118         $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1];
119         $this->telephoneNumber[$_POST['goFonQueueNumber_List']]    = $down; 
120         $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1]  = $up;
121       }
122     }
124     /* Queuenumber down */ 
125     if(isset($_POST['down_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
126       if(isset($this->telephoneNumber[($_POST['goFonQueueNumber_List']+1)])){
127         $up   = $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1];
128         $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
129         $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1]    = $down; 
130         $this->telephoneNumber[$_POST['goFonQueueNumber_List']]  = $up;
131       }
132     }
135     $smarty= get_smarty();
137     $smarty->assign("goFonQueueLanguageOptions",array('de'=>_('German'),'ur'=>_('Uruguai')));
138     $types= array('ringall'    =>_("ring all"),
139           'roundrobin' =>_("round robin"),
140           'leastrecent'=>_("least recently called"),
141           'fewestcalls'=>_("fewest completed calls"),
142           'random'     =>_("random"),
143           'rrmemory'   =>_("round robin with memory"));
144     sort($types);
145     $smarty->assign("goFonQueueStrategyOptions", $types);
147     foreach($this->attributes as $key => $val){
148       $smarty->assign($val,$this->$val);  
150       if($this->$val == false){
151         $smarty->assign($val."CHK","");
152       }else{
153         $smarty->assign($val."CHK"," checked ");
154       }
156       if(chkacl($this->acl,$key)==""){
157         $smarty->assign($val."ACL","");
158       }else{
159         $smarty->assign($val."ACL"," disabled ");
160       }
161     }
162     return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE)));
163   }
166   /* Check formular input */
167   function check()
168   {
169     $message= array();
170   #fixme workaround : Tab is not initialised correct
171           if(!$this->is_account) return($message);
173     if($this->is_number_used()){
174       $message[] = $this->is_number_used();
175     }
177     if($this->generate_mysql_entension_entries()){
178       $message[] = $this->generate_mysql_entension_entries();
179     }
181     if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){
182       $message[] = _("Timeout must be numeric");
183     }
184     if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){
185       $message[] = _("Retry must be numeric");
186     }
187     if(!((is_numeric($this->goFonMaxLen))||(empty($this->goFonMaxLen)))){
188       $message[] = _("Max queue length must be numeric");
189     }
190     if(!((is_numeric($this->goFonAnnounceFrequency))||(empty($this->goFonAnnounceFrequency)))){
191       $message[] = _("Announce frequency must be numeric");
192     }
193     if(count($this->telephoneNumber)==0){
194       $message[] = _("There must be least one queue number defined.");
195     }
197     return $message;
198   }
202   function generate_mysql_entension_entries($save = false)
203   {
205     $SQL = array();
206  
207     // Get Configuration for Mysql database Server
208     $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
209     $s_parameter  ="";
211     // Connect to DB server
212     $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
214     // Check if we are  connected correctly
215     if(!$r_con){
216       gosa_log(mysql_error());
217       return (sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
218           $a_SETUP['SERVER'],$a_SETUP['LOGIN']));
219     }
221     // Select database for Extensions
222     $db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
224     // Test if we have the database selected correctly
225     if(!$db){
226       gosa_log(mysql_error());
227       return( sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
228     }
230     if($save){
231       $i = 0;
232       $prio = 11; 
234       if(empty($this->cn)){
235         $this->cn = $this->parent->by_object['ogroup']->cn;
236         $this->attrs['cn'][0] = $this->parent->by_object['ogroup']->cn;
237       }
239       // Delete old Entries 
240       $delete = array();
241       if(is_array($this->old_phone_numbers)){
242         foreach($this->old_phone_numbers as $phone){
243           $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n";
244         }
245       }
246       $delete[]=    "DELETE FROM ".$a_SETUP['EXT_TABLE']."    WHERE exten='".$this->attrs['cn'][0]."';\n";
247       $delete[]=    "DELETE FROM ".$a_SETUP['QUEUE_TABLE']."  WHERE name=\"".$this->attrs['cn'][0]."\"; \n";
248       $delete[]=    "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name=\"".$this->attrs['cn'][0]."\";\n";
250       /* Perform queries to delte old entries */
251       foreach($delete as $query){
252         if(!mysql_query($query)){
253           gosa_log(mysql_error());
254           return(mysql_error(). sprintf(_("Can't delete in Database %s, on Server %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
255         }
256       }
258       /* Append new Member for this queue */ 
259       $i = 0;
260       $queueuser =array();
261       foreach($this->parent->by_object['ogroup']->memberList as $member){
262         if(in_array("goFonAccount",$member['objectClass'])){
263           $i ++ ;
264           $queueuser[$i]['queue_name']  = $this->attrs['cn'][0]; 
265           $queueuser[$i]['interface']   = "SIP/".$member['uid'][0]; 
266           $queueuser[$i]['penalty']     = 1; 
267         }
268       }
270       /* Parse and Add members to query Array */
271       if(is_array($queueuser)){
272         foreach($queueuser as $user){
273           $entries = "";
274           $values  = "";
275           foreach($user as $attr => $val){
276             $entries.= "`".$attr."`,"; 
277             $values .= "'".$val."',";
278           }
279           $values  = preg_replace("/,$/","",$values);
280           $entries = preg_replace("/,$/","",$entries );
282           $SQL[]="INSERT INTO ".$a_SETUP['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")"; 
283         }
284       }
285       
287       /* generate Extension entries, with priority  */
289       $queueusers=0;
290       foreach($this->parent->by_object['ogroup']->memberList as $member){
291         if(in_array("goFonAccount",$member['objectClass'])){
292           $queueusers++;
293         }
294       }
297       $i = 0;
298       foreach($this->telephoneNumber as $num){
299        
300         // If there are no member in a Queue
301         // Play sound an quit
303         // A Queue is not deleted directly, it is stored until the o group is deleted
304         
305         $a_ext[$i]['context']  = 'GOsa';
306         $a_ext[$i]['exten']    = $this->attrs['cn'][0];
307         $a_ext[$i]['priority'] = 1;
308         $a_ext[$i]['app']      = "Goto";
309         $a_ext[$i]['appdata']  = $num."|1";
310         $i ++ ; 
311     
312         if($queueusers == 0){
313           $a_ext[$i]['context']  = 'GOsa';
314           $a_ext[$i]['exten']    = $num;
315           $a_ext[$i]['priority'] = 1;
316           $a_ext[$i]['app']      = "SetLanguage";
317           $a_ext[$i]['appdata']  = "de";
318           $i ++ ; 
319           
320           $a_ext[$i]['context']  = 'GOsa';
321           $a_ext[$i]['exten']    = $num;
322           $a_ext[$i]['priority'] = 2;
323           $a_ext[$i]['app']      = "Playback";
324           $a_ext[$i]['appdata']  = "ss-noservice";
325           $i ++ ; 
326           
327           $a_ext[$i]['context']  = 'GOsa';
328           $a_ext[$i]['exten']    = $num;
329           $a_ext[$i]['priority'] = 3;
330           $a_ext[$i]['app']      = "Goto";
331           $a_ext[$i]['appdata']  = "default";
332           $i ++ ; 
333         }else{
334           $prio --;
335           $a_ext[$i]['context']  = 'GOsa';
336           $a_ext[$i]['exten']    = $num;
337           $a_ext[$i]['priority'] = 1;
338           $a_ext[$i]['app']      = "Wait";
339           $a_ext[$i]['appdata']  = "2";
340           $i ++ ; 
341           $a_ext[$i]['context']  = 'GOsa';
342           $a_ext[$i]['exten']    = $num;
343           $a_ext[$i]['priority'] = 2;
344           $a_ext[$i]['app']      = "SetLanguage";
345           $a_ext[$i]['appdata']  = $this->goFonQueueLanguage;
346           $i ++ ; 
347           $a_ext[$i]['context']  = 'GOsa';
348           $a_ext[$i]['exten']    = $num;
349           $a_ext[$i]['priority'] = 3;
350           $a_ext[$i]['app']      = "Playback";
351           $a_ext[$i]['appdata']  = $this->goFonWelcomeMusic;
352           $i ++ ; 
353           $a_ext[$i]['context']  = 'GOsa';
354           $a_ext[$i]['exten']    = $num;
355           $a_ext[$i]['priority'] = 4;
356           $a_ext[$i]['app']      = "SetCIDName";
357           if(!empty($this->parent->by_object['ogroup']->description)){
358             $a_ext[$i]['appdata']  = $this->parent->by_object['ogroup']->description;
359           }else{
360             $a_ext[$i]['appdata']  = $this->attrs['cn'][0]." - ".$num;
361           }
362           $i ++ ; 
363           $a_ext[$i]['context']  = 'GOsa';
364           $a_ext[$i]['exten']    = $num;
365           $a_ext[$i]['priority'] = 5;
366           $a_ext[$i]['app']      = "SetVar";
367           $a_ext[$i]['appdata']  =  $prio;
368           $i ++ ; 
369           $a_ext[$i]['context']  = 'GOsa';
370           $a_ext[$i]['exten']    = $num;
371           $a_ext[$i]['priority'] = 6;
372           $a_ext[$i]['app']      = "Queue";
373           $a_ext[$i]['appdata']  =  $this->attrs['cn'][0].
374             "|".
375             $this->goFonDialOption_t.
376             $this->goFonDialOption_T.
377             $this->goFonDialOption_h.
378             $this->goFonDialOption_H.
379             $this->goFonDialOption_r;
380         }
382         if($this->goFonQueueAnnounceHoldtime != false) {
383           $this->goFonQueueAnnounceHoldtime = "yes";
384         }else{
385           $this->goFonQueueAnnounceHoldtime = "no";
386         }
389         /* Generate Priority Entry */
390         $queue["announce"]              = "";
391         $queue["monitor_join"]          = "";
392         $queue["monitor_format"]        = "";
393         $queue["queue_holdtime"]        = $this->goFonQueueAnnounce;
394         $queue["queue_lessthan"]        = "";   
395         $queue["announce_round_seconds"]= "";   
396         $queue["retry"]                 = $this->goFonQueueRetry;
397         $queue["wrapuptime"]            = "";
398         $queue["servicelevel"]          = "";
399         $queue["joinempty"]             = "no";
400         $queue["leavewhenempty"]        = "yes";   
401         $queue["eventmemberstatus"]     = "";
402         $queue["eventwhencalled"]       = "";
403         $queue["reportholdtime"]        = "yes";
404         $queue["memberdelay"]           = "";
405         $queue["weight"]                = "";
406         $queue["timeoutrestart"]        = "";
408         $queue["context"]               = "default";
409         $queue["name"]                  = $this->attrs['cn'][0];  
410         $queue["timeout"]               = $this->goFonTimeOut; 
411         $queue["maxlen"]                = $this->goFonMaxLen;
412         $queue["strategy" ]             = $this->goFonQueueStrategy;
413         $queue["queue_thankyou"]        = $this->goFonQueueThankYou;   
414         $queue["queue_reporthold"]      = $this->goFonQueueReportHold; 
415         $queue["announce_frequency"]    = $this->goFonAnnounceFrequency;
416         $queue["queue_youarenext"]      = $this->goFonQueueYouAreNext;   
417         $queue["queue_thereare"]        = $this->goFonQueueThereAre;   
418         $queue["queue_callswaiting"]    = $this->goFonQueueCallsWaiting;
419         $queue["queue_minutes"]         = $this->goFonQueueMinutes;
420         $queue["queue_seconds"]         = $this->goFonQueueSeconds;   
421         $queue["announce_holdtime"]     = $this->goFonQueueAnnounceHoldtime;   
422         $queue["musiconhold"]           = $this->goFonMusiconHold;
424         $i++;
425       }
427       /* Parse and Add Extension entries */
428       foreach($a_ext as $ext){
429         $entries = "";
430         $values  = "";
431         foreach($ext as $attr => $val){
432           $entries.= "`".$attr."`,";
433           $values .= "'".$val."',";
434         }
435         $values  = preg_replace("/,$/","",$values);
436         $entries = preg_replace("/,$/","",$entries );
437         $SQL[]="INSERT INTO ".$a_SETUP['EXT_TABLE']." (".$entries.") VALUES (".$values.")";
438       }
441       /* Parse and Add Queue */
442       $entries = "";
443       $values  = "";
444       foreach($queue as $attr=>$val){
445         if($val == "") continue;
446         $entries.= "`".$attr."`,";
447         $values .= "'".$val."',";
448       }
449       $values  = preg_replace("/,$/","",$values);
450       $entries = preg_replace("/,$/","",$entries );
451       $SQL[]="INSERT INTO ".$a_SETUP['QUEUE_TABLE']." (".$entries.") VALUES (".$values.")";
453       foreach($SQL as $query){
454          if(!mysql_query($query)){
455           gosa_log(mysql_error());
456           print_red(mysql_error());
457           return(mysql_error(). sprintf(_("Can't delete in Database %s, on Server %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
458         }
459       }
461     }
462     return(false);
463   }
467  /* This function checks if the given phonenumbers are available or already in use*/
469   function is_number_used()
470   {
471     $ldap= $this->config->get_ldap_link();
472     $ldap->cd($this->config->current['BASE']);
473     $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue))", array("telephoneNumber","cn","uid"));
474     while($attrs = $ldap->fetch()) {
475       unset($attrs['telephoneNumber']['count']);
476       foreach($attrs['telephoneNumber'] as $tele){
477         if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
478         if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
479         $numbers[$tele]=$attrs;
480       }
481     }
483     foreach($this->telephoneNumber as $num){
484       if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!= $this->attrs['cn'][0]))){
485         if(isset($numbers[$num]['uid'][0])){
486           return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
487         }else{
488           return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
489         }
490       }
491     }
492   }
498   function save_object()
499   {
500     plugin::save_object();  
501     if(isset($_POST['phonenumber'])){
502       foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_h","goFonDialOption_r","goFonDialOption_H","goFonMusiconHold") as $val){
503         if(isset($_POST[$val])){
504           $this->$val = $_POST[$val];
505         }else{
506           $this->$val = false;
507         }
508       }
509       if(isset($_POST['goFonQueueAnnounceHoldtime'])){
510         $this->goFonQueueAnnounceHoldtime = "yes";
511       }else{
512         $this->goFonQueueAnnounceHoldtime = false;
513       }
514       
515     }
517   }
519   function save()
520   {
521   #fixme workaround : Tab is not initialised correct
522         if(!$this->is_account) return;
523     $ldap= $this->config->get_ldap_link();
525     plugin::save();
526     $this->attrs['goFonDialOption'] = "";
527     foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_r","goFonDialOption_h","goFonDialOption_H") as $val){
528       $this->attrs['goFonDialOption'].=$this->$val; 
529       unset($this->attrs[$val]); 
530     }
531     $this->generate_mysql_entension_entries(true);
532     if($this->attrs['goFonDialOption']=="") $this->attrs['goFonDialOption']=array();
533   
534     if($this->goFonQueueAnnounceHoldtime != "no" ){
535       $this->attrs['goFonQueueAnnounceHoldtime'] = "yes";
536     }else{
537       $this->attrs['goFonQueueAnnounceHoldtime'] = "no";
538     }
539  
540     /* Save data to LDAP */
541     $ldap->cd($this->dn);
542     $ldap->modify($this->attrs);
544     show_ldap_error($ldap->get_error());
546     /* Optionally execute a command after we're done */
547     if ($this->initially_was_account == $this->is_account){
548       if ($this->is_modified){
549         $this->handle_post_events("mofify");
550       }
551     } else {
552       $this->handle_post_events("add");
553     }
554   }
557   /* remove object from parent */
558   function remove_from_parent()
559   {
560     $SQL = array();
562     // Get Configuration for Mysql database Server
563     $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
564     $s_parameter  ="";
566     // Connect to DB server
567     $r_con =  @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
569     // Check if we are  connected correctly
570     if(!$r_con){
571       gosa_log(mysql_error());
572       return (sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
573             $a_SETUP['SERVER'],$a_SETUP['LOGIN']));
574     }
576     // Select database for Extensions
577     $db  =  @mysql_select_db($a_SETUP['DB'],$r_con);
579     // Test if we have the database selected correctly
580     if(!$db){
581       gosa_log(mysql_error());
582       return( sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
583     }
585     $tmp = array_flip($this->attributes);
586     foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_r","goFonDialOption_h","goFonDialOption_H") as $val){
587       unset($this->$val);
588       unset($this->attrs[$val]);
589       unset($tmp[$val]);
590     }   
591     foreach(array_flip($tmp) as $key => $val){
592       $tmp2[]=$val;
593     } 
594     $this->attributes = $tmp2;
596     $i = 0;
597     $prio = 11;
599     if(empty($this->cn)){
600       $this->cn = $this->parent->by_object['ogroup']->cn;
601       $this->attrs['cn'][0] = $this->parent->by_object['ogroup']->cn;
602     }
604     // Delete old Entries
605     $delete = array();
606     foreach($this->old_phone_numbers as $phone){
607       $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n";
608     }
609     $delete[]=    "DELETE FROM ".$a_SETUP['EXT_TABLE']."    WHERE exten='".$this->attrs['cn'][0]."';\n";
610     $delete[]=    "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name=\"".$this->attrs['cn'][0]."\"; \n";
611     $delete[]=    "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name=\"".$this->attrs['cn'][0]."\";\n";
613     /* Perform queries to delte old entries */
614     foreach($delete as $query){
615       if(!mysql_query($query)){
616         gosa_log(mysql_error());
617         return(mysql_error(). sprintf(_("Can't delete in Database %s, on Server %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
618       }
619     }
623     /* Cancel if there's nothing to do here */
624     if (!$this->initially_was_account){
625       return;
626     }
628     /* include global link_info */
629     $ldap= $this->config->get_ldap_link();
631     /* Remove and write to LDAP */
632     plugin::remove_from_parent();
634     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
635         $this->attributes, "Save");
636     $ldap->cd($this->dn);
637     $ldap->modify($this->attrs);
638     show_ldap_error($ldap->get_error());
639   }
643 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
644 ?>