You are here

function cmis_headerswing_cmis_invoke in CMIS API 6.4

Same name and namespace in other branches
  1. 7.2 cmis_headerswing/cmis_headerswing.module \cmis_headerswing_cmis_invoke()
  2. 7 cmis_headerswing/cmis_headerswing.module \cmis_headerswing_cmis_invoke()

Implementation of hook_cmis_invoke($url, $properties, $settings)

$conf example: $conf['cmis_repositories'] = array( 'default' => array( 'user' => 'admin', 'password' => 'admin', 'label' => 'local cmis repo', 'url' => 'http://127.0.0.1:8080/cmis', 'transport' => 'cmis_headerswing', 'headerswing_headers' => array( 'HTTP_HOST' => 'FRONTENT_HOST', 'HTTP_HOST' => 'FRONTENT_HOST_AGAIN', 'HTTP_USER' => 'FRONTENT_USER', 'PHP_AUTH_USER' => 'FRONTENT_USER' 'PHP_AUTH_DIGEST' => 'FRONTEND_AUTH' ) ), ... );

File

cmis_headerswing/cmis_headerswing.module, line 26

Code

function cmis_headerswing_cmis_invoke($url, $properties, $settings) {
  if (array_key_exists('headerswing_headers', $settings)) {
    if (!array_key_exists('headers', $properties)) {
      $properties['headers'] = array();
    }
    foreach ($settings['headerswing_headers'] as $header_src => $header_dest) {
      if (array_key_exists($header_src, $_SERVER)) {
        $properties['headers'][$header_dest] = $_SERVER[$header_src];
      }
    }
  }

  /* example on how to decorate cmis_common_cmis_invoke() method:
    $retval = cmis_common_cmis_invoke($url, $properties, $settings, TRUE);

    // ...
    // do some custom code here, before doing the actual call
    // ...

    // execute curl session. These fields are mandatory in order to
    // get a working hook_cmis_invoke() implementation.
    $retval->body = curl_exec($retval->curl_session);
    $retval->code = curl_getinfo($retval->curl_session, CURLINFO_HTTP_CODE);
    $retval->content_type = curl_getinfo($retval->curl_session, CURLINFO_CONTENT_TYPE);
    $retval->content_length = curl_getinfo($retval->curl_session, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
    curl_close($retval->curl_session);

    return $retval;
    */
  return cmis_common_cmis_invoke($url, $properties, $settings);
}