1fddc4935acb993eaf51c7c4f1988d5cd9bbfbb8
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 {
601 /* Show tab dialog headers */
602 $display= "";
604 /* Show main page */
605 $smarty= get_smarty();
607 if (function_exists("pg_connect")){
608 $smarty->assign("pg", true);
609 }else{
610 $smarty->assign("pg", false);
611 }
613 /* Load attributes */
614 foreach($this->attributes as $val){
615 $smarty->assign("$val", $this->$val);
616 $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
617 }
618 $smarty->assign("oxchangeAccountACL", chkacl($this->acl, "oxchangeAccount"));
619 if ($this->is_account){
620 $smarty->assign("oxchangeState", "checked");
621 } else {
622 $smarty->assign("oxchangeState", "");
623 }
625 $smarty->assign("timezones", $this->timezones);
628 if ($this->parent != NULL){
629 $smarty->assign("tabbed", 1);
630 }
632 $display.= $smarty->fetch (get_template_path('oxchange.tpl', TRUE, dirname(__FILE__)));
633 return ($display);
634 }
636 function remove_from_parent()
637 {
638 $sqldeluser=array(
639 "delete from prg_notes where (user_right like '".$this->attrs[$this->dnmode][0]."') and (group_right like 's')",
640 "delete from prg_documents_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
641 "delete from prg_documents_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
642 "delete from prg_docufolders_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
643 "delete from prg_docufolders_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
644 "delete from prg_date_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')",
645 "delete from prg_date_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
646 "delete from prg_dates_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
647 "delete from prg_knowledge_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
648 "delete from prg_knowledge_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
649 "delete from prg_knowledge_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
650 "delete from prg_knowledge_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
651 "delete from prg_pin_board_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
652 "delete from prg_pin_board_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
653 "delete from prg_bookmarks_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
654 "delete from prg_bookmarks_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
655 "delete from prg_bookmarks_folder_read where (user_right like '".$this->attrs[$this->dnmode][0]."')",
656 "delete from prg_bookmarks_folder_mod where (user_right like '".$this->attrs[$this->dnmode][0]."')",
657 "delete from prg_tasks_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')",
658 "delete from prg_tasks_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
659 "delete from prg_tasks_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
660 "delete from prg_projects_rights where (user_right like '".$this->attrs[$this->dnmode][0]."')",
661 "delete from prg_projects_notification where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
662 "delete from prg_projects_members where (member_uid like '".$this->attrs[$this->dnmode][0]."')",
663 "delete from oxfolder_permissions where (entity like '".$this->attrs[$this->dnmode][0]."') AND ((role = 256) OR (role = 1024))",
664 "delete from oxfolder_standardfolders where owner like '".$this->attrs[$this->dnmode][0]."'",
665 "delete from prg_forum_read where user_right = '".$this->attrs[$this->dnmode][0]."'",
666 "delete from prg_forum_mod where user_right = '".$this->attrs[$this->dnmode][0]."'",
667 "delete from prg_forum_abo where user_right = '".$this->attrs[$this->dnmode][0]."'",
668 "delete from prg_forum_seen where username = '".$this->attrs[$this->dnmode][0]."'",
669 "delete from sys_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')",
670 "delete from usr_holiday where (userid like '".$this->attrs[$this->dnmode][0]."')");
672 /* Trying to open a Postgresql Database Server */
673 if (function_exists("pg_connect")){
674 if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){
675 $pgcon = pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]);
676 if (! $pgcon){
677 print_red(_("Couldn't Connect To Postgresql Database"));
678 return;
679 }
680 }else{
681 print_red(_("Needed Parameters to openexchange connectivity plugin failed!"));
682 return;
683 }
684 }else{
685 print_red(_("PHP4 module for Postgresql Database Failed!"));
686 return;
687 }
689 plugin::remove_from_parent();
690 $ldap= $this->config->get_ldap_link();
692 $ldap->cd($this->dn);
693 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
694 $this->attributes, "Save");
695 $ldap->modify($this->attrs);
696 show_ldap_error($ldap->get_error());
698 /* Optionally execute a command after we're done */
699 $this->postremove();
701 /* Finally remove data from postgresql server */
702 foreach ($sqldeluser as $sqls){
703 pg_exec($pgcon,$sqls);
704 }
705 pg_close();
706 }
708 /* Save data to object */
709 function save_object()
710 {
711 /* Do we need to flip is_account state? */
712 if (isset($_POST['connectivityTab'])){
713 if (isset($_POST['oxchange'])){
714 if (!$this->is_account && $_POST['oxchange'] == "B"){
715 $this->is_account= TRUE;
716 }
717 } else {
718 $this->is_account= FALSE;
719 }
720 }
722 plugin::save_object();
723 if (isset($_POST["oxchangeStatus"])){
724 $this->oxchangeStatus = "disabled";
725 } else {
726 $this->oxchangeStatus = "enabled";
727 }
728 }
731 /* Save to LDAP */
732 function save()
733 {
735 $needupdate=TRUE;
737 /*First at all, we must check if this is new or is updated */
738 foreach ($this->attrs['objectClass'] as $object){
739 if($object=="OXUserObject") $needupdate=FALSE;
740 }
742 if($needupdate){
743 /* Trying to open a Postgresql Database Server */
744 if (function_exists("pg_connect")){
745 if(isset($this->oxconf["PGUSER"]) and isset($this->oxconf["PGHOST"]) and isset($this->oxconf["PGDBNAME"]) and isset($this->oxconf["PGPASSWD"])){
746 $pgcon = pg_connect("host=".$this->oxconf["PGHOST"]." user=".$this->oxconf["PGUSER"]." password=".$this->oxconf["PGPASSWD"]." dbname=".$this->oxconf["PGDBNAME"]);
747 if (! $pgcon){
748 print_red(_("Couldn't Connect To Postgresql Database"));
749 return;
750 }
751 }else{
752 print_red(_("Needed Parameters to openexchange connectivity plugin failed!"));
753 return;
754 }
755 }else{
756 print_red(_("PHP4 module for Postgresql Database Failed!"));
757 return;
758 }
759 }
761 $uid=$this->attrs[$this->dnmode][0];
763 plugin::save();
765 /* Write back to ldap */
766 $ldap= $this->config->get_ldap_link();
767 $ldap->cd($this->dn);
768 $ldap->modify($this->attrs);
769 show_ldap_error($ldap->get_error());
771 /* Optionally execute a command after we're done */
772 $this->postcreate();
774 if($needupdate){
775 /* Finally save data to postgresql server */
776 pg_set_client_encoding ("UNICODE");
777 $nv = "SELECT nextval ('serial_id')";
778 $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')";
779 $op = "INSERT INTO oxfolder_permissions (puid, pid, role, entity, sealed, fp, orp, owp, odp) VALUES (%d, %d, 32768, '%s', 0, 128, 128, 128, 128)";
780 $os = "insert into oxfolder_standardfolders (owner,module_calendar,module_contact,module_task) VALUES ('%s',%d,%d,%d)";
781 $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'";
783 $res=pg_exec($pgcon,$nv); $calendarid=pg_fetch_row($res); pg_freeresult($res);
784 $q=sprintf($ot,$calendarid[0],'My Appointments','calendar',$uid,$uid);
785 pg_exec($pgcon,$q);
786 $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
787 $q=sprintf($op,$nid[0],$calendarid[0],$uid);
788 pg_exec($pgcon,$q);
789 $res=pg_exec($pgcon,$nv); $contactsid=pg_fetch_row($res); pg_freeresult($res);
790 $q=sprintf($ot,$contactsid[0],'My Contacts','contact',$uid,$uid);
791 pg_exec($pgcon,$q);
792 $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
793 $q=sprintf($op,$nid[0],$contactsid[0],$uid);
794 pg_exec($pgcon,$q);
795 $res=pg_exec($pgcon,$nv); $tasksid=pg_fetch_row($res); pg_freeresult($res);
796 $q=sprintf($ot,$tasksid[0],'My Tasks','task',$uid,$uid);
797 pg_exec($pgcon,$q);
798 $res=pg_exec($pgcon,$nv); $nid=pg_fetch_row($res); pg_freeresult($res);
799 $q=sprintf($op,$nid[0],$tasksid[0],$uid);
800 pg_exec($pgcon,$q);
801 $q=sprintf($os,$uid,$calendarid[0],$contactsid[0],$tasksid[0]);
802 pg_exec($pgcon,$q);
803 $q=sprintf($ugr,$uid);
804 pg_exec($pgcon,$q);
805 pg_close($pgcon);
806 }
807 }
808 }
810 ?>