Rev 1194 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1194 | Rev 1215 | ||
|---|---|---|---|
| Line 18... | Line 18... | ||
| 18 | echo getMeetingsRestOfDay($_GET["shortname"]); |
18 | echo getMeetingsRestOfDay($_GET["shortname"]); |
| 19 | } |
19 | } |
| 20 | break; |
20 | break; |
| 21 | 21 | ||
| 22 | case "bookMeeting": |
22 | case "bookMeeting": |
| 23 | if (isset($_GET["from"]) && isset($_GET["to"])) |
23 | if (isset($_GET["from"]) && isset($_GET["to"]) && isset($_GET["shortname"])) |
| 24 | { |
24 | { |
| - | 25 | if (preg_match("/^\d\d:\d\d$/", $_GET["from"]) && preg_match("/^\d\d:\d\d$/", $_GET["to"])) |
|
| 25 | 26 | { |
|
| - | 27 | echo bookMeeting($_GET["shortname"], $_GET["from"], $_GET["to"]); |
|
| - | 28 | } |
|
| 26 | } |
29 | } |
| 27 | break; |
30 | break; |
| 28 | 31 | ||
| 29 | //case "": |
32 | //case "": |
| 30 | // |
33 | // |
| 31 | //break; |
34 | //break; |
| 32 | } |
35 | } |
| 33 | } |
36 | } |
| - | 37 | ||
| 34 | 38 | ||
| 35 | /* |
39 | /* |
| - | 40 | Book meeting |
|
| - | 41 | Return a JSON formed string with the result |
|
| - | 42 | */ |
|
| - | 43 | function bookMeeting($shortname, $bookFrom, $bookTo) |
|
| - | 44 | { |
|
| - | 45 | global $Calender; |
|
| - | 46 | global $wsdl; |
|
| - | 47 | $founditem = false; |
|
| - | 48 | ||
| - | 49 | foreach($Calender as $item) |
|
| - | 50 | { |
|
| - | 51 | if ($item->Shortname == $shortname) |
|
| - | 52 | { |
|
| - | 53 | $founditem = $item; |
|
| - | 54 | break; |
|
| - | 55 | } |
|
| - | 56 | } |
|
| - | 57 | ||
| - | 58 | if ($founditem !== false) |
|
| - | 59 | { |
|
| 36 | $CreateItem->SendMeetingInvitations = "SendToNone"; |
60 | $CreateItem->SendMeetingInvitations = "SendToNone"; |
| 37 | $CreateItem->SavedItemFolderId->DistinguishedFolderId->Id = "calendar"; |
61 | $CreateItem->SavedItemFolderId->DistinguishedFolderId->Id = "calendar"; |
| 38 | $CreateItem->Items->CalendarItem = array(); |
62 | $CreateItem->Items->CalendarItem = array(); |
| 39 |
|
63 | $CreateItem->Items->CalendarItem[0]->Subject = "Booking from panel"; |
| - | 64 | /* Dont forget to use the proper timezone and setting for daylight saving time (php handles this fine) */ |
|
| 40 |
|
65 | $CreateItem->Items->CalendarItem[0]->Start = date("c",strtotime($bookFrom)); // "2009-05-22T17:00:00Z" ISO date format. Z denotes UTC time |
| 41 |
|
66 | $CreateItem->Items->CalendarItem[0]->End = date("c",strtotime($bookTo)); |
| 42 | $CreateItem->Items->CalendarItem[0]->IsAllDayEvent = false; |
67 | $CreateItem->Items->CalendarItem[0]->IsAllDayEvent = false; |
| 43 | $CreateItem->Items->CalendarItem[0]->LegacyFreeBusyStatus = "Busy"; |
68 | $CreateItem->Items->CalendarItem[0]->LegacyFreeBusyStatus = "Busy"; |
| 44 |
|
69 | $CreateItem->Items->CalendarItem[0]->Location = $founditem->Shortname; |
| 45 |
|
70 | $CreateItem->Items->CalendarItem[0]->Categories->String = "Meeting"; |
| - | 71 | ||
| - | 72 | stream_wrapper_unregister('https'); |
|
| - | 73 | stream_wrapper_register('https', 'NTLMStream') or die("Failed to register protocol"); |
|
| - | 74 | ||
| - | 75 | try |
|
| - | 76 | { |
|
| - | 77 | $client = new ExchangeNTLMSoapClient($wsdl); |
|
| - | 78 | $client->user = $founditem->UserName; |
|
| - | 79 | $client->pass = $founditem->Password; |
|
| 46 | $result = $client->CreateItem($CreateItem); |
80 | $result = $client->CreateItem($CreateItem); |
| - | 81 | if ($result) |
|
| - | 82 | { |
|
| 47 |
|
83 | //print_array($result); |
| - | 84 | if ($result->ResponseMessages->CreateItemResponseMessage->ResponseClass == "Success") |
|
| - | 85 | { |
|
| - | 86 | $returndata = "{ result:'success',\nshortname:'".$shortname."'}\n"; |
|
| - | 87 | } |
|
| - | 88 | else |
|
| - | 89 | { |
|
| - | 90 | $errorcode=$result->ResponseMessages->CreateItemResponseMessage->MessageText; |
|
| - | 91 | $returndata = "{ result:'error',\nerror:'".$errorcode."',\nshortname:'".$shortname."'}\n"; |
|
| - | 92 | } |
|
| - | 93 | } |
|
| - | 94 | else |
|
| - | 95 | { |
|
| - | 96 | $returdata = "{ error:'No result',\nshortname:'".$shortname."'}\n"; |
|
| - | 97 | } |
|
| - | 98 | ||
| - | 99 | } |
|
| - | 100 | catch (SoapFault $exception) |
|
| - | 101 | { |
|
| - | 102 | $returdata = "{ error:'".$exception."',\nshortname:'".$shortname."'}\n"; |
|
| - | 103 | } |
|
| - | 104 | ||
| - | 105 | stream_wrapper_restore('https'); |
|
| - | 106 | return $returndata; |
|
| - | 107 | } |
|
| - | 108 | else |
|
| - | 109 | { |
|
| - | 110 | return "{ error:'Unknown shortname',\nshortname:'".$shortname."'}\n"; |
|
| - | 111 | } |
|
| - | 112 | } |
|
| - | 113 | ||
| - | 114 | ||
| - | 115 | /* |
|
| - | 116 | ||
| - | 117 | stdClass Object |
|
| - | 118 | ( |
|
| - | 119 | [ResponseMessages] => stdClass Object |
|
| - | 120 | ( |
|
| - | 121 | [CreateItemResponseMessage] => stdClass Object |
|
| - | 122 | ( |
|
| - | 123 | [ResponseCode] => NoError |
|
| - | 124 | [ResponseClass] => Success |
|
| - | 125 | [Items] => stdClass Object |
|
| - | 126 | ( |
|
| - | 127 | [CalendarItem] => stdClass Object |
|
| - | 128 | ( |
|
| - | 129 | [ItemId] => stdClass Object |
|
| - | 130 | ( |
|
| - | 131 | [Id] => |
|
| - | 132 | AAAcAEVudGVyLktvbmZlcmVuc3J1bUBxcnRlY2guc2UARgAAAAAAWx3xkPMlnUyMluTTqIdb4AcAdM/rfM3YaEeMsdYGn8jOeAAAAClWOAAAK68xOGjBUkCXHxa/+2eMqAAah/ErtAAA |
|
| - | 133 | [ChangeKey] => DwAAABYAAAArrzE4aMFSQJcfFr/7Z4yoABqH8Tu3 |
|
| - | 134 | ) |
|
| - | 135 | ) |
|
| - | 136 | ) |
|
| - | 137 | ) |
|
| - | 138 | ) |
|
| - | 139 | ) |
|
| - | 140 | ||
| - | 141 | stdClass Object |
|
| - | 142 | ( |
|
| - | 143 | [ResponseMessages] => stdClass Object |
|
| - | 144 | ( |
|
| - | 145 | [CreateItemResponseMessage] => stdClass Object |
|
| - | 146 | ( |
|
| - | 147 | [MessageText] => EndDate is earlier than StartDate |
|
| - | 148 | [ResponseCode] => ErrorCalendarEndDateIsEarlierThanStartDate |
|
| - | 149 | [DescriptiveLinkKey] => 0 |
|
| - | 150 | [ResponseClass] => Error |
|
| - | 151 | [Items] => stdClass Object |
|
| - | 152 | ( |
|
| - | 153 | ) |
|
| - | 154 | ) |
|
| - | 155 | ) |
|
| - | 156 | ) |
|
| 48 | */ |
157 | */ |
| - | 158 | ||
| - | 159 | ||
| 49 | 160 | ||
| 50 | /* |
161 | /* |
| 51 | Get all meetings from now and 9 hours later |
162 | Get all meetings from now and 9 hours later |
| 52 | Return a JSON formed string |
163 | Return a JSON formed string |
| 53 | */ |
164 | */ |
| Line 79... | Line 190... | ||
| 79 | stream_wrapper_unregister('https'); |
190 | stream_wrapper_unregister('https'); |
| 80 | stream_wrapper_register('https', 'NTLMStream') or die("Failed to register protocol"); |
191 | stream_wrapper_register('https', 'NTLMStream') or die("Failed to register protocol"); |
| 81 | 192 | ||
| 82 | $returndata = "{ \n\tshortname:'".$shortname."',\n\tmeetings:[\n"; |
193 | $returndata = "{ \n\tshortname:'".$shortname."',\n\tmeetings:[\n"; |
| 83 | try |
194 | try |
| 84 | { |
195 | { |
| 85 | $client = new ExchangeNTLMSoapClient($wsdl); |
196 | $client = new ExchangeNTLMSoapClient($wsdl); |
| 86 | $client->user = $founditem->UserName; |
197 | $client->user = $founditem->UserName; |
| 87 | $client->pass = $founditem->Password; |
198 | $client->pass = $founditem->Password; |
| 88 | $result = $client->FindItem($FindItem); |
199 | $result = $client->FindItem($FindItem); |
| 89 | if ($result) |
200 | if ($result) |
| Line 101... | Line 212... | ||
| 101 | { |
212 | { |
| 102 | $item = $calendaritems; |
213 | $item = $calendaritems; |
| 103 | } |
214 | } |
| 104 | $returndata .= "\t\t{\n"; |
215 | $returndata .= "\t\t{\n"; |
| 105 | $returndata .= "\t\torganizer:'".$item->Organizer->Mailbox->Name."',\n"; |
216 | $returndata .= "\t\torganizer:'".$item->Organizer->Mailbox->Name."',\n"; |
| - | 217 | $returndata .= "\t\tsubject:'".$item->Subject."',\n"; |
|
| 106 | $returndata .= "\t\tstart:'".date("G:i", strtotime($item->Start))."',\n"; |
218 | $returndata .= "\t\tstart:'".date("G:i", strtotime($item->Start))."',\n"; |
| 107 | $returndata .= "\t\tend:'".date("G:i", strtotime($item->End))."'\n"; |
219 | $returndata .= "\t\tend:'".date("G:i", strtotime($item->End))."'\n"; |
| 108 | $returndata .= "\t\t}"; |
220 | $returndata .= "\t\t}"; |
| 109 | if ($i+1 < count($calendaritems)) |
221 | if ($i+1 < count($calendaritems)) |
| 110 | { |
222 | { |
| 111 | $returndata .= ",\n"; |
223 | $returndata .= ",\n"; |
| 112 | } |
224 | } |
| 113 | } |
225 | } |
| 114 | } |
226 | } |
| - | 227 | else |
|
| 115 | 228 | { |
|
| - | 229 | return "{ error:'No result',\nshortname:'".$shortname."'}\n"; |
|
| - | 230 | } |
|
| 116 | } |
231 | } |
| 117 | catch (SoapFault $exception) |
232 | catch (SoapFault $exception) |
| 118 | { |
233 | { |
| 119 | return "{ error:'".$exception."',\nshortname:'".$shortname."'}\n"; |
234 | return "{ error:'".$exception."',\nshortname:'".$shortname."'}\n"; |
| 120 | } |
235 | } |