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