Autor Zpráva
Chuchycek
Profil
Zdravím,

nevím jestli to patří zrovna sem, ale chtěl jsem se zeptat jestli by mi někdo mohl poradit od někoho, kdo už to třeba někdy dělal nebo prostě ví. Snažím se vypsat exchange kalendáře události k danému termínu, jenže nevím jak zjistím jejich počet nebo přímo je z objektu. Jinak mi všechno funguje události do kalendáře přidám, jen je nedokážu vypsat. :(

A ano zkoušel jsem googlit... :D

Práce s objektem:
$response  = $ews -> listCalendarEvent();

listCalendarEvent
public function listCalendarEvent($id=null, $start=null, $end=null, $onbehalf=null){
        $type = "CALENDAR";
        return $this->listItems($type, $id, $start, $end, $onbehalf);
    }

listItems:
public function listItems($type, $id=null, $start=null, $end=null, $on_behalf=null){

            
        //by id
        if($id){
            // Form the GetItem request
            $request = new EWSType_GetItemType();            
            // Define which item properties are returned in the response
            $itemProperties = new EWSType_ItemResponseShapeType();
            $itemProperties->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
            
            // Add properties shape to request
            $request->ItemShape = $itemProperties;
            
            // Set the itemID of the desired item to retrieve
            $item_id = new EWSType_ItemIdType();
            $item_id->Id = $id;
            $request->ItemIds->ItemId = $item_id;
            
            //  Send the listing (find) request and get the response
            $response = $this->ews->GetItem($request);            
        }
        //by date
        else{
            $request = new EWSType_FindItemType();
            $request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;    
            
            $request->ItemShape = new EWSType_ItemResponseShapeType();
            $request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
            
            switch($type){
                case "CALENDAR" :
                $request->CalendarView = new EWSType_CalendarViewType();
                $request->CalendarView->StartDate = date('c', $start);
                $request->CalendarView->EndDate = date('c', $end);
                break;
                case "TASKS" :
                //do we have start date?
                $start = $start ? $start : 0;
                //do we have and date?
                $end = $end ? $end : mktime(0, 0, 0, 1, 1, 2038);
                print_r(array($start, $end));
                //create AND restrction
                $request->Restriction = new EWSType_RestrictionType();
                $request->Restriction->And = new EWSType_AndType();
                
                $request->Restriction->And->IsGreaterThanOrEqualTo = new EWSType_IsGreaterThanOrEqualToType();
                $request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI = new EWSType_PathToExtendedFieldType;
                $request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI->DistinguishedPropertySetId = "Task";
                $request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI->PropertyId = "33029";
                $request->Restriction->And->IsGreaterThanOrEqualTo->ExtendedFieldURI->PropertyType = "SystemTime";
                $request->Restriction->And->IsGreaterThanOrEqualTo->FieldURIOrConstant->Constant->Value = date('c', $start);
                
                $request->Restriction->And->IsLessThanOrEqualTo = new EWSType_IsLessThanOrEqualToType();
                $request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI = new EWSType_PathToExtendedFieldType;
                $request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI->DistinguishedPropertySetId = "Task";
                $request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI->PropertyId = "33029";
                $request->Restriction->And->IsLessThanOrEqualTo->ExtendedFieldURI->PropertyType = "SystemTime";
                $request->Restriction->And->IsLessThanOrEqualTo->FieldURIOrConstant->Constant->Value = date('c', $end);
                break;
            }
            // configure the view
            //$request->IndexedPageFolderView = new EWSType_IndexedPageViewType();
            //$request->IndexedPageFolderView->BasePoint = EWSType_IndexBasePointType::BEGINNING;
            //$request->IndexedPageFolderView->Offset = 0;
            /*
            $request->Restriction = new EWSType_RestrictionType();
            $request->Restriction->IsLessThanOrEqualTo = new EWSType_IsLessThanOrEqualToType();
            $request->Restriction->IsLessThanOrEqualTo->ExtendedFieldURI = new EWSType_PathToExtendedFieldType;
            $request->Restriction->IsLessThanOrEqualTo->ExtendedFieldURI->DistinguishedPropertySetId = "Task";
            $request->Restriction->IsLessThanOrEqualTo->ExtendedFieldURI->PropertyId = "33029";
            $request->Restriction->IsLessThanOrEqualTo->ExtendedFieldURI->PropertyType = "SystemTime";
            $request->Restriction->IsLessThanOrEqualTo->FieldURIOrConstant->Constant->Value = date('c', $start);
            */
            
            $request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
            $request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
            $request->ParentFolderIds->DistinguishedFolderId->Id = constant("EWSType_DistinguishedFolderIdNameType::".$type);
            if($on_behalf)
                $request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $on_behalf;            
    
            //make the call
            //print_r($request); //die();
            $response = $this->ews->FindItem($request);
        }
        
        return $response;
    }


Edit:

Todle dostanu z objektu, ještě v nich nejsem tak zběhlí a potřeboval bych aspon, aby mi to vrátilo ten počet, což jsou v tomto případě dva.

stdClass Object ( [ResponseMessages] => stdClass Object ( [FindItemResponseMessage] => stdClass Object ( [ResponseCode] => NoError [ResponseClass] => Success [RootFolder] => stdClass Object ( [Items] => stdClass Object ( [CalendarItem] => Array ( [0] => stdClass Object ( [ItemId] => stdClass Object ( [Id] => AAMkADU2ZGYzZmU5LWEwZDUtNGI0NS1hNTVlLTM0MDQxMTU2ZjczMQBGAAAAAACCC4uHeXWLRbHfIwM9OmioBwCqnZmq0uOvSaqVpmyZmWWeAAAAAAWMAAAhVfa4tGbjT6DM/69ZxQBRAAAAAAP1AAA= [ChangeKey] => DwAAABYAAAAhVfa4tGbjT6DM/69ZxQBRAAAAAC/c ) [Subject] => Test subject [HasAttachments] => [Start] => 2012-06-08T11:00:00Z [End] => 2012-06-08T12:00:00Z [LegacyFreeBusyStatus] => Free [CalendarItemType] => Single [Organizer] => stdClass Object ( [Mailbox] => stdClass Object ( [Name] => Jmeno Prijmeni ) ) ) [1] => stdClass Object ( [ItemId] => stdClass Object ( [Id] => AAMkADU2ZGYzZmU5LWEwZDUtNGI0NS1hNTVlLTM0MDQxMTU2ZjczMQBGAAAAAACCC4uHeXWLRbHfIwM9OmioBwCqnZmq0uOvSaqVpmyZmWWeAAAAAAWMAAAhVfa4tGbjT6DM/69ZxQBRAAAAAAP0AAA= [ChangeKey] => DwAAABYAAAAhVfa4tGbjT6DM/69ZxQBRAAAAAC/C ) [Subject] => Test subject [HasAttachments] => [Start] => 2012-06-08T15:30:00Z [End] => 2012-06-08T16:30:00Z [LegacyFreeBusyStatus] => Free [CalendarItemType] => Single [Organizer] => stdClass Object ( [Mailbox] => stdClass Object ( [Name] => Jmeno Prijmeni ) ) ) ) ) [IncludesLastItemInRange] => 1 [TotalItemsInView] => 2 ) ) ) )
Chuchycek
Profil
Tak jsem na to přišel sám, můžete lock.
nemeja
Profil
Nemohl by jsi nám prosím říct, jak jsi to vyřešil až někdo jinej bude mít podobnej problém. :)
Chuchycek
Profil
Můžu.

Do konečnýho výpisu jsem připsal
$response  = $ews -> listCalendarEvent();
$pocet = $response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView;
Chuchycek
Profil
A mám tu ještě jeden problém, v pátek mi to v pohodě celý fungovalo, ale dneska nic. V pohodě se spojím se serverem, ale žádný dotaz jako je vkládání, čtení, mazání mi nefunguje. Nevíte někdo, kde by mohl být problém, když jsem skripty nijak neupravoval?


Např. chci vložit úkol, ale z $response nedostanu nic, pouze z $request.
    public function addTask($subject, $on_behalf, $due, $body=null, $reminderdue=null, $reminderStart="30", $importance="NORMAL", $sensitivity="NORMAL", $bodytype="TEXT", $category="default"){

        $request = new EWSType_CreateItemType();
        $request->SavedItemFolderId->DistinguishedFolderId->Id =EWSType_DistinguishedFolderIdNameType::TASKS; 
        if($on_behalf)
            $request->SavedItemFolderId->DistinguishedFolderId->Mailbox->EmailAddress = $on_behalf;
        $request->Items->Task->Subject = $subject;
        if($body){
            $request->Items->Task->Body->BodyType = constant("EWSType_BodyTypeResponseType::".$bodytype);
            $request->Items->Task->Body->_ = $body;
        }
        $request->Items->Task->Sensitivity = constant("EWSType_SensitivityChoicesType::".$sensitivity);
        $request->Items->Task->Categories->String = $category;
        $request->Items->Task->Importance = constant("EWSType_ImportanceChoicesType::".$importance);
        if($reminderdue){
            $request->Items->Task->ReminderDueBy = date('c',  $reminderdue);
            $request->Items->Task->ReminderMinutesBeforeStart = $reminderStart;
            $request->Items->Task->ReminderIsSet = "true";
        }
        $request->Items->Task->DueDate = date('c',  $due);
        
        
        //make the call
        $response = $this->ews->CreateItem($request);        
        
        return $response;

    }

Z $request

EWSType_CreateItemType Object ( [SavedItemFolderId] => stdClass Object ( [DistinguishedFolderId] => stdClass Object ( [Id] => tasks [Mailbox] => stdClass Object ( [EmailAddress] => jmeno.prijmeni@provocado.cz ) ) ) [Items] => stdClass Object ( [Task] => stdClass Object ( [Subject] => Very Important Task [Body] => stdClass Object ( [BodyType] => Text [_] => Sample task description ) [Sensitivity] => Normal [Categories] => stdClass Object ( [String] => default ) [Importance] => Normal [ReminderDueBy] => 2012-06-12T10:59:58+02:00 [ReminderMinutesBeforeStart] => 30 [ReminderIsSet] => true [DueDate] => 2012-06-12T09:59:58+02:00 ) ) [MessageDisposition] => [SendMeetingInvitations] => [schema:protected] => Array ( [0] => Array ( [name] => SavedItemFolderId [required] => [type] => TargetFolderIdType ) [1] => Array ( [name] => Items [required] => [type] => NonEmptyArrayOfAllItemsType ) [2] => Array ( [name] => MessageDisposition [required] => [type] => MessageDispositionType ) [3] => Array ( [name] => SendMeetingInvitations [required] => [type] => CalendarItemCreateOrDeleteOperationType ) ) )


    public function CreateItem($request) {
        $request->getAsSOAP();
        return $this->initializeSoapClient()->{__FUNCTION__}($request);
    } // end function CreateItem()

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: