Mercurial > defr > drupal > scald > dnd
comparison dnd.module @ 8:b9cd179a30a8
Use user session for the drupal_http_request requesting the library.
By default, drupal_http_request runs in a sandbox environment, thus the
request doesn't have any idea about the current user. This in turn means that
the request on the library is performed as an anonymous user, who may not have
appropriate credentials to access the library.
author | Franck Deroche <franck@defr.org> |
---|---|
date | Wed, 01 Apr 2009 15:49:44 +0200 |
parents | e6378dbabe45 |
children | a54d04d76554 |
comparison
equal
deleted
inserted
replaced
7:e6378dbabe45 | 8:b9cd179a30a8 |
---|---|
114 // application and keeps things nice and consistent. | 114 // application and keeps things nice and consistent. |
115 if (!($url = parse_url($settings['url']))) { | 115 if (!($url = parse_url($settings['url']))) { |
116 return t('This library is not available'); | 116 return t('This library is not available'); |
117 } | 117 } |
118 | 118 |
119 $headers = array(); | |
119 // Handle both relative and absolute urls | 120 // Handle both relative and absolute urls |
120 if (!isset($url['scheme'])) { | 121 if (!isset($url['scheme'])) { |
121 $settings['url'] = $base_url .'/'. $settings['url']; | 122 $settings['url'] = $base_url .'/'. $settings['url']; |
123 $headers['Cookie'] = session_name() .'='. session_id(); | |
122 } | 124 } |
123 | 125 |
124 $request = drupal_http_request($settings['url']); | 126 $request = drupal_http_request($settings['url'], $headers); |
125 | 127 |
126 // We must remove some Drupal escaping | 128 // We must remove some Drupal escaping |
127 $json = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $request->data), TRUE); | 129 $json = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $request->data), TRUE); |
128 | 130 |
129 // Generate an array of editor representations to add | 131 // Generate an array of editor representations to add |