You are here

public function SocialContentLinkedin::prepareRow in Social Content 7.2

Do the uploads and attach expected fields to a row about to be imported.

Overrides SocialContent::prepareRow

File

modules/linkedin/social_content_linkedin.class.inc, line 232
Social Content Linkedin class.

Class

SocialContentLinkedin
@file Social Content Linkedin class.

Code

public function prepareRow($row) {
  $mappings = $this
    ->getFieldMappings();
  if (isset($row->updateContent)) {

    // Status update.
    $row->id = $row->updateContent->companyStatusUpdate->share->id;
    $row->caption = $row->updateContent->companyStatusUpdate->share->comment;
    $row->created = $row->updateContent->companyStatusUpdate->share->timestamp / 1000;
    $row->account_id = $row->updateContent->company->id;
    $row->account_name = $row->updateContent->company->name;
    if (parent::prepareRow($row) === FALSE) {
      return FALSE;
    }

    // @todo: Company name.
    $row->account_link = 'https://www.linkedin.com/company/' . $row->account_id;
    $row->link = $row->updateContent->companyStatusUpdate->share->content->submittedUrl;
    $global_settings = $this->settings['global'];
    $row->update_link = $global_settings['update_url'] . explode('-', $row->updateKey)[2];
    $image_url = $row->updateContent->companyStatusUpdate->share->content->submittedImageUrl;
    if ($image_url) {
      $picture = $this
        ->saveExternalFile($image_url, $mappings['picture']);
      $row->picture = $picture ? $picture : NULL;
    }

    //@todo: Link preview.
    return TRUE;
  }
  return FALSE;
}