Révision ed9a13f1
Ajouté par Assos Assos il y a presque 4 ans
drupal7/sites/all/modules/feeds/tests/feeds_tests.module | ||
---|---|---|
39 | 39 |
'access arguments' => array('access content'), |
40 | 40 |
'type' => MENU_CALLBACK, |
41 | 41 |
); |
42 |
if (module_exists('rules')) { |
|
43 |
$items['testing/feeds/trigger-rules-event'] = array( |
|
44 |
'page callback' => 'feeds_tests_trigger_rules_event', |
|
45 |
'access arguments' => array('access content'), |
|
46 |
'type' => MENU_CALLBACK, |
|
47 |
); |
|
48 |
} |
|
42 | 49 |
return $items; |
43 | 50 |
} |
44 | 51 |
|
... | ... | |
309 | 316 |
print $csv; |
310 | 317 |
} |
311 | 318 |
|
319 |
/** |
|
320 |
* Implements hook_query_TAG_alter() for tag 'term_access'. |
|
321 |
*/ |
|
322 |
function feeds_tests_query_term_access_alter(QueryAlterableInterface $query) { |
|
323 |
global $user; |
|
324 |
|
|
325 |
$allowed_user = variable_get('feeds_tests_term_reference_allowed_user', NULL); |
|
326 |
if (is_null($allowed_user)) { |
|
327 |
// No allowed user set. Abort. |
|
328 |
return; |
|
329 |
} |
|
330 |
|
|
331 |
// Read meta-data from query, if provided. |
|
332 |
if (!$account = $query->getMetaData('account')) { |
|
333 |
$account = $user; |
|
334 |
} |
|
335 |
|
|
336 |
// If the current active user is the set user, abort. |
|
337 |
if ($account->uid == $allowed_user) { |
|
338 |
return; |
|
339 |
} |
|
340 |
|
|
341 |
// If $account can bypass node access, or there are no node access |
|
342 |
// modules, we don't need to alter the query. |
|
343 |
if (user_access('bypass node access', $account)) { |
|
344 |
return; |
|
345 |
} |
|
346 |
|
|
347 |
// Disallow any terms. |
|
348 |
$tables = $query->getTables(); |
|
349 |
foreach ($tables as $talias => $tableinfo) { |
|
350 |
$table = $tableinfo['table']; |
|
351 |
if (!($table instanceof SelectQueryInterface) && $table == 'taxonomy_term_data') { |
|
352 |
$query->condition("$talias.tid", 0); |
|
353 |
} |
|
354 |
} |
|
355 |
} |
|
356 |
|
|
357 |
/** |
|
358 |
* Page callback. Triggers the rules event 'feeds_tests_rules_event'. |
|
359 |
*/ |
|
360 |
function feeds_tests_trigger_rules_event() { |
|
361 |
rules_invoke_event('feeds_tests_rules_event'); |
|
362 |
return array( |
|
363 |
'#markup' => 'Rules event "feeds_tests_rules_event" triggered.', |
|
364 |
); |
|
365 |
} |
|
366 |
|
|
312 | 367 |
/** |
313 | 368 |
* Implements hook_feeds_processor_targets(). |
314 | 369 |
*/ |
... | ... | |
513 | 568 |
// items in there with encoding issues. These items can not be processed |
514 | 569 |
// during tests without having a test failure because in < PHP 5.4 that would |
515 | 570 |
// produce the following warning: |
516 |
// htmlspecialchars(): Invalid multibyte sequence in argument
|
|
571 |
// > htmlspecialchars(): Invalid multibyte sequence in argument.
|
|
517 | 572 |
// @see FeedsCSVParserTestCase::testMbstringExtensionDisabled() |
518 | 573 |
if (variable_get('feeds_tests_feeds_after_parse_empty_items', FALSE)) { |
519 | 574 |
// Remove all items. No items will be processed. |
... | ... | |
545 | 600 |
$item['uid'] = (float) $item['uid']; |
546 | 601 |
} |
547 | 602 |
} |
603 |
|
|
604 |
// Conditionally set the 'uid' value to the current user. |
|
605 |
// @see FeedsAccountSwitcherTest |
|
606 |
if (variable_get('feeds_tests_set_uid_current_user', FALSE)) { |
|
607 |
foreach ($result->items as &$item) { |
|
608 |
$item['uid'] = $GLOBALS['user']->uid; |
|
609 |
} |
|
610 |
} |
|
611 |
|
|
612 |
// Conditionally abort the import abruptly. |
|
613 |
// @see FeedsAccountSwitcherTest |
|
614 |
if (variable_get('feeds_tests_trigger_import_disruption', FALSE)) { |
|
615 |
die(); |
|
616 |
} |
|
548 | 617 |
} |
549 | 618 |
|
550 | 619 |
/** |
... | ... | |
565 | 634 |
*/ |
566 | 635 |
class FeedsTestsPreprocess { |
567 | 636 |
|
568 |
/** |
|
569 |
* Preprocess callback for test_target. |
|
570 |
* |
|
571 |
* @see feeds_tests_feeds_processor_targets() |
|
572 |
*/ |
|
637 |
/**
|
|
638 |
* Preprocess callback for test_target.
|
|
639 |
*
|
|
640 |
* @see feeds_tests_feeds_processor_targets()
|
|
641 |
*/
|
|
573 | 642 |
public static function callback(array $target, array &$mapping) { |
574 | 643 |
$mapping['required_value'] = TRUE; |
575 | 644 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules