You are here

function _editablefields_node_load_and_update in Editable Fields 5.2

Same name and namespace in other branches
  1. 5.3 editablefields.module \_editablefields_node_load_and_update()
  2. 5 editablefields.module \_editablefields_node_load_and_update()

handle editable field forms, and return back if there are editable fields

1 call to _editablefields_node_load_and_update()
_handle_editablefield_form_input in ./editablefields.module

File

./editablefields.module, line 49

Code

function _editablefields_node_load_and_update($nid, $oldnode = NULL) {
  $node = node_load($nid);
  if (node_access("update", $node)) {
    $nodeupdate = FALSE;
    if ($_POST['op']) {
      foreach ($_POST as $post => $value) {
        if (sscanf($post, "editablefield_%d_%s", $nid, $fieldname) == 2) {
          if ($nid == $node->nid) {
            if ($node->{$fieldname} != $value) {
              $node->{$fieldname} = $oldnode ? $oldnode->{$fieldname} : $value;
              $nodeupdate = TRUE;
            }
          }
        }
      }
    }
  }
  return $nodeupdate ? $node : NULL;
}