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