update core to 7.36

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-19 19:33:23 +02:00
parent 6de56c702c
commit 802ec0c6f3
271 changed files with 4111 additions and 1227 deletions

View File

@@ -9,8 +9,8 @@ files[] = comment.test
configure = admin/content/comment
stylesheets[all][] = comment.css
; Information added by Drupal.org packaging script on 2014-05-08
version = "7.28"
; Information added by Drupal.org packaging script on 2015-04-02
version = "7.36"
project = "drupal"
datestamp = "1399522731"
datestamp = "1427943826"

View File

@@ -993,12 +993,7 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode =
$comment->content = array();
// Allow modules to change the view mode.
$context = array(
'entity_type' => 'comment',
'entity' => $comment,
'langcode' => $langcode,
);
drupal_alter('entity_view_mode', $view_mode, $context);
$view_mode = key(entity_view_mode_prepare('comment', array($comment->cid => $comment), $view_mode, $langcode));
// Build fields content.
field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $langcode);
@@ -1108,17 +1103,26 @@ function comment_links($comment, $node) {
* An array in the format expected by drupal_render().
*/
function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) {
field_attach_prepare_view('comment', $comments, $view_mode, $langcode);
entity_prepare_view('comment', $comments, $langcode);
$build = array();
$entities_by_view_mode = entity_view_mode_prepare('comment', $comments, $view_mode, $langcode);
foreach ($entities_by_view_mode as $entity_view_mode => $entities) {
field_attach_prepare_view('comment', $entities, $entity_view_mode, $langcode);
entity_prepare_view('comment', $entities, $langcode);
foreach ($entities as $entity) {
$build[$entity->cid] = comment_view($entity, $node, $entity_view_mode, $langcode);
}
}
$build = array(
'#sorted' => TRUE,
);
foreach ($comments as $comment) {
$build[$comment->cid] = comment_view($comment, $node, $view_mode, $langcode);
$build[$comment->cid]['#weight'] = $weight;
$weight++;
}
// Sort here, to preserve the input order of the entities that were passed to
// this function.
uasort($build, 'element_sort');
$build['#sorted'] = TRUE;
return $build;
}
@@ -2603,7 +2607,7 @@ function comment_unpublish_action($comment, $context = array()) {
/**
* Unpublishes a comment if it contains certain keywords.
*
* @param $comment
* @param object $comment
* Comment object to modify.
* @param array $context
* Array with components:
@@ -2615,10 +2619,13 @@ function comment_unpublish_action($comment, $context = array()) {
* @see comment_unpublish_by_keyword_action_submit()
*/
function comment_unpublish_by_keyword_action($comment, $context) {
$node = node_load($comment->nid);
$build = comment_view($comment, $node);
$text = drupal_render($build);
foreach ($context['keywords'] as $keyword) {
$text = drupal_render($comment);
if (strpos($text, $keyword) !== FALSE) {
$comment->status = COMMENT_NOT_PUBLISHED;
comment_save($comment);
watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject));
break;
}

View File

@@ -13,7 +13,7 @@ class CommentHelperCase extends DrupalWebTestCase {
function setUp() {
parent::setUp('comment', 'search');
// Create users and test node.
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks'));
$this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks', 'administer actions'));
$this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments'));
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid));
}
@@ -1973,6 +1973,41 @@ class CommentActionsTestCase extends CommentHelperCase {
$this->clearWatchdog();
}
/**
* Tests the unpublish comment by keyword action.
*/
public function testCommentUnpublishByKeyword() {
$this->drupalLogin($this->admin_user);
$callback = 'comment_unpublish_by_keyword_action';
$hash = drupal_hash_base64($callback);
$comment_text = $keywords = $this->randomName();
$edit = array(
'actions_label' => $callback,
'keywords' => $keywords,
);
$this->drupalPost("admin/config/system/actions/configure/$hash", $edit, t('Save'));
$action = db_query("SELECT aid, type, callback, parameters, label FROM {actions} WHERE callback = :callback", array(':callback' => $callback))->fetchObject();
$this->assertTrue($action, 'The action could be loaded.');
$comment = $this->postComment($this->node, $comment_text, $this->randomName());
// Load the full comment so that status is available.
$comment = comment_load($comment->id);
$this->assertTrue($comment->status == COMMENT_PUBLISHED, 'The comment status was set to published.');
comment_unpublish_by_keyword_action($comment, array('keywords' => array($keywords)));
// We need to make sure that the comment has been saved with status
// unpublished.
$this->assertEqual(comment_load($comment->cid)->status, COMMENT_NOT_PUBLISHED, 'Comment was unpublished.');
$this->assertWatchdogMessage('Unpublished comment %subject.', array('%subject' => $comment->subject), 'Found watchdog message.');
$this->clearWatchdog();
}
/**
* Verify that a watchdog message has been entered.
*