function _pmteam_beforesave in Drupal PM (Project Management) 7
Function to be called internally before saving Project Management Team nodes
2 calls to _pmteam_beforesave()
- pmteam_insert in pmteam/
pmteam.module - Implements hook_insert().
- pmteam_update in pmteam/
pmteam.module - Implements hook_update().
File
- pmteam/
pmteam.module, line 285 - Functionality for the Project Management Team module Organized into the following sections:
Code
function _pmteam_beforesave(&$node) {
$i = 1;
$variable = 'members_array_' . $i;
// unsetting the $node->members_array to handle deleting of members.
$node->members_array = array();
while (isset($node->{$variable})) {
$per_result = db_select('node', 'n')
->fields('n', array(
'title',
))
->condition('n.nid', $node->{$variable})
->execute();
$title = $per_result
->fetchObject();
if (!empty($title)) {
$node->members_array[$node->{$variable}] = $title->title;
}
$i++;
$variable = 'members_array_' . $i;
}
if (isset($node->members_array)) {
if (array_key_exists(0, $node->members_array)) {
unset($node->members_array[0]);
}
$node->members = serialize($node->members_array);
}
}