Commit 224d64c6 authored by Spleshka's avatar Spleshka

Issue #1854156 by boyan.borisov, Spleshka: Add support for entity references.

parent 0aeeccd1
......@@ -79,6 +79,16 @@ function expire_admin_settings_form() {
'#weight' => 1,
);
$form['tabs']['node']['override'] = array(
'#type' => 'fieldset',
'#title' => t('Node settings per type'),
);
$form['tabs']['node']['override']['info'] = array(
'#type' => 'item',
'#markup' => t('Please note that you may override this settings for each node type on the node type configuration page.'),
);
$form['tabs']['node']['actions'] = array(
'#type' => 'fieldset',
'#title' => t('Node actions'),
......@@ -86,7 +96,7 @@ function expire_admin_settings_form() {
$form['tabs']['node']['actions']['expire_node_actions'] = array(
'#type' => 'checkboxes',
'#description' => t('Page cache for node will be expired after selected actions.'),
'#description' => t('Page cache for node will be flushed after selected actions.'),
'#options' => array(
EXPIRE_NODE_INSERT => t('Node insert'),
EXPIRE_NODE_UPDATE => t('Node update'),
......@@ -103,12 +113,14 @@ function expire_admin_settings_form() {
$form['tabs']['node']['expire']['expire_node_front_page'] = array(
'#type' => 'checkbox',
'#title' => t('Front page'),
'#description' => t('Expire url of the site front page'),
'#default_value' => variable_get('expire_node_front_page', EXPIRE_NODE_FRONT_PAGE),
);
$form['tabs']['node']['expire']['expire_node_node_page'] = array(
'#type' => 'checkbox',
'#title' => t('Node page'),
'#description' => t('Expire url of the expiring node.'),
'#default_value' => variable_get('expire_node_node_page', EXPIRE_NODE_NODE_PAGE),
);
......@@ -116,14 +128,16 @@ function expire_admin_settings_form() {
$form['tabs']['node']['expire']['expire_node_term_pages'] = array(
'#type' => 'checkbox',
'#title' => t('Node term pages'),
'#description' => t('Expire urls of terms that are selected in the expiring node.'),
'#default_value' => variable_get('expire_node_term_pages', EXPIRE_NODE_TERM_PAGES),
);
}
if (module_exists('node_reference')) {
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['tabs']['node']['expire']['expire_node_reference_pages'] = array(
'#type' => 'checkbox',
'#title' => t('Node reference pages'),
'#description' => t('Expire urls of entities which are referenced from the expiring node.'),
'#default_value' => variable_get('expire_node_reference_pages', EXPIRE_NODE_REFERENCE_PAGES),
);
}
......@@ -131,6 +145,7 @@ function expire_admin_settings_form() {
$form['tabs']['node']['expire']['expire_node_custom'] = array(
'#type' => 'checkbox',
'#title' => t('Custom pages'),
'#description' => t('Expire user-defined custom urls.'),
'#default_value' => variable_get('expire_node_custom', EXPIRE_NODE_CUSTOM),
);
......@@ -158,6 +173,16 @@ function expire_admin_settings_form() {
'#weight' => 2,
);
$form['tabs']['comment']['override'] = array(
'#type' => 'fieldset',
'#title' => t('Comment settings per node type'),
);
$form['tabs']['comment']['override']['info'] = array(
'#type' => 'item',
'#markup' => t('Please note that you may override this settings for each node type on the node type configuration page.'),
);
$form['tabs']['comment']['actions'] = array(
'#type' => 'fieldset',
'#title' => t('Comment actions'),
......@@ -165,7 +190,7 @@ function expire_admin_settings_form() {
$form['tabs']['comment']['actions']['expire_comment_actions'] = array(
'#type' => 'checkboxes',
'#description' => t('Page cache for comment will be expired after selected actions.'),
'#description' => t('Page cache for comment will be flushed after selected actions.'),
'#options' => array(
EXPIRE_COMMENT_INSERT => t('Comment insert'),
EXPIRE_COMMENT_UPDATE => t('Comment update'),
......@@ -184,18 +209,30 @@ function expire_admin_settings_form() {
$form['tabs']['comment']['expire']['expire_comment_front_page'] = array(
'#type' => 'checkbox',
'#title' => t('Front page'),
'#description' => t('Expire url of the site front page'),
'#default_value' => variable_get('expire_comment_front_page', EXPIRE_COMMENT_FRONT_PAGE),
);
$form['tabs']['comment']['expire']['expire_comment_comment_page'] = array(
'#type' => 'checkbox',
'#title' => t('Comment page'),
'#description' => t('Expire url of the expiring comment.'),
'#default_value' => variable_get('expire_comment_comment_page', EXPIRE_COMMENT_COMMENT_PAGE),
);
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['tabs']['comment']['expire']['expire_comment_reference_pages'] = array(
'#type' => 'checkbox',
'#title' => t('Comment\'s reference pages'),
'#description' => t('Expire urls of entities which are referenced from the expiring comment.'),
'#default_value' => variable_get('expire_comment_reference_pages', EXPIRE_COMMENT_REFERENCE_PAGES),
);
}
$form['tabs']['comment']['expire']['expire_comment_node_page'] = array(
'#type' => 'checkbox',
'#title' => t('Comment\'s node page'),
'#description' => t('Expire url of the node, to which expiring comment is related.'),
'#default_value' => variable_get('expire_comment_node_page', EXPIRE_COMMENT_NODE_PAGE),
);
......@@ -203,14 +240,16 @@ function expire_admin_settings_form() {
$form['tabs']['comment']['expire']['expire_comment_node_term_pages'] = array(
'#type' => 'checkbox',
'#title' => t('Comment\'s node term pages'),
'#description' => t('Expire urls of terms that are selected in the node, to which expiring comment is related.'),
'#default_value' => variable_get('expire_comment_node_term_pages', EXPIRE_COMMENT_NODE_TERM_PAGES),
);
}
if (module_exists('node_reference')) {
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['tabs']['comment']['expire']['expire_comment_node_reference_pages'] = array(
'#type' => 'checkbox',
'#title' => t('Comment\'s node reference pages'),
'#description' => t('Expire urls of entities which are referenced from node, to which expiring comment is related.'),
'#default_value' => variable_get('expire_comment_node_reference_pages', EXPIRE_COMMENT_NODE_REFERENCE_PAGES),
);
}
......@@ -218,6 +257,7 @@ function expire_admin_settings_form() {
$form['tabs']['comment']['expire']['expire_comment_custom'] = array(
'#type' => 'checkbox',
'#title' => t('Custom pages'),
'#description' => t('Expire user-defined custom urls.'),
'#default_value' => variable_get('expire_comment_custom', EXPIRE_COMMENT_CUSTOM),
);
......@@ -252,7 +292,7 @@ function expire_admin_settings_form() {
$form['tabs']['user']['actions']['expire_user_actions'] = array(
'#type' => 'checkboxes',
'#description' => t('Page cache for user will be expired after selected actions.'),
'#description' => t('Page cache for user will be flushed after selected actions.'),
'#options' => array(
EXPIRE_USER_INSERT => t('User insert'),
EXPIRE_USER_UPDATE => t('User update'),
......@@ -270,18 +310,39 @@ function expire_admin_settings_form() {
$form['tabs']['user']['expire']['expire_user_front_page'] = array(
'#type' => 'checkbox',
'#title' => t('Front page'),
'#description' => t('Expire url of the site front page'),
'#default_value' => variable_get('expire_user_front_page', EXPIRE_USER_FRONT_PAGE),
);
$form['tabs']['user']['expire']['expire_user_user_page'] = array(
'#type' => 'checkbox',
'#title' => t('User page'),
'#description' => t('Expire url of the expiring user profile.'),
'#default_value' => variable_get('expire_user_user_page', EXPIRE_USER_USER_PAGE),
);
if (module_exists('taxonomy')) {
$form['tabs']['user']['expire']['expire_user_term_pages'] = array(
'#type' => 'checkbox',
'#title' => t('User term pages'),
'#description' => t('Expire urls of terms that are selected in the expiring user profile.'),
'#default_value' => variable_get('expire_user_term_pages', EXPIRE_USER_TERM_PAGES),
);
}
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['tabs']['user']['expire']['expire_user_reference_pages'] = array(
'#type' => 'checkbox',
'#title' => t('User reference pages'),
'#description' => t('Expire urls of entities which are referenced from the expiring user profile.'),
'#default_value' => variable_get('expire_user_reference_pages', EXPIRE_USER_REFERENCE_PAGES),
);
}
$form['tabs']['user']['expire']['expire_user_custom'] = array(
'#type' => 'checkbox',
'#title' => t('Custom pages'),
'#description' => t('Expire user-defined custom urls.'),
'#default_value' => variable_get('expire_user_custom', EXPIRE_USER_CUSTOM),
);
......@@ -306,7 +367,7 @@ function expire_admin_settings_form() {
'#type' => 'fieldset',
'#title' => t('File expiration'),
'#group' => 'tabs',
'#weight' => 3,
'#weight' => 4,
);
$form['tabs']['file']['actions'] = array(
......@@ -316,7 +377,7 @@ function expire_admin_settings_form() {
$form['tabs']['file']['actions']['expire_file_actions'] = array(
'#type' => 'checkboxes',
'#description' => t('Page cache for file will be expired after selected actions.'),
'#description' => t('Page cache for file will be flushed after selected actions.'),
'#options' => array(
EXPIRE_FILE_UPDATE => t('File update'),
EXPIRE_FILE_DELETE => t('File delete'),
......@@ -329,21 +390,24 @@ function expire_admin_settings_form() {
'#title' => t('What URLs should be expired when file action is triggered?'),
);
$form['tabs']['file']['expire']['expire_file_file'] = array(
'#type' => 'checkbox',
'#title' => t('File url'),
'#default_value' => variable_get('expire_file_file', EXPIRE_FILE_FILE),
);
$form['tabs']['file']['expire']['expire_file_front_page'] = array(
'#type' => 'checkbox',
'#title' => t('Front page'),
'#description' => t('Expire url of the site front page'),
'#default_value' => variable_get('expire_file_front_page', EXPIRE_FILE_FRONT_PAGE),
);
$form['tabs']['file']['expire']['expire_file_file'] = array(
'#type' => 'checkbox',
'#title' => t('File url'),
'#description' => t('Expire url of the expiring file.'),
'#default_value' => variable_get('expire_file_file', EXPIRE_FILE_FILE),
);
$form['tabs']['file']['expire']['expire_file_custom'] = array(
'#type' => 'checkbox',
'#title' => t('Custom pages'),
'#description' => t('Expire user-defined custom urls.'),
'#default_value' => variable_get('expire_file_custom', EXPIRE_FILE_CUSTOM),
);
......@@ -369,7 +433,7 @@ function expire_admin_settings_form() {
'#type' => 'fieldset',
'#title' => t('Votingapi expiration'),
'#group' => 'tabs',
'#weight' => 4,
'#weight' => 5,
);
$form['tabs']['votingapi']['actions'] = array(
......@@ -379,7 +443,7 @@ function expire_admin_settings_form() {
$form['tabs']['votingapi']['actions']['expire_votingapi_actions'] = array(
'#type' => 'checkboxes',
'#description' => t('Page cache for votes will be expired after selected actions.'),
'#description' => t('Page cache for votes will be flushed after selected actions.'),
'#options' => array(
EXPIRE_VOTINGAPI_INSERT => t('Vote insert'),
EXPIRE_VOTINGAPI_DELETE => t('Vote delete'),
......@@ -395,19 +459,21 @@ function expire_admin_settings_form() {
$form['tabs']['votingapi']['expire']['expire_votingapi_entity_page'] = array(
'#type' => 'checkbox',
'#title' => t('Voted entity page'),
'#description' => t('Expire url of the voted entity.'),
'#default_value' => variable_get('expire_votingapi_entity_page', EXPIRE_VOTINGAPI_ENTITY_PAGE),
);
$form['tabs']['votingapi']['expire']['expire_votingapi_entity'] = array(
'#type' => 'checkbox',
'#title' => t('Voted entity'),
'#description' => t('Note that will be executed expiration selected for voted entity type.'),
'#description' => t('Execute voted entity expiration. Note that will be executed expiration with expire settings for this entity type (user, node, etc).'),
'#default_value' => variable_get('expire_votingapi_entity', EXPIRE_VOTINGAPI_ENTITY),
);
$form['tabs']['votingapi']['expire']['expire_votingapi_custom'] = array(
'#type' => 'checkbox',
'#title' => t('Custom pages'),
'#description' => t('Expire user-defined custom urls.'),
'#default_value' => variable_get('expire_votingapi_custom', EXPIRE_VOTINGAPI_CUSTOM),
);
......@@ -433,7 +499,7 @@ function expire_admin_settings_form() {
'#type' => 'fieldset',
'#title' => t('Menu links expiration'),
'#group' => 'tabs',
'#weight' => 1,
'#weight' => 6,
);
$form['tabs']['menu_links']['actions'] = array(
......@@ -443,7 +509,7 @@ function expire_admin_settings_form() {
$form['tabs']['menu_links']['actions']['expire_menu_link_actions'] = array(
'#type' => 'checkboxes',
'#description' => t('Page cache for user will be expired after selected actions.'),
'#description' => t('Page cache for user will be flushed after selected actions.'),
'#options' => array(
EXPIRE_MENU_LINK_INSERT => t('Menu link insert'),
EXPIRE_MENU_LINK_UPDATE => t('Menu link update'),
......@@ -575,7 +641,7 @@ function expire_node_settings_form(&$form) {
variable_get('expire_node_term_pages_' . $node_type, EXPIRE_NODE_TERM_PAGES);
}
if (module_exists('node_reference')) {
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['expire']['node_expires']['expire_node_reference_pages']['#default_value'] =
variable_get('expire_node_reference_pages_' . $node_type, EXPIRE_NODE_REFERENCE_PAGES);
}
......@@ -604,7 +670,12 @@ function expire_node_settings_form(&$form) {
variable_get('expire_comment_node_term_pages_' . $node_type, EXPIRE_COMMENT_NODE_TERM_PAGES);
}
if (module_exists('node_reference')) {
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['expire']['comment_expires']['expire_comment_reference_pages']['#default_value'] =
variable_get('expire_comment_reference_pages_' . $node_type, EXPIRE_COMMENT_REFERENCE_PAGES);
}
if (module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) {
$form['expire']['comment_expires']['expire_comment_node_reference_pages']['#default_value'] =
variable_get('expire_comment_node_reference_pages_' . $node_type, EXPIRE_COMMENT_NODE_REFERENCE_PAGES);
}
......
......@@ -58,12 +58,15 @@ define('EXPIRE_NODE_REFERENCE_PAGES' , FALSE);
define('EXPIRE_NODE_CUSTOM' , FALSE);
define('EXPIRE_COMMENT_FRONT_PAGE' , FALSE);
define('EXPIRE_COMMENT_COMMENT_PAGE' , TRUE);
define('EXPIRE_COMMENT_REFERENCE_PAGES' , FALSE);
define('EXPIRE_COMMENT_NODE_PAGE' , TRUE);
define('EXPIRE_COMMENT_NODE_TERM_PAGES' , FALSE);
define('EXPIRE_COMMENT_NODE_REFERENCE_PAGES', FALSE);
define('EXPIRE_COMMENT_CUSTOM' , FALSE);
define('EXPIRE_USER_FRONT_PAGE' , FALSE);
define('EXPIRE_USER_USER_PAGE' , TRUE);
define('EXPIRE_USER_TERM_PAGES' , FALSE);
define('EXPIRE_USER_REFERENCE_PAGES' , FALSE);
define('EXPIRE_USER_CUSTOM' , FALSE);
define('EXPIRE_VOTINGAPI_ENTITY' , FALSE);
define('EXPIRE_VOTINGAPI_ENTITY_PAGE' , FALSE);
......
......@@ -99,27 +99,34 @@ class ExpireAPI {
}
/**
* Find all taxonomy terms in node fields and build urls for them.
* Find all taxonomy terms in the entity fields and build urls for them.
*
* @param $node
* Node object.
* @param $entity
* Entity object.
*
* @param $entity_type
* Type of entity.
*
* @return array
* Term urls that should be flushed.
*/
public static function expireNodeTermPages($node) {
public static function expireTermPages($entity, $entity_type) {
$terms = array();
$field_info = field_info_fields();
$field_instances = field_info_instances('node', $node->type);
list($id, $vid, $bundle_name) = entity_extract_ids($entity_type, $entity);
$field_instances = field_info_instances($entity_type, $bundle_name);
foreach ($field_instances as $field_name => $field_instance) {
// Load information about field.
$field_info = field_info_field($field_name);
foreach ($field_instances as $name => $instance) {
if ($field_info[$name]['type'] == 'taxonomy_term_reference') {
$new_terms = field_get_items('node', $node, $name);
if ($field_info['type'] == 'taxonomy_term_reference') {
$new_terms = field_get_items($entity_type, $entity, $field_name);
if (is_array($new_terms) && !empty($new_terms)) {
$terms = array_merge($new_terms, $terms);
}
$old_terms = isset($node->original) && !empty($node->original) ? field_get_items('node', $node->original, $name) : array();
$old_terms = !empty($entity->original) ? field_get_items($entity_type, $entity->original, $field_name) : array();
if (is_array($old_terms) && !empty($old_terms)) {
$terms = array_merge($old_terms, $terms);
}
......@@ -135,36 +142,84 @@ class ExpireAPI {
}
/**
* Find all node references in node fields and build urls for them.
* Find all entity references in fields and build urls for them.
*
* @param $node
* Node object.
* @param $entity
* Entity object.
*
* @param $entity_type
* Type of entity.
*
* @return array
* Node urls that should be flushed.
* Entity references' urls that should be flushed.
*/
public static function expireNodeReferences($node) {
public static function expireReferences($entity, $entity_type) {
$field_references = array();
list($id, $vid, $bundle_name) = entity_extract_ids($entity_type, $entity);
// Get all fields from current entity type.
$field_instances = field_info_instances($entity_type, $bundle_name);
foreach ($field_instances as $field_name => $field_instance) {
// Load information about field.
$field_info = field_info_field($field_name);
if (in_array($field_info['type'], array('node_reference', 'user_reference', 'entityreference'))) {
if (in_array($field_info['type'], array('node_reference', 'user_reference'))) {
$field_value_key = $field_info['type'] == 'node_reference' ? 'nid' : 'uid';
$field_entity_type = $field_info['type'] == 'node_reference' ? 'node' : 'user';
}
else {
$field_value_key = 'target_id';
$field_entity_type = $field_info['settings']['target_type'];
}
// Get new values from reference field.
$new_references = field_get_items($entity_type, $entity, $field_name);
$references = array();
$field_info = field_info_fields();
$field_instances = field_info_instances('node', $node->type);
// Get old values from reference field.
$old_references = !empty($entity->original) ? field_get_items($entity_type, $entity->original, $field_name) : array();
foreach ($field_instances as $name => $instance) {
if ($field_info[$name]['type'] == 'node_reference') {
$new_references = field_get_items('node', $node, $name);
if (is_array($new_references) && !empty($new_references)) {
$references = array_merge($new_references, $references);
$references = array();
if (!empty($new_references) && is_array($new_references)) {
$references = array_merge($references, $new_references);
}
$old_references = isset($node->original) && !empty($node->original) ? field_get_items('node', $node->original, $name) : array();
if (is_array($old_references) && !empty($old_references)) {
$references = array_merge($old_references, $references);
if (!empty($old_references) && is_array($old_references)) {
$references = array_merge($references, $old_references);
}
foreach ($references as $reference) {
$field_entity_id = isset($reference[$field_value_key]) ? $reference[$field_value_key] : FALSE;
$field_references[$field_entity_type . $field_entity_id] = array(
'entity_type' => $field_entity_type,
'entity_id' => $field_entity_id,
);
}
}
}
// Collect urls of referenced entities.
$urls = array();
foreach ($references as $reference) {
$urls['reference-' . $reference['nid']] = 'node/' . $reference['nid'];
foreach ($field_references as $field_reference) {
// Load entity.
$field_entity = entity_load_single($field_reference['entity_type'], $field_reference['entity_id']);
if (empty($field_entity)) {
continue;
}
// Get entity uri;
$field_entity_uri = entity_uri($field_reference['entity_type'], $field_entity);
if (empty($field_entity_uri['path'])) {
continue;
}
$urls['reference-' . $field_reference['entity_type'] . '-' . $field_reference['entity_id']] = $field_entity_uri['path'];
}
return $urls;
......
......@@ -83,10 +83,17 @@ class ExpireComment implements ExpireInterface {
$expire_urls = array_merge($expire_urls, $urls);
}
// Expire comment's references.
$expire_references = variable_get('expire_comment_reference_pages' . $variable_suffix, EXPIRE_COMMENT_REFERENCE_PAGES);
if ((module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) && $expire_references) {
$urls = ExpireAPI::expireReferences($comment, 'comment');
$expire_urls = array_merge($expire_urls, $urls);
}
// Expire comment's node references.
$expire_node_references = variable_get('expire_comment_node_reference_pages' . $variable_suffix, EXPIRE_COMMENT_NODE_REFERENCE_PAGES);
if (module_exists('node_reference') && $expire_node_references) {
$urls = ExpireAPI::expireNodeReferences($node);
if ((module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) && $expire_node_references) {
$urls = ExpireAPI::expireReferences($node, 'node');
$expire_urls = array_merge($expire_urls, $urls);
}
......@@ -101,6 +108,7 @@ class ExpireComment implements ExpireInterface {
// Flush page cache for expired urls.
ExpireAPI::executeExpiration($expire_urls, 'comment', $comment);
// Mark cache flushed as true, to avoid duplicate cache flushes in some cases.
$cache_flushed = TRUE;
}
......
......@@ -60,14 +60,14 @@ class ExpireNode implements ExpireInterface {
// Expire taxonomy term pages.
$expire_term_pages = variable_get('expire_node_term_pages' . $variable_suffix, EXPIRE_NODE_TERM_PAGES);
if (module_exists('taxonomy') && $expire_term_pages) {
$urls = ExpireAPI::expireNodeTermPages($node);
$urls = ExpireAPI::expireTermPages($node, 'node');
$expire_urls = array_merge($expire_urls, $urls);
}
// Expire node reference's pages.
$expire_node_references = variable_get('expire_node_reference_pages' . $variable_suffix, EXPIRE_NODE_REFERENCE_PAGES);
if (module_exists('node_reference') && $expire_node_references) {
$urls = ExpireAPI::expireNodeReferences($node);
if ((module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) && $expire_node_references) {
$urls = ExpireAPI::expireReferences($node, 'node');
$expire_urls = array_merge($expire_urls, $urls);
}
......
......@@ -10,7 +10,7 @@ class ExpireUser implements ExpireInterface {
/**
* Executes expiration actions for user.
*
* @param $user
* @param $account
* User object.
*
* @param $action
......@@ -19,16 +19,16 @@ class ExpireUser implements ExpireInterface {
* @param $skip_action_check
* Shows whether should we check executed action or just expire node.
*/
function expire($user, $action, $skip_action_check = FALSE) {
function expire($account, $action, $skip_action_check = FALSE) {
if (empty($user->uid)) {
if (empty($account->uid)) {
return;
}
$enabled_actions = variable_get('expire_user_actions', array());
$enabled_actions = array_filter($enabled_actions);
// Stop further expiration if executed action is not selected by admin.
// Stop further expiration if executed action is not selected by admin.
if (!in_array($action, $enabled_actions) && !$skip_action_check) {
return;
}
......@@ -44,19 +44,33 @@ class ExpireUser implements ExpireInterface {
// Expire user page.
$expire_user_page = variable_get('expire_user_user_page', EXPIRE_USER_USER_PAGE);
if ($expire_user_page) {
$expire_urls['user-' . $user->uid] = 'user/' . $user->uid;
$expire_urls['user-' . $account->uid] = 'user/' . $account->uid;
}
// Expire taxonomy term pages.
$expire_term_pages = variable_get('expire_user_term_pages', EXPIRE_USER_TERM_PAGES);
if (module_exists('taxonomy') && $expire_term_pages) {
$urls = ExpireAPI::expireTermPages($account, 'user');
$expire_urls = array_merge($expire_urls, $urls);
}
// Expire user reference's pages.
$expire_references = variable_get('expire_user_reference_pages', EXPIRE_USER_REFERENCE_PAGES);
if ((module_exists('node_reference') || module_exists('user_reference') || module_exists('entityreference')) && $expire_references) {
$urls = ExpireAPI::expireReferences($account, 'user');
$expire_urls = array_merge($expire_urls, $urls);
}
// Expire custom pages.
$expire_custom = variable_get('expire_user_custom', EXPIRE_USER_CUSTOM);
if ($expire_custom) {
$pages = variable_get('expire_user_custom_pages');
$urls = ExpireAPI::expireCustomPages($pages, array('user' => $user));
$urls = ExpireAPI::expireCustomPages($pages, array('user' => $account));
$expire_urls = array_merge($expire_urls, $urls);
}
// Flush page cache for expired urls.
ExpireAPI::executeExpiration($expire_urls, 'user', $user);
ExpireAPI::executeExpiration($expire_urls, 'user', $account);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment