drupal-module-misc.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. Activate the Drupal glue code for the FCKeditor filemanager.
  2. Index: sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php
  3. --- sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php.orig 2008-03-25 16:28:24 +0100
  4. +++ sites/all/modules/fckeditor/fckeditor/editor/filemanager/connectors/php/config.php 2008-05-02 23:02:23 +0200
  5. @@ -39,6 +39,9 @@
  6. // Attention: The above 'UserFilesPath' must point to the same directory.
  7. $Config['UserFilesAbsolutePath'] = '' ;
  8. +// activate Drupal glue code for filemanager
  9. +require_once "../../../../../filemanager.config.php";
  10. +
  11. // Due to security issues with Apache modules, it is recommended to leave the
  12. // following setting enabled.
  13. $Config['ForceSingleExtension'] = true ;
  14. -----------------------------------------------------------------------------
  15. 1. Fix content validation in "xmlcontent" module in case
  16. one has enabled multiple filters on a particular input format.
  17. 2. Additionally, allow absolute paths to support .xsd/.xsl files
  18. in arbitrary directories.
  19. 3. Finally, do not create a new DOM and output it as XML. Instead directly
  20. output the transformed XML in order to get rid of the <?xml...?> declaration.
  21. 4. Additionally, support an optional XML content template (mainly
  22. for loading ENTITY definitions which cannot be done via XSD and XSLT)
  23. Index: sites/all/modules/xmlcontent/xmlcontent.module
  24. --- sites/all/modules/xmlcontent/xmlcontent.module.orig 2007-03-14 22:59:59 +0100
  25. +++ sites/all/modules/xmlcontent/xmlcontent.module 2008-05-30 21:13:16 +0200
  26. @@ -39,8 +39,22 @@
  27. return t('Allows users to post XML node content and get it transformed through a configured XSLT script');
  28. case 'process':
  29. - $xslt_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_xslt_path_$format", '');
  30. - return _xmlcontent_transform($text, $xslt_path);
  31. + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
  32. + if ($tpl_path) {
  33. + if (substr($tpl_path, 0, 1) != "/")
  34. + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
  35. + $tpl = file_get_contents($tpl_path);
  36. + $text = preg_replace("/&template_body;/", $text, $tpl);
  37. + $cwd = getcwd();
  38. + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
  39. + }
  40. + $xslt_path = variable_get("xmlcontent_xslt_path_$format", '');
  41. + if (substr($xslt_path, 0, 1) != "/")
  42. + $xslt_path = drupal_get_path('module', 'xmlcontent') . '/' . $xslt_path;
  43. + $result = _xmlcontent_transform($text, $xslt_path);
  44. + if ($tpl_path)
  45. + chdir($cwd);
  46. + return $result;
  47. case 'settings':
  48. return _xmlcontent_filter_settings($format);
  49. @@ -72,7 +86,7 @@
  50. }
  51. // Does the input format of this node use XML Content filter?
  52. $format = filter_resolve_format($node->format);
  53. - $module = db_result(db_query('SELECT module FROM {filters} WHERE format = %d', $format));
  54. + $module = db_result(db_query("SELECT module FROM {filters} WHERE format = %d AND module = 'xmlcontent'", $format));
  55. if ($module != 'xmlcontent') {
  56. return;
  57. }
  58. @@ -83,7 +97,10 @@
  59. return;
  60. }
  61. - $schema_path = drupal_get_path('module', 'xmlcontent'). '/' . variable_get("xmlcontent_schema_path_$format",'');
  62. + $schema_path = variable_get("xmlcontent_schema_path_$format", '');
  63. + if (substr($schema_path, 0, 1) != "/")
  64. + $schema_path = drupal_get_path('module', 'xmlcontent') . '/' . $schema_path;
  65. +
  66. if (!is_file($schema_path) && ($validation == 'xsd' or $validation == 'rng')) {
  67. $schema_path = null;
  68. watchdog( 'xmlcontent', t('Validation required but no schema file'), WATCHDOG_WARNING );
  69. @@ -93,7 +110,23 @@
  70. libxml_clear_errors();
  71. libxml_use_internal_errors(true);
  72. - if (!_xmlcontent_validate($node->body, $validation, $schema_path)) {
  73. + $text = $node->body;
  74. + $tpl_path = variable_get("xmlcontent_tpl_path_$format", '');
  75. + if ($tpl_path) {
  76. + if (substr($tpl_path, 0, 1) != "/")
  77. + $tpl_path = drupal_get_path('module', 'xmlcontent') . '/' . $tpl_path;
  78. + $tpl = file_get_contents($tpl_path);
  79. + $text = preg_replace("/&template_body;/", $text, $tpl);
  80. + $cwd = getcwd();
  81. + chdir(preg_replace("/\\/[^\\/]+\$/", "", $tpl_path));
  82. + }
  83. +
  84. + $result = _xmlcontent_validate($text, $validation, $schema_path);
  85. +
  86. + if ($tpl_path)
  87. + chdir($cwd);
  88. +
  89. + if (!$result) {
  90. form_set_error('body', t('XML Content: Invalid XML') . libxml_errors_string());
  91. }
  92. @@ -156,6 +189,13 @@
  93. '#collapsible' => TRUE,
  94. '#collapsed' => FALSE,
  95. );
  96. + $form['xmlcontent']["xmlcontent_tpl_path_$format"] = array(
  97. + '#type' => 'textfield',
  98. + '#title' => t('Optional XML Template File Path'),
  99. + '#default_value' => variable_get("xmlcontent_tpl_path_$format", ''),
  100. + '#field_prefix' => drupal_get_path('module', 'xmlcontent'). '/',
  101. + '#description' => t('The file path to the optional XML template, wrapper around the XML content before processing.'),
  102. + );
  103. $form['xmlcontent']["xmlcontent_xslt_path_$format"] = array(
  104. '#type' => 'textfield',
  105. '#title' => t('XSLT Script File Path'),
  106. @@ -218,6 +258,8 @@
  107. // Load the XML document
  108. $dom = new DomDocument('1.0', 'UTF-8');
  109. + $dom->resolveExternals = true;
  110. + $dom->substituteEntities = true;
  111. $valid = $dom->loadXML($xml);
  112. if (!$valid) {
  113. watchdog('xmlcontent', "Invalid XML Content", WATCHDOG_WARNING);
  114. @@ -227,6 +269,8 @@
  115. // Load the XSLT script
  116. // TODO: is there a way to cache it, or not necessary
  117. $xsl = new DomDocument('1.0', 'UTF-8');
  118. + $xsl->resolveExternals = true;
  119. + $xsl->substituteEntities = true;
  120. $xsl->load($path_to_xslt);
  121. // Create the XSLT processor
  122. @@ -242,10 +286,8 @@
  123. }
  124. // Transform
  125. - $newdom = $proc->transformToDoc($dom);
  126. -
  127. - // Return the output as XML text (in fact subset of XHTML, depending on the XSLT script)
  128. - return $newdom->saveXML();
  129. + $xml = $proc->transformToXML($dom);
  130. + return $xml;
  131. }
  132. -----------------------------------------------------------------------------
  133. Fix upgrading in "simplefeed" module if PostgreSQL is used.
  134. Fix modules as Drupal 6.2 does not provide db_num_rows() anymore.
  135. Index: sites/all/modules/simplefeed/simplefeed.install
  136. --- sites/all/modules/simplefeed/simplefeed.install.orig 2008-06-11 07:22:28 +0200
  137. +++ sites/all/modules/simplefeed/simplefeed.install 2008-06-14 15:09:53 +0200
  138. @@ -31,8 +31,17 @@
  139. function simplefeed_update_2() {
  140. $ret = array();
  141. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
  142. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
  143. + switch ($GLOBALS['db_type']) {
  144. + case 'mysql':
  145. + case 'mysqli':
  146. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} DROP INDEX url");
  147. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} CHANGE url url text");
  148. + break;
  149. + case 'pgsql':
  150. + $ret[] = update_sql("DROP INDEX {simplefeed_feed}_url_idx");
  151. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed} ALTER COLUMN url TYPE text");
  152. + break;
  153. + }
  154. return $ret;
  155. }
  156. Index: sites/all/modules/simplefeed/simplefeed_item.install
  157. --- sites/all/modules/simplefeed/simplefeed_item.install.orig 2008-06-11 07:22:28 +0200
  158. +++ sites/all/modules/simplefeed/simplefeed_item.install 2008-06-14 16:23:01 +0200
  159. @@ -60,8 +62,18 @@
  160. function simplefeed_item_update_3() {
  161. $ret = array();
  162. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
  163. - $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
  164. + switch ($GLOBALS['db_type']) {
  165. + case 'mysql':
  166. + case 'mysqli':
  167. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE url url text");
  168. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} CHANGE iid iid varchar(32) NOT NULL");
  169. + break;
  170. + case 'pgsql':
  171. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN url TYPE text");
  172. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid TYPE VARCHAR(32)");
  173. + $ret[] = update_sql("ALTER TABLE {simplefeed_feed_item} ALTER COLUMN iid SET NOT NULL");
  174. + break;
  175. + }
  176. return $ret;
  177. }
  178. -----------------------------------------------------------------------------
  179. Fix helpers module for PostgreSQL usage.
  180. Index: sites/all/modules/helpers/helpers_database.module
  181. --- sites/all/modules/helpers/helpers_database.module.orig 2008-04-23 04:38:34 +0200
  182. +++ sites/all/modules/helpers/helpers_database.module 2008-06-16 18:06:41 +0200
  183. @@ -16,7 +16,7 @@
  184. *
  185. * NOTE: This is open code - do not put a function declaration on it.
  186. */
  187. - $db_types = array('mysql', 'mysqli', 'postgres');
  188. + $db_types = array('mysql', 'mysqli', 'pgsql');
  189. $dbtype = $GLOBALS['db_type'];
  190. if (in_array($dbtype, $db_types)) {
  191. // Using include because the site may not be using this so we don't want a fatal error.
  192. Index: sites/all/modules/helpers/includes/dra_pgsql.inc
  193. --- sites/all/modules/helpers/includes/dra_pgsql.inc.orig 2008-06-16 17:49:43 +0200
  194. +++ sites/all/modules/helpers/includes/dra_pgsql.inc 2008-06-16 18:05:19 +0200
  195. @@ -0,0 +1,40 @@
  196. +<?php
  197. +/* $Id */
  198. + /**
  199. + * Return a result array from the previous query. PostgreSql version.
  200. + * This is very handy for building an option list for a form element.
  201. + *
  202. + * @param $result
  203. + * A database query result resource, as returned from db_query().
  204. + * @return
  205. + * The resulting array or FALSE.
  206. + * If the query contains -- the result array would be
  207. + * 0 columns (bool)FALSE
  208. + * 1 column value => value
  209. + * 2 columns 1st value => 2nd value
  210. + * 3 or more 1st value => array(2nd value, 3rd value, ...)
  211. + */
  212. +function db_result_array($result) {
  213. + $array = array();
  214. + while ($row = pg_fetch_array($result, NULL, PGSQL_NUM)) {
  215. + $y = count($row);
  216. + switch ($y) {
  217. + case 0:
  218. + drupal_set_message(t('Db_result_array found no columns in the result set.'), 'error');
  219. + return false;
  220. +
  221. + case 1:
  222. + $array[$row[0]] = $row[0];
  223. + break;
  224. +
  225. + case 2:
  226. + $array[$row[0]] = $row[1];
  227. + break;
  228. +
  229. + default:
  230. + $array[$row[0]] = array_slice($row, 1);
  231. + break;
  232. + }
  233. + }
  234. + return $array;
  235. +}
  236. -----------------------------------------------------------------------------
  237. Fix PostgreSQL usage.
  238. Index: sites/all/modules/nodeupdates/nodeupdates.install
  239. --- sites/all/modules/nodeupdates/nodeupdates.install.orig 2007-12-31 15:11:57 +0100
  240. +++ sites/all/modules/nodeupdates/nodeupdates.install 2008-06-18 18:00:08 +0200
  241. @@ -15,10 +15,10 @@
  242. case 'pgsql':
  243. db_query("CREATE TABLE {nodeupdates} (
  244. - nid integer(10) NOT NULL default '0',
  245. + nid integer NOT NULL default '0',
  246. title varchar(128) NOT NULL default '',
  247. - message longtext NOT NULL default '',
  248. - timestamp integer(11) NOT NULL default '0'
  249. + message text NOT NULL default '',
  250. + timestamp integer NOT NULL default '0'
  251. )");
  252. break;
  253. }
  254. -----------------------------------------------------------------------------
  255. Since PHP 5.3 calling functions with objects and having the function
  256. declare the object parameter as a reference causes a run-time error.
  257. The "call-by-reference" indicator "&" has to be removed from parameters
  258. which are known to be passed as objects (by reference).
  259. Index: sites/all/modules/diff/diff.module
  260. --- sites/all/modules/diff/diff.module.orig 2010-08-12 18:34:08.000000000 +0200
  261. +++ sites/all/modules/diff/diff.module 2010-08-13 14:18:26.000000000 +0200
  262. @@ -87,7 +87,7 @@
  263. /**
  264. * Implementation of hook_menu_alter().
  265. */
  266. -function diff_menu_alter(&$callbacks) {
  267. +function diff_menu_alter($callbacks) {
  268. // Overwrite the default 'Revisions' page
  269. $callbacks['node/%node/revisions']['page callback'] = 'diff_diffs_overview';
  270. $callbacks['node/%node/revisions']['module'] = 'diff';
  271. @@ -133,7 +133,7 @@
  272. /**
  273. * Implementation of hook_nodeapi().
  274. */
  275. -function diff_nodeapi(&$node, $op, $teaser, $page) {
  276. +function diff_nodeapi($node, $op, $teaser, $page) {
  277. if ($page && $op == 'view' && user_access('view revisions') && variable_get('show_diff_inline_'. $node->type, FALSE)) {
  278. // Ugly but cheap way to check that we are viewing a node's revision page.
  279. if (arg(2) === 'revisions' && arg(3) === $node->vid) {
  280. @@ -149,7 +149,7 @@
  281. /**
  282. * Implementation of hook_form_alter().
  283. */
  284. -function diff_form_alter(&$form, $form_state, $form_id) {
  285. +function diff_form_alter($form, $form_state, $form_id) {
  286. if (isset($form['type']['#value']) && $form['type']['#value'] .'_node_form' == $form_id) {
  287. // Add a 'View changes' button on the node edit form.
  288. if (variable_get('show_preview_changes_'. $form['type']['#value'], TRUE) && $form['nid']['#value'] > 0) {
  289. @@ -194,7 +194,7 @@
  290. /**
  291. * Callback if 'View changes' is pressed.
  292. */
  293. -function diff_node_form_build_preview_changes($form, &$form_state) {
  294. +function diff_node_form_build_preview_changes($form, $form_state) {
  295. module_load_include('inc', 'diff', 'diff.pages');
  296. $node = node_form_submit_build_node($form, $form_state);
  297. @@ -323,7 +323,7 @@
  298. /**
  299. * Form submission handler for diff_inline_form() for JS-disabled clients.
  300. */
  301. -function diff_inline_form_submit(&$form, &$form_state) {
  302. +function diff_inline_form_submit($form, $form_state) {
  303. if (isset($form_state['values']['revision'], $form_state['values']['node'])) {
  304. $node = $form_state['values']['node'];
  305. $vid = $form_state['values']['revision'];