function _node_expire_node_prepare in Node expire 8
Same name and namespace in other branches
- 7 node_expire.nodeapi.inc \_node_expire_node_prepare()
Implements hook_node_prepare().
2 calls to _node_expire_node_prepare()
- node_expire_node_prepare_form in ./
node_expire.module - Implements hook_node_prepare().
- _node_expire_node_update_insert in ./
node_expire.nodeapi.inc - Implements hook_node_update() and hook_node_insert().
File
- ./
node_expire.nodeapi.inc, line 57 - Node API integration.
Code
function _node_expire_node_prepare(&$ntype, \Drupal\node\NodeInterface $node) {
// To prevent default value 1969-12-31 check also $ntypes['default'].
if (!isset($node->expire) && $ntype['default']) {
$node->expire = format_date(strtotime($ntype['default']), 'custom', NODE_EXPIRE_FORMAT);
}
// This gives a way to users without edit exipration permission
// to update nodes with default expiration.
if (isset($node->expire) && !\Drupal::currentUser()
->hasPermission('edit node expire')) {
$node->expire = format_date(strtotime($ntype['default']), 'custom', NODE_EXPIRE_FORMAT);
}
}