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