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 $goFonQueueLessThan ="queue-lessthan";
29 var $goFonQueueLanguage ="queue-holdtime";
30 var $goFonQueueStrategy ="ringall";
31 var $goFonQueueAnnounceHoldtime="yes";
32 var $telephoneNumber =array();
33 var $goFonQueueMember =array();
34 var $goFonDialOption ="";
35 var $goFonQueueRetry =5;
37 var $goFonQueueStrategyOptions=array();
38 var $goFonQueueStrategyOptionsR=array();
41 var $old_phone_numbers =array();
43 /* attribute list for save action */
44 var $attributes= array( "goFonTimeOut","goFonMaxLen","goFonAnnounceFrequency","goFonDialOption_t","goFonDialOption_T",
45 "goFonDialOption_h","goFonDialOption_r",
46 "goFonDialOption_H","goFonMusiconHold","goFonWelcomeMusic","goFonQueueReportHold","goFonQueueYouAreNext",
47 "goFonQueueThereAre","goFonQueueCallsWaiting","goFonQueueThankYou","goFonQueueMinutes","goFonQueueSeconds","goFonQueueLessThan",
48 "telephoneNumber","goFonQueueLanguage","goFonQueueStrategy","goFonQueueAnnounceHoldtime","goFonQueueAnnounce","goFonDialOption","goFonQueueRetry");
49 /* ObjectClass */
50 var $objectclasses= array("goFonQueue");
52 function phonequeue ($config, $dn= NULL)
53 {
54 plugin::plugin($config, $dn);
56 /* Include config object */
57 $this->config= $config;
59 /* Save initial account state */
60 $this->initially_was_account= $this->is_account;
62 if($this->is_account){
63 if(isset($this->attrs['telephoneNumber'])){
64 $this->telephoneNumber=$this->attrs['telephoneNumber'];
65 unset($this->telephoneNumber['count']);
66 }
68 for($i = 0; $i < strlen($this->goFonDialOption); $i++){
69 $name = "goFonDialOption_".$this->goFonDialOption[$i];
70 $this->$name=$this->goFonDialOption[$i];
71 }
72 }
74 if($this->goFonQueueAnnounceHoldtime == "no"){
75 $this->goFonQueueAnnounceHoldtime=false;
76 }
77 $this->old_phone_numbers = $this->telephoneNumber;
79 $types= array('ringall' =>_("ring all"),
80 'roundrobin' =>_("round robin"),
81 'leastrecent'=>_("least recently called"),
82 'fewestcalls'=>_("fewest completed calls"),
83 'random' =>_("random"),
84 'rrmemory' =>_("round robin with memory"));
86 $i = 0;
87 foreach($types as $type => $name){
88 $i++;
89 $this->goFonQueueStrategyOptions[$i] =$name;
90 $this->goFonQueueStrategyOptionsR[$i] =$type;
91 $tmp[$type] = $i;
92 }
94 $this->goFonQueueStrategy= $tmp[$this->goFonQueueStrategy];
97 }
100 function execute()
101 {
102 /* Do we need to flip is_account state? */
103 if (isset($_POST['modify_state'])){
104 $this->is_account= !$this->is_account;
105 }
107 /* Show tab dialog headers */
108 if ($this->parent != NULL){
109 if ($this->is_account){
110 $display= $this->show_header(_("Remove the phone queue from this Account"),
111 _("Phone queue is enabled for this group. You can disable it by clicking below."));
112 } else {
113 $display= $this->show_header(_("Create phone queue"), _("For this group the phone queues are disabled. You can enable them by clicking below."));
114 return ($display);
115 }
116 }
118 /* Add queue number */
119 if(isset($_POST['add_phonenumber'])&&(isset($_POST['phonenumber']))&&(!empty($_POST['phonenumber']))){
120 if((!in_array($_POST['phonenumber'],$this->telephoneNumber))&&(is_numeric($_POST['phonenumber']))){
121 $this->telephoneNumber[]=$_POST['phonenumber'];
122 }
123 }
125 /* Delete queue number */
126 if(isset($_POST['delete_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
127 unset($this->telephoneNumber[$_POST['goFonQueueNumber_List']]);
128 }
130 $tmp = array();
131 foreach($this->telephoneNumber as $val){
132 if(!empty($val)){
133 $tmp[]= $val;
134 }
135 }
136 $this->telephoneNumber=$tmp;
138 /* queue number up */
139 if(isset($_POST['up_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
140 if($_POST['goFonQueueNumber_List']>0){
141 $up = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
142 $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1];
143 $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $down;
144 $this->telephoneNumber[$_POST['goFonQueueNumber_List']-1] = $up;
145 }
146 }
148 /* Queuenumber down */
149 if(isset($_POST['down_phonenumber'])&&(isset($_POST['goFonQueueNumber_List']))){
150 if(isset($this->telephoneNumber[($_POST['goFonQueueNumber_List']+1)])){
151 $up = $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1];
152 $down = $this->telephoneNumber[$_POST['goFonQueueNumber_List']];
153 $this->telephoneNumber[$_POST['goFonQueueNumber_List']+1] = $down;
154 $this->telephoneNumber[$_POST['goFonQueueNumber_List']] = $up;
155 }
156 }
158 $smarty= get_smarty();
160 $smarty->assign("goFonQueueLanguageOptions",array('de'=>_('German'),'ur'=>_('Uruguai')));
161 $smarty->assign("goFonQueueStrategyOptions", $this->goFonQueueStrategyOptions);
163 foreach($this->attributes as $key => $val){
164 $smarty->assign($val,$this->$val);
166 if($this->$val == false){
167 $smarty->assign($val."CHK","");
168 }else{
169 $smarty->assign($val."CHK"," checked ");
170 }
172 if(chkacl($this->acl,$key)==""){
173 $smarty->assign($val."ACL","");
174 }else{
175 $smarty->assign($val."ACL"," disabled ");
176 }
177 }
178 return ($display.$smarty->fetch (get_template_path('phonequeue.tpl', TRUE)));
179 }
182 /* Check formular input */
183 function check()
184 {
185 $message= array();
186 #fixme workaround : Tab is not initialised correct
187 if(!$this->is_account) return($message);
189 if($this->is_number_used()){
190 $message[] = $this->is_number_used();
191 }
193 if($this->generate_mysql_entension_entries()){
194 $message[] = $this->generate_mysql_entension_entries();
195 }
197 if(!((is_numeric($this->goFonTimeOut))||(empty($this->goFonTimeOut)))){
198 $message[] = _("Timeout must be numeric");
199 }
200 if(!((is_numeric($this->goFonQueueRetry))||(empty($this->goFonQueueRetry)))){
201 $message[] = _("Retry must be numeric");
202 }
203 if(!((is_numeric($this->goFonMaxLen))||(empty($this->goFonMaxLen)))){
204 $message[] = _("Max queue length must be numeric");
205 }
206 if(!((is_numeric($this->goFonAnnounceFrequency))||(empty($this->goFonAnnounceFrequency)))){
207 $message[] = _("Announce frequency must be numeric");
208 }
209 if(count($this->telephoneNumber)==0){
210 $message[] = _("There must be least one queue number defined.");
211 }
213 return $message;
214 }
218 function generate_mysql_entension_entries($save = false)
219 {
221 $SQL = array();
223 // Get Configuration for Mysql database Server
224 $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
225 $s_parameter ="";
227 // Connect to DB server
228 $r_con = @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
230 // Check if we are connected correctly
231 if(!$r_con){
232 gosa_log(mysql_error());
233 return (sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
234 $a_SETUP['SERVER'],$a_SETUP['LOGIN']));
235 }
237 // Select database for Extensions
238 $db = @mysql_select_db($a_SETUP['DB'],$r_con);
240 // Test if we have the database selected correctly
241 if(!$db){
242 gosa_log(mysql_error());
243 return( sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
244 }
246 if($save){
247 $i = 0;
248 $prio = 11;
250 if(empty($this->cn)){
251 $this->cn = $this->parent->by_object['ogroup']->cn;
252 $this->attrs['cn'][0] = $this->parent->by_object['ogroup']->cn;
253 }
255 // Delete old Entries
256 $delete = array();
257 if(is_array($this->old_phone_numbers)){
258 foreach($this->old_phone_numbers as $phone){
259 $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n";
260 }
261 }
262 $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->attrs['cn'][0]."';\n";
263 $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name=\"".$this->attrs['cn'][0]."\"; \n";
264 $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name=\"".$this->attrs['cn'][0]."\";\n";
266 /* Perform queries to delte old entries */
267 foreach($delete as $query){
268 if(!mysql_query($query)){
269 gosa_log(mysql_error());
270 return(mysql_error(). sprintf(_("Can't delete in Database %s, on Server %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
271 }
272 }
274 /* Append new Member for this queue */
275 $i = 0;
276 $queueuser =array();
277 foreach($this->parent->by_object['ogroup']->memberList as $member){
278 if(in_array("goFonAccount",$member['objectClass'])){
279 $i ++ ;
280 $queueuser[$i]['queue_name'] = $this->attrs['cn'][0];
281 $queueuser[$i]['interface'] = "SIP/".$member['uid'][0];
282 $queueuser[$i]['penalty'] = 1;
283 }
284 }
286 /* Parse and Add members to query Array */
287 if(is_array($queueuser)){
288 foreach($queueuser as $user){
289 $entries = "";
290 $values = "";
291 foreach($user as $attr => $val){
292 $entries.= "`".$attr."`,";
293 $values .= "'".$val."',";
294 }
295 $values = preg_replace("/,$/","",$values);
296 $entries = preg_replace("/,$/","",$entries );
298 $SQL[]="INSERT INTO ".$a_SETUP['QUEUE_MEMBER_TABLE']." (".$entries.") VALUES (".$values.")";
299 }
300 }
303 /* generate Extension entries, with priority */
305 $queueusers=0;
306 foreach($this->parent->by_object['ogroup']->memberList as $member){
307 if(in_array("goFonAccount",$member['objectClass'])){
308 $queueusers++;
309 }
310 }
313 $i = 0;
314 foreach($this->telephoneNumber as $num){
316 // If there are no member in a Queue
317 // Play sound an quit
319 // A Queue is not deleted directly, it is stored until the o group is deleted
321 $a_ext[$i]['context'] = 'GOsa';
322 $a_ext[$i]['exten'] = $this->attrs['cn'][0];
323 $a_ext[$i]['priority'] = 1;
324 $a_ext[$i]['app'] = "Goto";
325 $a_ext[$i]['appdata'] = $num."|1";
326 $i ++ ;
328 if($queueusers == 0){
329 $a_ext[$i]['context'] = 'GOsa';
330 $a_ext[$i]['exten'] = $num;
331 $a_ext[$i]['priority'] = 1;
332 $a_ext[$i]['app'] = "SetLanguage";
333 $a_ext[$i]['appdata'] = "de";
334 $i ++ ;
336 $a_ext[$i]['context'] = 'GOsa';
337 $a_ext[$i]['exten'] = $num;
338 $a_ext[$i]['priority'] = 2;
339 $a_ext[$i]['app'] = "Playback";
340 $a_ext[$i]['appdata'] = "ss-noservice";
341 $i ++ ;
343 $a_ext[$i]['context'] = 'GOsa';
344 $a_ext[$i]['exten'] = $num;
345 $a_ext[$i]['priority'] = 3;
346 $a_ext[$i]['app'] = "Goto";
347 $a_ext[$i]['appdata'] = "default";
348 $i ++ ;
349 }else{
350 $prio --;
351 $a_ext[$i]['context'] = 'GOsa';
352 $a_ext[$i]['exten'] = $num;
353 $a_ext[$i]['priority'] = 1;
354 $a_ext[$i]['app'] = "Wait";
355 $a_ext[$i]['appdata'] = "2";
356 $i ++ ;
357 $a_ext[$i]['context'] = 'GOsa';
358 $a_ext[$i]['exten'] = $num;
359 $a_ext[$i]['priority'] = 2;
360 $a_ext[$i]['app'] = "SetLanguage";
361 $a_ext[$i]['appdata'] = $this->goFonQueueLanguage;
362 $i ++ ;
363 $a_ext[$i]['context'] = 'GOsa';
364 $a_ext[$i]['exten'] = $num;
365 $a_ext[$i]['priority'] = 3;
366 $a_ext[$i]['app'] = "Playback";
367 $a_ext[$i]['appdata'] = $this->goFonWelcomeMusic;
368 $i ++ ;
369 $a_ext[$i]['context'] = 'GOsa';
370 $a_ext[$i]['exten'] = $num;
371 $a_ext[$i]['priority'] = 4;
372 $a_ext[$i]['app'] = "SetCIDName";
373 if(!empty($this->parent->by_object['ogroup']->description)){
374 $a_ext[$i]['appdata'] = $this->parent->by_object['ogroup']->description;
375 }else{
376 $a_ext[$i]['appdata'] = $this->attrs['cn'][0]." - ".$num;
377 }
378 $i ++ ;
379 $a_ext[$i]['context'] = 'GOsa';
380 $a_ext[$i]['exten'] = $num;
381 $a_ext[$i]['priority'] = 5;
382 $a_ext[$i]['app'] = "SetVar";
383 $a_ext[$i]['appdata'] = "QUEUE_PRIO=".$prio;
384 $i ++ ;
385 $a_ext[$i]['context'] = 'GOsa';
386 $a_ext[$i]['exten'] = $num;
387 $a_ext[$i]['priority'] = 6;
388 $a_ext[$i]['app'] = "Queue";
389 $a_ext[$i]['appdata'] = $this->attrs['cn'][0].
390 "|".
391 $this->goFonDialOption_t.
392 $this->goFonDialOption_T.
393 $this->goFonDialOption_h.
394 $this->goFonDialOption_H.
395 $this->goFonDialOption_r;
396 }
398 if($this->goFonQueueAnnounceHoldtime != false) {
399 $this->goFonQueueAnnounceHoldtime = "yes";
400 }else{
401 $this->goFonQueueAnnounceHoldtime = "no";
402 }
405 /* Generate Priority Entry */
406 $queue["announce"] = "";
407 $queue["monitor_join"] = "";
408 $queue["monitor_format"] = "";
409 $queue["queue_holdtime"] = $this->goFonQueueAnnounce;
410 $queue["queue_lessthan"] = $this->goFonQueueLessThan;
411 $queue["announce_round_seconds"]= "";
412 $queue["retry"] = $this->goFonQueueRetry;
413 $queue["wrapuptime"] = "";
414 $queue["servicelevel"] = "";
415 $queue["joinempty"] = "no";
416 $queue["leavewhenempty"] = "yes";
417 $queue["eventmemberstatus"] = "";
418 $queue["eventwhencalled"] = "";
419 $queue["reportholdtime"] = "yes";
420 $queue["memberdelay"] = "";
421 $queue["weight"] = "";
422 $queue["timeoutrestart"] = "";
424 $queue["context"] = "default";
425 $queue["name"] = $this->attrs['cn'][0];
426 $queue["timeout"] = $this->goFonTimeOut;
427 $queue["maxlen"] = $this->goFonMaxLen;
428 $queue["strategy" ] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy];
429 $queue["queue_thankyou"] = $this->goFonQueueThankYou;
430 $queue["queue_reporthold"] = $this->goFonQueueReportHold;
431 $queue["announce_frequency"] = $this->goFonAnnounceFrequency;
432 $queue["queue_youarenext"] = $this->goFonQueueYouAreNext;
433 $queue["queue_thereare"] = $this->goFonQueueThereAre;
434 $queue["queue_callswaiting"] = $this->goFonQueueCallsWaiting;
435 $queue["queue_minutes"] = $this->goFonQueueMinutes;
436 $queue["queue_seconds"] = $this->goFonQueueSeconds;
437 $queue["announce_holdtime"] = $this->goFonQueueAnnounceHoldtime;
438 $queue["musiconhold"] = $this->goFonMusiconHold;
440 $i++;
441 }
443 /* Parse and Add Extension entries */
444 foreach($a_ext as $ext){
445 $entries = "";
446 $values = "";
447 foreach($ext as $attr => $val){
448 $entries.= "`".$attr."`,";
449 $values .= "'".$val."',";
450 }
451 $values = preg_replace("/,$/","",$values);
452 $entries = preg_replace("/,$/","",$entries );
453 $SQL[]="INSERT INTO ".$a_SETUP['EXT_TABLE']." (".$entries.") VALUES (".$values.")";
454 }
457 /* Parse and Add Queue */
458 $entries = "";
459 $values = "";
460 foreach($queue as $attr=>$val){
461 if($val == "") continue;
462 $entries.= "`".$attr."`,";
463 $values .= "'".$val."',";
464 }
465 $values = preg_replace("/,$/","",$values);
466 $entries = preg_replace("/,$/","",$entries );
467 $SQL[]="INSERT INTO ".$a_SETUP['QUEUE_TABLE']." (".$entries.") VALUES (".$values.")";
469 foreach($SQL as $query){
470 if(!mysql_query($query)){
471 gosa_log(mysql_error());
472 print_red(mysql_error());
473 return(mysql_error(). sprintf(_("Can't delete in Database %s, on Server %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
474 }
475 }
477 }
478 return(false);
479 }
483 /* This function checks if the given phonenumbers are available or already in use*/
485 function is_number_used()
486 {
487 $ldap= $this->config->get_ldap_link();
488 $ldap->cd($this->config->current['BASE']);
489 $ldap->search("(|(objectClass=goFonAccount)(objectClass=goFonQueue)(objectClass=goFonConference))", array("telephoneNumber","cn","uid"));
490 while($attrs = $ldap->fetch()) {
491 unset($attrs['telephoneNumber']['count']);
492 foreach($attrs['telephoneNumber'] as $tele){
493 if(!isset($attrs['cn'][0])) $attrs['cn'][0]=$attrs['dn'];
494 if(!isset($attrs['uid'][0])) $attrs['uid'][0]=$attrs['dn'];
495 $numbers[$tele]=$attrs;
496 }
497 }
499 foreach($this->telephoneNumber as $num){
500 if((isset($numbers[$num]))&&(($numbers[$num]['cn'][0]!= $this->attrs['cn'][0]))){
501 if(isset($numbers[$num]['uid'][0])){
502 return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['uid'][0]);
503 }else{
504 return sprintf(_("The specified telephonenumber '%s' is already assigned to '%s'."),$num,$numbers[$num]['cn'][0]);
505 }
506 }
507 }
508 }
514 function save_object()
515 {
516 plugin::save_object();
517 if(isset($_POST['phonenumber'])){
518 foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_h","goFonDialOption_r","goFonDialOption_H","goFonMusiconHold") as $val){
519 if(isset($_POST[$val])){
520 $this->$val = $_POST[$val];
521 }else{
522 $this->$val = false;
523 }
524 }
525 if(isset($_POST['goFonQueueAnnounceHoldtime'])){
526 $this->goFonQueueAnnounceHoldtime = "yes";
527 }else{
528 $this->goFonQueueAnnounceHoldtime = false;
529 }
531 }
533 }
535 function save()
536 {
537 #fixme workaround : Tab is not initialised correct
538 if(!$this->is_account) return;
539 $ldap= $this->config->get_ldap_link();
541 plugin::save();
542 $this->attrs['goFonDialOption'] = "";
543 foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_r","goFonDialOption_h","goFonDialOption_H") as $val){
544 $this->attrs['goFonDialOption'].=$this->$val;
545 unset($this->attrs[$val]);
546 }
547 $this->generate_mysql_entension_entries(true);
548 if($this->attrs['goFonDialOption']=="") $this->attrs['goFonDialOption']=array();
550 if($this->goFonQueueAnnounceHoldtime != "no" ){
551 $this->attrs['goFonQueueAnnounceHoldtime'] = "yes";
552 }else{
553 $this->attrs['goFonQueueAnnounceHoldtime'] = "no";
554 }
556 $this->attrs['goFonQueueStrategy'] = $this->goFonQueueStrategyOptionsR[$this->goFonQueueStrategy];
558 /* Save data to LDAP */
559 $ldap->cd($this->dn);
560 $ldap->modify($this->attrs);
562 show_ldap_error($ldap->get_error());
564 /* Optionally execute a command after we're done */
565 if ($this->initially_was_account == $this->is_account){
566 if ($this->is_modified){
567 $this->handle_post_events("mofify");
568 }
569 } else {
570 $this->handle_post_events("add");
571 }
572 }
575 /* remove object from parent */
576 function remove_from_parent()
577 {
578 $SQL = array();
580 // Get Configuration for Mysql database Server
581 $a_SETUP = $_SESSION['config']->data['SERVERS']['FON'];
582 $s_parameter ="";
584 // Connect to DB server
585 $r_con = @mysql_pconnect($a_SETUP['SERVER'],$a_SETUP['LOGIN'],$a_SETUP['PASSWORD']);
587 // Check if we are connected correctly
588 if(!$r_con){
589 gosa_log(mysql_error());
590 return (sprintf(_("The MySQL Server '%s' isn't reachable as user '%s', check GOsa log for mysql error."),
591 $a_SETUP['SERVER'],$a_SETUP['LOGIN']));
592 }
594 // Select database for Extensions
595 $db = @mysql_select_db($a_SETUP['DB'],$r_con);
597 // Test if we have the database selected correctly
598 if(!$db){
599 gosa_log(mysql_error());
600 return( sprintf(_("Can't select database %s on %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
601 }
603 $tmp = array_flip($this->attributes);
604 foreach(array("goFonDialOption_t","goFonDialOption_T","goFonDialOption_r","goFonDialOption_h","goFonDialOption_H") as $val){
605 unset($this->$val);
606 unset($this->attrs[$val]);
607 unset($tmp[$val]);
608 }
609 foreach(array_flip($tmp) as $key => $val){
610 $tmp2[]=$val;
611 }
612 $this->attributes = $tmp2;
614 $i = 0;
615 $prio = 11;
617 if(empty($this->cn)){
618 $this->cn = $this->parent->by_object['ogroup']->cn;
619 $this->attrs['cn'][0] = $this->parent->by_object['ogroup']->cn;
620 }
622 // Delete old Entries
623 $delete = array();
624 foreach($this->old_phone_numbers as $phone){
625 $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$phone."';\n";
626 }
627 $delete[]= "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->attrs['cn'][0]."';\n";
628 $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_TABLE']." WHERE name=\"".$this->attrs['cn'][0]."\"; \n";
629 $delete[]= "DELETE FROM ".$a_SETUP['QUEUE_MEMBER_TABLE']." WHERE queue_name=\"".$this->attrs['cn'][0]."\";\n";
631 /* Perform queries to delte old entries */
632 foreach($delete as $query){
633 if(!mysql_query($query)){
634 gosa_log(mysql_error());
635 return(mysql_error(). sprintf(_("Can't delete in Database %s, on Server %s."),$a_SETUP['DB'],$a_SETUP['SERVER']));
636 }
637 }
641 /* Cancel if there's nothing to do here */
642 if (!$this->initially_was_account){
643 return;
644 }
646 /* include global link_info */
647 $ldap= $this->config->get_ldap_link();
649 /* Remove and write to LDAP */
650 plugin::remove_from_parent();
652 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
653 $this->attributes, "Save");
654 $ldap->cd($this->dn);
655 $ldap->modify($this->attrs);
656 show_ldap_error($ldap->get_error());
657 }
659 }
661 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
662 ?>