Code

Added execute methods
[gosa.git] / plugins / personal / connectivity / class_oxchangeAccount.inc
1 <?php
2 /*
3   This code is part of GOsa (https://gosa.gonicus.de)
4   Copyright (C) 2005 Alejandro Escanero Blanco
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2 of the License, or
9   (at your option) any later version.
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
21 class oxchangeAccount extends plugin
22 {
23   /* Definitions */
24   var $plHeadline= "Open-Xchange";
25   var $plDescription= "This does something";
27   /* CLI vars */
28   var $cli_summary= "Management of Open-Xchange accounts";
29   var $cli_description= "Some longer text\nfor help";
30   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
32   /* GW attributes */
33   var $OXAppointmentDays="500";
34   var $OXTaskDays="5";
35   var $OXTimeZone="GMT";
36   var $mailEnabled="OK";
38   /* attribute list for save action */
39   var $attributes= array("OXAppointmentDays", "OXTaskDays", "OXTimeZone","mailEnabled");
40   var $objectclasses= array("OXUserObject");
42   var $oxconf = array();
43   var $timezones=array(
44       "Africa/Abidjan",
45       "Africa/Accra",
46       "Africa/Addis_Ababa",
47       "Africa/Algiers",
48       "Africa/Asmera",
49       "Africa/Bamako",
50       "Africa/Bangui",
51       "Africa/Banjul",
52       "Africa/Bissau",
53       "Africa/Blantyre",
54       "Africa/Brazzaville",
55       "Africa/Bujumbura",
56       "Africa/Cairo",
57       "Africa/Casablanca",
58       "Africa/Ceuta",
59       "Africa/Conakry",
60       "Africa/Dakar",
61       "Africa/Dar_es_Salaam",
62       "Africa/Djibouti",
63       "Africa/Douala",
64       "Africa/El_Aaiun",
65       "Africa/Freetown",
66       "Africa/Gaborone",
67       "Africa/Harare",
68       "Africa/Johannesburg",
69       "Africa/Kampala",
70       "Africa/Khartoum",
71       "Africa/Kigali",
72       "Africa/Kinshasa",
73       "Africa/Lagos",
74       "Africa/Libreville",
75       "Africa/Lome",
76       "Africa/Luanda",
77       "Africa/Lubumbashi",
78       "Africa/Lusaka",
79       "Africa/Malabo",
80       "Africa/Maputo",
81       "Africa/Maseru",
82       "Africa/Mbabane",
83       "Africa/Mogadishu",
84       "Africa/Monrovia",
85       "Africa/Nairobi",
86       "Africa/Ndjamena",
87       "Africa/Niamey",
88       "Africa/Nouakchott",
89       "Africa/Ouagadougou",
90       "Africa/Porto-Novo",
91       "Africa/Sao_Tome",
92       "Africa/Timbuktu",
93       "Africa/Tripoli",
94       "Africa/Tunis",
95       "Africa/Windhoek",
96       "America/Adak",
97       "America/Anchorage",
98       "America/Anguilla",
99       "America/Antigua",
100       "America/Araguaina",
101       "America/Aruba",
102       "America/Asuncion",
103       "America/Atka",
104       "America/Barbados",
105       "America/Belem",
106       "America/Belize",
107       "America/Boa_Vista",
108       "America/Bogota",
109       "America/Boise",
110       "America/Buenos_Aires",
111       "America/Cambridge_Bay",
112       "America/Cancun",
113       "America/Caracas",
114       "America/Catamarca",
115       "America/Cayenne",
116       "America/Cayman",
117       "America/Chicago",
118       "America/Chihuahua",
119       "America/Cordoba",
120       "America/Costa_Rica",
121       "America/Cuiaba",
122       "America/Curacao",
123       "America/Danmarkshavn",
124       "America/Dawson",
125       "America/Dawson_Creek",
126       "America/Denver",
127       "America/Detroit",
128       "America/Dominica",
129       "America/Edmonton",
130       "America/Eirunepe",
131       "America/El_Salvador",
132       "America/Ensenada",
133       "America/Fortaleza",
134       "America/Fort_Wayne",
135       "America/Glace_Bay",
136       "America/Godthab",
137       "America/Goose_Bay",
138       "America/Grand_Turk",
139       "America/Grenada",
140       "America/Guadeloupe",
141       "America/Guatemala",
142       "America/Guayaquil",
143       "America/Guyana",
144       "America/Halifax",
145       "America/Havana",
146       "America/Hermosillo",
147       "America/Indiana",
148       "America/Indiana/Indianapolis",
149       "America/Indiana/Knox",
150       "America/Indiana/Marengo",
151       "America/Indiana/Vevay",
152       "America/Indianapolis",
153       "America/Inuvik",
154       "America/Iqaluit",
155       "America/Jamaica",
156       "America/Jujuy",
157       "America/Juneau",
158       "America/Kentucky",
159       "America/Kentucky/Louisville",
160       "America/Kentucky/Monticello",
161       "America/Knox_IN",
162       "America/La_Paz",
163       "America/Lima",
164       "America/Los_Angeles",
165       "America/Louisville",
166       "America/Maceio",
167       "America/Managua",
168       "America/Manaus",
169       "America/Martinique",
170       "America/Mazatlan",
171       "America/Mendoza",
172       "America/Menominee",
173       "America/Merida",
174       "America/Mexico_City",
175       "America/Miquelon",
176       "America/Monterrey",
177       "America/Montevideo",
178       "America/Montreal",
179       "America/Montserrat",
180       "America/Nassau",
181       "America/New_York",
182       "America/Nipigon",
183       "America/Nome",
184       "America/Noronha",
185       "America/North_Dakota",
186       "America/North_Dakota/Center",
187       "America/Panama",
188       "America/Pangnirtung",
189       "America/Paramaribo",
190       "America/Phoenix",
191       "America/Port-au-Prince",
192       "America/Porto_Acre",
193       "America/Porto_Velho",
194       "America/Port_of_Spain",
195       "America/Puerto_Rico",
196       "America/Rainy_River",
197       "America/Rankin_Inlet",
198       "America/Recife",
199       "America/Regina",
200       "America/Rio_Branco",
201       "America/Rosario",
202       "America/Santiago",
203       "America/Santo_Domingo",
204       "America/Sao_Paulo",
205       "America/Scoresbysund",
206       "America/Shiprock",
207       "America/St_Johns",
208       "America/St_Kitts",
209       "America/St_Lucia",
210       "America/St_Thomas",
211       "America/St_Vincent",
212       "America/Swift_Current",
213       "America/Tegucigalpa",
214       "America/Thule",
215       "America/Thunder_Bay",
216       "America/Tijuana",
217       "America/Tortola",
218       "America/Vancouver",
219       "America/Virgin",
220       "America/Whitehorse",
221       "America/Winnipeg",
222       "America/Yakutat",
223       "America/Yellowknife",
224       "Antarctica/Casey",
225       "Antarctica/Davis",
226       "Antarctica/DumontDUrville",
227       "Antarctica/Mawson",
228       "Antarctica/McMurdo",
229       "Antarctica/Palmer",
230       "Antarctica/South_Pole",
231       "Antarctica/Syowa",
232       "Antarctica/Vostok",
233       "Arctic/Longyearbyen",
234       "Asia/Aden",
235       "Asia/Almaty",
236       "Asia/Amman",
237       "Asia/Anadyr",
238       "Asia/Aqtau",
239       "Asia/Aqtobe",
240       "Asia/Ashgabat",
241       "Asia/Ashkhabad",
242       "Asia/Baghdad",
243       "Asia/Bahrain",
244       "Asia/Baku",
245       "Asia/Bangkok",
246       "Asia/Beirut",
247       "Asia/Bishkek",
248       "Asia/Brunei",
249       "Asia/Calcutta",
250       "Asia/Choibalsan",
251       "Asia/Chongqing",
252       "Asia/Chungking",
253       "Asia/Colombo",
254       "Asia/Dacca",
255       "Asia/Damascus",
256       "Asia/Dhaka",
257       "Asia/Dili",
258       "Asia/Dubai",
259       "Asia/Dushanbe",
260       "Asia/Gaza",
261       "Asia/Harbin",
262       "Asia/Hong_Kong",
263       "Asia/Hovd",
264       "Asia/Irkutsk",
265       "Asia/Istanbul",
266       "Asia/Jakarta",
267       "Asia/Jayapura",
268       "Asia/Jerusalem",
269       "Asia/Kabul",
270       "Asia/Kamchatka",
271       "Asia/Karachi",
272       "Asia/Kashgar",
273       "Asia/Katmandu",
274       "Asia/Krasnoyarsk",
275       "Asia/Kuala_Lumpur",
276       "Asia/Kuching",
277       "Asia/Kuwait",
278       "Asia/Macao",
279       "Asia/Macau",
280       "Asia/Magadan",
281       "Asia/Manila",
282       "Asia/Muscat",
283       "Asia/Nicosia",
284       "Asia/Novosibirsk",
285       "Asia/Omsk",
286       "Asia/Oral",
287       "Asia/Phnom_Penh",
288       "Asia/Pontianak",
289       "Asia/Pyongyang",
290       "Asia/Qatar",
291       "Asia/Qyzylorda",
292       "Asia/Rangoon",
293       "Asia/Riyadh",
294       "Asia/Riyadh87",
295       "Asia/Riyadh88",
296       "Asia/Riyadh89",
297       "Asia/Saigon",
298       "Asia/Sakhalin",
299       "Asia/Samarkand",
300       "Asia/Seoul",
301       "Asia/Shanghai",
302       "Asia/Singapore",
303       "Asia/Taipei",
304       "Asia/Tashkent",
305       "Asia/Tbilisi",
306       "Asia/Tehran",
307       "Asia/Tel_Aviv",
308       "Asia/Thimbu",
309       "Asia/Thimphu",
310       "Asia/Tokyo",
311       "Asia/Ujung_Pandang",
312       "Asia/Ulaanbaatar",
313       "Asia/Ulan_Bator",
314       "Asia/Urumqi",
315       "Asia/Vientiane",
316       "Asia/Vladivostok",
317       "Asia/Yakutsk",
318       "Asia/Yekaterinburg",
319       "Asia/Yerevan",
320       "Atlantic/Azores",
321       "Atlantic/Bermuda",
322       "Atlantic/Canary",
323       "Atlantic/Cape_Verde",
324       "Atlantic/Faeroe",
325       "Atlantic/Jan_Mayen",
326       "Atlantic/Madeira",
327       "Atlantic/Reykjavik",
328       "Atlantic/South_Georgia",
329       "Atlantic/Stanley",
330       "Atlantic/St_Helena",
331       "Australia/ACT",
332       "Australia/Adelaide",
333       "Australia/Brisbane",
334       "Australia/Broken_Hill",
335       "Australia/Canberra",
336       "Australia/Darwin",
337       "Australia/Hobart",
338       "Australia/LHI",
339       "Australia/Lindeman",
340       "Australia/Lord_Howe",
341       "Australia/Melbourne",
342       "Australia/North",
343       "Australia/NSW",
344       "Australia/Perth",
345       "Australia/Queensland",
346       "Australia/South",
347       "Australia/Sydney",
348       "Australia/Tasmania",
349       "Australia/Victoria",
350       "Australia/West",
351       "Australia/Yancowinna",
352       "Brazil/Acre",
353       "Brazil/DeNoronha",
354       "Brazil/East",
355       "Brazil/West",
356       "Canada/Atlantic",
357       "Canada/Central",
358       "Canada/East-Saskatchewan",
359       "Canada/Eastern",
360       "Canada/Mountain",
361       "Canada/Newfoundland",
362       "Canada/Pacific",
363       "Canada/Saskatchewan",
364       "Canada/Yukon",
365       "CET",
366       "Chile/Continental",
367       "Chile/EasterIsland",
368       "CST6CDT",
369       "Cuba",
370       "EET",
371       "Egypt",
372       "Eire",
373       "EST",
374       "EST5EDT",
375       "Etc/GMT",
376       "Etc/GMT+0",
377       "Etc/GMT+1",
378       "Etc/GMT+10",
379       "Etc/GMT+11",
380       "Etc/GMT+12",
381       "Etc/GMT+2",
382       "Etc/GMT+3",
383       "Etc/GMT+4",
384       "Etc/GMT+5",
385       "Etc/GMT+6",
386       "Etc/GMT+7",
387       "Etc/GMT+8",
388       "Etc/GMT+9",
389       "Etc/GMT-0",
390       "Etc/GMT-1",
391       "Etc/GMT-10",
392       "Etc/GMT-11",
393       "Etc/GMT-12",
394       "Etc/GMT-13",
395       "Etc/GMT-14",
396       "Etc/GMT-2",
397       "Etc/GMT-3",
398       "Etc/GMT-4",
399       "Etc/GMT-5",
400       "Etc/GMT-6",
401       "Etc/GMT-7",
402       "Etc/GMT-8",
403       "Etc/GMT-9",
404       "Etc/GMT0",
405       "Etc/Greenwich",
406       "Etc/UCT",
407       "Etc/Universal",
408       "Etc/UTC",
409       "Etc/Zulu",
410       "Europe/Amsterdam",
411       "Europe/Andorra",
412       "Europe/Athens",
413       "Europe/Belfast",
414       "Europe/Belgrade",
415       "Europe/Berlin",
416       "Europe/Bratislava",
417       "Europe/Brussels",
418       "Europe/Bucharest",
419       "Europe/Budapest",
420       "Europe/Chisinau",
421       "Europe/Copenhagen",
422       "Europe/Dublin",
423       "Europe/Gibraltar",
424       "Europe/Helsinki",
425       "Europe/Istanbul",
426       "Europe/Kaliningrad",
427       "Europe/Kiev",
428       "Europe/Lisbon",
429       "Europe/Ljubljana",
430       "Europe/London",
431       "Europe/Luxembourg",
432       "Europe/Madrid",
433       "Europe/Malta",
434       "Europe/Minsk",
435       "Europe/Monaco",
436       "Europe/Moscow",
437       "Europe/Nicosia",
438       "Europe/Oslo",
439       "Europe/Paris",
440       "Europe/Prague",
441       "Europe/Riga",
442       "Europe/Rome",
443       "Europe/Samara",
444       "Europe/San_Marino",
445       "Europe/Sarajevo",
446       "Europe/Simferopol",
447       "Europe/Skopje",
448       "Europe/Sofia",
449       "Europe/Stockholm",
450       "Europe/Tallinn",
451       "Europe/Tirane",
452       "Europe/Tiraspol",
453       "Europe/Uzhgorod",
454       "Europe/Vaduz",
455       "Europe/Vatican",
456       "Europe/Vienna",
457       "Europe/Vilnius",
458       "Europe/Warsaw",
459       "Europe/Zagreb",
460       "Europe/Zaporozhye",
461       "Europe/Zurich",
462       "Factory",
463       "GB",
464       "GB-Eire",
465       "GMT",
466       "GMT+0",
467       "GMT-0",
468       "GMT0",
469       "Greenwich",
470       "Hongkong",
471       "HST",
472       "Iceland",
473       "Indian/Antananarivo",
474       "Indian/Chagos",
475       "Indian/Christmas",
476       "Indian/Cocos",
477       "Indian/Comoro",
478       "Indian/Kerguelen",
479       "Indian/Mahe",
480       "Indian/Maldives",
481       "Indian/Mauritius",
482       "Indian/Mayotte",
483       "Indian/Reunion",
484       "Iran",
485       "Israel",
486       "Jamaica",
487       "Japan",
488       "Kwajalein",
489       "Libya",
490       "MET",
491       "Mexico/BajaNorte",
492       "Mexico/BajaSur",
493       "Mexico/General",
494       "Mideast/Riyadh87",
495       "Mideast/Riyadh88",
496       "Mideast/Riyadh89",
497       "MST",
498       "MST7MDT",
499       "Navajo",
500       "NZ",
501       "NZ-CHAT",
502       "Pacific/Apia",
503       "Pacific/Auckland",
504       "Pacific/Chatham",
505       "Pacific/Easter",
506       "Pacific/Efate",
507       "Pacific/Enderbury",
508       "Pacific/Fakaofo",
509       "Pacific/Fiji",
510       "Pacific/Funafuti",
511       "Pacific/Galapagos",
512       "Pacific/Gambier",
513       "Pacific/Guadalcanal",
514       "Pacific/Guam",
515       "Pacific/Honolulu",
516       "Pacific/Johnston",
517       "Pacific/Kiritimati",
518       "Pacific/Kosrae",
519       "Pacific/Kwajalein",
520       "Pacific/Majuro",
521       "Pacific/Marquesas",
522       "Pacific/Midway",
523       "Pacific/Nauru",
524       "Pacific/Niue",
525       "Pacific/Norfolk",
526       "Pacific/Noumea",
527       "Pacific/Pago_Pago",
528       "Pacific/Palau",
529       "Pacific/Pitcairn",
530       "Pacific/Ponape",
531       "Pacific/Port_Moresby",
532       "Pacific/Rarotonga",
533       "Pacific/Saipan",
534       "Pacific/Samoa",
535       "Pacific/Tahiti",
536       "Pacific/Tarawa",
537       "Pacific/Tongatapu",
538       "Pacific/Truk",
539       "Pacific/Wake",
540       "Pacific/Wallis",
541       "Pacific/Yap",
542       "Poland",
543       "Portugal",
544       "PRC",
545       "PST8PDT",
546       "ROC",
547       "ROK",
548       "Singapore",
549       "SystemV/AST4",
550       "SystemV/AST4ADT",
551       "SystemV/CST6",
552       "SystemV/CST6CDT",
553       "SystemV/EST5",
554       "SystemV/EST5EDT",
555       "SystemV/HST10",
556       "SystemV/MST7",
557       "SystemV/MST7MDT",
558       "SystemV/PST8",
559       "SystemV/PST8PDT",
560       "SystemV/YST9",
561       "SystemV/YST9YDT",
562       "Turkey",
563       "UCT",
564       "Universal",
565       "US/Alaska",
566       "US/Aleutian",
567       "US/Arizona",
568       "US/Central",
569       "US/East-Indiana",
570       "US/Eastern",
571       "US/Hawaii",
572       "US/Indiana-Starke",
573       "US/Michigan",
574       "US/Mountain",
575       "US/Pacific",
576       "US/Samoa",
577       "UTC",
578       "W-SU",
579       "WET",
580       "Zulu"
581         );
583   var $dnmode= "";
585   function oxchangeAccount ($config, $dn= NULL)
586   {
587     plugin::plugin ($config, $dn);
588     for ($i=0;$i<count($this->config->data['TABS']['CONNECTIVITY']);$i++){
589       if($this->config->data['TABS']['CONNECTIVITY'][$i]['CLASS']=='oxchangeAccount') {
590         $this->oxconf=$this->config->data['TABS']['CONNECTIVITY'][$i];
591         break;
592       }
593     }
595     $this->dnmode= $this->config->current['DNMODE'];
596   }
598   function execute()
599   {
600         /* Call parent execute */
601         plugin::execute();
603     /* Show tab dialog headers */
604     $display="";
605     if ($this->parent != NULL){
606       if ($this->is_account){
607         $display="";
608       } else {
609         $obj= $this->parent->by_object['posixAccount'];
610         $obj2= $this->parent->by_object['mailAccount'];
611         if (! $obj->is_account){
612           $display= "<BR><BR><CENTER>".sprintf(_("This account has %s features disabled. Posix features are needed for openXchange accounts, enable them first."), "<b>"._("OpenXchange")."</b>")."</CENTER><BR><BR>";
614         } else {
615           if (! $obj2->is_account){
616             $display= "<BR><BR><CENTER>".sprintf(_("This account has %s features disabled. Mail features are needed for openXchange accounts, enable them first."), "<b>"._("OpenXchange")."</b>")."</CENTER><BR><BR>";
617             return ($display);
618           }
619         }
620       }
621     }
623     /* Show main page */
624     $smarty= get_smarty();
626     if (function_exists("pg_connect")){
627       $smarty->assign("pg", true);
628     }else{
629       $smarty->assign("pg", false);
630     }
632     /* Load attributes */
633     foreach($this->attributes as $val){
634       $smarty->assign("$val", $this->$val);
635       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
636     }
637     $smarty->assign("oxchangeAccountACL", chkacl($this->acl, "oxchangeAccount"));
638     if ($this->is_account){
639       $smarty->assign("oxchangeState", "checked");
640       $smarty->assign("oxState", "");
641     } else {
642       $smarty->assign("oxchangeState", "");
643       $smarty->assign("oxState", "disabled");
644     }
646     $smarty->assign("timezones", $this->timezones);
649     if ($this->parent != NULL){
650       $smarty->assign("tabbed", 1);
651     }
653     $display.= $smarty->fetch (get_template_path('oxchange.tpl', TRUE, dirname(__FILE__)));
654     return ($display);
655   }
657   function remove_from_parent()
658   {
659     $sqldeluser=array(
660         "delete from prg_notes where (user_right like '".$this->attrs[$this->dnmode][0]."') and (group_right like 's')",
661         "delete from prg_documents_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
662         "delete from prg_documents_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
663         "delete from prg_docufolders_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
664         "delete from prg_docufolders_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
665         "delete from prg_date_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')",
666         "delete from prg_date_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
667         "delete from prg_dates_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
668         "delete from prg_knowledge_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
669         "delete from prg_knowledge_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
670         "delete from prg_knowledge_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
671         "delete from prg_knowledge_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
672         "delete from prg_pin_board_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
673         "delete from prg_pin_board_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
674         "delete from prg_bookmarks_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
675         "delete from prg_bookmarks_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
676         "delete from prg_bookmarks_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
677         "delete from prg_bookmarks_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
678         "delete from prg_tasks_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')",
679         "delete from prg_tasks_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
680         "delete from prg_tasks_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
681         "delete from prg_projects_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')",
682         "delete from prg_projects_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
683         "delete from prg_projects_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
684         "delete from oxfolder_permissions where (entity like '".$this->attrs[$this->dnmode][0]."') AND ((role = 256) OR (role = 1024))",
685         "delete from oxfolder_standardfolders where owner like '".$this->attrs[$this->dnmode][0]."'",
686         "delete from prg_forum_read where user_right = '".$this->attrs[$this->dnmode][0]."'",
687         "delete from prg_forum_mod where user_right = '".$this->attrs[$this->dnmode][0]."'",
688         "delete from prg_forum_abo where user_right = '".$this->attrs[$this->dnmode][0]."'",
689         "delete from prg_forum_seen where username = '".$this->attrs[$this->dnmode][0]."'",
690         "delete from sys_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')",
691         "delete from usr_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')");
693     /* Trying to open a Postgresql Database Server */
694     if (function_exists("pg_connect")){
695       if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){
696         $pgcon = pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]);
697         if (! $pgcon){
698           print_red(_("Couldn't connect to postgresql database!"));
699           return;
700         }
701       }else{
702         print_red(_("Needed parameters to openexchange connectivity plugin are missing!"));
703         return;
704       }
705     }else{
706       print_red(_("PHP4 module for postgresql database is missing!"));
707       return;
708     }
710     plugin::remove_from_parent();
711     $ldap= $this->config->get_ldap_link();
713     if($ldap->dn_exists("ou=addr,".$this->dn)){
714         $ldap->rmdir_recursive("ou=addr,".$this->dn);
715         show_ldap_error($ldap->get_error());
716     }
718     $ldap->cd($this->dn);
719     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
720         $this->attributes, "Save");
721     $ldap->modify($this->attrs);
722     show_ldap_error($ldap->get_error());
723     /* Optionally execute a command after we're done */
724     $this->postremove();
726     /* Finally remove data from postgresql server */
727     foreach ($sqldeluser as $sqls){
728       pg_exec($pgcon,$sqls);
729     }
730     pg_close();
731   }
733   /* Save data to object */
734   function save_object()
735   {
736     /* Do we need to flip is_account state? */
737     if (isset($_POST['connectivityTab'])){
738       if (isset($_POST['oxchange'])){
739         if (!$this->is_account && $_POST['oxchange'] == "B"){
740           $this->is_account= TRUE;
741         }
742       } else {
743         $this->is_account= FALSE;
744       }
745     }
747     plugin::save_object();
748     if (isset($_POST["oxchangeStatus"])){
749       $this->oxchangeStatus = "disabled";
750     } else {
751       $this->oxchangeStatus = "enabled";
752     }
753   }
756   /* Save to LDAP */
757   function save()
758   {
760     $needupdate=TRUE;
761     $istemplate=FALSE;
764 /*       print "<pre>".print_r($this->attrs, true)."</pre>";*/
767     /*First at all, we must check if this is new or is updated */
768     /*Also check is we have a template, if is a template, is a new user */
769     if (isset($this->attrs['objectClass'])){
770       foreach ($this->attrs['objectClass'] as $object){
771         if($object=="OXUserObject") $needupdate=FALSE;
772         if($object=="gosaUserTemplate") $istemplate=TRUE;
773       }
774     }
776         $uidarray=array();
777         preg_match("/^(\w+(?=\=))=((\w|\s)+(?=\,)),.*/",$this->dn,$uidarray);
778         $uid=$uidarray[2];
779     
780     if ($istemplate) $needupdate=TRUE;
782     if($needupdate){
783       /* Trying to open a Postgresql Database Server */
784       if (function_exists("pg_connect")){
785         if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){
786           $pgcon = pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]);
787           if (! $pgcon){
788             print_red(_("Couldn't connect to postgresql database!"));
789             return;
790           }
791         }else{
792           print_red(_("Needed parameters for openexchange connectivity plugin are missing!"));
793           return;
794         }
795       }else{
796         print_red(_("PHP4 module for postgresql database is missing!"));
797         return;
798       }
799     }
801     plugin::save();
803     /* Write back to ldap */
804     $ldap= $this->config->get_ldap_link();
805     $ldap->cd($this->dn);
806     $ldap->modify($this->attrs);
807     show_ldap_error($ldap->get_error());
809     /* Optionally execute a command after we're done */
810     $this->postcreate();
812     if($needupdate){
813       $ldap->create_missing_trees("ou=addr,".$this->dn);
814       show_ldap_error($ldap->get_error());
815       /* Finally save data to postgresql server */
816       pg_set_client_encoding ("UNICODE");
817       $nv = "SELECT nextval ('serial_id')";
818       $ot = "insert into oxfolder_tree (fuid, parent, fname, module, type, owner, creator, creating_date, created_from, changing_date, changed_from) VALUES (%d, 1, '%s', '%s', 'private', '%s', '%s', 'now', 'System', 'now', 'System')";
819       $op = "INSERT INTO oxfolder_permissions (puid, pid, role, entity, sealed, fp, orp, owp, odp) VALUES (%d, %d, 32768,  '%s', 0, 128, 128, 128, 128)";
820       $os = "insert into oxfolder_standardfolders (owner,module_calendar,module_contact,module_task) VALUES ('%s',%d,%d,%d)";
821       $ugr= "INSERT INTO usr_general_rights SELECT creating_date, created_from, changing_date, changed_from,text('%s'),  addr_u, addr_r, addr_d, cont_u, cont_r, cont_d, data_u, data_r, data_d, serie_u, serie_r, serie_d, task_u, task_r, task_d,  refer, proj_u, proj_r, proj_d, dfolder_u, dfolder_r, dfolder_d, doc_u, doc_r, doc_d, knowl_u, knowl_r, knowl_d, bfolder_u,  bfolder_r, bfolder_d, bookm_u, bookm_r, bookm_d, pin_u, pin_r, pin_d, forum_n, fentrie_n, setup, pin_public, internal,  int_groups, kfolder_u, kfolder_r, kfolder_d, webmail FROM sys_gen_rights_template WHERE login LIKE 'default_template'";
823       $res=pg_exec($pgcon,$nv); $calendarid=pg_fetch_row($res); pg_freeresult($res);
824       $q=sprintf($ot,$calendarid[0],'My Appointments','calendar',$uid,$uid);
825       pg_exec($pgcon,$q);
826       $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
827       $q=sprintf($op,$nid[0],$calendarid[0],$uid);
828       pg_exec($pgcon,$q);
829       $res=pg_exec($pgcon,$nv); $contactsid=pg_fetch_row($res); pg_freeresult($res);
830       $q=sprintf($ot,$contactsid[0],'My Contacts','contact',$uid,$uid);
831       pg_exec($pgcon,$q);
832       $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
833       $q=sprintf($op,$nid[0],$contactsid[0],$uid);
834       pg_exec($pgcon,$q);
835       $res=pg_exec($pgcon,$nv); $tasksid=pg_fetch_row($res); pg_freeresult($res);
836       $q=sprintf($ot,$tasksid[0],'My Tasks','task',$uid,$uid);
837       pg_exec($pgcon,$q);
838       $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
839       $q=sprintf($op,$nid[0],$tasksid[0],$uid);
840       pg_exec($pgcon,$q);
841       $q=sprintf($os,$uid,$calendarid[0],$contactsid[0],$tasksid[0]);
842       pg_exec($pgcon,$q);
843       $q=sprintf($ugr,$uid);
844       pg_exec($pgcon,$q);
845       pg_close($pgcon);
846     }
847   }
850 ?>