示例#1
0
 public static function castDownActivityItem(Item $activityItem)
 {
     $relationModelClassNames = ActivitiesUtil::getActivityItemsModelClassNames();
     foreach ($relationModelClassNames as $relationModelClassName) {
         try {
             $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($relationModelClassName);
             return $activityItem->castDown(array($modelDerivationPathToItem));
         } catch (NotFoundException $e) {
         }
     }
 }
 /**
  * Get meeting attendees from activity items. It returns Contact, Opportunity or Account ids
  * @param $meeting
  * @return array
  * @throws Exception
  */
 protected static function getAttendeesFromActivityItems($meeting)
 {
     $data = array();
     $activityClassNames = ActivitiesUtil::getActivityItemsModelClassNames();
     try {
         foreach ($activityClassNames as $activityClassName) {
             foreach ($meeting->activityItems as $activityItem) {
                 try {
                     $modelDerivationPathToItem = RuntimeUtil::getModelDerivationPathToItem($activityClassName);
                     $castedDownModel = $activityItem->castDown(array($modelDerivationPathToItem));
                     $item = array();
                     $item['id'] = $castedDownModel->id;
                     if ($castedDownModel instanceof Contact) {
                         if ($castedDownModel->primaryEmail->emailAddress != null) {
                             $item['email'] = $castedDownModel->primaryEmail->emailAddress;
                         }
                         $item['firstName'] = $castedDownModel->firstName;
                         $item['lastName'] = $castedDownModel->lastName;
                     } elseif ($castedDownModel instanceof Account || $castedDownModel instanceof Opportunity) {
                         $item['name'] = $castedDownModel->name;
                     }
                     $data[$activityClassName][] = $item;
                 } catch (NotFoundException $e) {
                 }
             }
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
         throw new Exception($message);
     }
     return $data;
 }