Created
October 27, 2010 21:11
-
-
Save pifantastic/650006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Erase a CCK text field from a node. | |
*/ | |
function el_commons_wipe_cck_text_field(&$node, $field_name) { | |
if (!isset($node->$field_name)) { | |
return; | |
} | |
foreach ((array) $node->$field_name as $i => $field) { | |
$node->$field_name[$i]['value'] = NULL; | |
} | |
} | |
/** | |
* Erase a CCK node reference field from a node. | |
*/ | |
function el_commons_wipe_cck_nodereference_field(&$node, $field_name) { | |
if (!isset($node->$field_name)) { | |
return; | |
} | |
foreach ((array) $node->$field_name as $i => $field) { | |
$referenced_node = node_load($field['nid']); | |
if ($referenced_node->uid != $node->uid) { | |
$node->$field_name[$i] = NULL; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment