private static function NodeHookHandler::doNodeUpdateInsert in Node expire 7.2
Implements hook_node_update() and hook_node_insert().
2 calls to NodeHookHandler::doNodeUpdateInsert()
- NodeHookHandler::hookNodeInsert in src/
Module/ Hook/ NodeHookHandler.php - Implements hook_nodeapi_insert().
- NodeHookHandler::hookNodeUpdate in src/
Module/ Hook/ NodeHookHandler.php - Implements hook_nodeapi_update().
File
- src/
Module/ Hook/ NodeHookHandler.php, line 194 - NodeHookHandler class.
Class
- NodeHookHandler
- NodeHookHandler class.
Namespace
Drupal\node_expire\Module\HookCode
private static function doNodeUpdateInsert(&$ntype, $node) {
$handle_content_expiry = ConfigHandler::getHandleContentExpiry();
if ($handle_content_expiry == 0) {
// Old (legacy) style of processing.
// Has the expiration been removed, or does it exist?
if (isset($node->expire)) {
DbHandler::deleteNodeExpire($node->nid);
// Should we create a new record?
if ($node->expire) {
if (strtotime($node->expire)) {
$node->expire = strtotime($node->expire);
}
$node->expired = FALSE;
drupal_write_record('node_expire', $node);
}
}
}
else {
if (!isset($ntype['enabled']) || !$ntype['enabled']) {
return;
}
// Create a proper $node_expire stdClass.
$node_expire = new \stdClass();
$node_expire->nid = $node->nid;
// For compatibility with Node Clone module.
// Set default $node->expire value if it is not set.
if (!isset($node->expire)) {
// _node_expire_node_prepare($ntype, $node);
self::doNodePrepare($ntype, $node);
}
// Expire.
$date_expire = TimestampUtils::dateStrToDb($node->expire, $ntype);
$node_expire->expire = $date_expire;
// Lastnotify.
if (isset($node->lastnotify)) {
$node_expire->lastnotify = $node->lastnotify;
}
else {
// Default value.
$node_expire->lastnotify = 0;
}
// Expired.
if (isset($node->expired)) {
$node_expire->new_record = 0;
$node_expire->expired = $node->expired;
if ($node_expire->expire >= NODE_EXPIRE_NO_EXPIRE) {
// No expiry for this node.
$node_expire->expired = 0;
}
}
elseif (isset($node->original->expired)) {
// For VBO (Views Bulk Operations) compatibility.
// With VBO it is necessary to get all Node expire information
// from $node->original instead of $node.
$node_expire->new_record = 0;
$node_expire->expired = $node->original->expired;
// Also get other Node expire values.
// Expire.
$date_expire = TimestampUtils::dateStrToDb($node->original->expire, $ntype);
$node_expire->expire = $date_expire;
// Lastnotify.
if (isset($node->original->lastnotify)) {
$node_expire->lastnotify = $node->original->lastnotify;
}
else {
// Default value.
$node_expire->lastnotify = 0;
}
if ($node_expire->expire >= NODE_EXPIRE_NO_EXPIRE) {
// No expiry for this node.
$node_expire->expired = 0;
}
}
else {
// No record in the database yet.
$node_expire->new_record = 1;
// Default value.
$node_expire->expired = 0;
}
// Write the record.
DbHandler::writeRecord($node_expire, $node->nid);
}
}