drupal.patch 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. Fix Reverse Proxy Support:
  2. http://drupal.org/node/244593
  3. http://drupal.org/files/issues/drupal_80.patch
  4. Index: includes/bootstrap.inc
  5. --- includes/bootstrap.inc.orig 2008-02-11 15:36:21 +0100
  6. +++ includes/bootstrap.inc 2008-04-09 20:47:49 +0200
  7. @@ -272,6 +272,7 @@
  8. */
  9. function conf_init() {
  10. global $base_url, $base_path, $base_root;
  11. + global $base_url_local;
  12. // Export the following settings.php variables to the global namespace
  13. global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
  14. @@ -723,9 +724,22 @@
  15. * generate an equivalent using other environment variables.
  16. */
  17. function request_uri() {
  18. + global $base_url;
  19. + global $base_url_local;
  20. if (isset($_SERVER['REQUEST_URI'])) {
  21. $uri = $_SERVER['REQUEST_URI'];
  22. + if (isset($base_url) && isset($base_url_local)) {
  23. + $parts = parse_url($base_url_local);
  24. + if ( strlen($uri) >= strlen($base_url_local)
  25. + && substr($uri, 0, strlen($base_url_local)) == $base_url_local) {
  26. + $uri = $base_url . substr($uri, strlen($base_url_local));
  27. + }
  28. + elseif ( strlen($uri) >= strlen($parts["path"])
  29. + && substr($uri, 0, strlen($parts["path"])) == $parts["path"]) {
  30. + $uri = $base_url . substr($uri, strlen($parts["path"]));
  31. + }
  32. + }
  33. }
  34. else {
  35. if (isset($_SERVER['argv'])) {
  36. Index: sites/default/default.settings.php
  37. --- sites/default/default.settings.php.orig 2007-12-20 10:35:10 +0100
  38. +++ sites/default/default.settings.php 2008-04-09 20:47:32 +0200
  39. @@ -126,6 +126,24 @@
  40. # $base_url = 'http://www.example.com'; // NO trailing slash!
  41. /**
  42. + * Local Base URL (optional).
  43. + *
  44. + * If you are running Drupal behind a reverse proxy, $base_url (see above)
  45. + * usually points to the URL of the reverse proxy. Drupal uses this for
  46. + * all sorts of external URLs. In order to correctly calculate sub-URLs
  47. + * below $base_url for embedded HTML forms, Drupal also has to know the
  48. + * URL on the local/origin server under which Drupal is contacted by the
  49. + * reverse proxy. This is what $base_url_local is for.
  50. + *
  51. + * Examples:
  52. + * $base_url_local = 'http://www.example.com:8080/drupal';
  53. + *
  54. + * It is not allowed to have a trailing slash; Drupal will add it
  55. + * for you.
  56. + */
  57. +# $base_url_local = 'http://www.example.com:8080/drupal'; // NO trailing slash!
  58. +
  59. +/**
  60. * PHP settings:
  61. *
  62. * To see what PHP settings are possible, including whether they can
  63. -----------------------------------------------------------------------------
  64. 1. Support HTTP Proxies (mainly for update checks, RSS fetching, etc)
  65. http://drupal.org/node/7881
  66. http://drupal.org/files/issues/proxy_11.patch
  67. (post-adjusted and improved by RSE)
  68. 2. Fix CSS Cache Building Procedure
  69. http://drupal.org/node/275381
  70. http://drupal.org/files/issues/drupal-css-cache-building.patch
  71. (created by RSE)
  72. Index: includes/common.inc
  73. --- includes/common.inc.orig 2008-04-09 23:11:44 +0200
  74. +++ includes/common.inc 2008-06-26 20:16:16 +0200
  75. @@ -439,13 +439,27 @@
  76. case 'http':
  77. $port = isset($uri['port']) ? $uri['port'] : 80;
  78. $host = $uri['host'] . ($port != 80 ? ':'. $port : '');
  79. - $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
  80. + if (variable_get('proxy_server', '') != '') {
  81. + $proxy_server = variable_get('proxy_server', '');
  82. + $proxy_port = variable_get('proxy_port', 8080);
  83. + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
  84. + }
  85. + else {
  86. + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
  87. + }
  88. break;
  89. case 'https':
  90. // Note: Only works for PHP 4.3 compiled with OpenSSL.
  91. $port = isset($uri['port']) ? $uri['port'] : 443;
  92. $host = $uri['host'] . ($port != 443 ? ':'. $port : '');
  93. - $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
  94. + if (variable_get('proxy_server', '') != '') {
  95. + $proxy_server = variable_get('proxy_server', '');
  96. + $proxy_port = variable_get('proxy_port', 8080);
  97. + $fp = @fsockopen($proxy_server, $proxy_port, $errno, $errstr, 15);
  98. + }
  99. + else {
  100. + $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
  101. + }
  102. break;
  103. default:
  104. $result->error = 'invalid schema '. $uri['scheme'];
  105. @@ -462,9 +476,14 @@
  106. }
  107. // Construct the path to act on.
  108. - $path = isset($uri['path']) ? $uri['path'] : '/';
  109. - if (isset($uri['query'])) {
  110. - $path .= '?'. $uri['query'];
  111. + if (variable_get('proxy_server', '') != '') {
  112. + $path = $url;
  113. + }
  114. + else {
  115. + $path = isset($uri['path']) ? $uri['path'] : '/';
  116. + if (isset($uri['query'])) {
  117. + $path .= '?'. $uri['query'];
  118. + }
  119. }
  120. // Create HTTP request.
  121. @@ -482,6 +501,14 @@
  122. $defaults['Authorization'] = 'Authorization: Basic '. base64_encode($uri['user'] . (!empty($uri['pass']) ? ":". $uri['pass'] : ''));
  123. }
  124. + // If the proxy server required a username then attempt to authenticate with it
  125. + if (variable_get('proxy_username', '') != '') {
  126. + $username = variable_get('proxy_username', '');
  127. + $password = variable_get('proxy_password', '');
  128. + $auth_string = base64_encode($username . ($password != '' ? ':'. $password : ''));
  129. + $defaults['Proxy-Authorization'] = 'Proxy-Authorization: Basic '. $auth_string ."\r\n";
  130. + }
  131. +
  132. foreach ($headers as $header => $value) {
  133. $defaults[$header] = $header .': '. $value;
  134. }
  135. @@ -1805,7 +1832,7 @@
  136. $last = '';
  137. while ($path != $last) {
  138. $last = $path;
  139. - $path = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $path);
  140. + $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
  141. }
  142. return 'url('. $path .')';
  143. }
  144. Index: modules/system/system.admin.inc
  145. --- modules/system/system.admin.inc.orig 2008-03-25 12:58:16 +0100
  146. +++ modules/system/system.admin.inc 2008-04-24 11:43:07 +0200
  147. @@ -1363,6 +1363,65 @@
  148. }
  149. /**
  150. + * Form builder; Configure the site proxy settings.
  151. + *
  152. + * @ingroup forms
  153. + * @see system_settings_form()
  154. + */
  155. +function system_proxy_settings() {
  156. +
  157. + $form['forward_proxy'] = array(
  158. + '#type' => 'fieldset',
  159. + '#title' => t('Forward proxy settings'),
  160. + '#description' => t('The proxy server used when Drupal needs to connect to other sites on the Internet.'),
  161. + );
  162. + $form['forward_proxy']['proxy_server'] = array(
  163. + '#type' => 'textfield',
  164. + '#title' => t('Proxy host name'),
  165. + '#default_value' => variable_get('proxy_server', ''),
  166. + '#description' => t('The host name of the proxy server, eg. localhost. If this is empty Drupal will connect directly to the internet.')
  167. + );
  168. + $form['forward_proxy']['proxy_port'] = array(
  169. + '#type' => 'textfield',
  170. + '#title' => t('Proxy port number'),
  171. + '#default_value' => variable_get('proxy_port', 8080),
  172. + '#description' => t('The port number of the proxy server, eg. 8080'),
  173. + );
  174. + $form['forward_proxy']['proxy_username'] = array(
  175. + '#type' => 'textfield',
  176. + '#title' => t('Proxy username'),
  177. + '#default_value' => variable_get('proxy_username', ''),
  178. + '#description' => t('The username used to authenticate with the proxy server.'),
  179. + );
  180. + $form['forward_proxy']['proxy_password'] = array(
  181. + '#type' => 'textfield',
  182. + '#title' => t('Proxy password'),
  183. + '#default_value' => variable_get('proxy_password', ''),
  184. + '#description' => t('The password used to connect to the proxy server. This is kept as plain text.', '')
  185. + );
  186. + $form['#validate'][] = 'system_proxy_settings_validate';
  187. +
  188. + return system_settings_form($form);
  189. +}
  190. +
  191. +/**
  192. + * Validate the submitted proxy form.
  193. + */
  194. +function system_proxy_settings_validate($form, &$form_state) {
  195. + // Validate the proxy settings
  196. + $form_state['values']['proxy_server'] = trim($form_state['values']['proxy_server']);
  197. + if ($form_state['values']['proxy_server'] != '') {
  198. + // TCP allows the port to be between 0 and 65536 inclusive
  199. + if (!is_numeric($form_state['values']['proxy_port'])) {
  200. + form_set_error('proxy_port', t('The proxy port is invalid. It must be a number between 0 and 65535.'));
  201. + }
  202. + elseif ($form_state['values']['proxy_port'] < 0 || $form_state['values']['proxy_port'] >= 65536) {
  203. + form_set_error('proxy_port', t('The proxy port is invalid. It must be between 0 and 65535.'));
  204. + }
  205. + }
  206. +}
  207. +
  208. +/**
  209. * Form builder; Configure the site file handling.
  210. *
  211. * @ingroup forms
  212. Index: modules/system/system.module
  213. --- modules/system/system.module.orig 2008-04-09 23:11:49 +0200
  214. +++ modules/system/system.module 2008-04-24 11:43:47 +0200
  215. @@ -55,7 +55,7 @@
  216. $output .= '<li>'. t('support for enabling and disabling <a href="@themes">themes</a>, which determine the design and presentation of your site. Drupal comes packaged with several core themes and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/build/themes'), '@drupal-themes' => 'http://drupal.org/project/themes')) .'</li>';
  217. $output .= '<li>'. t('a robust <a href="@cache-settings">caching system</a> that allows the efficient re-use of previously-constructed web pages and web page components. Drupal stores the pages requested by anonymous users in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, Drupal\'s caching system may significantly increase the speed of your site.', array('@cache-settings' => url('admin/settings/performance'))) .'</li>';
  218. $output .= '<li>'. t('a set of routine administrative operations that rely on a correctly-configured <a href="@cron">cron maintenance task</a> to run automatically. A number of other modules, including the feed aggregator, ping module and search also rely on <a href="@cron">cron maintenance tasks</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>.', array('@cron' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron')) .'</li>';
  219. - $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
  220. + $output .= '<li>'. t('basic configuration options for your site, including <a href="@date-settings">date and time settings</a>, <a href="@file-system">file system settings</a>, <a href="@clean-url">clean URL support</a>, <a href="@proxy-server">proxy server settings</a>, a href="@site-info">site name and other information</a>, and a <a href="@site-maintenance">site maintenance</a> function for taking your site temporarily off-line.', array('@date-settings' => url('admin/settings/date-time'), '@file-system' => url('admin/settings/file-system'), '@clean-url' => url('admin/settings/clean-urls'), '@site-info' => url('admin/settings/site-information'), '@site-maintenance' => url('admin/settings/site-maintenance'))) .'</li></ul>';
  221. $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/handbook/modules/system/')) .'</p>';
  222. return $output;
  223. case 'admin':
  224. @@ -406,6 +406,14 @@
  225. 'access arguments' => array('administer site configuration'),
  226. 'file' => 'system.admin.inc',
  227. );
  228. + $items['admin/settings/proxy'] = array(
  229. + 'title' => 'Proxy server',
  230. + 'description' => 'Configure settings when the site is behind a proxy server.',
  231. + 'page callback' => 'drupal_get_form',
  232. + 'page arguments' => array('system_proxy_settings'),
  233. + 'access arguments' => array('administer site configuration'),
  234. + 'file' => 'system.admin.inc',
  235. + );
  236. $items['admin/settings/file-system'] = array(
  237. 'title' => 'File system',
  238. 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
  239. -----------------------------------------------------------------------------
  240. Properly activate Drupal support module in TinyMCE
  241. Index: sites/all/modules/tinymce/plugin_reg.php
  242. --- sites/all/modules/tinymce/plugin_reg.php.orig 2008-03-27 21:11:17 +0100
  243. +++ sites/all/modules/tinymce/plugin_reg.php 2008-05-02 20:56:56 +0200
  244. @@ -102,5 +102,9 @@
  245. $plugins['zoom'] = array();
  246. $plugins['zoom']['theme_advanced_buttons2'] = array('zoom');
  247. +$plugins['drupalimage'] = array();
  248. +$plugins['drupalimage']['theme_advanced_buttons1'] = array('drupalimage');
  249. +$plugins['drupalimage']['extended_valid_elements'] = array('img[class|src|border=0|alt|title|width|height|align|name]');
  250. +
  251. return $plugins;
  252. }
  253. -----------------------------------------------------------------------------
  254. Fix SQL in "remove" functionality of "img_assist" module.
  255. http://drupal.org/node/250128
  256. Index: sites/all/modules/img_assist/img_assist.module
  257. --- sites/all/modules/img_assist/img_assist.module.orig 2008-04-06 19:32:33 +0200
  258. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:00:24 +0200
  259. @@ -1239,7 +1239,7 @@
  260. }
  261. function _img_assist_remove($node, $size) {
  262. - $result = db_query("SELECT * FROM {files} f INNER JOIN {image} i WHERE f.fid = i.fid AND i.nid = %d AND f.filename = '%s'", $node->nid, $size['key']);
  263. + $result = db_query("SELECT * FROM {files} f INNER JOIN {image} ON f.fid = i.fid WHERE i.nid = %d AND f.filename = '%s'", $node->nid, $size['key']);
  264. while ($file = db_fetch_object($result)) {
  265. // Never delete original image.
  266. if ($file->filepath != $node->images[IMAGE_ORIGINAL]) {
  267. -----------------------------------------------------------------------------
  268. Optimize "img_assist" module by loading only when necessary.
  269. http://drupal.org/node/55101
  270. Index: sites/all/modules/img_assist/img_assist.js
  271. --- sites/all/modules/img_assist/img_assist.js.orig 2008-04-06 18:43:18 +0200
  272. +++ sites/all/modules/img_assist/img_assist.js 2008-05-02 21:05:56 +0200
  273. @@ -130,6 +130,24 @@
  274. var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  275. }
  276. +function launch_popup(nid, mw, mh) {
  277. + var ox = mw;
  278. + var oy = mh;
  279. + if((ox>=screen.width) || (oy>=screen.height)){
  280. + var ox = screen.width-150;
  281. + var oy = screen.height-150;
  282. + var winx = (screen.width / 2)-(ox / 2);
  283. + var winy = (screen.height / 2)-(oy / 2);
  284. + var use_scrollbars = 1;
  285. + }
  286. + else{
  287. + var winx = (screen.width / 2)-(ox / 2);
  288. + var winy = (screen.height / 2)-(oy / 2);
  289. + var use_scrollbars = 0;
  290. + }
  291. + var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  292. +}
  293. +
  294. function insertImage() {
  295. if (window.opener) {
  296. // Get variables from the fields on the properties frame
  297. Index: sites/all/modules/img_assist/img_assist.module
  298. --- sites/all/modules/img_assist/img_assist.module.orig 2008-05-02 21:04:49 +0200
  299. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:07:24 +0200
  300. @@ -126,7 +126,7 @@
  301. }
  302. // Assign base_path to insert in image source by javascript.
  303. drupal_add_js('var BASE_URL = "'. base_path() .'";', 'inline');
  304. - drupal_add_js($path .'/img_assist.js');
  305. + drupal_add_js($path .'/img_assist_popup.js');
  306. }
  307. /**
  308. @@ -150,6 +150,9 @@
  309. * Add image link underneath textareas.
  310. */
  311. function img_assist_textarea($element) {
  312. + $path = drupal_get_path('module', 'img_assist');
  313. + drupal_add_js($path .'/img_assist.js');
  314. +
  315. $link = variable_get('img_assist_link', 'icon');
  316. if (($link == 'icon') || ($link == 'text')) {
  317. if (_img_assist_textarea_match($element['#id']) && _img_assist_page_match() && !strstr($_GET['q'], 'img_assist')) {
  318. Index: sites/all/modules/img_assist/img_assist_popup.js
  319. --- /dev/null 2008-05-02 21:08:21 +0200
  320. +++ sites/all/modules/img_assist/img_assist_popup.js 2008-05-02 21:05:56 +0200
  321. @@ -0,0 +1,20 @@
  322. +/* $Id: drupal.patch,v 1.32 2008/10/11 07:18:03 rse Exp $ */
  323. +
  324. +function launch_popup(nid, mw, mh) {
  325. + var ox = mw;
  326. + var oy = mh;
  327. + if((ox>=screen.width) || (oy>=screen.height)){
  328. + var ox = screen.width-150;
  329. + var oy = screen.height-150;
  330. + var winx = (screen.width / 2)-(ox / 2);
  331. + var winy = (screen.height / 2)-(oy / 2);
  332. + var use_scrollbars = 1;
  333. + }
  334. + else{
  335. + var winx = (screen.width / 2)-(ox / 2);
  336. + var winy = (screen.height / 2)-(oy / 2);
  337. + var use_scrollbars = 0;
  338. + }
  339. + var win = window.open(BASE_URL + 'index.php?q=img_assist/popup/' + nid, 'imagev', 'height='+oy+'-10,width='+ox+',top='+winy+',left='+winx+',scrollbars='+use_scrollbars+',resizable');
  340. +}
  341. +
  342. -----------------------------------------------------------------------------
  343. Fix file permissions.
  344. http://drupal.org/node/247992
  345. Index: sites/all/modules/img_assist/img_assist.module
  346. --- sites/all/modules/img_assist/img_assist.module.orig 2008-05-02 21:11:15 +0200
  347. +++ sites/all/modules/img_assist/img_assist.module 2008-05-02 21:11:48 +0200
  348. @@ -1230,6 +1230,8 @@
  349. drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), 'error');
  350. }
  351. else {
  352. + // Set standard file permissions for webserver-generated files
  353. + @chmod(file_create_path($destination), 0664);
  354. $node->images[$key] = $destination;
  355. _image_insert($node, $key, file_create_path($destination));
  356. }
  357. -----------------------------------------------------------------------------
  358. Activate the Drupal glue code for the FCKeditor filemanager.
  359. Index: sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php
  360. --- sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php.orig 2008-03-25 16:28:24 +0100
  361. +++ sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php 2008-05-02 23:02:23 +0200
  362. @@ -39,6 +39,9 @@
  363. // Attention: The above 'UserFilesPath' must point to the same directory.
  364. $Config['UserFilesAbsolutePath'] = '' ;
  365. +// activate Drupal glue code for filemanager
  366. +require_once "../../../../../filemanager.config.php";
  367. +
  368. // Due to security issues with Apache modules, it is recommended to leave the
  369. // following setting enabled.
  370. $Config['ForceSingleExtension'] = true ;
  371. -----------------------------------------------------------------------------
  372. Disable "Update notifications" check by default during installation.
  373. Index: install.php
  374. --- install.php.orig 2008-02-08 23:00:45 +0100
  375. +++ install.php 2008-05-09 13:18:09 +0200
  376. @@ -1069,7 +1069,7 @@
  377. '#type' => 'checkboxes',
  378. '#title' => st('Update notifications'),
  379. '#options' => array(1 => st('Check for updates automatically')),
  380. - '#default_value' => array(1),
  381. + '#default_value' => array(),
  382. '#description' => st('With this option enabled, Drupal will notify you when new releases are available. This will significantly enhance your site\'s security and is <strong>highly recommended</strong>. This requires your site to periodically send anonymous information on its installed components to <a href="@drupal">drupal.org</a>. For more information please see the <a href="@update">update notification information</a>.', array('@drupal' => 'http://drupal.org', '@update' => 'http://drupal.org/handbook/modules/update')),
  383. '#weight' => 15,
  384. );
  385. -----------------------------------------------------------------------------
  386. No need to always expand the "Menu settings" on node edit pages.
  387. Index: modules/menu/menu.module
  388. --- modules/menu/menu.module.orig 2008-04-09 23:11:48 +0200
  389. +++ modules/menu/menu.module 2008-05-16 20:03:48 +0200
  390. @@ -366,7 +366,7 @@
  391. '#title' => t('Menu settings'),
  392. '#access' => user_access('administer menu'),
  393. '#collapsible' => TRUE,
  394. - '#collapsed' => FALSE,
  395. + '#collapsed' => TRUE,
  396. '#tree' => TRUE,
  397. '#weight' => -2,
  398. '#attributes' => array('class' => 'menu-item-form'),
  399. -----------------------------------------------------------------------------
  400. Use a larger text-area on node edit pages.
  401. Index: modules/node/node.pages.inc
  402. --- modules/node/node.pages.inc.orig 2008-02-27 20:44:44 +0100
  403. +++ modules/node/node.pages.inc 2008-05-16 20:06:45 +0200
  404. @@ -287,7 +287,8 @@
  405. '#type' => 'textarea',
  406. '#title' => check_plain($label),
  407. '#default_value' => $include ? $node->body : ($node->teaser . $node->body),
  408. - '#rows' => 20,
  409. + '#rows' => 30,
  410. + '#cols' => 80,
  411. '#required' => ($word_count > 0),
  412. );
  413. -----------------------------------------------------------------------------
  414. 1. Fix content validation in "xmlcontent" module in case
  415. one has enabled multiple filters on a particular input format.
  416. 2. Additionally, allow absolute paths to support .xsd/.xsl files
  417. in arbitrary directories.
  418. 3. Finally, do not create a new DOM and output it as XML. Instead directly
  419. output the transformed XML in order to get rid of the <?xml...?> declaration.
  420. 4. Additionally, support an optional XML content template (mainly
  421. for loading ENTITY definitions which cannot be done via XSD and XSLT)
  422. Index: sites/all/modules/xmlcontent/xmlcontent.module
  423. --- sites/all/modules/xmlcontent/xmlcontent.module.orig 2007-03-14 22:59:59 +0100
  424. +++ sites/all/modules/xmlcontent/xmlcontent.module 2008-05-30 21:13:16 +0200
  425. @@ -39,8 +39,22 @@
  426. return t('Allows users to post XML node content and get it transformed through a configured XSLT script');
  427. case 'process':
  428. - $xslt_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_xslt_path_$format", '');
  429. - return _xmlcontent_transform($text, $xslt_path);
  430. + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
  431. + if ($tpl_path) {
  432. + if (substr($tpl_path, 0, 1) != "/")
  433. + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
  434. + $tpl = file_get_contents($tpl_path);
  435. + $text = preg_replace("/&template_body;/", $text, $tpl);
  436. + $cwd = getcwd();
  437. + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
  438. + }
  439. + $xslt_path = variable_get("xmlcontent_xslt_path_$format", '');
  440. + if (substr($xslt_path, 0, 1) != "/")
  441. + $xslt_path = drupal_get_path('module', 'xmlcontent') . '/' . $xslt_path;
  442. + $result = _xmlcontent_transform($text, $xslt_path);
  443. + if ($tpl_path)
  444. + chdir($cwd);
  445. + return $result;
  446. case 'settings':
  447. return _xmlcontent_filter_settings($format);
  448. @@ -72,7 +86,7 @@
  449. }
  450. // Does the input format of this node use XML Content filter?
  451. $format = filter_resolve_format($node->format);
  452. - $module = db_result(db_query('SELECT module FROM {filters} WHERE format = %d', $format));
  453. + $module = db_result(db_query("SELECT module FROM {filters} WHERE format = %d AND module = 'xmlcontent'", $format));
  454. if ($module != 'xmlcontent') {
  455. return;
  456. }
  457. @@ -83,7 +97,10 @@
  458. return;
  459. }
  460. - $schema_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_schema_path_$format",'');
  461. + $schema_path = variable_get("xmlcontent_schema_path_$format", '');
  462. + if (substr($schema_path, 0, 1) != "/")
  463. + $schema_path = drupal_get_path('module', 'xmlcontent') . '/' . $schema_path;
  464. +
  465. if (!is_file($schema_path) && ($validation == 'xsd' or $validation == 'rng')) {
  466. $schema_path = null;
  467. watchdog( 'xmlcontent', t('Validation required but no schema file'), WATCHDOG_WARNING );
  468. @@ -93,7 +110,23 @@
  469. libxml_clear_errors();
  470. libxml_use_internal_errors(true);
  471. - if (!_xmlcontent_validate($node->body, $validation, $schema_path)) {
  472. + $text = $node->body;
  473. + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
  474. + if ($tpl_path) {
  475. + if (substr($tpl_path, 0, 1) != "/")
  476. + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
  477. + $tpl = file_get_contents($tpl_path);
  478. + $text = preg_replace("/&template_body;/", $text, $tpl);
  479. + $cwd = getcwd();
  480. + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
  481. + }
  482. +
  483. + $result = _xmlcontent_validate($text, $validation, $schema_path);
  484. +
  485. + if ($tpl_path)
  486. + chdir($cwd);
  487. +
  488. + if (!$result) {
  489. form_set_error('body', t('XML Content: Invalid XML') . libxml_errors_string());
  490. }
  491. @@ -156,6 +189,13 @@
  492. '#collapsible' => TRUE,
  493. '#collapsed' => FALSE,
  494. );
  495. + $form['xmlcontent']["xmlcontent_tpl_path_$format"] = array(
  496. + '#type' => 'textfield',
  497. + '#title' => t('Optional XML Template File Path'),
  498. + '#default_value' => variable_get("xmlcontent_tpl_path_$format", ''),
  499. + '#field_prefix' => drupal_get_path('module', 'xmlcontent'). '/',
  500. + '#description' => t('The file path to the optional XML template, wrapper around the XML content before processing.'),
  501. + );
  502. $form['xmlcontent']["xmlcontent_xslt_path_$format"] = array(
  503. '#type' => 'textfield',
  504. '#title' => t('XSLT Script File Path'),
  505. @@ -218,6 +258,8 @@
  506. // Load the XML document
  507. $dom = new DomDocument('1.0', 'UTF-8');
  508. + $dom->resolveExternals = true;
  509. + $dom->substituteEntities = true;
  510. $valid = $dom->loadXML($xml);
  511. if (!$valid) {
  512. watchdog('xmlcontent', "Invalid XML Content", WATCHDOG_WARNING);
  513. @@ -227,6 +269,8 @@
  514. // Load the XSLT script
  515. // TODO: is there a way to cache it, or not necessary
  516. $xsl = new DomDocument('1.0', 'UTF-8');
  517. + $xsl->resolveExternals = true;
  518. + $xsl->substituteEntities = true;
  519. $xsl->load($path_to_xslt);
  520. // Create the XSLT processor
  521. @@ -242,10 +286,8 @@
  522. }
  523. // Transform
  524. - $newdom = $proc->transformToDoc($dom);
  525. -
  526. - // Return the output as XML text (in fact subset of XHTML, depending on the XSLT script)
  527. - return $newdom->saveXML();
  528. + $xml = $proc->transformToXML($dom);
  529. + return $xml;
  530. }
  531. -----------------------------------------------------------------------------
  532. Fix upgrading in "simplefeed" module if PostgreSQL is used.
  533. Fix modules as Drupal 6.2 does not provide db_num_rows() anymore.
  534. Index: sites/all/modules/simplefeed/simplefeed.install
  535. --- sites/all/modules/simplefeed/simplefeed.install.orig 2008-06-11 07:22:28 +0200
  536. +++ sites/all/modules/simplefeed/simplefeed.install 2008-06-14 15:09:53 +0200
  537. @@ -31,8 +31,17 @@
  538. function simplefeed_update_2() {
  539. $ret = array();
  540. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
  541. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
  542. + switch ($GLOBALS['db_type']) {
  543. + case 'mysql':
  544. + case 'mysqli':
  545. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
  546. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
  547. + break;
  548. + case 'pgsql':
  549. + $ret[] = update_sql("DROP INDEX {simplefeed_feed}_url_idx");
  550. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} ALTER COLUMN url TYPE text");
  551. + break;
  552. + }
  553. return $ret;
  554. }
  555. Index: sites/all/modules/simplefeed/simplefeed_item.install
  556. --- sites/all/modules/simplefeed/simplefeed_item.install.orig 2008-06-11 07:22:28 +0200
  557. +++ sites/all/modules/simplefeed/simplefeed_item.install 2008-06-14 16:23:01 +0200
  558. @@ -40,13 +40,15 @@
  559. // Fetch up to N feed items and update their iids to new schema
  560. $count = $_SESSION['simplefeed_item_update_2']['count'];
  561. $feed_items = db_query_range('SELECT r.vid, r.title, s.url FROM {node_revisions} r JOIN {simplefeed_feed_item} s ON r.vid = s.vid ORDER BY r.vid ASC', $count, $limit);
  562. + $n = 0;
  563. while ($feed_item = db_fetch_object($feed_items)) {
  564. $iid = md5($feed_item->title . $feed_item->url);
  565. db_query("UPDATE {simplefeed_feed_item} SET iid = '%s' WHERE vid = %d", $iid, $feed_item->vid);
  566. $_SESSION['simplefeed_item_update_2']['vid'] = $feed_item->vid;
  567. + $n++;
  568. }
  569. - if (db_num_rows($feed_items) == $limit) {
  570. + if ($n == $limit) {
  571. $_SESSION['simplefeed_item_update_2']['count'] += $limit;
  572. // Return progress (never return 100% here to ensure clean-up is still run last).
  573. return array('#finished' => $_SESSION['simplefeed_item_update_2']['vid'] / ($_SESSION['simplefeed_item_update_2']['max'] + 1));
  574. @@ -60,8 +62,18 @@
  575. function simplefeed_item_update_3() {
  576. $ret = array();
  577. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
  578. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
  579. + switch ($GLOBALS['db_type']) {
  580. + case 'mysql':
  581. + case 'mysqli':
  582. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
  583. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
  584. + break;
  585. + case 'pgsql':
  586. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN url TYPE text");
  587. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid TYPE VARCHAR(32)");
  588. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid SET NOT NULL");
  589. + break;
  590. + }
  591. return $ret;
  592. }
  593. Index: sites/all/modules/autologout/autologout.module
  594. --- sites/all/modules/autologout/autologout.module.orig 2008-03-14 21:05:41 +0100
  595. +++ sites/all/modules/autologout/autologout.module 2008-06-14 15:57:27 +0200
  596. @@ -257,8 +257,8 @@
  597. if (_autologout_user_in_by_user_role($account)) {
  598. $account->autologout = 0;
  599. $r = db_query("SELECT setting FROM {autologout} WHERE uid = %d", $account->uid);
  600. - if (db_num_rows($r) > 0) {
  601. - $row = db_fetch_object($r);
  602. + $row = db_fetch_object($r);
  603. + if ($row) {
  604. $account->autologout = (int)$row->setting;
  605. }
  606. }
  607. -----------------------------------------------------------------------------
  608. Fix helpers module for PostgreSQL usage.
  609. Index: sites/all/modules/helpers/helpers_database.module
  610. --- sites/all/modules/helpers/helpers_database.module.orig 2008-04-23 04:38:34 +0200
  611. +++ sites/all/modules/helpers/helpers_database.module 2008-06-16 18:06:41 +0200
  612. @@ -16,7 +16,7 @@
  613. *
  614. * NOTE: This is open code - do not put a function declaration on it.
  615. */
  616. - $db_types = array('mysql', 'mysqli', 'postgres');
  617. + $db_types = array('mysql', 'mysqli', 'pgsql');
  618. $dbtype = $GLOBALS['db_type'];
  619. if (in_array($dbtype, $db_types)) {
  620. // Using include because the site may not be using this so we don't want a fatal error.
  621. Index: sites/all/modules/helpers/includes/dra_pgsql.inc
  622. --- sites/all/modules/helpers/includes/dra_pgsql.inc.orig 2008-06-16 17:49:43 +0200
  623. +++ sites/all/modules/helpers/includes/dra_pgsql.inc 2008-06-16 18:05:19 +0200
  624. @@ -0,0 +1,40 @@
  625. +<?php
  626. +/* $Id */
  627. + /**
  628. + * Return a result array from the previous query. PostgreSql version.
  629. + * This is very handy for building an option list for a form element.
  630. + *
  631. + * @param $result
  632. + * A database query result resource, as returned from db_query().
  633. + * @return
  634. + * The resulting array or FALSE.
  635. + * If the query contains -- the result array would be
  636. + * 0 columns (bool)FALSE
  637. + * 1 column value => value
  638. + * 2 columns 1st value => 2nd value
  639. + * 3 or more 1st value => array(2nd value, 3rd value, ...)
  640. + */
  641. +function db_result_array($result) {
  642. + $array = array();
  643. + while ($row = pg_fetch_array($result, NULL, PGSQL_NUM)) {
  644. + $y = count($row);
  645. + switch ($y) {
  646. + case 0:
  647. + drupal_set_message(t('Db_result_array found no columns in the result set.'), 'error');
  648. + return false;
  649. +
  650. + case 1:
  651. + $array[$row[0]] = $row[0];
  652. + break;
  653. +
  654. + case 2:
  655. + $array[$row[0]] = $row[1];
  656. + break;
  657. +
  658. + default:
  659. + $array[$row[0]] = array_slice($row, 1);
  660. + break;
  661. + }
  662. + }
  663. + return $array;
  664. +}
  665. -----------------------------------------------------------------------------
  666. Fix PostgreSQL usage.
  667. Index: sites/all/modules/nodeupdates/nodeupdates.install
  668. --- sites/all/modules/nodeupdates/nodeupdates.install.orig 2007-12-31 15:11:57 +0100
  669. +++ sites/all/modules/nodeupdates/nodeupdates.install 2008-06-18 18:00:08 +0200
  670. @@ -15,10 +15,10 @@
  671. case 'pgsql':
  672. db_query("CREATE TABLE {nodeupdates} (
  673. - nid integer(10) NOT NULL default '0',
  674. + nid integer NOT NULL default '0',
  675. title varchar(128) NOT NULL default '',
  676. - message longtext NOT NULL default '',
  677. - timestamp integer(11) NOT NULL default '0'
  678. + message text NOT NULL default '',
  679. + timestamp integer NOT NULL default '0'
  680. )");
  681. break;
  682. }
  683. -----------------------------------------------------------------------------
  684. Avoid incorrect ordering of BLOG entries by removing the
  685. db_rewrite_sql() calls which seem to introduce a wrong ordering.
  686. Index: modules/blog/blog.module
  687. --- modules/blog/blog.module.orig 2008-05-19 09:27:35 +0200
  688. +++ modules/blog/blog.module 2008-07-29 21:20:42 +0200
  689. @@ -182,13 +182,13 @@
  690. * Helper function to determine if a user has blog posts already.
  691. */
  692. function _blog_post_exists($account) {
  693. - return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1));
  694. + return (bool)db_result(db_query_range("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1", $account->uid, 0, 1));
  695. }
  696. /**
  697. * Implementation of hook_block().
  698. *
  699. - * Displays the most recent 10 blog titles.
  700. + * Displays the most recent 5 blog titles.
  701. */
  702. function blog_block($op = 'list', $delta = 0) {
  703. global $user;
  704. @@ -198,7 +198,7 @@
  705. }
  706. else if ($op == 'view') {
  707. if (user_access('access content')) {
  708. - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10);
  709. + $result = db_query_range("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, 5);
  710. if ($node_title_list = node_title_list($result)) {
  711. $block['content'] = $node_title_list;
  712. $block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.'));
  713. Index: modules/blog/blog.pages.inc
  714. --- modules/blog/blog.pages.inc.orig 2008-02-08 22:15:12 +0100
  715. +++ modules/blog/blog.pages.inc 2008-06-26 17:19:49 +0200
  716. @@ -25,7 +25,7 @@
  717. $output = theme('item_list', $items);
  718. - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
  719. + $result = pager_query("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
  720. $has_posts = FALSE;
  721. while ($node = db_fetch_object($result)) {
  722. @@ -64,7 +64,7 @@
  723. $output = theme('item_list', $items);
  724. - $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10));
  725. + $result = pager_query("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC", variable_get('default_nodes_main', 10));
  726. $has_posts = FALSE;
  727. while ($node = db_fetch_object($result)) {
  728. @@ -87,7 +87,7 @@
  729. * Menu callback; displays an RSS feed containing recent blog entries of a given user.
  730. */
  731. function blog_feed_user($account) {
  732. - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
  733. + $result = db_query_range("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC", $account->uid, 0, variable_get('feed_default_items', 10));
  734. $channel['title'] = $account->name ."'s blog";
  735. $channel['link'] = url('blog/'. $account->uid, array('absolute' => TRUE));
  736. @@ -102,7 +102,7 @@
  737. * Menu callback; displays an RSS feed containing recent blog entries of all users.
  738. */
  739. function blog_feed_last() {
  740. - $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, variable_get('feed_default_items', 10));
  741. + $result = db_query_range("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC", 0, variable_get('feed_default_items', 10));
  742. $channel['title'] = variable_get('site_name', 'Drupal') .' blogs';
  743. $channel['link'] = url('blog', array('absolute' => TRUE));